blob: 3c5de3abf73dc386eb5b5e8aabd8e9633a22cf66 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
|
class C { // C is not serializable
def foo: () => Any = {
{ () => class UseOuterInConstructor { C.this.toString }; new UseOuterInConstructor : Any}
}
}
object Test {
def main(args: Array[String]): Unit = {
val c = new C
val f = c.foo
f() // Doesn't NPE, as we didn't elide the outer instance in the constructor call.
}
}
|