It's more easily explained in code:
class Bippy {
val x = 42
class Boppy {
val y = "hello world"
}
val bop = new Boppy
}
val bip = new Bippy
val bop: Bippy#Boppy = bip.bop
bop
is then supplied to another method, which needs to find the value x
from the containing instance of Bippy
. What's the magic incantation to do so?
The instance bop
comes from code that I don't control, so adding new methods to Boppy
isn't an option here.
You can't. At least not without cheating. Here's how to cheat.
def getOuter(bop : Bippy#Boppy) =
bop.asInstanceOf[{def Bippy$Boppy$$$outer() : Bippy}].Bippy$Boppy$$$outer()
Obviously that's very dependent on details of how scalac works today and no guarantees that it will work tomorrow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With