package Objects.Traits
fun main(args : Array<String>){
var adam = Cowboy(“Adam”)
adam.does()
}
trait Shooting {
abstract var name : String
fun does(){
print(“$name can Shoot”)
}
}
class Cowboy (name : String): Shooting{
override var name = name
}
According to this http://blog.jetbrains.com/kotlin/2011/08/multiple-inheritance-part-2-possible-directions/, above code should work. Instead they generate
``
Exception in thread “main” java.lang.IllegalAccessError: Objects.Traits.Cowboy.getName()Ljava/lang/String;
at Objects.Traits.Shooting$$TImpl.does(Traits.kt:11)
at Objects.Traits.Cowboy.does(Traits.kt)
at Objects.Traits.namespace.main(Traits.kt:5)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)