Vampire
06/17/2022, 3:24 PMJoffrey
06/17/2022, 3:26 PMJoffrey
06/17/2022, 3:26 PMVampire
06/17/2022, 3:29 PMJoffrey
06/17/2022, 3:32 PMJoffrey
06/17/2022, 3:35 PMChild : Parent
and declare Child.foo()
and Parent.foo()
, you will be able to call the "overriden" child function only on variables that are statically known to be of type Child
.
Child().foo() // calls the Child extension
val child: Parent = Child()
child.foo() // calls the Parent extension
Joffrey
06/17/2022, 3:36 PMVampire
06/17/2022, 3:37 PMVampire
06/17/2022, 3:38 PMJoffrey
06/17/2022, 3:40 PMA library defines an extension function and uses it and I need it to do something differentAh. Assuming it's a JVM lib, this compiled down to a static function in the bytecode, so unless you manipulate that lib in some way, you're out of luck
Joffrey
06/17/2022, 3:42 PMVampire
06/17/2022, 3:49 PMJoffrey
06/17/2022, 3:51 PMNothing prevents nasty hacks if you are desparate enoughTrue in a way, but ideally the nasty hack will be so hard that it will become more viable to contribute a change to the library code (when possible of course..)
ephemient
06/17/2022, 4:02 PMJoffrey
06/17/2022, 4:05 PMVampire
06/17/2022, 4:07 PM