diff options
Diffstat (limited to 'test/files')
26 files changed, 418 insertions, 381 deletions
diff --git a/test/files/neg/t5148.check b/test/files/neg/t5148.check index 0de4fe2d4c..286ed9e04a 100644 --- a/test/files/neg/t5148.check +++ b/test/files/neg/t5148.check @@ -1,6 +1,11 @@ error: missing or invalid dependency detected while loading class file 'Imports.class'. +Could not access type Wrapper in class scala.tools.nsc.interpreter.IMain.Request, +because it (or its dependencies) are missing. Check your build definition for +missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.) +A full rebuild may help if 'Imports.class' was compiled against an incompatible version of scala.tools.nsc.interpreter.IMain.Request. +error: missing or invalid dependency detected while loading class file 'Imports.class'. Could not access type Request in class scala.tools.nsc.interpreter.IMain, because it (or its dependencies) are missing. Check your build definition for missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.) A full rebuild may help if 'Imports.class' was compiled against an incompatible version of scala.tools.nsc.interpreter.IMain. -one error found +two errors found diff --git a/test/files/neg/t8597.check b/test/files/neg/t8597.check new file mode 100644 index 0000000000..bc945f9191 --- /dev/null +++ b/test/files/neg/t8597.check @@ -0,0 +1,21 @@ +t8597.scala:2: warning: abstract type T in type pattern Some[T] is unchecked since it is eliminated by erasure + def nowarn[T] = (null: Any) match { case _: Some[T] => } // warn (did not warn due to SI-8597) + ^ +t8597.scala:5: warning: abstract type pattern T is unchecked since it is eliminated by erasure + def warn1[T] = (null: Any) match { case _: T => } // warn + ^ +t8597.scala:6: warning: non-variable type argument String in type pattern Some[String] is unchecked since it is eliminated by erasure + def warn2 = (null: Any) match { case _: Some[String] => } // warn + ^ +t8597.scala:7: warning: non-variable type argument Unchecked.this.C in type pattern Some[Unchecked.this.C] is unchecked since it is eliminated by erasure + (null: Any) match { case _: Some[C] => } // warn + ^ +t8597.scala:18: warning: abstract type T in type pattern Array[T] is unchecked since it is eliminated by erasure + def warnArray[T] = (null: Any) match { case _: Array[T] => } // warn (did not warn due to SI-8597) + ^ +t8597.scala:26: warning: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure + def warnArrayErasure2 = (null: Any) match {case Some(_: Array[Array[List[String]]]) => } // warn + ^ +error: No warnings can be incurred under -Xfatal-warnings. +6 warnings found +one error found diff --git a/test/files/neg/t8597.flags b/test/files/neg/t8597.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t8597.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t8597.scala b/test/files/neg/t8597.scala new file mode 100644 index 0000000000..068e87d91a --- /dev/null +++ b/test/files/neg/t8597.scala @@ -0,0 +1,27 @@ +class Unchecked[C] { + def nowarn[T] = (null: Any) match { case _: Some[T] => } // warn (did not warn due to SI-8597) + + // These warned before. + def warn1[T] = (null: Any) match { case _: T => } // warn + def warn2 = (null: Any) match { case _: Some[String] => } // warn + (null: Any) match { case _: Some[C] => } // warn + + // These must remain without warnings. These are excerpts from + // related tests that are more exhauative. + class C; class D extends C + def okay = (List(new D) : Seq[D]) match { case _: List[C] => case _ => } // nowarn + class B2[A, B] + class A2[X] extends B2[X, String] + def okay2(x: A2[Int]) = x match { case _: B2[Int, _] => true } // nowarn + def okay3(x: A2[Int]) = x match { case _: B2[Int, typeVar] => true } // nowarn + + def warnArray[T] = (null: Any) match { case _: Array[T] => } // warn (did not warn due to SI-8597) + def nowarnArrayC = (null: Any) match { case _: Array[C] => } // nowarn + + def nowarnArrayTypeVar[T] = (null: Any) match { case _: Array[t] => } // nowarn + + def noWarnArrayErasure1 = (null: Any) match {case Some(_: Array[String]) => } // nowarn + def noWarnArrayErasure2 = (null: Any) match {case Some(_: Array[List[_]]) => } // nowarn + def noWarnArrayErasure3 = (null: Any) match {case Some(_: Array[Array[List[_]]]) => } // nowarn + def warnArrayErasure2 = (null: Any) match {case Some(_: Array[Array[List[String]]]) => } // warn +} diff --git a/test/files/neg/t8597b.check b/test/files/neg/t8597b.check new file mode 100644 index 0000000000..3c45a31337 --- /dev/null +++ b/test/files/neg/t8597b.check @@ -0,0 +1,6 @@ +t8597b.scala:18: warning: non-variable type argument T in type pattern Some[T] is unchecked since it is eliminated by erasure + case _: Some[T] => // warn + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t8597b.flags b/test/files/neg/t8597b.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t8597b.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t8597b.scala b/test/files/neg/t8597b.scala new file mode 100644 index 0000000000..b29d591cb1 --- /dev/null +++ b/test/files/neg/t8597b.scala @@ -0,0 +1,21 @@ +object Unchecked { + (null: Any) match { + case _: Some[t] => + + // t is a fresh pattern type variable, despite our attempts to + // backtick our way to the enclosing `t`. Under this interpretation, + // the absense of an unchecked warning is expected. + (null: Any) match { + case _: Some[t] => // no warn + } + (null: Any) match { + case _: Some[`t`] => // no warn + } + + // here we correctly issue an unchecked warning + type T = t + (null: Any) match { + case _: Some[T] => // warn + } + } +} diff --git a/test/files/neg/unchecked-abstract.check b/test/files/neg/unchecked-abstract.check index 72019082ac..703929dca8 100644 --- a/test/files/neg/unchecked-abstract.check +++ b/test/files/neg/unchecked-abstract.check @@ -4,6 +4,9 @@ unchecked-abstract.scala:16: warning: abstract type H in type Contravariant[M.th unchecked-abstract.scala:21: warning: abstract type H in type Contravariant[M.this.H] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Contravariant[H]]) ^ +unchecked-abstract.scala:22: warning: abstract type T in type Contravariant[M.this.T] is unchecked since it is eliminated by erasure + /* warn */ println(x.isInstanceOf[Contravariant[T]]) + ^ unchecked-abstract.scala:27: warning: abstract type T in type Invariant[M.this.T] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Invariant[T]]) ^ @@ -22,6 +25,15 @@ unchecked-abstract.scala:36: warning: abstract type H in type Invariant[M.this.H unchecked-abstract.scala:37: warning: abstract type T in type Invariant[M.this.T] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Invariant[T]]) ^ +unchecked-abstract.scala:42: warning: abstract type T in type Covariant[M.this.T] is unchecked since it is eliminated by erasure + /* warn */ println(x.isInstanceOf[Covariant[T]]) + ^ +unchecked-abstract.scala:43: warning: abstract type L in type Covariant[M.this.L] is unchecked since it is eliminated by erasure + /* warn */ println(x.isInstanceOf[Covariant[L]]) + ^ +unchecked-abstract.scala:48: warning: abstract type L in type Covariant[M.this.L] is unchecked since it is eliminated by erasure + /* warn */ println(x.isInstanceOf[Covariant[L]]) + ^ error: No warnings can be incurred under -Xfatal-warnings. -8 warnings found +12 warnings found one error found diff --git a/test/files/pos/t7596/A_1.scala b/test/files/pos/t7596/A_1.scala new file mode 100644 index 0000000000..6303c6d132 --- /dev/null +++ b/test/files/pos/t7596/A_1.scala @@ -0,0 +1,10 @@ +trait Driver { + abstract class Table +} + +object Config { + val driver : Driver = ??? + def driver(a: Any) = ??? +} + +object Sites extends Config.driver.Table diff --git a/test/files/pos/t7596/B_2.scala b/test/files/pos/t7596/B_2.scala new file mode 100644 index 0000000000..977e5c8bd1 --- /dev/null +++ b/test/files/pos/t7596/B_2.scala @@ -0,0 +1,19 @@ +object Test { + locally { + Sites: Config.driver.Table + } +} + +// Under separate compilation, the pickler is foiled by the +// overloaded term `Config.driver`, and results in: + +// qbin/scalac test/files/pos/t7596/A_1.scala && qbin/scalac -explaintypes test/files/pos/t7596/B_2.scala +// test/files/pos/t7596/B_2.scala:3: error: type mismatch; +// found : Sites.type +// required: Config.driver.Table +// Sites: Config.driver.Table +// ^ +// Sites.type <: Config.driver.Table? +// Driver.this.type = Config.driver.type? +// false +// false
\ No newline at end of file diff --git a/test/files/pos/t7596b/A.scala b/test/files/pos/t7596b/A.scala new file mode 100644 index 0000000000..65c1bc56ef --- /dev/null +++ b/test/files/pos/t7596b/A.scala @@ -0,0 +1,10 @@ +trait H2Driver{ + abstract class Table[T] +} + +object Config { + val driver : H2Driver = ??? + def driver(app: Any): H2Driver = ??? +} + +class Sites extends Config.driver.Table[String] diff --git a/test/files/pos/t7596b/B.scala b/test/files/pos/t7596b/B.scala new file mode 100644 index 0000000000..cbcf149c23 --- /dev/null +++ b/test/files/pos/t7596b/B.scala @@ -0,0 +1,6 @@ +class DAOBase[E]{ + type TableType <: Config.driver.Table[E] +} +class SitesDAO extends DAOBase[String]{ + type TableType = Sites +} diff --git a/test/files/pos/t7596c/A_1.scala b/test/files/pos/t7596c/A_1.scala new file mode 100644 index 0000000000..3e366df477 --- /dev/null +++ b/test/files/pos/t7596c/A_1.scala @@ -0,0 +1,11 @@ +trait Driver { + abstract class Table +} + +object Config { + val driver : Driver = ??? + val driverUniqueName: driver.type = driver + def driver(a: Any) = ??? +} + +object Sites extends Config.driver.Table diff --git a/test/files/pos/t7596c/B_2.scala b/test/files/pos/t7596c/B_2.scala new file mode 100644 index 0000000000..33da68c1ff --- /dev/null +++ b/test/files/pos/t7596c/B_2.scala @@ -0,0 +1,9 @@ +object Test { + locally { + Sites: Config.driver.Table + } +} + +// This variation worked by avoiding referring to the +// overloaded term `Config.driver` in the parent type of +// Sites
\ No newline at end of file diff --git a/test/files/pos/t9018.scala b/test/files/pos/t9018.scala new file mode 100644 index 0000000000..7fb4cf21b3 --- /dev/null +++ b/test/files/pos/t9018.scala @@ -0,0 +1,16 @@ +object TestObject { + + def m(i: Int): AnyRef = i match { + case 0 => new C() + case 1 => Some(E.A).getOrElse("") + } + + class C extends Ordered[C] { + def compare(that: C): Int = ??? + } + + object E extends Enumeration { + type CharacterClass = Value + val A = Value + } +} diff --git a/test/files/run/priorityQueue.scala b/test/files/run/priorityQueue.scala deleted file mode 100644 index 327d8bf137..0000000000 --- a/test/files/run/priorityQueue.scala +++ /dev/null @@ -1,373 +0,0 @@ - - - -import scala.collection.mutable.PriorityQueue - - - - - - -// populate a priority queue a few different ways and make sure they all seem equal -object Test { - - def main(args: Array[String]) { - // testInsertionsAndEqualities - // testIntensiveEnqueueDequeue - // testTails - // testInits - // testFilters - // testDrops - // testEquality - // testMisc - // testReverse - // testToList - // testForeach - } - - // def testInsertionsAndEqualities { - // import scala.util.Random.nextInt - // val pq1 = new PriorityQueue[String] - // val pq2 = new PriorityQueue[String] - // val pq3 = new PriorityQueue[String] - // val pq4 = new PriorityQueue[String] - - // val strings = (1 to 20).toList map (i => List.fill((Math.abs(nextInt % 20)) + 1)("x").mkString) - - // pq1 ++= strings - // pq2 ++= strings.reverse - // for (s <- strings) pq3 += s - // for (s <- strings.reverse) pq4 += s - - // val pqs = List(pq1, pq2, pq3, pq4, pq1.clone, pq2.clone) - - // for (queue1 <- pqs ; queue2 <- pqs) { - // val l1: List[String] = queue1.dequeueAll[String, List[String]] - // val l2: List[String] = queue2.dequeueAll[String, List[String]] - // assert(l1 == l2) - // assert(queue1.max == queue2.max) - // } - - // assertPriorityDestructive(pq1) - // } - - // not a sequence anymore, Mildred - // def testIndexing { - // val pq = new PriorityQueue[Char] - // "The quick brown fox jumps over the lazy dog".foreach(pq += _) - - // // val iter = pq.iterator - // // while (iter.hasNext) println("`" + iter.next + "`") - // assert(pq(0) == 'z') - // assert(pq(1) == 'y') - // assert(pq(2) == 'x') - // assert(pq(3) == 'w') - // assert(pq(4) == 'v') - // assert(pq(5) == 'u') - // assert(pq(7) == 't') - // assert(pq(8) == 's') - // assert(pq(9) == 'r') - // assert(pq(10) == 'r') - - // pq.clear - // "abcdefghijklmnopqrstuvwxyz".foreach(pq += _) - // for (i <- 0 until 26) assert(pq(i) == ('z' - i)) - - // val intpq = new PriorityQueue[Int] - // val intlst = new collection.mutable.ArrayBuffer ++ (0 until 100) - // val random = new util.Random(101) - // while (intlst.nonEmpty) { - // val idx = random.nextInt(intlst.size) - // intpq += intlst(idx) - // intlst.remove(idx) - // } - // for (i <- 0 until 100) assert(intpq(i) == (99 - i)) - // } - - // def testTails { - // val pq = new PriorityQueue[Int] - // for (i <- 0 until 10) pq += i * 4321 % 200 - - // assert(pq.size == 10) - // assert(pq.nonEmpty) - - // val tailpq = pq.tail - // // pq.printstate - // // tailpq.printstate - // assert(tailpq.size == 9) - // assert(tailpq.nonEmpty) - // assertPriorityDestructive(tailpq) - // } - - // def assertPriorityDestructive[A](pq: PriorityQueue[A])(implicit ord: Ordering[A]) { - // import ord._ - // var prev: A = null.asInstanceOf[A] - // while (pq.nonEmpty) { - // val curr = pq.dequeue - // if (prev != null) assert(curr <= prev) - // prev = curr - // } - // } - - // def testInits { - // val pq = new PriorityQueue[Long] - // for (i <- 0 until 20) pq += (i + 313) * 111 % 300 - - // assert(pq.size == 20) - - // val initpq = pq.init - // assert(initpq.size == 19) - // assertPriorityDestructive(initpq) - // } - - // def testFilters { - // val pq = new PriorityQueue[String] - // for (i <- 0 until 100) pq += "Some " + (i * 312 % 200) - - // val filpq = pq.filter(_.indexOf('0') != -1) - // assertPriorityDestructive(filpq) - // } - - // def testIntensiveEnqueueDequeue { - // val pq = new PriorityQueue[Int] - - // testIntensive(1000, pq) - // pq.clear - // testIntensive(200, pq) - // } - - // def testIntensive(sz: Int, pq: PriorityQueue[Int]) { - // val lst = new collection.mutable.ArrayBuffer[Int] ++ (0 until sz) - // val rand = new util.Random(7) - // while (lst.nonEmpty) { - // val idx = rand.nextInt(lst.size) - // pq.enqueue(lst(idx)) - // lst.remove(idx) - // if (rand.nextDouble < 0.25 && pq.nonEmpty) pq.dequeue - // assertPriority(pq) - // } - // } - - // def testDrops { - // val pq = new PriorityQueue[Int] - // pq ++= (0 until 100) - // val droppq = pq.drop(50) - // assertPriority(droppq) - - // pq.clear - // pq ++= droppq - // assertPriorityDestructive(droppq) - // assertPriority(pq) - // assertPriorityDestructive(pq) - // } - - // // your sequence days have ended, foul priority queue - // // def testUpdates { - // // val pq = new PriorityQueue[Int] - // // pq ++= (0 until 36) - // // assertPriority(pq) - - // // pq(0) = 100 - // // assert(pq(0) == 100) - // // assert(pq.dequeue == 100) - // // assertPriority(pq) - - // // pq.clear - - // // pq ++= (1 to 100) - // // pq(5) = 200 - // // assert(pq(0) == 200) - // // assert(pq(1) == 100) - // // assert(pq(2) == 99) - // // assert(pq(3) == 98) - // // assert(pq(4) == 97) - // // assert(pq(5) == 96) - // // assert(pq(6) == 94) - // // assert(pq(7) == 93) - // // assert(pq(98) == 2) - // // assert(pq(99) == 1) - // // assertPriority(pq) - - // // pq(99) = 450 - // // assert(pq(0) == 450) - // // assert(pq(1) == 200) - // // assert(pq(99) == 2) - // // assertPriority(pq) - - // // pq(1) = 0 - // // assert(pq(1) == 100) - // // assert(pq(99) == 0) - // // assertPriority(pq) - // // assertPriorityDestructive(pq) - // // } - - // def testEquality { - // val pq1 = new PriorityQueue[Int] - // val pq2 = new PriorityQueue[Int] - - // pq1 ++= (0 until 50) - // var i = 49 - // while (i >= 0) { - // pq2 += i - // i -= 1 - // } - // assert(pq1 == pq2) - // assertPriority(pq2) - - // pq1 += 100 - // assert(pq1 != pq2) - // pq2 += 100 - // assert(pq1 == pq2) - // pq2 += 200 - // assert(pq1 != pq2) - // pq1 += 200 - // assert(pq1 == pq2) - // assertPriorityDestructive(pq1) - // assertPriorityDestructive(pq2) - // } - - // def testMisc { - // val pq = new PriorityQueue[Int] - // pq ++= (0 until 100) - // assert(pq.size == 100) - - // val (p1, p2) = pq.partition(_ < 50) - // assertPriorityDestructive(p1) - // assertPriorityDestructive(p2) - - // val spq = pq.slice(25, 75) - // assertPriorityDestructive(spq) - - // pq.clear - // pq ++= (0 until 10) - // pq += 5 - // assert(pq.size == 11) - - // val ind = pq.lastIndexWhere(_ == 5) - // assert(ind == 5) - // assertPriorityDestructive(pq) - - // pq.clear - // pq ++= (0 until 10) - // assert(pq.lastIndexWhere(_ == 9) == 0) - // assert(pq.lastIndexOf(8) == 1) - // assert(pq.lastIndexOf(7) == 2) - - // pq += 5 - // pq += 9 - // assert(pq.lastIndexOf(9) == 1) - // assert(pq.lastIndexWhere(_ % 2 == 1) == 10) - // assert(pq.lastIndexOf(5) == 6) - - // val lst = pq.reverseIterator.toList - // for (i <- 0 until 5) assert(lst(i) == i) - // assert(lst(5) == 5) - // assert(lst(6) == 5) - // assert(lst(7) == 6) - // assert(lst(8) == 7) - // assert(lst(9) == 8) - // assert(lst(10) == 9) - // assert(lst(11) == 9) - - // pq.clear - // assert(pq.reverseIterator.toList.isEmpty) - - // pq ++= (50 to 75) - // assert(pq.lastIndexOf(70) == 5) - - // pq += 55 - // pq += 70 - // assert(pq.lastIndexOf(70) == 6) - // assert(pq.lastIndexOf(55) == 22) - // assert(pq.lastIndexOf(55, 21) == 21) - // assert(pq.lastIndexWhere(_ > 54) == 22) - // assert(pq.lastIndexWhere(_ > 54, 21) == 21) - // assert(pq.lastIndexWhere(_ > 69, 5) == 5) - // } - - // def testReverse { - // val pq = new PriorityQueue[(Int, Int)] - // pq ++= (for (i <- 0 until 10) yield (i, i * i % 10)) - - // assert(pq.reverse.size == pq.reverseIterator.toList.size) - // assert((pq.reverse zip pq.reverseIterator.toList).forall(p => p._1 == p._2)) - // assert(pq.reverse.sameElements(pq.reverseIterator.toSeq)) - // assert(pq.reverse(0)._1 == pq(9)._1) - // assert(pq.reverse(1)._1 == pq(8)._1) - // assert(pq.reverse(4)._1 == pq(5)._1) - // assert(pq.reverse(9)._1 == pq(0)._1) - - // pq += ((7, 7)) - // pq += ((7, 9)) - // pq += ((7, 8)) - // assert(pq.reverse.reverse == pq) - // assert(pq.reverse.lastIndexWhere(_._2 == 6) == 6) - // assertPriorityDestructive(pq.reverse.reverse) - - // val iq = new PriorityQueue[Int] - // iq ++= (0 until 50) - // assert(iq.reverse == iq.reverseIterator.toSeq) - // assert(iq.reverse.reverse == iq) - - // iq += 25 - // iq += 40 - // iq += 10 - // assert(iq.reverse == iq.reverseIterator.toList) - // assert(iq.reverse.reverse == iq) - // assert(iq.reverse.lastIndexWhere(_ == 10) == 11) - // assertPriorityDestructive(iq.reverse.reverse) - // } - - // def testToList { - // val pq = new PriorityQueue[Int] - - // pq += 1 - // pq += 4 - // pq += 0 - // pq += 5 - // pq += 3 - // pq += 2 - // assert(pq.toList == pq) - // assert(pq == List(5, 4, 3, 2, 1, 0)) - // assert(pq.reverse == List(0, 1, 2, 3, 4, 5)) - - // pq.clear - // for (i <- -50 until 50) pq += i - // assert(pq.toList == pq) - // assert(pq.toList == (-50 until 50).reverse) - // } - - // def testForeach { - // val pq = new PriorityQueue[Char] - - // pq += 't' - // pq += 'o' - // pq += 'b' - // pq += 'y' - // val sbf = new StringBuilder - // val sbi = new StringBuilder - // pq.foreach(sbf += _) - // pq.iterator.foreach(sbi += _) - // assert(sbf.toString == sbi.toString) - // assert(sbf.toString == "ytob") - // } - -} - - - - - - - - - - - - - - - - - - diff --git a/test/files/run/t5938.scala b/test/files/run/t5938.scala new file mode 100644 index 0000000000..59a95ac37f --- /dev/null +++ b/test/files/run/t5938.scala @@ -0,0 +1,35 @@ +import scala.tools.partest.DirectTest + +object Test extends DirectTest { + + override def extraSettings: String = + s"-usejavacp -d ${testOutput.path}" + + override def code = """ +object O extends C { + def main(args: Array[String]): Unit = { + } + // Static forwarder for foo and setter_foo_= added more once in a multi-run compile. +} + """.trim + + override def show(): Unit = { + val global = newCompiler() + Console.withErr(System.out) { + compileString(global)(code) + compileString(global)(code) + loadClass // was "duplicate name and signature in class X" + } + } + + def loadClass: Class[_] = { + val cl = new java.net.URLClassLoader(Array(testOutput.toFile.toURL)); + cl.loadClass("O") + } +} + +trait T { + val foo: String = "" +} +class C extends T + diff --git a/test/files/run/t6440.check b/test/files/run/t6440.check index 2358f08fcc..4d8618182b 100644 --- a/test/files/run/t6440.check +++ b/test/files/run/t6440.check @@ -1,5 +1,4 @@ -pos: source-newSource1.scala,line-9,offset=109 missing or invalid dependency detected while loading class file 'U.class'. -Could not access term pack1 in package <root>, -because it (or its dependencies) are missing. Check your build definition for -missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.) -A full rebuild may help if 'U.class' was compiled against an incompatible version of <root>. ERROR +pos: source-newSource1.scala,line-9,offset=109 reference to U is ambiguous; +it is imported twice in the same scope by +import pack2._ +and import X._ ERROR diff --git a/test/files/run/t6440.scala b/test/files/run/t6440.scala index 5a3a4150d9..94eda3642e 100644 --- a/test/files/run/t6440.scala +++ b/test/files/run/t6440.scala @@ -41,7 +41,7 @@ object Test extends StoreReporterDirectTest { assert(tClass.delete()) assert(pack1.delete()) - // bad symbolic reference error expected (but no stack trace!) + // should report ambiguous import, despite the fact that a parent of pack2.U is absent compileCode(app) println(filteredInfos.mkString("\n")) } diff --git a/test/files/run/t8253.check b/test/files/run/t8253.check new file mode 100644 index 0000000000..0b4cb2d1f7 --- /dev/null +++ b/test/files/run/t8253.check @@ -0,0 +1,40 @@ + +<sample xmlns='ns1'/> +{ + var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope; + $tmpscope = new _root_.scala.xml.NamespaceBinding(null, "ns1", $tmpscope); + { + val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope; + new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true) + } +} + +<sample xmlns={identity(ns1)}/> +{ + var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope; + $tmpscope = new _root_.scala.xml.NamespaceBinding(null, ns1, $tmpscope); + { + val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope; + new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true) + } +} + +<sample xmlns:foo='ns1'/> +{ + var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope; + $tmpscope = new _root_.scala.xml.NamespaceBinding("foo", "ns1", $tmpscope); + { + val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope; + new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true) + } +} + +<sample xmlns:foo={identity(ns1)}/> +{ + var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope; + $tmpscope = new _root_.scala.xml.NamespaceBinding("foo", ns1, $tmpscope); + { + val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope; + new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true) + } +} diff --git a/test/files/run/t8253.scala b/test/files/run/t8253.scala new file mode 100644 index 0000000000..c4800b4491 --- /dev/null +++ b/test/files/run/t8253.scala @@ -0,0 +1,14 @@ +object Test extends App { + import reflect.runtime.universe._ // not using the XML library in compiler tests + + def show(code: String, t: Tree) = println(s"\n$code\n$t") + + val ns1 = "ns1" + show("<sample xmlns='ns1'/>", q"<sample xmlns='ns1'/>") + show("<sample xmlns={identity(ns1)}/>", q"<sample xmlns={ns1}/>") + show("<sample xmlns:foo='ns1'/>", q"<sample xmlns:foo='ns1'/>") + show("<sample xmlns:foo={identity(ns1)}/>", q"<sample xmlns:foo={ns1}/>") + + // `identity(foo)` used to match the overly permissive match in SymbolXMLBuilder + // which was intented to more specifically match `_root_.scala.xml.Text(...)` +} diff --git a/test/files/run/t8502.scala b/test/files/run/t8502.scala new file mode 100644 index 0000000000..903e573711 --- /dev/null +++ b/test/files/run/t8502.scala @@ -0,0 +1,41 @@ +import scala.tools.partest._ +import java.io.File + +object Test extends StoreReporterDirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + + def show(): Unit = { + compileCode(""" + object U { + def foo(log: vanishing.Vanishing) = () + } + + package vanishing { + class Vanishing + } + """) + assert(filteredInfos.isEmpty, filteredInfos) + deletePackage("vanishing") + compileCode(""" + class Test { + U + } + """) + assert(storeReporter.infos.isEmpty, storeReporter.infos.mkString("\n")) // Included a MissingRequirementError before. + } + + def deletePackage(name: String) { + val directory = new File(testOutput.path, name) + for (f <- directory.listFiles()) { + assert(f.getName.endsWith(".class")) + assert(f.delete()) + } + assert(directory.listFiles().isEmpty) + assert(directory.delete()) + } +} diff --git a/test/files/run/t9003.flags b/test/files/run/t9003.flags new file mode 100644 index 0000000000..49d036a887 --- /dev/null +++ b/test/files/run/t9003.flags @@ -0,0 +1 @@ +-optimize diff --git a/test/files/run/t9003.scala b/test/files/run/t9003.scala new file mode 100644 index 0000000000..4f24712201 --- /dev/null +++ b/test/files/run/t9003.scala @@ -0,0 +1,71 @@ +object Single { + var i = 0 + def isEmpty = false + def get = i + def unapply(a: Single.type) = this +} + +object Product { + var i = 0 + def _1: Int = i + def _2: String = ??? + def productArity = 2 + def unapply(a: Product.type) = this + def isEmpty = false + def get: this.type = this +} + +object Sequence { + var i = 0 + def apply(n: Int): Int = i + def length = 2 + def unapplySeq(a: Sequence.type) = this + def isEmpty = false + def get = this +} + +object Test { + def main(args: Array[String]): Unit = { + def assertZero(i: Int) = assert(i == 0) + + Single match { + case Single(i) => + Single.i = 1 + assertZero(i) // fails under -optimize + } + + Product match { + case Product(i, _) => + Product.i = 1 + assertZero(i) // fails under -optimize + } + + Sequence match { + case Sequence(i, _ @ _*) => + Sequence.i = 1 + assertZero(i) // okay + } + + Sequence.i = 0 + Sequence match { + case Sequence(_, i) => + Sequence.i = 1 + assertZero(i) // okay + } + + val buffer = collection.mutable.Buffer(0, 0) + buffer match { + case Seq(_, i) => + buffer(1) = 1 + assertZero(i) // failed + } + + case class CaseSequence(as: Int*) + val buffer1 = collection.mutable.Buffer(0, 0) + CaseSequence(buffer1: _*) match { + case CaseSequence(_, i) => + buffer1(1) = 1 + assertZero(i) // failed + } + } +} diff --git a/test/files/run/t9027.check b/test/files/run/t9027.check new file mode 100644 index 0000000000..3429254286 --- /dev/null +++ b/test/files/run/t9027.check @@ -0,0 +1,19 @@ +{ + { + val $buf = new _root_.scala.xml.NodeBuffer(); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, true)); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true)); + $buf + }; + println("hello, world.") +} +{ + { + val $buf = new _root_.scala.xml.NodeBuffer(); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, true)); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true)); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "c", _root_.scala.xml.Null, $scope, true)); + $buf + }; + println("hello, world.") +} diff --git a/test/files/run/t9027.scala b/test/files/run/t9027.scala new file mode 100644 index 0000000000..26238147da --- /dev/null +++ b/test/files/run/t9027.scala @@ -0,0 +1,15 @@ + +// used to be parsed as .println +object Test extends App { + import reflect.runtime._, universe._ + + val trees = List( + q"""<a/><b/> + println("hello, world.")""", + q"""<a/> + <b/> + <c/> + println("hello, world.")""" + ) + trees foreach println +} |