diff options
author | Lukas Rytz <lukas.rytz@typesafe.com> | 2016-06-29 10:26:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-29 10:26:35 +0200 |
commit | 79e24d52af441e728bf0c09fc054a00db693e07d (patch) | |
tree | 36ef9af07fc6b2296e678459525bee3f4f55e861 /test/files | |
parent | 7a7fdac795bdee3e05cda1327a570e59fbc9ce00 (diff) | |
parent | d8c862b225cc7936e475419abaabb07226fea568 (diff) | |
download | scala-79e24d52af441e728bf0c09fc054a00db693e07d.tar.gz scala-79e24d52af441e728bf0c09fc054a00db693e07d.tar.bz2 scala-79e24d52af441e728bf0c09fc054a00db693e07d.zip |
Merge pull request #5251 from adriaanm/rebase-5177
Emit trait method bodies in statics [rebase of #5177]
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/instrumented/InstrumentationTest.check | 2 | ||||
-rw-r--r-- | test/files/neg/trait-defaults-super.check | 4 | ||||
-rw-r--r-- | test/files/neg/trait-defaults-super.scala | 21 | ||||
-rw-r--r-- | test/files/pos/trait-defaults-super.scala | 21 | ||||
-rw-r--r-- | test/files/run/t4891.check | 3 | ||||
-rw-r--r-- | test/files/run/t5652.check | 3 | ||||
-rw-r--r-- | test/files/run/t7700.check | 5 | ||||
-rw-r--r-- | test/files/run/t7700.scala | 16 | ||||
-rw-r--r-- | test/files/run/t7932.check | 4 | ||||
-rw-r--r-- | test/files/run/t7932.scala | 10 | ||||
-rw-r--r-- | test/files/run/t8601e/StaticInit.class | bin | 417 -> 0 bytes | |||
-rw-r--r-- | test/files/run/trait-static-clash.scala | 10 |
12 files changed, 83 insertions, 16 deletions
diff --git a/test/files/instrumented/InstrumentationTest.check b/test/files/instrumented/InstrumentationTest.check index 74f9c9d268..d317fc4207 100644 --- a/test/files/instrumented/InstrumentationTest.check +++ b/test/files/instrumented/InstrumentationTest.check @@ -6,5 +6,5 @@ Method call statistics: 1 instrumented/Foo2.someMethod()I 1 scala/DeprecatedConsole.<init>()V 1 scala/Predef$.println(Ljava/lang/Object;)V - 1 scala/io/AnsiColor.$init$()V + 1 scala/io/AnsiColor.$init$(Lscala/io/AnsiColor;)V 1 scala/runtime/BoxesRunTime.boxToBoolean(Z)Ljava/lang/Boolean; diff --git a/test/files/neg/trait-defaults-super.check b/test/files/neg/trait-defaults-super.check new file mode 100644 index 0000000000..2b19402828 --- /dev/null +++ b/test/files/neg/trait-defaults-super.check @@ -0,0 +1,4 @@ +trait-defaults-super.scala:14: error: Unable to implement a super accessor required by trait T unless Iterable[String] is directly extended by class C. +class C extends T + ^ +one error found diff --git a/test/files/neg/trait-defaults-super.scala b/test/files/neg/trait-defaults-super.scala new file mode 100644 index 0000000000..def271e8e7 --- /dev/null +++ b/test/files/neg/trait-defaults-super.scala @@ -0,0 +1,21 @@ +trait T extends java.lang.Iterable[String] { + + override def spliterator(): java.util.Spliterator[String] = { + super[Iterable].spliterator + super.spliterator + null + } + def foo = { + super[Iterable].spliterator + super.spliterator + } + def iterator(): java.util.Iterator[String] = java.util.Collections.emptyList().iterator() +} +class C extends T +object Test { + def main(args: Array[String]): Unit = { + val t: T = new C + t.spliterator + t.foo + } +} diff --git a/test/files/pos/trait-defaults-super.scala b/test/files/pos/trait-defaults-super.scala new file mode 100644 index 0000000000..8f867ab563 --- /dev/null +++ b/test/files/pos/trait-defaults-super.scala @@ -0,0 +1,21 @@ +trait T extends java.lang.Iterable[String] { + + override def spliterator(): java.util.Spliterator[String] = { + super[Iterable].spliterator + super.spliterator + null + } + def foo = { + super[Iterable].spliterator + super.spliterator + } + def iterator(): java.util.Iterator[String] = java.util.Collections.emptyList().iterator() +} +class C extends T with java.lang.Iterable[String] // super accessor is okay with Iterable as a direct parent +object Test { + def main(args: Array[String]): Unit = { + val t: T = new C + t.spliterator + t.foo + } +} diff --git a/test/files/run/t4891.check b/test/files/run/t4891.check index 1b1108e9ee..a460569fd9 100644 --- a/test/files/run/t4891.check +++ b/test/files/run/t4891.check @@ -1,6 +1,7 @@ test.generic.T1 - (m) public default void test.generic.T1.$init$() + (m) public static void test.generic.T1.$init$(test.generic.T1) (m) public default A test.generic.T1.t1(A) + (m) public static java.lang.Object test.generic.T1.t1$(test.generic.T1,java.lang.Object) test.generic.C1 (m) public void test.generic.C1.m1() test.generic.C2 diff --git a/test/files/run/t5652.check b/test/files/run/t5652.check index 7c65ba6698..3c039d68aa 100644 --- a/test/files/run/t5652.check +++ b/test/files/run/t5652.check @@ -1,6 +1,7 @@ public default int T1.f0() -public default void T1.$init$() public static int T1.T1$$g$1() +public static int T1.f0$(T1) +public static void T1.$init$(T1) public int A1.f1() public static final int A1.A1$$g$2() public int A2.f2() diff --git a/test/files/run/t7700.check b/test/files/run/t7700.check index 1d51e68877..7d18dbfcb4 100644 --- a/test/files/run/t7700.check +++ b/test/files/run/t7700.check @@ -1,3 +1,4 @@ -public default void C.$init$() +public static void C.$init$(C) public default java.lang.Object C.bar(java.lang.Object) -public abstract java.lang.Object C.foo(java.lang.Object) +public static java.lang.Object C.bar$(C,java.lang.Object) +public abstract java.lang.Object C.foo(java.lang.Object)
\ No newline at end of file diff --git a/test/files/run/t7700.scala b/test/files/run/t7700.scala index 76d16b808c..fd13666467 100644 --- a/test/files/run/t7700.scala +++ b/test/files/run/t7700.scala @@ -7,11 +7,13 @@ trait C[@specialized U] { def bar[A](u: U) = u } -object Test extends App { - val declared = classOf[C[_]].getDeclaredMethods.sortBy(_.getName) - println(declared.mkString("\n")) - object CInt extends C[Int] { def foo(i: Int) = i } - object CAny extends C[Any] { def foo(a: Any) = a } - assert(CInt.foo(1) == 1) - assert(CAny.foo("") == "") +object Test { + def main(args: Array[String]) { + val declared = classOf[C[_]].getDeclaredMethods.sortBy(_.getName) + println(declared.mkString("\n")) + object CInt extends C[Int] { def foo(i: Int) = i } + object CAny extends C[Any] { def foo(a: Any) = a } + assert(CInt.foo(1) == 1) + assert(CAny.foo("") == "") + } } diff --git a/test/files/run/t7932.check b/test/files/run/t7932.check index a2ad84cd46..76968fd179 100644 --- a/test/files/run/t7932.check +++ b/test/files/run/t7932.check @@ -2,5 +2,9 @@ public Category<?> C.category() public Category<scala.Tuple2> C.category1() public default Category<java.lang.Object> M1.category() public default Category<scala.Tuple2> M1.category1() +public static Category M1.category$(M1) +public static Category M1.category1$(M1) public default Category<java.lang.Object> M2.category() public default Category<scala.Tuple2> M2.category1() +public static Category M2.category$(M2) +public static Category M2.category1$(M2)
\ No newline at end of file diff --git a/test/files/run/t7932.scala b/test/files/run/t7932.scala index e6bdbf2417..40b0b9989b 100644 --- a/test/files/run/t7932.scala +++ b/test/files/run/t7932.scala @@ -17,12 +17,14 @@ trait M2[F] { self: M1[F] => abstract class C extends M1[Float] with M2[Float] -object Test extends App { +object Test { def t(c: Class[_]) = { val ms = c.getMethods.filter(_.getName.startsWith("category")) println(ms.map(_.toGenericString).sorted.mkString("\n")) } - t(classOf[C]) - t(classOf[M1[_]]) - t(classOf[M2[_]]) + def main(args: Array[String]) { + t(classOf[C]) + t(classOf[M1[_]]) + t(classOf[M2[_]]) + } } diff --git a/test/files/run/t8601e/StaticInit.class b/test/files/run/t8601e/StaticInit.class Binary files differdeleted file mode 100644 index 99a0e2a643..0000000000 --- a/test/files/run/t8601e/StaticInit.class +++ /dev/null diff --git a/test/files/run/trait-static-clash.scala b/test/files/run/trait-static-clash.scala new file mode 100644 index 0000000000..603cf6b6e5 --- /dev/null +++ b/test/files/run/trait-static-clash.scala @@ -0,0 +1,10 @@ +trait T { + def foo = 1 + def foo(t: T) = 2 +} +object Test extends T { + def main(args: Array[String]) { + assert(foo == 1) + assert(foo(this) == 2) + } +} |