diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/t9105.check | 14 | ||||
-rw-r--r-- | test/files/run/t9390c.scala | 21 | ||||
-rw-r--r-- | test/files/run/t9390d.scala | 12 |
3 files changed, 35 insertions, 12 deletions
diff --git a/test/files/jvm/t9105.check b/test/files/jvm/t9105.check index 48439ee004..9447e0cf29 100644 --- a/test/files/jvm/t9105.check +++ b/test/files/jvm/t9105.check @@ -1,18 +1,8 @@ -#partest -Ydelambdafy:inline -(class C$$anonfun$1$A$1,class C$$anonfun$1,null) -(class C$$anonfun$1$B$1,class C$$anonfun$1,private final java.lang.Object C$$anonfun$1.m$1()) -(class C$$anonfun$1$C$1,class C$$anonfun$1,null) -(class C$$anonfun$1$$anonfun$2$D$1,class C$$anonfun$1$$anonfun$2,null) -(class C$$anonfun$met$1$E$1,class C$$anonfun$met$1,null) -(class C$$anonfun$met$1$F$1,class C$$anonfun$met$1,private final java.lang.Object C$$anonfun$met$1.m$2()) -(class C$$anonfun$met$1$G$1,class C$$anonfun$met$1,null) -(class C$$anonfun$met$1$$anonfun$3$H$1,class C$$anonfun$met$1$$anonfun$3,null) -#partest !-Ydelambdafy:inline (class C$A$1,class C,null) -(class C$B$1,class C,private final java.lang.Object C.m$1()) +(class C$B$1,class C,private static final java.lang.Object C.m$1()) (class C$C$1,class C,null) (class C$D$1,class C,null) (class C$E$1,class C,public scala.Function0 C.met()) -(class C$F$1,class C,private final java.lang.Object C.m$2()) +(class C$F$1,class C,private static final java.lang.Object C.m$2()) (class C$G$1,class C,public scala.Function0 C.met()) (class C$H$1,class C,public scala.Function0 C.met()) diff --git a/test/files/run/t9390c.scala b/test/files/run/t9390c.scala new file mode 100644 index 0000000000..db39da57cd --- /dev/null +++ b/test/files/run/t9390c.scala @@ -0,0 +1,21 @@ +class C { // C is not serializable + def foo = { + { (x: Any) => new Object {} } + } +} +object Test { + def main(args: Array[String]): Unit = { + val c = new C + val f = c.foo + val f1 = serializeDeserialize(f) + } + + def serializeDeserialize[T <: AnyRef](obj: T): T = { + import java.io._ + val buffer = new ByteArrayOutputStream + val out = new ObjectOutputStream(buffer) + out.writeObject(obj) + val in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray)) + in.readObject.asInstanceOf[T] + } +} diff --git a/test/files/run/t9390d.scala b/test/files/run/t9390d.scala new file mode 100644 index 0000000000..3c5de3abf7 --- /dev/null +++ b/test/files/run/t9390d.scala @@ -0,0 +1,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. + } +} |