From 9136e76ca1a9827e1a8c90fa4f7f63c2967cb019 Mon Sep 17 00:00:00 2001 From: James Iry Date: Mon, 22 Jul 2013 16:51:46 -0700 Subject: Add a skeletal Delambdafy phase. This commit adds a do-nothing phase called "Delambdafy" that will eventually be responsible for doing the final translation of lambdas into classes. --- test/files/neg/t6446-additional.check | 25 +++++++++++++------------ test/files/neg/t6446-missing.check | 21 +++++++++++---------- test/files/neg/t6446-show-phases.check | 21 +++++++++++---------- test/files/neg/t7494-no-options.check | 25 +++++++++++++------------ 4 files changed, 48 insertions(+), 44 deletions(-) (limited to 'test/files/neg') 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/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 -- cgit v1.2.3 From 8d4a5bab2666c7006f31645b59cf063f07a8a12d Mon Sep 17 00:00:00 2001 From: James Iry Date: Wed, 28 Aug 2013 20:51:31 -0700 Subject: Create test variants where delambdafication alters signatures. This commit includes several tests where there's a variation in signatures between inline delambdafication and method based delambdafication. --- test/files/neg/delambdafy_t6260_method.check | 13 +++++++ test/files/neg/delambdafy_t6260_method.flags | 1 + test/files/neg/delambdafy_t6260_method.scala | 17 +++++++++ test/files/neg/t6260.flags | 1 + test/files/run/delambdafy_t6028.check | 57 ++++++++++++++++++++++++++++ test/files/run/delambdafy_t6028.scala | 21 ++++++++++ test/files/run/delambdafy_t6555.check | 15 ++++++++ test/files/run/delambdafy_t6555.scala | 15 ++++++++ test/files/run/t6028.scala | 2 +- test/files/run/t6555.scala | 2 +- 10 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 test/files/neg/delambdafy_t6260_method.check create mode 100644 test/files/neg/delambdafy_t6260_method.flags create mode 100644 test/files/neg/delambdafy_t6260_method.scala create mode 100644 test/files/neg/t6260.flags create mode 100644 test/files/run/delambdafy_t6028.check create mode 100644 test/files/run/delambdafy_t6028.scala create mode 100644 test/files/run/delambdafy_t6555.check create mode 100644 test/files/run/delambdafy_t6555.scala (limited to 'test/files/neg') 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/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/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 { + class T extends Object { + private[this] val classParam: Int = _; + def (classParam: Int): T = { + T.super.(); + () + }; + private[this] val field: Int = 0; + 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 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 { + def $outer(): T + }; + object MethodLocalObject$2 extends Object with T#MethodLocalTrait$1 { + def ($outer: T, barParam$1: Int): T#MethodLocalObject$2.type = { + MethodLocalObject$2.super.(); + MethodLocalObject$2.this.$asInstanceOf[T#MethodLocalTrait$1$class]()./*MethodLocalTrait$1$class*/$init$(barParam$1); + () + }; + private[this] val $outer: T = _; + def $outer(): T = MethodLocalObject$2.this.$outer; + def $outer(): T = MethodLocalObject$2.this.$outer + }; + final 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 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 { + class Foo extends Object { + def (): Foo = { + Foo.super.(); + () + }; + private[this] val f: Int => Int = { + final def $anonfun(param: Int): Int = param; + ((param: Int) => $anonfun(param)) + }; + 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/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/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 } " -- cgit v1.2.3 From ef995ac6b4030e3cd10e487d414c941e5794666f Mon Sep 17 00:00:00 2001 From: James Iry Date: Wed, 28 Aug 2013 20:55:05 -0700 Subject: Force several tests to run using inline delambdafication. The differences when running with method based delambdafication aren't important enough yet to create specialized versions that use method based delambdafication. --- test/files/instrumented/inline-in-constructors.flags | 2 +- test/files/neg/t6231.flags | 1 + test/files/neg/t6666.flags | 1 + test/files/neg/t6666c.flags | 1 + test/files/run/origins.flags | 2 +- test/files/run/primitive-sigs-2-new.flags | 1 + test/files/run/primitive-sigs-2-old.flags | 1 + test/files/run/t1167.flags | 1 + test/files/run/t3897.flags | 1 + 9 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 test/files/neg/t6231.flags create mode 100644 test/files/neg/t6666.flags create mode 100644 test/files/neg/t6666c.flags create mode 100644 test/files/run/primitive-sigs-2-new.flags create mode 100644 test/files/run/primitive-sigs-2-old.flags create mode 100644 test/files/run/t1167.flags create mode 100644 test/files/run/t3897.flags (limited to 'test/files/neg') 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/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/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/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/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 -- cgit v1.2.3