diff options
Diffstat (limited to 'test/files')
88 files changed, 488 insertions, 210 deletions
diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala index abcf1b4cbc..d0de2f5542 100644 --- a/test/files/jvm/future-spec/FutureTests.scala +++ b/test/files/jvm/future-spec/FutureTests.scala @@ -238,7 +238,7 @@ class FutureTests extends MinimalScalaTest { "support pattern matching within a for-comprehension" in { case class Req[T](req: T) case class Res[T](res: T) - def async[T](req: Req[T]) = req match { + def async[T](req: Req[T]) = (req: @unchecked) match { case Req(s: String) => Future { Res(s.length) } case Req(i: Int) => Future { Res((i * 2).toString) } } diff --git a/test/files/jvm/innerClassEnclMethodJavaReflection.scala b/test/files/jvm/innerClassEnclMethodJavaReflection.scala index a4d64d0b67..a60b5cac8e 100644 --- a/test/files/jvm/innerClassEnclMethodJavaReflection.scala +++ b/test/files/jvm/innerClassEnclMethodJavaReflection.scala @@ -25,12 +25,13 @@ object Test extends App { def testClasses(jarOrDirectory: String): Unit = { val classPath = AbstractFile.getDirectory(new java.io.File(jarOrDirectory)) + val basePath = classPath.path + "/" - def flatten(f: AbstractFile): Iterator[AbstractFile] = - if (f.isClassContainer) f.iterator.flatMap(flatten) - else Iterator(f) + def flatten(f: AbstractFile, s: String): Iterator[(AbstractFile, String)] = + if (f.isClassContainer) f.iterator.map(ch => (ch, (if(s.isEmpty) "" else s + "/") + ch.name)).flatMap((flatten _).tupled) + else Iterator((f, s)) - val classFullNames = flatten(classPath).filter(_.hasExtension("class")).map(_.path.replace("/", ".").replaceAll(".class$", "")) + val classFullNames = flatten(classPath, "").filter(_._1.hasExtension("class")).map(_._2.replace("/", ".").replaceAll(".class$", "")) // it seems that Class objects can only be GC'd together with their class loader // (http://stackoverflow.com/questions/2433261/when-and-how-are-classes-garbage-collected-in-java) diff --git a/test/files/jvm/t6941.check b/test/files/jvm/t6941.check deleted file mode 100644 index 43f53aba12..0000000000 --- a/test/files/jvm/t6941.check +++ /dev/null @@ -1 +0,0 @@ -bytecode identical diff --git a/test/files/jvm/t6941.flags b/test/files/jvm/t6941.flags deleted file mode 100644 index 49d036a887..0000000000 --- a/test/files/jvm/t6941.flags +++ /dev/null @@ -1 +0,0 @@ --optimize diff --git a/test/files/jvm/t6941/Analyzed_1.flags b/test/files/jvm/t6941/Analyzed_1.flags deleted file mode 100644 index ad51758c39..0000000000 --- a/test/files/jvm/t6941/Analyzed_1.flags +++ /dev/null @@ -1 +0,0 @@ --nowarn diff --git a/test/files/jvm/t6941/Analyzed_1.scala b/test/files/jvm/t6941/Analyzed_1.scala deleted file mode 100644 index b6951f71ee..0000000000 --- a/test/files/jvm/t6941/Analyzed_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -// this class's bytecode, compiled under -optimize is analyzed by the test -// method a's bytecode should be identical to method b's bytecode -class SameBytecode { - def a(xs: List[Int]) = xs match { - case x :: _ => x - } - - def b(xs: List[Int]) = xs match { - case xs: ::[Int] => xs.head - } -}
\ No newline at end of file diff --git a/test/files/jvm/t6941/test.scala b/test/files/jvm/t6941/test.scala deleted file mode 100644 index fceb54487f..0000000000 --- a/test/files/jvm/t6941/test.scala +++ /dev/null @@ -1,15 +0,0 @@ -import scala.tools.partest.{BytecodeTest, ASMConverters} - -import scala.tools.nsc.util.JavaClassPath -import java.io.InputStream -import scala.tools.asm -import asm.ClassReader -import asm.tree.{ClassNode, InsnList} -import scala.collection.JavaConverters._ - -object Test extends BytecodeTest { - def show: Unit = { - val classNode = loadClassNode("SameBytecode") - similarBytecode(getMethod(classNode, "a"), getMethod(classNode, "b"), ASMConverters.equivalentBytecode(_, _)) - } -} diff --git a/test/files/neg/choices.check b/test/files/neg/choices.check index b114394e96..df4f23461f 100644 --- a/test/files/neg/choices.check +++ b/test/files/neg/choices.check @@ -1,2 +1,6 @@ +error: Usage: -Yresolve-term-conflict:<strategy> + where <strategy> choices are package, object, error (default: error) +error: bad option: '-Yresolve-term-conflict' error: bad options: -Yresolve-term-conflict -one error found +error: flags file may only contain compiler options, found: -Yresolve-term-conflict +four errors found diff --git a/test/files/neg/compile-time-only-a.check b/test/files/neg/compile-time-only-a.check index b1ed1d24c2..a10f8b6489 100644 --- a/test/files/neg/compile-time-only-a.check +++ b/test/files/neg/compile-time-only-a.check @@ -13,9 +13,15 @@ compile-time-only-a.scala:36: error: C2 compile-time-only-a.scala:38: error: C3 new C3(2) ^ +compile-time-only-a.scala:39: error: C3 + C3(2) + ^ compile-time-only-a.scala:41: error: C4 new C4(2) ^ +compile-time-only-a.scala:42: error: C4 + C4(2) + ^ compile-time-only-a.scala:45: error: C5 2.ext ^ @@ -73,4 +79,4 @@ compile-time-only-a.scala:75: error: placebo compile-time-only-a.scala:75: error: placebo @placebo def x = (2: @placebo) ^ -25 errors found +27 errors found diff --git a/test/files/neg/override-object-no.check b/test/files/neg/override-object-no.check index 9cfda80fc3..972a719b3b 100644 --- a/test/files/neg/override-object-no.check +++ b/test/files/neg/override-object-no.check @@ -20,4 +20,12 @@ an overriding object must conform to the overridden object's class bound; required: case2.Bar[Traversable[String]] override object A extends Bar[List[String]] // err ^ -four errors found +override-object-no.scala:52: error: overriding method x in trait A of type => SI9574.Foo.type; + method x has incompatible type + trait B extends A { def x: Bar.type } // should not compile (SI-9574) + ^ +override-object-no.scala:53: error: overriding method x in trait A of type => SI9574.Foo.type; + object x has incompatible type + trait C extends A { override object x } + ^ +6 errors found diff --git a/test/files/neg/override-object-no.scala b/test/files/neg/override-object-no.scala index 745cdb2332..517408886d 100644 --- a/test/files/neg/override-object-no.scala +++ b/test/files/neg/override-object-no.scala @@ -43,3 +43,14 @@ package case2 { override object A extends Bar[List[String]] // err } } + +// Both overridden and overriding members must be objects, not vals with a module type +object SI9574 { + object Foo + object Bar + trait A { def x: Foo.type } + trait B extends A { def x: Bar.type } // should not compile (SI-9574) + trait C extends A { override object x } + trait D { object x; def y = x } + trait E extends D { override val x: super.x.type = y } // OK but doesn't need object subtyping exception +} diff --git a/test/files/neg/partestInvalidFlag.check b/test/files/neg/partestInvalidFlag.check new file mode 100644 index 0000000000..812191dc22 --- /dev/null +++ b/test/files/neg/partestInvalidFlag.check @@ -0,0 +1,4 @@ +error: bad option: '-badCompilerFlag' +error: bad options: -badCompilerFlag notAFlag -Yopt:badChoice +error: flags file may only contain compiler options, found: -badCompilerFlag notAFlag -Yopt:badChoice +three errors found diff --git a/test/files/neg/partestInvalidFlag.flags b/test/files/neg/partestInvalidFlag.flags new file mode 100644 index 0000000000..68884532b9 --- /dev/null +++ b/test/files/neg/partestInvalidFlag.flags @@ -0,0 +1 @@ +-badCompilerFlag notAFlag -Yopt:badChoice diff --git a/test/files/neg/partestInvalidFlag.scala b/test/files/neg/partestInvalidFlag.scala new file mode 100644 index 0000000000..826a1a5bc2 --- /dev/null +++ b/test/files/neg/partestInvalidFlag.scala @@ -0,0 +1 @@ +class C diff --git a/test/files/neg/t8685.check b/test/files/neg/t8685.check new file mode 100644 index 0000000000..1780a20b6e --- /dev/null +++ b/test/files/neg/t8685.check @@ -0,0 +1,45 @@ +t8685.scala:6: warning: constructor D in class D is deprecated: ctor D is depr +case class D @deprecated("ctor D is depr", since="now") (i: Int) + ^ +t8685.scala:35: warning: class C is deprecated: class C is depr + def f = C(42) + ^ +t8685.scala:37: warning: object E is deprecated: module E is depr + def h = E(42) + ^ +t8685.scala:37: warning: class E is deprecated: class E is depr + def h = E(42) + ^ +t8685.scala:38: warning: object F is deprecated: module F is depr + def i = F.G(42) + ^ +t8685.scala:39: warning: object F in object Extra is deprecated: Extra module F is depr + def j = Extra.F.G(42) + ^ +t8685.scala:43: warning: value gg in trait Applies is deprecated: member gg + def k = this.gg.H(0) + ^ +t8685.scala:45: warning: class K in object J is deprecated: Inner K is depr + def l = J.K(42) + ^ +t8685.scala:48: warning: class C is deprecated: class C is depr + def f = new C(42) + ^ +t8685.scala:49: warning: constructor D in class D is deprecated: ctor D is depr + def g = new D(42) + ^ +t8685.scala:50: warning: class E is deprecated: class E is depr + def h = new E(42) + ^ +t8685.scala:51: warning: object F is deprecated: module F is depr + def i = new F.G(42) + ^ +t8685.scala:52: warning: object F in object Extra is deprecated: Extra module F is depr + def j = new Extra.F.G(42) + ^ +t8685.scala:53: warning: class K in object J is deprecated: Inner K is depr + def l = new J.K(42) + ^ +error: No warnings can be incurred under -Xfatal-warnings. +14 warnings found +one error found diff --git a/test/files/neg/t8685.flags b/test/files/neg/t8685.flags new file mode 100644 index 0000000000..c6bfaf1f64 --- /dev/null +++ b/test/files/neg/t8685.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings diff --git a/test/files/neg/t8685.scala b/test/files/neg/t8685.scala new file mode 100644 index 0000000000..711680ecbd --- /dev/null +++ b/test/files/neg/t8685.scala @@ -0,0 +1,54 @@ + + +@deprecated("class C is depr", since="now") +case class C(i: Int) + +case class D @deprecated("ctor D is depr", since="now") (i: Int) + +@deprecated("class E is depr", since="now") +case class E(i: Int) +@deprecated("module E is depr", since="now") +object E + +@deprecated("module F is depr", since="now") +object F { + case class G(i: Int) +} + +object G { + case class H(i: Int) +} + +object Extra { + @deprecated("Extra module F is depr", since="now") + object F { + case class G(i: Int) + } +} + +object J { + @deprecated("Inner K is depr", since="now") + case class K(i: Int) +} + +trait Applies { + def f = C(42) + def g = D(42) + def h = E(42) + def i = F.G(42) + def j = Extra.F.G(42) + + @deprecated("member gg", since="now") + val gg = G + def k = this.gg.H(0) + + def l = J.K(42) +} +trait News { + def f = new C(42) + def g = new D(42) + def h = new E(42) + def i = new F.G(42) + def j = new Extra.F.G(42) + def l = new J.K(42) +} diff --git a/test/files/neg/t9398.check b/test/files/neg/t9398.check new file mode 100644 index 0000000000..f0c464daa1 --- /dev/null +++ b/test/files/neg/t9398.check @@ -0,0 +1,7 @@ +match.scala:3: warning: match may not be exhaustive. +It would fail on the following input: CC(B2) + def test(c: CC): Unit = c match { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t9398.flags b/test/files/neg/t9398.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t9398.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t9398/data.scala b/test/files/neg/t9398/data.scala new file mode 100644 index 0000000000..7a98c0e8e8 --- /dev/null +++ b/test/files/neg/t9398/data.scala @@ -0,0 +1,5 @@ +sealed abstract class TB +case object B extends TB +case object B2 extends TB + +case class CC(tb: TB) diff --git a/test/files/neg/t9398/match.scala b/test/files/neg/t9398/match.scala new file mode 100644 index 0000000000..e110c6a96a --- /dev/null +++ b/test/files/neg/t9398/match.scala @@ -0,0 +1,6 @@ +class Test { + // Should warn that CC(B2) isn't matched + def test(c: CC): Unit = c match { + case CC(B) => () + } +} diff --git a/test/files/neg/t9572.check b/test/files/neg/t9572.check new file mode 100644 index 0000000000..b95bd015cf --- /dev/null +++ b/test/files/neg/t9572.check @@ -0,0 +1,7 @@ +t9572.scala:3: error: too many elements for tuple: 23, allowed: 22 + val term23 = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23) + ^ +t9572.scala:5: error: too many elements for tuple: 23, allowed: 22 + val type23: (Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) = null + ^ +two errors found diff --git a/test/files/neg/t9572.scala b/test/files/neg/t9572.scala new file mode 100644 index 0000000000..32b2db320e --- /dev/null +++ b/test/files/neg/t9572.scala @@ -0,0 +1,6 @@ +class T9572 { + val term22 = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22) + val term23 = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23) + val type22: (Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) = null + val type23: (Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) = null +} diff --git a/test/files/neg/t9629.check b/test/files/neg/t9629.check new file mode 100644 index 0000000000..4eafa84236 --- /dev/null +++ b/test/files/neg/t9629.check @@ -0,0 +1,17 @@ +t9629.scala:4: error: pattern must be a value: Option[Int] +Note: if you intended to match against the class, try `case _: Option[_]` + case Option[Int] => // error was issued before + ^ +t9629.scala:5: error: pattern must be a value: Option[Int] +Note: if you intended to match against the class, try `case _: Option[_]` + case Some(Option[Int]) => // error was skipped, patmat issued an internal error + ^ +t9629.scala:8: error: pattern must be a value: Option[Int] +Note: if you intended to match against the class, try `case _: Option[_]` + case (_, Option[Int]) => + ^ +t9629.scala:9: error: pattern must be a value: Option[Int] +Note: if you intended to match against the class, try `case _: Option[_]` + case x @ (y @ Option[Int]) => + ^ +four errors found diff --git a/test/files/neg/t9629.scala b/test/files/neg/t9629.scala new file mode 100644 index 0000000000..2be2b039f2 --- /dev/null +++ b/test/files/neg/t9629.scala @@ -0,0 +1,12 @@ +class Test { + def foo(a: Any) { + a match { + case Option[Int] => // error was issued before + case Some(Option[Int]) => // error was skipped, patmat issued an internal error + + // variations + case (_, Option[Int]) => + case x @ (y @ Option[Int]) => + } + } +} diff --git a/test/files/pos/t2171.flags b/test/files/pos/t2171.flags deleted file mode 100644 index eb4d19bcb9..0000000000 --- a/test/files/pos/t2171.flags +++ /dev/null @@ -1 +0,0 @@ --optimise
\ No newline at end of file diff --git a/test/files/pos/t2171.scala b/test/files/pos/t2171.scala deleted file mode 100644 index 6c754c76a6..0000000000 --- a/test/files/pos/t2171.scala +++ /dev/null @@ -1,7 +0,0 @@ -final object test { - def logIgnoredException(msg: => String) = - try 0 catch { case ex => println(msg) } - - def main (args: Array[String]): Unit = - while (true) logIgnoredException ("...") -} diff --git a/test/files/pos/t3252.flags b/test/files/pos/t3252.flags deleted file mode 100644 index eb4d19bcb9..0000000000 --- a/test/files/pos/t3252.flags +++ /dev/null @@ -1 +0,0 @@ --optimise
\ No newline at end of file diff --git a/test/files/pos/t3252.scala b/test/files/pos/t3252.scala deleted file mode 100644 index 3ecc1e7cef..0000000000 --- a/test/files/pos/t3252.scala +++ /dev/null @@ -1,15 +0,0 @@ -class A { - def f(x : Boolean) : Thread = { - g { - x match { - case false => - B.h { } - } - } - } - - private def g[T](block : => T) = sys.error("") -} -object B { - def h(block : => Unit) : Nothing = sys.error("") -} diff --git a/test/files/pos/t3420.flags b/test/files/pos/t3420.flags index 4fbafb7e80..397969bb1d 100644 --- a/test/files/pos/t3420.flags +++ b/test/files/pos/t3420.flags @@ -1 +1 @@ --Yopt-warnings Yopt:l:project -Xfatal-warnings
\ No newline at end of file +-Yopt-warnings -Yopt:l:classpath -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t3430.flags b/test/files/pos/t3430.flags deleted file mode 100644 index eb4d19bcb9..0000000000 --- a/test/files/pos/t3430.flags +++ /dev/null @@ -1 +0,0 @@ --optimise
\ No newline at end of file diff --git a/test/files/pos/t3430.scala b/test/files/pos/t3430.scala deleted file mode 100644 index 3129c6276a..0000000000 --- a/test/files/pos/t3430.scala +++ /dev/null @@ -1,13 +0,0 @@ -// package com.example - -object A { - def f1(f: String => Boolean) = f("a") - - def f2(): Boolean = - f1 { s1 => - f1 { s2 => - while (true) { } - true - } - } -}
\ No newline at end of file diff --git a/test/files/pos/t4579.flags b/test/files/pos/t4579.flags deleted file mode 100644 index 1182725e86..0000000000 --- a/test/files/pos/t4579.flags +++ /dev/null @@ -1 +0,0 @@ --optimize
\ No newline at end of file diff --git a/test/files/pos/t4840.flags b/test/files/pos/t4840.flags index eb4d19bcb9..422d6be431 100644 --- a/test/files/pos/t4840.flags +++ b/test/files/pos/t4840.flags @@ -1 +1 @@ --optimise
\ No newline at end of file +-Yopt:l:classpath
\ No newline at end of file diff --git a/test/files/pos/t5899.scala b/test/files/pos/t5899.scala index b16f1f84fe..885baca790 100644 --- a/test/files/pos/t5899.scala +++ b/test/files/pos/t5899.scala @@ -14,6 +14,7 @@ trait Foo { Bippy(Stable) match { case Bippy(nme.WILDCARD) => 1 case Bippy(Stable) => 2 // should not be considered unreachable + case Bippy(_) => 3 } } }
\ No newline at end of file diff --git a/test/files/pos/t6157.flags b/test/files/pos/t6157.flags deleted file mode 100644 index 0ebca3e7af..0000000000 --- a/test/files/pos/t6157.flags +++ /dev/null @@ -1 +0,0 @@ - -optimize diff --git a/test/files/pos/t6157.scala b/test/files/pos/t6157.scala deleted file mode 100644 index 7463989b14..0000000000 --- a/test/files/pos/t6157.scala +++ /dev/null @@ -1,25 +0,0 @@ -// SI-6157 - Compiler crash on inlined function and -optimize option - -object Test { - def main(args: Array[String]) { - Console.println( - ErrorHandler.defaultIfIOException("String")("String") - ) - } -} - -import java.io.IOException - -object ErrorHandler { - - @inline - def defaultIfIOException[T](default: => T)(closure: => T): T = { - try { - closure - } catch { - case e: IOException => - default - } - } -} - diff --git a/test/files/pos/t6547.flags b/test/files/pos/t6547.flags deleted file mode 100644 index c9b68d70dc..0000000000 --- a/test/files/pos/t6547.flags +++ /dev/null @@ -1 +0,0 @@ --optimise diff --git a/test/files/pos/t6547.scala b/test/files/pos/t6547.scala deleted file mode 100644 index 53bd798219..0000000000 --- a/test/files/pos/t6547.scala +++ /dev/null @@ -1,6 +0,0 @@ -trait ConfigurableDefault[@specialized V] { - def fillArray(arr: Array[V], v: V) = (arr: Any) match { - case x: Array[Int] => null - case x: Array[Long] => v.asInstanceOf[Long] - } -} diff --git a/test/files/pos/t8062.flags b/test/files/pos/t8062.flags deleted file mode 100644 index 49d036a887..0000000000 --- a/test/files/pos/t8062.flags +++ /dev/null @@ -1 +0,0 @@ --optimize diff --git a/test/files/pos/t8062/A_1.scala b/test/files/pos/t8062/A_1.scala deleted file mode 100644 index ca0411dae8..0000000000 --- a/test/files/pos/t8062/A_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -package warmup - -object Warmup { - def filter[A](p: Any => Boolean): Any = filter[Any](p) -} diff --git a/test/files/pos/t8062/B_2.scala b/test/files/pos/t8062/B_2.scala deleted file mode 100644 index f0a6761488..0000000000 --- a/test/files/pos/t8062/B_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - warmup.Warmup.filter[Any](x => false) -} diff --git a/test/files/pos/t8306.flags b/test/files/pos/t8306.flags deleted file mode 100644 index 49d036a887..0000000000 --- a/test/files/pos/t8306.flags +++ /dev/null @@ -1 +0,0 @@ --optimize diff --git a/test/files/pos/t8306.scala b/test/files/pos/t8306.scala deleted file mode 100644 index e04b054eb9..0000000000 --- a/test/files/pos/t8306.scala +++ /dev/null @@ -1,8 +0,0 @@ -class Si8306 { - def foo: Int = 123 - lazy val extension: Int = - foo match { - case idx if idx != -1 => 15 - case _ => 17 - } -} diff --git a/test/files/pos/t8359-closelim-crash.flags b/test/files/pos/t8359-closelim-crash.flags deleted file mode 100644 index 49d036a887..0000000000 --- a/test/files/pos/t8359-closelim-crash.flags +++ /dev/null @@ -1 +0,0 @@ --optimize diff --git a/test/files/pos/t8359-closelim-crash.scala b/test/files/pos/t8359-closelim-crash.scala deleted file mode 100644 index 1413694d10..0000000000 --- a/test/files/pos/t8359-closelim-crash.scala +++ /dev/null @@ -1,23 +0,0 @@ -package test - -// This is a minimization of code that crashed the compiler during bootstrapping -// in the first iteration of https://github.com/scala/scala/pull/4373, the PR -// that adjusted the order of free and declared params in LambdaLift. - -// Was: -// java.lang.AssertionError: assertion failed: -// Record Record(<$anon: Function1>,Map(value a$1 -> Deref(LocalVar(value b)))) does not contain a field value b$1 -// at scala.tools.nsc.Global.assert(Global.scala:262) -// at scala.tools.nsc.backend.icode.analysis.CopyPropagation$copyLattice$State.getFieldNonRecordValue(CopyPropagation.scala:113) -// at scala.tools.nsc.backend.icode.analysis.CopyPropagation$copyLattice$State.getFieldNonRecordValue(CopyPropagation.scala:122) -// at scala.tools.nsc.backend.opt.ClosureElimination$ClosureElim$$anonfun$analyzeMethod$1$$anonfun$apply$2.replaceFieldAccess$1(ClosureElimination.scala:124) -class Typer { - def bar(a: Boolean, b: Boolean): Unit = { - @inline - def baz(): Unit = { - ((_: Any) => (Typer.this, a, b)).apply("") - } - ((_: Any) => baz()).apply("") - } -} - diff --git a/test/files/pos/t9123.flags b/test/files/pos/t9123.flags deleted file mode 100644 index c16e2f71dc..0000000000 --- a/test/files/pos/t9123.flags +++ /dev/null @@ -1 +0,0 @@ --optimize -Ydelambdafy:method diff --git a/test/files/pos/t9123.scala b/test/files/pos/t9123.scala deleted file mode 100644 index 22d55b4351..0000000000 --- a/test/files/pos/t9123.scala +++ /dev/null @@ -1,10 +0,0 @@ -trait Setting { - type T - def value: T -} - -object Test { - def test(x: Some[Setting]) = x match { - case Some(dep) => Some(dep.value) map (_ => true) - } -} diff --git a/test/files/pos/t9399.flags b/test/files/pos/t9399.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t9399.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t9399.scala b/test/files/pos/t9399.scala new file mode 100644 index 0000000000..e8a8720f94 --- /dev/null +++ b/test/files/pos/t9399.scala @@ -0,0 +1,17 @@ +sealed abstract class TA +sealed abstract class TB extends TA +case object A extends TA +case object B extends TB + +sealed trait C +case class CTA(id: Int, da: TA) extends C +case class CTB(id: Int, da: TB) extends C + +class Test { + def test(c: C): Unit = c match { + case CTA(_, A) => + case CTA(_, B) => + case CTB(_, B) => + } +} + diff --git a/test/files/pos/t9411a.flags b/test/files/pos/t9411a.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t9411a.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t9411a.scala b/test/files/pos/t9411a.scala new file mode 100644 index 0000000000..d5264663ec --- /dev/null +++ b/test/files/pos/t9411a.scala @@ -0,0 +1,27 @@ +object OhNoes { + + sealed trait F + sealed abstract class FA extends F + sealed abstract class FB extends F + + case object FA1 extends FA + case object FB1 extends FB + case object FB2 extends FB + + sealed trait G + case object G1 extends G + case object G2 extends G + + sealed trait H + case class H1(a: FB, b: G) extends H + case class H2(a: F) extends H + + val demo: H => Unit = { + case H1(FB1, G1) => + case H1(FB2, G2) => + case H2(_: FB) => + case H2(_: FA) => + case H1(FB1, G2) => + case H1(FB2, G1) => + } +} diff --git a/test/files/pos/t9411b.flags b/test/files/pos/t9411b.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t9411b.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t9411b.scala b/test/files/pos/t9411b.scala new file mode 100644 index 0000000000..6888ba9382 --- /dev/null +++ b/test/files/pos/t9411b.scala @@ -0,0 +1,36 @@ +object OhNoes { + + sealed trait F + sealed abstract class FA extends F + sealed abstract class FB extends F + + case object FA1 extends FA + case object FB1 extends FB + case object FB2 extends FB + + sealed trait G + case object G1 extends G + case object G2 extends G + + sealed trait H + case class H1(a: FB, b: G) extends H + case class H2(b: F) extends H + + val demo: H => Unit = { + case H1(FB1, G1) => + case H1(FB2, G2) => + case H2(_: FB) => + case H2(_: FA) => + case H1(FB1, G2) => + case H1(FB2, G1) => + } + + val demo2: H => Unit = { + case H2(_: FA) => + case H2(_: FB) => + case H1(FB1, G1) => + case H1(FB2, G1) => + case H1(FB1, G2) => + case H1(FB2, G2) => + } +} diff --git a/test/files/pos/t9542.scala b/test/files/pos/t9542.scala new file mode 100644 index 0000000000..d65f7ac4c6 --- /dev/null +++ b/test/files/pos/t9542.scala @@ -0,0 +1,8 @@ +object O { + trait T + + class VC(val self: Any) extends AnyVal { + def extMethod(f: F1[T, Any]) = () + } +} +trait F1[A, B] diff --git a/test/files/pos/t9630.flags b/test/files/pos/t9630.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t9630.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t9630/t9630a.scala b/test/files/pos/t9630/t9630a.scala new file mode 100644 index 0000000000..c76ecd2ff2 --- /dev/null +++ b/test/files/pos/t9630/t9630a.scala @@ -0,0 +1,9 @@ + +sealed trait Base +final case class Base_1(sameName: Some[Any]) extends Base +final case class Base_2(sameName: Nested) extends Base + +sealed trait Nested +final case class Nested_1(x: Any) extends Nested +final case class Nested_2(y: Any) extends Nested + diff --git a/test/files/pos/t9630/t9630b.scala b/test/files/pos/t9630/t9630b.scala new file mode 100644 index 0000000000..3e1787ec52 --- /dev/null +++ b/test/files/pos/t9630/t9630b.scala @@ -0,0 +1,8 @@ + +class Test { + def test(b: Base): Unit = b match { + case Base_1(Some(_)) => + case Base_2(Nested_1(_)) => + case Base_2(Nested_2(_)) => + } +} diff --git a/test/files/pos/trait-force-info.flags b/test/files/pos/trait-force-info.flags deleted file mode 100644 index eb4d19bcb9..0000000000 --- a/test/files/pos/trait-force-info.flags +++ /dev/null @@ -1 +0,0 @@ --optimise
\ No newline at end of file diff --git a/test/files/pos/trait-force-info.scala b/test/files/pos/trait-force-info.scala deleted file mode 100644 index c2b33869c3..0000000000 --- a/test/files/pos/trait-force-info.scala +++ /dev/null @@ -1,18 +0,0 @@ -/** This does NOT crash unless it's in the interactive package. - */ - -package scala.tools.nsc -package interactive - -trait MyContextTrees { - val self: Global - val NoContext = self.analyzer.NoContext -} -// -// error: java.lang.AssertionError: assertion failed: trait Contexts.NoContext$ linkedModule: <none>List() -// at scala.Predef$.assert(Predef.scala:160) -// at scala.tools.nsc.symtab.classfile.ClassfileParser$innerClasses$.innerSymbol$1(ClassfileParser.scala:1211) -// at scala.tools.nsc.symtab.classfile.ClassfileParser$innerClasses$.classSymbol(ClassfileParser.scala:1223) -// at scala.tools.nsc.symtab.classfile.ClassfileParser.classNameToSymbol(ClassfileParser.scala:489) -// at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:757) -// at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:789) diff --git a/test/files/presentation/doc/doc.scala b/test/files/presentation/doc/doc.scala index f2233f1828..ce431910ee 100644 --- a/test/files/presentation/doc/doc.scala +++ b/test/files/presentation/doc/doc.scala @@ -118,6 +118,12 @@ object Test extends InteractiveTest { } } + // The remainder of this test has been found to fail intermittently on Windows + // only. The problem is difficult to isolate and reproduce; see + // https://github.com/scala/scala-dev/issues/72 for details. + // So if we're on Windows, let's just bail out here. + if (scala.util.Properties.isWin) return + // Check inter-classes documentation one-time retrieved ok. val baseSource = findSource("Base.scala") val derivedSource = findSource("Derived.scala") diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala index 2d9457653f..db6e1d8e04 100644 --- a/test/files/run/Course-2002-07.scala +++ b/test/files/run/Course-2002-07.scala @@ -485,7 +485,7 @@ object MB { import Utils._; - trait Expr { + sealed trait Expr { private def count: Int = this match { case Lit(n) => n diff --git a/test/files/run/caseclasses.scala b/test/files/run/caseclasses.scala index 668c984f3d..10c0916dc0 100644 --- a/test/files/run/caseclasses.scala +++ b/test/files/run/caseclasses.scala @@ -18,7 +18,7 @@ object M { object Test extends App { def Abs(x: Int) = new Abs(x * 2){} - Abs(2) match { + (Abs(2): @unchecked) match { case Abs(4) => ; } diff --git a/test/files/run/elidable-opt.scala b/test/files/run/elidable-opt.scala index ebada46de8..a2f29d2caf 100644 --- a/test/files/run/elidable-opt.scala +++ b/test/files/run/elidable-opt.scala @@ -1,6 +1,3 @@ -/* - * filter: inliner warnings; re-run with - */ import annotation._ import elidable._ diff --git a/test/files/run/infix.scala b/test/files/run/infix.scala index a867d03ce8..1d39003644 100644 --- a/test/files/run/infix.scala +++ b/test/files/run/infix.scala @@ -7,5 +7,6 @@ object Test extends App { Console.println(xs) xs match { case null op (0, 0) op (1, 1) op (2, 2) => Console.println("OK") + case _ => } } diff --git a/test/files/run/lisp.check b/test/files/run/lisp.check new file mode 100644 index 0000000000..64053f26d0 --- /dev/null +++ b/test/files/run/lisp.check @@ -0,0 +1,26 @@ +(lambda (x) (+ (* x x) 1)) +(lambda (x) (+ (* x x) 1)) + +( '(1 2 3)) = (1 2 3) +(car '(1 2 3)) = 1 +(cdr '(1 2 3)) = (2 3) +(null? '(2 3)) = 0 +(null? '()) = 1 + +faculty(10) = 3628800 +faculty(10) = 3628800 +foobar = ("a" "bc" "def" "z") + +List('lambda, List('x), List('+, List('*, 'x, 'x), 1)) +(lambda (x) (+ (* x x) 1)) + +( '(1 2 3)) = (1 2 3) +(car '(1 2 3)) = 1 +(cdr '(1 2 3)) = (2 3) +(null? '(2 3)) = 0 +(null? '()) = 1 + +faculty(10) = 3628800 +faculty(10) = 3628800 +foobar = ("a" "bc" "def" "z") + diff --git a/test/files/pos/t4579.scala b/test/files/run/lisp.scala index cd1553f02a..162c7d2599 100644 --- a/test/files/pos/t4579.scala +++ b/test/files/run/lisp.scala @@ -1,5 +1,5 @@ //############################################################################ -// Lisp interpreter (revived as an optimizer test.) +// Lisp interpreter //############################################################################ //############################################################################ diff --git a/test/files/run/numbereq.scala b/test/files/run/numbereq.scala index 7ce4b23cf8..1f12d0643e 100644 --- a/test/files/run/numbereq.scala +++ b/test/files/run/numbereq.scala @@ -1,6 +1,7 @@ object Test { def mkNumbers(x: Int): List[AnyRef] = { - val base = List( + //Use explicit AnyRef to workaround known limitation of type inference with F-Bounds + val base = List[AnyRef]( BigDecimal(x), BigInt(x), new java.lang.Double(x.toDouble), diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index 3c0d00dc6c..2647d97836 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -539,7 +539,7 @@ object Test { case class Operator(x: Int); val EQ = new Operator(2); - def analyze(x: Tuple2[Operator, Int]) = x match { + def analyze(x: Tuple2[Operator, Int]) = (x: @unchecked) match { case (EQ, 0) => "0" case (EQ, 1) => "1" case (EQ, 2) => "2" @@ -603,7 +603,7 @@ object Test { object Bug1093 { def run() { - assert(Some(3) match { + assert((Some(3): @unchecked) match { case Some(1 | 2) => false case Some(3) => true }) diff --git a/test/files/run/t3126.scala b/test/files/run/t3126.scala index 36322bf896..865047ce4f 100644 --- a/test/files/run/t3126.scala +++ b/test/files/run/t3126.scala @@ -4,6 +4,6 @@ object Test { def main(args: Array[String]): Unit = { try C.unapply(null) catch { case _: MatchError => } - try v match { case Some(1) => } catch { case _: MatchError => } + try ((v: @unchecked) match { case Some(1) => }) catch { case _: MatchError => } } } diff --git a/test/files/run/t4124.scala b/test/files/run/t4124.scala index 9f35b57ce3..db4e382634 100644 --- a/test/files/run/t4124.scala +++ b/test/files/run/t4124.scala @@ -2,22 +2,22 @@ import xml.Node object Test extends App { val body: Node = <elem>hi</elem> - println ((body: AnyRef, "foo") match { + println (((body: AnyRef, "foo"): @unchecked) match { case (node: Node, "bar") => "bye" case (ser: Serializable, "foo") => "hi" }) - println ((body, "foo") match { + println (((body, "foo"): @unchecked) match { case (node: Node, "bar") => "bye" case (ser: Serializable, "foo") => "hi" }) - println ((body: AnyRef, "foo") match { + println (((body: AnyRef, "foo"): @unchecked) match { case (node: Node, "foo") => "bye" case (ser: Serializable, "foo") => "hi" }) - println ((body: AnyRef, "foo") match { + println (((body: AnyRef, "foo"): @unchecked) match { case (node: Node, "foo") => "bye" case (ser: Serializable, "foo") => "hi" }) diff --git a/test/files/run/t6089.scala b/test/files/run/t6089.scala index c72d7ba792..c42a9f68c6 100644 --- a/test/files/run/t6089.scala +++ b/test/files/run/t6089.scala @@ -3,7 +3,7 @@ case class Foo(x: Int) object Test { def bippo(result: Boolean): Boolean = result def bungus(m: Foo): Boolean = - bippo(m match { case Foo(2) => bungus(m) }) + bippo((m: @unchecked) match { case Foo(2) => bungus(m) }) def main(args: Array[String]): Unit = try { bungus(Foo(0)) diff --git a/test/files/run/t7008-scala-defined.flags b/test/files/run/t7008-scala-defined.flags deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t7008-scala-defined.flags +++ /dev/null diff --git a/test/files/run/t7008-scala-defined/Test_3.scala b/test/files/run/t7008-scala-defined/Test_3.scala index 26178142ab..ee7b9d9cde 100644 --- a/test/files/run/t7008-scala-defined/Test_3.scala +++ b/test/files/run/t7008-scala-defined/Test_3.scala @@ -1,6 +1,3 @@ -/* - * filter: inliner warning; re-run with - */ import scala.reflect.runtime.universe._ object Test extends App { diff --git a/test/files/run/t7459f.scala b/test/files/run/t7459f.scala index 63e2109560..5cd972129a 100644 --- a/test/files/run/t7459f.scala +++ b/test/files/run/t7459f.scala @@ -3,7 +3,7 @@ object Test extends App { case class FooSeq(x: Int, y: String, z: C*) - FooSeq(1, "a", new C()) match { + (FooSeq(1, "a", new C()): @unchecked) match { case FooSeq(1, "a", x@_* ) => //println(x.toList) x.asInstanceOf[x.type] diff --git a/test/files/run/t7582.check b/test/files/run/t7582.check index 0cfbf08886..58d0f19f5d 100644 --- a/test/files/run/t7582.check +++ b/test/files/run/t7582.check @@ -1 +1,6 @@ +InlineHolder.scala:9: warning: p1/InlineHolder$::inlinable()I is annotated @inline but could not be inlined: +The callee p1/InlineHolder$::inlinable()I contains the instruction INVOKESTATIC p1/PackageProtectedJava.protectedMethod ()I +that would cause an IllegalAccessError when inlined into class O$. + def x = p1.InlineHolder.inlinable + ^ 2 diff --git a/test/files/run/t7582.flags b/test/files/run/t7582.flags index 422d6be431..1f45833eff 100644 --- a/test/files/run/t7582.flags +++ b/test/files/run/t7582.flags @@ -1 +1 @@ --Yopt:l:classpath
\ No newline at end of file +-Yopt:l:classpath -Yopt-warnings
\ No newline at end of file diff --git a/test/files/run/t7582/InlineHolder.scala b/test/files/run/t7582/InlineHolder.scala index 3cbf233ce1..a18b9effaa 100644 --- a/test/files/run/t7582/InlineHolder.scala +++ b/test/files/run/t7582/InlineHolder.scala @@ -1,6 +1,3 @@ -/* - * filter: inliner warning; re-run with - */ package p1 { object InlineHolder { @inline def inlinable = p1.PackageProtectedJava.protectedMethod() + 1 diff --git a/test/files/run/t7582b.check b/test/files/run/t7582b.check index 0cfbf08886..58d0f19f5d 100644 --- a/test/files/run/t7582b.check +++ b/test/files/run/t7582b.check @@ -1 +1,6 @@ +InlineHolder.scala:9: warning: p1/InlineHolder$::inlinable()I is annotated @inline but could not be inlined: +The callee p1/InlineHolder$::inlinable()I contains the instruction INVOKESTATIC p1/PackageProtectedJava.protectedMethod ()I +that would cause an IllegalAccessError when inlined into class O$. + def x = p1.InlineHolder.inlinable + ^ 2 diff --git a/test/files/run/t7582b.flags b/test/files/run/t7582b.flags index 422d6be431..1f45833eff 100644 --- a/test/files/run/t7582b.flags +++ b/test/files/run/t7582b.flags @@ -1 +1 @@ --Yopt:l:classpath
\ No newline at end of file +-Yopt:l:classpath -Yopt-warnings
\ No newline at end of file diff --git a/test/files/run/t7582b/InlineHolder.scala b/test/files/run/t7582b/InlineHolder.scala index 3cbf233ce1..a18b9effaa 100644 --- a/test/files/run/t7582b/InlineHolder.scala +++ b/test/files/run/t7582b/InlineHolder.scala @@ -1,6 +1,3 @@ -/* - * filter: inliner warning; re-run with - */ package p1 { object InlineHolder { @inline def inlinable = p1.PackageProtectedJava.protectedMethod() + 1 diff --git a/test/files/run/t7807.check b/test/files/run/t7807.check new file mode 100644 index 0000000000..fd22077f2e --- /dev/null +++ b/test/files/run/t7807.check @@ -0,0 +1,3 @@ +... +... +... diff --git a/test/files/run/t7807.scala b/test/files/run/t7807.scala new file mode 100644 index 0000000000..8e3099ec14 --- /dev/null +++ b/test/files/run/t7807.scala @@ -0,0 +1,21 @@ +object Test { + def main(args: Array[String]) { + try { + println("...") + } + finally { + try { + println("...") + } + finally { + try { + println("...") + } + catch { + case ct: scala.util.control.ControlThrowable => throw(ct) + case t: Throwable => t.printStackTrace() + } + } + } + } +} diff --git a/test/files/run/t9349/data.scala b/test/files/run/t9349/data.scala new file mode 100644 index 0000000000..f88a6cfaeb --- /dev/null +++ b/test/files/run/t9349/data.scala @@ -0,0 +1 @@ +case class Outer(i: Int) { class Inner } diff --git a/test/files/run/t9349/test.scala b/test/files/run/t9349/test.scala new file mode 100644 index 0000000000..ebce4e77dd --- /dev/null +++ b/test/files/run/t9349/test.scala @@ -0,0 +1,21 @@ +object Test { + def main(args: Array[String]): Unit = { + val o1 = Outer(5) + o1 match { + case o @ Outer(_) => + val i = new o.Inner + } + o1 match { + case o : Outer => + val i = new o.Inner + + } + object Extractor { + def unapply(a: Any): Option[Outer] = Some(o1) + } + null match { + case Extractor(o2) => + val i = new o2.Inner + } + } +} diff --git a/test/files/run/t9567.scala b/test/files/run/t9567.scala new file mode 100644 index 0000000000..69896b8650 --- /dev/null +++ b/test/files/run/t9567.scala @@ -0,0 +1,18 @@ +object Test { + def testMethodLocalCaseClass { + case class MethodLocalWide( + f01: Int, f02: Int, f03: Int, f04: Int, f05: Int, f06: Int, f07: Int, f08: Int, f09: Int, f10: Int, + f11: Int, f12: Int, f13: Int, f14: Int, f15: Int, f16: Int, f17: Int, f18: Int, f19: Int, f20: Int, + f21: Int, f22: Int, f23: Int) + + val instance = MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + val result = instance match { + case MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) => true + case _ => false + } + assert(result) + } + def main(args: Array[String]) { + testMethodLocalCaseClass + } +} diff --git a/test/files/run/t9567b.scala b/test/files/run/t9567b.scala new file mode 100644 index 0000000000..88cef0a60e --- /dev/null +++ b/test/files/run/t9567b.scala @@ -0,0 +1,19 @@ +object Test { + def testMethodLocalCaseClass { + object MethodLocalWide + case class MethodLocalWide( + f01: Int, f02: Int, f03: Int, f04: Int, f05: Int, f06: Int, f07: Int, f08: Int, f09: Int, f10: Int, + f11: Int, f12: Int, f13: Int, f14: Int, f15: Int, f16: Int, f17: Int, f18: Int, f19: Int, f20: Int, + f21: Int, f22: Int, f23: Int) + + val instance = MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + val result = instance match { + case MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) => true + case _ => false + } + assert(result) + } + def main(args: Array[String]) { + testMethodLocalCaseClass + } +} diff --git a/test/files/run/t9567c.scala b/test/files/run/t9567c.scala new file mode 100644 index 0000000000..560bea8821 --- /dev/null +++ b/test/files/run/t9567c.scala @@ -0,0 +1,29 @@ +case class CaseSequenceTopLevel(as: Int*) + +object Test { + def main(args: Array[String]): Unit = { + + val buffer1 = collection.mutable.Buffer(0, 0) + CaseSequenceTopLevel(buffer1: _*) match { + case CaseSequenceTopLevel(_, i) => + buffer1(1) = 1 + assert(i == 0, i) // fails in 2.11.7 -optimize + } + + case class CaseSequence(as: Int*) + val buffer2 = collection.mutable.Buffer(0, 0) + CaseSequence(buffer2: _*) match { + case CaseSequence(_, i) => + buffer2(1) = 1 + assert(i == 0, i) + } + + case class CaseSequenceWithVar(var x: Any, as: Int*) + val buffer3 = collection.mutable.Buffer(0, 0) + CaseSequenceWithVar("", buffer3: _*) match { + case CaseSequenceWithVar(_, _, i) => // crashes in 2.11.7 + buffer2(1) = 1 + assert(i == 0, i) + } + } +} |