CFrei
04/03/2020, 8:47 AMclass A
class B
open class C
open class D
val a: A = A()
val c: C = C()
a is B // <-- as expected: error
c is D // <-- not expected: no error
As expected I get an "Incompatible types B and A"-error at compile time for the line a is B. But not for the next line c is D. Is there any chance that c could be of type D or is this a missing feature in the compiler? Does anyone have an example?diesieben07
04/03/2020, 8:49 AMD as a superclass of C.diesieben07
04/03/2020, 8:50 AMB is not open (i.e. final).CFrei
04/03/2020, 8:50 AMCFrei
04/03/2020, 8:54 AMdiesieben07
04/03/2020, 8:58 AMclass C : D()
Now c is D is true.diesieben07
04/03/2020, 8:59 AMMichael de Kaste
04/03/2020, 9:33 AMis keyword probably only tests on open-ness of a class. Even though we can logically conclude c is D to not be the case in this specific instance. nothing can is a final class, and thus you get an error