Joshua Hansen
12/02/2024, 11:45 PMthing
to a val
?
interface A
interface B {
var thing: A
}
class Foo : A
class Bar(
override var thing: Foo
) : B
When thing
is a var
, I get this error:
Type of 'thing' doesn't match the type of the overridden 'var' property 'var thing: A' defined in '/B'.
PHondogo
12/03/2024, 12:11 AMPHondogo
12/03/2024, 12:14 AMoverride var thing: Foo
// fun get() : Foo
// fun set(f: Foo)
Joshua Hansen
12/03/2024, 12:31 AMLandry Norris
12/03/2024, 12:32 AMclass Baz: A
val bar = Bar(Foo())
(bar as B).thing = Baz()
And now you've assigned a Baz to a Foo, despite them not being compatible