diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-11-07 10:56:47 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-11-07 10:56:47 -0800 |
commit | e72c11e18062b4e281cc38fb7727b3bd144c8594 (patch) | |
tree | c73549ee81ec9aacab999fc68673133940d5ae26 /test/files | |
parent | bb02fb350f7ec4aefcc830fec36a964ae45cfdd4 (diff) | |
parent | ef995ac6b4030e3cd10e487d414c941e5794666f (diff) | |
download | scala-e72c11e18062b4e281cc38fb7727b3bd144c8594.tar.gz scala-e72c11e18062b4e281cc38fb7727b3bd144c8594.tar.bz2 scala-e72c11e18062b4e281cc38fb7727b3bd144c8594.zip |
Merge pull request #3081 from JamesIry/wip_delayed_delambdafy_cleanup
Delay delambdafication and put the lambda's body into the containing class
Diffstat (limited to 'test/files')
48 files changed, 450 insertions, 57 deletions
diff --git a/test/files/instrumented/inline-in-constructors.flags b/test/files/instrumented/inline-in-constructors.flags index c9b68d70dc..068318e8ac 100644 --- a/test/files/instrumented/inline-in-constructors.flags +++ b/test/files/instrumented/inline-in-constructors.flags @@ -1 +1 @@ --optimise +-optimise -Ydelambdafy:inline diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala index 5d213691df..1595b2c862 100644 --- a/test/files/jvm/future-spec/FutureTests.scala +++ b/test/files/jvm/future-spec/FutureTests.scala @@ -10,7 +10,7 @@ import scala.util.{Try,Success,Failure} -object FutureTests extends MinimalScalaTest { +class FutureTests extends MinimalScalaTest { /* some utils */ diff --git a/test/files/jvm/future-spec/PromiseTests.scala b/test/files/jvm/future-spec/PromiseTests.scala index 6e613bf3ec..49350586b8 100644 --- a/test/files/jvm/future-spec/PromiseTests.scala +++ b/test/files/jvm/future-spec/PromiseTests.scala @@ -9,7 +9,7 @@ import scala.runtime.NonLocalReturnControl import scala.util.{Try,Success,Failure} -object PromiseTests extends MinimalScalaTest { +class PromiseTests extends MinimalScalaTest { import ExecutionContext.Implicits._ val defaultTimeout = Inf diff --git a/test/files/jvm/future-spec/TryTests.scala b/test/files/jvm/future-spec/TryTests.scala index 5d1b9b84b4..01bb3c9d36 100644 --- a/test/files/jvm/future-spec/TryTests.scala +++ b/test/files/jvm/future-spec/TryTests.scala @@ -5,7 +5,7 @@ import scala.util.{Try,Success,Failure} -object TryTests extends MinimalScalaTest { +class TryTests extends MinimalScalaTest { class MyException extends Exception val e = new Exception("this is an exception") diff --git a/test/files/jvm/future-spec/main.scala b/test/files/jvm/future-spec/main.scala index 132263e2e8..697d0fe91f 100644 --- a/test/files/jvm/future-spec/main.scala +++ b/test/files/jvm/future-spec/main.scala @@ -10,9 +10,9 @@ import java.util.concurrent.{ TimeoutException, CountDownLatch, TimeUnit } object Test { def main(args: Array[String]) { - FutureTests.check() - PromiseTests.check() - TryTests.check() + (new FutureTests).check() + (new PromiseTests).check() + (new TryTests).check() } } diff --git a/test/files/jvm/t7006.check b/test/files/jvm/t7006.check index 7c99eba30c..6294b14d62 100644 --- a/test/files/jvm/t7006.check +++ b/test/files/jvm/t7006.check @@ -19,6 +19,7 @@ [running phase flatten on Foo_1.scala] [running phase mixin on Foo_1.scala] [running phase cleanup on Foo_1.scala] +[running phase delambdafy on Foo_1.scala] [running phase icode on Foo_1.scala] [running phase inliner on Foo_1.scala] [running phase inlinehandlers on Foo_1.scala] diff --git a/test/files/neg/delambdafy_t6260_method.check b/test/files/neg/delambdafy_t6260_method.check new file mode 100644 index 0000000000..f5cd6947d1 --- /dev/null +++ b/test/files/neg/delambdafy_t6260_method.check @@ -0,0 +1,13 @@ +delambdafy_t6260_method.scala:3: error: bridge generated for member method apply: (bx: Object)Object in class map$extension1 +which overrides method apply: (v1: Object)Object in trait Function1 +clashes with definition of the member itself; +both have erased type (bx: Object)Object + ((bx: Box[X]) => new Box(f(bx.x)))(this) + ^ +delambdafy_t6260_method.scala:8: error: bridge generated for member method apply: (bx: Object)Object in class map21 +which overrides method apply: (v1: Object)Object in trait Function1 +clashes with definition of the member itself; +both have erased type (bx: Object)Object + ((bx: Box[X]) => new Box(f(bx.x)))(self) + ^ +two errors found diff --git a/test/files/neg/delambdafy_t6260_method.flags b/test/files/neg/delambdafy_t6260_method.flags new file mode 100644 index 0000000000..48b438ddf8 --- /dev/null +++ b/test/files/neg/delambdafy_t6260_method.flags @@ -0,0 +1 @@ +-Ydelambdafy:method diff --git a/test/files/neg/delambdafy_t6260_method.scala b/test/files/neg/delambdafy_t6260_method.scala new file mode 100644 index 0000000000..93b5448227 --- /dev/null +++ b/test/files/neg/delambdafy_t6260_method.scala @@ -0,0 +1,17 @@ +class Box[X](val x: X) extends AnyVal { + def map[Y](f: X => Y): Box[Y] = + ((bx: Box[X]) => new Box(f(bx.x)))(this) +} + +object Test { + def map2[X, Y](self: Box[X], f: X => Y): Box[Y] = + ((bx: Box[X]) => new Box(f(bx.x)))(self) + + def main(args: Array[String]) { + val f = (x: Int) => x + 1 + val g = (x: String) => x + x + + map2(new Box(42), f) + new Box("abc") map g + } +} diff --git a/test/files/neg/t6231.flags b/test/files/neg/t6231.flags new file mode 100644 index 0000000000..ac96850b69 --- /dev/null +++ b/test/files/neg/t6231.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/neg/t6260.flags b/test/files/neg/t6260.flags new file mode 100644 index 0000000000..2349d8294d --- /dev/null +++ b/test/files/neg/t6260.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline diff --git a/test/files/neg/t6446-additional.check b/test/files/neg/t6446-additional.check index c91333830a..a87af2f1e5 100755 --- a/test/files/neg/t6446-additional.check +++ b/test/files/neg/t6446-additional.check @@ -21,18 +21,19 @@ superaccessors 6 add super accessors in traits and nested classes flatten 19 eliminate inner classes mixin 20 mixin composition cleanup 21 platform-specific cleanups, generate reflective calls - icode 22 generate portable intermediate code + delambdafy 22 remove lambdas + icode 23 generate portable intermediate code #partest -optimise - inliner 23 optimization: do inlining -inlinehandlers 24 optimization: inline exception handlers - closelim 25 optimization: eliminate uncalled closures - constopt 26 optimization: optimize null and other constants - dce 27 optimization: eliminate dead code - jvm 28 generate JVM bytecode - ploogin 29 A sample phase that does so many things it's kind of hard... - terminal 30 the last phase during a compilation run + inliner 24 optimization: do inlining +inlinehandlers 25 optimization: inline exception handlers + closelim 26 optimization: eliminate uncalled closures + constopt 27 optimization: optimize null and other constants + dce 28 optimization: eliminate dead code + jvm 29 generate JVM bytecode + ploogin 30 A sample phase that does so many things it's kind of hard... + terminal 31 the last phase during a compilation run #partest !-optimise - jvm 23 generate JVM bytecode - ploogin 24 A sample phase that does so many things it's kind of hard... - terminal 25 the last phase during a compilation run + jvm 24 generate JVM bytecode + ploogin 25 A sample phase that does so many things it's kind of hard... + terminal 26 the last phase during a compilation run #partest diff --git a/test/files/neg/t6446-missing.check b/test/files/neg/t6446-missing.check index b2d5ddd686..cd867289c3 100755 --- a/test/files/neg/t6446-missing.check +++ b/test/files/neg/t6446-missing.check @@ -22,16 +22,17 @@ superaccessors 6 add super accessors in traits and nested classes flatten 19 eliminate inner classes mixin 20 mixin composition cleanup 21 platform-specific cleanups, generate reflective calls - icode 22 generate portable intermediate code + delambdafy 22 remove lambdas + icode 23 generate portable intermediate code #partest !-optimise - jvm 23 generate JVM bytecode - terminal 24 the last phase during a compilation run + jvm 24 generate JVM bytecode + terminal 25 the last phase during a compilation run #partest -optimise - inliner 23 optimization: do inlining -inlinehandlers 24 optimization: inline exception handlers - closelim 25 optimization: eliminate uncalled closures - constopt 26 optimization: optimize null and other constants - dce 27 optimization: eliminate dead code - jvm 28 generate JVM bytecode - terminal 29 the last phase during a compilation run + inliner 24 optimization: do inlining +inlinehandlers 25 optimization: inline exception handlers + closelim 26 optimization: eliminate uncalled closures + constopt 27 optimization: optimize null and other constants + dce 28 optimization: eliminate dead code + jvm 29 generate JVM bytecode + terminal 30 the last phase during a compilation run #partest diff --git a/test/files/neg/t6446-show-phases.check b/test/files/neg/t6446-show-phases.check index 48d4f37b3e..3ae3f96ef2 100644 --- a/test/files/neg/t6446-show-phases.check +++ b/test/files/neg/t6446-show-phases.check @@ -21,16 +21,17 @@ superaccessors 6 add super accessors in traits and nested classes flatten 19 eliminate inner classes mixin 20 mixin composition cleanup 21 platform-specific cleanups, generate reflective calls - icode 22 generate portable intermediate code + delambdafy 22 remove lambdas + icode 23 generate portable intermediate code #partest !-optimise - jvm 23 generate JVM bytecode - terminal 24 the last phase during a compilation run + jvm 24 generate JVM bytecode + terminal 25 the last phase during a compilation run #partest -optimise - inliner 23 optimization: do inlining -inlinehandlers 24 optimization: inline exception handlers - closelim 25 optimization: eliminate uncalled closures - constopt 26 optimization: optimize null and other constants - dce 27 optimization: eliminate dead code - jvm 28 generate JVM bytecode - terminal 29 the last phase during a compilation run + inliner 24 optimization: do inlining +inlinehandlers 25 optimization: inline exception handlers + closelim 26 optimization: eliminate uncalled closures + constopt 27 optimization: optimize null and other constants + dce 28 optimization: eliminate dead code + jvm 29 generate JVM bytecode + terminal 30 the last phase during a compilation run #partest diff --git a/test/files/neg/t6666.flags b/test/files/neg/t6666.flags new file mode 100644 index 0000000000..2349d8294d --- /dev/null +++ b/test/files/neg/t6666.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline diff --git a/test/files/neg/t6666c.flags b/test/files/neg/t6666c.flags new file mode 100644 index 0000000000..2349d8294d --- /dev/null +++ b/test/files/neg/t6666c.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline diff --git a/test/files/neg/t7494-no-options.check b/test/files/neg/t7494-no-options.check index b5dc0e3d4f..e3316f590a 100644 --- a/test/files/neg/t7494-no-options.check +++ b/test/files/neg/t7494-no-options.check @@ -22,18 +22,19 @@ superaccessors 6 add super accessors in traits and nested classes flatten 19 eliminate inner classes mixin 20 mixin composition cleanup 21 platform-specific cleanups, generate reflective calls - icode 22 generate portable intermediate code + delambdafy 22 remove lambdas + icode 23 generate portable intermediate code #partest !-optimise - jvm 23 generate JVM bytecode - ploogin 24 A sample phase that does so many things it's kind of hard... - terminal 25 the last phase during a compilation run + jvm 24 generate JVM bytecode + ploogin 25 A sample phase that does so many things it's kind of hard... + terminal 26 the last phase during a compilation run #partest -optimise - inliner 23 optimization: do inlining -inlinehandlers 24 optimization: inline exception handlers - closelim 25 optimization: eliminate uncalled closures - constopt 26 optimization: optimize null and other constants - dce 27 optimization: eliminate dead code - jvm 28 generate JVM bytecode - ploogin 29 A sample phase that does so many things it's kind of hard... - terminal 30 the last phase during a compilation run + inliner 24 optimization: do inlining +inlinehandlers 25 optimization: inline exception handlers + closelim 26 optimization: eliminate uncalled closures + constopt 27 optimization: optimize null and other constants + dce 28 optimization: eliminate dead code + jvm 29 generate JVM bytecode + ploogin 30 A sample phase that does so many things it's kind of hard... + terminal 31 the last phase during a compilation run #partest diff --git a/test/files/pos/delambdafy-lambdalift.scala b/test/files/pos/delambdafy-lambdalift.scala new file mode 100644 index 0000000000..e9da24ef37 --- /dev/null +++ b/test/files/pos/delambdafy-lambdalift.scala @@ -0,0 +1,8 @@ +class LambdaLift { + + def enclosingMethod(capturedArg: Int): Unit = { + def innerMethod(x: Int): Int = x + capturedArg + val f = (y: Int) => innerMethod(y) + } + +} diff --git a/test/files/pos/delambdafy-patterns.scala b/test/files/pos/delambdafy-patterns.scala new file mode 100644 index 0000000000..95d498629b --- /dev/null +++ b/test/files/pos/delambdafy-patterns.scala @@ -0,0 +1,15 @@ +class DelambdafyPatterns { + def bar: Unit = () + def wildcardPatternInTryCatch: Unit => Unit = (x: Unit) => + // patterns in try..catch are preserved so we need to be + // careful when it comes to free variable detction + // in particular a is _not_ free variable, also the + // `_` identifier has no symbol attached to it + try bar catch { + case a@(_:java.lang.reflect.InvocationTargetException) => + // refer to a so we trigger a bug where a is considered + // to be a free variable for enclosing lambda + val b = a + () + } +} diff --git a/test/files/run/delambdafy-nested-by-name.check b/test/files/run/delambdafy-nested-by-name.check new file mode 100644 index 0000000000..94954abda4 --- /dev/null +++ b/test/files/run/delambdafy-nested-by-name.check @@ -0,0 +1,2 @@ +hello +world diff --git a/test/files/run/delambdafy-nested-by-name.scala b/test/files/run/delambdafy-nested-by-name.scala new file mode 100644 index 0000000000..4498b3308d --- /dev/null +++ b/test/files/run/delambdafy-nested-by-name.scala @@ -0,0 +1,11 @@ +// during development of delayed delambdafication I created a bug where calling a by-name method with a by-name argument that +// itself contained a by-name argument would cause a class cast exception. That bug wasn't found in the existing test suite +// so this test covers that case +object Test { + def meth1(arg1: => String) = arg1 + def meth2(arg2: => String) = meth1({println("hello"); arg2}) + + def main(args: Array[String]) { + println(meth2("world")) + } +}
\ No newline at end of file diff --git a/test/files/run/delambdafy-two-lambdas.check b/test/files/run/delambdafy-two-lambdas.check new file mode 100644 index 0000000000..ed9ea404dd --- /dev/null +++ b/test/files/run/delambdafy-two-lambdas.check @@ -0,0 +1,2 @@ +13 +24 diff --git a/test/files/run/delambdafy-two-lambdas.scala b/test/files/run/delambdafy-two-lambdas.scala new file mode 100644 index 0000000000..decede74a4 --- /dev/null +++ b/test/files/run/delambdafy-two-lambdas.scala @@ -0,0 +1,12 @@ +/* + * Tests if two lambdas defined in the same class do not lead to + * name clashes. + */ +object Test { + def takeLambda(f: Int => Int ): Int = f(12) + + def main(args: Array[String]): Unit = { + println(takeLambda(x => x+1)) + println(takeLambda(x => x*2)) + } +} diff --git a/test/files/run/delambdafy_t6028.check b/test/files/run/delambdafy_t6028.check new file mode 100644 index 0000000000..92cfbaefb6 --- /dev/null +++ b/test/files/run/delambdafy_t6028.check @@ -0,0 +1,57 @@ +[[syntax trees at end of lambdalift]] // newSource1.scala +package <empty> { + class T extends Object { + <paramaccessor> private[this] val classParam: Int = _; + def <init>(classParam: Int): T = { + T.super.<init>(); + () + }; + private[this] val field: Int = 0; + <stable> <accessor> def field(): Int = T.this.field; + def foo(methodParam: Int): Function0 = { + val methodLocal: Int = 0; + { + (() => T.this.$anonfun$1(methodParam, methodLocal)).$asInstanceOf[Function0]() + } + }; + def bar(barParam: Int): Object = { + @volatile var MethodLocalObject$module: runtime.VolatileObjectRef = scala.runtime.VolatileObjectRef.zero(); + T.this.MethodLocalObject$1(barParam, MethodLocalObject$module) + }; + def tryy(tryyParam: Int): Function0 = { + var tryyLocal: runtime.IntRef = scala.runtime.IntRef.create(0); + { + (() => T.this.$anonfun$2(tryyParam, tryyLocal)).$asInstanceOf[Function0]() + } + }; + final <artifact> private[this] def $anonfun$1(methodParam$1: Int, methodLocal$1: Int): Int = T.this.classParam.+(T.this.field()).+(methodParam$1).+(methodLocal$1); + abstract trait MethodLocalTrait$1 extends Object { + <synthetic> <stable> <artifact> def $outer(): T + }; + object MethodLocalObject$2 extends Object with T#MethodLocalTrait$1 { + def <init>($outer: T, barParam$1: Int): T#MethodLocalObject$2.type = { + MethodLocalObject$2.super.<init>(); + MethodLocalObject$2.this.$asInstanceOf[T#MethodLocalTrait$1$class]()./*MethodLocalTrait$1$class*/$init$(barParam$1); + () + }; + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer; + <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer + }; + final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { + MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); + MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]() + }; + abstract trait MethodLocalTrait$1$class extends Object with T#MethodLocalTrait$1 { + def /*MethodLocalTrait$1$class*/$init$(barParam$1: Int): Unit = { + () + }; + scala.this.Predef.print(scala.Int.box(barParam$1)) + }; + final <artifact> private[this] def $anonfun$2(tryyParam$1: Int, tryyLocal$1: runtime.IntRef): Unit = try { + tryyLocal$1.elem = tryyParam$1 + } finally () + } +} + +warning: there were 1 feature warning(s); re-run with -feature for details diff --git a/test/files/run/delambdafy_t6028.scala b/test/files/run/delambdafy_t6028.scala new file mode 100644 index 0000000000..0b7ef48c3d --- /dev/null +++ b/test/files/run/delambdafy_t6028.scala @@ -0,0 +1,21 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Ydelambdafy:method -Xprint:lambdalift -d " + testOutput.path + + override def code = """class T(classParam: Int) { + | val field: Int = 0 + | def foo(methodParam: Int) = {val methodLocal = 0 ; () => classParam + field + methodParam + methodLocal } + | def bar(barParam: Int) = { trait MethodLocalTrait { print(barParam) }; object MethodLocalObject extends MethodLocalTrait; MethodLocalObject } + | def tryy(tryyParam: Int) = { var tryyLocal = 0; () => try { tryyLocal = tryyParam } finally () } + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/delambdafy_t6555.check b/test/files/run/delambdafy_t6555.check new file mode 100644 index 0000000000..6b174c0d2a --- /dev/null +++ b/test/files/run/delambdafy_t6555.check @@ -0,0 +1,15 @@ +[[syntax trees at end of specialize]] // newSource1.scala +package <empty> { + class Foo extends Object { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + private[this] val f: Int => Int = { + final <artifact> def $anonfun(param: Int): Int = param; + ((param: Int) => $anonfun(param)) + }; + <stable> <accessor> def f(): Int => Int = Foo.this.f + } +} + diff --git a/test/files/run/delambdafy_t6555.scala b/test/files/run/delambdafy_t6555.scala new file mode 100644 index 0000000000..a1dcfe790c --- /dev/null +++ b/test/files/run/delambdafy_t6555.scala @@ -0,0 +1,15 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:specialize -Ydelambdafy:method -d " + testOutput.path + + override def code = "class Foo { val f = (param: Int) => param } " + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/delambdafy_uncurry_byname_inline.check b/test/files/run/delambdafy_uncurry_byname_inline.check new file mode 100644 index 0000000000..0dc69b379a --- /dev/null +++ b/test/files/run/delambdafy_uncurry_byname_inline.check @@ -0,0 +1,21 @@ +[[syntax trees at end of uncurry]] // newSource1.scala +package <empty> { + class Foo extends Object { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + def bar(x: () => Int): Int = x.apply(); + def foo(): Int = Foo.this.bar({ + @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0[Int] with Serializable { + def <init>(): <$anon: () => Int> = { + $anonfun.super.<init>(); + () + }; + final def apply(): Int = 1 + }; + (new <$anon: () => Int>(): () => Int) + }) + } +} + diff --git a/test/files/run/delambdafy_uncurry_byname_inline.scala b/test/files/run/delambdafy_uncurry_byname_inline.scala new file mode 100644 index 0000000000..8f480fa804 --- /dev/null +++ b/test/files/run/delambdafy_uncurry_byname_inline.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:uncurry -Ydelambdafy:inline -d " + testOutput.path + + override def code = """class Foo { + | def bar(x: => Int) = x + | + | def foo = bar(1) + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/delambdafy_uncurry_byname_method.check b/test/files/run/delambdafy_uncurry_byname_method.check new file mode 100644 index 0000000000..cd3edc7d6f --- /dev/null +++ b/test/files/run/delambdafy_uncurry_byname_method.check @@ -0,0 +1,15 @@ +[[syntax trees at end of uncurry]] // newSource1.scala +package <empty> { + class Foo extends Object { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + def bar(x: () => Int): Int = x.apply(); + def foo(): Int = Foo.this.bar({ + final <artifact> def $anonfun(): Int = 1; + (() => $anonfun()) + }) + } +} + diff --git a/test/files/run/delambdafy_uncurry_byname_method.scala b/test/files/run/delambdafy_uncurry_byname_method.scala new file mode 100644 index 0000000000..1adeec8433 --- /dev/null +++ b/test/files/run/delambdafy_uncurry_byname_method.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:uncurry -Ydelambdafy:method -Ystop-after:uncurry -d " + testOutput.path + + override def code = """class Foo { + | def bar(x: => Int) = x + | + | def foo = bar(1) + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/delambdafy_uncurry_inline.check b/test/files/run/delambdafy_uncurry_inline.check new file mode 100644 index 0000000000..e2b024b462 --- /dev/null +++ b/test/files/run/delambdafy_uncurry_inline.check @@ -0,0 +1,23 @@ +[[syntax trees at end of uncurry]] // newSource1.scala +package <empty> { + class Foo extends Object { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + def bar(): Unit = { + val f: Int => Int = { + @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1[Int,Int] with Serializable { + def <init>(): <$anon: Int => Int> = { + $anonfun.super.<init>(); + () + }; + final def apply(x: Int): Int = x.+(1) + }; + (new <$anon: Int => Int>(): Int => Int) + }; + () + } + } +} + diff --git a/test/files/run/delambdafy_uncurry_inline.scala b/test/files/run/delambdafy_uncurry_inline.scala new file mode 100644 index 0000000000..b42b65f5bb --- /dev/null +++ b/test/files/run/delambdafy_uncurry_inline.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:uncurry -Ydelambdafy:inline -d " + testOutput.path + + override def code = """class Foo { + | def bar = { + | val f = {x: Int => x + 1} + | } + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/delambdafy_uncurry_method.check b/test/files/run/delambdafy_uncurry_method.check new file mode 100644 index 0000000000..5ee3d174b3 --- /dev/null +++ b/test/files/run/delambdafy_uncurry_method.check @@ -0,0 +1,17 @@ +[[syntax trees at end of uncurry]] // newSource1.scala +package <empty> { + class Foo extends Object { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + def bar(): Unit = { + val f: Int => Int = { + final <artifact> def $anonfun(x: Int): Int = x.+(1); + ((x: Int) => $anonfun(x)) + }; + () + } + } +} + diff --git a/test/files/run/delambdafy_uncurry_method.scala b/test/files/run/delambdafy_uncurry_method.scala new file mode 100644 index 0000000000..a988fb2ee7 --- /dev/null +++ b/test/files/run/delambdafy_uncurry_method.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:uncurry -Ydelambdafy:method -Ystop-after:uncurry -d " + testOutput.path + + override def code = """class Foo { + | def bar = { + | val f = {x: Int => x + 1} + | } + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/origins.flags b/test/files/run/origins.flags index a7e64e4f0c..690753d807 100644 --- a/test/files/run/origins.flags +++ b/test/files/run/origins.flags @@ -1 +1 @@ --no-specialization
\ No newline at end of file +-no-specialization -Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/run/primitive-sigs-2-new.flags b/test/files/run/primitive-sigs-2-new.flags new file mode 100644 index 0000000000..2349d8294d --- /dev/null +++ b/test/files/run/primitive-sigs-2-new.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline diff --git a/test/files/run/primitive-sigs-2-old.flags b/test/files/run/primitive-sigs-2-old.flags new file mode 100644 index 0000000000..ac96850b69 --- /dev/null +++ b/test/files/run/primitive-sigs-2-old.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index cfa3ed3fb4..1cd94ccb45 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -21,6 +21,7 @@ superaccessors 6 add super accessors in traits and nested classes flatten 19 eliminate inner classes mixin 20 mixin composition cleanup 21 platform-specific cleanups, generate reflective calls - icode 22 generate portable intermediate code - jvm 23 generate JVM bytecode - terminal 24 the last phase during a compilation run + delambdafy 22 remove lambdas + icode 23 generate portable intermediate code + jvm 24 generate JVM bytecode + terminal 25 the last phase during a compilation run diff --git a/test/files/run/static-module-method.check b/test/files/run/static-module-method.check new file mode 100644 index 0000000000..ce01362503 --- /dev/null +++ b/test/files/run/static-module-method.check @@ -0,0 +1 @@ +hello diff --git a/test/files/run/static-module-method.scala b/test/files/run/static-module-method.scala new file mode 100644 index 0000000000..a8691300de --- /dev/null +++ b/test/files/run/static-module-method.scala @@ -0,0 +1,14 @@ +// During development of delayed delambdafy there was a problem where +// GenASM would eliminate a loadmodule for all methods defined within that module +// even if those methods were static. This test would thus fail +// with a verify error under -Ydelambdafy:method + +object Test { + def moduleMethod(x: String) = x + + def map(x: String, f: String => String) = f(x) + + def main(args: Array[String]) { + println(map("hello", Test.moduleMethod)) + } +}
\ No newline at end of file diff --git a/test/files/run/t1167.flags b/test/files/run/t1167.flags new file mode 100644 index 0000000000..ac96850b69 --- /dev/null +++ b/test/files/run/t1167.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/run/t3897.flags b/test/files/run/t3897.flags new file mode 100644 index 0000000000..ac96850b69 --- /dev/null +++ b/test/files/run/t3897.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/run/t6028.scala b/test/files/run/t6028.scala index cab17535fc..a6f920c5bb 100644 --- a/test/files/run/t6028.scala +++ b/test/files/run/t6028.scala @@ -3,7 +3,7 @@ import java.io.{Console => _, _} object Test extends DirectTest { - override def extraSettings: String = "-usejavacp -Xprint:lambdalift -d " + testOutput.path + override def extraSettings: String = "-usejavacp -Ydelambdafy:inline -Xprint:lambdalift -d " + testOutput.path override def code = """class T(classParam: Int) { | val field: Int = 0 diff --git a/test/files/run/t6102.check b/test/files/run/t6102.check index 4e8efa7b6d..aa3e6cc9e2 100644 --- a/test/files/run/t6102.check +++ b/test/files/run/t6102.check @@ -19,6 +19,7 @@ [running phase flatten on t6102.scala] [running phase mixin on t6102.scala] [running phase cleanup on t6102.scala] +[running phase delambdafy on t6102.scala] [running phase icode on t6102.scala] #partest -optimise [running phase inliner on t6102.scala] diff --git a/test/files/run/t6555.scala b/test/files/run/t6555.scala index b1a6137786..cc0e4d1bfa 100644 --- a/test/files/run/t6555.scala +++ b/test/files/run/t6555.scala @@ -3,7 +3,7 @@ import java.io.{Console => _, _} object Test extends DirectTest { - override def extraSettings: String = "-usejavacp -Xprint:specialize -d " + testOutput.path + override def extraSettings: String = "-usejavacp -Xprint:specialize -Ydelambdafy:inline -d " + testOutput.path override def code = "class Foo { val f = (param: Int) => param } " diff --git a/test/files/specialized/constant_lambda.check b/test/files/specialized/constant_lambda.check new file mode 100644 index 0000000000..4b095fd0ff --- /dev/null +++ b/test/files/specialized/constant_lambda.check @@ -0,0 +1,2 @@ +false +false diff --git a/test/files/specialized/constant_lambda.scala b/test/files/specialized/constant_lambda.scala new file mode 100644 index 0000000000..bb9a97403e --- /dev/null +++ b/test/files/specialized/constant_lambda.scala @@ -0,0 +1,16 @@ +// during development of late delmabdafying there was a problem where +// specialization would undo some of the work done in uncurry if the body of the +// lambda had a constant type. That would result in a compiler crash as +// when the delambdafy phase got a tree shape it didn't understand +class X[@specialized(Int) A] { + val f = { x: A => false } +} + +object Test { + def main(args: Array[String]) { + val xInt = new X[Int] + println(xInt.f(42)) + val xString = new X[String] + println(xString.f("hello")) + } +}
\ No newline at end of file |