diff options
Diffstat (limited to 'test/files')
26 files changed, 206 insertions, 71 deletions
diff --git a/test/files/neg/eta-expand-star-deprecation.check b/test/files/neg/eta-expand-star-deprecation.check deleted file mode 100644 index a79f0df76c..0000000000 --- a/test/files/neg/eta-expand-star-deprecation.check +++ /dev/null @@ -1,4 +0,0 @@ -warning: -Yeta-expand-keeps-star is deprecated: This flag is scheduled for removal in 2.12. If you have a case where you need this flag then please report a bug. -error: No warnings can be incurred under -Xfatal-warnings. -one warning found -one error found diff --git a/test/files/neg/eta-expand-star-deprecation.flags b/test/files/neg/eta-expand-star-deprecation.flags deleted file mode 100644 index 5ac8b638e4..0000000000 --- a/test/files/neg/eta-expand-star-deprecation.flags +++ /dev/null @@ -1 +0,0 @@ --Yeta-expand-keeps-star -deprecation -Xfatal-warnings diff --git a/test/files/neg/eta-expand-star-deprecation.scala b/test/files/neg/eta-expand-star-deprecation.scala deleted file mode 100644 index 5749692522..0000000000 --- a/test/files/neg/eta-expand-star-deprecation.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - def f[T](xs: T*): Unit = () - def g[T] = f[T] _ - - def main(args: Array[String]): Unit = { - g(1, 2) - } -} diff --git a/test/files/neg/t10068.check b/test/files/neg/t10068.check new file mode 100644 index 0000000000..2bb27c4fd8 --- /dev/null +++ b/test/files/neg/t10068.check @@ -0,0 +1,13 @@ +t10068.scala:5: error: i : Only methods can be marked @elidable. + @elidable(INFO) val i: Int = 42 + ^ +t10068.scala:6: error: j: Only methods can be marked @elidable. + @elidable(INFO) lazy val j: Int = 42 + ^ +t10068.scala:7: error: k : Only methods can be marked @elidable. + @elidable(INFO) var k: Int = 42 + ^ +t10068.scala:9: error: D: Only methods can be marked @elidable. +@elidable(INFO) class D + ^ +four errors found diff --git a/test/files/neg/t10068.flags b/test/files/neg/t10068.flags new file mode 100644 index 0000000000..2b18795468 --- /dev/null +++ b/test/files/neg/t10068.flags @@ -0,0 +1 @@ +-Xelide-below WARNING -Xsource:2.13 diff --git a/test/files/neg/t10068.scala b/test/files/neg/t10068.scala new file mode 100644 index 0000000000..a45ee5dac4 --- /dev/null +++ b/test/files/neg/t10068.scala @@ -0,0 +1,9 @@ + +import annotation._, elidable._ + +class C { + @elidable(INFO) val i: Int = 42 + @elidable(INFO) lazy val j: Int = 42 + @elidable(INFO) var k: Int = 42 +} +@elidable(INFO) class D diff --git a/test/files/neg/t3772.check b/test/files/neg/t3772.check new file mode 100644 index 0000000000..d1ed39d8b6 --- /dev/null +++ b/test/files/neg/t3772.check @@ -0,0 +1,7 @@ +t3772.scala:7: error: value inner is not a member of object CC + CC.inner + ^ +t3772.scala:14: error: value outer is not a member of object CC + CC.outer + ^ +two errors found diff --git a/test/files/neg/t3772.scala b/test/files/neg/t3772.scala new file mode 100644 index 0000000000..cac4932d4a --- /dev/null +++ b/test/files/neg/t3772.scala @@ -0,0 +1,17 @@ +class Test { + def m = { + case class CC(c: Int) + if ("".isEmpty) { + object CC { def inner = 42} + } + CC.inner + } + def n = { + object CC { val outer = 42 } + if ("".isEmpty) { + case class CC(c: Int) + CC(0).c + CC.outer + } + } +} diff --git a/test/files/neg/t8002-nested-scope.check b/test/files/neg/t8002-nested-scope.check new file mode 100644 index 0000000000..f66249e432 --- /dev/null +++ b/test/files/neg/t8002-nested-scope.check @@ -0,0 +1,4 @@ +t8002-nested-scope.scala:8: error: method x in class C cannot be accessed in C + new C().x + ^ +one error found diff --git a/test/files/neg/t8002-nested-scope.scala b/test/files/neg/t8002-nested-scope.scala new file mode 100644 index 0000000000..44704a12b1 --- /dev/null +++ b/test/files/neg/t8002-nested-scope.scala @@ -0,0 +1,12 @@ +class C { + def foo = { + class C { private def x = 0 } + + { + val a = 0 + object C { + new C().x + } + } + } +} diff --git a/test/files/pos/t3772.scala b/test/files/pos/t3772.scala new file mode 100644 index 0000000000..62c433ebd1 --- /dev/null +++ b/test/files/pos/t3772.scala @@ -0,0 +1,8 @@ +class Test { + def m = { + case class C(c: Int) + object C { def xxx = true} + C(42).c + C.xxx + } +} diff --git a/test/files/pos/t8002-nested-scope.scala b/test/files/pos/t8002-nested-scope.scala deleted file mode 100644 index 8ce809e556..0000000000 --- a/test/files/pos/t8002-nested-scope.scala +++ /dev/null @@ -1,20 +0,0 @@ -// This test serves to capture the status quo, but should really -// emit an accessibility error. - -// `Namers#companionSymbolOf` seems too lenient, and currently doesn't -// implement the same-scope checks mentioned: -// -// https://github.com/scala/scala/pull/2816#issuecomment-22555206 -// -class C { - def foo = { - class C { private def x = 0 } - - { - val a = 0 - object C { - new C().x - } - } - } -} diff --git a/test/files/run/SD-290.scala b/test/files/run/SD-290.scala new file mode 100644 index 0000000000..0af9cb7cfa --- /dev/null +++ b/test/files/run/SD-290.scala @@ -0,0 +1,39 @@ +object p1 { + class B + object B + + class C extends java.io.Serializable + object C + + type D = DD + object D +} +package object p2 { + class B + object B + + class C extends java.io.Serializable + object C + + type D = DD + object D + +} +class DD extends java.io.Serializable + +object Test { + def main(args: Array[String]): Unit = { + + // This is the behaviour that was intended and was unchanged by this commmit. + assert(!(p1.B : Object).isInstanceOf[scala.Serializable]) + assert(p1.C.isInstanceOf[scala.Serializable]) + assert(!(p1.D: Object).isInstanceOf[scala.Serializable]) + + assert(!(p2.B : Object).isInstanceOf[scala.Serializable]) + assert(p2.C.isInstanceOf[scala.Serializable]) + + // this behaviour was different in 2.12.1 and earlier due to a bug + // in companionSymbolOf + assert(!(p2.D: Object).isInstanceOf[scala.Serializable]) + } +} diff --git a/test/files/run/elidable.flags b/test/files/run/elidable.flags index 93fd3d5317..4bebebdc41 100644 --- a/test/files/run/elidable.flags +++ b/test/files/run/elidable.flags @@ -1 +1 @@ --Xelide-below 900 +-Xelide-below WARNING diff --git a/test/files/run/elidable.scala b/test/files/run/elidable.scala index 6a603084b7..02785972bb 100644 --- a/test/files/run/elidable.scala +++ b/test/files/run/elidable.scala @@ -1,6 +1,8 @@ import annotation._ import elidable._ +// runs -Xelide-below WARNING or 900 + trait T { @elidable(FINEST) def f1() @elidable(SEVERE) def f2() @@ -38,6 +40,13 @@ object Test { @elidable(FINEST) def fd() = 1.0 @elidable(FINEST) def fe() = "s" + /* variable elisions? see test/files/neg/t10068.scala + @elidable(INFO) val goner1: Int = { assert(false, "Should have been elided.") ; 42 } + @elidable(INFO) lazy val goner2: Int = { assert(false, "Should have been elided.") ; 42 } + @elidable(INFO) var goner3: Int = { assert(false, "Should have been elided.") ; 42 } + @elidable(INFO) var goner4: Nothing = _ + */ + def main(args: Array[String]): Unit = { f1() f2() @@ -80,5 +89,17 @@ object Test { Class.forName(className).getMethod(methodName) } } + + // variable elisions? + /* + assert(goner1 == 0) + assert(goner2 == 0) + assert(goner3 == 0) + try assert(goner4 == null) + catch { + case _: NullPointerException => println("NPE") + case _: NotImplementedError => println("NIE") + } + */ } } diff --git a/test/files/run/eta-expand-star2.check b/test/files/run/eta-expand-star2.check deleted file mode 100644 index d6929e4969..0000000000 --- a/test/files/run/eta-expand-star2.check +++ /dev/null @@ -1,2 +0,0 @@ -warning: there was one deprecation warning; re-run with -deprecation for details -hello diff --git a/test/files/run/eta-expand-star2.flags b/test/files/run/eta-expand-star2.flags deleted file mode 100644 index 0402fe55a4..0000000000 --- a/test/files/run/eta-expand-star2.flags +++ /dev/null @@ -1 +0,0 @@ --Yeta-expand-keeps-star
\ No newline at end of file diff --git a/test/files/run/eta-expand-star2.scala b/test/files/run/eta-expand-star2.scala deleted file mode 100644 index eb650788d0..0000000000 --- a/test/files/run/eta-expand-star2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - def f[T](xs: T*): T = xs.head - def g[T] = f[T] _ - - def main(args: Array[String]): Unit = { - println(g("hello")) - } -} diff --git a/test/files/run/t10067.flags b/test/files/run/t10067.flags new file mode 100644 index 0000000000..c02e5f2461 --- /dev/null +++ b/test/files/run/t10067.flags @@ -0,0 +1 @@ +-unchecked diff --git a/test/files/run/t10067/OuterClass.java b/test/files/run/t10067/OuterClass.java new file mode 100644 index 0000000000..15c2c990d7 --- /dev/null +++ b/test/files/run/t10067/OuterClass.java @@ -0,0 +1,7 @@ +public class OuterClass { + public class InnerClass { } + + public Object getInnerClassInstance() { + return new InnerClass(); + } +} diff --git a/test/files/run/t10067/Test.scala b/test/files/run/t10067/Test.scala new file mode 100644 index 0000000000..af1e12592e --- /dev/null +++ b/test/files/run/t10067/Test.scala @@ -0,0 +1,19 @@ +object Test { + def main(args: Array[String]): Unit = { + //get inner class as some instance of super type + var oc = new OuterClass(); + var icObj = oc.getInnerClassInstance(); + + //get a stable identifier on outer class + val ocStable = oc; + + //these will work + icObj.isInstanceOf[ocStable.InnerClass]; + icObj.asInstanceOf[ocStable.InnerClass]; + + //this will fail with java.lang.NoSuchMethodError + icObj match { + case ic: ocStable.InnerClass => ; + } + } +} diff --git a/test/files/run/t10069.scala b/test/files/run/t10069.scala new file mode 100644 index 0000000000..4e70b7e814 --- /dev/null +++ b/test/files/run/t10069.scala @@ -0,0 +1,34 @@ +object Expected extends Exception +object Test { + def throwExpected: Nothing = throw Expected + def foo0(a: Array[Double]) = { // does compile for Int instead of Double + val v = 42 + a(0) = throwExpected // was crash in code gen: java.lang.NegativeArraySizeException + } + + def foo1(a: Array[Double]) = { // does compile for Int instead of Double + a(0) = throwExpected // was VerifyError at runtime + } + + def foo2(a: Array[Int]) = { // does compile for Int instead of Double + a(0) = throwExpected // was VerifyError at runtime + } + + def foo3(a: Array[String]) = { // does compile for Int instead of Double + a(0) = throwExpected // was already working + } + + + def main(args: Array[String]): Unit = { + check(foo0(new Array[Double](1))) + check(foo1(new Array[Double](1))) + check(foo2(new Array[Int](1))) + check(foo3(new Array[String](1))) + } + def check(f: => Any) { + try {f ; sys.error("no exception thrown") + } catch { + case Expected => + } + } +} diff --git a/test/files/run/t10069b.scala b/test/files/run/t10069b.scala new file mode 100644 index 0000000000..c9d652bb0c --- /dev/null +++ b/test/files/run/t10069b.scala @@ -0,0 +1,13 @@ +object Test { + def main(args: Array[String]): Unit = { + try { + Int.box(???) // crashed the compiler: java.util.NoSuchElementException: key not found: Lscala/runtime/Nothing$; + sys.error("no exception") + } catch { + case _: NotImplementedError => + // oka + case e: Throwable => + sys.error("wrong exception: " + e) + } + } +} diff --git a/test/files/run/t7899-regression.check b/test/files/run/t7899-regression.check deleted file mode 100644 index 602b03a1d1..0000000000 --- a/test/files/run/t7899-regression.check +++ /dev/null @@ -1 +0,0 @@ -warning: -Yinfer-by-name is deprecated: This flag is scheduled for removal in 2.12. If you have a case where you need this flag then please report a bug. diff --git a/test/files/run/t7899-regression.flags b/test/files/run/t7899-regression.flags deleted file mode 100644 index 553a27eafd..0000000000 --- a/test/files/run/t7899-regression.flags +++ /dev/null @@ -1 +0,0 @@ --Yinfer-by-name -deprecation diff --git a/test/files/run/t7899-regression.scala b/test/files/run/t7899-regression.scala deleted file mode 100644 index 67d38cdd1d..0000000000 --- a/test/files/run/t7899-regression.scala +++ /dev/null @@ -1,24 +0,0 @@ -import language.higherKinds - -object Test { - trait Monad[M[_]] { - def foo[A](ma: M[A])(f: M[A] => Any) = f(ma) - } - implicit def function1Covariant[T]: Monad[({type l[a] = (T => a)})#l] = - new Monad[({type l[a] = (T => a)})#l] {} - - def main(args: Array[String]) { - // inference of T = (=> Any) here was outlawed by SI-7899 / 8ed7099 - // but this pattern is used in Scalaz in just a few places and caused - // a regression. - // - // Inference of a by-name type doesn't *always* lead to a ClassCastException, - // it only gets there if a method in generic code accepts a parameter of - // that type. - // - // We need to introduce the stricter inference rules gradually, probably - // with a warning. - val m = implicitly[Monad[({type f[+x] = (=> Any) => x})#f]] - assert(m.foo[Int]((x => 0))(f => f(???)) == 0) - } -} |