y
01/17/2024, 8:53 AMclass Concrete {
override val name: String,
// ...
} : FooInterface, BarAbstractClass<SomeType>
interface FooInterface {
val name: String
// ...
}
abstract class BarAbstractClass<T: SomeTypeBound>() {
abstract val name: String
// ...
}
which name does Concrete have? does it have two different ones?Jaap Beetstra
01/17/2024, 8:59 AMname. If you refer to obj.name it doesn’t matter if obj is of type Concrete, FooInterface, or BarAbstractClass. If it’s the same instance, it’s the same name.Klitos Kyriacou
01/17/2024, 9:00 AMname, with a single getter that overrides the abstract getters of both the interface and the abstract class.y
01/17/2024, 9:00 AMy
01/17/2024, 9:02 AMFooInterface, which in fact only has a single field name, is probably there because it exposes an interface (heh) that allows accessing the deriving class's name without specifying the type bound when taking or returning a Concrete.y
01/17/2024, 9:04 AMConcrete also inherits from more interfaces.
could we have achieved the same result by taking/returning a BarAbstractClass<*> instead?Daniel Pitts
01/17/2024, 4:34 PM