diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t2796.check | 4 | ||||
-rw-r--r-- | test/files/neg/t2796.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t2796.scala | 28 | ||||
-rw-r--r-- | test/files/neg/t5969.check | 7 | ||||
-rw-r--r-- | test/files/neg/t5969.scala | 11 | ||||
-rw-r--r-- | test/files/neg/t6013.check | 7 | ||||
-rw-r--r-- | test/files/neg/t6013/Abstract.java | 7 | ||||
-rw-r--r-- | test/files/neg/t6013/Base.java | 10 | ||||
-rw-r--r-- | test/files/neg/t6013/DerivedScala.scala | 7 | ||||
-rw-r--r-- | test/files/neg/t649.check | 2 | ||||
-rw-r--r-- | test/files/run/abstypetags_core.check | 56 | ||||
-rw-r--r-- | test/files/run/abstypetags_core.scala | 4 | ||||
-rw-r--r-- | test/files/run/classtags_core.check | 4 | ||||
-rw-r--r-- | test/files/run/classtags_core.scala | 4 | ||||
-rw-r--r-- | test/files/run/patmat-finally.scala | 25 | ||||
-rw-r--r-- | test/files/run/reify_magicsymbols.check | 13 | ||||
-rw-r--r-- | test/files/run/reify_magicsymbols.scala | 17 | ||||
-rw-r--r-- | test/files/run/test-cpp.check | 138 | ||||
-rw-r--r-- | test/files/run/typetags_core.check | 56 | ||||
-rw-r--r-- | test/files/run/typetags_core.scala | 4 |
20 files changed, 279 insertions, 126 deletions
diff --git a/test/files/neg/t2796.check b/test/files/neg/t2796.check new file mode 100644 index 0000000000..aeb18497ed --- /dev/null +++ b/test/files/neg/t2796.check @@ -0,0 +1,4 @@ +t2796.scala:7: error: Implementation restriction: early definitions in traits are not initialized before the super class is initialized. + val abstractVal = "T1.abstractVal" // warn + ^ +one error found diff --git a/test/files/neg/t2796.flags b/test/files/neg/t2796.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/t2796.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t2796.scala b/test/files/neg/t2796.scala new file mode 100644 index 0000000000..3bcc9df562 --- /dev/null +++ b/test/files/neg/t2796.scala @@ -0,0 +1,28 @@ +trait Base { + val abstractVal: String + final val useAbstractVal = abstractVal +} + +trait T1 extends { + val abstractVal = "T1.abstractVal" // warn +} with Base + +trait T2 extends { + type X = Int // okay +} with Base + + +class C1 extends { + val abstractVal = "C1.abstractVal" // okay +} with Base + +object Test { + def main(args: Array[String]) { + assert(new C1 ().useAbstractVal == "C1.abstractVal") + // This currently fails. a more ambitious approach to this ticket would add $earlyinit$ + // to traits and call it from the right places in the right order. + // + // For now, we'll just issue a warning. + assert(new T1 {}.useAbstractVal == "T1.abstractVal") + } +} diff --git a/test/files/neg/t5969.check b/test/files/neg/t5969.check new file mode 100644 index 0000000000..9d8ac9a3a5 --- /dev/null +++ b/test/files/neg/t5969.check @@ -0,0 +1,7 @@ +t5969.scala:9: error: overloaded method value g with alternatives: + (x: C2)String <and> + (x: C1)String + cannot be applied to (String) + if (false) List(g(x)) else List[C1]() map g + ^ +one error found diff --git a/test/files/neg/t5969.scala b/test/files/neg/t5969.scala new file mode 100644 index 0000000000..62f87fd7ab --- /dev/null +++ b/test/files/neg/t5969.scala @@ -0,0 +1,11 @@ +class C1 +class C2 +class A { + def f(x: Any) = x + def g(x: C1): String = "A" + def g(x: C2): String = "B" + + def crash() = f(List[String]() flatMap { x => + if (false) List(g(x)) else List[C1]() map g + }) +} diff --git a/test/files/neg/t6013.check b/test/files/neg/t6013.check new file mode 100644 index 0000000000..502da999f5 --- /dev/null +++ b/test/files/neg/t6013.check @@ -0,0 +1,7 @@ +DerivedScala.scala:4: error: class C needs to be abstract, since there is a deferred declaration of method foo in class B of type => Int which is not implemented in a subclass +class C extends B + ^ +DerivedScala.scala:7: error: class DerivedScala needs to be abstract, since there is a deferred declaration of method foo in class Abstract of type ()Boolean which is not implemented in a subclass +class DerivedScala extends Abstract + ^ +two errors found diff --git a/test/files/neg/t6013/Abstract.java b/test/files/neg/t6013/Abstract.java new file mode 100644 index 0000000000..c0ef046bbd --- /dev/null +++ b/test/files/neg/t6013/Abstract.java @@ -0,0 +1,7 @@ +public abstract class Abstract extends Base { + // overrides Base#bar under the erasure model + public void bar(java.util.List<java.lang.Integer> foo) { return; } + + // must force re-implementation in derived classes + public abstract boolean foo(); +} diff --git a/test/files/neg/t6013/Base.java b/test/files/neg/t6013/Base.java new file mode 100644 index 0000000000..b73d7fd821 --- /dev/null +++ b/test/files/neg/t6013/Base.java @@ -0,0 +1,10 @@ +abstract public class Base { + // This must considered to be overridden by Abstract#foo based + // on the erased signatures. This special case is handled by + // `javaErasedOverridingSym` in `RefChecks`. + public abstract void bar(java.util.List<java.lang.String> foo) { return; } + + // But, a concrete method in a Java superclass must not excuse + // a deferred method in the Java subclass! + public boolean foo() { return true; } +} diff --git a/test/files/neg/t6013/DerivedScala.scala b/test/files/neg/t6013/DerivedScala.scala new file mode 100644 index 0000000000..fc0c55d398 --- /dev/null +++ b/test/files/neg/t6013/DerivedScala.scala @@ -0,0 +1,7 @@ +// Scala extending Scala (this case was working fine before this bug.) +class A { def foo: Int = 0 } +abstract class B extends A { def foo: Int } +class C extends B + +// Scala extending Java +class DerivedScala extends Abstract diff --git a/test/files/neg/t649.check b/test/files/neg/t649.check index a6670886b5..5a270d4751 100644 --- a/test/files/neg/t649.check +++ b/test/files/neg/t649.check @@ -1,4 +1,4 @@ t649.scala:3: error: overloaded method foo needs result type def foo[A] = foo[A] - ^ + ^ one error found diff --git a/test/files/run/abstypetags_core.check b/test/files/run/abstypetags_core.check index ec93221a30..8d20e099c4 100644 --- a/test/files/run/abstypetags_core.check +++ b/test/files/run/abstypetags_core.check @@ -1,26 +1,30 @@ -true -TypeTag[Byte] -true -TypeTag[Short] -true -TypeTag[Char] -true -TypeTag[Int] -true -TypeTag[Long] -true -TypeTag[Float] -true -TypeTag[Double] -true -TypeTag[Boolean] -true -TypeTag[Unit] -true -TypeTag[Any] -true -TypeTag[java.lang.Object] -true -TypeTag[Null] -true -TypeTag[Nothing] +true
+TypeTag[Byte]
+true
+TypeTag[Short]
+true
+TypeTag[Char]
+true
+TypeTag[Int]
+true
+TypeTag[Long]
+true
+TypeTag[Float]
+true
+TypeTag[Double]
+true
+TypeTag[Boolean]
+true
+TypeTag[Unit]
+true
+TypeTag[Any]
+true
+TypeTag[AnyVal]
+true
+TypeTag[AnyRef]
+true
+TypeTag[java.lang.Object]
+true
+TypeTag[Null]
+true
+TypeTag[Nothing]
diff --git a/test/files/run/abstypetags_core.scala b/test/files/run/abstypetags_core.scala index dbe9b5e11d..226de94055 100644 --- a/test/files/run/abstypetags_core.scala +++ b/test/files/run/abstypetags_core.scala @@ -21,6 +21,10 @@ object Test extends App { println(implicitly[AbsTypeTag[Unit]]) println(implicitly[AbsTypeTag[Any]] eq AbsTypeTag.Any) println(implicitly[AbsTypeTag[Any]]) + println(implicitly[AbsTypeTag[AnyVal]] eq AbsTypeTag.AnyVal) + println(implicitly[AbsTypeTag[AnyVal]]) + println(implicitly[AbsTypeTag[AnyRef]] eq AbsTypeTag.AnyRef) + println(implicitly[AbsTypeTag[AnyRef]]) println(implicitly[AbsTypeTag[Object]] eq AbsTypeTag.Object) println(implicitly[AbsTypeTag[Object]]) println(implicitly[AbsTypeTag[Null]] eq AbsTypeTag.Null) diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check index ce7793e188..6519db2178 100644 --- a/test/files/run/classtags_core.check +++ b/test/files/run/classtags_core.check @@ -21,6 +21,10 @@ ClassTag[class java.lang.Object] true
ClassTag[class java.lang.Object]
true
+ClassTag[class java.lang.Object]
+true
+ClassTag[class java.lang.Object]
+true
ClassTag[class scala.runtime.Null$]
true
ClassTag[class scala.runtime.Nothing$]
diff --git a/test/files/run/classtags_core.scala b/test/files/run/classtags_core.scala index ad5e12a8c2..0e174d8243 100644 --- a/test/files/run/classtags_core.scala +++ b/test/files/run/classtags_core.scala @@ -21,6 +21,10 @@ object Test extends App { println(implicitly[ClassTag[Unit]]) println(implicitly[ClassTag[Any]] eq ClassTag.Any) println(implicitly[ClassTag[Any]]) + println(implicitly[ClassTag[AnyVal]] eq ClassTag.AnyVal) + println(implicitly[ClassTag[AnyVal]]) + println(implicitly[ClassTag[AnyRef]] eq ClassTag.AnyRef) + println(implicitly[ClassTag[AnyRef]]) println(implicitly[ClassTag[Object]] eq ClassTag.Object) println(implicitly[ClassTag[Object]]) println(implicitly[ClassTag[Null]] eq ClassTag.Null) diff --git a/test/files/run/patmat-finally.scala b/test/files/run/patmat-finally.scala new file mode 100644 index 0000000000..6f769b30a0 --- /dev/null +++ b/test/files/run/patmat-finally.scala @@ -0,0 +1,25 @@ +/** Test pattern matching and finally, see SI-5929. */ +object Test extends App { + def bar(s1: Object, s2: Object) { + s1 match { + case _ => + } + + try { + () + } finally { + s2 match { + case _ => + } + } + } + + def x = { + null match { case _ => } + + try { 1 } finally { while(false) { } } + } + + bar(null, null) + x +} diff --git a/test/files/run/reify_magicsymbols.check b/test/files/run/reify_magicsymbols.check new file mode 100644 index 0000000000..e2aa46a364 --- /dev/null +++ b/test/files/run/reify_magicsymbols.check @@ -0,0 +1,13 @@ +Any +AnyVal +AnyRef +Null +Nothing +List[Any] +List[AnyVal] +List[AnyRef] +List[Null] +List[Nothing] +AnyRef{def foo(x: Int): Int} +Int* => Unit +=> Int => Unit diff --git a/test/files/run/reify_magicsymbols.scala b/test/files/run/reify_magicsymbols.scala new file mode 100644 index 0000000000..256ecbea33 --- /dev/null +++ b/test/files/run/reify_magicsymbols.scala @@ -0,0 +1,17 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + println(typeOf[Any]) + println(typeOf[AnyVal]) + println(typeOf[AnyRef]) + println(typeOf[Null]) + println(typeOf[Nothing]) + println(typeOf[List[Any]]) + println(typeOf[List[AnyVal]]) + println(typeOf[List[AnyRef]]) + println(typeOf[List[Null]]) + println(typeOf[List[Nothing]]) + println(typeOf[{def foo(x: Int): Int}]) + println(typeOf[(Int*) => Unit]) + println(typeOf[(=> Int) => Unit]) +}
\ No newline at end of file diff --git a/test/files/run/test-cpp.check b/test/files/run/test-cpp.check index 40a976119f..a7163edb5f 100644 --- a/test/files/run/test-cpp.check +++ b/test/files/run/test-cpp.check @@ -1,73 +1,65 @@ -37c37 -< locals: value args, value x, value y ---- -> locals: value args -42,43d41 -< 52 CONSTANT(2) -< 52 STORE_LOCAL(value x) -45,46d42 -< 53 LOAD_LOCAL(value x) -< 53 STORE_LOCAL(value y) -49c45 -< 54 LOAD_LOCAL(value y) ---- -> 54 CONSTANT(2) -92c88 -< locals: value args, value x, value y ---- -> locals: value args, value x -101,102d96 -< 82 LOAD_LOCAL(value x) -< 82 STORE_LOCAL(value y) -105c99 -< 83 LOAD_LOCAL(value y) ---- -> 83 LOAD_LOCAL(value x) -135c129 -< locals: value args, value x, value y ---- -> locals: value args -140,141d133 -< 66 THIS(TestAliasChainDerefThis) -< 66 STORE_LOCAL(value x) -143,144d134 -< 67 LOAD_LOCAL(value x) -< 67 STORE_LOCAL(value y) -147c137 -< 68 LOAD_LOCAL(value y) ---- -> 68 THIS(Object) -176c166 -< locals: value x, value y ---- -> locals: value x -181,182d170 -< 29 LOAD_LOCAL(value x) -< 29 STORE_LOCAL(value y) -185c173 -< 30 LOAD_LOCAL(value y) ---- -> 30 LOAD_LOCAL(value x) -223,224d210 -< 97 LOAD_LOCAL(variable x) -< 97 STORE_LOCAL(variable y) -227c213 -< 98 LOAD_LOCAL(variable y) ---- -> 98 LOAD_LOCAL(variable x) -233,234d218 -< 101 LOAD_LOCAL(variable y) -< 101 STORE_LOCAL(variable x) -236c220 -< 102 LOAD_LOCAL(variable x) ---- -> 102 LOAD_LOCAL(variable y) -345c329 -< 41 THIS(TestSetterInline) ---- -> 41 THIS(Object) -347c331 -< 41 CALL_METHOD TestSetterInline._postSetHook_$eq (static-instance) ---- -> 41 STORE_FIELD variable _postSetHook (dynamic) - +37c37
+< locals: value args, value x, value y
+---
+> locals: value args
+42,43d41
+< 52 CONSTANT(2)
+< 52 STORE_LOCAL(value x)
+45,46d42
+< 53 LOAD_LOCAL(value x)
+< 53 STORE_LOCAL(value y)
+49c45
+< 54 LOAD_LOCAL(value y)
+---
+> 54 CONSTANT(2)
+92c88
+< locals: value args, value x, value y
+---
+> locals: value args, value x
+101,102d96
+< 82 LOAD_LOCAL(value x)
+< 82 STORE_LOCAL(value y)
+105c99
+< 83 LOAD_LOCAL(value y)
+---
+> 83 LOAD_LOCAL(value x)
+135c129
+< locals: value args, value x, value y
+---
+> locals: value args
+140,141d133
+< 66 THIS(TestAliasChainDerefThis)
+< 66 STORE_LOCAL(value x)
+143,144d134
+< 67 LOAD_LOCAL(value x)
+< 67 STORE_LOCAL(value y)
+147c137
+< 68 LOAD_LOCAL(value y)
+---
+> 68 THIS(Object)
+176c166
+< locals: value x, value y
+---
+> locals: value x
+181,182d170
+< 29 LOAD_LOCAL(value x)
+< 29 STORE_LOCAL(value y)
+185c173
+< 30 LOAD_LOCAL(value y)
+---
+> 30 LOAD_LOCAL(value x)
+223,224d210
+< 97 LOAD_LOCAL(variable x)
+< 97 STORE_LOCAL(variable y)
+227c213
+< 98 LOAD_LOCAL(variable y)
+---
+> 98 LOAD_LOCAL(variable x)
+233,234d218
+< 101 LOAD_LOCAL(variable y)
+< 101 STORE_LOCAL(variable x)
+236c220
+< 102 LOAD_LOCAL(variable x)
+---
+> 102 LOAD_LOCAL(variable y)
+
diff --git a/test/files/run/typetags_core.check b/test/files/run/typetags_core.check index ec93221a30..8d20e099c4 100644 --- a/test/files/run/typetags_core.check +++ b/test/files/run/typetags_core.check @@ -1,26 +1,30 @@ -true -TypeTag[Byte] -true -TypeTag[Short] -true -TypeTag[Char] -true -TypeTag[Int] -true -TypeTag[Long] -true -TypeTag[Float] -true -TypeTag[Double] -true -TypeTag[Boolean] -true -TypeTag[Unit] -true -TypeTag[Any] -true -TypeTag[java.lang.Object] -true -TypeTag[Null] -true -TypeTag[Nothing] +true
+TypeTag[Byte]
+true
+TypeTag[Short]
+true
+TypeTag[Char]
+true
+TypeTag[Int]
+true
+TypeTag[Long]
+true
+TypeTag[Float]
+true
+TypeTag[Double]
+true
+TypeTag[Boolean]
+true
+TypeTag[Unit]
+true
+TypeTag[Any]
+true
+TypeTag[AnyVal]
+true
+TypeTag[AnyRef]
+true
+TypeTag[java.lang.Object]
+true
+TypeTag[Null]
+true
+TypeTag[Nothing]
diff --git a/test/files/run/typetags_core.scala b/test/files/run/typetags_core.scala index 0d86fac25b..5257d55118 100644 --- a/test/files/run/typetags_core.scala +++ b/test/files/run/typetags_core.scala @@ -21,6 +21,10 @@ object Test extends App { println(implicitly[TypeTag[Unit]]) println(implicitly[TypeTag[Any]] eq TypeTag.Any) println(implicitly[TypeTag[Any]]) + println(implicitly[TypeTag[AnyVal]] eq TypeTag.AnyVal) + println(implicitly[TypeTag[AnyVal]]) + println(implicitly[TypeTag[AnyRef]] eq TypeTag.AnyRef) + println(implicitly[TypeTag[AnyRef]]) println(implicitly[TypeTag[Object]] eq TypeTag.Object) println(implicitly[TypeTag[Object]]) println(implicitly[TypeTag[Null]] eq TypeTag.Null) |