diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/delambdafy_t6028.check | 2 | ||||
-rw-r--r-- | test/files/run/t6028.check | 2 | ||||
-rw-r--r-- | test/files/run/t9697.check | 1 | ||||
-rw-r--r-- | test/files/run/t9697.scala | 204 | ||||
-rw-r--r-- | test/files/run/t9920.scala | 17 | ||||
-rw-r--r-- | test/files/run/t9920b.scala | 17 | ||||
-rw-r--r-- | test/files/run/t9920c.scala | 21 | ||||
-rw-r--r-- | test/files/run/t9920d.scala | 14 |
8 files changed, 276 insertions, 2 deletions
diff --git a/test/files/run/delambdafy_t6028.check b/test/files/run/delambdafy_t6028.check index 6a15b3b003..7b319c92dd 100644 --- a/test/files/run/delambdafy_t6028.check +++ b/test/files/run/delambdafy_t6028.check @@ -47,7 +47,7 @@ package <empty> { final <stable> private[this] def MethodLocalObject$1(barParam$1: String, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) T.this.MethodLocalObject$lzycompute$1(barParam$1, MethodLocalObject$module$1); - MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]() + (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type](): T#MethodLocalObject$2.type) }; final <artifact> private[this] def $anonfun$tryy$1(tryyParam$1: String, tryyLocal$1: runtime.ObjectRef): Unit = try { tryyLocal$1.elem = tryyParam$1 diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 80f8698ecf..903ea3b753 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -59,7 +59,7 @@ package <empty> { final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) T.this.MethodLocalObject$lzycompute$1(barParam$1, MethodLocalObject$module$1); - MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]() + (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type](): T#MethodLocalObject$2.type) }; @SerialVersionUID(value = 0) final <synthetic> class $anonfun$tryy$1 extends scala.runtime.AbstractFunction0$mcV$sp with Serializable { def <init>($outer: T, tryyParam$1: Int, tryyLocal$1: runtime.IntRef): <$anon: Function0> = { diff --git a/test/files/run/t9697.check b/test/files/run/t9697.check new file mode 100644 index 0000000000..2a4f01c14f --- /dev/null +++ b/test/files/run/t9697.check @@ -0,0 +1 @@ +warning: there were 9 deprecation warnings (since 2.11.0); re-run with -deprecation for details diff --git a/test/files/run/t9697.scala b/test/files/run/t9697.scala new file mode 100644 index 0000000000..eb8e44f8fc --- /dev/null +++ b/test/files/run/t9697.scala @@ -0,0 +1,204 @@ +object log { + val b = new collection.mutable.StringBuilder + def apply(s: Any): Unit = b.append(s) + def check(s: String) = { + val bs = b.toString + assert(s == bs, bs) + b.clear() + } +} + +package t9697 { + abstract class WA extends DelayedInit { + override def delayedInit(x: => Unit): Unit = x + val waField = "4" + } + + class C { + def b(s: String) = log(s) + val cField = "1" + + { + val dummyLocal = "2" + new WA { + val anonField = "3" + b(cField) + b(dummyLocal) + b(anonField) + b(waField) + } + } + } +} + +package sd229 { + class Broken { + def is(ee: AnyRef) = { + new Delayed { + log(ee) + } + } + } + + class Delayed extends DelayedInit { + def delayedInit(x: => Unit): Unit = x + } +} + + +// already fixed in 2.11.8, crashes in 2.10.6 +package t4683a { + class A { log("a") } + class B { log("b") } + class Bug extends DelayedInit { + log("bug") + def foo(a: A): B = new B + def delayedInit(init: => Unit): Unit = init + } +} + +// already fixed in 2.12.0-RC1, crashes in 2.11.8 +package t4683b { + class Entity extends DelayedInit { + def delayedInit(x: => Unit): Unit = x + + class Field + + protected def EntityField[T <: Entity: reflect.ClassTag] = new Field + + def find[T <: Entity: reflect.ClassTag] { + Nil.map(dbo => { + class EntityHolder extends Entity { + val entity = EntityField[T] + } + }) + log("find") + } + } +} + +package t4683c { + trait T extends DelayedInit { + def delayedInit(body: => Unit) = { + log("init") + body + } + } +} + +package t4683d { + class C extends DelayedInit { + def delayedInit(body: => Unit): Unit = body + } + class Injector { + def test: Object = { + val name = "k" + class crash extends C { + log(name) + } + new crash() + } + } +} + +package t4683e { + class DelayedInitTest { + def a = log("uh") + class B extends DelayedInit { + a + def delayedInit(body: => Unit): Unit = body + } + } +} + +package t4683f { + class Foo extends DelayedInit { + log("fooInit") + def delayedInit(newBody: => Unit): Unit = { + log("delayedInit") + inits = { + val f = () => newBody + if (inits == null) { + log("initsNull") + List(f) + } else + f :: inits + } + } + def foo = log("foo") + var inits: List[() => Unit] = Nil + } + + class Bar extends Foo { + log("barInit") + def bar = foo + def newBaz: Foo = new Baz + private class Baz extends Foo { + log("bazInit") + bar + } + } +} + +package t4683g { + trait MatExpWorld { self => + class T extends Runner { val expWorld: self.type = self } + } + + trait Runner extends DelayedInit { + def delayedInit(init: => Unit): Unit = init + val expWorld: MatExpWorld + } +} + + +object Test extends App { + new t9697.C() + log.check("1234") + + new sd229.Broken().is("hi") + log.check("hi") + + val a: t4683a.A = new t4683a.A + var b: t4683a.B = null + new t4683a.Bug { + val b = foo(a) + } + log.check("abugb") + + new t4683b.Entity().find[t4683b.Entity] + log.check("find") + + val f = (p1: Int) => new t4683c.T { log(p1) } + f(5) + log.check("init5") + + new t4683d.Injector().test + log.check("k") + + val dit = new t4683e.DelayedInitTest() + new dit.B() + log.check("uh") + + val fuu = new t4683f.Foo + log.check("delayedInitinitsNull") + fuu.inits.foreach(_.apply()) + log.check("fooInit") + assert(fuu.inits == Nil) // the (delayed) initializer of Foo sets the inits field to Nil + + val brr = new t4683f.Bar + log.check("delayedInitinitsNulldelayedInit") // delayedInit is called once for each constructor + brr.inits.foreach(_.apply()) + log.check("barInitfooInit") + assert(brr.inits == Nil) + + val bzz = brr.newBaz + log.check("delayedInitinitsNulldelayedInit") + bzz.inits.foreach(_.apply()) + log.check("bazInitfoofooInit") + assert(bzz.inits == Nil) + + val mew = new t4683g.MatExpWorld { } + val mt = new mew.T + assert(mt.expWorld == mew) +} diff --git a/test/files/run/t9920.scala b/test/files/run/t9920.scala new file mode 100644 index 0000000000..5dc32e99b7 --- /dev/null +++ b/test/files/run/t9920.scala @@ -0,0 +1,17 @@ +class C0 +trait T { self: C0 => + def test = { + object Local + + class C1 { + Local + } + new C1() + } +} + +object Test extends C0 with T { + def main(args: Array[String]): Unit = { + test + } +} diff --git a/test/files/run/t9920b.scala b/test/files/run/t9920b.scala new file mode 100644 index 0000000000..fab196b669 --- /dev/null +++ b/test/files/run/t9920b.scala @@ -0,0 +1,17 @@ +class C0 +trait T { + def test = { + object Local + + class C1 { + Local + } + new C1() + } +} + +object Test extends C0 with T { + def main(args: Array[String]): Unit = { + test + } +} diff --git a/test/files/run/t9920c.scala b/test/files/run/t9920c.scala new file mode 100644 index 0000000000..9541dc650a --- /dev/null +++ b/test/files/run/t9920c.scala @@ -0,0 +1,21 @@ +class C0 +trait T { self: C0 => + def test = { + object Local + + class C2 { + class C1 { + Local + } + T.this.toString + new C1 + } + new C2() + } +} + +object Test extends C0 with T { + def main(args: Array[String]): Unit = { + test + } +} diff --git a/test/files/run/t9920d.scala b/test/files/run/t9920d.scala new file mode 100644 index 0000000000..debc99e199 --- /dev/null +++ b/test/files/run/t9920d.scala @@ -0,0 +1,14 @@ +class C { object O } +trait T { _: C => + def foo { + class D { O } + new D + } +} + + +object Test extends C with T { + def main(args: Array[String]): Unit = { + foo + } +} |