From 3904c3216c741b387d81754e55aa079ce4218d06 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Tue, 29 Mar 2016 18:18:09 -0700 Subject: LMF cannot instantiate SAM of trait with non-trait superclass Also, drop AbstractFunction for parent of anonymous subclass of function type that must have its class spun up at compile time (rather than at linkage time by LambdaMetaFactory). This revealed an old problem with typedTemplate, in which parent types may be normalized at the level of trees, while this change does not get propagated to the class's info in time for the constructor to be located when we type check the primary constructor. --- test/files/neg/t5761.check | 2 +- test/files/run/delambdafy_uncurry_byname_inline.check | 2 +- test/files/run/delambdafy_uncurry_inline.check | 2 +- test/files/run/sammy_restrictions_LMF.scala | 9 +++++++++ test/files/run/t6028.check | 6 ++++-- test/files/run/t6555.check | 2 +- 6 files changed, 17 insertions(+), 6 deletions(-) (limited to 'test/files') diff --git a/test/files/neg/t5761.check b/test/files/neg/t5761.check index 2d66af26f6..15c0bc7634 100644 --- a/test/files/neg/t5761.check +++ b/test/files/neg/t5761.check @@ -13,7 +13,7 @@ Unspecified value parameter x. t5761.scala:13: error: not found: type Tread new Tread("sth") { }.run() ^ -t5761.scala:13: error: value run is not a member of AnyRef +t5761.scala:13: error: value run is not a member of new Tread("sth") { }.run() ^ 5 errors found diff --git a/test/files/run/delambdafy_uncurry_byname_inline.check b/test/files/run/delambdafy_uncurry_byname_inline.check index d96a995f44..e1ee4c29e2 100644 --- a/test/files/run/delambdafy_uncurry_byname_inline.check +++ b/test/files/run/delambdafy_uncurry_byname_inline.check @@ -7,7 +7,7 @@ package { }; def bar(x: () => Int): Int = x.apply(); def foo(): Int = Foo.this.bar({ - @SerialVersionUID(value = 0) final class $anonfun extends scala.runtime.AbstractFunction0[Int] with Serializable { + @SerialVersionUID(value = 0) final class $anonfun extends Object with () => Int with Serializable { def (): <$anon: () => Int> = { $anonfun.super.(); () diff --git a/test/files/run/delambdafy_uncurry_inline.check b/test/files/run/delambdafy_uncurry_inline.check index 5521cc4a2c..479e9409fa 100644 --- a/test/files/run/delambdafy_uncurry_inline.check +++ b/test/files/run/delambdafy_uncurry_inline.check @@ -7,7 +7,7 @@ package { }; def bar(): Unit = { val f: Int => Int = { - @SerialVersionUID(value = 0) final class $anonfun extends scala.runtime.AbstractFunction1[Int,Int] with Serializable { + @SerialVersionUID(value = 0) final class $anonfun extends Object with Int => Int with Serializable { def (): <$anon: Int => Int> = { $anonfun.super.(); () diff --git a/test/files/run/sammy_restrictions_LMF.scala b/test/files/run/sammy_restrictions_LMF.scala index 27a3d21dad..aa49e14113 100644 --- a/test/files/run/sammy_restrictions_LMF.scala +++ b/test/files/run/sammy_restrictions_LMF.scala @@ -8,6 +8,11 @@ trait TImpure { def apply(x: Int): String ; println(1) } trait Println { println(1) } trait TImpureSuper extends Println { def apply(x: Int): String } +class C +trait A extends C +trait B extends A +trait TClassParent extends B { def apply(x: Int): String } + object Test extends App { final val AnonFunClass = "$anonfun$" final val LMFClass = "$$Lambda$" // LambdaMetaFactory names classes like this @@ -45,4 +50,8 @@ object Test extends App { notLMF((x => "a"): TImpure) notLMF((x => "a"): TImpureSuper) + + val fClassParent: TClassParent = x => "a" + notLMF(fClassParent) + assert(fClassParent(1) == "a") } diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 532d177300..f21b77fdc7 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -24,9 +24,10 @@ package { (new <$anon: Function0>(T.this, tryyParam, tryyLocal): Function0) } }; - @SerialVersionUID(value = 0) final class $anonfun$foo$1 extends scala.runtime.AbstractFunction0$mcI$sp with Serializable { + @SerialVersionUID(value = 0) final class $anonfun$foo$1 extends Object with Function0$mcI$sp with Serializable { def ($outer: T, methodParam$1: Int, methodLocal$1: Int): <$anon: Function0> = { $anonfun$foo$1.super.(); + $anonfun$foo$1.super./*Function0*/$init$(); () }; final def apply(): Int = $anonfun$foo$1.this.apply$mcI$sp(); @@ -66,9 +67,10 @@ package { T.this.MethodLocalObject$lzycompute$1(barParam$1, MethodLocalObject$module$1) else MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type](); - @SerialVersionUID(value = 0) final class $anonfun$tryy$1 extends scala.runtime.AbstractFunction0$mcV$sp with Serializable { + @SerialVersionUID(value = 0) final class $anonfun$tryy$1 extends Object with Function0$mcV$sp with Serializable { def ($outer: T, tryyParam$1: Int, tryyLocal$1: runtime.IntRef): <$anon: Function0> = { $anonfun$tryy$1.super.(); + $anonfun$tryy$1.super./*Function0*/$init$(); () }; final def apply(): Unit = $anonfun$tryy$1.this.apply$mcV$sp(); diff --git a/test/files/run/t6555.check b/test/files/run/t6555.check index e3b467ce7c..fef689a80d 100644 --- a/test/files/run/t6555.check +++ b/test/files/run/t6555.check @@ -6,7 +6,7 @@ package { () }; private[this] val f: Int => Int = { - @SerialVersionUID(value = 0) final class $anonfun extends scala.runtime.AbstractFunction1$mcII$sp with Serializable { + @SerialVersionUID(value = 0) final class $anonfun extends Object with Int => Int with Serializable { def (): <$anon: Int => Int> = { $anonfun.super.(); () -- cgit v1.2.3