Maxim Kizub
10/24/2019, 12:33 PMclass Wrapper<T> (val value: T) : T by value ?diesieben07
10/24/2019, 12:37 PMT just becomes Any?.
And even if they weren't erased, the compiler would have to emit a new class for every T that's used, because superclasses cannot be dynamic on the JVM.Maxim Kizub
10/24/2019, 1:02 PMmarstran
10/24/2019, 1:06 PMMaxim Kizub
10/24/2019, 1:17 PMinstance with instance.value.marstran
10/24/2019, 1:33 PMWrapper a subclass of T, which means that every public method in the class T will be inherited by Wrapper.marstran
10/24/2019, 1:33 PMmarstran
10/24/2019, 1:34 PMT is.Maxim Kizub
10/24/2019, 1:43 PMwr: Wrapper<Int>(3); wr.coerceAtLeast(5) should be just replaced by compiler with wr.value.coerceAtLeast(5)diesieben07
10/24/2019, 1:48 PMMaxim Kizub
10/24/2019, 1:53 PMdiesieben07
10/24/2019, 1:55 PMinterface Bar {
fun barMethod(): String
}
class BarImpl : Bar {
override fun barMethod() = "Hello from BarImpl"
}
class BarByDelegate(barImpl: BarImpl) : Bar by barImpl
// becomes:
class BarByDelegate(val barImpl: BarImpl) : Bar {
override fun barMethod() = barImpl.barMethod()
}diesieben07
10/24/2019, 1:55 PMBarByDelegate implements Bar normally.Maxim Kizub
10/24/2019, 2:03 PMstreetsofboston
10/24/2019, 2:54 PM