diff options
Diffstat (limited to 'test')
134 files changed, 1574 insertions, 450 deletions
diff --git a/test/files/jvm/innerClassAttribute/Classes_1.scala b/test/files/jvm/innerClassAttribute/Classes_1.scala index bffc495b4f..27f01a880a 100644 --- a/test/files/jvm/innerClassAttribute/Classes_1.scala +++ b/test/files/jvm/innerClassAttribute/Classes_1.scala @@ -303,3 +303,40 @@ object NestedInValueClass { def f = { class C; new C } // outer class A$, outer method f } } + +object LocalAndAnonymousInLazyInitializer { + abstract class A + class C { + lazy val a: A = new A { } + lazy val b: A = { + class AA extends A + new AA + } + lazy val c: A = { + object AA extends A + AA + } + } + object O { + lazy val a: A = new A { } + lazy val b: A = { + class AA extends A + new AA + } + lazy val c: A = { + object AA extends A + AA + } + } + trait T { + lazy val a: A = new A { } + lazy val b: A = { + class AA extends A + new AA + } + lazy val c: A = { + object AA extends A + AA + } + } +}
\ No newline at end of file diff --git a/test/files/jvm/innerClassAttribute/Test.scala b/test/files/jvm/innerClassAttribute/Test.scala index 1b78773d42..5c666a615f 100644 --- a/test/files/jvm/innerClassAttribute/Test.scala +++ b/test/files/jvm/innerClassAttribute/Test.scala @@ -416,7 +416,7 @@ object Test extends BytecodeTest { def testAnonymousClassesMayBeNestedInSpecialized() { assertEnclosingMethod("AnonymousClassesMayBeNestedInSpecialized$C$$anon$17", "AnonymousClassesMayBeNestedInSpecialized$C", "foo", "(Ljava/lang/Object;)LAnonymousClassesMayBeNestedInSpecialized$A;") - assertEnclosingMethod("AnonymousClassesMayBeNestedInSpecialized$C$mcI$sp$$anon$18", "AnonymousClassesMayBeNestedInSpecialized$C$mcI$sp", "foo$mcI$sp", "(I)LAnonymousClassesMayBeNestedInSpecialized$A;") + assertEnclosingMethod("AnonymousClassesMayBeNestedInSpecialized$C$mcI$sp$$anon$21", "AnonymousClassesMayBeNestedInSpecialized$C$mcI$sp", "foo$mcI$sp", "(I)LAnonymousClassesMayBeNestedInSpecialized$A;") } def testNestedInValueClass() { @@ -444,6 +444,20 @@ object Test extends BytecodeTest { testInner("NestedInValueClass$A$", a, am, b, c, methodHandlesLookup) } + def testLocalAndAnonymousInLazyInitializer(): Unit = { + assertEnclosingMethod("LocalAndAnonymousInLazyInitializer$C$$anon$18", "LocalAndAnonymousInLazyInitializer$C", null, null) + assertEnclosingMethod("LocalAndAnonymousInLazyInitializer$C$AA$4", "LocalAndAnonymousInLazyInitializer$C", null, null) + assertEnclosingMethod("LocalAndAnonymousInLazyInitializer$C$AA$5$", "LocalAndAnonymousInLazyInitializer$C", null, null) + + assertEnclosingMethod("LocalAndAnonymousInLazyInitializer$O$$anon$19", "LocalAndAnonymousInLazyInitializer$O$", null, null) + assertEnclosingMethod("LocalAndAnonymousInLazyInitializer$O$AA$6", "LocalAndAnonymousInLazyInitializer$O$", null, null) + assertEnclosingMethod("LocalAndAnonymousInLazyInitializer$O$AA$7$", "LocalAndAnonymousInLazyInitializer$O$", null, null) + + assertEnclosingMethod("LocalAndAnonymousInLazyInitializer$T$$anon$20", "LocalAndAnonymousInLazyInitializer$T", null, null) + assertEnclosingMethod("LocalAndAnonymousInLazyInitializer$T$AA$8", "LocalAndAnonymousInLazyInitializer$T", null, null) + assertEnclosingMethod("LocalAndAnonymousInLazyInitializer$T$AA$9$", "LocalAndAnonymousInLazyInitializer$T", null, null) + } + def show(): Unit = { testA1() testA2() @@ -473,5 +487,6 @@ object Test extends BytecodeTest { testSpecializedClassesTopLevel() testAnonymousClassesMayBeNestedInSpecialized() testNestedInValueClass() + testLocalAndAnonymousInLazyInitializer() } } diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index 9a2162a906..72d8d39fd0 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -93,7 +93,7 @@ scala> case class Bar(n: Int) defined class Bar scala> implicit def foo2bar(foo: Foo) = Bar(foo.n) -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' foo2bar: (foo: Foo)Bar scala> val bar: Bar = Foo(3) @@ -267,7 +267,7 @@ scala> xs map (x => x) res6: Array[_] = Array(1, 2) scala> xs map (x => (x, x)) -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2)) scala> diff --git a/test/files/jvm/serialization-new.check b/test/files/jvm/serialization-new.check index 5b8a08da82..90da8a085d 100644 --- a/test/files/jvm/serialization-new.check +++ b/test/files/jvm/serialization-new.check @@ -1,6 +1,6 @@ warning: there were two deprecation warnings (since 2.11.0) -warning: there was one deprecation warning (since 2.11.6) -warning: there were three deprecation warnings in total; re-run with -deprecation for details +warning: there were three deprecation warnings (since 2.12.0) +warning: there were 5 deprecation warnings in total; re-run with -deprecation for details a1 = Array[1,2,3] _a1 = Array[1,2,3] arrayEquals(a1, _a1): true diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check index 5b8a08da82..964c68e528 100644 --- a/test/files/jvm/serialization.check +++ b/test/files/jvm/serialization.check @@ -1,5 +1,5 @@ warning: there were two deprecation warnings (since 2.11.0) -warning: there was one deprecation warning (since 2.11.6) +warning: there was one deprecation warning (since 2.12.0) warning: there were three deprecation warnings in total; re-run with -deprecation for details a1 = Array[1,2,3] _a1 = Array[1,2,3] diff --git a/test/files/jvm/t8786-sig.scala b/test/files/jvm/t8786-sig.scala new file mode 100644 index 0000000000..0745b650e6 --- /dev/null +++ b/test/files/jvm/t8786-sig.scala @@ -0,0 +1,116 @@ +class A[U] { + @annotation.varargs def m1[T] (a: T*): T = a.head + @annotation.varargs def m2[T <: AnyRef](a: T*): T = a.head + @annotation.varargs def m3[T <: AnyVal](a: T*): T = a.head + @annotation.varargs def m4[T <: Int] (a: T*): T = a.head + @annotation.varargs def m5[T <: String](a: T*): T = a.head + @annotation.varargs def m6 (a: String*): String = a.head + @annotation.varargs def m7 (a: Int*): Int = a.head + @annotation.varargs def m8 (a: U*): U = a.head + + def n1[T] (a: Array[T]): T = a(0) + def n2[T <: AnyRef](a: Array[T]): T = a(0) + def n3[T <: AnyVal](a: Array[T]): T = a(0) + def n4[T <: Int] (a: Array[T]): T = a(0) + def n5[T <: String](a: Array[T]): T = a(0) + def n6 (a: Array[String]): String = a(0) + def n7 (a: Array[Int]): Int = a(0) + def n8 (a: Array[U]): U = a(0) +} + +object Test extends App { + val a = classOf[A[_]] + + def sig (method: String, tp: Class[_]) = a.getDeclaredMethod(method, tp).toString + def genSig(method: String, tp: Class[_]) = a.getDeclaredMethod(method, tp).toGenericString + def bound (method: String, tp: Class[_]) = { + val m = a.getDeclaredMethod(method, tp) + m.getGenericParameterTypes.apply(0) match { + case _: Class[_] => "" + case gat: java.lang.reflect.GenericArrayType => + val compTp = gat.getGenericComponentType.asInstanceOf[java.lang.reflect.TypeVariable[_]] + compTp.getBounds.apply(0).toString + } + } + + def check(a: String, b: String) = { + assert(a == b, s"found: $a\nexpected: $b") + } + + val sq = classOf[Seq[_]] + val ob = classOf[Object] + val ao = classOf[Array[Object]] + val as = classOf[Array[String]] + val ai = classOf[Array[Int]] + + check(sig("m1", sq) , "public java.lang.Object A.m1(scala.collection.Seq)") + check(sig("m2", sq) , "public java.lang.Object A.m2(scala.collection.Seq)") + check(sig("m3", sq) , "public java.lang.Object A.m3(scala.collection.Seq)") + check(sig("m4", sq) , "public int A.m4(scala.collection.Seq)") + check(sig("m5", sq) , "public java.lang.String A.m5(scala.collection.Seq)") + check(sig("m6", sq) , "public java.lang.String A.m6(scala.collection.Seq)") + check(sig("m7", sq) , "public int A.m7(scala.collection.Seq)") + check(sig("m8", sq) , "public java.lang.Object A.m8(scala.collection.Seq)") + + check(genSig("m1", sq), "public <T> T A.m1(scala.collection.Seq<T>)") + check(genSig("m2", sq), "public <T> T A.m2(scala.collection.Seq<T>)") + check(genSig("m3", sq), "public <T> T A.m3(scala.collection.Seq<T>)") + // TODO: the signature for is wrong for T <: Int, SI-9846. The signature should be + // `public int A.m4(scala.collection.Seq<java.lang.Object>)`. This is testing the status quo. + check(genSig("m4", sq), "public <T> T A.m4(scala.collection.Seq<T>)") + check(genSig("m5", sq), "public <T> T A.m5(scala.collection.Seq<T>)") + check(genSig("m6", sq), "public java.lang.String A.m6(scala.collection.Seq<java.lang.String>)") + check(genSig("m7", sq), "public int A.m7(scala.collection.Seq<java.lang.Object>)") + check(genSig("m8", sq), "public U A.m8(scala.collection.Seq<U>)") + + + // varargs forwarder + + check(sig("m1", ao) , "public java.lang.Object A.m1(java.lang.Object[])") + check(sig("m2", ao) , "public java.lang.Object A.m2(java.lang.Object[])") + check(sig("m3", ao) , "public java.lang.Object A.m3(java.lang.Object[])") + check(sig("m4", ao) , "public int A.m4(java.lang.Object[])") + check(sig("m5", as) , "public java.lang.String A.m5(java.lang.String[])") + check(sig("m6", as) , "public java.lang.String A.m6(java.lang.String[])") + check(sig("m7", ai) , "public int A.m7(int[])") + check(sig("m8", ao) , "public java.lang.Object A.m8(java.lang.Object[])") + + check(genSig("m1", ao), "public <T> T A.m1(T...)") + check(genSig("m2", ao), "public <T> T A.m2(T...)") + check(genSig("m3", ao), "public <T> T A.m3(T...)") + // testing status quo: signature is wrong for T <: Int, SI-9846 + check(genSig("m4", ao), "public <T> T A.m4(T...)") + check(genSig("m5", as), "public <T> T A.m5(T...)") + check(genSig("m6", as), "public java.lang.String A.m6(java.lang.String...)") + check(genSig("m7", ai), "public int A.m7(int...)") + check(genSig("m8", ao), "public U A.m8(U...)") + + check(bound("m1", ao) , "class java.lang.Object") + check(bound("m2", ao) , "class java.lang.Object") + check(bound("m3", ao) , "class java.lang.Object") + check(bound("m4", ao) , "class java.lang.Object") + check(bound("m5", as) , "class java.lang.String") + check(bound("m6", as) , "") + check(bound("m7", ai) , "") + check(bound("m8", ao) , "class java.lang.Object") + + + check(sig("n1", ob) , "public java.lang.Object A.n1(java.lang.Object)") + check(sig("n2", ao) , "public java.lang.Object A.n2(java.lang.Object[])") + check(sig("n3", ob) , "public java.lang.Object A.n3(java.lang.Object)") + check(sig("n4", ob) , "public int A.n4(java.lang.Object)") + check(sig("n5", as) , "public java.lang.String A.n5(java.lang.String[])") + check(sig("n6", as) , "public java.lang.String A.n6(java.lang.String[])") + check(sig("n7", ai) , "public int A.n7(int[])") + check(sig("n8", ob) , "public java.lang.Object A.n8(java.lang.Object)") + + check(genSig("n1", ob), "public <T> T A.n1(java.lang.Object)") + check(genSig("n2", ao), "public <T> T A.n2(T[])") + check(genSig("n3", ob), "public <T> T A.n3(java.lang.Object)") + // testing status quo: signature is wrong for T <: Int, SI-9846 + check(genSig("n4", ob), "public <T> T A.n4(java.lang.Object)") + check(genSig("n5", as), "public <T> T A.n5(T[])") + check(genSig("n6", as), "public java.lang.String A.n6(java.lang.String[])") + check(genSig("n7", ai), "public int A.n7(int[])") + check(genSig("n8", ob), "public U A.n8(java.lang.Object)") +} diff --git a/test/files/jvm/t8786/A_1.scala b/test/files/jvm/t8786/A_1.scala new file mode 100644 index 0000000000..13c0ad191d --- /dev/null +++ b/test/files/jvm/t8786/A_1.scala @@ -0,0 +1,3 @@ +class A { + @annotation.varargs def foo[T](a: Int, b: T*): T = b.head +} diff --git a/test/files/jvm/t8786/B_2.java b/test/files/jvm/t8786/B_2.java new file mode 100644 index 0000000000..dc155a290f --- /dev/null +++ b/test/files/jvm/t8786/B_2.java @@ -0,0 +1,22 @@ +public class B_2 { + private static int res = 0; + + public static void m(char a[]) { res += 10; } + public static void m(String a) { res += 100; } + public static void m(Object a) { res += 1000; } + + public static <T> T foo(int a, T... b) { return b[0]; } + + public static <T> T bar(T b[]) { return b[0]; } + + public static void main(String[] args) { + m(foo(15, "a", "b", "c")); + if (res != 100) + throw new Error("bad: "+ res); + + A a = new A(); + m(a.foo(16, "a", "b", "c")); + if (res != 200) + throw new Error("bad: " + res); + } +} diff --git a/test/files/jvm/t8786/Test_2.scala b/test/files/jvm/t8786/Test_2.scala new file mode 100644 index 0000000000..76ccb4c3ed --- /dev/null +++ b/test/files/jvm/t8786/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + B_2.main(null) +} diff --git a/test/files/jvm/varargs/JavaClass.java b/test/files/jvm/varargs/JavaClass.java index 6928ee5adc..0cc3587c5e 100644 --- a/test/files/jvm/varargs/JavaClass.java +++ b/test/files/jvm/varargs/JavaClass.java @@ -1,16 +1,12 @@ - - - public class JavaClass { - public static <T> void varargz(int i, T... v) { - } - - public static void callSomeAnnotations() { - VaClass va = new VaClass(); - va.vs(4, "", "", ""); - va.vi(1, 2, 3, 4); - varargz(5, 1.0, 2.0, 3.0); - va.vt(16, "", "", ""); - System.out.println(va.vt1(16, "a", "b", "c")); - } -}
\ No newline at end of file + public static <T> void varargz(int i, T... v) { } + + public static void callSomeAnnotations() { + VaClass va = new VaClass(); + va.vs(4, "", "", ""); + va.vi(1, 2, 3, 4); + varargz(5, 1.0, 2.0, 3.0); + va.vt(16, "", "", ""); + System.out.println(va.vt1(16, "a", "b", "c")); + } +} diff --git a/test/files/jvm/varargs/VaClass.scala b/test/files/jvm/varargs/VaClass.scala index d83e63ace1..ee8c288a16 100644 --- a/test/files/jvm/varargs/VaClass.scala +++ b/test/files/jvm/varargs/VaClass.scala @@ -1,15 +1,8 @@ - - import annotation.varargs - - class VaClass { - @varargs def vs(a: Int, b: String*) = println(a + b.length) @varargs def vi(a: Int, b: Int*) = println(a + b.sum) @varargs def vt[T](a: Int, b: T*) = println(a + b.length) - - // TODO remove type bound after fixing SI-8786, see also https://github.com/scala/scala/pull/3961 - @varargs def vt1[T <: String](a: Int, b: T*): T = b.head + @varargs def vt1[T](a: Int, b: T*): T = b.head } diff --git a/test/files/jvm/varargs/varargs.scala b/test/files/jvm/varargs/varargs.scala index 6d2e707bdf..b09818f46f 100644 --- a/test/files/jvm/varargs/varargs.scala +++ b/test/files/jvm/varargs/varargs.scala @@ -1,21 +1,5 @@ - - - - - - object Test { def main(args: Array[String]) { JavaClass.callSomeAnnotations } } - - - - - - - - - - diff --git a/test/files/neg/overloaded-unapply.check b/test/files/neg/overloaded-unapply.check index 68a826bac2..3951166de5 100644 --- a/test/files/neg/overloaded-unapply.check +++ b/test/files/neg/overloaded-unapply.check @@ -7,8 +7,8 @@ match argument types (List[a]) overloaded-unapply.scala:22: error: cannot resolve overloaded unapply case List(x, xs) => 7 ^ -overloaded-unapply.scala:12: error: method unapply is defined twice - conflicting symbols both originated in file 'overloaded-unapply.scala' +overloaded-unapply.scala:12: error: method unapply is defined twice; + the conflicting method unapply was defined at line 7:7 def unapply[a](xs: List[a]): Option[Null] = xs match { ^ three errors found diff --git a/test/files/neg/t0764.check b/test/files/neg/t0764.check index 0c7cff1e1e..830278e715 100644 --- a/test/files/neg/t0764.check +++ b/test/files/neg/t0764.check @@ -1,5 +1,5 @@ t0764.scala:13: error: type mismatch; - found : Node{type T = _1.type} where val _1: Node{type T = NextType} + found : Node{type T = _2.type} where val _2: Node{type T = NextType} required: Node{type T = Main.this.AType} (which expands to) Node{type T = Node{type T = NextType}} new Main[AType]( (value: AType).prepend ) diff --git a/test/files/neg/t1960.check b/test/files/neg/t1960.check index 5238141c4e..de0907b4a9 100644 --- a/test/files/neg/t1960.check +++ b/test/files/neg/t1960.check @@ -1,4 +1,4 @@ -t1960.scala:5: error: parameter 'p' requires field but conflicts with method p in trait TBase +t1960.scala:5: error: parameter 'p' requires field but conflicts with variable p in trait TBase class Aclass (p: Int) extends TBase { def g() { f(p) } } ^ one error found diff --git a/test/files/neg/t200.check b/test/files/neg/t200.check index b6b1a32267..f0c5e77772 100644 --- a/test/files/neg/t200.check +++ b/test/files/neg/t200.check @@ -1,5 +1,5 @@ -t200.scala:7: error: method foo is defined twice - conflicting symbols both originated in file 't200.scala' +t200.scala:7: error: method foo is defined twice; + the conflicting method foo was defined at line 6:7 def foo: Int; ^ one error found diff --git a/test/files/neg/t2779.check b/test/files/neg/t2779.check index 0ab4c50d0f..9881d5182c 100644 --- a/test/files/neg/t2779.check +++ b/test/files/neg/t2779.check @@ -1,5 +1,5 @@ -t2779.scala:16: error: method f is defined twice - conflicting symbols both originated in file 't2779.scala' +t2779.scala:16: error: method f is defined twice; + the conflicting method f was defined at line 15:18 override def f = List(M1) ^ one error found diff --git a/test/files/neg/t278.check b/test/files/neg/t278.check index 405f7d225c..940b8edcef 100644 --- a/test/files/neg/t278.check +++ b/test/files/neg/t278.check @@ -4,8 +4,8 @@ t278.scala:5: error: overloaded method value a with alternatives: does not take type parameters println(a[A]) ^ -t278.scala:4: error: method a is defined twice - conflicting symbols both originated in file 't278.scala' +t278.scala:4: error: method a is defined twice; + the conflicting method a was defined at line 3:7 def a = (p:A) => () ^ two errors found diff --git a/test/files/neg/t3871.check b/test/files/neg/t3871.check index b920357ee6..c9667abfb6 100644 --- a/test/files/neg/t3871.check +++ b/test/files/neg/t3871.check @@ -1,5 +1,5 @@ t3871.scala:4: error: variable foo in class Sub2 cannot be accessed in Sub2 - Access to protected method foo not permitted because + Access to protected variable foo not permitted because enclosing class Base is not a subclass of class Sub2 where target is defined s.foo = true diff --git a/test/files/neg/t4541.check b/test/files/neg/t4541.check index 7bd8ff78f9..7ee0cc6414 100644 --- a/test/files/neg/t4541.check +++ b/test/files/neg/t4541.check @@ -1,5 +1,5 @@ t4541.scala:11: error: variable data in class Sparse cannot be accessed in Sparse[Int] - Access to protected method data not permitted because + Access to protected variable data not permitted because prefix type Sparse[Int] does not conform to class Sparse$mcI$sp where the access take place that.data diff --git a/test/files/neg/t4541b.check b/test/files/neg/t4541b.check index 8a52fd97f4..2aae95f6b9 100644 --- a/test/files/neg/t4541b.check +++ b/test/files/neg/t4541b.check @@ -1,5 +1,5 @@ t4541b.scala:13: error: variable data in class SparseArray cannot be accessed in SparseArray[Int] - Access to protected method data not permitted because + Access to protected variable data not permitted because prefix type SparseArray[Int] does not conform to class SparseArray$mcI$sp where the access take place use(that.data.clone) diff --git a/test/files/neg/t5429.check b/test/files/neg/t5429.check index 4350696bc8..fb2d9c2e47 100644 --- a/test/files/neg/t5429.check +++ b/test/files/neg/t5429.check @@ -134,7 +134,7 @@ t5429.scala:87: error: overriding value value in class A0 of type Any; lazy value value cannot override a concrete non-lazy value override lazy val value = 0 // fail (strict over lazy) ^ -t5429.scala:91: error: value oneArg overrides nothing. +t5429.scala:91: error: lazy value oneArg overrides nothing. Note: the super classes of class F0 contain the following, non final members named oneArg: def oneArg(x: String): Any override lazy val oneArg = 15 // fail diff --git a/test/files/neg/t591.check b/test/files/neg/t591.check index d33f6d7a2f..c0bade0814 100644 --- a/test/files/neg/t591.check +++ b/test/files/neg/t591.check @@ -1,5 +1,5 @@ -t591.scala:38: error: method input_= is defined twice - conflicting symbols both originated in file 't591.scala' +t591.scala:40: error: method input_= is defined twice; + the conflicting variable input was defined at line 35:18 def input_=(in : Input) = {} ^ one error found diff --git a/test/files/neg/t591.scala b/test/files/neg/t591.scala index 0f0b02395c..14fb256a69 100644 --- a/test/files/neg/t591.scala +++ b/test/files/neg/t591.scala @@ -35,7 +35,8 @@ trait BaseFlow extends BaseList { private var input : Input = _; private var output : Output = _; + // the error message is a bit confusing, as it points here, + // but the symbol it reports is `input`'s actual setter (the one we synthesized) def input_=(in : Input) = {} - } } diff --git a/test/files/neg/t6335.check b/test/files/neg/t6335.check index 1727a05eb2..d118440f75 100644 --- a/test/files/neg/t6335.check +++ b/test/files/neg/t6335.check @@ -1,9 +1,9 @@ -t6335.scala:6: error: method Z is defined twice - conflicting symbols both originated in file 't6335.scala' +t6335.scala:6: error: method Z is defined twice; + the conflicting method Z was defined at line 5:7 implicit class Z[A](val i: A) { def zz = i } ^ -t6335.scala:3: error: method X is defined twice - conflicting symbols both originated in file 't6335.scala' +t6335.scala:3: error: method X is defined twice; + the conflicting method X was defined at line 2:7 implicit class X(val x: Int) { def xx = x } ^ two errors found diff --git a/test/files/neg/t6446-additional.check b/test/files/neg/t6446-additional.check index e56a67b28b..45db63317c 100644 --- a/test/files/neg/t6446-additional.check +++ b/test/files/neg/t6446-additional.check @@ -10,18 +10,19 @@ superaccessors 6 add super accessors in traits and nested classes pickler 8 serialize symbol tables refchecks 9 reference/override checking, translate nested objects uncurry 10 uncurry, translate function values to anonymous classes - tailcalls 11 replace tail calls by jumps - specialize 12 @specialized-driven class and method specialization - explicitouter 13 this refs to outer pointers - erasure 14 erase types, add interfaces for traits - posterasure 15 clean up erased inline classes - lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 17 move nested functions to top level - constructors 18 move field definitions into constructors - flatten 19 eliminate inner classes - mixin 20 mixin composition - cleanup 21 platform-specific cleanups, generate reflective calls - delambdafy 22 remove lambdas - 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 + fields 11 synthesize accessors and fields + tailcalls 12 replace tail calls by jumps + specialize 13 @specialized-driven class and method specialization + explicitouter 14 this refs to outer pointers + erasure 15 erase types, add interfaces for traits + posterasure 16 clean up erased inline classes + lazyvals 17 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 18 move nested functions to top level + constructors 19 move field definitions into constructors + flatten 20 eliminate inner classes + mixin 21 mixin composition + cleanup 22 platform-specific cleanups, generate reflective calls + delambdafy 23 remove lambdas + 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 diff --git a/test/files/neg/t6446-missing.check b/test/files/neg/t6446-missing.check index 15f0ceb6e3..04523d18e6 100644 --- a/test/files/neg/t6446-missing.check +++ b/test/files/neg/t6446-missing.check @@ -11,17 +11,18 @@ superaccessors 6 add super accessors in traits and nested classes pickler 8 serialize symbol tables refchecks 9 reference/override checking, translate nested objects uncurry 10 uncurry, translate function values to anonymous classes - tailcalls 11 replace tail calls by jumps - specialize 12 @specialized-driven class and method specialization - explicitouter 13 this refs to outer pointers - erasure 14 erase types, add interfaces for traits - posterasure 15 clean up erased inline classes - lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 17 move nested functions to top level - constructors 18 move field definitions into constructors - flatten 19 eliminate inner classes - mixin 20 mixin composition - cleanup 21 platform-specific cleanups, generate reflective calls - delambdafy 22 remove lambdas - jvm 23 generate JVM bytecode - terminal 24 the last phase during a compilation run + fields 11 synthesize accessors and fields + tailcalls 12 replace tail calls by jumps + specialize 13 @specialized-driven class and method specialization + explicitouter 14 this refs to outer pointers + erasure 15 erase types, add interfaces for traits + posterasure 16 clean up erased inline classes + lazyvals 17 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 18 move nested functions to top level + constructors 19 move field definitions into constructors + flatten 20 eliminate inner classes + mixin 21 mixin composition + cleanup 22 platform-specific cleanups, generate reflective calls + delambdafy 23 remove lambdas + jvm 24 generate JVM bytecode + terminal 25 the last phase during a compilation run diff --git a/test/files/neg/t6446-show-phases.check b/test/files/neg/t6446-show-phases.check index 280a4f43d5..03f8273c17 100644 --- a/test/files/neg/t6446-show-phases.check +++ b/test/files/neg/t6446-show-phases.check @@ -10,17 +10,18 @@ superaccessors 6 add super accessors in traits and nested classes pickler 8 serialize symbol tables refchecks 9 reference/override checking, translate nested objects uncurry 10 uncurry, translate function values to anonymous classes - tailcalls 11 replace tail calls by jumps - specialize 12 @specialized-driven class and method specialization - explicitouter 13 this refs to outer pointers - erasure 14 erase types, add interfaces for traits - posterasure 15 clean up erased inline classes - lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 17 move nested functions to top level - constructors 18 move field definitions into constructors - flatten 19 eliminate inner classes - mixin 20 mixin composition - cleanup 21 platform-specific cleanups, generate reflective calls - delambdafy 22 remove lambdas - jvm 23 generate JVM bytecode - terminal 24 the last phase during a compilation run + fields 11 synthesize accessors and fields + tailcalls 12 replace tail calls by jumps + specialize 13 @specialized-driven class and method specialization + explicitouter 14 this refs to outer pointers + erasure 15 erase types, add interfaces for traits + posterasure 16 clean up erased inline classes + lazyvals 17 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 18 move nested functions to top level + constructors 19 move field definitions into constructors + flatten 20 eliminate inner classes + mixin 21 mixin composition + cleanup 22 platform-specific cleanups, generate reflective calls + delambdafy 23 remove lambdas + jvm 24 generate JVM bytecode + terminal 25 the last phase during a compilation run diff --git a/test/files/neg/t6455.flags b/test/files/neg/t6455.flags deleted file mode 100644 index 112fc720a0..0000000000 --- a/test/files/neg/t6455.flags +++ /dev/null @@ -1 +0,0 @@ --Xfuture
\ No newline at end of file diff --git a/test/files/neg/t6455.scala b/test/files/neg/t6455.scala index ebbb37f1cd..22e4c30fdd 100644 --- a/test/files/neg/t6455.scala +++ b/test/files/neg/t6455.scala @@ -1,6 +1,6 @@ object O { def filter(p: Int => Boolean): O.type = this } class Test { - // should not compile because we no longer rewrite withFilter => filter under -Xfuture + // should not compile because we no longer rewrite withFilter => filter O.withFilter(f => true) -}
\ No newline at end of file +} diff --git a/test/files/neg/t6666.check b/test/files/neg/t6666.check index 43c8252753..090ef72770 100644 --- a/test/files/neg/t6666.check +++ b/test/files/neg/t6666.check @@ -1,7 +1,7 @@ t6666.scala:23: error: Implementation restriction: access of method x$2 in object O1 from <$anon: Function0>, would require illegal premature access to object O1 F.byname(x) ^ -t6666.scala:30: error: Implementation restriction: access of value x$3 in object O2 from <$anon: Function0>, would require illegal premature access to object O2 +t6666.scala:30: error: Implementation restriction: access of method x$3 in object O2 from <$anon: Function0>, would require illegal premature access to object O2 F.byname(x) ^ t6666.scala:37: error: Implementation restriction: access of method x$4 in object O3 from <$anon: Function0>, would require illegal premature access to object O3 @@ -10,7 +10,7 @@ t6666.scala:37: error: Implementation restriction: access of method x$4 in objec t6666.scala:50: error: Implementation restriction: access of method x$6 in class C1 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C1 F.byname(x) ^ -t6666.scala:54: error: Implementation restriction: access of value x$7 in class C2 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C2 +t6666.scala:54: error: Implementation restriction: access of method x$7 in class C2 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C2 F.byname(x) ^ t6666.scala:58: error: Implementation restriction: access of method x$8 in class C3 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C3 diff --git a/test/files/neg/t7187.check b/test/files/neg/t7187.check new file mode 100644 index 0000000000..a30803c746 --- /dev/null +++ b/test/files/neg/t7187.check @@ -0,0 +1,6 @@ +t7187.scala:3: warning: Eta-expansion of zero-argument method values is deprecated. Did you intend to write EtaExpandZeroArg.this.foo()? + val f: () => Any = foo + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7187.flags b/test/files/neg/t7187.flags new file mode 100644 index 0000000000..c6bfaf1f64 --- /dev/null +++ b/test/files/neg/t7187.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings diff --git a/test/files/neg/t7187.scala b/test/files/neg/t7187.scala new file mode 100644 index 0000000000..45d33f06af --- /dev/null +++ b/test/files/neg/t7187.scala @@ -0,0 +1,6 @@ +class EtaExpandZeroArg { + def foo(): () => String = () => "" + val f: () => Any = foo + + // f() would evaluate to <function0> instead of "" +} diff --git a/test/files/neg/t7494-no-options.check b/test/files/neg/t7494-no-options.check index a4c4a1ad5b..bb143e8644 100644 --- a/test/files/neg/t7494-no-options.check +++ b/test/files/neg/t7494-no-options.check @@ -11,18 +11,19 @@ superaccessors 6 add super accessors in traits and nested classes pickler 8 serialize symbol tables refchecks 9 reference/override checking, translate nested objects uncurry 10 uncurry, translate function values to anonymous classes - tailcalls 11 replace tail calls by jumps - specialize 12 @specialized-driven class and method specialization - explicitouter 13 this refs to outer pointers - erasure 14 erase types, add interfaces for traits - posterasure 15 clean up erased inline classes - lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 17 move nested functions to top level - constructors 18 move field definitions into constructors - flatten 19 eliminate inner classes - mixin 20 mixin composition - cleanup 21 platform-specific cleanups, generate reflective calls - delambdafy 22 remove lambdas - 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 + fields 11 synthesize accessors and fields + tailcalls 12 replace tail calls by jumps + specialize 13 @specialized-driven class and method specialization + explicitouter 14 this refs to outer pointers + erasure 15 erase types, add interfaces for traits + posterasure 16 clean up erased inline classes + lazyvals 17 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 18 move nested functions to top level + constructors 19 move field definitions into constructors + flatten 20 eliminate inner classes + mixin 21 mixin composition + cleanup 22 platform-specific cleanups, generate reflective calls + delambdafy 23 remove lambdas + 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 diff --git a/test/files/neg/t7602.check b/test/files/neg/t7602.check index 5bb1450d7d..5ce3776790 100644 --- a/test/files/neg/t7602.check +++ b/test/files/neg/t7602.check @@ -1,5 +1,5 @@ -t7602.scala:16: error: method foo is defined twice - conflicting symbols both originated in file 't7602.scala' +t7602.scala:16: error: method foo is defined twice; + the conflicting method foo was defined at line 15:7 def foo : Device ^ one error found diff --git a/test/files/neg/t7622-cyclic-dependency.check b/test/files/neg/t7622-cyclic-dependency.check index 3546964f5f..81e3ecc6a4 100644 --- a/test/files/neg/t7622-cyclic-dependency.check +++ b/test/files/neg/t7622-cyclic-dependency.check @@ -1 +1 @@ -error: Cycle in phase dependencies detected at cyclicdependency1, created phase-cycle.dot +error: Cycle in phase dependencies detected at cyclicdependency2, created phase-cycle.dot diff --git a/test/files/neg/t800.check b/test/files/neg/t800.check index 8ba95fddde..238b8dd27d 100644 --- a/test/files/neg/t800.check +++ b/test/files/neg/t800.check @@ -1,16 +1,16 @@ t800.scala:4: error: qualification is already defined as value qualification val qualification = false; ^ -t800.scala:8: error: method qualification is defined twice - conflicting symbols both originated in file 't800.scala' +t800.scala:8: error: value qualification is defined twice; + the conflicting variable qualification was defined at line 7:7 val qualification = false; ^ -t800.scala:12: error: value qualification is defined twice - conflicting symbols both originated in file 't800.scala' +t800.scala:12: error: variable qualification is defined twice; + the conflicting value qualification was defined at line 11:7 var qualification = false; ^ -t800.scala:16: error: method qualification is defined twice - conflicting symbols both originated in file 't800.scala' +t800.scala:16: error: variable qualification is defined twice; + the conflicting variable qualification was defined at line 15:7 var qualification = false; ^ four errors found diff --git a/test/files/neg/t8849.check b/test/files/neg/t8849.check index 15b00aee8b..1d5b4164b2 100644 --- a/test/files/neg/t8849.check +++ b/test/files/neg/t8849.check @@ -1,5 +1,5 @@ t8849.scala:8: error: ambiguous implicit values: - both value global in object Implicits of type => scala.concurrent.ExecutionContext + both lazy value global in object Implicits of type => scala.concurrent.ExecutionContext and value dummy of type scala.concurrent.ExecutionContext match expected type scala.concurrent.ExecutionContext require(implicitly[ExecutionContext] eq dummy) diff --git a/test/files/neg/t9684.check b/test/files/neg/t9684.check index ab36479a47..bb5669733d 100644 --- a/test/files/neg/t9684.check +++ b/test/files/neg/t9684.check @@ -1,7 +1,7 @@ -t9684.scala:6: warning: object JavaConversions in package collection is deprecated (since 2.12): Use JavaConverters +t9684.scala:6: warning: object JavaConversions in package collection is deprecated (since 2.12.0): use JavaConverters null.asInstanceOf[java.util.List[Int]] : Buffer[Int] ^ -t9684.scala:8: warning: object JavaConversions in package collection is deprecated (since 2.12): Use JavaConverters +t9684.scala:8: warning: object JavaConversions in package collection is deprecated (since 2.12.0): use JavaConverters null.asInstanceOf[Iterable[Int]] : java.util.Collection[Int] ^ error: No warnings can be incurred under -Xfatal-warnings. diff --git a/test/files/neg/trait_fields_conflicts.check b/test/files/neg/trait_fields_conflicts.check new file mode 100644 index 0000000000..696d0284c1 --- /dev/null +++ b/test/files/neg/trait_fields_conflicts.check @@ -0,0 +1,273 @@ +trait_fields_conflicts.scala:5: error: overriding value x in trait Val of type Int; + value x needs `override' modifier +trait ValForVal extends Val { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:6: error: overriding value x in trait Val of type Int; + variable x needs `override' modifier +trait VarForVal extends Val { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:7: error: overriding value x in trait Val of type Int; + method x needs `override' modifier +trait DefForVal extends Val { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:8: error: overriding variable x in trait Var of type Int; + value x needs `override' modifier +trait ValForVar extends Var { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:9: error: overriding variable x in trait Var of type Int; + variable x needs `override' modifier +trait VarForVar extends Var { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:10: error: overriding variable x in trait Var of type Int; + method x needs `override' modifier +trait DefForVar extends Var { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:11: error: overriding lazy value x in trait Lazy of type Int; + value x needs `override' modifier +trait ValForLazy extends Lazy { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:12: error: overriding lazy value x in trait Lazy of type Int; + variable x needs `override' modifier +trait VarForLazy extends Lazy { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:13: error: overriding lazy value x in trait Lazy of type Int; + method x needs `override' modifier +trait DefForLazy extends Lazy { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:16: error: overriding value x in trait Val of type Int; + variable x needs to be a stable, immutable value +trait VarForValOvr extends Val { override var x: Int = 1 } // bad override + ^ +trait_fields_conflicts.scala:17: error: overriding value x in trait Val of type Int; + method x needs to be a stable, immutable value +trait DefForValOvr extends Val { override def x: Int = 1 } // bad override + ^ +trait_fields_conflicts.scala:18: error: overriding variable x in trait Var of type Int; + value x cannot override a mutable variable +trait ValForVarOvr extends Var { override val x: Int = 1 } // bad override -- unsound if used in path and var changes + ^ +trait_fields_conflicts.scala:19: error: overriding variable x in trait Var of type Int; + variable x cannot override a mutable variable +trait VarForVarOvr extends Var { override var x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:20: error: overriding variable x in trait Var of type Int; + method x cannot override a mutable variable +trait DefForVarOvr extends Var { override def x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:21: error: overriding lazy value x in trait Lazy of type Int; + value x must be declared lazy to override a concrete lazy value +trait ValForLazyOvr extends Lazy { override val x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:22: error: overriding lazy value x in trait Lazy of type Int; + variable x needs to be a stable, immutable value +trait VarForLazyOvr extends Lazy { override var x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:23: error: overriding lazy value x in trait Lazy of type Int; + method x needs to be a stable, immutable value +trait DefForLazyOvr extends Lazy { override def x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:25: error: overriding value x in trait Val of type Int; + value x needs `override' modifier +class CValForVal extends Val { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:26: error: overriding value x in trait Val of type Int; + variable x needs `override' modifier +class CVarForVal extends Val { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:27: error: overriding value x in trait Val of type Int; + method x needs `override' modifier +class CDefForVal extends Val { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:28: error: overriding variable x in trait Var of type Int; + value x needs `override' modifier +class CValForVar extends Var { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:29: error: overriding variable x in trait Var of type Int; + variable x needs `override' modifier +class CVarForVar extends Var { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:30: error: overriding variable x in trait Var of type Int; + method x needs `override' modifier +class CDefForVar extends Var { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:31: error: overriding lazy value x in trait Lazy of type Int; + value x needs `override' modifier +class CValForLazy extends Lazy { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:32: error: overriding lazy value x in trait Lazy of type Int; + variable x needs `override' modifier +class CVarForLazy extends Lazy { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:33: error: overriding lazy value x in trait Lazy of type Int; + method x needs `override' modifier +class CDefForLazy extends Lazy { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:36: error: overriding value x in trait Val of type Int; + variable x needs to be a stable, immutable value +class CVarForValOvr extends Val { override var x: Int = 1 } // bad override + ^ +trait_fields_conflicts.scala:37: error: overriding value x in trait Val of type Int; + method x needs to be a stable, immutable value +class CDefForValOvr extends Val { override def x: Int = 1 } // bad override + ^ +trait_fields_conflicts.scala:38: error: overriding variable x in trait Var of type Int; + value x cannot override a mutable variable +class CValForVarOvr extends Var { override val x: Int = 1 } // bad override -- unsound if used in path and var changes + ^ +trait_fields_conflicts.scala:39: error: overriding variable x in trait Var of type Int; + variable x cannot override a mutable variable +class CVarForVarOvr extends Var { override var x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:40: error: overriding variable x in trait Var of type Int; + method x cannot override a mutable variable +class CDefForVarOvr extends Var { override def x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:41: error: overriding lazy value x in trait Lazy of type Int; + value x must be declared lazy to override a concrete lazy value +class CValForLazyOvr extends Lazy { override val x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:42: error: overriding lazy value x in trait Lazy of type Int; + variable x needs to be a stable, immutable value +class CVarForLazyOvr extends Lazy { override var x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:43: error: overriding lazy value x in trait Lazy of type Int; + method x needs to be a stable, immutable value +class CDefForLazyOvr extends Lazy { override def x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:49: error: overriding value x in class CVal of type Int; + value x needs `override' modifier +trait ValForCVal extends CVal { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:50: error: overriding value x in class CVal of type Int; + variable x needs `override' modifier +trait VarForCVal extends CVal { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:51: error: overriding value x in class CVal of type Int; + method x needs `override' modifier +trait DefForCVal extends CVal { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:52: error: overriding variable x in class CVar of type Int; + value x needs `override' modifier +trait ValForCVar extends CVar { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:53: error: overriding variable x in class CVar of type Int; + variable x needs `override' modifier +trait VarForCVar extends CVar { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:54: error: overriding variable x in class CVar of type Int; + method x needs `override' modifier +trait DefForCVar extends CVar { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:55: error: overriding lazy value x in class CLazy of type Int; + value x needs `override' modifier +trait ValForCLazy extends CLazy { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:56: error: overriding lazy value x in class CLazy of type Int; + variable x needs `override' modifier +trait VarForCLazy extends CLazy { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:57: error: overriding lazy value x in class CLazy of type Int; + method x needs `override' modifier +trait DefForCLazy extends CLazy { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:60: error: overriding value x in class CVal of type Int; + variable x needs to be a stable, immutable value +trait VarForCValOvr extends CVal { override var x: Int = 1 } // bad override + ^ +trait_fields_conflicts.scala:61: error: overriding value x in class CVal of type Int; + method x needs to be a stable, immutable value +trait DefForCValOvr extends CVal { override def x: Int = 1 } // bad override + ^ +trait_fields_conflicts.scala:62: error: overriding variable x in class CVar of type Int; + value x cannot override a mutable variable +trait ValForCVarOvr extends CVar { override val x: Int = 1 } // bad override -- unsound if used in path and var changes + ^ +trait_fields_conflicts.scala:63: error: overriding variable x in class CVar of type Int; + variable x cannot override a mutable variable +trait VarForCVarOvr extends CVar { override var x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:64: error: overriding variable x in class CVar of type Int; + method x cannot override a mutable variable +trait DefForCVarOvr extends CVar { override def x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:65: error: overriding lazy value x in class CLazy of type Int; + value x must be declared lazy to override a concrete lazy value +trait ValForCLazyOvr extends CLazy { override val x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:66: error: overriding lazy value x in class CLazy of type Int; + variable x needs to be a stable, immutable value +trait VarForCLazyOvr extends CLazy { override var x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:67: error: overriding lazy value x in class CLazy of type Int; + method x needs to be a stable, immutable value +trait DefForCLazyOvr extends CLazy { override def x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:69: error: overriding value x in class CVal of type Int; + value x needs `override' modifier +class CValForCVal extends CVal { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:70: error: overriding value x in class CVal of type Int; + variable x needs `override' modifier +class CVarForCVal extends CVal { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:71: error: overriding value x in class CVal of type Int; + method x needs `override' modifier +class CDefForCVal extends CVal { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:72: error: overriding variable x in class CVar of type Int; + value x needs `override' modifier +class CValForCVar extends CVar { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:73: error: overriding variable x in class CVar of type Int; + variable x needs `override' modifier +class CVarForCVar extends CVar { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:74: error: overriding variable x in class CVar of type Int; + method x needs `override' modifier +class CDefForCVar extends CVar { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:75: error: overriding lazy value x in class CLazy of type Int; + value x needs `override' modifier +class CValForCLazy extends CLazy { val x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:76: error: overriding lazy value x in class CLazy of type Int; + variable x needs `override' modifier +class CVarForCLazy extends CLazy { var x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:77: error: overriding lazy value x in class CLazy of type Int; + method x needs `override' modifier +class CDefForCLazy extends CLazy { def x: Int = 1 } // needs override + ^ +trait_fields_conflicts.scala:80: error: overriding value x in class CVal of type Int; + variable x needs to be a stable, immutable value +class CVarForCValOvr extends CVal { override var x: Int = 1 } // bad override + ^ +trait_fields_conflicts.scala:81: error: overriding value x in class CVal of type Int; + method x needs to be a stable, immutable value +class CDefForCValOvr extends CVal { override def x: Int = 1 } // bad override + ^ +trait_fields_conflicts.scala:82: error: overriding variable x in class CVar of type Int; + value x cannot override a mutable variable +class CValForCVarOvr extends CVar { override val x: Int = 1 } // bad override -- unsound if used in path and var changes + ^ +trait_fields_conflicts.scala:83: error: overriding variable x in class CVar of type Int; + variable x cannot override a mutable variable +class CVarForCVarOvr extends CVar { override var x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:84: error: overriding variable x in class CVar of type Int; + method x cannot override a mutable variable +class CDefForCVarOvr extends CVar { override def x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:85: error: overriding lazy value x in class CLazy of type Int; + value x must be declared lazy to override a concrete lazy value +class CValForCLazyOvr extends CLazy { override val x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:86: error: overriding lazy value x in class CLazy of type Int; + variable x needs to be a stable, immutable value +class CVarForCLazyOvr extends CLazy { override var x: Int = 1 } // bad override -- why? + ^ +trait_fields_conflicts.scala:87: error: overriding lazy value x in class CLazy of type Int; + method x needs to be a stable, immutable value +class CDefForCLazyOvr extends CLazy { override def x: Int = 1 } // bad override -- why? + ^ +68 errors found diff --git a/test/files/neg/trait_fields_conflicts.scala b/test/files/neg/trait_fields_conflicts.scala new file mode 100644 index 0000000000..92fc106e44 --- /dev/null +++ b/test/files/neg/trait_fields_conflicts.scala @@ -0,0 +1,87 @@ +trait Val { val x: Int = 123 } +trait Var { var x: Int = 123 } +trait Lazy { lazy val x: Int = 123 } + +trait ValForVal extends Val { val x: Int = 1 } // needs override +trait VarForVal extends Val { var x: Int = 1 } // needs override +trait DefForVal extends Val { def x: Int = 1 } // needs override +trait ValForVar extends Var { val x: Int = 1 } // needs override +trait VarForVar extends Var { var x: Int = 1 } // needs override +trait DefForVar extends Var { def x: Int = 1 } // needs override +trait ValForLazy extends Lazy { val x: Int = 1 } // needs override +trait VarForLazy extends Lazy { var x: Int = 1 } // needs override +trait DefForLazy extends Lazy { def x: Int = 1 } // needs override + +trait ValForValOvr extends Val { override val x: Int = 1 } // override ok +trait VarForValOvr extends Val { override var x: Int = 1 } // bad override +trait DefForValOvr extends Val { override def x: Int = 1 } // bad override +trait ValForVarOvr extends Var { override val x: Int = 1 } // bad override -- unsound if used in path and var changes +trait VarForVarOvr extends Var { override var x: Int = 1 } // bad override -- why? +trait DefForVarOvr extends Var { override def x: Int = 1 } // bad override -- why? +trait ValForLazyOvr extends Lazy { override val x: Int = 1 } // bad override -- why? +trait VarForLazyOvr extends Lazy { override var x: Int = 1 } // bad override -- why? +trait DefForLazyOvr extends Lazy { override def x: Int = 1 } // bad override -- why? + +class CValForVal extends Val { val x: Int = 1 } // needs override +class CVarForVal extends Val { var x: Int = 1 } // needs override +class CDefForVal extends Val { def x: Int = 1 } // needs override +class CValForVar extends Var { val x: Int = 1 } // needs override +class CVarForVar extends Var { var x: Int = 1 } // needs override +class CDefForVar extends Var { def x: Int = 1 } // needs override +class CValForLazy extends Lazy { val x: Int = 1 } // needs override +class CVarForLazy extends Lazy { var x: Int = 1 } // needs override +class CDefForLazy extends Lazy { def x: Int = 1 } // needs override + +class CValForValOvr extends Val { override val x: Int = 1 } // override ok +class CVarForValOvr extends Val { override var x: Int = 1 } // bad override +class CDefForValOvr extends Val { override def x: Int = 1 } // bad override +class CValForVarOvr extends Var { override val x: Int = 1 } // bad override -- unsound if used in path and var changes +class CVarForVarOvr extends Var { override var x: Int = 1 } // bad override -- why? +class CDefForVarOvr extends Var { override def x: Int = 1 } // bad override -- why? +class CValForLazyOvr extends Lazy { override val x: Int = 1 } // bad override -- why? +class CVarForLazyOvr extends Lazy { override var x: Int = 1 } // bad override -- why? +class CDefForLazyOvr extends Lazy { override def x: Int = 1 } // bad override -- why? + +class CVal { val x: Int = 123 } +class CVar { var x: Int = 123 } +class CLazy { lazy val x: Int = 123 } + +trait ValForCVal extends CVal { val x: Int = 1 } // needs override +trait VarForCVal extends CVal { var x: Int = 1 } // needs override +trait DefForCVal extends CVal { def x: Int = 1 } // needs override +trait ValForCVar extends CVar { val x: Int = 1 } // needs override +trait VarForCVar extends CVar { var x: Int = 1 } // needs override +trait DefForCVar extends CVar { def x: Int = 1 } // needs override +trait ValForCLazy extends CLazy { val x: Int = 1 } // needs override +trait VarForCLazy extends CLazy { var x: Int = 1 } // needs override +trait DefForCLazy extends CLazy { def x: Int = 1 } // needs override + +trait ValForCValOvr extends CVal { override val x: Int = 1 } // override ok +trait VarForCValOvr extends CVal { override var x: Int = 1 } // bad override +trait DefForCValOvr extends CVal { override def x: Int = 1 } // bad override +trait ValForCVarOvr extends CVar { override val x: Int = 1 } // bad override -- unsound if used in path and var changes +trait VarForCVarOvr extends CVar { override var x: Int = 1 } // bad override -- why? +trait DefForCVarOvr extends CVar { override def x: Int = 1 } // bad override -- why? +trait ValForCLazyOvr extends CLazy { override val x: Int = 1 } // bad override -- why? +trait VarForCLazyOvr extends CLazy { override var x: Int = 1 } // bad override -- why? +trait DefForCLazyOvr extends CLazy { override def x: Int = 1 } // bad override -- why? + +class CValForCVal extends CVal { val x: Int = 1 } // needs override +class CVarForCVal extends CVal { var x: Int = 1 } // needs override +class CDefForCVal extends CVal { def x: Int = 1 } // needs override +class CValForCVar extends CVar { val x: Int = 1 } // needs override +class CVarForCVar extends CVar { var x: Int = 1 } // needs override +class CDefForCVar extends CVar { def x: Int = 1 } // needs override +class CValForCLazy extends CLazy { val x: Int = 1 } // needs override +class CVarForCLazy extends CLazy { var x: Int = 1 } // needs override +class CDefForCLazy extends CLazy { def x: Int = 1 } // needs override + +class CValForCValOvr extends CVal { override val x: Int = 1 } // override ok +class CVarForCValOvr extends CVal { override var x: Int = 1 } // bad override +class CDefForCValOvr extends CVal { override def x: Int = 1 } // bad override +class CValForCVarOvr extends CVar { override val x: Int = 1 } // bad override -- unsound if used in path and var changes +class CVarForCVarOvr extends CVar { override var x: Int = 1 } // bad override -- why? +class CDefForCVarOvr extends CVar { override def x: Int = 1 } // bad override -- why? +class CValForCLazyOvr extends CLazy { override val x: Int = 1 } // bad override -- why? +class CVarForCLazyOvr extends CLazy { override var x: Int = 1 } // bad override -- why? +class CDefForCLazyOvr extends CLazy { override def x: Int = 1 } // bad override -- why? diff --git a/test/files/neg/trait_fields_deprecated_overriding.check b/test/files/neg/trait_fields_deprecated_overriding.check new file mode 100644 index 0000000000..89dfa5c295 --- /dev/null +++ b/test/files/neg/trait_fields_deprecated_overriding.check @@ -0,0 +1,6 @@ +trait_fields_deprecated_overriding.scala:8: warning: overriding value x in trait DeprecatedOverriding is deprecated + override val x = 2 + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/trait_fields_deprecated_overriding.flags b/test/files/neg/trait_fields_deprecated_overriding.flags new file mode 100644 index 0000000000..c6bfaf1f64 --- /dev/null +++ b/test/files/neg/trait_fields_deprecated_overriding.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings diff --git a/test/files/neg/trait_fields_deprecated_overriding.scala b/test/files/neg/trait_fields_deprecated_overriding.scala new file mode 100644 index 0000000000..e7d722c92f --- /dev/null +++ b/test/files/neg/trait_fields_deprecated_overriding.scala @@ -0,0 +1,11 @@ +package scala + +trait DeprecatedOverriding { + @deprecatedOverriding val x = 1 +} + +class COverride extends DeprecatedOverriding { + override val x = 2 +} + +class CSynthImpl extends DeprecatedOverriding
\ No newline at end of file diff --git a/test/files/neg/trait_fields_var_override.check b/test/files/neg/trait_fields_var_override.check new file mode 100644 index 0000000000..7245c78b09 --- /dev/null +++ b/test/files/neg/trait_fields_var_override.check @@ -0,0 +1,5 @@ +trait_fields_var_override.scala:2: error: overriding variable end in trait SizeChangeEvent of type Int; + variable end cannot override a mutable variable +class BackedUpListIterator[E](override protected var end: Int) extends SizeChangeEvent + ^ +one error found diff --git a/test/files/neg/trait_fields_var_override.scala b/test/files/neg/trait_fields_var_override.scala new file mode 100644 index 0000000000..f61ba09eec --- /dev/null +++ b/test/files/neg/trait_fields_var_override.scala @@ -0,0 +1,2 @@ +trait SizeChangeEvent { protected var end: Int = 1 } +class BackedUpListIterator[E](override protected var end: Int) extends SizeChangeEvent diff --git a/test/files/neg/val_infer.check b/test/files/neg/val_infer.check new file mode 100644 index 0000000000..711450add9 --- /dev/null +++ b/test/files/neg/val_infer.check @@ -0,0 +1,6 @@ +val_infer.scala:3: error: type mismatch; + found : String("") + required: Int + trait Sub extends Base { def foo = "" } + ^ +one error found diff --git a/test/files/neg/val_infer.scala b/test/files/neg/val_infer.scala new file mode 100644 index 0000000000..7fe8393749 --- /dev/null +++ b/test/files/neg/val_infer.scala @@ -0,0 +1,4 @@ +class Test { + trait Base { def foo: Int } + trait Sub extends Base { def foo = "" } +}
\ No newline at end of file diff --git a/test/files/neg/val_sig_infer_match.check b/test/files/neg/val_sig_infer_match.check new file mode 100644 index 0000000000..704c99cf84 --- /dev/null +++ b/test/files/neg/val_sig_infer_match.check @@ -0,0 +1,4 @@ +val_sig_infer_match.scala:21: error: value y is not a member of A + def m = f.y // doesn't compile anymore + ^ +one error found diff --git a/test/files/neg/val_sig_infer_match.scala b/test/files/neg/val_sig_infer_match.scala new file mode 100644 index 0000000000..fb8aa66d56 --- /dev/null +++ b/test/files/neg/val_sig_infer_match.scala @@ -0,0 +1,22 @@ +class A + +class B extends A { + def y: Int = 0 +} + +class B1 extends B +class B2 extends B + +class C { + def f: A = null +} + +class D extends C { + def s = "" + override final val f = s match { + case "" => new B1 + case _ => new B2 + } + + def m = f.y // doesn't compile anymore +}
\ No newline at end of file diff --git a/test/files/neg/val_sig_infer_struct.check b/test/files/neg/val_sig_infer_struct.check new file mode 100644 index 0000000000..26efbbc3f4 --- /dev/null +++ b/test/files/neg/val_sig_infer_struct.check @@ -0,0 +1,4 @@ +val_sig_infer_struct.scala:7: error: value foo is not a member of Object + def bar = f.foo + ^ +one error found diff --git a/test/files/neg/val_sig_infer_struct.scala b/test/files/neg/val_sig_infer_struct.scala new file mode 100644 index 0000000000..e88340337c --- /dev/null +++ b/test/files/neg/val_sig_infer_struct.scala @@ -0,0 +1,8 @@ +class C { + def f: Object = this +} + +class D extends C { + override val f = new Object { def foo = 1 } + def bar = f.foo +}
\ No newline at end of file diff --git a/test/files/neg/warn-unused-privates.check b/test/files/neg/warn-unused-privates.check index 4876ed8fc2..2e93f338bb 100644 --- a/test/files/neg/warn-unused-privates.check +++ b/test/files/neg/warn-unused-privates.check @@ -19,10 +19,7 @@ warn-unused-privates.scala:36: warning: private val in class Boppy is never used warn-unused-privates.scala:43: warning: private var in trait Accessors is never used private var v1: Int = 0 // warn ^ -warn-unused-privates.scala:43: warning: private setter in trait Accessors is never used - private var v1: Int = 0 // warn - ^ -warn-unused-privates.scala:44: warning: private setter in trait Accessors is never used +warn-unused-privates.scala:44: warning: private var in trait Accessors is never used private var v2: Int = 0 // warn, never set ^ warn-unused-privates.scala:45: warning: private var in trait Accessors is never used @@ -65,5 +62,5 @@ warn-unused-privates.scala:103: warning: local type OtherThing is never used type OtherThing = String // warn ^ error: No warnings can be incurred under -Xfatal-warnings. -22 warnings found +21 warnings found one error found diff --git a/test/files/presentation/t4287c.flags b/test/files/pos/infer_override_def_args.flags index d1a8244169..d1a8244169 100644 --- a/test/files/presentation/t4287c.flags +++ b/test/files/pos/infer_override_def_args.flags diff --git a/test/files/pos/infer_override_def_args.scala b/test/files/pos/infer_override_def_args.scala new file mode 100644 index 0000000000..ac10720c81 --- /dev/null +++ b/test/files/pos/infer_override_def_args.scala @@ -0,0 +1,5 @@ +abstract class A { def foo(a: Int): A } +class B extends A { + implicit def spackle(x: Int): A = new B + def foo(a) = a +}
\ No newline at end of file diff --git a/test/files/pos/t7239.scala b/test/files/pos/t7239.scala deleted file mode 100644 index 16e9d00f17..0000000000 --- a/test/files/pos/t7239.scala +++ /dev/null @@ -1,38 +0,0 @@ -object Test { - def BrokenMethod(): HasFilter[(Int, String)] = ??? - - trait HasFilter[B] { - def filter(p: B => Boolean) = ??? - } - - trait HasWithFilter { - def withFilter = ??? - } - - object addWithFilter { - trait NoImplicit - implicit def enrich(v: Any) - (implicit F0: NoImplicit): HasWithFilter = ??? - } - - BrokenMethod().withFilter(_ => true) // okay - BrokenMethod().filter(_ => true) // okay - - locally { - import addWithFilter._ - BrokenMethod().withFilter((_: (Int, String)) => true) // okay - } - - locally { - import addWithFilter._ - // adaptToMemberWithArgs sets the type of the tree `x` - // to ErrorType (while in silent mode, so the error is not - // reported. Later, when the fallback from `withFilter` - // to `filter` is attempted, the closure is taken to have - // have the type `<error> => Boolean`, which conforms to - // `(B => Boolean)`. Only later during pickling does the - // defensive check for erroneous types in the tree pick up - // the problem. - BrokenMethod().withFilter(x => true) // erroneous or inaccessible type. - } -} diff --git a/test/files/pos/t9178.flags b/test/files/pos/t9178.flags deleted file mode 100644 index 7de3c0f3ee..0000000000 --- a/test/files/pos/t9178.flags +++ /dev/null @@ -1 +0,0 @@ --Xfatal-warnings -deprecation diff --git a/test/files/pos/t9178.scala b/test/files/pos/t9178.scala deleted file mode 100644 index f2cf20a778..0000000000 --- a/test/files/pos/t9178.scala +++ /dev/null @@ -1,13 +0,0 @@ -// eta expansion to Function0 is problematic (as shown here). -// Perhaps we should we deprecate it? See discussion in the comments of -// on SI-9178. -// -// This test encodes the status quo: no deprecation. -object Test { - def foo(): () => String = () => "" - val f: () => Any = foo - - def main(args: Array[String]): Unit = { - println(f()) // <function0> - } -} diff --git a/test/files/pos/trait_fields_dependent_conflict.scala b/test/files/pos/trait_fields_dependent_conflict.scala new file mode 100644 index 0000000000..afb6f4b0c5 --- /dev/null +++ b/test/files/pos/trait_fields_dependent_conflict.scala @@ -0,0 +1,20 @@ +// derived from test/files/pos/S5.scala + +// compile with -uniqid to see a hint of the trouble +trait N { + // the symbol for self does not get rebound when synthesizing members in C + val self: N = ??? + val n: self.type = self +} + +abstract class M { + val self: N + val n: self.type +} + +abstract class MConflict extends N { + val self: N + val n: self.type +} + +class C extends M with N diff --git a/test/files/pos/trait_fields_dependent_rebind.scala b/test/files/pos/trait_fields_dependent_rebind.scala new file mode 100644 index 0000000000..e2cf4c43c3 --- /dev/null +++ b/test/files/pos/trait_fields_dependent_rebind.scala @@ -0,0 +1,15 @@ +// derived from test/files/pos/S5.scala + +// compile with -uniqid to see a hint of the trouble +trait N { + // the symbol for self does not get rebound when synthesizing members in C + val self: N = ??? + val n: self.type = self +} + +abstract class M { + val self: N + val n: self.type +} + +class C extends M with N diff --git a/test/files/pos/trait_fields_inherit_double_def.scala b/test/files/pos/trait_fields_inherit_double_def.scala new file mode 100644 index 0000000000..8703d6312c --- /dev/null +++ b/test/files/pos/trait_fields_inherit_double_def.scala @@ -0,0 +1,20 @@ +// done +// test/files/trait-defaults/fields.scala:24: error: double definition: +// def signalDelegate_=(x$1: Signalling): Unit at line 24 and +// def signalDelegate_=(x$1: Signalling): Unit at line 24 +// have same type +// class SUB extends IterableSplitter +// ^ +// one error found + +trait Signalling + +trait DelegatedSignalling extends Signalling { + var signalDelegate: Signalling +} + +trait IterableSplitter extends DelegatedSignalling { + var signalDelegate: Signalling = ??? +} + +class SUB extends IterableSplitter
\ No newline at end of file diff --git a/test/files/pos/trait_fields_lambdalift.scala b/test/files/pos/trait_fields_lambdalift.scala new file mode 100644 index 0000000000..62304a5268 --- /dev/null +++ b/test/files/pos/trait_fields_lambdalift.scala @@ -0,0 +1,22 @@ +class Lift { + def foo = { + // this will be captured by the MouseHandler trait, + // which gives rise to a new trait field during LambdaLift + var Clicked = "Clicked" + + def bar = Clicked + + trait MouseHandler { + def mouseClicked = Clicked + bar + } + + class CC extends MouseHandler + + // new C {} + (new CC).mouseClicked + } +} + +object O extends Lift with App { + println(foo) +} diff --git a/test/files/pos/trait_fields_nested_private_object.scala b/test/files/pos/trait_fields_nested_private_object.scala new file mode 100644 index 0000000000..8efc1cb3fa --- /dev/null +++ b/test/files/pos/trait_fields_nested_private_object.scala @@ -0,0 +1,8 @@ +trait NestedObj { + private object O { println("NO") } +} + + +class C extends NestedObj { + def O = ??? +}
\ No newline at end of file diff --git a/test/files/pos/trait_fields_nested_public_object.scala b/test/files/pos/trait_fields_nested_public_object.scala new file mode 100644 index 0000000000..016487fb8a --- /dev/null +++ b/test/files/pos/trait_fields_nested_public_object.scala @@ -0,0 +1,5 @@ +trait NestedObj { + object O { println("NO") } +} + +class C extends NestedObj
\ No newline at end of file diff --git a/test/files/pos/trait_fields_owners.scala b/test/files/pos/trait_fields_owners.scala new file mode 100644 index 0000000000..6aa5572171 --- /dev/null +++ b/test/files/pos/trait_fields_owners.scala @@ -0,0 +1,19 @@ +trait V { + // ok + // error: java.lang.IllegalArgumentException: Could not find proxy for val f: Function1 in List(value f, value v, trait V, package <empty>, package <root>) (currentOwner= value <local V$class> ) + val v = { val f = (x: Int) => x + 1; f(2) } + + // ok + // assertion failed: + // Trying to access the this of another class: tree.symbol = trait V, class symbol = object V$class compilation unit: fields.scala + val developmentVersion = + for { + v <- scalaPropOrNone("maven.version.number") + if v endsWith "-SNAPSHOT" + ov <- scalaPropOrNone("version.number") + } yield ov + + def scalaPropOrNone(name: String): Option[String] = ??? +} + +object O extends V
\ No newline at end of file diff --git a/test/files/pos/trait_fields_private_this.scala b/test/files/pos/trait_fields_private_this.scala new file mode 100644 index 0000000000..8065cc89e6 --- /dev/null +++ b/test/files/pos/trait_fields_private_this.scala @@ -0,0 +1,5 @@ +trait Chars { + private[this] val char2uescapeArray: String = ??? +} + +object Chars extends Chars
\ No newline at end of file diff --git a/test/files/pos/trait_fields_static_fwd.scala b/test/files/pos/trait_fields_static_fwd.scala new file mode 100644 index 0000000000..af2cdad9ff --- /dev/null +++ b/test/files/pos/trait_fields_static_fwd.scala @@ -0,0 +1,10 @@ +trait T { + // Need to mark the synthesized member in the object's module class as notPROTECTED, + // since the trait member will receive this flag later. + // If we don't add notPROTECTED to the synthesized one, the member will not be seen as overriding the trait member. + // Therefore, addForwarders's call to membersBasedOnFlags would see the deferred member in the trait, + // instead of the concrete (desired) one in the class, and thus not create the static forwarder. + protected val propFilename: String = "/" +} + +object P extends T diff --git a/test/files/pos/trait_fields_var_override_deferred.scala b/test/files/pos/trait_fields_var_override_deferred.scala new file mode 100644 index 0000000000..0205326506 --- /dev/null +++ b/test/files/pos/trait_fields_var_override_deferred.scala @@ -0,0 +1,2 @@ +trait SizeChangeEvent { protected var end: Int } +class BackedUpListIterator[E](override protected var end: Int) extends SizeChangeEvent diff --git a/test/files/pos/trait_fields_volatile.scala b/test/files/pos/trait_fields_volatile.scala new file mode 100644 index 0000000000..030b24f187 --- /dev/null +++ b/test/files/pos/trait_fields_volatile.scala @@ -0,0 +1,13 @@ +// This test illustrates the intent of what should work (but didn't for a while during the fields refactoring), +// but it does not actually defend against the regression seen in twitter-util's Scheduler, which I cannot reproduce +// outside the project. The whole project consistently fails to build before, and compiles after the commit +// that includes this test, but this single test file (as well as Scheduler.scala with external dependencies removed) +// compiles both before and after.... +// (https://github.com/twitter/util/blob/6398a56923/util-core/src/main/scala/com/twitter/concurrent/Scheduler.scala#L260-L265) +// There's also a run test that checks that the field in C is actually volatile. +trait Vola { + @volatile private[this] var _vola = "tile" + @volatile var vola = "tile" +} + +class C extends Vola diff --git a/test/files/pos/val_infer.scala b/test/files/pos/val_infer.scala new file mode 100644 index 0000000000..5f82da8393 --- /dev/null +++ b/test/files/pos/val_infer.scala @@ -0,0 +1,5 @@ +class Test { + implicit def s2i(s: String): Int = s.length + trait Base { def foo: Int } + trait Sub extends Base { val foo = "" } +} diff --git a/test/files/presentation/doc/doc.scala b/test/files/presentation/doc/doc.scala index 8c60af557b..08c6ebf059 100644 --- a/test/files/presentation/doc/doc.scala +++ b/test/files/presentation/doc/doc.scala @@ -37,7 +37,7 @@ object Test extends InteractiveTest { prepre + docComment(nTags) + prepost + post } - override lazy val compiler = { + override lazy val compiler: Global { def getComment(sym: Symbol, source: SourceFile, fragments: List[(Symbol,SourceFile)]): Option[Comment] } = { prepareSettings(settings) new Global(settings, compilerReporter) with MemberLookupBase with CommentFactoryBase with doc.ScaladocGlobalTrait { outer => diff --git a/test/files/presentation/scope-completion-3.check b/test/files/presentation/scope-completion-3.check index b70a7d5c6b..f2510127fb 100644 --- a/test/files/presentation/scope-completion-3.check +++ b/test/files/presentation/scope-completion-3.check @@ -3,7 +3,7 @@ reload: Completions.scala askScopeCompletion at Completions.scala(75,2) ================================================================================ [response] askScopeCompletion at (75,2) -retrieved 37 members +retrieved 38 members abstract class Base1 extends AnyRef abstract trait Trait1 extends AnyRef class Cb1 extends AnyRef @@ -14,6 +14,8 @@ def <init>(): test.Completion1 def fb1: Int def fc1: Int def ft1: Int +def rt1: Int +def rt1_=(x$1: Int): Unit object Completion2 object Ob1 object Oc1 @@ -30,23 +32,22 @@ private[this] val vb1: Int private[this] val vb3: Int private[this] val vc1: Int private[this] val vc2: Int -private[this] val vt1: Int private[this] val vt3: Int private[this] var rb1: Int private[this] var rb3: Int private[this] var rc1: Int private[this] var rc2: Int -private[this] var rt1: Int private[this] var rt3: Int type tb1 = Completion1.this.tb1 type tc1 = Completion1.this.tc1 type tt1 = Completion1.this.tt1 +val vt1: Int ================================================================================ askScopeCompletion at Completions.scala(104,2) ================================================================================ [response] askScopeCompletion at (104,2) -retrieved 37 members +retrieved 38 members abstract class Base1 extends AnyRef abstract trait Trait1 extends AnyRef class Cb1 extends AnyRef @@ -57,6 +58,8 @@ def <init>(): test.Completion2.type def fb1: Int def fo1: Int def ft1: Int +def rt1: Int +def rt1_=(x$1: Int): Unit object Completion2 object Ob1 object Oo1 @@ -73,15 +76,14 @@ private[this] val vb1: Int private[this] val vb3: Int private[this] val vo1: Int private[this] val vo2: Int -private[this] val vt1: Int private[this] val vt3: Int private[this] var rb1: Int private[this] var rb3: Int private[this] var ro1: Int private[this] var ro2: Int -private[this] var rt1: Int private[this] var rt3: Int type tb1 = test.Completion2.tb1 type to1 = test.Completion2.to1 type tt1 = test.Completion2.tt1 +val vt1: Int ================================================================================ diff --git a/test/files/presentation/t4287c.check b/test/files/presentation/t4287c.check deleted file mode 100644 index 42fc30997d..0000000000 --- a/test/files/presentation/t4287c.check +++ /dev/null @@ -1,11 +0,0 @@ -reload: Foo.scala - -askHyperlinkPos for `A` at (1,18) Foo.scala -================================================================================ -[response] found askHyperlinkPos for `A` at (3,8) Foo.scala -================================================================================ - -askHyperlinkPos for `a` at (1,25) Foo.scala -================================================================================ -[response] found askHyperlinkPos for `a` at (4,7) Foo.scala -================================================================================ diff --git a/test/files/presentation/t4287c/Test.scala b/test/files/presentation/t4287c/Test.scala deleted file mode 100644 index bec1131c4c..0000000000 --- a/test/files/presentation/t4287c/Test.scala +++ /dev/null @@ -1,3 +0,0 @@ -import scala.tools.nsc.interactive.tests.InteractiveTest - -object Test extends InteractiveTest
\ No newline at end of file diff --git a/test/files/presentation/t4287c/src/Foo.scala b/test/files/presentation/t4287c/src/Foo.scala deleted file mode 100644 index 26870b5021..0000000000 --- a/test/files/presentation/t4287c/src/Foo.scala +++ /dev/null @@ -1,9 +0,0 @@ -class A(a: Int = A/*#*/.a/*#*/) - -object A { - val a = 2 -} - -class B extends A { - def this(a) = this() -}
\ No newline at end of file diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala index 5e21edaba3..1d0e02262d 100644 --- a/test/files/run/Course-2002-08.scala +++ b/test/files/run/Course-2002-08.scala @@ -205,7 +205,7 @@ object M5 { val inputSig = input.getSignal; afterDelay(InverterDelay) {() => output.setSignal(!inputSig) }; } - input addAction invertAction + input addAction invertAction _ } def andGate(a1: Wire, a2: Wire, output: Wire): Unit = { @@ -214,8 +214,8 @@ object M5 { val a2Sig = a2.getSignal; afterDelay(AndGateDelay) {() => output.setSignal(a1Sig & a2Sig) }; } - a1 addAction andAction; - a2 addAction andAction; + a1 addAction andAction _ + a2 addAction andAction _ } def orGate(o1: Wire, o2: Wire, output: Wire): Unit = { @@ -224,8 +224,8 @@ object M5 { val o2Sig = o2.getSignal; afterDelay(OrGateDelay) {() => output.setSignal(o1Sig | o2Sig) }; } - o1 addAction orAction; - o2 addAction orAction; + o1 addAction orAction _ + o2 addAction orAction _ } def probe(name: String, wire: Wire): Unit = { @@ -479,7 +479,7 @@ abstract class BasicCircuitSimulator() extends Simulator() { val inputSig = input.getSignal; afterDelay(InverterDelay) {() => output.setSignal(!inputSig) }; } - input addAction invertAction + input addAction invertAction _ } def andGate(a1: Wire, a2: Wire, output: Wire) = { @@ -488,8 +488,8 @@ abstract class BasicCircuitSimulator() extends Simulator() { val a2Sig = a2.getSignal; afterDelay(AndGateDelay) {() => output.setSignal(a1Sig & a2Sig) }; } - a1 addAction andAction; - a2 addAction andAction + a1 addAction andAction _ + a2 addAction andAction _ } def orGate(a1: Wire, a2: Wire, output: Wire) = { @@ -498,8 +498,8 @@ abstract class BasicCircuitSimulator() extends Simulator() { val a2Sig = a2.getSignal; afterDelay(OrGateDelay) {() => output.setSignal(a1Sig | a2Sig) }; } - a1 addAction orAction; - a2 addAction orAction + a1 addAction orAction _ + a2 addAction orAction _ } def orGate2(a1: Wire, a2: Wire, output: Wire) = { diff --git a/test/files/run/SymbolsTest.scala b/test/files/run/SymbolsTest.scala index d5948ea168..7c185b0e09 100644 --- a/test/files/run/SymbolsTest.scala +++ b/test/files/run/SymbolsTest.scala @@ -137,16 +137,16 @@ object Test { // } // val an2 = () => { // object nested { - // val m = 'mfsa + // val m = 'mfsa // } // nested.m // } // val an3 = () => { // object nested { - // val f = () => { - // 'layered - // } - // def gets = f() + // val f = () => { + // 'layered + // } + // def gets = f() // } // nested.gets // } @@ -204,8 +204,8 @@ object Test { val s1 = 's1 def s2 = 's2 object inner { - val s3 = 's3 - val s4 = 's4 + val s3 = 's3 + val s4 = 's4 } } @@ -223,8 +223,8 @@ object Test { val s5 = 's5 def s6 = 's6 object inner2 { - val s7 = 's7 - def s8 = 's8 + val s7 = 's7 + def s8 = 's8 } } assert(Local.s5 == 's5) diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check index 1bb7c6ceab..ca0005ea4d 100644 --- a/test/files/run/analyzerPlugins.check +++ b/test/files/run/analyzerPlugins.check @@ -21,7 +21,6 @@ lub(List(Int @testAnn, Int)) [1] pluginsPt(?, Trees$Annotated) [7] pluginsPt(?, Trees$Apply) [11] pluginsPt(?, Trees$ApplyImplicitView) [2] -pluginsPt(?, Trees$Assign) [7] pluginsPt(?, Trees$Block) [4] pluginsPt(?, Trees$ClassDef) [2] pluginsPt(?, Trees$DefDef) [14] @@ -31,9 +30,9 @@ pluginsPt(?, Trees$Literal) [16] pluginsPt(?, Trees$New) [5] pluginsPt(?, Trees$PackageDef) [1] pluginsPt(?, Trees$Return) [1] -pluginsPt(?, Trees$Select) [50] +pluginsPt(?, Trees$Select) [43] pluginsPt(?, Trees$Super) [2] -pluginsPt(?, Trees$This) [20] +pluginsPt(?, Trees$This) [13] pluginsPt(?, Trees$TypeApply) [3] pluginsPt(?, Trees$TypeBoundsTree) [2] pluginsPt(?, Trees$TypeDef) [1] @@ -47,23 +46,19 @@ pluginsPt(Boolean @testAnn, Trees$Literal) [1] pluginsPt(Boolean @testAnn, Trees$Select) [1] pluginsPt(Boolean, Trees$Apply) [1] pluginsPt(Boolean, Trees$Ident) [1] -pluginsPt(Boolean, Trees$Literal) [1] pluginsPt(Double, Trees$Select) [1] pluginsPt(Int @testAnn, Trees$Literal) [1] pluginsPt(Int, Trees$Apply) [1] -pluginsPt(Int, Trees$Ident) [2] -pluginsPt(Int, Trees$If) [1] -pluginsPt(Int, Trees$Literal) [5] +pluginsPt(Int, Trees$Ident) [1] +pluginsPt(Int, Trees$Literal) [4] pluginsPt(Int, Trees$Select) [3] -pluginsPt(List, Trees$Apply) [1] pluginsPt(List[Any], Trees$Select) [1] pluginsPt(String @testAnn, Trees$Select) [1] pluginsPt(String, Trees$Apply) [1] pluginsPt(String, Trees$Block) [2] -pluginsPt(String, Trees$Ident) [4] +pluginsPt(String, Trees$Ident) [3] pluginsPt(String, Trees$Literal) [1] pluginsPt(String, Trees$Select) [1] -pluginsPt(String, Trees$Typed) [1] pluginsPt(Unit, Trees$Assign) [1] pluginsPt(testAnn, Trees$Apply) [5] pluginsTypeSig(<none>, Trees$Template) [2] @@ -119,7 +114,7 @@ pluginsTyped(=> Int, Trees$TypeApply) [1] pluginsTyped(=> String @testAnn, Trees$Select) [1] pluginsTyped(A, Trees$Apply) [1] pluginsTyped(A, Trees$Ident) [2] -pluginsTyped(A, Trees$This) [8] +pluginsTyped(A, Trees$This) [1] pluginsTyped(A, Trees$TypeTree) [4] pluginsTyped(A.super.type, Trees$Super) [1] pluginsTyped(A.this.type, Trees$This) [11] @@ -128,25 +123,23 @@ pluginsTyped(AnyRef, Trees$Select) [4] pluginsTyped(Array[Any], Trees$ArrayValue) [1] pluginsTyped(Boolean @testAnn, Trees$Select) [1] pluginsTyped(Boolean @testAnn, Trees$TypeTree) [4] -pluginsTyped(Boolean(false), Trees$Literal) [2] +pluginsTyped(Boolean(false), Trees$Literal) [1] pluginsTyped(Boolean, Trees$Apply) [1] -pluginsTyped(Boolean, Trees$Select) [4] +pluginsTyped(Boolean, Trees$Select) [3] pluginsTyped(Char('c'), Trees$Literal) [2] pluginsTyped(Double, Trees$Apply) [3] pluginsTyped(Double, Trees$Select) [6] pluginsTyped(Int @testAnn, Trees$TypeTree) [2] pluginsTyped(Int @testAnn, Trees$Typed) [2] -pluginsTyped(Int(0), Trees$Literal) [3] +pluginsTyped(Int(0), Trees$Literal) [2] pluginsTyped(Int(1) @testAnn, Trees$Typed) [1] pluginsTyped(Int(1), Trees$Literal) [8] pluginsTyped(Int(2), Trees$Literal) [1] pluginsTyped(Int, Trees$Apply) [1] -pluginsTyped(Int, Trees$Ident) [2] -pluginsTyped(Int, Trees$If) [2] -pluginsTyped(Int, Trees$Select) [15] +pluginsTyped(Int, Trees$Ident) [1] +pluginsTyped(Int, Trees$If) [1] +pluginsTyped(Int, Trees$Select) [12] pluginsTyped(Int, Trees$TypeTree) [13] -pluginsTyped(List, Trees$Apply) [1] -pluginsTyped(List, Trees$Select) [1] pluginsTyped(List[Any], Trees$Apply) [1] pluginsTyped(List[Any], Trees$Select) [1] pluginsTyped(List[Any], Trees$TypeTree) [3] @@ -159,15 +152,13 @@ pluginsTyped(String(""), Trees$Literal) [2] pluginsTyped(String("huhu"), Trees$Literal) [1] pluginsTyped(String("str") @testAnn, Trees$Typed) [1] pluginsTyped(String("str"), Trees$Literal) [1] -pluginsTyped(String("str"), Trees$Typed) [1] pluginsTyped(String("two"), Trees$Literal) [2] pluginsTyped(String, Trees$Apply) [2] pluginsTyped(String, Trees$Block) [2] -pluginsTyped(String, Trees$Ident) [1] -pluginsTyped(String, Trees$Select) [9] +pluginsTyped(String, Trees$Select) [7] pluginsTyped(String, Trees$TypeTree) [7] pluginsTyped(Unit, Trees$Apply) [2] -pluginsTyped(Unit, Trees$Assign) [8] +pluginsTyped(Unit, Trees$Assign) [1] pluginsTyped(Unit, Trees$Block) [4] pluginsTyped(Unit, Trees$If) [1] pluginsTyped(Unit, Trees$Literal) [5] diff --git a/test/files/run/array-charSeq.check b/test/files/run/array-charSeq.check index f1f374f63e..3ccf493cee 100644 --- a/test/files/run/array-charSeq.check +++ b/test/files/run/array-charSeq.check @@ -1,3 +1,4 @@ +warning: there were two deprecation warnings (since 2.12.0); re-run with -deprecation for details [check 'abcdefghi'] len = 9 sub(0, 9) == 'abcdefghi' diff --git a/test/files/run/bitsets.check b/test/files/run/bitsets.check index 770d9b5e3f..89e51f9a78 100644 --- a/test/files/run/bitsets.check +++ b/test/files/run/bitsets.check @@ -1,4 +1,4 @@ -warning: there were three deprecation warnings (since 2.11.6); re-run with -deprecation for details +warning: there were three deprecation warnings (since 2.12.0); re-run with -deprecation for details ms0 = BitSet(2) ms1 = BitSet(2) ms2 = BitSet(2) diff --git a/test/files/run/collection-stacks.check b/test/files/run/collection-stacks.check index 826e3a87f8..cd87cc61e4 100644 --- a/test/files/run/collection-stacks.check +++ b/test/files/run/collection-stacks.check @@ -1,4 +1,6 @@ -warning: there was one deprecation warning (since 2.11.0); re-run with -deprecation for details +warning: there was one deprecation warning (since 2.11.0) +warning: there were two deprecation warnings (since 2.12.0) +warning: there were three deprecation warnings in total; re-run with -deprecation for details 3-2-1: true 3-2-1: true apply diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index 5444cf2088..4acd9d16ae 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -69,11 +69,11 @@ scala> var four = "four" four: String = four scala> val four2 = m(four) // should have an existential bound -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' four2: String @Annot(x) forSome { val x: String } = four scala> val four3 = four2 // should have the same type as four2 -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' four3: String @Annot(x) forSome { val x: String } = four scala> val stuff = m("stuff") // should not crash @@ -96,7 +96,7 @@ scala> def m = { val y : String @Annot(x) = x y } // x should not escape the local scope with a narrow type -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' m: String @Annot(x) forSome { val x: String } scala> @@ -110,7 +110,7 @@ scala> def n(y: String) = { } m("stuff".stripMargin) } // x should be existentially bound -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' n: (y: String)String @Annot(x) forSome { val x: String } scala> diff --git a/test/files/run/iterator-from.scala b/test/files/run/iterator-from.scala index e7ba1aeb28..01006ffc21 100644 --- a/test/files/run/iterator-from.scala +++ b/test/files/run/iterator-from.scala @@ -1,5 +1,5 @@ /* This file tests iteratorFrom, keysIteratorFrom, and valueIteratorFrom on various sorted sets and maps - * filter: inliner warnings; re-run with + * filter: inliner warnings */ import scala.util.{Random => R} diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index 280a4f43d5..03f8273c17 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -10,17 +10,18 @@ superaccessors 6 add super accessors in traits and nested classes pickler 8 serialize symbol tables refchecks 9 reference/override checking, translate nested objects uncurry 10 uncurry, translate function values to anonymous classes - tailcalls 11 replace tail calls by jumps - specialize 12 @specialized-driven class and method specialization - explicitouter 13 this refs to outer pointers - erasure 14 erase types, add interfaces for traits - posterasure 15 clean up erased inline classes - lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 17 move nested functions to top level - constructors 18 move field definitions into constructors - flatten 19 eliminate inner classes - mixin 20 mixin composition - cleanup 21 platform-specific cleanups, generate reflective calls - delambdafy 22 remove lambdas - jvm 23 generate JVM bytecode - terminal 24 the last phase during a compilation run + fields 11 synthesize accessors and fields + tailcalls 12 replace tail calls by jumps + specialize 13 @specialized-driven class and method specialization + explicitouter 14 this refs to outer pointers + erasure 15 erase types, add interfaces for traits + posterasure 16 clean up erased inline classes + lazyvals 17 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 18 move nested functions to top level + constructors 19 move field definitions into constructors + flatten 20 eliminate inner classes + mixin 21 mixin composition + cleanup 22 platform-specific cleanups, generate reflective calls + delambdafy 23 remove lambdas + jvm 24 generate JVM bytecode + terminal 25 the last phase during a compilation run diff --git a/test/files/run/reflection-fieldsymbol-navigation.check b/test/files/run/reflection-fieldsymbol-navigation.check index ae0597a045..fd06c78a18 100644 --- a/test/files/run/reflection-fieldsymbol-navigation.check +++ b/test/files/run/reflection-fieldsymbol-navigation.check @@ -1,6 +1,6 @@ -method x +variable x false variable x true -method x -method x_= +variable x +variable x diff --git a/test/files/run/reflection-magicsymbols-repl.check b/test/files/run/reflection-magicsymbols-repl.check index dd26c08349..a33f41012e 100644 --- a/test/files/run/reflection-magicsymbols-repl.check +++ b/test/files/run/reflection-magicsymbols-repl.check @@ -19,7 +19,7 @@ scala> def test(n: Int): Unit = { val x = sig.asInstanceOf[MethodType].params.head println(x.info) } -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' test: (n: Int)Unit scala> for (i <- 1 to 8) test(i) diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index 21fbe34d96..1217e8d8c2 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -35,7 +35,7 @@ Int scala> :type protected lazy val f = 5 <console>:5: error: lazy value f cannot be accessed in object $iw - Access to protected value f not permitted because + Access to protected lazy value f not permitted because enclosing object $eval in package $line13 is not a subclass of object $iw where target is defined lazy val $result = f diff --git a/test/files/run/repl-no-imports-no-predef-power.check b/test/files/run/repl-no-imports-no-predef-power.check index a76db3dbc2..08f614eb60 100644 --- a/test/files/run/repl-no-imports-no-predef-power.check +++ b/test/files/run/repl-no-imports-no-predef-power.check @@ -7,11 +7,11 @@ Try :help or completions for vals._ and power._ scala> // guarding against "error: reference to global is ambiguous" scala> global.emptyValDef // "it is imported twice in the same scope by ..." -warning: there was one deprecation warning (since 2.11.0); re-run with -deprecation for details +warning: there was one deprecation warning (since 2.11.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res0: $r.global.noSelfType.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' tp: $r.global.Type = Array[scala.util.Random] scala> tp.memberType(Array_apply) // evidence diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index a76db3dbc2..08f614eb60 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -7,11 +7,11 @@ Try :help or completions for vals._ and power._ scala> // guarding against "error: reference to global is ambiguous" scala> global.emptyValDef // "it is imported twice in the same scope by ..." -warning: there was one deprecation warning (since 2.11.0); re-run with -deprecation for details +warning: there was one deprecation warning (since 2.11.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res0: $r.global.noSelfType.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' tp: $r.global.Type = Array[scala.util.Random] scala> tp.memberType(Array_apply) // evidence diff --git a/test/files/run/runtime.scala b/test/files/run/runtime.scala index 89348b294d..468a80fc0c 100644 --- a/test/files/run/runtime.scala +++ b/test/files/run/runtime.scala @@ -73,7 +73,7 @@ object Test1Test { // {System.out.print(22); test1.bar}.System.out.println(); {Console.print(23); test1.bar.System}.out.println(); {Console.print(24); test1.bar.System.out}.println(); - {Console.print(25); test1.bar.System.out.println:(() => Unit)} apply (); + {Console.print(25); test1.bar.System.out.println _ : (() => Unit)} apply (); {Console.print(26); test1.bar.System.out.println()}; } diff --git a/test/files/run/showdecl.check b/test/files/run/showdecl.check index b8d7f94c57..d431c36f6d 100644 --- a/test/files/run/showdecl.check +++ b/test/files/run/showdecl.check @@ -8,7 +8,7 @@ initialized y: lazy val y: Int uninitialized z: def z: <?> initialized z: def z: Int uninitialized t: def t: <?> -initialized t: def t[T <: Int](x: D)(y: x.W): Int +initialized t: def t[T <: <?>](x: D)(y: x.W): Int uninitialized W: type W = String initialized W: type W = String uninitialized C: class C extends diff --git a/test/files/run/showdecl/Macros_1.scala b/test/files/run/showdecl/Macros_1.scala index c68dd275de..89b8e8d3c2 100644 --- a/test/files/run/showdecl/Macros_1.scala +++ b/test/files/run/showdecl/Macros_1.scala @@ -9,7 +9,7 @@ object Macros { import c.universe._ def test(sym: Symbol): Unit = { println(s"uninitialized ${sym.name}: ${showDecl(sym)}") - sym.info + sym.info // NOTE: not fullyInitializeSymbol, so some parts may still be LazyTypes println(s"initialized ${sym.name}: ${showDecl(sym)}") } diff --git a/test/files/run/showraw_mods.check b/test/files/run/showraw_mods.check index 4d34160422..ff77d22adf 100644 --- a/test/files/run/showraw_mods.check +++ b/test/files/run/showraw_mods.check @@ -1 +1 @@ -Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), TypeName("C"), List(), Template(List(Ident(TypeName("AnyRef"))), noSelfType, List(DefDef(Modifiers(), TermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), TermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), TermName("y"), TypeTree(), Select(This(TypeName("C")), TermName("x"))), ValDef(Modifiers(LAZY), TermName("z"), TypeTree(), Select(This(TypeName("C")), TermName("y"))))))), Literal(Constant(()))) +Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), TypeName("C"), List(), Template(List(Ident(TypeName("AnyRef"))), noSelfType, List(DefDef(Modifiers(), TermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), DefDef(Modifiers(PRIVATE | METHOD | LOCAL | STABLE | ACCESSOR), TermName("x"), List(), List(), TypeTree(), Literal(Constant(2))), DefDef(Modifiers(METHOD | ACCESSOR), TermName("y"), List(), List(), TypeTree(), Select(This(TypeName("C")), TermName("x"))), DefDef(Modifiers(METHOD | ACCESSOR), TermName("y_$eq"), List(), List(List(ValDef(Modifiers(PARAM | SYNTHETIC), TermName("x$1"), TypeTree(), EmptyTree))), TypeTree(), EmptyTree), ValDef(Modifiers(LAZY), TermName("z"), TypeTree(), Select(This(TypeName("C")), TermName("y"))))))), Literal(Constant(()))) diff --git a/test/files/run/synchronized.scala b/test/files/run/synchronized.scala index 6be0d64dd8..d777b85b2c 100644 --- a/test/files/run/synchronized.scala +++ b/test/files/run/synchronized.scala @@ -1,5 +1,5 @@ /* - * filter: inliner warnings; re-run with + * filter: inliner warnings; */ import java.lang.Thread.holdsLock import scala.collection.mutable.StringBuilder diff --git a/test/files/run/t2946/MyResponseCommon_2.scala b/test/files/run/t2946/MyResponseCommon_2.scala new file mode 100644 index 0000000000..4f8f924f2c --- /dev/null +++ b/test/files/run/t2946/MyResponseCommon_2.scala @@ -0,0 +1,7 @@ +class MyResponseCommon extends Parser with ResponseCommon + +object Test { + def main(args: Array[String]) { + new MyResponseCommon + } +} diff --git a/test/files/run/t2946/ResponseCommon_1.scala b/test/files/run/t2946/ResponseCommon_1.scala new file mode 100644 index 0000000000..bb921e7027 --- /dev/null +++ b/test/files/run/t2946/ResponseCommon_1.scala @@ -0,0 +1,13 @@ +class Parser { + def parse(t: Any): Unit = {} +} + +trait ResponseCommon extends Parser { + private[this] var paramsParser: Parser = null + def withParamsParser(parser: Parser) = {paramsParser = parser; this} + + override abstract def parse(t: Any): Unit = t match { + case ("params", value: List[_]) => value.foreach {paramsParser.parse(_)} + case _ => super.parse(t) + } +} diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check index 3141647dba..99e420678c 100644 --- a/test/files/run/t4172.check +++ b/test/files/run/t4172.check @@ -1,6 +1,6 @@ scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) } -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' c: (C, C{def f: Int}) forSome { type C <: AnyRef } = (C,C) scala> :quit diff --git a/test/files/run/t4287inferredMethodTypes.check b/test/files/run/t4287inferredMethodTypes.check deleted file mode 100644 index 56e9c097cc..0000000000 --- a/test/files/run/t4287inferredMethodTypes.check +++ /dev/null @@ -1,30 +0,0 @@ -[[syntax trees at end of typer]] // newSource1.scala -[0:92]package [0:0]<empty> { - [0:21]class A extends [7:21][23]scala.AnyRef { - [8:16]<paramaccessor> private[this] val a: [8]Int = _; - <8:20>def <init>(<8:20>a: [11]<type: [11]scala.Int> = [17:20]A.a): [7]A = <8:20>{ - <8:20><8:20><8:20>A.super.<init>(); - <8:20>() - } - }; - [23:47]object A extends [32:47][49]scala.AnyRef { - [49]def <init>(): [32]A.type = [49]{ - [49][49][49]A.super.<init>(); - [32]() - }; - [36:45]private[this] val a: [40]Int = [44:45]2; - [40]<stable> <accessor> def a: [40]Int = [40][40]A.this.a; - [8]<synthetic> def <init>$default$1: [8]Int = [19]A.a - }; - [49:92]class B extends [57:92][65:66]A { - [65]def <init>(): [57]B = [65]{ - [65][65][65]B.super.<init>([65]A.<init>$default$1); - [57]() - }; - [70:90]def <init>([79:80]a: [79]Int): [74]B = [84:90]{ - [84:90][84:90][84]B.this.<init>(); - [84]() - } - } -} - diff --git a/test/files/run/t4287inferredMethodTypes.scala b/test/files/run/t4287inferredMethodTypes.scala deleted file mode 100644 index f14e672da8..0000000000 --- a/test/files/run/t4287inferredMethodTypes.scala +++ /dev/null @@ -1,25 +0,0 @@ -import scala.tools.partest.DirectTest - -object Test extends DirectTest { - - override def extraSettings: String = - s"-usejavacp -Yinfer-argument-types -Xprint-pos -Xprint:typer -Yrangepos -Ystop-after:typer -d ${testOutput.path}" - - override def code = """ -class A(a: Int = A.a) - -object A { - val a = 2 -} - -class B extends A { - def this(a) = this() -} - """.trim - - override def show(): Unit = { - Console.withErr(System.out) { - compile() - } - } -}
\ No newline at end of file diff --git a/test/files/run/t4594-repl-settings.scala b/test/files/run/t4594-repl-settings.scala index 524ec28843..587bb2312b 100644 --- a/test/files/run/t4594-repl-settings.scala +++ b/test/files/run/t4594-repl-settings.scala @@ -9,7 +9,7 @@ object Test extends SessionTest { |depp: String | |scala> def a = depp - |warning: there was one deprecation warning (since Time began.); re-run with -deprecation for details + |warning: there was one deprecation warning (since Time began.); for details, enable `:setting -deprecation' or `:replay -deprecation' |a: String | |scala> :settings -deprecation diff --git a/test/files/run/t4710.check b/test/files/run/t4710.check index 5f90c68ed1..4a5d11f185 100644 --- a/test/files/run/t4710.check +++ b/test/files/run/t4710.check @@ -1,6 +1,6 @@ scala> def method : String = { implicit def f(s: Symbol) = "" ; 'symbol } -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' method: String scala> :quit diff --git a/test/files/run/t6240-universe-code-gen.scala b/test/files/run/t6240-universe-code-gen.scala index 60e1f76b54..80b60bab7e 100644 --- a/test/files/run/t6240-universe-code-gen.scala +++ b/test/files/run/t6240-universe-code-gen.scala @@ -54,7 +54,7 @@ object Test extends App { | |${forceCode("this", JavaUniverseTpe)} |${forceCode("definitions", DefinitionsModule.info)} - |${forceCode("refChecks", typeOf[scala.reflect.internal.transform.RefChecks])} + | |${forceCode("uncurry", typeOf[scala.reflect.internal.transform.UnCurry])} |${forceCode("erasure", typeOf[scala.reflect.internal.transform.Erasure])} | } diff --git a/test/files/run/t6329_repl.check b/test/files/run/t6329_repl.check index 86cd984e11..22882a3597 100644 --- a/test/files/run/t6329_repl.check +++ b/test/files/run/t6329_repl.check @@ -3,28 +3,28 @@ scala> import scala.reflect.classTag import scala.reflect.classTag scala> classManifest[scala.List[_]] -warning: there was one deprecation warning (since 2.10.0); re-run with -deprecation for details +warning: there was one deprecation warning (since 2.10.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] scala> classTag[scala.List[_]] res1: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List scala> classManifest[scala.collection.immutable.List[_]] -warning: there was one deprecation warning (since 2.10.0); re-run with -deprecation for details +warning: there was one deprecation warning (since 2.10.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res2: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] scala> classTag[scala.collection.immutable.List[_]] res3: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List scala> classManifest[Predef.Set[_]] -warning: there was one deprecation warning (since 2.10.0); re-run with -deprecation for details +warning: there was one deprecation warning (since 2.10.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res4: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[<?>] scala> classTag[Predef.Set[_]] res5: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set scala> classManifest[scala.collection.immutable.Set[_]] -warning: there was one deprecation warning (since 2.10.0); re-run with -deprecation for details +warning: there was one deprecation warning (since 2.10.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res6: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[<?>] scala> classTag[scala.collection.immutable.Set[_]] diff --git a/test/files/run/t6329_repl_bug.check b/test/files/run/t6329_repl_bug.check index 6476fa71fc..11decae9bd 100644 --- a/test/files/run/t6329_repl_bug.check +++ b/test/files/run/t6329_repl_bug.check @@ -6,7 +6,7 @@ scala> import scala.reflect.runtime._ import scala.reflect.runtime._ scala> classManifest[List[_]] -warning: there was one deprecation warning (since 2.10.0); re-run with -deprecation for details +warning: there was one deprecation warning (since 2.10.0); for details, enable `:setting -deprecation' or `:replay -deprecation' res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] scala> scala.reflect.classTag[List[_]] diff --git a/test/files/run/t6733.check b/test/files/run/t6733.check index aeb595fbfd..7062301c56 100644 --- a/test/files/run/t6733.check +++ b/test/files/run/t6733.check @@ -2,23 +2,22 @@ method $init$: isPrivateThis = false, isProtectedThis = false value pri1a: isPrivateThis = true, isProtectedThis = false method pri2a: isPrivateThis = true, isProtectedThis = false variable pri3a: isPrivateThis = true, isProtectedThis = false -value pri4a: isPrivateThis = true, isProtectedThis = false +variable pri3a: isPrivateThis = true, isProtectedThis = false +lazy value pri4a: isPrivateThis = true, isProtectedThis = false lazy value pri4a: isPrivateThis = true, isProtectedThis = false type Pri5a: isPrivateThis = true, isProtectedThis = false class Pri6: isPrivateThis = true, isProtectedThis = false trait Pri7: isPrivateThis = true, isProtectedThis = false object Pri8: isPrivateThis = true, isProtectedThis = false value pro1a: isPrivateThis = false, isProtectedThis = true -value pro1a: isPrivateThis = true, isProtectedThis = false value pro1b: isPrivateThis = false, isProtectedThis = true method pro2a: isPrivateThis = false, isProtectedThis = true method pro2b: isPrivateThis = false, isProtectedThis = true -method pro3a: isPrivateThis = false, isProtectedThis = true -method pro3a_=: isPrivateThis = false, isProtectedThis = true -variable pro3a: isPrivateThis = true, isProtectedThis = false -method pro3b: isPrivateThis = false, isProtectedThis = true -method pro3b_=: isPrivateThis = false, isProtectedThis = true -value pro4a: isPrivateThis = false, isProtectedThis = true +variable pro3a: isPrivateThis = false, isProtectedThis = true +variable pro3a: isPrivateThis = false, isProtectedThis = true +variable pro3b: isPrivateThis = false, isProtectedThis = true +variable pro3b: isPrivateThis = false, isProtectedThis = true +lazy value pro4a: isPrivateThis = false, isProtectedThis = true lazy value pro4a: isPrivateThis = true, isProtectedThis = false type Pro5a: isPrivateThis = false, isProtectedThis = true type Pro5b: isPrivateThis = false, isProtectedThis = true diff --git a/test/files/run/t7319.check b/test/files/run/t7319.check index 31923e7119..1dcb84c804 100644 --- a/test/files/run/t7319.check +++ b/test/files/run/t7319.check @@ -3,15 +3,15 @@ scala> class M[A] defined class M scala> implicit def ma0[A](a: A): M[A] = null -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' ma0: [A](a: A)M[A] scala> implicit def ma1[A](a: A): M[A] = null -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' ma1: [A](a: A)M[A] scala> def convert[F[X <: F[X]]](builder: F[_ <: F[_]]) = 0 -warning: there was one feature warning; re-run with -feature for details +warning: there was one feature warning; for details, enable `:setting -feature' or `:replay -feature' convert: [F[X <: F[X]]](builder: F[_ <: F[_]])Int scala> convert(Some[Int](0)) diff --git a/test/files/run/t7533.check b/test/files/run/t7533.check index fa5b3edc8f..61fd4657bd 100644 --- a/test/files/run/t7533.check +++ b/test/files/run/t7533.check @@ -1,30 +1,29 @@ Testing Symbol.isAbstract... =======class C======= -class C => true -constructor C => false -value x1 => true -value x2 => false -value x2 => false -method y1 => true -method y2 => false -type T1 => true -type T2 => false +class C => abstract +constructor C => concrete +value xAbs => abstract +value x => concrete +value x => concrete +method yAbs => abstract +method y => concrete +type TAbs => abstract +type T => concrete =======trait T======= -trait T => true -method $init$ => false -value z1 => true -value z2 => false -value z2 => false -method w1 => true -method w2 => false -type U1 => true -type U2 => false -=======class D======= -class D => false -constructor D => false -value x1 => false -value x1 => false -method y1 => false +trait T => abstract +method $init$ => concrete +value zAbs => abstract +value z => concrete +method wAbs => abstract +method w => concrete +type UAbs => abstract +type U => concrete +=======class AllConcrete======= +class AllConcrete => concrete +constructor AllConcrete => concrete +value xAbs => concrete +value xAbs => concrete +method yAbs => concrete =======object M======= -object M => false -constructor M => false +object M => concrete +constructor M => concrete diff --git a/test/files/run/t7533.scala b/test/files/run/t7533.scala index c7bd8e8d43..65c5c26b42 100644 --- a/test/files/run/t7533.scala +++ b/test/files/run/t7533.scala @@ -1,24 +1,24 @@ import scala.reflect.runtime.universe._ abstract class C { - val x1: Int - val x2: Int = 2 - def y1: Int - def y2: Int = 2 - type T1 <: Int - type T2 = Int + val xAbs: Int + val x: Int = 2 + def yAbs: Int + def y: Int = 2 + type TAbs <: Int + type T = Int } trait T { - val z1: Int - val z2: Int = 2 - def w1: Int - def w2: Int = 2 - type U1 <: Int - type U2 = Int + val zAbs: Int + val z: Int = 2 + def wAbs: Int + def w: Int = 2 + type UAbs <: Int + type U = Int } -class D extends C { - val x1 = 3 - def y1 = 3 +class AllConcrete extends C { + val xAbs = 3 + def yAbs = 3 } object M @@ -27,12 +27,12 @@ object Test extends App { def test[T: TypeTag] = { val sym = typeOf[T].typeSymbol println(s"=======$sym=======") - def printAbstract(sym: Symbol) = println(s"$sym => ${sym.isAbstract}") + def printAbstract(sym: Symbol) = println(s"$sym => ${if (sym.isAbstract) "abstract" else "concrete"}") printAbstract(sym) sym.info.decls.sorted.foreach(printAbstract) } test[C] test[T] - test[D] + test[AllConcrete] test[M.type] }
\ No newline at end of file diff --git a/test/files/run/t8549.scala b/test/files/run/t8549.scala index da7a731459..7a38491231 100644 --- a/test/files/run/t8549.scala +++ b/test/files/run/t8549.scala @@ -79,7 +79,7 @@ object Test extends App { } } - // Generated on 20160715-08:27:53 with Scala version 2.12.0-20160715-012500-f5a80bd) + // Generated on 20160720-18:56:11 with Scala version 2.12.0-local-5815f9a) overwrite.foreach(updateComment) check(Some(1))("rO0ABXNyAApzY2FsYS5Tb21lESLyaV6hi3QCAAFMAAV2YWx1ZXQAEkxqYXZhL2xhbmcvT2JqZWN0O3hyAAxzY2FsYS5PcHRpb27+aTf92w5mdAIAAHhwc3IAEWphdmEubGFuZy5JbnRlZ2VyEuKgpPeBhzgCAAFJAAV2YWx1ZXhyABBqYXZhLmxhbmcuTnVtYmVyhqyVHQuU4IsCAAB4cAAAAAE=") @@ -174,7 +174,7 @@ object Test extends App { // check(mutable.ArraySeq(1, 2, 3))( "rO0ABXNyACFzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuQXJyYXlTZXEVPD3SKEkOcwIAAkkABmxlbmd0aFsABWFycmF5dAATW0xqYXZhL2xhbmcvT2JqZWN0O3hwAAAAA3VyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAANzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4ABQAAAAJzcQB+AAUAAAAD") check(mutable.AnyRefMap("a" -> "A"))( "rO0ABXNyACJzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuQW55UmVmTWFwAAAAAAAAAAECAAdJAAVfc2l6ZUkAB192YWNhbnRJAARtYXNrTAAMZGVmYXVsdEVudHJ5dAARTHNjYWxhL0Z1bmN0aW9uMTtbACtzY2FsYSRjb2xsZWN0aW9uJG11dGFibGUkQW55UmVmTWFwJCRfaGFzaGVzdAACW0lbAClzY2FsYSRjb2xsZWN0aW9uJG11dGFibGUkQW55UmVmTWFwJCRfa2V5c3QAE1tMamF2YS9sYW5nL09iamVjdDtbACtzY2FsYSRjb2xsZWN0aW9uJG11dGFibGUkQW55UmVmTWFwJCRfdmFsdWVzcQB+AAN4cAAAAAEAAAAAAAAAB3NyADNzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuQW55UmVmTWFwJEV4Y2VwdGlvbkRlZmF1bHQAAAAAAAAAAQIAAHhwdXIAAltJTbpgJnbqsqUCAAB4cAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+UkA2AAAAAHVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAhwcHBwcHB0AAFhcHVxAH4ACQAAAAhwcHBwcHB0AAFBcA==") check(mutable.ArrayStack(1, 2, 3))( "rO0ABXNyACNzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuQXJyYXlTdGFja3bdxXbcnLBeAgACSQAqc2NhbGEkY29sbGVjdGlvbiRtdXRhYmxlJEFycmF5U3RhY2skJGluZGV4WwAqc2NhbGEkY29sbGVjdGlvbiRtdXRhYmxlJEFycmF5U3RhY2skJHRhYmxldAATW0xqYXZhL2xhbmcvT2JqZWN0O3hwAAAAA3VyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAANzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAA3NxAH4ABQAAAAJzcQB+AAUAAAAB") - check(mutable.DoubleLinkedList(1, 2, 3))( "rO0ABXNyAClzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuRG91YmxlTGlua2VkTGlzdI73LKsKRr1RAgADTAAEZWxlbXQAEkxqYXZhL2xhbmcvT2JqZWN0O0wABG5leHR0AB5Mc2NhbGEvY29sbGVjdGlvbi9tdXRhYmxlL1NlcTtMAARwcmV2cQB+AAJ4cHNyABFqYXZhLmxhbmcuSW50ZWdlchLioKT3gYc4AgABSQAFdmFsdWV4cgAQamF2YS5sYW5nLk51bWJlcoaslR0LlOCLAgAAeHAAAAABc3EAfgAAc3EAfgAEAAAAAnNxAH4AAHNxAH4ABAAAAANzcQB+AABwcQB+AAtxAH4ACXEAfgAHcQB+AANw") + check(mutable.DoubleLinkedList(1, 2, 3))( "rO0ABXNyAClzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuRG91YmxlTGlua2VkTGlzdI73LKsKRr1RAgADTAAEZWxlbXQAEkxqYXZhL2xhbmcvT2JqZWN0O0wABG5leHR0ACtMc2NhbGEvY29sbGVjdGlvbi9tdXRhYmxlL0RvdWJsZUxpbmtlZExpc3Q7TAAEcHJldnEAfgACeHBzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4AAHNxAH4ABAAAAAJzcQB+AABzcQB+AAQAAAADc3EAfgAAcHEAfgALcQB+AAlxAH4AB3EAfgADcA==") check(mutable.HashMap())( "rO0ABXNyACBzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuSGFzaE1hcAAAAAAAAAABAwAAeHB3DQAAAu4AAAAAAAAABAB4") check(mutable.HashMap(1 -> 1))( "rO0ABXNyACBzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuSGFzaE1hcAAAAAAAAAABAwAAeHB3DQAAAu4AAAABAAAABABzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXEAfgAEeA==") @@ -189,7 +189,7 @@ object Test extends App { // check(new mutable.History())( "rO0ABXNyACBzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuSGlzdG9yeUhuXxDIFJrsAgACSQAKbWF4SGlzdG9yeUwAA2xvZ3QAIExzY2FsYS9jb2xsZWN0aW9uL211dGFibGUvUXVldWU7eHAAAAPoc3IAHnNjYWxhLmNvbGxlY3Rpb24ubXV0YWJsZS5RdWV1ZbjMURVfOuHHAgAAeHIAJHNjYWxhLmNvbGxlY3Rpb24ubXV0YWJsZS5NdXRhYmxlTGlzdFJpnjJ+gFbAAgADSQADbGVuTAAGZmlyc3QwdAAlTHNjYWxhL2NvbGxlY3Rpb24vbXV0YWJsZS9MaW5rZWRMaXN0O0wABWxhc3QwcQB+AAV4cAAAAABzcgAjc2NhbGEuY29sbGVjdGlvbi5tdXRhYmxlLkxpbmtlZExpc3Sak+nGCZHaUQIAAkwABGVsZW10ABJMamF2YS9sYW5nL09iamVjdDtMAARuZXh0dAAeTHNjYWxhL2NvbGxlY3Rpb24vbXV0YWJsZS9TZXE7eHBwcQB+AApxAH4ACg==") check(mutable.LinkedHashMap(1 -> 2))( "rO0ABXNyACZzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuTGlua2VkSGFzaE1hcAAAAAAAAAABAwAAeHB3DQAAAu4AAAABAAAABABzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4AAgAAAAJ4") check(mutable.LinkedHashSet(1, 2, 3))( "rO0ABXNyACZzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuTGlua2VkSGFzaFNldAAAAAAAAAABAwAAeHB3DQAAAu4AAAADAAAABABzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4AAgAAAAJzcQB+AAIAAAADeA==") - check(mutable.LinkedList(1, 2, 3))( "rO0ABXNyACNzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuTGlua2VkTGlzdJqT6cYJkdpRAgACTAAEZWxlbXQAEkxqYXZhL2xhbmcvT2JqZWN0O0wABG5leHR0AB5Mc2NhbGEvY29sbGVjdGlvbi9tdXRhYmxlL1NlcTt4cHNyABFqYXZhLmxhbmcuSW50ZWdlchLioKT3gYc4AgABSQAFdmFsdWV4cgAQamF2YS5sYW5nLk51bWJlcoaslR0LlOCLAgAAeHAAAAABc3EAfgAAc3EAfgAEAAAAAnNxAH4AAHNxAH4ABAAAAANzcQB+AABwcQB+AAs=") + check(mutable.LinkedList(1, 2, 3))( "rO0ABXNyACNzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuTGlua2VkTGlzdJqT6cYJkdpRAgACTAAEZWxlbXQAEkxqYXZhL2xhbmcvT2JqZWN0O0wABG5leHR0ACVMc2NhbGEvY29sbGVjdGlvbi9tdXRhYmxlL0xpbmtlZExpc3Q7eHBzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4AAHNxAH4ABAAAAAJzcQB+AABzcQB+AAQAAAADc3EAfgAAcHEAfgAL") // TODO SI-8576 unstable under -Xcheckinit // check(mutable.ListBuffer(1, 2, 3))( "rO0ABXNyACNzY2FsYS5jb2xsZWN0aW9uLm11dGFibGUuTGlzdEJ1ZmZlci9y9I7QyWzGAwAEWgAIZXhwb3J0ZWRJAANsZW5MAAVsYXN0MHQAKUxzY2FsYS9jb2xsZWN0aW9uL2ltbXV0YWJsZS8kY29sb24kY29sb247TAAqc2NhbGEkY29sbGVjdGlvbiRtdXRhYmxlJExpc3RCdWZmZXIkJHN0YXJ0dAAhTHNjYWxhL2NvbGxlY3Rpb24vaW1tdXRhYmxlL0xpc3Q7eHBzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4ABAAAAAJzcQB+AAQAAAADc3IALHNjYWxhLmNvbGxlY3Rpb24uaW1tdXRhYmxlLkxpc3RTZXJpYWxpemVFbmQkilxjW/dTC20CAAB4cHcFAAAAAAN4") diff --git a/test/files/run/trait_fields_bytecode.scala b/test/files/run/trait_fields_bytecode.scala new file mode 100644 index 0000000000..d87412f43e --- /dev/null +++ b/test/files/run/trait_fields_bytecode.scala @@ -0,0 +1,23 @@ +trait TFinal { final val bla: Int = 123 } + +// bla should be final in C +class CFinal extends TFinal + + +trait TConst { final val C = "S" } +// there should be a C method in `T$class`! +class CConst extends TConst { } + + +object Test { + def main(args: Array[String]): Unit = { + val f1 = classOf[CFinal].getDeclaredMethod("bla") + import java.lang.reflect.Modifier._ + assert(isFinal(f1.getModifiers), f1) + + classOf[CConst].getMethod("C") + + import language.reflectiveCalls + assert(new CConst().asInstanceOf[{def C: String}].C == "S") + } +} diff --git a/test/files/run/trait_fields_final.scala b/test/files/run/trait_fields_final.scala new file mode 100644 index 0000000000..8b32e5b47d --- /dev/null +++ b/test/files/run/trait_fields_final.scala @@ -0,0 +1,21 @@ +// TODO: clarify meaning of final in traits +// In the new compiler, there's no final modifier after mixin for `meh`'s setter, +// whereas 2.12.0-M3 makes meh's trait setter final. +// NOTE: bytecode is identical, but the scalasignature is different +trait Foo { self: Meh => + def bar(x: String) = x == "a" + private final val meh = bar("a") +} + +abstract class Meh extends Foo + +object Test { + def main(args: Array[String]): Unit = { + val setter = classOf[Meh].getDeclaredMethod("Foo$_setter_$Foo$$meh_$eq", java.lang.Boolean.TYPE) + val getter = classOf[Meh].getDeclaredMethod("Foo$$meh") + import java.lang.reflect.Modifier._ + assert(isFinal(setter.getModifiers), setter) + assert(isFinal(getter.getModifiers), getter) + } + +} diff --git a/test/files/run/trait_fields_init.check b/test/files/run/trait_fields_init.check new file mode 100644 index 0000000000..84c1a2ead9 --- /dev/null +++ b/test/files/run/trait_fields_init.check @@ -0,0 +1,21 @@ +x +y +z +abstract +public +protected +abstract protected +private +private[this] +abstract +public +protected +abstract protected +private +private[this] +abstract +public +protected +abstract protected +private +private[this] diff --git a/test/files/run/trait_fields_init.scala b/test/files/run/trait_fields_init.scala new file mode 100644 index 0000000000..496911d538 --- /dev/null +++ b/test/files/run/trait_fields_init.scala @@ -0,0 +1,55 @@ +trait T { + val abs: String + protected val protabs: String + val pub = "public" + protected val prot = "protected" + private val privvy = "private" + private[this] val privateThis = "private[this]" + // TODO: + // final val const = "const" + + trait Nested { println(abs + privateThis) } + + object NO { + println(abs) + println(pub) + println(prot) + println(protabs) + println(privvy) + println(privateThis) + } + + trait NT { + println(abs) + println(pub) + println(prot) + println(protabs) + println(privvy) + println(privateThis) + } + + class NC { + println(abs) + println(pub) + println(prot) + println(protabs) + println(privvy) + println(privateThis) + } +} + +class C extends AnyRef with T { + println("x") + val abs = "abstract" + println("y") + val protabs = "abstract protected" + final val const = "const" + println("z") +} + +object Test extends C { + def main(args: Array[String]): Unit = { + NO + new NT{} + new NC +}}
\ No newline at end of file diff --git a/test/files/run/trait_fields_repl.check b/test/files/run/trait_fields_repl.check new file mode 100644 index 0000000000..d03a565c7b --- /dev/null +++ b/test/files/run/trait_fields_repl.check @@ -0,0 +1,11 @@ + +scala> trait B { val y = "a" } +defined trait B + +scala> trait T extends B { val x: y.type = y } +defined trait T + +scala> println((new T{}).x) +a + +scala> :quit diff --git a/test/files/run/trait_fields_repl.scala b/test/files/run/trait_fields_repl.scala new file mode 100644 index 0000000000..311477b7d2 --- /dev/null +++ b/test/files/run/trait_fields_repl.scala @@ -0,0 +1,10 @@ +// TODO: fix AME when this runs in REPL +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ +trait B { val y = "a" } +trait T extends B { val x: y.type = y } +println((new T{}).x) +""" +} diff --git a/test/files/run/trait_fields_three_layer_overrides.check b/test/files/run/trait_fields_three_layer_overrides.check new file mode 100644 index 0000000000..8bb45803c5 --- /dev/null +++ b/test/files/run/trait_fields_three_layer_overrides.check @@ -0,0 +1,2 @@ +the real universe.TypeTag +1 diff --git a/test/files/run/trait_fields_three_layer_overrides.scala b/test/files/run/trait_fields_three_layer_overrides.scala new file mode 100644 index 0000000000..9d7aa94341 --- /dev/null +++ b/test/files/run/trait_fields_three_layer_overrides.scala @@ -0,0 +1,25 @@ +// interesting hierarchies/overrides distilled from reflect/compiler + +trait Aliases { + val TypeTag = "universe.TypeTag" +} +trait AliasesOverrides extends Aliases { // or self: Aliases => + override val TypeTag = "the real universe.TypeTag" +} +class Context extends Aliases with AliasesOverrides + + + +trait SymbolTable { + def currentRunId: Int = -1 +} +trait ReflectSetup extends SymbolTable { + override val currentRunId = 1 +} +class G extends SymbolTable with ReflectSetup + + +object Test extends App { + println((new Context).TypeTag) + println((new G).currentRunId) +}
\ No newline at end of file diff --git a/test/files/run/trait_fields_volatile.scala b/test/files/run/trait_fields_volatile.scala new file mode 100644 index 0000000000..eedb6de1c2 --- /dev/null +++ b/test/files/run/trait_fields_volatile.scala @@ -0,0 +1,13 @@ +// bytecode should reflect volatile annotation +trait VolatileAbort { + @volatile private var abortflag = false +} +class DefaultSignalling extends VolatileAbort + +object Test { + def main(args: Array[String]): Unit = { + val field = classOf[DefaultSignalling].getDeclaredFields.find(_.getName.contains("abortflag")).get + assert(java.lang.reflect.Modifier.isVolatile(field.getModifiers), field) + } + +} diff --git a/test/files/run/xMigration.check b/test/files/run/xMigration.check index 1104dbea83..b812d6a282 100644 --- a/test/files/run/xMigration.check +++ b/test/files/run/xMigration.check @@ -1,11 +1,11 @@ scala> Map(1 -> "eis").values // no warn -res0: Iterable[String] = MapLike(eis) +res0: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:none scala> Map(1 -> "eis").values // no warn -res1: Iterable[String] = MapLike(eis) +res1: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:any @@ -14,12 +14,12 @@ scala> Map(1 -> "eis").values // warn `values` returns `Iterable[V]` rather than `Iterator[V]`. Map(1 -> "eis").values // warn ^ -res2: Iterable[String] = MapLike(eis) +res2: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:2.8 scala> Map(1 -> "eis").values // no warn -res3: Iterable[String] = MapLike(eis) +res3: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:2.7 @@ -28,12 +28,12 @@ scala> Map(1 -> "eis").values // warn `values` returns `Iterable[V]` rather than `Iterator[V]`. Map(1 -> "eis").values // warn ^ -res4: Iterable[String] = MapLike(eis) +res4: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration:2.11 scala> Map(1 -> "eis").values // no warn -res5: Iterable[String] = MapLike(eis) +res5: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :setting -Xmigration // same as :any @@ -42,6 +42,6 @@ scala> Map(1 -> "eis").values // warn `values` returns `Iterable[V]` rather than `Iterator[V]`. Map(1 -> "eis").values // warn ^ -res6: Iterable[String] = MapLike(eis) +res6: Iterable[String] = MapLike.DefaultValuesIterable(eis) scala> :quit diff --git a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala index 2c4d81f333..fe07893a36 100644 --- a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala +++ b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala @@ -103,7 +103,7 @@ object TypecheckedProps extends QuasiquoteProperties("typechecked") val lazyName = TermName("x") val lazyRhsVal = 42 val lazyRhs = Literal(Constant(lazyRhsVal)) - val q"{lazy val $pname = $rhs}" = typecheck(q"{lazy val $lazyName = $lazyRhsVal}") + val q"{ $_ ; $mods val $pname: $_ = { $_ = $rhs ; $_ } }" = typecheck(q"{lazy val $lazyName = $lazyRhsVal}") assert(pname == lazyName) assert(rhs ≈ lazyRhs) diff --git a/test/junit/scala/collection/NewBuilderTest.scala b/test/junit/scala/collection/NewBuilderTest.scala new file mode 100644 index 0000000000..fdc6af113d --- /dev/null +++ b/test/junit/scala/collection/NewBuilderTest.scala @@ -0,0 +1,184 @@ +package scala.collection + +import scala.{collection => sc} +import scala.collection.{mutable => scm, immutable => sci, parallel => scp, concurrent => scc} +import scala.collection.parallel.{mutable => scpm, immutable => scpi} + +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.junit.Test +import scala.reflect.ClassTag +import org.junit.Assert._ + +/* Tests various maps by making sure they all agree on the same answers. */ +@RunWith(classOf[JUnit4]) +class NewBuilderTest { + + @Test + def mapPreservesCollectionType() { + def test[T: ClassTag](mapped: Any): Unit = { + val expected = reflect.classTag[T].runtimeClass + val isInstance = reflect.classTag[T].runtimeClass.isInstance(mapped) + assertTrue(s"$mapped (of class ${mapped.getClass} is not a in instance of ${expected}", isInstance) + } + + test[sc.GenTraversable[_] ]((sc.GenTraversable(1): sc.GenTraversable[Int]).map(x => x)) + test[sc.Traversable[_] ]((sc.Traversable(1): sc.GenTraversable[Int]).map(x => x)) + test[sc.GenIterable[_] ]((sc.GenIterable(1): sc.GenTraversable[Int]).map(x => x)) + test[sc.Iterable[_] ]((sc.Iterable(1): sc.GenTraversable[Int]).map(x => x)) + test[sc.GenSeq[_] ]((sc.GenSeq(1): sc.GenTraversable[Int]).map(x => x)) + test[sc.Seq[_] ]((sc.Seq(1): sc.GenTraversable[Int]).map(x => x)) + test[sc.LinearSeq[_] ]((sc.LinearSeq(1): sc.GenTraversable[Int]).map(x => x)) + test[sc.LinearSeq[_] ]((sc.LinearSeq(1): sc.Seq[Int] ).map(x => x)) + test[sc.IndexedSeq[_] ]((sc.IndexedSeq(1): sc.GenTraversable[Int]).map(x => x)) + test[sc.IndexedSeq[_] ]((sc.IndexedSeq(1): sc.Seq[Int] ).map(x => x)) + test[sc.GenSet[_] ]((sc.GenSet(1): sc.GenTraversable[Int]).map(x => x)) + test[sc.Set[_] ]((sc.Set(1): sc.GenTraversable[Int]).map(x => x)) + test[sc.GenMap[_, _] ]((sc.GenMap(1 -> 1): sc.GenMap[Int, Int] ).map(x => x)) + test[sc.Map[_, _] ]((sc.Map(1 -> 1): sc.GenMap[Int, Int] ).map(x => x)) + + test[scm.Traversable[_] ]((scm.Traversable(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.Iterable[_] ]((scm.Iterable(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.LinearSeq[_] ]((scm.LinearSeq(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.LinearSeq[_] ]((scm.LinearSeq(1): sc.Seq[Int] ).map(x => x)) + test[scm.MutableList[_] ]((scm.MutableList(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.MutableList[_] ]((scm.MutableList(1): sc.Seq[Int] ).map(x => x)) + test[scm.Queue[_] ]((scm.Queue(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.Queue[_] ]((scm.Queue(1): sc.Seq[Int] ).map(x => x)) + test[scm.DoubleLinkedList[_]]((scm.DoubleLinkedList(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.DoubleLinkedList[_]]((scm.DoubleLinkedList(1): sc.Seq[Int] ).map(x => x)) + test[scm.LinkedList[_] ]((scm.LinkedList(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.LinkedList[_] ]((scm.LinkedList(1): sc.Seq[Int] ).map(x => x)) + test[scm.ArrayStack[_] ]((scm.ArrayStack(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.ArrayStack[_] ]((scm.ArrayStack(1): sc.Seq[Int] ).map(x => x)) + test[scm.Stack[_] ]((scm.Stack(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.Stack[_] ]((scm.Stack(1): sc.Seq[Int] ).map(x => x)) + test[scm.ArraySeq[_] ]((scm.ArraySeq(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.ArraySeq[_] ]((scm.ArraySeq(1): sc.Seq[Int] ).map(x => x)) + + test[scm.Buffer[_] ]((scm.Buffer(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.Buffer[_] ]((scm.Buffer(1): sc.Seq[Int] ).map(x => x)) + test[scm.IndexedSeq[_] ]((scm.IndexedSeq(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.IndexedSeq[_] ]((scm.IndexedSeq(1): sc.Seq[Int] ).map(x => x)) + test[scm.ArrayBuffer[_] ]((scm.ArrayBuffer(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.ArrayBuffer[_] ]((scm.ArrayBuffer(1): sc.Seq[Int] ).map(x => x)) + test[scm.ListBuffer[_] ]((scm.ListBuffer(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.ListBuffer[_] ]((scm.ListBuffer(1): sc.Seq[Int] ).map(x => x)) + test[scm.Seq[_] ]((scm.Seq(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.Seq[_] ]((scm.Seq(1): sc.Seq[Int] ).map(x => x)) + test[scm.ResizableArray[_] ]((scm.ResizableArray(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.ResizableArray[_] ]((scm.ResizableArray(1): sc.Seq[Int] ).map(x => x)) + test[scm.Set[_] ]((scm.Set(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.Set[_] ]((scm.Set(1): sc.Set[Int] ).map(x => x)) + test[scm.HashSet[_] ]((scm.HashSet(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.HashSet[_] ]((scm.HashSet(1): sc.Set[Int] ).map(x => x)) + test[scm.LinkedHashSet[_] ]((scm.LinkedHashSet(1): sc.GenTraversable[Int]).map(x => x)) + test[scm.LinkedHashSet[_] ]((scm.LinkedHashSet(1): sc.Set[Int] ).map(x => x)) + + test[sci.Traversable[_] ]((sci.Traversable(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.Iterable[_] ]((sci.Iterable(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.LinearSeq[_] ]((sci.LinearSeq(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.LinearSeq[_] ]((sci.LinearSeq(1): sc.Seq[Int] ).map(x => x)) + test[sci.List[_] ]((sci.List(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.List[_] ]((sci.List(1): sc.Seq[Int] ).map(x => x)) + test[sci.Stream[_] ]((sci.Stream(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.Stream[_] ]((sci.Stream(1): sc.Seq[Int] ).map(x => x)) + test[sci.Stack[_] ]((sci.Stack(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.Stack[_] ]((sci.Stack(1): sc.Seq[Int] ).map(x => x)) + test[sci.Queue[_] ]((sci.Queue(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.Queue[_] ]((sci.Queue(1): sc.Seq[Int] ).map(x => x)) + test[sci.IndexedSeq[_] ]((sci.IndexedSeq(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.IndexedSeq[_] ]((sci.IndexedSeq(1): sc.Seq[Int] ).map(x => x)) + test[sci.Vector[_] ]((sci.Vector(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.Vector[_] ]((sci.Vector(1): sc.Seq[Int] ).map(x => x)) + test[sci.Seq[_] ]((sci.Seq(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.Seq[_] ]((sci.Seq(1): sc.Seq[Int] ).map(x => x)) + test[sci.Set[_] ]((sci.Set(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.Set[_] ]((sci.Set(1): sc.Set[Int] ).map(x => x)) + test[sci.ListSet[_] ]((sci.ListSet(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.ListSet[_] ]((sci.ListSet(1): sc.Set[Int] ).map(x => x)) + test[sci.HashSet[_] ]((sci.HashSet(1): sc.GenTraversable[Int]).map(x => x)) + test[sci.HashSet[_] ]((sci.HashSet(1): sc.Set[Int] ).map(x => x)) + + test[scp.ParIterable[_] ]((scp.ParIterable(1): sc.GenTraversable[Int]).map(x => x)) + test[scp.ParSeq[_] ]((scp.ParSeq(1): sc.GenTraversable[Int]).map(x => x)) + test[scp.ParSeq[_] ]((scp.ParSeq(1): sc.GenSeq[Int] ).map(x => x)) + test[scp.ParSet[_] ]((scp.ParSet(1): sc.GenTraversable[Int]).map(x => x)) + test[scp.ParSet[_] ]((scp.ParSet(1): sc.GenSet[Int] ).map(x => x)) + + test[scpm.ParIterable[_] ]((scpm.ParIterable(1): sc.GenTraversable[Int]).map(x => x)) + test[scpm.ParSeq[_] ]((scpm.ParSeq(1): sc.GenTraversable[Int]).map(x => x)) + test[scpm.ParSeq[_] ]((scpm.ParSeq(1): sc.GenSeq[Int] ).map(x => x)) + test[scpm.ParArray[_] ]((scpm.ParArray(1): sc.GenTraversable[Int]).map(x => x)) + test[scpm.ParArray[_] ]((scpm.ParArray(1): sc.GenSeq[Int] ).map(x => x)) + test[scpm.ParSet[_] ]((scpm.ParSet(1): sc.GenTraversable[Int]).map(x => x)) + test[scpm.ParSet[_] ]((scpm.ParSet(1): sc.GenSet[Int] ).map(x => x)) + test[scpm.ParHashSet[_] ]((scpm.ParHashSet(1): sc.GenTraversable[Int]).map(x => x)) + test[scpm.ParHashSet[_] ]((scpm.ParHashSet(1): sc.GenSet[Int] ).map(x => x)) + + test[scpi.ParIterable[_] ]((scpi.ParIterable(1): sc.GenTraversable[Int]).map(x => x)) + test[scpi.ParSeq[_] ]((scpi.ParSeq(1): sc.GenTraversable[Int]).map(x => x)) + test[scpi.ParSeq[_] ]((scpi.ParSeq(1): sc.GenSeq[Int] ).map(x => x)) + test[scpi.ParVector[_] ]((scpi.ParVector(1): sc.GenTraversable[Int]).map(x => x)) + test[scpi.ParVector[_] ]((scpi.ParVector(1): sc.GenSeq[Int] ).map(x => x)) + test[scpi.ParSet[_] ]((scpi.ParSet(1): sc.GenTraversable[Int]).map(x => x)) + test[scpi.ParSet[_] ]((scpi.ParSet(1): sc.GenSet[Int] ).map(x => x)) + test[scpi.ParHashSet[_] ]((scpi.ParHashSet(1): sc.GenTraversable[Int]).map(x => x)) + test[scpi.ParHashSet[_] ]((scpi.ParHashSet(1): sc.GenSet[Int] ).map(x => x)) + + // These go through `GenMap.canBuildFrom`. There is no simple fix for Map like there is for Set. + // A Map does not provide access to its companion object at runtime. (The `companion` field + // points to an inherited `GenericCompanion`, not the actual companion object). Therefore, the + // `MapCanBuildFrom` has no way to get the correct builder for the source type at runtime. + //test[scm.Map[_, _] ]((scm.Map(1 -> 1): sc.GenMap[Int, Int]).map(x => x) + //test[scm.OpenHashMap[_, _] ]((scm.OpenHashMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scm.LongMap[_] ]((scm.LongMap(1L -> 1): sc.GenMap[Long, Int]).map(x => x)) + //test[scm.ListMap[_, _] ]((scm.ListMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scm.LinkedHashMap[_, _]]((scm.LinkedHashMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scm.HashMap[_, _] ]((scm.HashMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[sci.Map[_, _] ]((sci.Map(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[sci.ListMap[_, _] ]((sci.ListMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[sci.IntMap[_] ]((sci.IntMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[sci.LongMap[_] ]((sci.LongMap(1L -> 1): sc.GenMap[Long, Int]).map(x => x)) + //test[sci.HashMap[_, _] ]((sci.HashMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[sci.SortedMap[_, _] ]((sci.SortedMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[sci.TreeMap[_, _] ]((sci.TreeMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scc.TrieMap[_, _] ]((scc.TrieMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scp.ParMap[_, _] ]((scp.ParMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scpm.ParMap[_, _] ]((scpm.ParMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scpm.ParHashMap[_, _] ]((scpm.ParHashMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scpm.ParTrieMap[_, _] ]((scpm.ParTrieMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scpi.ParMap[_, _] ]((scpi.ParMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scpi.ParHashMap[_, _] ]((scpi.ParHashMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + + // These cannot be expected to work. The static type information is lost, and `map` does not capture + // a `ClassTag` of the result type, so there is no way for a `CanBuildFrom` to decide to build another + // `BitSet` instead of a generic `Set` implementation: + //test[scm.BitSet ]((scm.BitSet(1): sc.GenTraversable[Int]).map(x => x)) + //test[scm.BitSet ]((scm.BitSet(1): sc.Set[Int]).map(x => x)) + + // These also require a `ClassTag`: + //test[scm.UnrolledBuffer[_]]((scm.UnrolledBuffer(1): sc.GenTraversable[Int]).map(x => x)) + //test[scm.UnrolledBuffer[_]]((scm.UnrolledBuffer(1): sc.Seq[Int]).map(x => x)) + + // The situation is similar for sorted collection. They require an implicit `Ordering` which cannot + // be captured at runtime by a `CanBuildFrom` when the static type has been lost: + //test[sc.SortedMap[_, _] ]((sc.SortedMap(1 -> 1): sc.GenTraversable[(Int, Int)]).map(x => x)) + //test[sc.SortedMap[_, _] ]((sc.SortedMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[sc.SortedSet[_] ]((sc.SortedSet(1): sc.GenTraversable[Int]).map(x => x)) + //test[sc.SortedSet[_] ]((sc.SortedSet(1): sc.Set[Int]).map(x => x)) + //test[scm.SortedSet[_] ]((scm.SortedSet(1): sc.GenTraversable[Int]).map(x => x)) + //test[scm.SortedSet[_] ]((scm.SortedSet(1): sc.Set[Int]).map(x => x)) + //test[scm.TreeSet[_] ]((scm.TreeSet(1): sc.GenTraversable[Int]).map(x => x)) + //test[scm.TreeSet[_] ]((scm.TreeSet(1): sc.Set[Int]).map(x => x)) + //test[scm.TreeMap[_, _] ]((scm.TreeMap(1 -> 1): sc.GenTraversable[(Int, Int)]).map(x => x)) + //test[scm.TreeMap[_, _] ]((scm.TreeMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + //test[scm.SortedMap[_, _] ]((scm.SortedMap(1 -> 1): sc.GenTraversable[(Int, Int)]).map(x => x)) + //test[scm.SortedMap[_, _] ]((scm.SortedMap(1 -> 1): sc.GenMap[Int, Int]).map(x => x)) + + // Maps do not map to maps when seen as GenTraversable. This would require knowledge that `map` + // returns a `Tuple2`, which is not available dynamically: + //test[sc.GenMap[_, _] ]((sc.GenMap(1 -> 1): sc.GenTraversable[(Int, Int)]).map(x => x)) + //test[sc.Map[_, _] ]((sc.Map(1 -> 1): sc.GenTraversable[(Int, Int)]).map(x => x)) + } +} diff --git a/test/junit/scala/collection/TraversableLikeTest.scala b/test/junit/scala/collection/TraversableLikeTest.scala new file mode 100644 index 0000000000..8588956016 --- /dev/null +++ b/test/junit/scala/collection/TraversableLikeTest.scala @@ -0,0 +1,33 @@ +package scala.collection + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class TraversableLikeTest { + // For test_SI9019; out here because as of test writing, putting this in a method would crash compiler + class Baz[@specialized(Int) A]() extends IndexedSeq[A] { + def apply(i: Int) = ??? + def length: Int = 0 + } + + @Test + def test_SI9019 { + object Foo { + def mkBar = () => { + class Bar extends IndexedSeq[Int] { + def apply(i: Int) = ??? + def length: Int = 0 + } + new Bar + } + } + val bar = Foo.mkBar() + assertEquals("Bar", bar.stringPrefix) // Previously would have been outermost class, TraversableLikeTest + + val baz = new Baz[Int]() + assertEquals("TraversableLikeTest.Baz", baz.stringPrefix) // Make sure we don't see specialization $mcI$sp stuff + } +} diff --git a/test/junit/scala/collection/immutable/StreamTest.scala b/test/junit/scala/collection/immutable/StreamTest.scala index fad4e502eb..7046525f37 100644 --- a/test/junit/scala/collection/immutable/StreamTest.scala +++ b/test/junit/scala/collection/immutable/StreamTest.scala @@ -107,4 +107,14 @@ class StreamTest { def withFilter_map_properly_lazy_in_tail: Unit = { assertStreamOpLazyInTail(_.withFilter(_ % 2 == 0).map(identity), List(1, 2)) } + + @Test // SI-6881 + def test_reference_equality: Unit = { + // Make sure we're tested with reference equality + val s = Stream.from(0) + assert(s == s, "Referentially identical streams should be equal (==)") + assert(s equals s, "Referentially identical streams should be equal (equals)") + assert((0 #:: 1 #:: s) == (0 #:: 1 #:: s), "Cons of referentially identical streams should be equal (==)") + assert((0 #:: 1 #:: s) equals (0 #:: 1 #:: s), "Cons of referentially identical streams should be equal (equals)") + } } diff --git a/test/junit/scala/reflect/internal/PrintersTest.scala b/test/junit/scala/reflect/internal/PrintersTest.scala index d581ca8cf4..234f22e9fb 100644 --- a/test/junit/scala/reflect/internal/PrintersTest.scala +++ b/test/junit/scala/reflect/internal/PrintersTest.scala @@ -151,7 +151,7 @@ class BasePrintTest { |else | ((a.toString): String)""", typedCode=sm""" - |val a = 1; + |val a: Int = 1; |if (PrintersContext.this.a.>(1)) | ((PrintersContext.this.a): scala.Int) |else @@ -864,7 +864,7 @@ class TraitPrintTest { @Test def testTraitWithSelf2 = assertPrintedCode(sm""" |trait X { self: scala.Cloneable with scala.Serializable => - | val x: scala.Int = 1 + | val x: Int = 1 |}""") @Test def testTraitTypeParams = assertPrintedCode("trait X[A, B]") @@ -903,7 +903,7 @@ class TraitPrintTest { | type Foo; | type XString = scala.Predef.String |} with scala.Serializable { - | val z = 7 + | val z: Int = 7 |}""") @Test def testTraitWithSingletonTypeTree = assertPrintedCode(sm""" @@ -1018,7 +1018,11 @@ class ValAndDefPrintTest { """, typedCode = sm""" |def a = { - | lazy val test: scala.Int = 42; + | lazy val test$$lzy: scala.Int = _; + | lazy val test: Int = { + | test$$lzy = 42; + | test$$lzy + | }; | () |}""") diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala index f531ce9322..f88b95eae4 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala @@ -1587,4 +1587,41 @@ class InlinerTest extends BytecodeTesting { val List(c, t) = compile(code) assertNoIndy(getMethod(c, "t1")) } + + @Test + def limitInlinedLocalVariableNames(): Unit = { + val code = + """class C { + | def f(x: Int): Int = x + | @inline final def methodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(param: Int) = + | f(param) + | @inline final def anotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(param: Int) = + | methodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(param)) + | @inline final def oneMoreMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(param: Int) = + | anotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(param)) + | @inline final def yetAnotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(param: Int) = + | oneMoreMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(param)) + | @inline final def oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(param: Int) = + | yetAnotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(param)) + | def t(p: Int) = + | oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(p)) + + | oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence(f(p)) + |} + """.stripMargin + + val List(c) = compile(code) + assertEquals(getAsmMethod(c, "t").localVariables.asScala.toList.map(l => (l.name, l.index)).sortBy(_._2),List( + ("this",0), + ("p",1), + ("oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence_param",2), + ("oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchS_yetAnotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFren_param",3), + ("oneLastMethodWithVeryVeryLongNameAlmostLik_yetAnotherMethodWithVeryVeryLongNameAlmost_oneMoreMethodWithVeryVeryLongNameAlmostLik_param",4), + ("oneLastMethodWithVeryVeryLongNam_yetAnotherMethodWithVeryVeryLong_oneMoreMethodWithVeryVeryLongNam_anotherMethodWithVeryVeryLongNam_param",5), + ("oneLastMethodWithVeryVery_yetAnotherMethodWithVeryV_oneMoreMethodWithVeryVery_anotherMethodWithVeryVery_methodWithVeryVeryLongNam_param",6), + ("oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchSentence_param",7), + ("oneLastMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFrenchS_yetAnotherMethodWithVeryVeryLongNameAlmostLikeAGermanWordOrAFren_param",8), + ("oneLastMethodWithVeryVeryLongNameAlmostLik_yetAnotherMethodWithVeryVeryLongNameAlmost_oneMoreMethodWithVeryVeryLongNameAlmostLik_param",9), + ("oneLastMethodWithVeryVeryLongNam_yetAnotherMethodWithVeryVeryLong_oneMoreMethodWithVeryVeryLongNam_anotherMethodWithVeryVeryLongNam_param",10), + ("oneLastMethodWithVeryVery_yetAnotherMethodWithVeryV_oneMoreMethodWithVeryVery_anotherMethodWithVeryVery_methodWithVeryVeryLongNam_param",11))) + } } diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala index 54f4c805c1..56da0e2493 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/opt/ScalaInlineInfoTest.scala @@ -83,7 +83,7 @@ class ScalaInlineInfoTest extends BytecodeTesting { false, // final class None, // not a sam Map( - ("O()LT$O$;", MethodInlineInfo(true ,false,false)), // the accessor is abstract in bytecode, but still effectivelyFinal because there's no (late)DEFERRED flag, https://github.com/scala/scala-dev/issues/126 + ("O()LT$O$;", MethodInlineInfo(false,false,false)), ("T$$super$toString()Ljava/lang/String;", MethodInlineInfo(true ,false,false)), ("T$_setter_$x1_$eq(I)V", MethodInlineInfo(false,false,false)), ("f1()I", MethodInlineInfo(false,false,false)), @@ -104,8 +104,9 @@ class ScalaInlineInfoTest extends BytecodeTesting { ("x4()I", MethodInlineInfo(false,false,false)), ("x4$(LT;)I", MethodInlineInfo(true ,false,false)), ("x5()I", MethodInlineInfo(true, false,false)), + ("x5$(LT;)I", MethodInlineInfo(true ,false,false)), ("L$lzycompute$1(Lscala/runtime/VolatileObjectRef;)LT$L$2$;", MethodInlineInfo(true, false,false)), - ("L$1(Lscala/runtime/VolatileObjectRef;)LT$L$2$;", MethodInlineInfo(true ,false,false)), + ("L$1(Lscala/runtime/VolatileObjectRef;)LT$L$2$;", MethodInlineInfo(true, false,false)), ("nest$1()I", MethodInlineInfo(true, false,false)), ("$init$(LT;)V", MethodInlineInfo(true,false,false))), None // warning @@ -127,7 +128,7 @@ class ScalaInlineInfoTest extends BytecodeTesting { "x3_$eq(I)V" -> MethodInlineInfo(false,false,false), "x4$lzycompute()I" -> MethodInlineInfo(true ,false,false), "x4()I" -> MethodInlineInfo(false,false,false), - "x5()I" -> MethodInlineInfo(true ,false,false), +// "x5()I" -> MethodInlineInfo(true ,false,false), -- there is no x5 in the class as it's implemented fully in the interface "T$$super$toString()Ljava/lang/String;" -> MethodInlineInfo(true ,false,false), "<init>()V" -> MethodInlineInfo(false,false,false)), None) diff --git a/test/junit/scala/tools/nsc/symtab/FlagsTest.scala b/test/junit/scala/tools/nsc/symtab/FlagsTest.scala index 96eae38011..e88b3f9e96 100644 --- a/test/junit/scala/tools/nsc/symtab/FlagsTest.scala +++ b/test/junit/scala/tools/nsc/symtab/FlagsTest.scala @@ -31,12 +31,7 @@ class FlagsTest { @Test def testTimedFlags(): Unit = { - testLate(lateDEFERRED, _.isDeferred) - testLate(lateFINAL, _.isFinal) - testLate(lateMETHOD, _.isMethod) - testLate(lateMODULE, _.isModule) testNot(PROTECTED | notPROTECTED, _.isProtected) - testNot(OVERRIDE | notOVERRIDE, _.isOverride) testNot(PRIVATE | notPRIVATE, _.isPrivate) assertFalse(withFlagMask(AllFlags)(sym.setFlag(PRIVATE | notPRIVATE).isPrivate)) diff --git a/test/files/neg/t6375.check b/test/pending/neg/t6375.check index 89d7d8060f..89d7d8060f 100644 --- a/test/files/neg/t6375.check +++ b/test/pending/neg/t6375.check diff --git a/test/files/neg/t6375.flags b/test/pending/neg/t6375.flags index 85d8eb2ba2..85d8eb2ba2 100644 --- a/test/files/neg/t6375.flags +++ b/test/pending/neg/t6375.flags diff --git a/test/files/neg/t6375.scala b/test/pending/neg/t6375.scala index 21634df688..21634df688 100644 --- a/test/files/neg/t6375.scala +++ b/test/pending/neg/t6375.scala diff --git a/test/pending/run/origins.check b/test/pending/run/origins.check index b12cb6e38f..af94b549d3 100644 --- a/test/pending/run/origins.check +++ b/test/pending/run/origins.check @@ -1,6 +1,4 @@ ->> Origins tag 'boop' logged 65 calls from 3 distinguished sources. +>> Origins tag 'boop' logged 65 calls from 1 distinguished sources. - 50 Test$$anonfun$f3$1.apply(origins.scala:16) - 10 Test$$anonfun$f2$1.apply(origins.scala:15) - 5 Test$$anonfun$f1$1.apply(origins.scala:14) + 65 null diff --git a/test/scaladoc/run/t9585.check b/test/scaladoc/run/t9585.check new file mode 100644 index 0000000000..3784317d54 --- /dev/null +++ b/test/scaladoc/run/t9585.check @@ -0,0 +1,6 @@ +warning: there was one feature warning; re-run with -feature for details +any2stringadd[Box[T]] +StringFormat[Box[T]] +Ensuring[Box[T]] +ArrowAssoc[Box[T]] +Done. diff --git a/test/scaladoc/run/t9585.scala b/test/scaladoc/run/t9585.scala new file mode 100644 index 0000000000..af8350b6cf --- /dev/null +++ b/test/scaladoc/run/t9585.scala @@ -0,0 +1,25 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def code = """ + object Box { + + implicit def anyToBox[T](t: T): Box[T] = new Box(t) + + } + + class Box[T](val t: T) + """ + + def scaladocSettings = "-implicits" + + def testModel(root: Package) = { + import access._ + + // this used to contain the conversion to Box[Box[T]], + // but not anymore. + val conversions = root._class("Box").conversions + println(conversions.map(_.targetType).mkString("\n")) + } +} |