diff options
Diffstat (limited to 'test/files/run')
861 files changed, 8044 insertions, 1921 deletions
diff --git a/test/files/run/Course-2002-01.check b/test/files/run/Course-2002-01.check index 17b30bf3c2..16b491d6e2 100644 --- a/test/files/run/Course-2002-01.check +++ b/test/files/run/Course-2002-01.check @@ -1,3 +1,6 @@ +Course-2002-01.scala:41: warning: method loop in object M0 does nothing other than call itself recursively + def loop: Int = loop; + ^ 232 667 11 diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala index 7848ae3e8e..055ff74d81 100644 --- a/test/files/run/Course-2002-07.scala +++ b/test/files/run/Course-2002-07.scala @@ -16,13 +16,13 @@ object M0 { def isNumber: Boolean = true; def isSum: Boolean = false; def numValue: Int = n; - def leftOp: Expr = error("Number.leftOp"); - def rightOp: Expr = error("Number.rightOp"); + def leftOp: Expr = sys.error("Number.leftOp"); + def rightOp: Expr = sys.error("Number.rightOp"); } class Sum(e1: Expr, e2: Expr) extends Expr { def isNumber: Boolean = false; def isSum: Boolean = true; - def numValue: Int = error("Sum.numValue"); + def numValue: Int = sys.error("Sum.numValue"); def leftOp: Expr = e1; def rightOp: Expr = e2; } @@ -30,7 +30,7 @@ object M0 { class Prod(e1: Expr, e2: Expr) extends Expr { def isNumber: Boolean = false; def isSum: Boolean = false; - def numValue: Int = error("Prod.numValue"); + def numValue: Int = sys.error("Prod.numValue"); def leftOp: Expr = e1; def rightOp: Expr = e2; } @@ -38,15 +38,15 @@ object M0 { class Var(x: String) extends Expr { def isNumber: Boolean = false; def isSum: Boolean = false; - def numValue: Int = error("Var.numValue"); - def leftOp: Expr = error("Var.leftOp"); - def rightOp: Expr = error("Var.rightOp"); + def numValue: Int = sys.error("Var.numValue"); + def leftOp: Expr = sys.error("Var.leftOp"); + def rightOp: Expr = sys.error("Var.rightOp"); } def eval(e: Expr): Int = { if (e.isNumber) e.numValue else if (e.isSum) eval(e.leftOp) + eval(e.rightOp) - else error("unknown expression") + else sys.error("unknown expression") } def test = { @@ -375,7 +375,7 @@ object M9 { object MA { def lookup[k,v](xs: List[Pair[k,v]], k: k): v = xs match { - case List() => error("no value for " + k) + case List() => sys.error("no value for " + k) case Pair(k1,v1) :: xs1 => if (k1 == k) v1 else lookup(xs1, k) } @@ -410,7 +410,7 @@ object MA { def eval(e: Expr): Int = e match { case Number(n) => n - case Var(_) => error("cannot evaluate variable") + case Var(_) => sys.error("cannot evaluate variable") case Sum(e1, e2) => eval(e1) + eval(e2) case Prod(e1, e2) => eval(e1) * eval(e2) } @@ -453,7 +453,7 @@ object Utils { if (y == 1) x else if (y % 2 == 0) power0(x*x,y/2) else x*power0(x, y-1); def power(x: Int, y: Int): Int = (x,y) match { - case Pair(0,0) => error("power(0,0)") + case Pair(0,0) => sys.error("power(0,0)") case Pair(0,_) => 0 case Pair(1,_) => 1 case Pair(_,0) => 1 @@ -463,7 +463,7 @@ object Utils { } def lookup(entries: List[(String,Int)], key: String): Int = entries match { - case List() => error("no value for " + key) + case List() => sys.error("no value for " + key) case Pair(k,v) :: _ if (k == key) => v case _ :: rest => lookup(rest, key) } diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala index 85a83e0146..38b8363661 100644 --- a/test/files/run/Course-2002-08.scala +++ b/test/files/run/Course-2002-08.scala @@ -33,7 +33,7 @@ object M1 { if (0 < amount && amount <= balance) { balance = balance - amount; balance - } else error("insufficient funds"); + } else sys.error("insufficient funds"); } def test0 = { @@ -520,7 +520,7 @@ abstract class CircuitSimulator() extends BasicCircuitSimulator() { val w1 = new Wire(); val w2 = new Wire(); val w3 = new Wire(); - + andGate(in, ctrl(1), w3); andGate(in, ctrl(1), w2); andGate(in, ctrlN(1), w1); diff --git a/test/files/run/Course-2002-09.scala b/test/files/run/Course-2002-09.scala index 384a91efd8..87f91111d8 100644 --- a/test/files/run/Course-2002-09.scala +++ b/test/files/run/Course-2002-09.scala @@ -8,8 +8,8 @@ trait Constraint { } object NoConstraint extends Constraint { - def newValue: Unit = error("NoConstraint.newValue"); - def dropValue: Unit = error("NoConstraint.dropValue"); + def newValue: Unit = sys.error("NoConstraint.newValue"); + def dropValue: Unit = sys.error("NoConstraint.dropValue"); } class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint { @@ -47,7 +47,7 @@ class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity) class Squarer(square: Quantity, root: Quantity) extends Constraint { def newValue: Unit = Pair(square.getValue, root.getValue) match { - case Pair(Some(x), _ )if (x < 0) => error("Square of negative number") + case Pair(Some(x), _ )if (x < 0) => sys.error("Square of negative number") case Pair(Some(x), _ ) => root.setValue(Math.sqrt(x), this) case Pair(_ , Some(x)) => square.setValue(x*x, this) case _ => @@ -72,8 +72,8 @@ class Eq(a: Quantity, b: Quantity) extends Constraint { } class Constant(q: Quantity, v: Double) extends Constraint { - def newValue: Unit = error("Constant.newValue"); - def dropValue: Unit = error("Constant.dropValue"); + def newValue: Unit = sys.error("Constant.newValue"); + def dropValue: Unit = sys.error("Constant.dropValue"); q connect this; q.setValue(v, this); } @@ -100,7 +100,7 @@ class Quantity() { def setValue(v: Double, setter: Constraint) = value match { case Some(v1) => - if (v != v1) error("Error! contradiction: " + v + " and " + v1); + if (v != v1) sys.error("Error! contradiction: " + v + " and " + v1); case None => informant = setter; value = Some(v); for (c <- constraints; if !(c == informant)) { diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala index c266af8c32..4bd3614fb0 100644 --- a/test/files/run/Course-2002-13.scala +++ b/test/files/run/Course-2002-13.scala @@ -42,7 +42,7 @@ object Terms { } case class Binding(name: String, term: Term) { - term match { case Var(n) if (name == n) => error("bad binding") case _ => () } + term match { case Var(n) if (name == n) => sys.error("bad binding") case _ => () } override def toString() = name + " = " + term; } @@ -168,7 +168,7 @@ class Parser(s: String) { var token: String = it.next; - def syntaxError(msg: String): Unit = error(msg + ", but " + token + " found"); + def syntaxError(msg: String): Unit = sys.error(msg + ", but " + token + " found"); def rep[a](p: => a): List[a] = { val t = p; diff --git a/test/files/run/Meter.check b/test/files/run/Meter.check index b7e2eac125..c79c51a294 100644 --- a/test/files/run/Meter.check +++ b/test/files/run/Meter.check @@ -1,3 +1,6 @@ +Meter.scala:72: warning: a.Meter and Int are unrelated: they will never compare equal + println("x == 1: "+(x == 1)) + ^ 2.0 4.0m false diff --git a/test/files/run/MeterCaseClass.check b/test/files/run/MeterCaseClass.check index 2528753657..2782704f9f 100644 --- a/test/files/run/MeterCaseClass.check +++ b/test/files/run/MeterCaseClass.check @@ -1,3 +1,6 @@ +MeterCaseClass.scala:69: warning: comparing values of types a.Meter and Int using `==' will always yield false + println("x == 1: "+(x == 1)) + ^ 2.0 Meter(4.0) false diff --git a/test/files/run/Predef.readLine.scala b/test/files/run/Predef.readLine.scala index 9f07936638..54809f8071 100644 --- a/test/files/run/Predef.readLine.scala +++ b/test/files/run/Predef.readLine.scala @@ -1,4 +1,5 @@ import java.io.StringReader +import scala.io.ReadStdin.readLine object Test extends App { Console.withIn(new StringReader("")) { @@ -7,4 +8,4 @@ object Test extends App { readLine("%s prompt\n", "fancy") readLine("%s %s prompt\n", "immensely", "fancy") } -}
\ No newline at end of file +} diff --git a/test/files/run/SymbolsTest.scala b/test/files/run/SymbolsTest.scala index 53caa5e62f..d5948ea168 100644 --- a/test/files/run/SymbolsTest.scala +++ b/test/files/run/SymbolsTest.scala @@ -1,6 +1,5 @@ - - +import scala.language.reflectiveCalls class Slazz { val s1 = 'myFirstSymbol diff --git a/test/files/run/abstypetags_serialize.scala b/test/files/run/abstypetags_serialize.scala index 93fb5dcd06..6ec97105fe 100644 --- a/test/files/run/abstypetags_serialize.scala +++ b/test/files/run/abstypetags_serialize.scala @@ -1,3 +1,4 @@ +import scala.language.higherKinds import java.io._ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{universe => ru} @@ -30,4 +31,4 @@ object Test extends App { } qwe -}
\ No newline at end of file +} diff --git a/test/files/run/all-overridden.check b/test/files/run/all-overridden.check new file mode 100644 index 0000000000..1b620b1176 --- /dev/null +++ b/test/files/run/all-overridden.check @@ -0,0 +1 @@ +method g diff --git a/test/files/run/all-overridden.scala b/test/files/run/all-overridden.scala new file mode 100644 index 0000000000..1b798ef748 --- /dev/null +++ b/test/files/run/all-overridden.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe._ + +object Test { + trait Foo { def f: Int = 5 ; def g: Int } + trait Bar extends Foo { def f: Int ; def g: Int = 5 } + + def main(args: Array[String]): Unit = { + // We should see g, but not f or $init$. + typeOf[Bar].declarations.toList.flatMap(_.allOverriddenSymbols) foreach println + } +} diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check index 7d8d181306..e3ab554d4c 100644 --- a/test/files/run/analyzerPlugins.check +++ b/test/files/run/analyzerPlugins.check @@ -7,7 +7,7 @@ annotationsConform(Int @testAnn, Int) [2] annotationsConform(Int(1) @testAnn, Int) [1] annotationsConform(Int(1), Int @testAnn) [1] annotationsConform(Nothing, Int @testAnn) [2] -annotationsConform(String @testAnn, String) [1] +annotationsConform(String @testAnn, String) [2] canAdaptAnnotations(Trees$Ident, String) [1] canAdaptAnnotations(Trees$Select, ?) [1] canAdaptAnnotations(Trees$Select, Boolean @testAnn) [1] @@ -19,27 +19,27 @@ canAdaptAnnotations(Trees$Typed, Any) [1] canAdaptAnnotations(Trees$Typed, Int) [1] lub(List(Int @testAnn, Int)) [1] pluginsPt(?, Trees$Annotated) [7] -pluginsPt(?, Trees$Apply) [8] +pluginsPt(?, Trees$Apply) [9] pluginsPt(?, Trees$ApplyImplicitView) [2] pluginsPt(?, Trees$Assign) [7] -pluginsPt(?, Trees$Block) [7] +pluginsPt(?, Trees$Block) [4] pluginsPt(?, Trees$ClassDef) [2] pluginsPt(?, Trees$DefDef) [14] -pluginsPt(?, Trees$Ident) [49] +pluginsPt(?, Trees$Ident) [50] pluginsPt(?, Trees$If) [2] -pluginsPt(?, Trees$Literal) [20] +pluginsPt(?, Trees$Literal) [16] pluginsPt(?, Trees$New) [5] pluginsPt(?, Trees$PackageDef) [1] pluginsPt(?, Trees$Return) [1] -pluginsPt(?, Trees$Select) [51] +pluginsPt(?, Trees$Select) [48] pluginsPt(?, Trees$Super) [2] pluginsPt(?, Trees$This) [20] -pluginsPt(?, Trees$TypeApply) [3] +pluginsPt(?, Trees$TypeApply) [4] pluginsPt(?, Trees$TypeBoundsTree) [2] pluginsPt(?, Trees$TypeDef) [1] -pluginsPt(?, Trees$TypeTree) [37] +pluginsPt(?, Trees$TypeTree) [39] pluginsPt(?, Trees$Typed) [1] -pluginsPt(?, Trees$ValDef) [23] +pluginsPt(?, Trees$ValDef) [21] pluginsPt(Any, Trees$Literal) [2] pluginsPt(Any, Trees$Typed) [1] pluginsPt(Array[Any], Trees$ArrayValue) [1] @@ -53,7 +53,7 @@ pluginsPt(Int @testAnn, Trees$Literal) [1] pluginsPt(Int, Trees$Apply) [1] pluginsPt(Int, Trees$Ident) [2] pluginsPt(Int, Trees$If) [1] -pluginsPt(Int, Trees$Literal) [6] +pluginsPt(Int, Trees$Literal) [5] pluginsPt(Int, Trees$Select) [3] pluginsPt(List, Trees$Apply) [1] pluginsPt(List[Any], Trees$Select) [1] @@ -65,7 +65,7 @@ pluginsPt(String, Trees$Literal) [1] pluginsPt(String, Trees$Select) [1] pluginsPt(String, Trees$Typed) [1] pluginsPt(Unit, Trees$Assign) [1] -pluginsPt(scala.annotation.Annotation, Trees$Apply) [5] +pluginsPt(testAnn, Trees$Apply) [5] pluginsTypeSig(<none>, Trees$Template) [2] pluginsTypeSig(class A, Trees$ClassDef) [1] pluginsTypeSig(class testAnn, Trees$ClassDef) [1] @@ -82,8 +82,8 @@ pluginsTypeSig(value lub1, Trees$ValDef) [2] pluginsTypeSig(value lub2, Trees$ValDef) [2] pluginsTypeSig(value param, Trees$ValDef) [2] pluginsTypeSig(value str, Trees$ValDef) [1] -pluginsTypeSig(value x, Trees$ValDef) [5] -pluginsTypeSig(value y, Trees$ValDef) [5] +pluginsTypeSig(value x, Trees$ValDef) [4] +pluginsTypeSig(value y, Trees$ValDef) [4] pluginsTypeSig(variable count, Trees$ValDef) [3] pluginsTypeSigAccessor(value annotField) [1] pluginsTypeSigAccessor(value inferField) [1] @@ -98,6 +98,7 @@ pluginsTyped(()String, Trees$Ident) [1] pluginsTyped(()String, Trees$TypeApply) [1] pluginsTyped(()scala.annotation.Annotation, Trees$Select) [1] pluginsTyped(()testAnn, Trees$Select) [10] +pluginsTyped(()type, Trees$TypeApply) [1] pluginsTyped((str: String)A <and> (param: Double)A, Trees$Select) [1] pluginsTyped((x$1: Any)Boolean <and> (x: Double)Boolean <and> (x: Float)Boolean <and> (x: Long)Boolean <and> (x: Int)Boolean <and> (x: Char)Boolean <and> (x: Short)Boolean <and> (x: Byte)Boolean, Trees$Select) [1] pluginsTyped((x$1: Int)Unit, Trees$Select) [1] @@ -110,8 +111,7 @@ pluginsTyped(<notype>, Trees$ClassDef) [2] pluginsTyped(<notype>, Trees$DefDef) [14] pluginsTyped(<notype>, Trees$PackageDef) [1] pluginsTyped(<notype>, Trees$TypeDef) [1] -pluginsTyped(<notype>, Trees$ValDef) [23] -pluginsTyped(<root>, Trees$Ident) [1] +pluginsTyped(<notype>, Trees$ValDef) [21] pluginsTyped(=> Boolean @testAnn, Trees$Select) [1] pluginsTyped(=> Double, Trees$Select) [4] pluginsTyped(=> Int, Trees$Select) [5] @@ -124,7 +124,7 @@ pluginsTyped(A, Trees$TypeTree) [4] pluginsTyped(A.super.type, Trees$Super) [1] pluginsTyped(A.this.type, Trees$This) [11] pluginsTyped(Any, Trees$TypeTree) [1] -pluginsTyped(AnyRef, Trees$Select) [2] +pluginsTyped(AnyRef, Trees$Select) [4] pluginsTyped(Array[Any], Trees$ArrayValue) [1] pluginsTyped(Boolean @testAnn, Trees$Select) [1] pluginsTyped(Boolean @testAnn, Trees$TypeTree) [4] @@ -137,12 +137,12 @@ pluginsTyped(Int @testAnn, Trees$TypeTree) [2] pluginsTyped(Int @testAnn, Trees$Typed) [2] pluginsTyped(Int(0), Trees$Literal) [3] pluginsTyped(Int(1) @testAnn, Trees$Typed) [1] -pluginsTyped(Int(1), Trees$Literal) [9] +pluginsTyped(Int(1), Trees$Literal) [8] pluginsTyped(Int(2), Trees$Literal) [1] pluginsTyped(Int, Trees$Apply) [1] pluginsTyped(Int, Trees$Ident) [2] pluginsTyped(Int, Trees$If) [2] -pluginsTyped(Int, Trees$Select) [17] +pluginsTyped(Int, Trees$Select) [15] pluginsTyped(Int, Trees$TypeTree) [13] pluginsTyped(List, Trees$Apply) [1] pluginsTyped(List, Trees$Select) [1] @@ -150,7 +150,6 @@ pluginsTyped(List[Any], Trees$Apply) [1] pluginsTyped(List[Any], Trees$Select) [1] pluginsTyped(List[Any], Trees$TypeTree) [3] pluginsTyped(Nothing, Trees$Return) [1] -pluginsTyped(Nothing, Trees$Select) [2] pluginsTyped(Object, Trees$Apply) [1] pluginsTyped(String @testAnn, Trees$Ident) [1] pluginsTyped(String @testAnn, Trees$Select) [1] @@ -160,31 +159,30 @@ pluginsTyped(String("huhu"), Trees$Literal) [1] pluginsTyped(String("str") @testAnn, Trees$Typed) [1] pluginsTyped(String("str"), Trees$Literal) [1] pluginsTyped(String("str"), Trees$Typed) [1] -pluginsTyped(String("two"), Trees$Literal) [3] +pluginsTyped(String("two"), Trees$Literal) [2] pluginsTyped(String, Trees$Apply) [2] pluginsTyped(String, Trees$Block) [2] pluginsTyped(String, Trees$Ident) [1] pluginsTyped(String, Trees$Select) [9] -pluginsTyped(String, Trees$TypeTree) [8] +pluginsTyped(String, Trees$TypeTree) [7] pluginsTyped(Unit, Trees$Apply) [2] pluginsTyped(Unit, Trees$Assign) [8] -pluginsTyped(Unit, Trees$Block) [7] +pluginsTyped(Unit, Trees$Block) [4] pluginsTyped(Unit, Trees$If) [1] -pluginsTyped(Unit, Trees$Literal) [8] +pluginsTyped(Unit, Trees$Literal) [5] pluginsTyped(Unit, Trees$TypeTree) [1] pluginsTyped([A](xs: A*)List[A], Trees$Select) [1] pluginsTyped([T <: Int]=> Int, Trees$Select) [1] -pluginsTyped([T0 >: ? <: ?]()T0, Trees$Select) [1] +pluginsTyped([T0]()T0, Trees$Select) [2] pluginsTyped([T](xs: Array[T])scala.collection.mutable.WrappedArray[T], Trees$Select) [1] -pluginsTyped(annotation.type, Trees$Select) [2] +pluginsTyped(annotation.type, Trees$Select) [4] pluginsTyped(math.type, Trees$Select) [9] pluginsTyped(scala.annotation.Annotation, Trees$Apply) [1] pluginsTyped(scala.annotation.TypeConstraint, Trees$Select) [4] +pluginsTyped(scala.annotation.TypeConstraint, Trees$TypeTree) [2] pluginsTyped(scala.collection.immutable.List.type, Trees$Select) [2] pluginsTyped(scala.collection.immutable.StringOps, Trees$ApplyImplicitView) [2] pluginsTyped(scala.collection.mutable.WrappedArray[Any], Trees$Apply) [1] -pluginsTyped(scala.type, Trees$Ident) [1] -pluginsTyped(scala.type, Trees$Select) [1] pluginsTyped(str.type, Trees$Ident) [3] pluginsTyped(testAnn, Trees$Apply) [5] pluginsTyped(testAnn, Trees$Ident) [5] @@ -192,5 +190,7 @@ pluginsTyped(testAnn, Trees$New) [5] pluginsTyped(testAnn, Trees$This) [1] pluginsTyped(testAnn, Trees$TypeTree) [2] pluginsTyped(testAnn.super.type, Trees$Super) [1] +pluginsTyped(type, Trees$Apply) [1] pluginsTyped(type, Trees$Select) [1] +pluginsTyped(type, Trees$TypeTree) [1] pluginsTypedReturn(return f, String) [1] diff --git a/test/files/run/analyzerPlugins.scala b/test/files/run/analyzerPlugins.scala index daef83fa30..b20a734fe6 100644 --- a/test/files/run/analyzerPlugins.scala +++ b/test/files/run/analyzerPlugins.scala @@ -77,12 +77,12 @@ object Test extends DirectTest { object analyzerPlugin extends AnalyzerPlugin { def treeClass(t: Tree) = t.getClass.toString.split('.').last - override def pluginsPt(pt: Type, typer: Typer, tree: Tree, mode: Int): Type = { + override def pluginsPt(pt: Type, typer: Typer, tree: Tree, mode: Mode): Type = { output += s"pluginsPt($pt, ${treeClass(tree)})" pt } - override def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Int, pt: Type): Type = { + override def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Mode, pt: Type): Type = { output += s"pluginsTyped($tpe, ${treeClass(tree)})" tpe } @@ -98,7 +98,7 @@ object Test extends DirectTest { } - override def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Int, pt: Type): Boolean = { + override def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Boolean = { output += s"canAdaptAnnotations(${treeClass(tree)}, $pt)" false } diff --git a/test/files/run/array-addition.check b/test/files/run/array-addition.check new file mode 100644 index 0000000000..7bfbd9c711 --- /dev/null +++ b/test/files/run/array-addition.check @@ -0,0 +1,4 @@ +Array(1, 2, 3, 4) +Array(1, 2, 3, 4) +Array(1) +Array(1) diff --git a/test/files/run/array-addition.scala b/test/files/run/array-addition.scala new file mode 100644 index 0000000000..8def48e85c --- /dev/null +++ b/test/files/run/array-addition.scala @@ -0,0 +1,11 @@ +object Test { + def prettyPrintArray(x: Array[_]) = println("Array(" + x.mkString(", ") + ")") + + def main(args: Array[String]): Unit = { + prettyPrintArray(Array(1,2,3) :+ 4) + prettyPrintArray(1 +: Array(2,3,4)) + prettyPrintArray(Array() :+ 1) + prettyPrintArray(1 +: Array()) + } +} + diff --git a/test/files/run/array-charSeq.scala b/test/files/run/array-charSeq.scala index f7d0586f03..53796bb9d5 100644 --- a/test/files/run/array-charSeq.scala +++ b/test/files/run/array-charSeq.scala @@ -6,6 +6,7 @@ object Test { def check(chars: CharSequence) { println("\n[check '" + chars + "'] len = " + chars.length) chars match { + case x: Predef.ArrayCharSequence => assert(x.__arrayOfChars eq arr, ((x.__arrayOfChars, arr))) case x: runtime.ArrayCharSequence => assert(x.xs eq arr, ((x.xs, arr))) case x => assert(false, x) } diff --git a/test/files/run/array-existential-bound.scala b/test/files/run/array-existential-bound.scala index bc442d39f7..b397c98111 100644 --- a/test/files/run/array-existential-bound.scala +++ b/test/files/run/array-existential-bound.scala @@ -10,8 +10,8 @@ object Test extends Fooz[Array[Int]] { def main(args: Array[String]): Unit = { println(f1.f0(Array[String]("a", "b"))) - println(f2.f0(1 to 1000 toArray)) + println(f2.f0((1 to 1000).toArray)) println(f3.f0((1 to 1000).toArray[Any])) - println(f4.f0('a' to 'z' toArray)) + println(f4.f0(('a' to 'z').toArray)) } } diff --git a/test/files/run/arrays.check b/test/files/run/arrays.check index b1f7fae1d1..c9a3a87268 100644 --- a/test/files/run/arrays.check +++ b/test/files/run/arrays.check @@ -1 +1,7 @@ +arrays.scala:248: warning: comparing values of types Unit and Unit using `==' will always yield true + check(xs(0) == u0, xs(0), u0); + ^ +arrays.scala:249: warning: comparing values of types Unit and Unit using `==' will always yield true + check(xs(1) == u1, xs(1), u1); + ^ checks: 2302 diff --git a/test/files/run/arrays.scala b/test/files/run/arrays.scala index ecebc78a6f..c8bf80ea60 100644 --- a/test/files/run/arrays.scala +++ b/test/files/run/arrays.scala @@ -107,7 +107,7 @@ object Test { val s1 = if (test1) "ok" else "KO"; val s2 = actual.toString(); val s3 = expected.toString(); - error(s0 + " - " + s1 + ": " + s2 + " != " + s3); + sys.error(s0 + " - " + s1 + ": " + s2 + " != " + s3); } checks += 1 } diff --git a/test/files/run/bitsets.check b/test/files/run/bitsets.check index 3f01d2a400..41c2ccdcb8 100644 --- a/test/files/run/bitsets.check +++ b/test/files/run/bitsets.check @@ -37,6 +37,11 @@ m2_r1 = true m2_r2 = true m2_r3 = true +b1:BitSet(5, 6, 7) +b2:BitSet(5) +b3:BitSet(5, 7) +b4:BitSet(7) +b0:BitSet(5, 6, 7) is0 = BitSet() is1 = BitSet() is2 = BitSet(2) diff --git a/test/files/run/bitsets.scala b/test/files/run/bitsets.scala index 27395683b4..5d49220749 100644 --- a/test/files/run/bitsets.scala +++ b/test/files/run/bitsets.scala @@ -4,6 +4,8 @@ //############################################################################ +import scala.language.postfixOps + object TestMutable { import scala.collection.mutable.BitSet @@ -37,6 +39,19 @@ object TestMutable { Console.println("mi1 = " + ms1.toImmutable) Console.println("mi2 = " + ms2.toImmutable) Console.println + + val N = 257 + val gen = 3 + val bs = BitSet((1 until N): _*) + (1 until N).foldLeft(gen) { + case (acc, i) => + assert(bs.size == N-i, s"Bad size for $bs, expected ${N-i} actual ${bs.size}") + assert(!bs.isEmpty, s"Unexpected isEmpty for $bs") + bs -= acc + acc*gen % N + } + assert(bs.size == 0, s"Expected size == 0 for $bs") + assert(bs.isEmpty, s"Expected isEmpty for $bs") } object TestMutable2 { @@ -81,12 +96,51 @@ object TestMutable2 { println } +object TestMutable3 { + import scala.collection.mutable.BitSet + + val b0 = BitSet(5, 6) + val b1 = BitSet(7) + val b2 = BitSet(1, 5) + val b3 = BitSet(6, 7) + val b4 = BitSet(6, 7) + + b1 |= b0 + println(s"b1:$b1") + b2 &= b0 + println(s"b2:$b2") + b3 ^= b0 + println(s"b3:$b3") + b4 &~= b0 + println(s"b4:$b4") + b0 ^= b0 |= b1 + println(s"b0:$b0") +} + +/*** +The memory requirements here are way beyond +what a test should exercise. + +object TestMutable4 { + import scala.collection.mutable.BitSet + + val bMax = BitSet(Int.MaxValue) + println(s"bMax:$bMax") + bMax.foreach(println) + + val bLarge = BitSet(2000000001) + println(s"bLarge:$bLarge") + + println(bMax == bLarge) +} +***/ + object TestImmutable { import scala.collection.immutable.BitSet val is0 = BitSet() - val is1 = BitSet.fromArray(Array()) - val is2 = BitSet.fromArray(Array(4)) + val is1 = BitSet.fromBitMask(Array()) + val is2 = BitSet.fromBitMask(Array(4)) val is3 = BitSet.empty Console.println("is0 = " + is0) @@ -155,6 +209,8 @@ object TestImmutable2 { object Test extends App { TestMutable TestMutable2 + TestMutable3 + // TestMutable4 TestImmutable TestImmutable2 } diff --git a/test/files/run/blame_eye_triple_eee-double.check b/test/files/run/blame_eye_triple_eee-double.check new file mode 100644 index 0000000000..5e46d91a8f --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-double.check @@ -0,0 +1,9 @@ +if (NaN == NaN) is good +if (x == x) is good +if (x == NaN) is good +if (NaN != NaN) is good +if (x != x) is good +if (NaN != x) is good +x matching was good +NaN matching was good +loop with NaN was goood diff --git a/test/files/run/blame_eye_triple_eee-double.flags b/test/files/run/blame_eye_triple_eee-double.flags new file mode 100644 index 0000000000..c9b68d70dc --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-double.flags @@ -0,0 +1 @@ +-optimise diff --git a/test/files/run/blame_eye_triple_eee-double.scala b/test/files/run/blame_eye_triple_eee-double.scala new file mode 100644 index 0000000000..1640aead40 --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-double.scala @@ -0,0 +1,61 @@ +object Test extends App { + import Double.NaN + + // NaN must not equal NaN no matter what optimizations are applied + // All the following will seem redundant, but to an optimizer + // they can appear different + + val x = NaN + + if (NaN == NaN) + println("if (NaN == NaN) is broken") + else + println("if (NaN == NaN) is good") + + if (x == x) + println("if (x == x) is broken") + else + println("if (x == x) is good") + + if (x == NaN) + println("if (x == NaN) is broken") + else + println("if (x == NaN) is good") + + if (NaN != NaN) + println("if (NaN != NaN) is good") + else + println("if (NaN != NaN) broken") + + if (x != x) + println("if (x != x) is good") + else + println("if (x != x) broken") + + if (NaN != x) + println("if (NaN != x) is good") + else + println("if (NaN != x) is broken") + + x match { + case 0.0d => println("x matched 0!") + case NaN => println("x matched NaN!") + case _ => println("x matching was good") + } + + NaN match { + case 0.0d => println("NaN matched 0!") + case NaN => println("NaN matched NaN!") + case _ => println("NaN matching was good") + } + + var z = 0.0d + var i = 0 + while (i < 10) { + if (i % 2 == 0) z = NaN + else z = NaN + i += 1 + } + if (z.isNaN && i == 10) println("loop with NaN was goood") + else println("loop with NaN was broken") +} diff --git a/test/files/run/blame_eye_triple_eee-float.check b/test/files/run/blame_eye_triple_eee-float.check new file mode 100644 index 0000000000..5e46d91a8f --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-float.check @@ -0,0 +1,9 @@ +if (NaN == NaN) is good +if (x == x) is good +if (x == NaN) is good +if (NaN != NaN) is good +if (x != x) is good +if (NaN != x) is good +x matching was good +NaN matching was good +loop with NaN was goood diff --git a/test/files/run/blame_eye_triple_eee-float.flags b/test/files/run/blame_eye_triple_eee-float.flags new file mode 100644 index 0000000000..c9b68d70dc --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-float.flags @@ -0,0 +1 @@ +-optimise diff --git a/test/files/run/blame_eye_triple_eee-float.scala b/test/files/run/blame_eye_triple_eee-float.scala new file mode 100644 index 0000000000..4deb9f3d60 --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-float.scala @@ -0,0 +1,61 @@ +object Test extends App { + import Float.NaN + + // NaN must not equal NaN no matter what optimizations are applied + // All the following will seem redundant, but to an optimizer + // they can appear different + + val x = NaN + + if (NaN == NaN) + println("if (NaN == NaN) is broken") + else + println("if (NaN == NaN) is good") + + if (x == x) + println("if (x == x) is broken") + else + println("if (x == x) is good") + + if (x == NaN) + println("if (x == NaN) is broken") + else + println("if (x == NaN) is good") + + if (NaN != NaN) + println("if (NaN != NaN) is good") + else + println("if (NaN != NaN) broken") + + if (x != x) + println("if (x != x) is good") + else + println("if (x != x) broken") + + if (NaN != x) + println("if (NaN != x) is good") + else + println("if (NaN != x) is broken") + + x match { + case 0.0f => println("x matched 0!") + case NaN => println("x matched NaN!") + case _ => println("x matching was good") + } + + NaN match { + case 0.0f => println("NaN matched 0!") + case NaN => println("NaN matched NaN!") + case _ => println("NaN matching was good") + } + + var z = 0.0f + var i = 0 + while (i < 10) { + if (i % 2 == 0) z = NaN + else z = NaN + i += 1 + } + if (z.isNaN && i == 10) println("loop with NaN was goood") + else println("loop with NaN was broken") +} diff --git a/test/files/run/bridges.scala b/test/files/run/bridges.scala index fda86eabc6..eb036bd781 100644 --- a/test/files/run/bridges.scala +++ b/test/files/run/bridges.scala @@ -3588,7 +3588,7 @@ object Test { errors = errors + 1; } } catch { - case exception => { + case exception: Throwable => { Console.print(name + " raised exception " + exception); Console.println; errors = errors + 1; diff --git a/test/files/run/bugs.scala b/test/files/run/bugs.scala index ca598603bb..9d2be42fb7 100644 --- a/test/files/run/bugs.scala +++ b/test/files/run/bugs.scala @@ -444,7 +444,7 @@ object Test { try { test; } catch { - case exception => + case exception: Throwable => Console.print("Exception in thread \"" + Thread.currentThread + "\" " + exception); Console.println; errors += 1 diff --git a/test/files/run/case-class-23.check b/test/files/run/case-class-23.check new file mode 100644 index 0000000000..888ed2c9eb --- /dev/null +++ b/test/files/run/case-class-23.check @@ -0,0 +1,2 @@ +23 +(1,23) diff --git a/test/files/run/case-class-23.scala b/test/files/run/case-class-23.scala new file mode 100644 index 0000000000..92b719574a --- /dev/null +++ b/test/files/run/case-class-23.scala @@ -0,0 +1,33 @@ +case class TwentyThree( + _1: Int, + _2: Int, + _3: Int, + _4: Int, + _5: Int, + _6: Int, + _7: Int, + _8: Int, + _9: Int, + _10: Int, + _11: Int, + _12: Int, + _13: Int, + _14: Int, + _15: Int, + _16: Int, + _17: Int, + _18: Int, + _19: Int, + _20: Int, + _21: Int, + _22: Int, + _23: Int +) + +object Test extends App { + val x = new TwentyThree(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23) + println(x._23) + assert(x.copy(_1 = 1) == x) + val TwentyThree(a, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, b) = x + println((a, b)) +} diff --git a/test/files/run/caseclasses.scala b/test/files/run/caseclasses.scala index 5aafea59e3..668c984f3d 100644 --- a/test/files/run/caseclasses.scala +++ b/test/files/run/caseclasses.scala @@ -1,6 +1,6 @@ case class Foo(x: Int)(y: Int) -case class Bar +case class Bar() abstract class Base abstract case class Abs(x: Int) extends Base diff --git a/test/files/run/classmanifests_new_alias.scala b/test/files/run/classmanifests_new_alias.scala index 12bd93bab6..777bd5dd6d 100644 --- a/test/files/run/classmanifests_new_alias.scala +++ b/test/files/run/classmanifests_new_alias.scala @@ -1,5 +1,7 @@ + +@deprecated("Suppress warnings", since="2.11") object Test extends App { type CM[T] = ClassManifest[T] println(implicitly[CM[Int]]) println(implicitly[CM[Int]] eq Manifest.Int) -}
\ No newline at end of file +} diff --git a/test/files/run/classmanifests_new_core.scala b/test/files/run/classmanifests_new_core.scala index 63dbfab25c..0a9c58e8e1 100644 --- a/test/files/run/classmanifests_new_core.scala +++ b/test/files/run/classmanifests_new_core.scala @@ -1,4 +1,5 @@ +@deprecated("Suppress warnings", since="2.11") object Test extends App { println(classManifest[Int]) println(classManifest[Int] eq Manifest.Int) -}
\ No newline at end of file +} diff --git a/test/files/run/collection-stacks.check b/test/files/run/collection-stacks.check new file mode 100644 index 0000000000..aa25cd1fa6 --- /dev/null +++ b/test/files/run/collection-stacks.check @@ -0,0 +1,14 @@ +3-2-1: true +3-2-1: true +apply +3: true +3: true +1: true +1: true +top +3: true +3: true +pop +2-1: true +3: true +2-1: true diff --git a/test/files/run/collection-stacks.scala b/test/files/run/collection-stacks.scala new file mode 100644 index 0000000000..be9fbbf1ae --- /dev/null +++ b/test/files/run/collection-stacks.scala @@ -0,0 +1,38 @@ +import scala.collection.{ immutable, mutable } + +object Test extends App { + def mutableStack[T](xs: T*): mutable.Stack[T] = { + val s = new mutable.Stack[T] + s.pushAll(xs) + s + } + + def immutableStack[T](xs: T*): immutable.Stack[T] = { + immutable.Stack.empty[T] pushAll xs + } + + def check[T](expected: T, got: T) { + println(got + ": " + (expected == got)) + } + + // check #957 + check("3-2-1", immutableStack(1, 2, 3).iterator.mkString("-")) + check("3-2-1", mutableStack(1, 2, 3).iterator.mkString("-")) + + println("apply") + check(3, immutableStack(1, 2, 3).apply(0)) + check(3, mutableStack(1, 2, 3).apply(0)) + check(1, immutableStack(1, 2, 3).apply(2)) + check(1, mutableStack(1, 2, 3).apply(2)) + + println("top") + check(3, immutableStack(1, 2, 3).top) + check(3, mutableStack(1, 2, 3).top) + + println("pop") + check("2-1", immutableStack(1, 2, 3).pop.mkString("-")) + check(3, mutableStack(1, 2, 3).pop()) + check("2-1", { val s = mutableStack(1, 2, 3); s.pop(); s.toList.mkString("-") }) +} + +// vim: set ts=2 sw=2 et: diff --git a/test/files/run/collections.scala b/test/files/run/collections.scala index 69c40fae80..1e4e8791ac 100644 --- a/test/files/run/collections.scala +++ b/test/files/run/collections.scala @@ -1,5 +1,6 @@ -import collection._ +import scala.collection._ import scala.compat.Platform.currentTime +import scala.language.postfixOps object Test extends App { diff --git a/test/files/run/colltest1.scala b/test/files/run/colltest1.scala index 54adeb7cda..9d77fc413a 100644 --- a/test/files/run/colltest1.scala +++ b/test/files/run/colltest1.scala @@ -1,4 +1,8 @@ -import collection._ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ +import scala.collection._ +import scala.language.postfixOps object Test extends App { diff --git a/test/files/run/comparable-comparator.scala b/test/files/run/comparable-comparator.scala index ac943c63bb..1707fb6e61 100644 --- a/test/files/run/comparable-comparator.scala +++ b/test/files/run/comparable-comparator.scala @@ -15,7 +15,8 @@ object Test { def compare(p1: C2, p2: C2) = p2.s compareTo p1.s } - val strs = "zip foo bar baz aggle bing bong" split ' ' toList + val words = "zip foo bar baz aggle bing bong" split ' ' + val strs = words.toList val c1s = strs map (x => new C1(x)) val c2s = strs map (x => new C2(x)) diff --git a/test/files/run/compiler-asSeenFrom.scala b/test/files/run/compiler-asSeenFrom.scala index 19feb45101..bd3db0bf66 100644 --- a/test/files/run/compiler-asSeenFrom.scala +++ b/test/files/run/compiler-asSeenFrom.scala @@ -1,6 +1,10 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import scala.tools.nsc._ import scala.tools.partest.CompilerTest import scala.collection.{ mutable, immutable, generic } +import scala.language.postfixOps /** It's too messy but it's better than not having it. */ @@ -47,10 +51,10 @@ package ll { for (p <- typeRefPrefixes ; c <- classes filter (isPossibleEnclosure(p.typeSymbol, _)) ; a <- targs) yield typeRef(p, c, List(a)) ) - + val wfmt = "%-" + 25 + "s" def to_s(x: Any): String = wfmt.format(x.toString.replaceAll("""\bll\.""", "")) - + def fmt(args: Any*): String = { (args map to_s mkString " ").replaceAll("""\s+$""", "") } @@ -61,7 +65,7 @@ package ll { } def permuteAsSeenFrom(targs: List[Type]) = ( - for { + for { tp <- typeRefs(targs filterNot (_ eq NoType)) prefix <- asSeenPrefixes if tp.prefix != prefix @@ -72,11 +76,11 @@ package ll { } yield ((site, tp, prefix, seen)) ) - + def block(label: Any)(lines: List[String]): List[String] = { val first = "" + label + " {" val last = "}" - + first +: lines.map(" " + _) :+ last } @@ -84,7 +88,7 @@ package ll { permuteAsSeenFrom(targs).groupBy(_._1).toList.sortBy(_._1.toString) flatMap { case (site, xs) => block(fmt(site)) { - fmt("type", "seen from prefix", "is") :: + fmt("type", "seen from prefix", "is") :: fmt("----", "----------------", "--") :: { xs.groupBy(_._2).toList.sortBy(_._1.toString) flatMap { case (tp, ys) => @@ -95,7 +99,7 @@ package ll { } } } - + def pretty(xs: List[_]) = if (xs.isEmpty) "" else xs.mkString("\n ", "\n ", "\n") def signaturesIn(info: Type): List[String] = ( @@ -103,11 +107,11 @@ package ll { filterNot (s => s.isType || s.owner == ObjectClass || s.owner == AnyClass || s.isConstructor) map (_.defString) ) - + def check(source: String, unit: global.CompilationUnit) = { import syms._ - afterTyper { + exitingTyper { val typeArgs = List[Type](IntClass.tpe, ListClass[Int]) ++ tparams.map(_.tpe) permute(typeArgs) foreach println } @@ -117,6 +121,5 @@ package ll { println(sigs.mkString(x + " { // after " + ph + "\n ", "\n ", "\n}\n")) } } - true } } diff --git a/test/files/run/concurrent-stream.scala b/test/files/run/concurrent-stream.scala index 42c695964e..9d5ba0428e 100644 --- a/test/files/run/concurrent-stream.scala +++ b/test/files/run/concurrent-stream.scala @@ -1,32 +1,33 @@ // test concurrent calls to Stream.tail +@deprecated("Suppress warnings", since="2.11") object Test { -def slowRange(from: Int, until: Int, cons: (Int, => Stream[Int]) => Stream[Int]): Stream[Int] = { - var current = from - def next: Stream[Int] = { - Thread.sleep(100) - if (current >= until) Stream.empty - else { - val stream = cons(current, next) - current += 1 - stream + def slowRange(from: Int, until: Int, cons: (Int, => Stream[Int]) => Stream[Int]): Stream[Int] = { + var current = from + def next: Stream[Int] = { + Thread.sleep(100) + if (current >= until) Stream.empty + else { + val stream = cons(current, next) + current += 1 + stream + } } + next } - next -} -def testCons(cons: (Int, => Stream[Int]) => Stream[Int]): Unit = { - import scala.actors.Actor._ + def testCons(cons: (Int, => Stream[Int]) => Stream[Int]): Unit = { + import scala.actors.Actor._ - val stream = slowRange(0, 10, cons) - val main = self - actor { main ! stream.toList } - actor { main ! stream.toList } - val eval0 = receive { case list: List[Int] => list } - val eval1 = receive { case list: List[Int] => list } - println("Evaluation 0: " + eval0) - println("Evaluation 1: " + eval1) -} + val stream = slowRange(0, 10, cons) + val main = self + actor { main ! stream.toList } + actor { main ! stream.toList } + val eval0 = receive { case list: List[Int @unchecked] => list } + val eval1 = receive { case list: List[Int @unchecked] => list } + println("Evaluation 0: " + eval0) + println("Evaluation 1: " + eval1) + } def main(args: Array[String]) { println("Testing standard cons.") diff --git a/test/files/run/constant-optimization.check b/test/files/run/constant-optimization.check new file mode 100644 index 0000000000..957ffc5a87 --- /dev/null +++ b/test/files/run/constant-optimization.check @@ -0,0 +1,5 @@ +testBothReachable: good +testOneReachable: good +testAllReachable: good +testOneUnreachable: good +testDefaultUnreachable: good diff --git a/test/files/run/constant-optimization.flags b/test/files/run/constant-optimization.flags new file mode 100644 index 0000000000..c9b68d70dc --- /dev/null +++ b/test/files/run/constant-optimization.flags @@ -0,0 +1 @@ +-optimise diff --git a/test/files/run/constant-optimization.scala b/test/files/run/constant-optimization.scala new file mode 100644 index 0000000000..5d13272f3b --- /dev/null +++ b/test/files/run/constant-optimization.scala @@ -0,0 +1,61 @@ +object Test extends App { + def testBothReachable() { + val i = util.Random.nextInt + val x = if (i % 2 == 0) null else "good" + val y = if (x == null) "good" else x + "" + println(s"testBothReachable: $y") + } + + def testOneReachable() { + val i = 1 + val x = if (i != 1) null else "good" + val y = if (x == null) "good" else x + "" + println(s"testOneReachable: $y") + } + + def testAllReachable() { + val i = util.Random.nextInt + val y = (i % 2) match { + case 0 => "good" + case 1 => "good" + case _ => "good" + } + println(s"testAllReachable: $y") + } + + def testOneUnreachable() { + val i = util.Random.nextInt + val x = if (i % 2 == 0) { + 1 + } else { + 2 + } + val y = x match { + case 0 => "good" + case 1 => "good" + case _ => "good" + } + println(s"testOneUnreachable: $y") + } + + def testDefaultUnreachable() { + val i = util.Random.nextInt + val x = if (i % 2 == 0) { + 1 + } else { + 2 + } + val y = x match { + case 1 => "good" + case 2 => "good" + case _ => "good" + } + println(s"testDefaultUnreachable: $y") + } + + testBothReachable() + testOneReachable() + testAllReachable() + testOneUnreachable() + testDefaultUnreachable() +} diff --git a/test/files/run/constant-type.check b/test/files/run/constant-type.check index dfd8be5297..4eededb8ba 100644 --- a/test/files/run/constant-type.check +++ b/test/files/run/constant-type.check @@ -13,16 +13,16 @@ scala> :power scala> val s = transformedType(StringClass.toType).asInstanceOf[Type] s: $r.intp.global.Type = String -scala> { println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } +scala> { println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } Class[String](classOf[java.lang.String]) -scala> { afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } +scala> { exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } Class(classOf[java.lang.String]) -scala> { ConstantType(Constant(s)); println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } +scala> { ConstantType(Constant(s)); println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } Class[String](classOf[java.lang.String]) -scala> { ConstantType(Constant(s)); afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } +scala> { ConstantType(Constant(s)); exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } Class(classOf[java.lang.String]) scala> diff --git a/test/files/run/constant-type.scala b/test/files/run/constant-type.scala index 84539e2895..373746af4a 100644 --- a/test/files/run/constant-type.scala +++ b/test/files/run/constant-type.scala @@ -9,9 +9,9 @@ object Test extends ReplTest { def code = """ :power val s = transformedType(StringClass.toType).asInstanceOf[Type] -{ println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } -{ afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } -{ ConstantType(Constant(s)); println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } -{ ConstantType(Constant(s)); afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } +{ println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } +{ exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } +{ ConstantType(Constant(s)); println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } +{ ConstantType(Constant(s)); exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } """ } diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index 85c4f41872..8b53e2391d 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -37,7 +37,7 @@ scala> object Stuff { val x = "hello" val y : Int @Annot(x) = 10 } -defined module Stuff +defined object Stuff scala> @@ -127,7 +127,7 @@ defined class rep scala> scala> object A { val x = "hello" : String @ rep } -defined module A +defined object A warning: previously defined class A is not a companion to object A. Companions must be defined together; you may wish to use :paste mode for this. diff --git a/test/files/run/contrib674.check b/test/files/run/contrib674.check new file mode 100644 index 0000000000..78325c1810 --- /dev/null +++ b/test/files/run/contrib674.check @@ -0,0 +1,3 @@ +contrib674.scala:15: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 1 + ^ diff --git a/test/files/run/contrib674.scala b/test/files/run/contrib674.scala index f6b46d13c6..45c9871fc4 100644 --- a/test/files/run/contrib674.scala +++ b/test/files/run/contrib674.scala @@ -5,11 +5,11 @@ object Test extends App { try { 1 } catch { - case e => + case e: Throwable => } finally { try { } catch { - case e => + case e: Throwable => } } 1 diff --git a/test/files/run/ctries-new/iterator.scala b/test/files/run/ctries-new/iterator.scala index b953a40e00..bb1175e61b 100644 --- a/test/files/run/ctries-new/iterator.scala +++ b/test/files/run/ctries-new/iterator.scala @@ -1,144 +1,134 @@ - - - - import collection._ import collection.concurrent.TrieMap - - object IteratorSpec extends Spec { - + def test() { "work for an empty trie" in { val ct = new TrieMap val it = ct.iterator - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] } - + def nonEmptyIteratorCheck(sz: Int) { val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + val it = ct.iterator val tracker = mutable.Map[Wrap, Int]() for (i <- 0 until sz) { assert(it.hasNext == true) tracker += it.next } - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] tracker.size shouldEqual (sz) tracker shouldEqual (ct) } - + "work for a 1 element trie" in { nonEmptyIteratorCheck(1) } - + "work for a 2 element trie" in { nonEmptyIteratorCheck(2) } - + "work for a 3 element trie" in { nonEmptyIteratorCheck(3) } - + "work for a 5 element trie" in { nonEmptyIteratorCheck(5) } - + "work for a 10 element trie" in { nonEmptyIteratorCheck(10) } - + "work for a 20 element trie" in { nonEmptyIteratorCheck(20) } - + "work for a 50 element trie" in { nonEmptyIteratorCheck(50) } - + "work for a 100 element trie" in { nonEmptyIteratorCheck(100) } - + "work for a 1k element trie" in { nonEmptyIteratorCheck(1000) } - + "work for a 5k element trie" in { nonEmptyIteratorCheck(5000) } - + "work for a 75k element trie" in { nonEmptyIteratorCheck(75000) } - + "work for a 250k element trie" in { nonEmptyIteratorCheck(500000) } - + def nonEmptyCollideCheck(sz: Int) { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until sz) ct.put(new DumbHash(i), i) - + val it = ct.iterator val tracker = mutable.Map[DumbHash, Int]() for (i <- 0 until sz) { assert(it.hasNext == true) tracker += it.next } - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] tracker.size shouldEqual (sz) tracker shouldEqual (ct) } - + "work for colliding hashcodes, 2 element trie" in { nonEmptyCollideCheck(2) } - + "work for colliding hashcodes, 3 element trie" in { nonEmptyCollideCheck(3) } - + "work for colliding hashcodes, 5 element trie" in { nonEmptyCollideCheck(5) } - + "work for colliding hashcodes, 10 element trie" in { nonEmptyCollideCheck(10) } - + "work for colliding hashcodes, 100 element trie" in { nonEmptyCollideCheck(100) } - + "work for colliding hashcodes, 500 element trie" in { nonEmptyCollideCheck(500) } - + "work for colliding hashcodes, 5k element trie" in { nonEmptyCollideCheck(5000) } - + def assertEqual(a: Map[Wrap, Int], b: Map[Wrap, Int]) { if (a != b) { println(a.size + " vs " + b.size) - // println(a) - // println(b) - // println(a.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) - // println(b.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) } assert(a == b) } - + "be consistent when taken with concurrent modifications" in { val sz = 25000 val W = 15 @@ -146,40 +136,40 @@ object IteratorSpec extends Spec { val checks = 5 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + class Modifier extends Thread { override def run() { for (i <- 0 until sz) ct.putIfAbsent(new Wrap(i), i) match { case Some(_) => ct.remove(new Wrap(i)) - case None => + case None => } } } - + def consistentIteration(ct: TrieMap[Wrap, Int], checks: Int) { class Iter extends Thread { override def run() { val snap = ct.readOnlySnapshot() val initial = mutable.Map[Wrap, Int]() for (kv <- snap) initial += kv - + for (i <- 0 until checks) { assertEqual(snap.iterator.toMap, initial) } } } - + val iter = new Iter iter.start() iter.join() } - + val threads = for (_ <- 0 until W) yield new Modifier threads.foreach(_.start()) for (_ <- 0 until S) consistentIteration(ct, checks) threads.foreach(_.join()) } - + "be consistent with a concurrent removal with a well defined order" in { val sz = 150000 val sgroupsize = 10 @@ -187,17 +177,16 @@ object IteratorSpec extends Spec { val removerslowdown = 50 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + class Remover extends Thread { override def run() { for (i <- 0 until sz) { assert(ct.remove(new Wrap(i)) == Some(i)) for (i <- 0 until removerslowdown) ct.get(new Wrap(i)) // slow down, mate } - //println("done removing") } } - + def consistentIteration(it: Iterator[(Wrap, Int)]) = { class Iter extends Thread { override def run() { @@ -210,7 +199,7 @@ object IteratorSpec extends Spec { } new Iter } - + val remover = new Remover remover.start() for (_ <- 0 until sgroupnum) { @@ -218,27 +207,25 @@ object IteratorSpec extends Spec { iters.foreach(_.start()) iters.foreach(_.join()) } - //println("done with iterators") remover.join() } - + "be consistent with a concurrent insertion with a well defined order" in { val sz = 150000 val sgroupsize = 10 val sgroupnum = 10 val inserterslowdown = 50 val ct = new TrieMap[Wrap, Int] - + class Inserter extends Thread { override def run() { for (i <- 0 until sz) { assert(ct.put(new Wrap(i), i) == None) for (i <- 0 until inserterslowdown) ct.get(new Wrap(i)) // slow down, mate } - //println("done inserting") } } - + def consistentIteration(it: Iterator[(Wrap, Int)]) = { class Iter extends Thread { override def run() { @@ -251,7 +238,7 @@ object IteratorSpec extends Spec { } new Iter } - + val inserter = new Inserter inserter.start() for (_ <- 0 until sgroupnum) { @@ -259,31 +246,30 @@ object IteratorSpec extends Spec { iters.foreach(_.start()) iters.foreach(_.join()) } - //println("done with iterators") inserter.join() } - + "work on a yet unevaluated snapshot" in { val sz = 50000 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.update(new Wrap(i), i) - + val snap = ct.snapshot() val it = snap.iterator - + while (it.hasNext) it.next() } - + "be duplicated" in { val sz = 50 val ct = collection.parallel.mutable.ParTrieMap((0 until sz) zip (0 until sz): _*) val it = ct.splitter for (_ <- 0 until (sz / 2)) it.next() val dupit = it.dup - + it.toList shouldEqual dupit.toList } - + } - + } diff --git a/test/files/run/ctries-new/main.scala b/test/files/run/ctries-new/main.scala index d7fe087e4d..34f3ec2ccf 100644 --- a/test/files/run/ctries-new/main.scala +++ b/test/files/run/ctries-new/main.scala @@ -21,6 +21,9 @@ object Test { trait Spec { + implicit def implicitously = scala.language.implicitConversions + implicit def reflectively = scala.language.reflectiveCalls + implicit def str2ops(s: String) = new { def in[U](body: =>U) { // just execute body @@ -37,11 +40,11 @@ trait Spec { var produced = false try body catch { - case e => if (e.getClass == implicitly[ClassTag[T]].runtimeClass) produced = true + case e: Throwable => if (e.getClass == implicitly[ClassTag[T]].runtimeClass) produced = true } finally { assert(produced, "Did not produce exception of type: " + implicitly[ClassTag[T]]) } } } -}
\ No newline at end of file +} diff --git a/test/files/run/ctries-old/concmap.scala b/test/files/run/ctries-old/concmap.scala index 3ec0256afb..fccd4bed3e 100644 --- a/test/files/run/ctries-old/concmap.scala +++ b/test/files/run/ctries-old/concmap.scala @@ -2,6 +2,7 @@ import collection.concurrent.TrieMap +import Test.Spec object ConcurrentMapSpec extends Spec { diff --git a/test/files/run/ctries-old/iterator.scala b/test/files/run/ctries-old/iterator.scala index b953a40e00..585bdc0e48 100644 --- a/test/files/run/ctries-old/iterator.scala +++ b/test/files/run/ctries-old/iterator.scala @@ -5,6 +5,7 @@ import collection._ import collection.concurrent.TrieMap +import Test.Spec object IteratorSpec extends Spec { diff --git a/test/files/run/ctries-old/lnode.scala b/test/files/run/ctries-old/lnode.scala index 92a31088e5..3ff5414ac0 100644 --- a/test/files/run/ctries-old/lnode.scala +++ b/test/files/run/ctries-old/lnode.scala @@ -3,6 +3,7 @@ import collection.concurrent.TrieMap +import Test.Spec object LNodeSpec extends Spec { diff --git a/test/files/run/ctries-old/main.scala b/test/files/run/ctries-old/main.scala index 78ba7f0db1..f714bcdcdc 100644 --- a/test/files/run/ctries-old/main.scala +++ b/test/files/run/ctries-old/main.scala @@ -5,6 +5,7 @@ +@deprecated("Suppress warnings", since="2.11") object Test { def main(args: Array[String]) { @@ -14,11 +15,13 @@ object Test { SnapshotSpec.test() } -} trait Spec { + implicit def implicitously = scala.language.implicitConversions + implicit def reflectively = scala.language.reflectiveCalls + implicit def str2ops(s: String) = new { def in[U](body: =>U) { // just execute body @@ -35,7 +38,7 @@ trait Spec { var produced = false try body catch { - case e => if (e.getClass == implicitly[ClassManifest[T]].erasure) produced = true + case e: Throwable => if (e.getClass == implicitly[ClassManifest[T]].erasure) produced = true } finally { assert(produced, "Did not produce exception of type: " + implicitly[ClassManifest[T]]) } @@ -43,3 +46,4 @@ trait Spec { } } +} diff --git a/test/files/run/ctries-old/snapshot.scala b/test/files/run/ctries-old/snapshot.scala index 5fe77d445b..768b588f81 100644 --- a/test/files/run/ctries-old/snapshot.scala +++ b/test/files/run/ctries-old/snapshot.scala @@ -5,6 +5,7 @@ import collection._ import collection.concurrent.TrieMap +import Test.Spec object SnapshotSpec extends Spec { diff --git a/test/files/run/deeps.check b/test/files/run/deeps.check new file mode 100644 index 0000000000..a68e474f62 --- /dev/null +++ b/test/files/run/deeps.check @@ -0,0 +1,87 @@ +testEquals1 +false +false +true + +testEquals2 +false +false +true + +testEquals3 +x=Array(1) +y=Array(1) +false +false +true + +x=Array(Array(1), Array(1)) +y=Array(Array(1), Array(1)) +false +false +true + +x=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1))) +y=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1))) +false +false +true + +testEquals4 +false +false +true +false +false +true +Array(true, false) +Array(true, false) +[true;false] +true;false + +Array(Array(true, false), Array(true, false)) +Array(Array(true, false), Array(true, false)) +[Array(true, false);Array(true, false)] +Array(true, false);Array(true, false) + +Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false))) +Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false))) +[Array(Array(true, false), Array(true, false));Array(Array(true, false), Array(true, false))] +Array(Array(true, false), Array(true, false));Array(Array(true, false), Array(true, false)) + +Array(1.0, 0.0) +Array(1.0, 0.0) +[1.0;0.0] +1.0;0.0 + +Array(Array(1.0, 0.0), Array(1.0, 0.0)) +Array(Array(1.0, 0.0), Array(1.0, 0.0)) +[Array(1.0, 0.0);Array(1.0, 0.0)] +Array(1.0, 0.0);Array(1.0, 0.0) + +Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0))) +Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0))) +[Array(Array(1.0, 0.0), Array(1.0, 0.0));Array(Array(1.0, 0.0), Array(1.0, 0.0))] +Array(Array(1.0, 0.0), Array(1.0, 0.0));Array(Array(1.0, 0.0), Array(1.0, 0.0)) + +Array(a, b) +Array(a, b) +[a;b] +a;b + +Array(Array(a, b), Array(a, b)) +Array(Array(a, b), Array(a, b)) +[Array(a, b);Array(a, b)] +Array(a, b);Array(a, b) + +Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b))) +Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b))) +[Array(Array(a, b), Array(a, b));Array(Array(a, b), Array(a, b))] +Array(Array(a, b), Array(a, b));Array(Array(a, b), Array(a, b)) + +[Array(true, false); Array(false)] +[Array(1, 2); Array(3)] +[Array(1, 2); Array(3)] + +Array(boo, and, foo) +Array(a) diff --git a/test/files/run/deeps.scala b/test/files/run/deeps.scala new file mode 100644 index 0000000000..6049cc6024 --- /dev/null +++ b/test/files/run/deeps.scala @@ -0,0 +1,114 @@ +//############################################################################ +// deepEquals / deep.toString +//############################################################################ + +//############################################################################ +// need to revisit array equqality +object Test { + + def testEquals1 { + println(Array(1) == Array(1)) + println(Array(1) equals Array(1)) + println(Array(1).deep == Array(1).deep) + println + } + + def testEquals2 { + println(Array(Array(1), Array(2)) == Array(Array(1), Array(2))) + println(Array(Array(1), Array(2)) equals Array(Array(1), Array(2))) + println(Array(Array(1), Array(2)).deep equals Array(Array(1), Array(2)).deep) + println + } + + def testEquals3 { + val a1 = Array(1) + val b1 = Array(1) + val a2 = Array(a1, b1) + val b2 = Array(a1, b1) + val a3 = Array(a2, b2) + val b3 = Array(a2, b2) + def test[T](x: Array[T], y: Array[T]) { + println("x=" + x.deep.toString) + println("y=" + y.deep.toString) + println(x == y) + println(x equals y) + println(x.deep == y.deep) + println + } + test(a1, b1) + test(a2, b2) + test(a3, b3) + } + + def testEquals4 { + println("boo:and:foo".split(':') == "boo:and:foo".split(':')) + println("boo:and:foo".split(':') equals "boo:and:foo".split(':')) + println("boo:and:foo".split(':').deep == "boo:and:foo".split(':').deep) + + val xs = new java.util.ArrayList[String](); xs.add("a") + val ys = new java.util.ArrayList[String](); ys.add("a") + println(xs.toArray == ys.toArray) + println(xs.toArray equals ys.toArray) + println(xs.toArray.deep == ys.toArray.deep) + } + + def testToString1 { + def sweep(s: String) = ( + s.replaceAll("D@[0-9a-fA-F]+", "D@0000000") + .replaceAll("Z@[0-9a-fA-F]+", "Z@0000000") + .replaceAll(";@[0-9a-fA-F]+", ";@0000000") + ) + def test[T](a: Array[T]) { + println(sweep(a.deep.toString)) + println(a.deep.toString) + println(a.deep.mkString("[", ";", "]")) + println(a.deep.mkString(";")) + println + } + + val ba1 = Array(true, false) + val ba2 = Array(ba1, ba1) + val ba3 = Array(ba2, ba2) + test(ba1) + test(ba2) + test(ba3) + + val da1 = Array(1.0d, 0.0d) + val da2 = Array(da1, da1) + val da3 = Array(da2, da2) + test(da1) + test(da2) + test(da3) + + val sa1 = Array("a", "b") + val sa2 = Array(sa1, sa1) + val sa3 = Array(sa2, sa2) + test(sa1) + test(sa2) + test(sa3) + } + + def testToString2 { + println(Array(Array(true, false), Array(false)).deep.mkString("[", "; ", "]")) + println(Array(Array('1', '2'), Array('3')).deep.mkString("[", "; ", "]")) + println(Array(Array(1, 2), Array(3)).deep.mkString("[", "; ", "]")) + println + } + + def testToString3 { + println("boo:and:foo".split(':').deep.toString) + + val xs = new java.util.ArrayList[String](); xs.add("a") + println(xs.toArray.deep.toString) + } + + def main(args: Array[String]): Unit = { + println("testEquals1") ; testEquals1 + println("testEquals2") ; testEquals2 + println("testEquals3") ; testEquals3 + println("testEquals4") ; testEquals4 + testToString1 + testToString2 + testToString3 + } +} diff --git a/test/files/run/delay-bad.check b/test/files/run/delay-bad.check index 9d9c828a03..2ae88267c5 100644 --- a/test/files/run/delay-bad.check +++ b/test/files/run/delay-bad.check @@ -1,3 +1,9 @@ +delay-bad.scala:53: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + f(new C { 5 }) + ^ +delay-bad.scala:73: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + f(new { val x = 5 } with E() { 5 }) + ^ // new C { } diff --git a/test/files/run/delay-good.check b/test/files/run/delay-good.check index 8eb04c7cff..b4f6b04af7 100644 --- a/test/files/run/delay-good.check +++ b/test/files/run/delay-good.check @@ -1,3 +1,9 @@ +delay-good.scala:53: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + f(new C { 5 }) + ^ +delay-good.scala:73: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + f(new { val x = 5 } with E() { 5 }) + ^ // new C { } diff --git a/test/files/run/distinct.scala b/test/files/run/distinct.scala index 09e5a0734a..37bbe7805a 100644 --- a/test/files/run/distinct.scala +++ b/test/files/run/distinct.scala @@ -3,7 +3,7 @@ */ object Test { val alphabet = 'a' to 'z' mkString "" - val alphaList = 'a' to 'z' toList + val alphaList = ('a' to 'z').toList def shuffled = util.Random.shuffle(alphaList) def main(args: Array[String]): Unit = { diff --git a/test/files/run/duration-coarsest.scala b/test/files/run/duration-coarsest.scala new file mode 100644 index 0000000000..51cb79287a --- /dev/null +++ b/test/files/run/duration-coarsest.scala @@ -0,0 +1,28 @@ +import scala.concurrent.duration._ +import scala.language.postfixOps + +object Test extends App { + List( + (60 minutes, 1 hour), + (2000 millis, 2 seconds), + (2000 micros, 2 millis), + (2000 nanos, 2 micros), + (2000000 nanos, 2 millis), + (48 hours, 2 days), + (5 seconds, 5 seconds), + (1 second, 1 second) + ) foreach { + case (x, expected) => + val actual = x.toCoarsest + assert(actual.unit == expected.unit, s"$actual, $expected") + assert(actual.length == expected.length, s"$actual, $expected") + } + + List( + 45 minutes, + 500 millis, + 1500 millis, + 23 hours, + 40 days + ) foreach (x => assert(x == x.toCoarsest, x)) +}
\ No newline at end of file diff --git a/test/files/run/enrich-gentraversable.scala b/test/files/run/enrich-gentraversable.scala index 52eded55fd..0f79a47030 100644 --- a/test/files/run/enrich-gentraversable.scala +++ b/test/files/run/enrich-gentraversable.scala @@ -1,3 +1,6 @@ +import scala.language.implicitConversions +import scala.language.postfixOps + object Test extends App { import scala.collection.{GenTraversableOnce,GenTraversableLike} import scala.collection.generic._ diff --git a/test/files/run/enums.scala b/test/files/run/enums.scala index 9cdeed2691..3aad7ec320 100644 --- a/test/files/run/enums.scala +++ b/test/files/run/enums.scala @@ -36,8 +36,11 @@ object Test2 { object Test3 { - object Direction extends Enumeration("North", "South", "East", "West") { - val North, South, East, West = Value; + object Direction extends Enumeration { + val North = Value("North") + val South = Value("South") + val East = Value("East") + val West = Value("West") } def run: Int = { @@ -48,8 +51,11 @@ object Test3 { object Test4 { - object Direction extends Enumeration("North", "South", "East", "West") { - val North, South, East, West = Value; + object Direction extends Enumeration { + val North = Value("North") + val South = Value("South") + val East = Value("East") + val West = Value("West") } def run: Int = { diff --git a/test/files/run/eta-expand-star2.check b/test/files/run/eta-expand-star2.check index ce01362503..cbf4781255 100644 --- a/test/files/run/eta-expand-star2.check +++ b/test/files/run/eta-expand-star2.check @@ -1 +1,2 @@ +warning: there were 1 deprecation warning(s); re-run with -deprecation for details hello diff --git a/test/files/run/exceptions-2.check b/test/files/run/exceptions-2.check index 9a3044cd4f..4f8244800a 100644 --- a/test/files/run/exceptions-2.check +++ b/test/files/run/exceptions-2.check @@ -1,3 +1,6 @@ +exceptions-2.scala:267: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + try { 1 } catch { case e: java.io.IOException => () } + ^ nested1: Innermost finally Outermost finally diff --git a/test/files/run/exceptions-2.scala b/test/files/run/exceptions-2.scala index d0312a49b2..8d755c3809 100644 --- a/test/files/run/exceptions-2.scala +++ b/test/files/run/exceptions-2.scala @@ -42,14 +42,14 @@ object NoExcep { def method4 = try { Console.println(".."); } catch { - case _ => error(".."); + case _: Throwable => sys.error(".."); } } object Test { def nested1: Unit = try { try { - error("nnnnoooo"); + sys.error("nnnnoooo"); } finally { Console.println("Innermost finally"); } @@ -59,7 +59,7 @@ object Test { def nested2 = try { try { - error("nnnnoooo"); + sys.error("nnnnoooo"); } finally { Console.println("Innermost finally"); } @@ -68,7 +68,7 @@ object Test { Console.println("Outermost finally"); } - def mixed = + def mixed = try { if (10 > 0) throw Leaf(10); @@ -107,7 +107,7 @@ object Test { case Leaf(a) => Console.println(a); } } catch { - case npe: NullPointerException => + case npe: NullPointerException => Console.println("Caught an NPE"); } @@ -134,74 +134,74 @@ object Test { () } finally { try { - error("a"); + sys.error("a"); } catch { - case _ => Console.println("Silently ignore exception in finally"); + case _: Throwable => Console.println("Silently ignore exception in finally"); } } } - def valInFinally: Unit = - try { + def valInFinally: Unit = + try { } finally { val fin = "Abc"; Console.println(fin); - }; + } - def tryAndValInFinally: Unit = + def tryAndValInFinally: Unit = try { } finally { val fin = "Abc"; try { Console.println(fin); - } catch { case _ => () } - }; + } catch { case _: Throwable => () } + } - def returnInBody: Unit = try { + def returnInBody: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); } - } finally { + } finally { Console.println("Outer finally"); } - def returnInBodySynch: Unit = try { + def returnInBodySynch: Unit = try { synchronized { try { Console.println("Synchronized normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); } } - } finally { + } finally { Console.println("Outer finally"); } - def returnInBodyAndInFinally: Unit = try { + def returnInBodyAndInFinally: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); return } - } finally { + } finally { Console.println("Outer finally"); return } - def returnInBodyAndInFinally2: Unit = try { + def returnInBodyAndInFinally2: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { try { @@ -211,7 +211,7 @@ object Test { Console.println("finally inside finally"); } } - } finally { + } finally { Console.println("Outer finally"); return } @@ -249,11 +249,11 @@ object Test { def execute(f: => Unit) = try { f; } catch { - case _ => (); + case _: Throwable => () } - def returnWithFinallyClean: Int = try { + def returnWithFinallyClean: Int = try { try { Console.println("Normal execution..."); return 10 @@ -262,7 +262,7 @@ object Test { } finally { Console.println("inner finally"); } - } finally { + } finally { Console.println("Outer finally"); try { 1 } catch { case e: java.io.IOException => () } } @@ -294,7 +294,7 @@ object Test { Console.println("mixed: "); execute(mixed); - + Console.println("withValue1:"); execute(withValue1); @@ -322,7 +322,7 @@ object Test { Console.println("NoExcep.method3:"); execute(NoExcep.method3); - + Console.println("NoExcep.method4:"); execute(NoExcep.method4); diff --git a/test/files/run/exceptions-nest.scala b/test/files/run/exceptions-nest.scala index 841e6b1c67..432d600d13 100644 --- a/test/files/run/exceptions-nest.scala +++ b/test/files/run/exceptions-nest.scala @@ -5,9 +5,9 @@ object Test extends App { println(test3) println(test4) println(test5) - try { println(test6) } catch { case _ => println("OK") } + try { println(test6) } catch { case _: Throwable => println("OK") } println(test7) - try { println(test8) } catch { case _ => println("OK") } + try { println(test8) } catch { case _: Throwable => println("OK") } println(test9) println(test10) println(test11) @@ -19,7 +19,7 @@ object Test extends App { x = 2 } catch { case _: NullPointerException => x = 3 - case _ => x = 4 + case _: Throwable => x = 4 } x } @@ -31,12 +31,12 @@ object Test extends App { try { x = 21 } catch { - case _ => x = 22 + case _: Throwable => x = 22 } x = 23 } catch { case _: NullPointerException => x = 3 - case _ => x = 4 + case _: Throwable => x = 4 } x } @@ -44,10 +44,10 @@ object Test extends App { def test3 = { var x = 1 try { - try{x = 2} catch { case _ => x = 4 } + try{x = 2} catch { case _: Throwable => x = 4 } } catch { case _: NullPointerException => x = 3 - case _ => x = 4 + case _: Throwable => x = 4 } x } @@ -58,7 +58,7 @@ object Test extends App { x = 2 } catch { case _: NullPointerException => x = 3 - case _ => x = 4 + case _: Throwable => x = 4 } try { x = 5 @@ -73,8 +73,8 @@ object Test extends App { try { x = 2 } catch { - case _: NullPointerException => try { x = 3 } catch { case f => throw f } - case _ => x = 4; try { x = 41 } catch { case _: Exception => x = 42 }; x = 43 + case _: NullPointerException => try { x = 3 } catch { case f: Throwable => throw f } + case _: Throwable => x = 4; try { x = 41 } catch { case _: Exception => x = 42 }; x = 43 } x } @@ -87,7 +87,7 @@ object Test extends App { } catch { case e: NullPointerException => throw e - case _ => + case _: Throwable => x = 3 return 1000 } finally { @@ -105,7 +105,7 @@ object Test extends App { try { x = 4 } catch { - case _ => x = 5 + case _: Throwable => x = 5 } } x @@ -116,7 +116,7 @@ object Test extends App { try { throw new NullPointerException } catch { - case e => throw e + case e: Throwable => throw e } x } @@ -124,7 +124,7 @@ object Test extends App { def test9 = { try { "" match { case s: String => 10 - }} catch { case _ => 20 } + }} catch { case _: Throwable => 20 } } var x10 = 1 @@ -135,7 +135,7 @@ object Test extends App { def test11 { try { () } - catch { case e => () } + catch { case e: Throwable => () } } class E1 extends Exception diff --git a/test/files/run/exceptions.scala b/test/files/run/exceptions.scala index fc3566f85e..f0fe76946b 100644 --- a/test/files/run/exceptions.scala +++ b/test/files/run/exceptions.scala @@ -6,8 +6,8 @@ abstract class IntMap[A] { def lookup(key: Int): A = this match { - case Empty() => error("KO") - case _ => error("ok") + case Empty() => sys.error("KO") + case _ => sys.error("ok") } } @@ -32,7 +32,7 @@ object exceptions { val value = try { map.lookup(key) } catch { - case e => e.getMessage() + case e: Throwable => e.getMessage() } check("lookup(" + key + ")", value, "KO"); } diff --git a/test/files/run/existentials-in-compiler.check b/test/files/run/existentials-in-compiler.check index 0d7a9298b4..b0d852865d 100644 --- a/test/files/run/existentials-in-compiler.check +++ b/test/files/run/existentials-in-compiler.check @@ -8,22 +8,22 @@ abstract trait BippyLike[A <: AnyRef, B <: List[A], This <: extest.BippyLike[A,B extest.BippyLike[A,B,This] forSome { A <: AnyRef; B <: List[A]; This <: extest.BippyLike[A,B,This] with extest.Bippy[A,B] } abstract trait Contra[-A >: AnyRef, -B] extends AnyRef - extest.Contra[_ >: AnyRef, _] + extest.Contra[AnyRef, _] abstract trait ContraLike[-A >: AnyRef, -B >: List[A]] extends AnyRef extest.ContraLike[A,B] forSome { -A >: AnyRef; -B >: List[A] } abstract trait Cov01[+A <: AnyRef, +B] extends AnyRef - extest.Cov01[_ <: AnyRef, _] + extest.Cov01[AnyRef,Any] abstract trait Cov02[+A <: AnyRef, B] extends AnyRef - extest.Cov02[_ <: AnyRef, _] + extest.Cov02[AnyRef, _] abstract trait Cov03[+A <: AnyRef, -B] extends AnyRef - extest.Cov03[_ <: AnyRef, _] + extest.Cov03[AnyRef, _] abstract trait Cov04[A <: AnyRef, +B] extends AnyRef - extest.Cov04[_ <: AnyRef, _] + extest.Cov04[_ <: AnyRef, Any] abstract trait Cov05[A <: AnyRef, B] extends AnyRef extest.Cov05[_ <: AnyRef, _] @@ -32,7 +32,7 @@ abstract trait Cov06[A <: AnyRef, -B] extends AnyRef extest.Cov06[_ <: AnyRef, _] abstract trait Cov07[-A <: AnyRef, +B] extends AnyRef - extest.Cov07[_ <: AnyRef, _] + extest.Cov07[_ <: AnyRef, Any] abstract trait Cov08[-A <: AnyRef, B] extends AnyRef extest.Cov08[_ <: AnyRef, _] @@ -41,16 +41,16 @@ abstract trait Cov09[-A <: AnyRef, -B] extends AnyRef extest.Cov09[_ <: AnyRef, _] abstract trait Cov11[+A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov11[_ <: AnyRef, _ <: List[_]] + extest.Cov11[AnyRef,List[_]] abstract trait Cov12[+A <: AnyRef, B <: List[_]] extends AnyRef - extest.Cov12[_ <: AnyRef, _ <: List[_]] + extest.Cov12[AnyRef, _ <: List[_]] abstract trait Cov13[+A <: AnyRef, -B <: List[_]] extends AnyRef - extest.Cov13[_ <: AnyRef, _ <: List[_]] + extest.Cov13[AnyRef, _ <: List[_]] abstract trait Cov14[A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov14[_ <: AnyRef, _ <: List[_]] + extest.Cov14[_ <: AnyRef, List[_]] abstract trait Cov15[A <: AnyRef, B <: List[_]] extends AnyRef extest.Cov15[_ <: AnyRef, _ <: List[_]] @@ -59,7 +59,7 @@ abstract trait Cov16[A <: AnyRef, -B <: List[_]] extends AnyRef extest.Cov16[_ <: AnyRef, _ <: List[_]] abstract trait Cov17[-A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov17[_ <: AnyRef, _ <: List[_]] + extest.Cov17[_ <: AnyRef, List[_]] abstract trait Cov18[-A <: AnyRef, B <: List[_]] extends AnyRef extest.Cov18[_ <: AnyRef, _ <: List[_]] @@ -68,16 +68,16 @@ abstract trait Cov19[-A <: AnyRef, -B <: List[_]] extends AnyRef extest.Cov19[_ <: AnyRef, _ <: List[_]] abstract trait Cov21[+A, +B] extends AnyRef - extest.Cov21[_, _] + extest.Cov21[Any,Any] abstract trait Cov22[+A, B] extends AnyRef - extest.Cov22[_, _] + extest.Cov22[Any, _] abstract trait Cov23[+A, -B] extends AnyRef - extest.Cov23[_, _] + extest.Cov23[Any, _] abstract trait Cov24[A, +B] extends AnyRef - extest.Cov24[_, _] + extest.Cov24[_, Any] abstract trait Cov25[A, B] extends AnyRef extest.Cov25[_, _] @@ -86,7 +86,7 @@ abstract trait Cov26[A, -B] extends AnyRef extest.Cov26[_, _] abstract trait Cov27[-A, +B] extends AnyRef - extest.Cov27[_, _] + extest.Cov27[_, Any] abstract trait Cov28[-A, B] extends AnyRef extest.Cov28[_, _] @@ -122,16 +122,16 @@ abstract trait Cov39[-A, -B, C <: Tuple2[_, _]] extends AnyRef extest.Cov39[_, _, _ <: Tuple2[_, _]] abstract trait Cov41[+A >: Null, +B] extends AnyRef - extest.Cov41[_ >: Null, _] + extest.Cov41[Any,Any] abstract trait Cov42[+A >: Null, B] extends AnyRef - extest.Cov42[_ >: Null, _] + extest.Cov42[Any, _] abstract trait Cov43[+A >: Null, -B] extends AnyRef - extest.Cov43[_ >: Null, _] + extest.Cov43[Any, _] abstract trait Cov44[A >: Null, +B] extends AnyRef - extest.Cov44[_ >: Null, _] + extest.Cov44[_ >: Null, Any] abstract trait Cov45[A >: Null, B] extends AnyRef extest.Cov45[_ >: Null, _] @@ -140,7 +140,7 @@ abstract trait Cov46[A >: Null, -B] extends AnyRef extest.Cov46[_ >: Null, _] abstract trait Cov47[-A >: Null, +B] extends AnyRef - extest.Cov47[_ >: Null, _] + extest.Cov47[_ >: Null, Any] abstract trait Cov48[-A >: Null, B] extends AnyRef extest.Cov48[_ >: Null, _] @@ -149,7 +149,7 @@ abstract trait Cov49[-A >: Null, -B] extends AnyRef extest.Cov49[_ >: Null, _] abstract trait Covariant[+A <: AnyRef, +B] extends AnyRef - extest.Covariant[_ <: AnyRef, _] + extest.Covariant[AnyRef,Any] abstract trait CovariantLike[+A <: AnyRef, +B <: List[A], +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B]] extends AnyRef extest.CovariantLike[A,B,This] forSome { +A <: AnyRef; +B <: List[A]; +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B] } diff --git a/test/files/run/existentials-in-compiler.scala b/test/files/run/existentials-in-compiler.scala index c69d1217fd..f5a0aa98d0 100644 --- a/test/files/run/existentials-in-compiler.scala +++ b/test/files/run/existentials-in-compiler.scala @@ -1,3 +1,6 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import scala.tools.nsc._ import scala.tools.partest.CompilerTest import scala.collection.{ mutable, immutable, generic } @@ -71,14 +74,13 @@ package extest { } """ - def check(source: String, unit: global.CompilationUnit) = { - getRequiredPackage("extest").moduleClass.info.decls.toList.filter(_.isType).map(_.initialize).sortBy(_.name.toString) foreach { clazz => - afterTyper { + override def check(source: String, unit: global.CompilationUnit) { + getPackage("extest").moduleClass.info.decls.toList.filter(_.isType).map(_.initialize).sortBy(_.name.toString) foreach { clazz => + exitingTyper { clazz.info println(clazz.defString) println(" " + classExistentialType(clazz) + "\n") } } - true } } diff --git a/test/files/run/existentials.scala b/test/files/run/existentials.scala index 3977d47417..65acfd2ac0 100644 --- a/test/files/run/existentials.scala +++ b/test/files/run/existentials.scala @@ -1,3 +1,6 @@ +import scala.language.existentials +import scala.language.reflectiveCalls + class Foo { class Line { case class Cell[T](var x: T) diff --git a/test/files/run/existentials3-new.check b/test/files/run/existentials3-new.check index 8f7dd701ac..c0233d2267 100644 --- a/test/files/run/existentials3-new.check +++ b/test/files/run/existentials3-new.check @@ -12,9 +12,9 @@ List[Seq[Int]], t=TypeRef, s=class List List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List Bar.type, t=TypeRef, s=type Bar.type Bar, t=TypeRef, s=type Bar -Test.ToS, t=RefinedType, s=g3 -Test.ToS, t=RefinedType, s=g4 -Test.ToS, t=RefinedType, s=g5 +Test.ToS, t=RefinedType, s=g3 +Test.ToS, t=RefinedType, s=g4 +Test.ToS, t=RefinedType, s=g5 () => Test.ToS, t=TypeRef, s=trait Function0 () => Test.ToS, t=TypeRef, s=trait Function0 $anon, t=TypeRef, s=type $anon diff --git a/test/files/run/existentials3-new.scala b/test/files/run/existentials3-new.scala index 110c8eff7a..6112a7b856 100644 --- a/test/files/run/existentials3-new.scala +++ b/test/files/run/existentials3-new.scala @@ -1,3 +1,4 @@ +import scala.language.existentials import scala.reflect.runtime.universe._ object Test { @@ -77,4 +78,4 @@ object Misc { } def g1 = o1.f1 _ def g2 = o1.f2 _ -}
\ No newline at end of file +} diff --git a/test/files/run/existentials3-old.scala b/test/files/run/existentials3-old.scala index 944160ff12..c021c0e71e 100644 --- a/test/files/run/existentials3-old.scala +++ b/test/files/run/existentials3-old.scala @@ -1,3 +1,5 @@ +import scala.language.existentials + object Test { trait ToS { final override def toString = getClass.getName } diff --git a/test/files/run/exoticnames.scala b/test/files/run/exoticnames.scala index fa0e5e6ec5..98f9a88776 100644 --- a/test/files/run/exoticnames.scala +++ b/test/files/run/exoticnames.scala @@ -1,7 +1,7 @@ // this is a run-test because the compiler should emit bytecode that'll pass the JVM's verifier object Test extends App { - def `(` = error("bla") - def `.` = error("bla") - def `)` = error("bla") - def `,` = error("bla") + def `(` = sys.error("bla") + def `.` = sys.error("bla") + def `)` = sys.error("bla") + def `,` = sys.error("bla") } diff --git a/test/files/run/finally.scala b/test/files/run/finally.scala index 635123cc4d..01180fd217 100644 --- a/test/files/run/finally.scala +++ b/test/files/run/finally.scala @@ -7,7 +7,7 @@ object Test extends App { try { bar } catch { - case e => println(e) + case e: Throwable => println(e) } } @@ -17,7 +17,7 @@ object Test extends App { println("hi") } catch { - case e => println("SHOULD NOT GET HERE") + case e: Throwable => println("SHOULD NOT GET HERE") } finally { println("In Finally") @@ -30,7 +30,7 @@ object Test extends App { try { throw new Exception } catch { - case e => + case e: Throwable => println(e); return } finally println("in finally") @@ -41,7 +41,7 @@ object Test extends App { try { throw new Exception } catch { - case e => + case e: Throwable => println(e); throw e } finally println("in finally") @@ -52,7 +52,7 @@ object Test extends App { try { return } catch { - case e => + case e: Throwable => println(e); throw e } finally println("in finally") @@ -63,7 +63,7 @@ object Test extends App { try { throw new Exception } catch { - case e => + case e: Throwable => println(e); } finally println("in finally") } @@ -89,7 +89,7 @@ object Test extends App { throw new Exception } } catch { - case e => println(e) + case e: Throwable => println(e) } } @@ -99,7 +99,7 @@ object Test extends App { try { return 10 } finally { - try { () } catch { case _ => () } + try { () } catch { case _: Throwable => () } println("in finally 1") } } finally { @@ -111,7 +111,7 @@ object Test extends App { try { m } catch { - case e => println("COUGHT: " + e) + case e: Throwable => println("COUGHT: " + e) } println("-" * 40) } diff --git a/test/files/run/genericValueClass.scala b/test/files/run/genericValueClass.scala index 68162bb685..9398390a80 100644 --- a/test/files/run/genericValueClass.scala +++ b/test/files/run/genericValueClass.scala @@ -1,11 +1,14 @@ -final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal { - @inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) - def →[B](y: B): Tuple2[A, B] = ->(y) -} + +import scala.language.implicitConversions object Test extends App { + class ArrowAssocClass[A](val __leftOfArrow: A) extends AnyVal { + @inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) + def →[B](y: B): Tuple2[A, B] = ->(y) + } + { - @inline implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x) + @inline implicit def ArrowAssoc[A](x: A): ArrowAssocClass[A] = new ArrowAssocClass(x) val x = 1 -> "abc" println(x) } diff --git a/test/files/run/getClassTest-old.scala b/test/files/run/getClassTest-old.scala index 951cc8d931..789dd4d162 100644 --- a/test/files/run/getClassTest-old.scala +++ b/test/files/run/getClassTest-old.scala @@ -50,6 +50,7 @@ class MoreAnyRefs { def f4 = (new A { def bippy() = 5 }).getClass() } +@deprecated("Suppress warnings", since="2.11") object Test { def returnTypes[T: Manifest] = ( manifest[T].erasure.getMethods.toList diff --git a/test/files/run/global-showdef.scala b/test/files/run/global-showdef.scala index 71ba7b8bb3..2a00ee51bd 100644 --- a/test/files/run/global-showdef.scala +++ b/test/files/run/global-showdef.scala @@ -1,6 +1,7 @@ import scala.tools.nsc._ -import io.{ AbstractFile } -import util.{ SourceFile, BatchSourceFile, stringFromStream } +import scala.reflect.io.AbstractFile +import scala.tools.nsc.util.stringFromStream +import scala.reflect.internal.util.{ SourceFile, BatchSourceFile } import scala.tools.nsc.reporters.ConsoleReporter object Test { @@ -53,7 +54,7 @@ object Bippy { val run = new compiler.Run() run.compileSources(List(src)) } - output split "\\n" toList + (output split "\\n").toList } def showClass(name: String) = lines("-Yshow:typer", "-Xshow-class", name) def showObject(name: String) = lines("-Yshow:typer", "-Xshow-object", name) diff --git a/test/files/run/hashset.check b/test/files/run/hashset.check new file mode 100644 index 0000000000..9542a1ff48 --- /dev/null +++ b/test/files/run/hashset.check @@ -0,0 +1,26 @@ +*** HashSet primitives +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 + +*** HashSet Strings with null +null true +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,10,11,12,13,14,15,16,17,18,19,2,3,4,5,6,7,8,9,null +null false +0 false,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true + +*** ParHashSet primitives +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 + +*** ParHashSet Strings with null +null true +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,10,11,12,13,14,15,16,17,18,19,2,3,4,5,6,7,8,9,null +null false +0 false,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true + diff --git a/test/files/run/hashset.scala b/test/files/run/hashset.scala new file mode 100644 index 0000000000..299dce3aec --- /dev/null +++ b/test/files/run/hashset.scala @@ -0,0 +1,48 @@ +import scala.collection.generic.{Growable, Shrinkable} +import scala.collection.GenSet +import scala.collection.mutable.FlatHashTable +import scala.collection.mutable.HashSet +import scala.collection.parallel.mutable.ParHashSet + +object Test extends App { + test(new Creator{ + def create[A] = new HashSet[A] + def hashSetType = "HashSet" + }) + + test(new Creator{ + def create[A] = new ParHashSet[A] + def hashSetType = "ParHashSet" + }) + + + def test(creator : Creator) { + println("*** " + creator.hashSetType + " primitives") + val h1 = creator.create[Int] + for (i <- 0 until 20) h1 += i + println((for (i <- 0 until 20) yield i + " " + (h1 contains i)).toList.sorted mkString(",")) + println((for (i <- 20 until 40) yield i + " " + (h1 contains i)).toList.sorted mkString(",")) + println(h1.toList.sorted mkString ",") + println + + println("*** " + creator.hashSetType + " Strings with null") + val h2 = creator.create[String] + h2 += null + for (i <- 0 until 20) h2 += "" + i + println("null " + (h2 contains null)) + println((for (i <- 0 until 20) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println((for (i <- 20 until 40) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println((h2.toList map {x => "" + x}).sorted mkString ",") + + h2 -= null + h2 -= "" + 0 + println("null " + (h2 contains null)) + println((for (i <- 0 until 20) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println + } + + trait Creator { + def create[A] : GenSet[A] with Cloneable with FlatHashTable[A] with Growable[A] with Shrinkable[A] + def hashSetType : String + } +}
\ No newline at end of file diff --git a/test/files/run/hashsetremove.check b/test/files/run/hashsetremove.check new file mode 100644 index 0000000000..8de9826895 --- /dev/null +++ b/test/files/run/hashsetremove.check @@ -0,0 +1,6 @@ +remove 0 should be false, was false +contains 1 should be true, was true +remove 1 should be true, was true +contains 1 should be false, was false +remove 1 should be false, was false +contains 1 should be false, was false diff --git a/test/files/run/hashsetremove.scala b/test/files/run/hashsetremove.scala new file mode 100644 index 0000000000..7b82a9909b --- /dev/null +++ b/test/files/run/hashsetremove.scala @@ -0,0 +1,13 @@ +import scala.collection.mutable.HashSet + + +object Test extends App { + val h = new HashSet[Int] + h += 1 + println(s"remove 0 should be false, was ${h remove 0}") + println(s"contains 1 should be true, was ${h contains 1}") + println(s"remove 1 should be true, was ${h remove 1}") + println(s"contains 1 should be false, was ${h contains 1}") + println(s"remove 1 should be false, was ${h remove 1}") + println(s"contains 1 should be false, was ${h contains 1}") + }
\ No newline at end of file diff --git a/test/files/run/idempotency-this.check b/test/files/run/idempotency-this.check index 8faf703d97..88b8288adf 100644 --- a/test/files/run/idempotency-this.check +++ b/test/files/run/idempotency-this.check @@ -1,4 +1,4 @@ List() List.apply[String]("") -Apply(TypeApply(Select(Ident(scala.collection.immutable.List), newTermName("apply")), List(TypeTree().setOriginal(Select(Ident(scala.Predef), newTypeName("String"))))), List(Literal(Constant("")))) +Apply(TypeApply(Select(Ident(scala.collection.immutable.List), TermName("apply")), List(TypeTree().setOriginal(Select(Ident(scala.Predef), TypeName("String"))))), List(Literal(Constant("")))) List() diff --git a/test/files/run/impconvtimes.scala b/test/files/run/impconvtimes.scala index 8c5ab61779..477a16a890 100644 --- a/test/files/run/impconvtimes.scala +++ b/test/files/run/impconvtimes.scala @@ -1,3 +1,5 @@ +import scala.language.implicitConversions + object Test { abstract class Unit object NoUnit extends Unit diff --git a/test/files/run/implicits.scala b/test/files/run/implicits.scala index a30f60f6d0..5681a9d484 100644 --- a/test/files/run/implicits.scala +++ b/test/files/run/implicits.scala @@ -1,3 +1,5 @@ +import scala.language.implicitConversions + object A { object B { implicit def int2string(x: Int) = "["+x.toString+"]" diff --git a/test/files/run/indexedSeq.scala b/test/files/run/indexedSeq.scala index 9744f47f63..29a8be701d 100644 --- a/test/files/run/indexedSeq.scala +++ b/test/files/run/indexedSeq.scala @@ -1,10 +1,11 @@ object Test { - import scala.collection.{ mutable, immutable, generic } + import scala.collection.immutable def checkIdentity[A](xs: immutable.IndexedSeq[A]) = assert(xs.toIndexedSeq eq xs) def main(args: Array[String]): Unit = { - checkIdentity(immutable.Vector(1 to 10: _*)) - checkIdentity(1 to 10 toIndexedSeq) + def r = 1 to 10 + checkIdentity(immutable.Vector(r: _*)) + checkIdentity(r.toIndexedSeq) } } diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check index 50a9d87557..7c885d2cc9 100644 --- a/test/files/run/inline-ex-handlers.check +++ b/test/files/run/inline-ex-handlers.check @@ -21,8 +21,8 @@ 92 RETURN(REF(class Object)) @@ -246,3 +245,3 @@ startBlock: 1 -- blocks: [1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18] -+ blocks: [1,2,3,4,5,6,8,10,11,12,13,14,15,16,17,18] +- blocks: [1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18] ++ blocks: [1,2,3,4,5,6,8,11,12,13,14,15,16,17,18] @@ -257,5 +256,2 @@ 92 SCOPE_ENTER value x1 @@ -72,8 +72,8 @@ 106 CALL_METHOD scala.Predef.println (dynamic) @@ -518,3 +517,3 @@ startBlock: 1 -- blocks: [1,2,3,4,6,7,8,9,10] -+ blocks: [1,2,3,4,6,7,8,9,10,11,12,13] +- blocks: [1,2,3,4,6,7,9,10] ++ blocks: [1,3,4,6,7,9,10,11,12,13] @@ -547,4 +546,9 @@ 306 CALL_METHOD MyException.<init> (static-instance) @@ -104,8 +104,12 @@ + ? JUMP 13 + 3: -@@ -575,2 +586,14 @@ +@@ -573,5 +584,14 @@ + 310 CALL_METHOD scala.Predef.println (dynamic) +- 310 JUMP 2 ++ 300 RETURN(UNIT) +- 2: + 13: + 310 LOAD_MODULE object Predef + 310 CALL_PRIMITIVE(StartConcat) @@ -116,44 +120,42 @@ + 310 CALL_PRIMITIVE(StringConcat(REF(class String))) + 310 CALL_PRIMITIVE(EndConcat) + 310 CALL_METHOD scala.Predef.println (dynamic) -+ 310 JUMP 2 -+ - 2: -@@ -583,6 +606,6 @@ + 300 RETURN(UNIT) +@@ -583,6 +603,6 @@ with finalizer: null -- catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6 -+ catch (Throwable) in ArrayBuffer(7, 8, 9, 10, 11) starting at: 6 +- catch (Throwable) in ArrayBuffer(7, 9, 10) starting at: 6 ++ catch (Throwable) in ArrayBuffer(7, 9, 10, 11) starting at: 6 consisting of blocks: List(6) with finalizer: null -- catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10) starting at: 3 -+ catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10, 11, 12) starting at: 3 +- catch (Throwable) in ArrayBuffer(4, 6, 7, 9, 10) starting at: 3 ++ catch (Throwable) in ArrayBuffer(4, 6, 7, 9, 10, 11, 12) starting at: 3 consisting of blocks: List(3) -@@ -618,3 +641,3 @@ +@@ -618,3 +638,3 @@ startBlock: 1 -- blocks: [1,2,3,4,5,6,7,9,10] -+ blocks: [1,2,3,4,5,6,7,9,10,11,12] +- blocks: [1,3,4,5,6,8,9] ++ blocks: [1,3,4,5,6,8,9,10,11] -@@ -642,4 +665,10 @@ +@@ -642,4 +662,10 @@ 78 CALL_METHOD java.lang.IllegalArgumentException.<init> (static-instance) - 78 THROW(IllegalArgumentException) + ? STORE_LOCAL(value e) -+ ? JUMP 11 ++ ? JUMP 10 -+ 11: ++ 10: + 81 LOAD_LOCAL(value e) + ? STORE_LOCAL(variable exc1) -+ ? JUMP 12 ++ ? JUMP 11 + - 9: -@@ -671,3 +700,4 @@ + 8: +@@ -668,3 +694,4 @@ 81 LOAD_LOCAL(value e) - 81 THROW(Exception) + ? STORE_LOCAL(variable exc1) -+ ? JUMP 12 ++ ? JUMP 11 -@@ -688,2 +718,15 @@ +@@ -685,2 +712,15 @@ -+ 12: ++ 11: + 83 LOAD_MODULE object Predef + 83 CONSTANT("finally") + 83 CALL_METHOD scala.Predef.println (dynamic) @@ -167,33 +169,33 @@ + 84 THROW(Throwable) + } -@@ -693,3 +736,3 @@ +@@ -690,3 +730,3 @@ with finalizer: null -- catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3 -+ catch (<none>) in ArrayBuffer(4, 6, 7, 9, 11) starting at: 3 +- catch (<none>) in ArrayBuffer(4, 5, 6, 8) starting at: 3 ++ catch (<none>) in ArrayBuffer(4, 5, 6, 8, 10) starting at: 3 consisting of blocks: List(3) -@@ -717,5 +760,5 @@ +@@ -714,5 +754,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, variable result, value ex6, variable exc2, value x4, value x5, value message, value x, value ex6, value x4, value x5, value message, value x + locals: value args, variable result, value ex6, variable exc2, value x4, value x5, value x, value ex6, value x4, value x5, value x startBlock: 1 -- blocks: [1,2,3,4,5,6,9,11,14,15,16,19,21,22,24,25] -+ blocks: [1,2,3,4,5,6,9,11,14,15,16,19,21,22,24,25,26,27,28] +- blocks: [1,3,4,5,6,9,13,14,15,18,20,21,23,24] ++ blocks: [1,3,4,5,6,9,13,14,15,18,20,21,23,24,25,26,27] -@@ -743,4 +786,11 @@ +@@ -740,4 +780,11 @@ 172 CALL_METHOD MyException.<init> (static-instance) - 172 THROW(MyException) + ? STORE_LOCAL(value ex6) -+ ? JUMP 26 ++ ? JUMP 25 -+ 26: ++ 25: + 170 LOAD_LOCAL(value ex6) + 170 STORE_LOCAL(value x4) + 170 SCOPE_ENTER value x4 -+ 170 JUMP 15 ++ 170 JUMP 14 + - 24: -@@ -786,8 +836,5 @@ + 23: +@@ -780,8 +827,5 @@ 175 SCOPE_ENTER value x5 - 175 LOAD_LOCAL(value x5) - 175 CALL_METHOD MyException.message (dynamic) @@ -204,7 +206,7 @@ + ? LOAD_LOCAL(value x5) + 176 CALL_METHOD MyException.message (dynamic) 176 CALL_METHOD scala.Predef.println (dynamic) -@@ -795,5 +842,7 @@ +@@ -789,5 +833,7 @@ 177 DUP(REF(class MyException)) - 177 LOAD_LOCAL(value message) + ? LOAD_LOCAL(value x5) @@ -212,24 +214,24 @@ 177 CALL_METHOD MyException.<init> (static-instance) - 177 THROW(MyException) + ? STORE_LOCAL(value ex6) -+ ? JUMP 27 ++ ? JUMP 26 -@@ -801,3 +850,4 @@ +@@ -795,3 +841,4 @@ 170 LOAD_LOCAL(value ex6) - 170 THROW(Throwable) + ? STORE_LOCAL(value ex6) -+ ? JUMP 27 ++ ? JUMP 26 -@@ -811,2 +861,8 @@ +@@ -805,2 +852,8 @@ -+ 27: ++ 26: + 169 LOAD_LOCAL(value ex6) + 169 STORE_LOCAL(value x4) + 169 SCOPE_ENTER value x4 + 169 JUMP 5 + 5: -@@ -821,8 +877,5 @@ +@@ -815,8 +868,5 @@ 180 SCOPE_ENTER value x5 - 180 LOAD_LOCAL(value x5) - 180 CALL_METHOD MyException.message (dynamic) @@ -240,7 +242,7 @@ + ? LOAD_LOCAL(value x5) + 181 CALL_METHOD MyException.message (dynamic) 181 CALL_METHOD scala.Predef.println (dynamic) -@@ -830,5 +883,7 @@ +@@ -824,5 +874,7 @@ 182 DUP(REF(class MyException)) - 182 LOAD_LOCAL(value message) + ? LOAD_LOCAL(value x5) @@ -248,17 +250,17 @@ 182 CALL_METHOD MyException.<init> (static-instance) - 182 THROW(MyException) + ? STORE_LOCAL(variable exc2) -+ ? JUMP 28 ++ ? JUMP 27 -@@ -836,3 +891,4 @@ +@@ -830,3 +882,4 @@ 169 LOAD_LOCAL(value ex6) - 169 THROW(Throwable) + ? STORE_LOCAL(variable exc2) -+ ? JUMP 28 ++ ? JUMP 27 -@@ -853,2 +909,15 @@ +@@ -847,2 +900,15 @@ -+ 28: ++ 27: + 184 LOAD_MODULE object Predef + 184 CONSTANT("finally") + 184 CALL_METHOD scala.Predef.println (dynamic) @@ -272,16 +274,16 @@ + 185 THROW(Throwable) + } -@@ -858,6 +927,6 @@ +@@ -852,6 +918,6 @@ with finalizer: null -- catch (Throwable) in ArrayBuffer(14, 15, 16, 19, 21, 22, 24) starting at: 4 -+ catch (Throwable) in ArrayBuffer(14, 15, 16, 19, 21, 22, 24, 26) starting at: 4 - consisting of blocks: List(9, 6, 5, 4) +- catch (Throwable) in ArrayBuffer(13, 14, 15, 18, 20, 21, 23) starting at: 4 ++ catch (Throwable) in ArrayBuffer(13, 14, 15, 18, 20, 21, 23, 25) starting at: 4 + consisting of blocks: List(9, 8, 6, 5, 4) with finalizer: null -- catch (<none>) in ArrayBuffer(4, 5, 6, 9, 14, 15, 16, 19, 21, 22, 24) starting at: 3 -+ catch (<none>) in ArrayBuffer(4, 5, 6, 9, 14, 15, 16, 19, 21, 22, 24, 26, 27) starting at: 3 +- catch (<none>) in ArrayBuffer(4, 5, 6, 9, 13, 14, 15, 18, 20, 21, 23) starting at: 3 ++ catch (<none>) in ArrayBuffer(4, 5, 6, 9, 13, 14, 15, 18, 20, 21, 23, 25, 26) starting at: 3 consisting of blocks: List(3) -@@ -885,5 +954,5 @@ +@@ -879,5 +945,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, variable result, value e, value ex6, value x4, value x5, value message, value x + locals: value args, variable result, value e, value ex6, value x4, value x5, value x @@ -289,7 +291,7 @@ - blocks: [1,2,3,6,7,8,11,13,14,16] + blocks: [1,2,3,6,7,8,11,13,14,16,17] -@@ -911,4 +980,11 @@ +@@ -905,4 +971,11 @@ 124 CALL_METHOD MyException.<init> (static-instance) - 124 THROW(MyException) + ? STORE_LOCAL(value ex6) @@ -302,7 +304,7 @@ + 122 JUMP 7 + 16: -@@ -936,8 +1012,5 @@ +@@ -930,8 +1003,5 @@ 127 SCOPE_ENTER value x5 - 127 LOAD_LOCAL(value x5) - 127 CALL_METHOD MyException.message (dynamic) @@ -313,12 +315,12 @@ + ? LOAD_LOCAL(value x5) + 127 CALL_METHOD MyException.message (dynamic) 127 CALL_METHOD scala.Predef.println (dynamic) -@@ -970,3 +1043,3 @@ +@@ -964,3 +1034,3 @@ with finalizer: null - catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 13, 14, 16) starting at: 3 + catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 13, 14, 16, 17) starting at: 3 consisting of blocks: List(3) -@@ -994,5 +1067,5 @@ +@@ -988,5 +1058,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, variable result, value ex6, value x4, value x5, value message, value x, value e + locals: value args, variable result, value ex6, value x4, value x5, value x, value e @@ -326,7 +328,7 @@ - blocks: [1,2,3,4,5,8,12,13,14,16] + blocks: [1,2,3,5,8,12,13,14,16,17] -@@ -1020,4 +1093,13 @@ +@@ -1014,4 +1084,13 @@ 148 CALL_METHOD MyException.<init> (static-instance) - 148 THROW(MyException) + ? STORE_LOCAL(value ex6) @@ -341,13 +343,13 @@ + 154 CZJUMP (BOOL)NE ? 5 : 8 + 16: -@@ -1041,5 +1123,2 @@ +@@ -1035,5 +1114,2 @@ 145 SCOPE_ENTER value x4 - 145 JUMP 4 - - 4: 154 LOAD_LOCAL(value x4) -@@ -1053,8 +1132,5 @@ +@@ -1047,8 +1123,5 @@ 154 SCOPE_ENTER value x5 - 154 LOAD_LOCAL(value x5) - 154 CALL_METHOD MyException.message (dynamic) @@ -358,12 +360,12 @@ + ? LOAD_LOCAL(value x5) + 154 CALL_METHOD MyException.message (dynamic) 154 CALL_METHOD scala.Predef.println (dynamic) -@@ -1275,3 +1351,3 @@ +@@ -1269,3 +1342,3 @@ startBlock: 1 - blocks: [1,2,3,4,5,7] + blocks: [1,2,3,4,5,7,8] -@@ -1299,4 +1375,11 @@ +@@ -1293,4 +1366,11 @@ 38 CALL_METHOD java.lang.IllegalArgumentException.<init> (static-instance) - 38 THROW(IllegalArgumentException) + ? STORE_LOCAL(value e) @@ -376,7 +378,7 @@ + 42 JUMP 2 + 7: -@@ -1346,5 +1429,5 @@ +@@ -1340,5 +1420,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, variable result, value ex6, value x4, value x5, value message, value x + locals: value args, variable result, value ex6, value x4, value x5, value x @@ -384,13 +386,13 @@ - blocks: [1,2,3,4,5,8,10,11,13,14,16] + blocks: [1,2,3,5,8,10,11,13,14,16,17] -@@ -1372,3 +1455,4 @@ +@@ -1366,3 +1446,4 @@ 203 CALL_METHOD MyException.<init> (static-instance) - 203 THROW(MyException) + ? STORE_LOCAL(value ex6) + ? JUMP 17 -@@ -1392,4 +1476,13 @@ +@@ -1386,4 +1467,13 @@ 209 CALL_METHOD MyException.<init> (static-instance) - 209 THROW(MyException) + ? STORE_LOCAL(value ex6) @@ -405,13 +407,13 @@ + 212 CZJUMP (BOOL)NE ? 5 : 8 + 16: -@@ -1405,5 +1498,2 @@ +@@ -1399,5 +1489,2 @@ 200 SCOPE_ENTER value x4 - 200 JUMP 4 - - 4: 212 LOAD_LOCAL(value x4) -@@ -1417,8 +1507,5 @@ +@@ -1411,8 +1498,5 @@ 212 SCOPE_ENTER value x5 - 212 LOAD_LOCAL(value x5) - 212 CALL_METHOD MyException.message (dynamic) @@ -422,12 +424,12 @@ + ? LOAD_LOCAL(value x5) + 213 CALL_METHOD MyException.message (dynamic) 213 CALL_METHOD scala.Predef.println (dynamic) -@@ -1466,3 +1553,3 @@ +@@ -1460,3 +1544,3 @@ startBlock: 1 - blocks: [1,2,3,4,5,7] + blocks: [1,2,3,4,5,7,8] -@@ -1490,4 +1577,11 @@ +@@ -1484,4 +1568,11 @@ 58 CALL_METHOD java.lang.IllegalArgumentException.<init> (static-instance) - 58 THROW(IllegalArgumentException) + ? STORE_LOCAL(value e) @@ -440,12 +442,12 @@ + 62 JUMP 2 + 7: -@@ -1539,3 +1633,3 @@ +@@ -1533,3 +1624,3 @@ startBlock: 1 -- blocks: [1,2,3,4] -+ blocks: [1,2,3,4,5] +- blocks: [1,3,4] ++ blocks: [1,3,4,5] -@@ -1559,4 +1653,9 @@ +@@ -1553,4 +1644,9 @@ 229 CALL_METHOD MyException.<init> (static-instance) - 229 THROW(MyException) + ? JUMP 5 @@ -456,20 +458,20 @@ + 228 THROW(Throwable) + 3: -@@ -1565,3 +1664,3 @@ +@@ -1559,3 +1655,3 @@ 228 MONITOR_EXIT - ? THROW(Throwable) + 228 THROW(Throwable) -@@ -1593,5 +1692,5 @@ +@@ -1587,5 +1683,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, variable result, variable monitor2, variable monitorResult1 + locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1 startBlock: 1 -- blocks: [1,2,3,4] -+ blocks: [1,2,3,4,5] +- blocks: [1,3,4] ++ blocks: [1,3,4,5] -@@ -1618,4 +1717,12 @@ +@@ -1612,4 +1708,12 @@ 245 CALL_METHOD MyException.<init> (static-instance) - 245 THROW(MyException) + ? STORE_LOCAL(value exception$1) @@ -483,7 +485,7 @@ + 244 THROW(Throwable) + 3: -@@ -1624,3 +1731,3 @@ +@@ -1618,3 +1722,3 @@ 244 MONITOR_EXIT - ? THROW(Throwable) + 244 THROW(Throwable) diff --git a/test/files/run/inline-ex-handlers.scala b/test/files/run/inline-ex-handlers.scala index a96b938e13..33e794b940 100644 --- a/test/files/run/inline-ex-handlers.scala +++ b/test/files/run/inline-ex-handlers.scala @@ -1,7 +1,7 @@ import scala.tools.partest.IcodeTest object Test extends IcodeTest { - override def printIcodeAfterPhase = "inlineExceptionHandlers" + override def printIcodeAfterPhase = "inlinehandlers" } import scala.util.Random._ diff --git a/test/files/run/inner-obj-auto.scala b/test/files/run/inner-obj-auto.scala index aa2e29326f..35ca56ba3e 100644 --- a/test/files/run/inner-obj-auto.scala +++ b/test/files/run/inner-obj-auto.scala @@ -25,7 +25,7 @@ class Class2_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -54,7 +54,7 @@ object Object3_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -83,7 +83,7 @@ trait Trait4_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -112,7 +112,7 @@ class Class6_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -141,7 +141,7 @@ object Object7_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -170,7 +170,7 @@ trait Trait8_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -199,7 +199,7 @@ class Class10_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -228,7 +228,7 @@ object Object11_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -257,7 +257,7 @@ trait Trait12_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -286,7 +286,7 @@ class Class14_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -315,7 +315,7 @@ object Object15_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -344,7 +344,7 @@ trait Trait16_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -373,7 +373,7 @@ class Class18_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -402,7 +402,7 @@ object Object19_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -431,7 +431,7 @@ trait Trait20_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -460,7 +460,7 @@ class Class22_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -489,7 +489,7 @@ object Object23_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -518,7 +518,7 @@ trait Trait24_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -548,7 +548,7 @@ class Class26_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -579,7 +579,7 @@ object Object27_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -610,7 +610,7 @@ trait Trait28_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -641,7 +641,7 @@ class Class30_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -672,7 +672,7 @@ object Object31_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -703,7 +703,7 @@ trait Trait32_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -733,7 +733,7 @@ class Class34_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -762,7 +762,7 @@ object Object35_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -791,7 +791,7 @@ trait Trait36_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -820,7 +820,7 @@ class Class38_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -849,7 +849,7 @@ object Object39_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -878,7 +878,7 @@ trait Trait40_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -907,7 +907,7 @@ class Class42_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -936,7 +936,7 @@ object Object43_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -965,7 +965,7 @@ trait Trait44_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -994,7 +994,7 @@ class Class46_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -1023,7 +1023,7 @@ object Object47_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -1052,7 +1052,7 @@ trait Trait48_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -1081,7 +1081,7 @@ class Class50_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -1110,7 +1110,7 @@ object Object51_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -1139,7 +1139,7 @@ trait Trait52_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } @@ -1172,7 +1172,7 @@ class Class54_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1205,7 +1205,7 @@ object Object55_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1238,7 +1238,7 @@ trait Trait56_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1271,7 +1271,7 @@ class Class58_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1304,7 +1304,7 @@ object Object59_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1337,7 +1337,7 @@ trait Trait60_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1370,7 +1370,7 @@ class Class62_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1403,7 +1403,7 @@ object Object63_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1436,7 +1436,7 @@ trait Trait64_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1469,7 +1469,7 @@ class Class66_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1502,7 +1502,7 @@ object Object67_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1535,7 +1535,7 @@ trait Trait68_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1568,7 +1568,7 @@ class Class70_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1601,7 +1601,7 @@ object Object71_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1634,7 +1634,7 @@ trait Trait72_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1667,7 +1667,7 @@ class Class74_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1700,7 +1700,7 @@ object Object75_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1733,7 +1733,7 @@ trait Trait76_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1767,7 +1767,7 @@ class Class78_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1802,7 +1802,7 @@ object Object79_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1837,7 +1837,7 @@ trait Trait80_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1872,7 +1872,7 @@ class Class82_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1907,7 +1907,7 @@ object Object83_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1942,7 +1942,7 @@ trait Trait84_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -1976,7 +1976,7 @@ class Class90_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } @@ -2009,7 +2009,7 @@ trait Trait92_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } diff --git a/test/files/run/interop_classtags_are_classmanifests.scala b/test/files/run/interop_classtags_are_classmanifests.scala index 91b9d89c6e..62d85c3ce3 100644 --- a/test/files/run/interop_classtags_are_classmanifests.scala +++ b/test/files/run/interop_classtags_are_classmanifests.scala @@ -1,5 +1,6 @@ -import scala.reflect.{ClassTag, classTag} +import scala.reflect.ClassTag +@deprecated("Suppress warnings", since="2.11") object Test extends App { def classTagIsClassManifest[T: ClassTag] = { println(classManifest[T]) @@ -8,4 +9,4 @@ object Test extends App { classTagIsClassManifest[Int] classTagIsClassManifest[String] classTagIsClassManifest[Array[Int]] -}
\ No newline at end of file +} diff --git a/test/files/run/interop_manifests_are_classtags.scala b/test/files/run/interop_manifests_are_classtags.scala index 03479e527a..705038ece7 100644 --- a/test/files/run/interop_manifests_are_classtags.scala +++ b/test/files/run/interop_manifests_are_classtags.scala @@ -1,5 +1,6 @@ import scala.reflect.{ClassTag, classTag} +@deprecated("Suppress warnings", since="2.11") object Test extends App { def classManifestIsClassTag[T: ClassManifest] = { println(classTag[T]) @@ -20,4 +21,4 @@ object Test extends App { manifestIsClassTag[Int] manifestIsClassTag[String] manifestIsClassTag[Array[Int]] -}
\ No newline at end of file +} diff --git a/test/files/run/interpolationArgs.scala b/test/files/run/interpolationArgs.scala index eb13767907..ffb254b63f 100644 --- a/test/files/run/interpolationArgs.scala +++ b/test/files/run/interpolationArgs.scala @@ -1,5 +1,5 @@ object Test extends App { - try { scala.StringContext("p1", "p2", "p3").s("e1") } catch { case ex => println(ex) } - try { scala.StringContext("p1").s("e1") } catch { case ex => println(ex) } + try { scala.StringContext("p1", "p2", "p3").s("e1") } catch { case ex: Throwable => println(ex) } + try { scala.StringContext("p1").s("e1") } catch { case ex: Throwable => println(ex) } } diff --git a/test/files/run/interpolationMultiline2.scala b/test/files/run/interpolationMultiline2.scala index f6a682c3ce..2de4c4b22e 100644 --- a/test/files/run/interpolationMultiline2.scala +++ b/test/files/run/interpolationMultiline2.scala @@ -2,14 +2,15 @@ object Test extends App { def test1(n: Int) = { val old = "old" - try { println(s"""Bob is ${s"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(s"""Bob is ${f"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(f"""Bob is ${s"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(f"""Bob is ${f"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(f"""Bob is ${f"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(f"""Bob is ${s"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(s"""Bob is ${f"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(s"""Bob is ${s"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) } + val catcher: PartialFunction[Throwable, Unit] = { case e => println(e) } + try { println(s"""Bob is ${s"$n"} years ${s"$old"}!""") } catch catcher + try { println(s"""Bob is ${f"$n"} years ${s"$old"}!""") } catch catcher + try { println(f"""Bob is ${s"$n"} years ${s"$old"}!""") } catch catcher + try { println(f"""Bob is ${f"$n"} years ${s"$old"}!""") } catch catcher + try { println(f"""Bob is ${f"$n%2d"} years ${s"$old"}!""") } catch catcher + try { println(f"""Bob is ${s"$n%2d"} years ${s"$old"}!""") } catch catcher + try { println(s"""Bob is ${f"$n%2d"} years ${s"$old"}!""") } catch catcher + try { println(s"""Bob is ${s"$n%2d"} years ${s"$old"}!""") } catch catcher } test1(1) diff --git a/test/files/run/io-position.scala b/test/files/run/io-position.scala index 1093704fa4..b227846fb4 100644 --- a/test/files/run/io-position.scala +++ b/test/files/run/io-position.scala @@ -1,7 +1,5 @@ object Test { - Console.setErr(Console.out) - - def main(args: Array[String]): Unit = { + def main(args: Array[String]): Unit = Console.withErr(Console.out) { try { xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<foo>"), false).document() } catch { diff --git a/test/files/run/is-valid-num.scala b/test/files/run/is-valid-num.scala index 402eff99d6..19a3b9c7c0 100644 --- a/test/files/run/is-valid-num.scala +++ b/test/files/run/is-valid-num.scala @@ -1,3 +1,6 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ object Test { def x = BigInt("10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") def y = BigDecimal("" + (Short.MaxValue + 1) + ".0") diff --git a/test/files/run/issue192.scala b/test/files/run/issue192.scala index d8db8b5816..3c3b44a8fb 100644 --- a/test/files/run/issue192.scala +++ b/test/files/run/issue192.scala @@ -1,3 +1,5 @@ +import scala.language.reflectiveCalls + object Test extends App { def f1(p: Any{def unary_+ : Int}) = +p diff --git a/test/files/run/iterator-concat.check b/test/files/run/iterator-concat.check new file mode 100644 index 0000000000..23835b07ae --- /dev/null +++ b/test/files/run/iterator-concat.check @@ -0,0 +1,4 @@ +100 +1000 +10000 +100000 diff --git a/test/files/run/iterator-concat.scala b/test/files/run/iterator-concat.scala new file mode 100644 index 0000000000..f11363410f --- /dev/null +++ b/test/files/run/iterator-concat.scala @@ -0,0 +1,15 @@ +object Test { + // Create `size` Function0s, each of which evaluates to an Iterator + // which produces 1. Then fold them over ++ to get a single iterator, + // which should sum to "size". + def mk(size: Int): Iterator[Int] = { + val closures = (1 to size).toList.map(x => (() => Iterator(1))) + closures.foldLeft(Iterator.empty: Iterator[Int])((res, f) => res ++ f()) + } + def main(args: Array[String]): Unit = { + println(mk(100).sum) + println(mk(1000).sum) + println(mk(10000).sum) + println(mk(100000).sum) + } +} diff --git a/test/files/run/iterator-from.scala b/test/files/run/iterator-from.scala new file mode 100644 index 0000000000..fb33f6b5ed --- /dev/null +++ b/test/files/run/iterator-from.scala @@ -0,0 +1,71 @@ +/* This file tests iteratorFrom, keysIteratorFrom, and valueIteratorFrom on various sorted sets and maps + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ + +import scala.util.{Random => R} +import scala.collection._ +import scala.math.Ordered + +object Test extends App { + val maxLength = 25 + val maxKey = 50 + val maxValue = 50 + + def testSet[A <% Ordered[A]](set: SortedSet[A], list: List[A]) { + val distinctSorted = list.distinct.sorted + assertEquals("Set size wasn't the same as list sze", set.size, distinctSorted.size) + + for(key <- distinctSorted) { + val clazz = set.getClass + val iteratorFrom = (set iteratorFrom key).toList + check(clazz, list, s"set iteratorFrom $key", s"(set from $key).iterator", iteratorFrom, (set from key).iterator.toList) + check(clazz, list, s"set.iteratorFrom $key", s"distinctSorted dropWhile (_ < $key)", iteratorFrom, distinctSorted dropWhile (_ < key)) + check(clazz, list, s"set iteratorFrom $key", s"set keysIterator from $key", iteratorFrom, (set keysIteratorFrom key).toList) + } + } + + def testMap[A <% Ordered[A], B](map: SortedMap[A, B], list: List[(A, B)]) { + val distinctSorted = distinctByKey(list).sortBy(_._1) + assertEquals("Map size wasn't the same as list sze", map.size, distinctSorted.size) + + for(keyValue <- distinctSorted) { + val key = keyValue._1 + val clazz = map.getClass + val iteratorFrom = (map iteratorFrom key).toList + check(clazz, list, s"map iteratorFrom $key", s"(map from $key).iterator", iteratorFrom, (map from key).iterator.toList) + check(clazz, list, s"map iteratorFrom $key", s"distinctSorted dropWhile (_._1 < $key)", iteratorFrom, distinctSorted dropWhile (_._1 < key)) + check(clazz, list, s"map iteratorFrom $key map (_._1)", s"map keysIteratorFrom $key", iteratorFrom map (_._1), (map keysIteratorFrom key).toList) + check(clazz, list, s"map iteratorFrom $key map (_._2)", s"map valuesIteratorFrom $key", iteratorFrom map (_._2), (map valuesIteratorFrom key).toList) + } + } + + def check[A](clazz: Class[_], list: List[_], m1: String, m2: String, l1: List[A], l2: List[A]) { + assertEquals(s"$clazz: `$m1` didn't match `$m2` on list $list", l1, l2) + } + + def assertEquals[A](msg: String, x: A, y: A) { + assert(x == y, s"$msg\n1: $x\n2: $y") + } + + def distinctByKey[A,B](list: List[(A, B)]) : List[(A,B)] = list.groupBy(_._1).map(_._2.last).toList + + object Weekday extends Enumeration { + type Weekday = Value + val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value + } + + 0 until maxLength foreach {length => + val keyValues = (0 until length map {_ => (R nextInt maxKey, R nextInt maxValue)}).toList + val keys = keyValues map (_._2) + testSet(immutable.BitSet(keys:_*), keys) + testSet(immutable.TreeSet(keys:_*), keys) + testSet(mutable.TreeSet(keys:_*), keys) + val days = keys map {n => Weekday(n % Weekday.values.size)} + testSet(Weekday.ValueSet(days:_*), days) + + val treeMap = immutable.TreeMap(keyValues:_*) + testMap(treeMap, keyValues) + testMap(treeMap.filterKeys(_ % 2 == 0), keyValues filter (_._1 % 2 == 0)) + testMap(treeMap mapValues (_ + 1), keyValues map {case (k,v) => (k, v + 1)}) + } +} diff --git a/test/files/run/iterator-iterate-lazy.scala b/test/files/run/iterator-iterate-lazy.scala index 73886f192b..92b170062e 100644 --- a/test/files/run/iterator-iterate-lazy.scala +++ b/test/files/run/iterator-iterate-lazy.scala @@ -1,5 +1,5 @@ object Test { def main(args: Array[String]): Unit = { - Iterator.iterate(1 to 5 toList)(_.tail).takeWhile(_.nonEmpty).map(_.head).toList + Iterator.iterate((1 to 5).toList)(_.tail).takeWhile(_.nonEmpty).map(_.head).toList } } diff --git a/test/files/run/iterators.scala b/test/files/run/iterators.scala index b85291cd72..e2d0f93a05 100644 --- a/test/files/run/iterators.scala +++ b/test/files/run/iterators.scala @@ -4,6 +4,8 @@ //############################################################################ +import scala.language.postfixOps + object Test { def check_from: Int = { diff --git a/test/files/run/json.scala b/test/files/run/json.scala index a81f12564c..36e86ac5bb 100644 --- a/test/files/run/json.scala +++ b/test/files/run/json.scala @@ -1,13 +1,17 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import scala.util.parsing.json._ import scala.collection.immutable.TreeMap +@deprecated("Suppress warnings", since="2.11") object Test extends App { /* This method converts parsed JSON back into real JSON notation with objects in * sorted-key order. Not required by the spec, but it allows us to do a stable * toString comparison. */ def jsonToString(in : Any) : String = in match { case l : List[_] => "[" + l.map(jsonToString).mkString(", ") + "]" - case m : Map[String,_] => "{" + m.iterator.toList + case m : Map[String @unchecked,_] => "{" + m.iterator.toList .sortWith({ (x,y) => x._1 < y._1 }) .map({ case (k,v) => "\"" + k + "\": " + jsonToString(v) }) .mkString(", ") + "}" @@ -20,7 +24,7 @@ object Test extends App { */ def sortJSON(in : Any) : Any = in match { case l : List[_] => l.map(sortJSON) - case m : Map[String,_] => TreeMap(m.mapValues(sortJSON).iterator.toSeq : _*) + case m : Map[String @unchecked,_] => TreeMap(m.mapValues(sortJSON).iterator.toSeq : _*) // For the object versions, sort their contents, ugly casts and all... case JSONObject(data) => JSONObject(sortJSON(data).asInstanceOf[Map[String,Any]]) case JSONArray(data) => JSONArray(sortJSON(data).asInstanceOf[List[Any]]) diff --git a/test/files/run/kind-repl-command.check b/test/files/run/kind-repl-command.check new file mode 100644 index 0000000000..afa32acdae --- /dev/null +++ b/test/files/run/kind-repl-command.check @@ -0,0 +1,32 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> :kind scala.Option +scala.Option's kind is F[+A] + +scala> :k (Int, Int) => Int +scala.Function2's kind is F[-A1,-A2,+A3] + +scala> :k -v Either +scala.util.Either's kind is F[+A1,+A2] +* -(+)-> * -(+)-> * +This is a type constructor: a 1st-order-kinded type. + +scala> :k -v scala.collection.generic.ImmutableSortedMapFactory +scala.collection.generic.ImmutableSortedMapFactory's kind is X[CC[A,B] <: scala.collection.immutable.SortedMap[A,B] with scala.collection.SortedMapLike[A,B,CC[A,B]]] +(* -> * -> *(scala.collection.immutable.SortedMap[A,B] with scala.collection.SortedMapLike[A,B,CC[A,B]])) -> * +This is a type constructor that takes type constructor(s): a higher-kinded type. + +scala> :k new { def empty = false } +AnyRef{def empty: Boolean}'s kind is A + +scala> :k Nonexisting +<console>:8: error: not found: value Nonexisting + Nonexisting + ^ + +scala> + +scala> diff --git a/test/files/run/kind-repl-command.scala b/test/files/run/kind-repl-command.scala new file mode 100644 index 0000000000..df1fafb667 --- /dev/null +++ b/test/files/run/kind-repl-command.scala @@ -0,0 +1,12 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + |:kind scala.Option + |:k (Int, Int) => Int + |:k -v Either + |:k -v scala.collection.generic.ImmutableSortedMapFactory + |:k new { def empty = false } + |:k Nonexisting + """.stripMargin +} diff --git a/test/files/run/lazy-exprs.check b/test/files/run/lazy-exprs.check index e77d204251..2efb8ceb4a 100644 --- a/test/files/run/lazy-exprs.check +++ b/test/files/run/lazy-exprs.check @@ -1,3 +1,11 @@ +lazy-exprs.scala:38: warning: match may not be exhaustive. +It would fail on the following input: Some((x: String forSome x not in Z1)) + t match { + ^ +lazy-exprs.scala:62: warning: match may not be exhaustive. +It would fail on the following input: Some((x: String forSome x not in LazyField)) + t match { + ^ forced <z1> lazy val in scrutinee: ok forced <z1> diff --git a/test/files/run/lazy-locals.check b/test/files/run/lazy-locals.check index d1cc754f2c..9e88a55d18 100644 --- a/test/files/run/lazy-locals.check +++ b/test/files/run/lazy-locals.check @@ -1,3 +1,9 @@ +lazy-locals.scala:153: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + { + ^ +lazy-locals.scala:159: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + { + ^ forced lazy val q q = 10 forced lazy val t diff --git a/test/files/run/lazy-locals.scala b/test/files/run/lazy-locals.scala index aca15d0357..8d4c61be8c 100644 --- a/test/files/run/lazy-locals.scala +++ b/test/files/run/lazy-locals.scala @@ -120,7 +120,7 @@ object Test extends App { t } - /** test recursive method with lazy vals and a all vals forced */ + /** test recursive method with lazy vals and all vals forced */ def testLazyRecMany(n: Int): Int = { lazy val t = { println("forced lazy val t at n = " + n); 42 } if (n > 0) { diff --git a/test/files/run/list_map.scala b/test/files/run/list_map.scala new file mode 100755 index 0000000000..fba3aae228 --- /dev/null +++ b/test/files/run/list_map.scala @@ -0,0 +1,26 @@ +import collection.immutable.ListMap + +object Test { + def testImmutableMinus() { + val empty = ListMap.empty[Int, Int] + + val m0 = ListMap(1 -> 1, 2 -> 2) + val m1 = m0 - 3 + assert (m1 eq m0) + val m2 = m0 - 1 + assert (m2.size == 1) + val m3 = m2 - 2 + assert (m3 eq empty) + + val m4 = ListMap(1 -> 1, 2 -> 2, 3 -> 3) + val m5 = m4 - 1 + assert (m5 == ListMap(2 -> 2, 3 -> 3)) + assert (m5.toList == (2, 2)::(3, 3)::Nil) + + assert ((empty - 1) eq empty) + } + + def main(args: Array[String]) { + testImmutableMinus() + } +} diff --git a/test/files/run/lists-run.scala b/test/files/run/lists-run.scala index ccfe5bc260..5ff3ee353e 100644 --- a/test/files/run/lists-run.scala +++ b/test/files/run/lists-run.scala @@ -2,6 +2,8 @@ * * @author Stephane Micheloud */ +import scala.language.postfixOps + object Test { def main(args: Array[String]) { Test_multiset.run() // multiset operations: union, intersect, diff @@ -153,7 +155,7 @@ object Test3 { List.range(1, 10, 0) } catch { case e: IllegalArgumentException => () - case _ => throw new Error("List.range(1, 10, 0)") + case _: Throwable => throw new Error("List.range(1, 10, 0)") } assert(List.range(10, 0, -2) == List(10, 8, 6, 4, 2)) } diff --git a/test/files/run/literals.check b/test/files/run/literals.check index f53c879dea..5f948762b7 100644 --- a/test/files/run/literals.check +++ b/test/files/run/literals.check @@ -1,3 +1,4 @@ +warning: there were 18 deprecation warning(s); re-run with -deprecation for details test '\u0024' == '$' was successful test '\u005f' == '_' was successful test 65.asInstanceOf[Char] == 'A' was successful @@ -43,7 +44,6 @@ test 0x8000000000000000L == -9223372036854775808L was successful test 0xffffffffffffffffL == -1L was successful test 1e1f == 10.0f was successful -test 2.f == 2.0f was successful test .3f == 0.3f was successful test 0f == 0.0f was successful test 3.14f == 3.14f was successful @@ -53,8 +53,6 @@ test 1.asInstanceOf[Float] == 1.0 was successful test 1l.asInstanceOf[Float] == 1.0 was successful test 1e1 == 10.0 was successful -test 2. == 2.0 was successful -test 2.d == 2.0 was successful test .3 == 0.3 was successful test 0.0 == 0.0 was successful test 0d == 0.0 was successful diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala index 32bc29fda8..7676125339 100644 --- a/test/files/run/literals.scala +++ b/test/files/run/literals.scala @@ -105,7 +105,7 @@ object Test { // float check_success("1e1f == 10.0f", 1e1f, 10.0f) - check_success("2.f == 2.0f", 2.f, 2.0f) + //check_success("2.f == 2.0f", 2.f, 2.0f) check_success(".3f == 0.3f", .3f, 0.3f) check_success("0f == 0.0f", 0f, 0.0f) check_success("3.14f == 3.14f", 3.14f, 3.14f) @@ -118,8 +118,8 @@ object Test { // double check_success("1e1 == 10.0", 1e1, 10.0) - check_success("2. == 2.0", 2., 2.0) - check_success("2.d == 2.0", 2.d, 2.0) + //check_success("2. == 2.0", 2., 2.0) + //check_success("2.d == 2.0", 2.d, 2.0) check_success(".3 == 0.3", .3, 0.3) check_success("0.0 == 0.0", 0.0, 0.0) check_success("0d == 0.0", 0d, 0.0) diff --git a/test/files/run/macro-expand-tparams-bounds-a.check b/test/files/run/longmap.check index e69de29bb2..e69de29bb2 100644 --- a/test/files/run/macro-expand-tparams-bounds-a.check +++ b/test/files/run/longmap.check diff --git a/test/files/run/longmap.scala b/test/files/run/longmap.scala new file mode 100644 index 0000000000..1f18eebd31 --- /dev/null +++ b/test/files/run/longmap.scala @@ -0,0 +1,8 @@ +object Test extends App{ + import scala.collection.immutable.LongMap; + + val it = LongMap(8L -> 2, 11L -> 3, 1L -> 2, 7L -> 13); + + assert(it.firstKey == 1L); + assert(it.lastKey == 11L); +} diff --git a/test/files/run/lub-visibility.check b/test/files/run/lub-visibility.check index 3461d1bf6b..50a0cadebf 100644 --- a/test/files/run/lub-visibility.check +++ b/test/files/run/lub-visibility.check @@ -8,7 +8,8 @@ scala> // should infer List[scala.collection.immutable.Seq[Nothing]] scala> // but reverted that for SI-5534. scala> val x = List(List(), Vector()) -x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq{def dropRight(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def takeRight(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def drop(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def take(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]}]; def dropRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.Ab... +x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing] with java.io.Serializable] = List(List(), Vector()) + scala> scala> diff --git a/test/files/run/macro-abort-fresh/Macros_1.scala b/test/files/run/macro-abort-fresh/Macros_1.scala index af1e292588..415b76852f 100644 --- a/test/files/run/macro-abort-fresh/Macros_1.scala +++ b/test/files/run/macro-abort-fresh/Macros_1.scala @@ -5,7 +5,7 @@ object Impls { import c.universe._ println(c.fresh()) println(c.fresh("qwe")) - println(c.fresh(newTypeName("qwe"))) + println(c.fresh(TypeName("qwe"))) c.abort(NoPosition, "blargh") } } diff --git a/test/files/run/macro-abort-fresh/Test_2.scala b/test/files/run/macro-abort-fresh/Test_2.scala index 0b9986e9f6..61f0bdfadc 100644 --- a/test/files/run/macro-abort-fresh/Test_2.scala +++ b/test/files/run/macro-abort-fresh/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-md-mi/Impls_1.scala b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala index 646634c972..ce30366c61 100644 --- a/test/files/run/macro-basic-ma-md-mi/Impls_1.scala +++ b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala @@ -3,19 +3,19 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala index aa1e52e4aa..a601af6dde 100644 --- a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala +++ b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala @@ -3,19 +3,19 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } } diff --git a/test/files/run/macro-basic-mamd-mi/Impls_1.scala b/test/files/run/macro-basic-mamd-mi/Impls_1.scala index 061aa2d4a3..6e5983bdec 100644 --- a/test/files/run/macro-basic-mamd-mi/Impls_1.scala +++ b/test/files/run/macro-basic-mamd-mi/Impls_1.scala @@ -3,17 +3,17 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala index 0ca0be5a48..56c5252f31 100644 --- a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala +++ b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala @@ -6,7 +6,9 @@ object Impls { def refToFoo(dummy: Int) = macro refToFoo_impl def refToFoo_impl(c: Ctx)(dummy: c.Expr[Int]) = { import c.universe._ - val body = Select(Ident(newTermName("Impls")), newTermName("foo")) + val body = Select(Ident(TermName("Impls")), TermName("foo")) + val global = c.universe.asInstanceOf[scala.tools.nsc.Global] + global.analyzer.markMacroImplRef(body.asInstanceOf[global.Tree]) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-bundle.check b/test/files/run/macro-bundle.check new file mode 100644 index 0000000000..2107454960 --- /dev/null +++ b/test/files/run/macro-bundle.check @@ -0,0 +1,3 @@ +() +Int +() diff --git a/test/files/run/macro-declared-in-annotation.flags b/test/files/run/macro-bundle.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-annotation.flags +++ b/test/files/run/macro-bundle.flags diff --git a/test/files/run/macro-bundle/Impls_Macros_1.scala b/test/files/run/macro-bundle/Impls_Macros_1.scala new file mode 100644 index 0000000000..3f651c9a43 --- /dev/null +++ b/test/files/run/macro-bundle/Impls_Macros_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.macros.Context +import scala.reflect.macros.Macro + +trait Impl extends Macro { + def mono = c.literalUnit + def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString) + def weird = macro mono +} + +object Macros { + def mono = macro Impl.mono + def poly[T] = macro Impl.poly[T] +}
\ No newline at end of file diff --git a/test/files/run/macro-bundle/Test_2.scala b/test/files/run/macro-bundle/Test_2.scala new file mode 100644 index 0000000000..428f809f9d --- /dev/null +++ b/test/files/run/macro-bundle/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + println(Macros.mono) + println(Macros.poly[Int]) + println(new Impl{val c = ???}.weird) +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class/Impls_1.scala b/test/files/run/macro-declared-in-class/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-class/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-method/Impls_1.scala b/test/files/run/macro-declared-in-method/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-method/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-class/Impls_1.scala b/test/files/run/macro-declared-in-object-class/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-object-class/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-object/Impls_1.scala b/test/files/run/macro-declared-in-object-object/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-object-object/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object/Impls_1.scala b/test/files/run/macro-declared-in-object/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-object/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-package-object/Impls_1.scala b/test/files/run/macro-declared-in-package-object/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-package-object/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-refinement/Impls_1.scala b/test/files/run/macro-declared-in-refinement/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-refinement/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-trait/Impls_1.scala b/test/files/run/macro-declared-in-trait/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-trait/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-a.check b/test/files/run/macro-def-infer-return-type-a.check deleted file mode 100644 index f70d7bba4a..0000000000 --- a/test/files/run/macro-def-infer-return-type-a.check +++ /dev/null @@ -1 +0,0 @@ -42
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-a/Impls_1.scala b/test/files/run/macro-def-infer-return-type-a/Impls_1.scala deleted file mode 100644 index 52c9f9c3e9..0000000000 --- a/test/files/run/macro-def-infer-return-type-a/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx)(x: c.Expr[Int]) = x -} diff --git a/test/files/run/macro-def-infer-return-type-a/Macros_Test_2.scala b/test/files/run/macro-def-infer-return-type-a/Macros_Test_2.scala deleted file mode 100644 index 60fe9dc1c2..0000000000 --- a/test/files/run/macro-def-infer-return-type-a/Macros_Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - def foo(x: Int) = macro Impls.foo - println(foo(42)) -}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b/Impls_Macros_1.scala b/test/files/run/macro-def-infer-return-type-b/Impls_Macros_1.scala deleted file mode 100644 index 8a0f18c01b..0000000000 --- a/test/files/run/macro-def-infer-return-type-b/Impls_Macros_1.scala +++ /dev/null @@ -1,10 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T](c: Ctx)(x: c.Expr[T]) = - throw new Error("an implementation is missing") -} - -object Macros { - def foo[T](x: T) = macro Impls.foo[T] -}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b/Test_2.scala b/test/files/run/macro-def-infer-return-type-b/Test_2.scala deleted file mode 100644 index ea0fd4bbff..0000000000 --- a/test/files/run/macro-def-infer-return-type-b/Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test extends App { - import scala.reflect.runtime.universe._ - import scala.reflect.runtime.{currentMirror => cm} - import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) - try cm.mkToolBox().eval(tree) - catch { case ex: Throwable => println(ex.getMessage) } -} diff --git a/test/files/run/macro-def-infer-return-type-c.check b/test/files/run/macro-def-infer-return-type-c.check deleted file mode 100644 index f70d7bba4a..0000000000 --- a/test/files/run/macro-def-infer-return-type-c.check +++ /dev/null @@ -1 +0,0 @@ -42
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-c/Impls_1.scala b/test/files/run/macro-def-infer-return-type-c/Impls_1.scala deleted file mode 100644 index 78db67eebf..0000000000 --- a/test/files/run/macro-def-infer-return-type-c/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T](c: Ctx)(x: c.Expr[T]): c.Expr[T] = x -} diff --git a/test/files/run/macro-def-infer-return-type-c/Macros_Test_2.scala b/test/files/run/macro-def-infer-return-type-c/Macros_Test_2.scala deleted file mode 100644 index 967d16f6de..0000000000 --- a/test/files/run/macro-def-infer-return-type-c/Macros_Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - def foo[T](x: T) = macro Impls.foo[T] - println(foo(42)) -}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b.check b/test/files/run/macro-def-infer-return-type.check index ae2dc7a06f..308e881960 100644 --- a/test/files/run/macro-def-infer-return-type-b.check +++ b/test/files/run/macro-def-infer-return-type.check @@ -1,6 +1,8 @@ +42 reflective compilation has failed: exception during macro expansion: java.lang.Error: an implementation is missing - at Impls$.foo(Impls_Macros_1.scala:5) + at Impls2$.foo(Impls_1.scala:9) +42 diff --git a/test/files/run/macro-declared-in-anonymous.flags b/test/files/run/macro-def-infer-return-type.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-anonymous.flags +++ b/test/files/run/macro-def-infer-return-type.flags diff --git a/test/files/run/macro-def-infer-return-type/Impls_1.scala b/test/files/run/macro-def-infer-return-type/Impls_1.scala new file mode 100644 index 0000000000..f8636fe725 --- /dev/null +++ b/test/files/run/macro-def-infer-return-type/Impls_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.Context + +object Impls1 { + def foo(c: Context)(x: c.Expr[Int]) = x +} + +object Impls2 { + def foo[T](c: Context)(x: c.Expr[T]) = + throw new Error("an implementation is missing") +} + +object Impls3 { + def foo[T](c: Context)(x: c.Expr[T]): c.Expr[T] = x +} diff --git a/test/files/run/macro-def-infer-return-type/Macros_Test_2.scala b/test/files/run/macro-def-infer-return-type/Macros_Test_2.scala new file mode 100644 index 0000000000..f579586b7f --- /dev/null +++ b/test/files/run/macro-def-infer-return-type/Macros_Test_2.scala @@ -0,0 +1,24 @@ +object Macros1 { + def foo(x: Int) = macro Impls1.foo +} + +object Macros2 { + def foo[T](x: T) = macro Impls2.foo[T] +} + +object Macros3 { + def foo[T](x: T) = macro Impls3.foo[T] +} + +object Test extends App { + println(Macros1.foo(42)) + + import scala.reflect.runtime.universe._ + import scala.reflect.runtime.{currentMirror => cm} + import scala.tools.reflect.ToolBox + val tree = Apply(Select(Ident(TermName("Macros2")), TermName("foo")), List(Literal(Constant(42)))) + try cm.mkToolBox().eval(tree) + catch { case ex: Throwable => println(ex.getMessage) } + + println(Macros3.foo(42)) +} diff --git a/test/files/run/macro-def-path-dependent-b.check b/test/files/run/macro-def-path-dependent-b.check deleted file mode 100644 index 7658ad2c24..0000000000 --- a/test/files/run/macro-def-path-dependent-b.check +++ /dev/null @@ -1 +0,0 @@ -it works diff --git a/test/files/run/macro-def-path-dependent-c.check b/test/files/run/macro-def-path-dependent-c.check deleted file mode 100644 index 7658ad2c24..0000000000 --- a/test/files/run/macro-def-path-dependent-c.check +++ /dev/null @@ -1 +0,0 @@ -it works diff --git a/test/files/run/macro-def-path-dependent-c/Test_2.scala b/test/files/run/macro-def-path-dependent-c/Test_2.scala deleted file mode 100644 index 7dffc5107d..0000000000 --- a/test/files/run/macro-def-path-dependent-c/Test_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends App { - println("it works") -}
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d1.check b/test/files/run/macro-def-path-dependent-d1.check deleted file mode 100644 index 7658ad2c24..0000000000 --- a/test/files/run/macro-def-path-dependent-d1.check +++ /dev/null @@ -1 +0,0 @@ -it works diff --git a/test/files/run/macro-def-path-dependent-d1/Test_2.scala b/test/files/run/macro-def-path-dependent-d1/Test_2.scala deleted file mode 100644 index 7dffc5107d..0000000000 --- a/test/files/run/macro-def-path-dependent-d1/Test_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends App { - println("it works") -}
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d2.check b/test/files/run/macro-def-path-dependent-d2.check deleted file mode 100644 index 7658ad2c24..0000000000 --- a/test/files/run/macro-def-path-dependent-d2.check +++ /dev/null @@ -1 +0,0 @@ -it works diff --git a/test/files/run/macro-def-path-dependent-d2/Test_3.scala b/test/files/run/macro-def-path-dependent-d2/Test_3.scala deleted file mode 100644 index 7dffc5107d..0000000000 --- a/test/files/run/macro-def-path-dependent-d2/Test_3.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends App { - println("it works") -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-annotation.check b/test/files/run/macro-def-path-dependent.check index 7658ad2c24..7658ad2c24 100644 --- a/test/files/run/macro-declared-in-annotation.check +++ b/test/files/run/macro-def-path-dependent.check diff --git a/test/files/run/macro-declared-in-block.flags b/test/files/run/macro-def-path-dependent.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-block.flags +++ b/test/files/run/macro-def-path-dependent.flags diff --git a/test/files/run/macro-def-path-dependent-a/Test_2.scala b/test/files/run/macro-def-path-dependent/Dummy.scala index 7dffc5107d..7dffc5107d 100644 --- a/test/files/run/macro-def-path-dependent-a/Test_2.scala +++ b/test/files/run/macro-def-path-dependent/Dummy.scala diff --git a/test/files/run/macro-def-path-dependent-a/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent/Test_1.scala index 3a91e41ff9..06c15e16c9 100644 --- a/test/files/run/macro-def-path-dependent-a/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_1.scala @@ -1,3 +1,5 @@ +package test1 + import scala.reflect.macros.{Context => Ctx} trait Exprs { diff --git a/test/files/run/macro-def-path-dependent-b/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent/Test_2.scala index cf9f9ebd0e..f1e9909981 100644 --- a/test/files/run/macro-def-path-dependent-b/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_2.scala @@ -1,3 +1,5 @@ +package test2 + import scala.reflect.macros.{Context => Ctx} trait Exprs { diff --git a/test/files/run/macro-def-path-dependent-c/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent/Test_3.scala index 6cb374d9ba..9f5efe5e47 100644 --- a/test/files/run/macro-def-path-dependent-c/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_3.scala @@ -1,3 +1,5 @@ +package test3 + import scala.reflect.macros.{Context => Ctx} trait Exprs { diff --git a/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent/Test_4.scala index 69d9708b2a..3af920d739 100644 --- a/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_4.scala @@ -1,3 +1,5 @@ +package test4 + import scala.reflect.runtime.universe._ import scala.reflect.macros.Context import scala.reflect.api.Universe diff --git a/test/files/run/macro-def-path-dependent-d2/Impls_1.scala b/test/files/run/macro-def-path-dependent/Test_5.scala index 7fa9c3579e..bc32fb92de 100644 --- a/test/files/run/macro-def-path-dependent-d2/Impls_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_5.scala @@ -1,3 +1,5 @@ +package test56 + import scala.reflect.runtime.universe._ import scala.reflect.macros.Context import scala.reflect.api.Universe diff --git a/test/files/run/macro-def-path-dependent-d2/Macros_2.scala b/test/files/run/macro-def-path-dependent/Test_6.scala index 65ce4d8bd2..6267743473 100644 --- a/test/files/run/macro-def-path-dependent-d2/Macros_2.scala +++ b/test/files/run/macro-def-path-dependent/Test_6.scala @@ -1,3 +1,5 @@ +package test56 + import scala.reflect.runtime.universe._ import scala.reflect.macros.Context import scala.reflect.api.Universe diff --git a/test/files/run/macro-duplicate.check b/test/files/run/macro-duplicate.check new file mode 100644 index 0000000000..58781b719a --- /dev/null +++ b/test/files/run/macro-duplicate.check @@ -0,0 +1,3 @@ +Test_2.scala:5: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + Macros.foo + ^ diff --git a/test/files/run/macro-declared-in-class-class.flags b/test/files/run/macro-duplicate.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-class-class.flags +++ b/test/files/run/macro-duplicate.flags diff --git a/test/files/run/macro-duplicate/Impls_Macros_1.scala b/test/files/run/macro-duplicate/Impls_Macros_1.scala new file mode 100644 index 0000000000..af80147a90 --- /dev/null +++ b/test/files/run/macro-duplicate/Impls_Macros_1.scala @@ -0,0 +1,29 @@ +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = { + import c.universe._ + val Expr(Block((cdef: ClassDef) :: Nil, _)) = reify { class C { def x = 2 } } + val cdef1 = + new Transformer { + override def transform(tree: Tree): Tree = tree match { + case Template(_, _, ctor :: defs) => + val defs1 = defs collect { + case ddef @ DefDef(mods, name, tparams, vparamss, tpt, body) => + val future = Select(Select(Select(Ident(TermName("scala")), TermName("concurrent")), TermName("package")), TermName("future")) + val Future = Select(Select(Ident(TermName("scala")), TermName("concurrent")), TypeName("Future")) + val tpt1 = if (tpt.isEmpty) tpt else AppliedTypeTree(Future, List(tpt)) + val body1 = Apply(future, List(body)) + val name1 = TermName("async" + name.toString.capitalize) + DefDef(mods, name1, tparams, vparamss, tpt1, body1) + } + Template(Nil, emptyValDef, ctor +: defs ::: defs1) + case _ => + super.transform(tree) + } + } transform cdef + c.Expr[Unit](Block(cdef1 :: Nil, Literal(Constant(())))) + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-duplicate/Test_2.scala b/test/files/run/macro-duplicate/Test_2.scala new file mode 100644 index 0000000000..6dbd4382d3 --- /dev/null +++ b/test/files/run/macro-duplicate/Test_2.scala @@ -0,0 +1,6 @@ +import scala.concurrent._ +import ExecutionContext.Implicits.global + +object Test extends App { + Macros.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-enclosures.check b/test/files/run/macro-enclosures.check new file mode 100644 index 0000000000..36bb67e194 --- /dev/null +++ b/test/files/run/macro-enclosures.check @@ -0,0 +1,32 @@ +enclosingPackage = package test { + object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo + } +} +enclosingClass = object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingImpl = object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingTemplate = scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingMethod = def test = Macros.foo +enclosingDef = def test = Macros.foo diff --git a/test/files/run/macro-declared-in-class-object.flags b/test/files/run/macro-enclosures.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-class-object.flags +++ b/test/files/run/macro-enclosures.flags diff --git a/test/files/run/macro-enclosures/Impls_Macros_1.scala b/test/files/run/macro-enclosures/Impls_Macros_1.scala new file mode 100644 index 0000000000..cd54028676 --- /dev/null +++ b/test/files/run/macro-enclosures/Impls_Macros_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = c.universe.reify { + println("enclosingPackage = " + c.literal(c.enclosingPackage.toString).splice) + println("enclosingClass = " + c.literal(c.enclosingClass.toString).splice) + println("enclosingImpl = " + c.literal(c.enclosingImpl.toString).splice) + println("enclosingTemplate = " + c.literal(c.enclosingTemplate.toString).splice) + println("enclosingMethod = " + c.literal(c.enclosingMethod.toString).splice) + println("enclosingDef = " + c.literal(c.enclosingDef.toString).splice) + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-enclosures/Test_2.scala b/test/files/run/macro-enclosures/Test_2.scala new file mode 100644 index 0000000000..779fe5211e --- /dev/null +++ b/test/files/run/macro-enclosures/Test_2.scala @@ -0,0 +1,11 @@ +object Test extends App { + test.Test.test +} + +package test { + object Test { + def test = { + Macros.foo + } + } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-argument/Macros_1.scala b/test/files/run/macro-expand-implicit-argument/Macros_1.scala index d9fd5b8cb0..b2c7b4d6ca 100644 --- a/test/files/run/macro-expand-implicit-argument/Macros_1.scala +++ b/test/files/run/macro-expand-implicit-argument/Macros_1.scala @@ -41,14 +41,14 @@ object Macros { def const(x:Int) = Literal(Constant(x)) val n = as.length - val arr = newTermName("arr") + val arr = TermName("arr") - val create = Apply(Select(ct.tree, newTermName("newArray")), List(const(n))) + val create = Apply(Select(ct.tree, TermName("newArray")), List(const(n))) val arrtpe = TypeTree(implicitly[c.WeakTypeTag[Array[A]]].tpe) val valdef = ValDef(Modifiers(), arr, arrtpe, create) val updates = (0 until n).map { - i => Apply(Select(Ident(arr), newTermName("update")), List(const(i), as(i).tree)) + i => Apply(Select(Ident(arr), TermName("update")), List(const(i), as(i).tree)) } val exprs = (Seq(valdef) ++ updates ++ Seq(Ident(arr))).toList diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala index 082e6b2efe..ac1e55c9b2 100644 --- a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(x.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(x.tree)) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala index cceb038f05..aa1fc7a358 100644 --- a/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = { import c.universe._ - val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, newTermName("toInt")))) + val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, TermName("toInt")))) c.Expr[Option[Int]](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala index 81ebd63c5f..22047eeb36 100644 --- a/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala +++ b/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala @@ -1,4 +1,5 @@ object Macros { + import scala.language.implicitConversions implicit def foo(x: String): Option[Int] = macro Impls.foo } @@ -7,4 +8,4 @@ object Test extends App { println("2": Option[Int]) val s: Int = "2" getOrElse 0 println(s) -}
\ No newline at end of file +} diff --git a/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala index cceb038f05..aa1fc7a358 100644 --- a/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = { import c.universe._ - val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, newTermName("toInt")))) + val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, TermName("toInt")))) c.Expr[Option[Int]](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala index 0ff1fb80ca..0d99f32d7e 100644 --- a/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala +++ b/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala @@ -1,4 +1,7 @@ + object Macros { + import scala.language.experimental.macros + import scala.language.implicitConversions implicit def foo(x: String): Option[Int] = macro Impls.foo } @@ -6,4 +9,4 @@ object Test extends App { import Macros._ def bar[T <% Option[Int]](x: T) = println(x) println("2") -}
\ No newline at end of file +} diff --git a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala index 11e07932c3..4fddc13d68 100644 --- a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala +++ b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala @@ -3,8 +3,8 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._ - val sum = Apply(Select(x.tree, newTermName("$minus")), List(y.tree)) - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum)) + val sum = Apply(Select(x.tree, TermName("$minus")), List(y.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum)) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-generic.check b/test/files/run/macro-expand-nullary-generic.check index 42976f4baf..0470d239dc 100644 --- a/test/files/run/macro-expand-nullary-generic.check +++ b/test/files/run/macro-expand-nullary-generic.check @@ -1,6 +1,6 @@ -it works WeakTypeTag[Int] -it works WeakTypeTag[Int] -it works WeakTypeTag[Int] -it works WeakTypeTag[Int] -it works WeakTypeTag[Int] +fooNullary[Int] +fooEmpty[Int] +fooEmpty[Int] +barNullary[Int] +barEmpty[Int] kkthxbai diff --git a/test/files/run/macro-expand-nullary-generic/Impls_1.scala b/test/files/run/macro-expand-nullary-generic/Impls_1.scala index 1180c83a40..5dfdd5c539 100644 --- a/test/files/run/macro-expand-nullary-generic/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala @@ -2,14 +2,14 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def impl[T: c.WeakTypeTag](c: Ctx) = { + def impl[T: c.WeakTypeTag](c: Ctx)(meth: String) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.WeakTypeTag[T]])))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(s"$meth[${c.weakTypeOf[T]}]")))) c.Expr[Unit](body) } - def fooNullary[T: c.WeakTypeTag](c: Ctx) = impl[T](c) - def fooEmpty[T: c.WeakTypeTag](c: Ctx)() = impl[T](c) - def barNullary[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c) - def barEmpty[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c) + def fooNullary[T: c.WeakTypeTag](c: Ctx) = impl[T](c)("fooNullary") + def fooEmpty[T: c.WeakTypeTag](c: Ctx)() = impl[T](c)("fooEmpty") + def barNullary[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c)("barNullary") + def barEmpty[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c)("barEmpty") }
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-nongeneric.check b/test/files/run/macro-expand-nullary-nongeneric.check index 9ab5f3a2bc..cb7e766394 100644 --- a/test/files/run/macro-expand-nullary-nongeneric.check +++ b/test/files/run/macro-expand-nullary-nongeneric.check @@ -1,6 +1,6 @@ -it works -it works -it works -it works -it works +fooNullary +fooEmpty +fooEmpty +barNullary +barEmpty kkthxbai diff --git a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala index c6bd1cdbf1..d23c671c84 100644 --- a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala @@ -1,14 +1,15 @@ +import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def impl(c: Ctx) = { + def impl(c: Ctx)(meth: String) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(meth)))) c.Expr[Unit](body) } - def fooNullary(c: Ctx) = impl(c) - def fooEmpty(c: Ctx)() = impl(c) - def barNullary(c: Ctx)(x: c.Expr[Int]) = impl(c) - def barEmpty(c: Ctx)(x: c.Expr[Int])() = impl(c) + def fooNullary(c: Ctx) = impl(c)("fooNullary") + def fooEmpty(c: Ctx)() = impl(c)("fooEmpty") + def barNullary(c: Ctx)(x: c.Expr[Int]) = impl(c)("barNullary") + def barEmpty(c: Ctx)(x: c.Expr[Int])() = impl(c)("barEmpty") }
\ No newline at end of file diff --git a/test/files/run/macro-expand-overload/Impls_1.scala b/test/files/run/macro-expand-overload/Impls_1.scala index f7c240d9ca..1c672f6040 100644 --- a/test/files/run/macro-expand-overload/Impls_1.scala +++ b/test/files/run/macro-expand-overload/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { import c.{prefix => prefix} import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-override/Impls_1.scala b/test/files/run/macro-expand-override/Impls_1.scala index ec93dd4111..69ef57d18d 100644 --- a/test/files/run/macro-expand-override/Impls_1.scala +++ b/test/files/run/macro-expand-override/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { import c.{prefix => prefix} import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-recursive/Impls_1.scala b/test/files/run/macro-expand-recursive/Impls_1.scala index 61db5c4a9b..47dd398454 100644 --- a/test/files/run/macro-expand-recursive/Impls_1.scala +++ b/test/files/run/macro-expand-recursive/Impls_1.scala @@ -3,13 +3,13 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works")))) c.Expr[Unit](body) } def fooFoo(c: Ctx) = { import c.universe._ - val body = Select(Ident(newTermName("Macros")), newTermName("foo")) + val body = Select(Ident(TermName("Macros")), TermName("foo")) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-a/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-bounds-a/Macros_Test_2.scala deleted file mode 100644 index b498e6f65b..0000000000 --- a/test/files/run/macro-expand-tparams-bounds-a/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo[U <: String] = macro Impls.foo[U] -} - -object Test extends App { - import Macros._ - foo[String] -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala deleted file mode 100644 index c11c89151c..0000000000 --- a/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala +++ /dev/null @@ -1,7 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -class C - -object Impls { - def foo[U <: C](c: Ctx): c.Expr[Unit] = c.literalUnit -} diff --git a/test/files/run/macro-expand-tparams-bounds-b/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-bounds-b/Macros_Test_2.scala deleted file mode 100644 index 1a261e9f73..0000000000 --- a/test/files/run/macro-expand-tparams-bounds-b/Macros_Test_2.scala +++ /dev/null @@ -1,10 +0,0 @@ -class D extends C - -object Macros { - def foo[T <: D] = macro Impls.foo[T] -} - -object Test extends App { - import Macros._ - foo[D] -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-b.check b/test/files/run/macro-expand-tparams-bounds.check index e69de29bb2..e69de29bb2 100644 --- a/test/files/run/macro-expand-tparams-bounds-b.check +++ b/test/files/run/macro-expand-tparams-bounds.check diff --git a/test/files/run/macro-declared-in-class.flags b/test/files/run/macro-expand-tparams-bounds.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-class.flags +++ b/test/files/run/macro-expand-tparams-bounds.flags diff --git a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala new file mode 100644 index 0000000000..f9103aaf8f --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala @@ -0,0 +1,12 @@ +import scala.reflect.macros.Context + +object Impls1 { + def foo[U <: String](c: Context): c.Expr[Unit] = c.literalUnit +} + +class C +class D extends C + +object Impls2 { + def foo[U <: C](c: Context): c.Expr[Unit] = c.literalUnit +} diff --git a/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala new file mode 100644 index 0000000000..37a4bcb2b9 --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala @@ -0,0 +1,12 @@ +object Macros1 { + def foo[U <: String] = macro Impls1.foo[U] +} + +object Macros2 { + def foo[T <: D] = macro Impls2.foo[T] +} + +object Test extends App { + Macros1.foo[String] + Macros2.foo[D] +} diff --git a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala index 72b420d92f..f748ab855f 100644 --- a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala @@ -5,7 +5,7 @@ object Impls { def foo[U: c.WeakTypeTag](c: Ctx) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala index 33770516df..c729aada51 100644 --- a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala @@ -5,7 +5,7 @@ object Impls { def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala b/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala deleted file mode 100644 index 9b8dafaa97..0000000000 --- a/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[U <: String](c: Ctx): c.Expr[Unit] = c.literalUnit -} diff --git a/test/files/run/macro-expand-tparams-prefix-a.check b/test/files/run/macro-expand-tparams-prefix-a.check deleted file mode 100644 index ca44a4f652..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-a.check +++ /dev/null @@ -1,4 +0,0 @@ -WeakTypeTag[Int] -WeakTypeTag[Int] -WeakTypeTag[String] -WeakTypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala deleted file mode 100644 index 33770516df..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { - import c.universe._ - val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-a/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-a/Macros_Test_2.scala deleted file mode 100644 index 81ccb7ff42..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-a/Macros_Test_2.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test extends App { - class C[T] { - def foo[U](x: U) = macro Impls.foo[U] - } - - new C[Int]().foo(42) - new C[Boolean]().foo(42) - new C[Int]().foo("42") - new C[String]().foo(true) -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b.check b/test/files/run/macro-expand-tparams-prefix-b.check deleted file mode 100644 index 2ff2ce435d..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-b.check +++ /dev/null @@ -1,2 +0,0 @@ -WeakTypeTag[Boolean] WeakTypeTag[Int] -WeakTypeTag[Boolean] WeakTypeTag[String] diff --git a/test/files/run/macro-expand-tparams-prefix-b.flags b/test/files/run/macro-expand-tparams-prefix-b.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-b.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala deleted file mode 100644 index 9378e67712..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala +++ /dev/null @@ -1,12 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { - import c.universe._ - val T = implicitly[c.WeakTypeTag[T]] - val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-b/Macros_Test_2.scala deleted file mode 100644 index a4a0acfe8b..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-b/Macros_Test_2.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test extends App { - class C[T] { - def foo[U](x: U) = macro Impls.foo[T, U] - } - - object D extends C[Boolean] - - D.foo(42) - D.foo("42") -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1.check b/test/files/run/macro-expand-tparams-prefix-c1.check deleted file mode 100644 index 0f24f74db1..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c1.check +++ /dev/null @@ -1,3 +0,0 @@ -WeakTypeTag[Int] -WeakTypeTag[String] -WeakTypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-c1.flags b/test/files/run/macro-expand-tparams-prefix-c1.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c1.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala deleted file mode 100644 index afdd7d4f7a..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala +++ /dev/null @@ -1,13 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { - import c.universe._ - c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(())))) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-c1/Macros_Test_2.scala deleted file mode 100644 index 4fa0c8cb33..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c1/Macros_Test_2.scala +++ /dev/null @@ -1,11 +0,0 @@ -class D[T] { - class C[U] { - def foo[V] = macro Impls.foo[T, U, V] - } -} - -object Test extends App { - val outer1 = new D[Int] - val outer2 = new outer1.C[String] - outer2.foo[Boolean] -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2.check b/test/files/run/macro-expand-tparams-prefix-c2.check deleted file mode 100644 index 0f24f74db1..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c2.check +++ /dev/null @@ -1,3 +0,0 @@ -WeakTypeTag[Int] -WeakTypeTag[String] -WeakTypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-c2.flags b/test/files/run/macro-expand-tparams-prefix-c2.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c2.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala deleted file mode 100644 index 3c2838208a..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala +++ /dev/null @@ -1,19 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { - import c.universe._ - c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(())))) - } -} - -class D[T] { - class C[U] { - def foo[V] = macro Impls.foo[T, U, V] - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Test_2.scala b/test/files/run/macro-expand-tparams-prefix-c2/Test_2.scala deleted file mode 100644 index e729d4a536..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c2/Test_2.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test extends App { - val outer1 = new D[Int] - val outer2 = new outer1.C[String] - outer2.foo[Boolean] -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-d1.check b/test/files/run/macro-expand-tparams-prefix-d1.check deleted file mode 100644 index 7832503256..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-d1.check +++ /dev/null @@ -1,3 +0,0 @@ -WeakTypeTag[T] -WeakTypeTag[U] -WeakTypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-d1.flags b/test/files/run/macro-expand-tparams-prefix-d1.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-d1.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala deleted file mode 100644 index afdd7d4f7a..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala +++ /dev/null @@ -1,13 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { - import c.universe._ - c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(())))) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-d1/Macros_Test_2.scala deleted file mode 100644 index 8222a6d1e8..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-d1/Macros_Test_2.scala +++ /dev/null @@ -1,11 +0,0 @@ -object Test extends App { - class D[T] { - class C[U] { - def foo[V] = macro Impls.foo[T, U, V] - foo[Boolean] - } - } - - val outer1 = new D[Int] - new outer1.C[String] -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix.check b/test/files/run/macro-expand-tparams-prefix.check new file mode 100644 index 0000000000..7397958066 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix.check @@ -0,0 +1,20 @@ +===Macros1=== +WeakTypeTag[Int] +WeakTypeTag[Int] +WeakTypeTag[String] +WeakTypeTag[Boolean] +===Macros2=== +WeakTypeTag[Boolean] WeakTypeTag[Int] +WeakTypeTag[Boolean] WeakTypeTag[String] +===Macros3=== +WeakTypeTag[Int] +WeakTypeTag[String] +WeakTypeTag[Boolean] +===Macros4=== +WeakTypeTag[Int] +WeakTypeTag[String] +WeakTypeTag[Boolean] +===Macros5=== +WeakTypeTag[T] +WeakTypeTag[U] +WeakTypeTag[Boolean] diff --git a/test/files/run/macro-declared-in-default-param.flags b/test/files/run/macro-expand-tparams-prefix.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-default-param.flags +++ b/test/files/run/macro-expand-tparams-prefix.flags diff --git a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala new file mode 100644 index 0000000000..e92396d1b4 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala @@ -0,0 +1,40 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.macros.Context + +object Impls1 { + def foo[U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = { + import c.universe._ + val U = implicitly[c.WeakTypeTag[U]] + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) + c.Expr[Unit](body) + } +} + +object Impls2 { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = { + import c.universe._ + val T = implicitly[c.WeakTypeTag[T]] + val U = implicitly[c.WeakTypeTag[U]] + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) + c.Expr[Unit](body) + } +} + +object Impls345 { + def foo[T, U: c.WeakTypeTag, V](c: Context)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { + import c.universe._ + c.Expr(Block(List( + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(V.toString))))), + Literal(Constant(())))) + } +} + +object Macros4 { + class D[T] { + class C[U] { + def foo[V] = macro Impls345.foo[T, U, V] + } + } +} diff --git a/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala new file mode 100644 index 0000000000..2b1730d36e --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala @@ -0,0 +1,57 @@ +object Macros1 { + class C[T] { + def foo[U](x: U) = macro Impls1.foo[U] + } +} + +object Macros2 { + class C[T] { + def foo[U](x: U) = macro Impls2.foo[T, U] + } +} + +object Macros3 { + class D[T] { + class C[U] { + def foo[V] = macro Impls345.foo[T, U, V] + } + } +} + +// object Macros4 is declared in Impls_1.scala + +object Macros5 { + class D[T] { + class C[U] { + def foo[V] = macro Impls345.foo[T, U, V] + foo[Boolean] + } + } +} + +object Test extends App { + println("===Macros1===") + new Macros1.C[Int]().foo(42) + new Macros1.C[Boolean]().foo(42) + new Macros1.C[Int]().foo("42") + new Macros1.C[String]().foo(true) + + println("===Macros2===") + object D2 extends Macros2.C[Boolean] + D2.foo(42) + D2.foo("42") + + println("===Macros3===") + val outer31 = new Macros3.D[Int] + val outer32 = new outer31.C[String] + outer32.foo[Boolean] + + println("===Macros4===") + val outer41 = new Macros4.D[Int] + val outer42 = new outer41.C[String] + outer42.foo[Boolean] + + println("===Macros5===") + val outer1 = new Macros5.D[Int] + new outer1.C[String] +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-a.check b/test/files/run/macro-expand-unapply-a.check new file mode 100644 index 0000000000..7c2976e51e --- /dev/null +++ b/test/files/run/macro-expand-unapply-a.check @@ -0,0 +1,2 @@ +(1,2) +(1,2,3) diff --git a/test/files/run/macro-declared-in-implicit-class.flags b/test/files/run/macro-expand-unapply-a.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-implicit-class.flags +++ b/test/files/run/macro-expand-unapply-a.flags diff --git a/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala b/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala new file mode 100644 index 0000000000..61d6345f16 --- /dev/null +++ b/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.Context + +object Helper { + def unapplySeq[T](x: List[T]): Option[Seq[T]] = List.unapplySeq[T](x) +} + +object Macros { + def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[List[T]]) = { + c.universe.reify(Helper.unapplySeq(x.splice)) + } + + object UnapplyMacro { + def unapplySeq[T](x: List[T]): Option[Seq[T]] = macro impl[T] + } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-a/Test_2.scala b/test/files/run/macro-expand-unapply-a/Test_2.scala new file mode 100644 index 0000000000..6169d86b19 --- /dev/null +++ b/test/files/run/macro-expand-unapply-a/Test_2.scala @@ -0,0 +1,6 @@ +import Macros._ + +object Test extends App { + List(1, 2) match { case UnapplyMacro(x, y) => println((x, y)) } + List(1, 2, 3) match { case UnapplyMacro(x, y, z) => println((x, y, z)) } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-b.check b/test/files/run/macro-expand-unapply-b.check new file mode 100644 index 0000000000..5272f0d00a --- /dev/null +++ b/test/files/run/macro-expand-unapply-b.check @@ -0,0 +1,2 @@ +(1,List(2)) +List(1) diff --git a/test/files/run/macro-declared-in-method.flags b/test/files/run/macro-expand-unapply-b.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-method.flags +++ b/test/files/run/macro-expand-unapply-b.flags diff --git a/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala b/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala new file mode 100644 index 0000000000..d0300bdf7e --- /dev/null +++ b/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala @@ -0,0 +1,37 @@ +import language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + implicit class ContextExtensions(c: StringContext) { + object q { + def unapply(x: Any): Option[Any] = macro impl + } + } + + def impl(c: Context)(x: c.Expr[Any]): c.Expr[Option[Any]] = { + import c.universe._ + import Flag._ + + // parts here will be string literals - static parts of the string interpolation + // e.g. for q"$x, $y" parts will be Literal(Constant("")), Literal(Constant(", ")) and Literal(Constant("")) + val Apply(Select(Select(Apply(_, List(Apply(_, parts))), _), _), _) = c.macroApplication + val nresults = parts.length - 1 + + def results() = + ((1 to (nresults - 1)).toList map (i => Literal(Constant(i)))) :+ // (n - 1) results of type Int + Apply(Ident(TermName("List")), List(Literal(Constant(nresults)))) // and also one result of a different type + def extractorBody() = + if (nresults == 0) Literal(Constant(true)) + else if (nresults == 1) Apply(Ident(TermName("Some")), results()) + else Apply(Ident(TermName("Some")), List(Apply(Ident(TermName("Tuple" + nresults)), results()))) + + val name = TermName(java.util.UUID.randomUUID().toString.replace("-", "")) + val mdef = ModuleDef(NoMods, name, Template(List(Select(Ident(TermName("scala")), TypeName("AnyRef"))), emptyValDef, List( + DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), + Block(List(pendingSuperCall), Literal(Constant(())))), + DefDef(Modifiers(), TermName("unapply"), List(), List(List(ValDef(Modifiers(PARAM), TermName("x"), Ident(TypeName("Any")), EmptyTree))), TypeTree(), + extractorBody())))) + c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, mdef) + c.Expr[Option[Any]](Apply(Select(Ident(name), TermName("unapply")), List(x.tree))) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-b/Test_2.scala b/test/files/run/macro-expand-unapply-b/Test_2.scala new file mode 100644 index 0000000000..5352160dfe --- /dev/null +++ b/test/files/run/macro-expand-unapply-b/Test_2.scala @@ -0,0 +1,8 @@ +object Test extends App { + import Macros._ + def whatever() = null + val q"$x1, $y1" = whatever() + println(x1, y1) + val q"$x2" = whatever() + println(x2) +} diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala index 2ef8f04be9..f6c1d27d54 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala index c832826d64..b844012d53 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala @@ -6,7 +6,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Typed(Apply(Ident(definitions.ListModule), List(Literal(Constant(1)), Literal(Constant(2)))), Ident(tpnme.WILDCARD_STAR)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Typed(Apply(Ident(definitions.ListModule), List(Literal(Constant(1)), Literal(Constant(2)))), Ident(tpnme.WILDCARD_STAR)))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala index 3c7f94f605..363ff0e0aa 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala @@ -7,7 +7,7 @@ object Impls { case List(Typed(stripped, Ident(wildstar))) if wildstar == tpnme.WILDCARD_STAR => List(stripped) case _ => ??? } - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), stripped_xs) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), stripped_xs) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala index 2066893bdc..0b61ab2f9b 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala @@ -7,7 +7,7 @@ object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(newTermName("Impls")), newTermName("myprintln")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(TermName("Impls")), TermName("myprintln")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala index 2ef8f04be9..f6c1d27d54 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala index 2066893bdc..0b61ab2f9b 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala @@ -7,7 +7,7 @@ object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(newTermName("Impls")), newTermName("myprintln")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(TermName("Impls")), TermName("myprintln")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala index 7c40045c0f..95d746980e 100644 --- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -7,10 +7,10 @@ object Impls { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + U.tpe))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo_targs...")))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("U is: " + U.tpe))))), Literal(Constant(()))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-impl-relaxed.check b/test/files/run/macro-impl-relaxed.check new file mode 100644 index 0000000000..487b116534 --- /dev/null +++ b/test/files/run/macro-impl-relaxed.check @@ -0,0 +1,4 @@ +2 +2 +2 +2 diff --git a/test/files/run/macro-impl-relaxed/Macros_1.scala b/test/files/run/macro-impl-relaxed/Macros_1.scala new file mode 100644 index 0000000000..af62646b4e --- /dev/null +++ b/test/files/run/macro-impl-relaxed/Macros_1.scala @@ -0,0 +1,14 @@ +import language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + def implUU(c: Context)(x: c.Tree): c.Tree = x + def implTU(c: Context)(x: c.Expr[Int]): c.Tree = x.tree + def implUT(c: Context)(x: c.Tree): c.Expr[Int] = c.Expr[Int](x) + def implTT(c: Context)(x: c.Expr[Int]): c.Expr[Int] = x + + def fooUU(x: Int): Int = macro implUU + def fooTU(x: Int): Int = macro implTU + def fooUT(x: Int): Int = macro implUT + def fooTT(x: Int): Int = macro implTT +}
\ No newline at end of file diff --git a/test/files/run/macro-impl-relaxed/Test_2.scala b/test/files/run/macro-impl-relaxed/Test_2.scala new file mode 100644 index 0000000000..2eaeef0fd0 --- /dev/null +++ b/test/files/run/macro-impl-relaxed/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + println(Macros.fooUU(2)) + println(Macros.fooTU(2)) + println(Macros.fooUT(2)) + println(Macros.fooTT(2)) +}
\ No newline at end of file diff --git a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala index 56c23f5faf..738c88bbc8 100644 --- a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala @@ -4,7 +4,7 @@ object Impls { def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = { import unconventionalName.universe._ val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo..."))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo..."))))), Literal(Constant(()))) unconventionalName.Expr[Unit](body) } diff --git a/test/files/run/macro-declared-in-object-class.flags b/test/files/run/macro-impl-tparam-only-in-impl.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-object-class.flags +++ b/test/files/run/macro-impl-tparam-only-in-impl.flags diff --git a/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala index 9b8dafaa97..9b8dafaa97 100644 --- a/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala +++ b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala diff --git a/test/files/run/macro-expand-tparams-only-in-impl/Macros_Test_2.scala b/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala index 218c7aec7f..218c7aec7f 100644 --- a/test/files/run/macro-expand-tparams-only-in-impl/Macros_Test_2.scala +++ b/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala diff --git a/test/files/run/macro-expand-tparams-optional.check b/test/files/run/macro-impl-tparam-typetag-is-optional.check index b4a0f394c1..b4a0f394c1 100644 --- a/test/files/run/macro-expand-tparams-optional.check +++ b/test/files/run/macro-impl-tparam-typetag-is-optional.check diff --git a/test/files/run/macro-declared-in-object-object.flags b/test/files/run/macro-impl-tparam-typetag-is-optional.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-object-object.flags +++ b/test/files/run/macro-impl-tparam-typetag-is-optional.flags diff --git a/test/files/run/macro-expand-tparams-optional/Impls_1.scala b/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala index 3b829e2e09..ace7a6cd26 100644 --- a/test/files/run/macro-expand-tparams-optional/Impls_1.scala +++ b/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo[U](c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("don't know U")))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("don't know U")))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-optional/Macros_Test_2.scala b/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala index e72c27881a..e72c27881a 100644 --- a/test/files/run/macro-expand-tparams-optional/Macros_Test_2.scala +++ b/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala index 0b9986e9f6..61f0bdfadc 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala index fb0d55208c..869a5a41fa 100644 --- a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx) = { import c.universe._ - val body = Ident(newTermName("IDoNotExist")) + val body = Ident(TermName("IDoNotExist")) c.Expr[Int](body) } } diff --git a/test/files/run/macro-invalidret-nontypeable/Test_2.scala b/test/files/run/macro-invalidret-nontypeable/Test_2.scala index 0daee49a08..7cd474ff52 100644 --- a/test/files/run/macro-invalidret-nontypeable/Test_2.scala +++ b/test/files/run/macro-invalidret-nontypeable/Test_2.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-badret/Test_2.scala b/test/files/run/macro-invalidusage-badret/Test_2.scala index 5cb0be5ddd..fc71353f54 100644 --- a/test/files/run/macro-invalidusage-badret/Test_2.scala +++ b/test/files/run/macro-invalidusage-badret/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Typed(Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))), Ident(newTypeName("String"))) + val tree = Typed(Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))), Ident(TypeName("String"))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams.check b/test/files/run/macro-invalidusage-partialapplication-with-tparams.check index f1d5e925fa..326f3e08ca 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams.check +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams.check @@ -1,3 +1,3 @@ reflective compilation has failed: -macros cannot be partially applied +too few argument lists for macro invocation diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala index 4583a726cf..8a93161af5 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[T]) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(x.tree.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(x.tree.toString)))) c.Expr[Unit](body) } } diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala index e453d0b70c..9a34c62e0f 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-invalidusage-partialapplication.check b/test/files/run/macro-invalidusage-partialapplication.check index f1d5e925fa..326f3e08ca 100644 --- a/test/files/run/macro-invalidusage-partialapplication.check +++ b/test/files/run/macro-invalidusage-partialapplication.check @@ -1,3 +1,3 @@ reflective compilation has failed: -macros cannot be partially applied +too few argument lists for macro invocation diff --git a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala index 5866469499..3ac9cd2a8d 100644 --- a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala @@ -3,8 +3,8 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._ - val sum = Apply(Select(x.tree, newTermName("$plus")), List(y.tree)) - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum)) + val sum = Apply(Select(x.tree, TermName("$plus")), List(y.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum)) c.Expr[Unit](body) } } diff --git a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala index dc48c127f4..75b8c139d4 100644 --- a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala +++ b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(40)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(40)))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala index b863ac048b..50a1782431 100644 --- a/test/files/run/macro-openmacros/Impls_Macros_1.scala +++ b/test/files/run/macro-openmacros/Impls_Macros_1.scala @@ -14,7 +14,7 @@ object Macros { } import c.universe._ - val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), newTermName("foo"))) else c.literalUnit + val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), TermName("foo"))) else c.literalUnit c.universe.reify { println(c.literal(normalizePaths(c.enclosingMacros.toString)).splice) next.splice diff --git a/test/files/run/macro-quasiquotes.check b/test/files/run/macro-quasiquotes.check new file mode 100644 index 0000000000..94ebaf9001 --- /dev/null +++ b/test/files/run/macro-quasiquotes.check @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/test/files/run/macro-quasiquotes/Macros_1.scala b/test/files/run/macro-quasiquotes/Macros_1.scala new file mode 100644 index 0000000000..b64eec8743 --- /dev/null +++ b/test/files/run/macro-quasiquotes/Macros_1.scala @@ -0,0 +1,15 @@ +import language.experimental.macros +import scala.reflect.macros.Macro + +trait Impls extends Macro { + import c.universe._ + def impl1 = q"println(1)" + def impl2 = q"{ println(2); println(3) }" + def impl3 = q"4" +} + +object Macros { + def m1 = macro Impls.impl1 + def m2 = macro Impls.impl2 + def m3 = macro Impls.impl3 +}
\ No newline at end of file diff --git a/test/files/run/macro-quasiquotes/Test_2.scala b/test/files/run/macro-quasiquotes/Test_2.scala new file mode 100644 index 0000000000..4be193938f --- /dev/null +++ b/test/files/run/macro-quasiquotes/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + Macros.m1 + Macros.m2 + println(Macros.m3) +} diff --git a/test/files/run/macro-range/Common_1.scala b/test/files/run/macro-range/Common_1.scala index 5c4bc211fc..4083e6126e 100644 --- a/test/files/run/macro-range/Common_1.scala +++ b/test/files/run/macro-range/Common_1.scala @@ -43,5 +43,5 @@ abstract class Utils { LabelDef(lname, Nil, rhs) } def makeBinop(left: Tree, op: String, right: Tree): Tree = - Apply(Select(left, newTermName(op)), List(right)) + Apply(Select(left, TermName(op)), List(right)) } diff --git a/test/files/run/macro-range/Expansion_Impossible_2.scala b/test/files/run/macro-range/Expansion_Impossible_2.scala index 57e0cee97f..ca0db48822 100644 --- a/test/files/run/macro-range/Expansion_Impossible_2.scala +++ b/test/files/run/macro-range/Expansion_Impossible_2.scala @@ -16,11 +16,11 @@ object Impls { // scala"($_this: RangeDefault).foreach($f)" c.Expr(c.prefix.tree match { case Apply(Select(New(tpt), initName), List(lo, hi)) if tpt.symbol.fullName == "Range" => - val iname = newTermName("$i") - val hname = newTermName("$h") + val iname = TermName("$i") + val hname = TermName("$h") def iref = Ident(iname) def href = Ident(hname) - val labelname = newTermName("$while") + val labelname = TermName("$while") val cond = makeBinop(iref, "$less", href) val body = Block( List(makeApply(f.tree, List(iref))), @@ -37,8 +37,8 @@ object Impls { case _ => Apply( Select( - Typed(c.prefix.tree, Ident(newTypeName("RangeDefault"))), - newTermName("foreach")), + Typed(c.prefix.tree, Ident(TypeName("RangeDefault"))), + TermName("foreach")), List(f.tree)) }) } diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala index fa559334d4..51e0264ed5 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala +++ b/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } } diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala index 2e64c01e35..267d1bc7b0 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala +++ b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala @@ -2,6 +2,6 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))) println(cm.mkToolBox().eval(tree)) } diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala index 5d7e077731..4261a6d45d 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala +++ b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala index 70560009b1..13cd953bde 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala +++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala @@ -8,12 +8,12 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val macrobody = Select(Ident(newTermName("Impls")), newTermName("foo")) - val macroparam = ValDef(NoMods, newTermName("x"), TypeTree(definitions.IntClass.toType), EmptyTree) - val macrodef = DefDef(Modifiers(MACRO), newTermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody) + val macrobody = Select(Ident(TermName("Impls")), TermName("foo")) + val macroparam = ValDef(NoMods, TermName("x"), TypeTree(definitions.IntClass.toType), EmptyTree) + val macrodef = DefDef(Modifiers(MACRO), TermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody) val modulector = DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))) - val module = ModuleDef(NoMods, newTermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef))) - val macroapp = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) + val module = ModuleDef(NoMods, TermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef))) + val macroapp = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))) val tree = Block(List(macrodef, module), macroapp) val toolbox = cm.mkToolBox(options = "-language:experimental.macros") println(toolbox.eval(tree)) diff --git a/test/files/run/macro-reify-freevars/Test_2.scala b/test/files/run/macro-reify-freevars/Test_2.scala index 7af9d89bdb..c2d0118e17 100644 --- a/test/files/run/macro-reify-freevars/Test_2.scala +++ b/test/files/run/macro-reify-freevars/Test_2.scala @@ -2,10 +2,10 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val q = New(AppliedTypeTree(Select(Select(Select(Ident(newTermName("scala")), newTermName("collection")), newTermName("slick")), newTypeName("Queryable")), List(Ident(newTermName("Int"))))) - val x = ValDef(NoMods, newTermName("x"), Ident(newTermName("Int")), EmptyTree) - val fn = Function(List(x), Apply(Select(Ident(newTermName("x")), newTermName("$plus")), List(Literal(Constant("5"))))) - val tree = Apply(Select(q, newTermName("map")), List(fn)) + val q = New(AppliedTypeTree(Select(Select(Select(Ident(TermName("scala")), TermName("collection")), TermName("slick")), TypeName("Queryable")), List(Ident(TermName("Int"))))) + val x = ValDef(NoMods, TermName("x"), Ident(TermName("Int")), EmptyTree) + val fn = Function(List(x), Apply(Select(Ident(TermName("x")), TermName("$plus")), List(Literal(Constant("5"))))) + val tree = Apply(Select(q, TermName("map")), List(fn)) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala index b4351c2c53..bb6a45e11e 100644 --- a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala @@ -28,7 +28,7 @@ object QueryableMacros{ val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( - Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree )) + Apply(Select(c.prefix.tree, TermName( name )), List( projection.tree )) ).asInstanceOf[Tree] ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} diff --git a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala index b4351c2c53..bb6a45e11e 100644 --- a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala @@ -28,7 +28,7 @@ object QueryableMacros{ val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( - Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree )) + Apply(Select(c.prefix.tree, TermName( name )), List( projection.tree )) ).asInstanceOf[Tree] ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} diff --git a/test/files/run/macro-reify-splice-outside-reify/Test_2.scala b/test/files/run/macro-reify-splice-outside-reify/Test_2.scala index 54bd03fcd2..dbc17e7c15 100644 --- a/test/files/run/macro-reify-splice-outside-reify/Test_2.scala +++ b/test/files/run/macro-reify-splice-outside-reify/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))) try println(cm.mkToolBox().eval(tree)) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-reify-tagless-a/Test_2.scala b/test/files/run/macro-reify-tagless-a/Test_2.scala index 584c4bdf5b..afb418a755 100644 --- a/test/files/run/macro-reify-tagless-a/Test_2.scala +++ b/test/files/run/macro-reify-tagless-a/Test_2.scala @@ -6,9 +6,9 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tpt = AppliedTypeTree(Ident(definitions.ListClass), List(Ident(definitions.StringClass))) - val rhs = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant("hello world")))) - val list = ValDef(NoMods, newTermName("list"), tpt, rhs) - val tree = Block(List(list), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Ident(list.name)))) + val rhs = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant("hello world")))) + val list = ValDef(NoMods, TermName("list"), tpt, rhs) + val tree = Block(List(list), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Ident(list.name)))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-reify-type/Macros_1.scala b/test/files/run/macro-reify-type/Macros_1.scala index 06de05735d..c4d1d9f8ad 100644 --- a/test/files/run/macro-reify-type/Macros_1.scala +++ b/test/files/run/macro-reify-type/Macros_1.scala @@ -8,7 +8,7 @@ object StaticReflect { import c.universe._ val nameName: TermName = name.tree match { - case Literal(Constant(str: String)) => newTermName(str) + case Literal(Constant(str: String)) => TermName(str) case _ => c.error(c.enclosingPosition, s"Method name not constant.") ; return reify(ru.NoType) } val clazz = weakTypeOf[A] @@ -17,8 +17,8 @@ object StaticReflect { case NoSymbol => c.error(c.enclosingPosition, s"No member called $nameName in $clazz.") ; reify(ru.NoType) case member => val mtpe = member typeSignatureIn clazz - val mtag = c.reifyType(treeBuild.mkRuntimeUniverseRef, Select(treeBuild.mkRuntimeUniverseRef, newTermName("rootMirror")), mtpe) - val mtree = Select(mtag, newTermName("tpe")) + val mtag = c.reifyType(treeBuild.mkRuntimeUniverseRef, Select(treeBuild.mkRuntimeUniverseRef, TermName("rootMirror")), mtpe) + val mtree = Select(mtag, TermName("tpe")) c.Expr[ru.Type](mtree) } diff --git a/test/files/run/macro-reify-type/Test_2.scala b/test/files/run/macro-reify-type/Test_2.scala index 9beaf98681..1f35973531 100644 --- a/test/files/run/macro-reify-type/Test_2.scala +++ b/test/files/run/macro-reify-type/Test_2.scala @@ -7,10 +7,10 @@ object Test extends App { //val $m: $u.Mirror = scala.reflect.runtime.universe.rootMirror; //import $u._, $m._, Flag._ //val tpe = { - // val symdef$B2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTypeName("B"), NoPosition, DEFERRED | PARAM, false); - // val symdef$That2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTypeName("That"), NoPosition, DEFERRED | PARAM, false); - // val symdef$f2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTermName("f"), NoPosition, PARAM, false); - // val symdef$bf2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTermName("bf"), NoPosition, IMPLICIT | PARAM, false); + // val symdef$B2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TypeName("B"), NoPosition, DEFERRED | PARAM, false); + // val symdef$That2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TypeName("That"), NoPosition, DEFERRED | PARAM, false); + // val symdef$f2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TermName("f"), NoPosition, PARAM, false); + // val symdef$bf2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TermName("bf"), NoPosition, IMPLICIT | PARAM, false); // build.setTypeSignature(symdef$B2, TypeBounds(staticClass("scala.Nothing").asType.toTypeConstructor, staticClass("scala.Any").asType.toTypeConstructor)); // build.setTypeSignature(symdef$That2, TypeBounds(staticClass("scala.Nothing").asType.toTypeConstructor, staticClass("scala.Any").asType.toTypeConstructor)); // build.setTypeSignature(symdef$f2, TypeRef(ThisType(staticPackage("scala").asModule.moduleClass), staticClass("scala.Function1"), List(staticClass("scala.Int").asType.toTypeConstructor, TypeRef(NoPrefix, symdef$B2, List())))); diff --git a/test/files/run/macro-reify-unreify/Macros_1.scala b/test/files/run/macro-reify-unreify/Macros_1.scala index 9f04c13014..25ed352cca 100644 --- a/test/files/run/macro-reify-unreify/Macros_1.scala +++ b/test/files/run/macro-reify-unreify/Macros_1.scala @@ -9,7 +9,7 @@ object Macros { import treeBuild._ val world = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, s.tree) - val greeting = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, c.typeCheck(Apply(Select(Literal(Constant("hello ")), newTermName("$plus")), List(c.unreifyTree(world))))) + val greeting = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, c.typeCheck(Apply(Select(Literal(Constant("hello ")), TermName("$plus")), List(c.unreifyTree(world))))) val typedGreeting = c.Expr[String](greeting) c.universe.reify { diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check index 7deed4a878..8d43a3aa16 100644 --- a/test/files/run/macro-repl-basic.check +++ b/test/files/run/macro-repl-basic.check @@ -14,23 +14,23 @@ scala> scala> object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } def bar(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } def quux(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } } -defined module Impls +defined object Impls scala> object Macros { object Shmacros { @@ -40,7 +40,7 @@ scala> object Macros { }; class Macros { def quux(x: Int): Int = macro Impls.quux } -defined module Macros +defined object Macros defined class Macros scala> diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala index eae1febb3a..3c22c13dc7 100644 --- a/test/files/run/macro-repl-basic.scala +++ b/test/files/run/macro-repl-basic.scala @@ -8,19 +8,19 @@ object Test extends ReplTest { |object Impls { | def foo(c: Ctx)(x: c.Expr[Int]) = { | import c.universe._ - | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) | c.Expr[Int](body) | } | | def bar(c: Ctx)(x: c.Expr[Int]) = { | import c.universe._ - | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) | c.Expr[Int](body) | } | | def quux(c: Ctx)(x: c.Expr[Int]) = { | import c.universe._ - | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) | c.Expr[Int](body) | } |} diff --git a/test/files/run/macro-repl-dontexpand.check b/test/files/run/macro-repl-dontexpand.check index 628a9146c4..99b70ea3dc 100644 --- a/test/files/run/macro-repl-dontexpand.check +++ b/test/files/run/macro-repl-dontexpand.check @@ -7,6 +7,6 @@ scala> def bar(c: scala.reflect.macros.Context) = ??? bar: (c: scala.reflect.macros.Context)Nothing scala> def foo = macro bar -foo: Any +defined term macro foo: Any scala> diff --git a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala index 5f3f61ca3f..8d7d3b5d3d 100644 --- a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala @@ -7,7 +7,7 @@ object Macros { val inscope = c.inferImplicitValue(c.mirror.staticClass("SourceLocation").toType) val outer = c.Expr[SourceLocation](if (!inscope.isEmpty) inscope else Literal(Constant(null))) - val Apply(fun, args) = c.enclosingImplicits(0)._2 + val Apply(fun, args) = c.enclosingImplicits(0).tree val fileName = fun.pos.source.file.file.getName val line = fun.pos.line val charOffset = fun.pos.point diff --git a/test/files/run/macro-sip19/Impls_Macros_1.scala b/test/files/run/macro-sip19/Impls_Macros_1.scala index 535ec2ccf0..4c165ed1b8 100644 --- a/test/files/run/macro-sip19/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.Context object Macros { def impl(c: Context) = { import c.universe._ - val Apply(fun, args) = c.enclosingImplicits(0)._2 + val Apply(fun, args) = c.enclosingImplicits(0).tree val fileName = fun.pos.source.file.file.getName val line = fun.pos.line val charOffset = fun.pos.point diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check index dce976df02..a2da4aaf60 100644 --- a/test/files/run/macro-system-properties.check +++ b/test/files/run/macro-system-properties.check @@ -13,13 +13,13 @@ scala> object GrabContext { def impl(c: Context)() = { System.getProperties.put("lastContext", c); c.literalUnit } def grab() = macro impl } -defined module GrabContext +defined object GrabContext scala> object Test { class C(implicit a: Any) { GrabContext.grab } } -defined module Test +defined object Test scala> object Test { class C(implicit a: Any) { GrabContext.grab } } -defined module Test +defined object Test scala> diff --git a/test/files/run/macro-def-path-dependent-a.check b/test/files/run/macro-term-declared-in-annotation.check index 7658ad2c24..7658ad2c24 100644 --- a/test/files/run/macro-def-path-dependent-a.check +++ b/test/files/run/macro-term-declared-in-annotation.check diff --git a/test/files/run/macro-declared-in-object.flags b/test/files/run/macro-term-declared-in-annotation.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-object.flags +++ b/test/files/run/macro-term-declared-in-annotation.flags diff --git a/test/files/run/macro-declared-in-annotation/Impls_1.scala b/test/files/run/macro-term-declared-in-annotation/Impls_1.scala index a11ee2907a..1ea06de679 100644 --- a/test/files/run/macro-declared-in-annotation/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-annotation/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) val body = Block(List(printPrefix), Literal(Constant("this is deprecated"))) c.Expr[String](body) } diff --git a/test/files/run/macro-declared-in-annotation/Macros_2.scala b/test/files/run/macro-term-declared-in-annotation/Macros_2.scala index 40d71c62fb..40d71c62fb 100644 --- a/test/files/run/macro-declared-in-annotation/Macros_2.scala +++ b/test/files/run/macro-term-declared-in-annotation/Macros_2.scala diff --git a/test/files/run/macro-declared-in-annotation/Test_3.scala b/test/files/run/macro-term-declared-in-annotation/Test_3.scala index 866487f028..866487f028 100644 --- a/test/files/run/macro-declared-in-annotation/Test_3.scala +++ b/test/files/run/macro-term-declared-in-annotation/Test_3.scala diff --git a/test/files/run/macro-declared-in-anonymous.check b/test/files/run/macro-term-declared-in-anonymous.check index 09b8d015a6..09b8d015a6 100644 --- a/test/files/run/macro-declared-in-anonymous.check +++ b/test/files/run/macro-term-declared-in-anonymous.check diff --git a/test/files/run/macro-declared-in-package-object.flags b/test/files/run/macro-term-declared-in-anonymous.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-package-object.flags +++ b/test/files/run/macro-term-declared-in-anonymous.flags diff --git a/test/files/run/macro-declared-in-class-object/Impls_1.scala b/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-class-object/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-anonymous/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala index 8bd8c172c9..88cd29ae4f 100644 --- a/test/files/run/macro-declared-in-anonymous/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala @@ -1,4 +1,6 @@ +import scala.language.reflectiveCalls + object Test extends App { val macros = new { def foo = macro Impls.foo } macros.foo -}
\ No newline at end of file +} diff --git a/test/files/run/macro-declared-in-block.check b/test/files/run/macro-term-declared-in-block.check index 5e687db8bf..5e687db8bf 100644 --- a/test/files/run/macro-declared-in-block.check +++ b/test/files/run/macro-term-declared-in-block.check diff --git a/test/files/run/macro-declared-in-refinement.flags b/test/files/run/macro-term-declared-in-block.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-refinement.flags +++ b/test/files/run/macro-term-declared-in-block.flags diff --git a/test/files/run/macro-declared-in-anonymous/Impls_1.scala b/test/files/run/macro-term-declared-in-block/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-anonymous/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-block/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-block/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala index 69088e24bc..69088e24bc 100644 --- a/test/files/run/macro-declared-in-block/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-class-class.check b/test/files/run/macro-term-declared-in-class-class.check index 47248d7af7..47248d7af7 100644 --- a/test/files/run/macro-declared-in-class-class.check +++ b/test/files/run/macro-term-declared-in-class-class.check diff --git a/test/files/run/macro-declared-in-trait.flags b/test/files/run/macro-term-declared-in-class-class.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-trait.flags +++ b/test/files/run/macro-term-declared-in-class-class.flags diff --git a/test/files/run/macro-declared-in-class-class/Impls_1.scala b/test/files/run/macro-term-declared-in-class-class/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-class-class/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-class-class/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala index 871857a97f..871857a97f 100644 --- a/test/files/run/macro-declared-in-class-class/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-class-object.check b/test/files/run/macro-term-declared-in-class-object.check index 35af59e40f..35af59e40f 100644 --- a/test/files/run/macro-declared-in-class-object.check +++ b/test/files/run/macro-term-declared-in-class-object.check diff --git a/test/files/run/macro-def-infer-return-type-a.flags b/test/files/run/macro-term-declared-in-class-object.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-def-infer-return-type-a.flags +++ b/test/files/run/macro-term-declared-in-class-object.flags diff --git a/test/files/run/macro-declared-in-block/Impls_1.scala b/test/files/run/macro-term-declared-in-class-object/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-block/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-class-object/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala index 994f9fe935..994f9fe935 100644 --- a/test/files/run/macro-declared-in-class-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-class.check b/test/files/run/macro-term-declared-in-class.check index a1c1d7af8b..a1c1d7af8b 100644 --- a/test/files/run/macro-declared-in-class.check +++ b/test/files/run/macro-term-declared-in-class.check diff --git a/test/files/run/macro-def-infer-return-type-b.flags b/test/files/run/macro-term-declared-in-class.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-def-infer-return-type-b.flags +++ b/test/files/run/macro-term-declared-in-class.flags diff --git a/test/files/run/macro-term-declared-in-class/Impls_1.scala b/test/files/run/macro-term-declared-in-class/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-class/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala index 1b9d13e775..1b9d13e775 100644 --- a/test/files/run/macro-declared-in-class/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-default-param.check b/test/files/run/macro-term-declared-in-default-param.check index 6decd7aa4d..6decd7aa4d 100644 --- a/test/files/run/macro-declared-in-default-param.check +++ b/test/files/run/macro-term-declared-in-default-param.check diff --git a/test/files/run/macro-def-infer-return-type-c.flags b/test/files/run/macro-term-declared-in-default-param.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-def-infer-return-type-c.flags +++ b/test/files/run/macro-term-declared-in-default-param.flags diff --git a/test/files/run/macro-declared-in-default-param/Impls_1.scala b/test/files/run/macro-term-declared-in-default-param/Impls_1.scala index db1e5c7435..4380f40b04 100644 --- a/test/files/run/macro-declared-in-default-param/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-default-param/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) val body = Block(List(printPrefix), Literal(Constant("it works"))) c.Expr[String](body) } diff --git a/test/files/run/macro-declared-in-default-param/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala index 356029e63e..356029e63e 100644 --- a/test/files/run/macro-declared-in-default-param/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-implicit-class.check b/test/files/run/macro-term-declared-in-implicit-class.check index 5dc968c08c..5dc968c08c 100644 --- a/test/files/run/macro-declared-in-implicit-class.check +++ b/test/files/run/macro-term-declared-in-implicit-class.check diff --git a/test/files/run/macro-def-path-dependent-a.flags b/test/files/run/macro-term-declared-in-implicit-class.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-a.flags +++ b/test/files/run/macro-term-declared-in-implicit-class.flags diff --git a/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala b/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala index 837b306976..4c009cc367 100644 --- a/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala +++ b/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala @@ -4,8 +4,8 @@ object Impls { def toOptionOfInt(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Ident(definitions.SomeModule), List(Select(Select(prefix.tree, newTermName("x")), newTermName("toInt"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Ident(definitions.SomeModule), List(Select(Select(prefix.tree, TermName("x")), TermName("toInt"))))) c.Expr[Option[Int]](body) } } diff --git a/test/files/run/macro-declared-in-implicit-class/Test_2.scala b/test/files/run/macro-term-declared-in-implicit-class/Test_2.scala index d0bc9cc38c..d0bc9cc38c 100644 --- a/test/files/run/macro-declared-in-implicit-class/Test_2.scala +++ b/test/files/run/macro-term-declared-in-implicit-class/Test_2.scala diff --git a/test/files/run/macro-declared-in-method.check b/test/files/run/macro-term-declared-in-method.check index 5e687db8bf..5e687db8bf 100644 --- a/test/files/run/macro-declared-in-method.check +++ b/test/files/run/macro-term-declared-in-method.check diff --git a/test/files/run/macro-def-path-dependent-b.flags b/test/files/run/macro-term-declared-in-method.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-b.flags +++ b/test/files/run/macro-term-declared-in-method.flags diff --git a/test/files/run/macro-term-declared-in-method/Impls_1.scala b/test/files/run/macro-term-declared-in-method/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-method/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-method/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala index ed5c8b7c43..ed5c8b7c43 100644 --- a/test/files/run/macro-declared-in-method/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-object-class.check b/test/files/run/macro-term-declared-in-object-class.check index 47248d7af7..47248d7af7 100644 --- a/test/files/run/macro-declared-in-object-class.check +++ b/test/files/run/macro-term-declared-in-object-class.check diff --git a/test/files/run/macro-def-path-dependent-c.flags b/test/files/run/macro-term-declared-in-object-class.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-c.flags +++ b/test/files/run/macro-term-declared-in-object-class.flags diff --git a/test/files/run/macro-term-declared-in-object-class/Impls_1.scala b/test/files/run/macro-term-declared-in-object-class/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-object-class/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala index 204deed61c..204deed61c 100644 --- a/test/files/run/macro-declared-in-object-class/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-object-object.check b/test/files/run/macro-term-declared-in-object-object.check index 35af59e40f..35af59e40f 100644 --- a/test/files/run/macro-declared-in-object-object.check +++ b/test/files/run/macro-term-declared-in-object-object.check diff --git a/test/files/run/macro-def-path-dependent-d1.flags b/test/files/run/macro-term-declared-in-object-object.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-d1.flags +++ b/test/files/run/macro-term-declared-in-object-object.flags diff --git a/test/files/run/macro-term-declared-in-object-object/Impls_1.scala b/test/files/run/macro-term-declared-in-object-object/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-object-object/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala index e261a50f3d..e261a50f3d 100644 --- a/test/files/run/macro-declared-in-object-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-object.check b/test/files/run/macro-term-declared-in-object.check index 4d955a96b1..4d955a96b1 100644 --- a/test/files/run/macro-declared-in-object.check +++ b/test/files/run/macro-term-declared-in-object.check diff --git a/test/files/run/macro-def-path-dependent-d2.flags b/test/files/run/macro-term-declared-in-object.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-d2.flags +++ b/test/files/run/macro-term-declared-in-object.flags diff --git a/test/files/run/macro-term-declared-in-object/Impls_1.scala b/test/files/run/macro-term-declared-in-object/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-object/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala index a5a4862ba0..a5a4862ba0 100644 --- a/test/files/run/macro-declared-in-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-package-object.check b/test/files/run/macro-term-declared-in-package-object.check index bc0069178d..bc0069178d 100644 --- a/test/files/run/macro-declared-in-package-object.check +++ b/test/files/run/macro-term-declared-in-package-object.check diff --git a/test/files/run/macro-expand-implicit-macro-is-view.flags b/test/files/run/macro-term-declared-in-package-object.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-expand-implicit-macro-is-view.flags +++ b/test/files/run/macro-term-declared-in-package-object.flags diff --git a/test/files/run/macro-term-declared-in-package-object/Impls_1.scala b/test/files/run/macro-term-declared-in-package-object/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-package-object/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-package-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala index 54a5962e80..54a5962e80 100644 --- a/test/files/run/macro-declared-in-package-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-refinement.check b/test/files/run/macro-term-declared-in-refinement.check index 09b8d015a6..09b8d015a6 100644 --- a/test/files/run/macro-declared-in-refinement.check +++ b/test/files/run/macro-term-declared-in-refinement.check diff --git a/test/files/run/macro-expand-tparams-bounds-a.flags b/test/files/run/macro-term-declared-in-refinement.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-bounds-a.flags +++ b/test/files/run/macro-term-declared-in-refinement.flags diff --git a/test/files/run/macro-term-declared-in-refinement/Impls_1.scala b/test/files/run/macro-term-declared-in-refinement/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-refinement/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-refinement/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala index f746c2da57..ff9a66d58a 100644 --- a/test/files/run/macro-declared-in-refinement/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala @@ -1,6 +1,9 @@ + +import scala.language.reflectiveCalls + class Base object Test extends App { val macros = new Base { def foo = macro Impls.foo } macros.foo -}
\ No newline at end of file +} diff --git a/test/files/run/macro-declared-in-trait.check b/test/files/run/macro-term-declared-in-trait.check index 0d70ac74f3..0d70ac74f3 100644 --- a/test/files/run/macro-declared-in-trait.check +++ b/test/files/run/macro-term-declared-in-trait.check diff --git a/test/files/run/macro-expand-tparams-bounds-b.flags b/test/files/run/macro-term-declared-in-trait.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-bounds-b.flags +++ b/test/files/run/macro-term-declared-in-trait.flags diff --git a/test/files/run/macro-term-declared-in-trait/Impls_1.scala b/test/files/run/macro-term-declared-in-trait/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-trait/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-trait/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala index f75906b636..f75906b636 100644 --- a/test/files/run/macro-declared-in-trait/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala diff --git a/test/files/run/t7291a.flags b/test/files/run/macro-toplevel-companion-a.check index e69de29bb2..e69de29bb2 100644 --- a/test/files/run/t7291a.flags +++ b/test/files/run/macro-toplevel-companion-a.check diff --git a/test/files/run/macro-expand-tparams-only-in-impl.flags b/test/files/run/macro-toplevel-companion-a.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-only-in-impl.flags +++ b/test/files/run/macro-toplevel-companion-a.flags diff --git a/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala b/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala new file mode 100644 index 0000000000..23e8694ddc --- /dev/null +++ b/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Macros { + def impl(c: Context) = { + import c.universe._ + val synthetic = reify{ class C { override def toString = "C" }; object C { implicit val c = new C } }.tree + val defs = synthetic.asInstanceOf[Block].stats.asInstanceOf[List[ImplDef]] + if (c.topLevelRef(TypeName("C")).isEmpty) c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, defs: _*) + c.literalUnit + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-a/Test_2.scala b/test/files/run/macro-toplevel-companion-a/Test_2.scala new file mode 100644 index 0000000000..78b65b5b1f --- /dev/null +++ b/test/files/run/macro-toplevel-companion-a/Test_2.scala @@ -0,0 +1,8 @@ +import Macros._ + +object Test extends App { + foo; + implicitly[C]; + foo; + implicitly[C]; +}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-b.check b/test/files/run/macro-toplevel-companion-b.check new file mode 100644 index 0000000000..bd30dc75d3 --- /dev/null +++ b/test/files/run/macro-toplevel-companion-b.check @@ -0,0 +1,4 @@ +reflective compilation has failed: + +Companions 'class C' and 'object C' must be defined in same file: + Found in <synthetic file name> and <synthetic file name> diff --git a/test/files/run/macro-expand-tparams-optional.flags b/test/files/run/macro-toplevel-companion-b.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-optional.flags +++ b/test/files/run/macro-toplevel-companion-b.flags diff --git a/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala b/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala new file mode 100644 index 0000000000..f30adc2965 --- /dev/null +++ b/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Macros { + def impl(c: Context) = { + import c.universe._ + val Block(List(cdef: ClassDef), _) = reify{ class C }.tree + val classRef = c.topLevelRef(TypeName("C")) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, cdef) + val Block(List(mdef: ModuleDef), _) = reify{ object C }.tree + val moduleRef = c.topLevelRef(TermName("C")) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, mdef) + c.literalUnit + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-b/Test_2.scala b/test/files/run/macro-toplevel-companion-b/Test_2.scala new file mode 100644 index 0000000000..4e766bde89 --- /dev/null +++ b/test/files/run/macro-toplevel-companion-b/Test_2.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.{ToolBox, ToolBoxError} +import Macros._ + +object Test extends App { + val tb = cm.mkToolBox() + try tb.compile(Select(Ident(TermName("Macros")), TermName("foo"))) + catch { case ToolBoxError(message, _) => println("""(Found in|and) .*?compileLateSynthetic-.*?\.scala""".r.replaceAllIn(message, m => m.group(1) + " <synthetic file name>")) } +}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-c.check b/test/files/run/macro-toplevel-companion-c.check new file mode 100644 index 0000000000..4052c472f8 --- /dev/null +++ b/test/files/run/macro-toplevel-companion-c.check @@ -0,0 +1,3 @@ +error: Companions 'class C' and 'object C' must be defined in same file: + Found in <synthetic file name> and newSource1.scala + diff --git a/test/files/run/macro-expand-tparams-prefix-a.flags b/test/files/run/macro-toplevel-companion-c.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-a.flags +++ b/test/files/run/macro-toplevel-companion-c.flags diff --git a/test/files/run/macro-toplevel-companion-c.scala b/test/files/run/macro-toplevel-companion-c.scala new file mode 100644 index 0000000000..c315f8b942 --- /dev/null +++ b/test/files/run/macro-toplevel-companion-c.scala @@ -0,0 +1,51 @@ +import scala.tools.partest._ +import java.io._ + +object Test extends DirectTest { + def code = ??? + + def macros_1 = """ + package test + + import scala.reflect.macros.Context + import language.experimental.macros + + object Macros { + def impl(c: Context) = { + import c.universe._ + val Block(List(cdef: ClassDef), _) = reify{ class C }.tree + val ref = c.topLevelRef(TypeName("test.C")) orElse c.introduceTopLevel("test", cdef) + c.literalUnit + } + + def foo = macro impl + } + """ + def compileMacros() = { + val classpath = List(sys.props("partest.lib"), sys.props("partest.reflect")) mkString sys.props("path.separator") + compileString(newCompiler("-language:experimental.macros", "-cp", classpath, "-d", testOutput.path))(macros_1) + } + + def test_2 = """ + package test + object C { Macros.foo } + """ + def compileTest() = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(test_2) + } + + def show(): Unit = { + // redirect err to string, for logging + val prevErr = System.err + val baos = new ByteArrayOutputStream() + System.setErr(new PrintStream(baos)) + log("Compiling Macros_1...") + if (compileMacros()) { + log("Compiling Test_2...") + if (compileTest()) log("Success!") else log("Failed...") + } + println("""(Found in|and) .*?compileLateSynthetic-.*?\.scala""".r.replaceAllIn(baos.toString, m => m.group(1) + " <synthetic file name>")) + System.setErr(prevErr) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel.check b/test/files/run/macro-toplevel.check new file mode 100644 index 0000000000..257c3764fd --- /dev/null +++ b/test/files/run/macro-toplevel.check @@ -0,0 +1,2 @@ +I've been created from Macros.foo +I've been created from Macros.foo diff --git a/test/files/run/macro-toplevel/Macros_1.scala b/test/files/run/macro-toplevel/Macros_1.scala new file mode 100644 index 0000000000..f681c86735 --- /dev/null +++ b/test/files/run/macro-toplevel/Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Macros { + def impl(c: Context) = { + import c.universe._ + val msg = "I've been created from " + c.macroApplication + val Block(List(synthetic: ClassDef), _) = reify{ class SomeUniqueName { def hello = c.literal(msg).splice } }.tree + val ref = c.topLevelRef(synthetic.name) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, synthetic) + c.Expr[String](Select(Apply(Select(New(ref), nme.CONSTRUCTOR), List()), TermName("hello"))) + } + + def foo = macro impl + def foo2 = macro impl +} diff --git a/test/files/run/macro-toplevel/Test_2.scala b/test/files/run/macro-toplevel/Test_2.scala new file mode 100644 index 0000000000..eee2d6ae13 --- /dev/null +++ b/test/files/run/macro-toplevel/Test_2.scala @@ -0,0 +1,6 @@ +import Macros._ + +object Test extends App { + println(Macros.foo) + println(Macros.foo2) +}
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-implicitsdisabled.check b/test/files/run/macro-typecheck-implicitsdisabled.check index c4fa2c5c28..91d8fabd72 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled.check +++ b/test/files/run/macro-typecheck-implicitsdisabled.check @@ -1,2 +1,2 @@ -scala.this.Predef.any2ArrowAssoc[Int](1).->[Int](2) +scala.this.Predef.ArrowAssoc[Int](1).->[Int](2) scala.reflect.macros.TypecheckException: value -> is not a member of Int diff --git a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala index 633cb930fc..dbeb7efbc0 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def impl_with_implicits_enabled(c: Context) = { import c.universe._ - val tree1 = Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + val tree1 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withImplicitViewsDisabled = false) c.literal(ttree1.toString) } @@ -15,7 +15,7 @@ object Macros { import c.universe._ try { - val tree2 = Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + val tree2 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withImplicitViewsDisabled = true) c.literal(ttree2.toString) } catch { diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check index 29a881f8b1..e0e880ab66 100644 --- a/test/files/run/macro-typecheck-macrosdisabled.check +++ b/test/files/run/macro-typecheck-macrosdisabled.check @@ -7,7 +7,7 @@ $treecreator1.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $u.Literal.apply($u.Constant.apply(2)) @@ -20,7 +20,7 @@ $typecreator2.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $u.ConstantType.apply($u.Constant.apply(2)) diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala index f693ad78cc..ff535fea8d 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -4,8 +4,8 @@ object Macros { def impl_with_macros_enabled(c: Context) = { import c.universe._ - val ru = Select(Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("package")), newTermName("universe")) - val tree1 = Apply(Select(ru, newTermName("reify")), List(Literal(Constant(2)))) + val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe")) + val tree1 = Apply(Select(ru, TermName("reify")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) c.literal(ttree1.toString) } @@ -21,7 +21,7 @@ object Macros { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) + val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) c.literal(ttree2.toString) } diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check index 27d15d47af..347dfec1dc 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2.check +++ b/test/files/run/macro-typecheck-macrosdisabled2.check @@ -7,10 +7,10 @@ $treecreator1.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) } }; new $treecreator1() @@ -20,7 +20,7 @@ $typecreator2.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor)) diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala index 1dbf5a1a87..a96e0c53b6 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -4,8 +4,8 @@ object Macros { def impl_with_macros_enabled(c: Context) = { import c.universe._ - val ru = Select(Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("package")), newTermName("universe")) - val tree1 = Apply(Select(ru, newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe")) + val tree1 = Apply(Select(ru, TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) c.literal(ttree1.toString) } @@ -21,7 +21,7 @@ object Macros { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) c.literal(ttree2.toString) } diff --git a/test/files/run/manifests-new.scala b/test/files/run/manifests-new.scala index f1596dee81..8b42e3ca73 100644 --- a/test/files/run/manifests-new.scala +++ b/test/files/run/manifests-new.scala @@ -1,3 +1,6 @@ + + +import scala.language.{ higherKinds, postfixOps } import scala.reflect.runtime.universe._ object Test @@ -146,4 +149,4 @@ object Test } def main(args: Array[String]): Unit = runAllTests -}
\ No newline at end of file +} diff --git a/test/files/run/manifests-old.scala b/test/files/run/manifests-old.scala index 621689a254..d8b1e751d4 100644 --- a/test/files/run/manifests-old.scala +++ b/test/files/run/manifests-old.scala @@ -1,3 +1,6 @@ +import scala.language.{ higherKinds, postfixOps } + +@deprecated("Suppress warnings", since="2.11") object Test { object Variances extends Enumeration { @@ -144,4 +147,4 @@ object Test } def main(args: Array[String]): Unit = runAllTests -}
\ No newline at end of file +} diff --git a/test/files/run/mapConserve.scala b/test/files/run/mapConserve.scala index 013095b1de..330fb34ca1 100644 --- a/test/files/run/mapConserve.scala +++ b/test/files/run/mapConserve.scala @@ -1,3 +1,6 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import scala.annotation.tailrec import scala.collection.mutable.ListBuffer @@ -50,4 +53,4 @@ object Test { checkStackOverflow(); } -}
\ No newline at end of file +} diff --git a/test/files/run/map_java_conversions.scala b/test/files/run/map_java_conversions.scala index 7714b2cc74..751167c04d 100644 --- a/test/files/run/map_java_conversions.scala +++ b/test/files/run/map_java_conversions.scala @@ -19,7 +19,7 @@ object Test { val concMap = new java.util.concurrent.ConcurrentHashMap[String, String] test(concMap) - val cmap = asScalaConcurrentMap(concMap) + val cmap = mapAsScalaConcurrentMap(concMap) cmap.putIfAbsent("absentKey", "absentValue") cmap.put("somekey", "somevalue") assert(cmap.remove("somekey", "somevalue") == true) diff --git a/test/files/run/memberpos.check b/test/files/run/memberpos.check new file mode 100644 index 0000000000..9e3a807f5a --- /dev/null +++ b/test/files/run/memberpos.check @@ -0,0 +1,11 @@ +newSource1.scala +2,4 class A +6,28 object A + 7,10 def bippy + 8 def hello + 11,27 class Dingo + 12,26 def foooooz + 22 val a +30 class B + 30 def f + diff --git a/test/files/run/memberpos.scala b/test/files/run/memberpos.scala new file mode 100644 index 0000000000..f2b79c0ec1 --- /dev/null +++ b/test/files/run/memberpos.scala @@ -0,0 +1,39 @@ +import scala.tools.partest._ + +// Simple sanity test for -Yshow-member-pos. +object Test extends DirectTest { + override def extraSettings: String = "-usejavacp -Ystop-after:parser -Yshow-member-pos \"\" -d " + testOutput.path + override def show() = compile() + override def code = """ +class A(val a: Int = 1) { + +} + +object A { + def bippy = { + def hello = 55 + "" + hello + } + class Dingo { + def foooooz = /**** + + + + + + ****/ { + + + + val a = 1 + + + a + } + } +} + +class B { def f = 1 } + +""" +} diff --git a/test/files/run/misc.check b/test/files/run/misc.check index 9fa7b72d50..56116f8104 100644 --- a/test/files/run/misc.check +++ b/test/files/run/misc.check @@ -1,3 +1,27 @@ +misc.scala:46: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 42; + ^ +misc.scala:47: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 42l; + ^ +misc.scala:48: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 23.5f; + ^ +misc.scala:49: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 23.5; + ^ +misc.scala:50: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + "Hello"; + ^ +misc.scala:51: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 32 + 45; + ^ +misc.scala:62: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + x; + ^ +misc.scala:74: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 1 < 2; + ^ ### Hello ### 17 ### Bye diff --git a/test/files/run/mutable-treeset.scala b/test/files/run/mutable-treeset.scala new file mode 100644 index 0000000000..c9918cba96 --- /dev/null +++ b/test/files/run/mutable-treeset.scala @@ -0,0 +1,145 @@ +import scala.collection.mutable.TreeSet + +object Test extends App { + val list = List(6,5,4,3,2,1,1,2,3,4,5,6,6,5,4,3,2,1) + val distinct = list.distinct + val sorted = distinct.sorted + + // sublist stuff for a single level of slicing + val min = list.min + val max = list.max + val nonlist = ((min - 10) until (max + 20) filterNot list.contains).toList + val sublist = list filter {x => x >=(min + 1) && x < max} + val distinctSublist = sublist.distinct + val subnonlist = min :: max :: nonlist + val subsorted = distinctSublist.sorted + + // subsublist for a 2nd level of slicing + val almostmin = sublist.min + val almostmax = sublist.max + val subsublist = sublist filter {x => x >=(almostmin + 1) && x < almostmax} + val distinctSubsublist = subsublist.distinct + val subsubnonlist = almostmin :: almostmax :: subnonlist + val subsubsorted = distinctSubsublist.sorted + + def testSize { + def check(set : TreeSet[Int], list: List[Int]) { + assert(set.size == list.size, s"$set had size ${set.size} while $list had size ${list.size}") + } + + check(TreeSet[Int](), List[Int]()) + val set = TreeSet(list:_*) + check(set, distinct) + check(set.clone, distinct) + + val subset = set from (min + 1) until max + check(subset, distinctSublist) + check(subset.clone, distinctSublist) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, distinctSubsublist) + check(subsubset.clone, distinctSubsublist) + } + + def testContains { + def check(set : TreeSet[Int], list: List[Int], nonlist: List[Int]) { + assert(list forall set.apply, s"$set did not contain all elements of $list using apply") + assert(list forall set.contains, s"$set did not contain all elements of $list using contains") + assert(!(nonlist exists set.apply), s"$set had an element from $nonlist using apply") + assert(!(nonlist exists set.contains), s"$set had an element from $nonlist using contains") + } + + val set = TreeSet(list:_*) + check(set, list, nonlist) + check(set.clone, list, nonlist) + + val subset = set from (min + 1) until max + check(subset, sublist, subnonlist) + check(subset.clone, sublist, subnonlist) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, subsublist, subsubnonlist) + check(subsubset.clone, subsublist, subsubnonlist) + } + + def testAdd { + def check(set : TreeSet[Int], list: List[Int], nonlist: List[Int]) { + var builtList = List[Int]() + for (x <- list) { + set += x + builtList = (builtList :+ x).distinct.sorted filterNot nonlist.contains + assert(builtList forall set.apply, s"$set did not contain all elements of $builtList using apply") + assert(builtList.size == set.size, s"$set had size ${set.size} while $builtList had size ${builtList.size}") + } + assert(!(nonlist exists set.apply), s"$set had an element from $nonlist using apply") + assert(!(nonlist exists set.contains), s"$set had an element from $nonlist using contains") + } + + val set = TreeSet[Int]() + val clone = set.clone + val subset = set.clone from (min + 1) until max + val subclone = subset.clone + val subsubset = subset.clone from (almostmin + 1) until almostmax + val subsubclone = subsubset.clone + + check(set, list, nonlist) + check(clone, list, nonlist) + + check(subset, list, subnonlist) + check(subclone, list, subnonlist) + + check(subsubset, list, subsubnonlist) + check(subsubclone, list, subsubnonlist) + } + + def testRemove { + def check(set: TreeSet[Int], sorted: List[Int]) { + var builtList = sorted + for (x <- list) { + set remove x + builtList = builtList filterNot (_ == x) + assert(builtList forall set.apply, s"$set did not contain all elements of $builtList using apply") + assert(builtList.size == set.size, s"$set had size $set.size while $builtList had size $builtList.size") + } + } + val set = TreeSet(list:_*) + val clone = set.clone + val subset = set.clone from (min + 1) until max + val subclone = subset.clone + val subsubset = subset.clone from (almostmin + 1) until almostmax + val subsubclone = subsubset.clone + + check(set, sorted) + check(clone, sorted) + + check(subset, subsorted) + check(subclone, subsorted) + + check(subsubset, subsubsorted) + check(subsubclone, subsubsorted) + } + + def testIterator { + def check(set: TreeSet[Int], list: List[Int]) { + val it = set.iterator.toList + assert(it == list, s"$it did not equal $list") + } + val set = TreeSet(list: _*) + check(set, sorted) + check(set.clone, sorted) + + val subset = set from (min + 1) until max + check(subset, subsorted) + check(subset.clone, subsorted) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, subsubsorted) + check(subsubset.clone, subsubsorted) + } + + testSize + testContains + testAdd + testRemove + testIterator +} diff --git a/test/files/run/names-defaults.check b/test/files/run/names-defaults.check index f253de71d6..0037822f3b 100644 --- a/test/files/run/names-defaults.check +++ b/test/files/run/names-defaults.check @@ -1,3 +1,7 @@ +names-defaults.scala:269: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + spawn(b = { val ttt = 1; ttt }, a = 0) + ^ +warning: there were 4 deprecation warning(s); re-run with -deprecation for details 1: @ get: $ get: 2 diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index 220414f02a..05cd4a540c 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds, existentials } + object Test extends App { def get[T](x: T) = { println("get: "+ x); x } diff --git a/test/files/run/no-pickle-skolems.check b/test/files/run/no-pickle-skolems.check new file mode 100644 index 0000000000..d64066171a --- /dev/null +++ b/test/files/run/no-pickle-skolems.check @@ -0,0 +1 @@ +OK! diff --git a/test/files/run/no-pickle-skolems/Source_1.scala b/test/files/run/no-pickle-skolems/Source_1.scala new file mode 100644 index 0000000000..1b4cbfa788 --- /dev/null +++ b/test/files/run/no-pickle-skolems/Source_1.scala @@ -0,0 +1,5 @@ +package s + +trait Foo { def to[CC[X]](implicit cc: CC[Int]): Unit } + +class Bar extends Foo { def to[CC[X]](implicit cc: CC[Int]): Unit = ??? } diff --git a/test/files/run/no-pickle-skolems/Test_2.scala b/test/files/run/no-pickle-skolems/Test_2.scala new file mode 100644 index 0000000000..8fd6016aea --- /dev/null +++ b/test/files/run/no-pickle-skolems/Test_2.scala @@ -0,0 +1,39 @@ + +import scala.language.reflectiveCalls +import scala.reflect.runtime.universe._ + +object Test { + /** Collects symbols by the given name, even if they're not + * named CC. + */ + def collectSymbols[T: TypeTag](inMethod: TermName, name: String): List[String] = { + val m = typeOf[T] member inMethod typeSignatureIn typeOf[T] + var buf: List[Symbol] = Nil + var seen: Set[Symbol] = Set() + def id(s: Symbol): Int = s.asInstanceOf[{ def id: Int }].id + + def check(s: Symbol) { + if (!seen(s)) { + seen += s + if (s.name.toString == name) buf ::= s + } + } + def loop(t: Type) { + t match { + case TypeRef(pre, sym, args) => loop(pre) ; check(sym) ; args foreach loop + case PolyType(tparams, restpe) => tparams foreach { tp => check(tp) ; check(tp.owner) ; loop(tp.typeSignature) } ; loop(restpe) + case MethodType(params, restpe) => params foreach { p => check(p) ; loop(p.typeSignature) } ; loop(restpe) + case _ => + } + } + loop(m) + + buf.reverse.distinct map (s => s.name + "#" + id(s)) + } + + def main(args: Array[String]): Unit = { + val syms = collectSymbols[s.Bar]("to", "CC") + assert(syms.size == 1, syms) + println("OK!") + } +} diff --git a/test/files/run/option-fold.scala b/test/files/run/option-fold.scala index d554ba4f9b..7e21403c2e 100644 --- a/test/files/run/option-fold.scala +++ b/test/files/run/option-fold.scala @@ -7,13 +7,14 @@ object Test { def g(x: Option[A]) = x.fold(-1) { case B => 0 case C(x) => x + case _ => ??? } def main(args: Array[String]): Unit = { - println(f(None)) - println(f(Some(5))) - println(g(None)) - println(g(Some(B))) - println(g(Some(C(1)))) + println(f(None)) //List() + println(f(Some(5))) //List(5) + println(g(None)) //-1 + println(g(Some(B))) //0 + println(g(Some(C(1)))) //1 } } diff --git a/test/files/run/patmat-exprs.scala b/test/files/run/patmat-exprs.scala index dfc78e2ca5..56e4e01598 100644 --- a/test/files/run/patmat-exprs.scala +++ b/test/files/run/patmat-exprs.scala @@ -1,3 +1,5 @@ + +import scala.language.{ implicitConversions } import runtime.ScalaRunTime object Test { @@ -576,4 +578,4 @@ trait Pattern { implicit def long2Constant[T](l: Long)(implicit num: NumericOps[T]): Leaf[T] = const(num.fromDouble(l.toDouble)) } -}
\ No newline at end of file +} diff --git a/test/files/run/patmat_unapp_abstype-new.check b/test/files/run/patmat_unapp_abstype-new.check index 42c54631d2..c5511e9516 100644 --- a/test/files/run/patmat_unapp_abstype-new.check +++ b/test/files/run/patmat_unapp_abstype-new.check @@ -1,3 +1,9 @@ +patmat_unapp_abstype-new.scala:21: warning: abstract type pattern TypesUser.this.TypeRef is unchecked since it is eliminated by erasure + case TypeRef(x) => println("TypeRef") + ^ +patmat_unapp_abstype-new.scala:53: warning: abstract type pattern Intermed.this.Foo is unchecked since it is eliminated by erasure + case Foo(x) => println("Foo") + ^ TypeRef MethodType Bar diff --git a/test/files/run/patmat_unapp_abstype-old.check b/test/files/run/patmat_unapp_abstype-old.check deleted file mode 100644 index 72239d16cd..0000000000 --- a/test/files/run/patmat_unapp_abstype-old.check +++ /dev/null @@ -1,4 +0,0 @@ -TypeRef -none of the above -Bar -Foo diff --git a/test/files/run/patmat_unapp_abstype-old.flags b/test/files/run/patmat_unapp_abstype-old.flags deleted file mode 100644 index ba80cad69b..0000000000 --- a/test/files/run/patmat_unapp_abstype-old.flags +++ /dev/null @@ -1 +0,0 @@ --Xoldpatmat diff --git a/test/files/run/patmat_unapp_abstype-old.scala b/test/files/run/patmat_unapp_abstype-old.scala deleted file mode 100644 index 45496f08a2..0000000000 --- a/test/files/run/patmat_unapp_abstype-old.scala +++ /dev/null @@ -1,83 +0,0 @@ -// abstract types and extractors, oh my! -trait TypesAPI { - trait Type - - // an alternative fix (implemented in the virtual pattern matcher, is to replace the isInstanceOf by a manifest-based run-time test) - // that's what typeRefMani is for - type TypeRef <: Type //; implicit def typeRefMani: Manifest[TypeRef] - val TypeRef: TypeRefExtractor; trait TypeRefExtractor { - def apply(x: Int): TypeRef - def unapply(x: TypeRef): Option[(Int)] - } - - // just for illustration, should follow the same pattern as TypeRef - case class MethodType(n: Int) extends Type -} - -// user should not be exposed to the implementation -trait TypesUser extends TypesAPI { - def shouldNotCrash(tp: Type): Unit = { - tp match { - case TypeRef(x) => println("TypeRef") - // the above checks tp.isInstanceOf[TypeRef], which is erased to tp.isInstanceOf[Type] - // before calling TypeRef.unapply(tp), which will then crash unless tp.isInstanceOf[TypesImpl#TypeRef] (which is not implied by tp.isInstanceOf[Type]) - // tp.isInstanceOf[TypesImpl#TypeRef] is equivalent to classOf[TypesImpl#TypeRef].isAssignableFrom(tp.getClass) - // this is equivalent to manifest - // it is NOT equivalent to manifest[Type] <:< typeRefMani - case MethodType(x) => println("MethodType") - case _ => println("none of the above") - } - } -} - -trait TypesImpl extends TypesAPI { - object TypeRef extends TypeRefExtractor // this will have a bridged unapply(x: Type) = unapply(x.asInstanceOf[TypeRef]) - case class TypeRef(n: Int) extends Type // this has a bridge from TypesAPI#Type to TypesImpl#TypeRef - // --> the cast in the bridge will fail because the pattern matcher can't type test against the abstract types in TypesUser - //lazy val typeRefMani = manifest[TypeRef] -} - -trait Foos { - trait Bar - type Foo <: Bar - trait FooExtractor { - def unapply(foo: Foo): Option[Int] - } - val Foo: FooExtractor -} - -trait RealFoos extends Foos { - class Foo(val x: Int) extends Bar - object Foo extends FooExtractor { - def unapply(foo: Foo): Option[Int] = Some(foo.x) - } -} - -trait Intermed extends Foos { - def crash(bar: Bar): Unit = - bar match { - case Foo(x) => println("Foo") - case _ => println("Bar") - } -} - -object TestUnappStaticallyKnownSynthetic extends TypesImpl with TypesUser { - def test() = { - shouldNotCrash(TypeRef(10)) // should and does print "TypeRef" - // once #1697/#2337 are fixed, this should generate the correct output - shouldNotCrash(MethodType(10)) // should print "MethodType" but prints "none of the above" -- good one, pattern matcher! - } -} - -object TestUnappDynamicSynth extends RealFoos with Intermed { - case class FooToo(n: Int) extends Bar - def test() = { - crash(FooToo(10)) - crash(new Foo(5)) - } -} - -object Test extends App { - TestUnappStaticallyKnownSynthetic.test() - TestUnappDynamicSynth.test() -} diff --git a/test/files/run/patmatnew.check b/test/files/run/patmatnew.check index e69de29bb2..56b8ac2f4f 100644 --- a/test/files/run/patmatnew.check +++ b/test/files/run/patmatnew.check @@ -0,0 +1,15 @@ +patmatnew.scala:351: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + case 1 => "OK" + ^ +patmatnew.scala:352: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + case 2 => assert(false); "KO" + ^ +patmatnew.scala:353: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + case 3 => assert(false); "KO" + ^ +patmatnew.scala:670: warning: This catches all Throwables. If this is really intended, use `case e : Throwable` to clear this warning. + case e => { + ^ +patmatnew.scala:489: warning: unreachable code + case _ if false => + ^ diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index a6f8199457..fb49e0c924 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -1,3 +1,6 @@ + +import scala.language.{ postfixOps } + object Test { def main(args: Array[String]) { diff --git a/test/files/run/pc-conversions.scala b/test/files/run/pc-conversions.scala index 60ee59c3c4..b1ef3d963e 100644 --- a/test/files/run/pc-conversions.scala +++ b/test/files/run/pc-conversions.scala @@ -1,4 +1,6 @@ - +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import collection._ diff --git a/test/files/run/pf-catch.scala b/test/files/run/pf-catch.scala index ba0781fe89..dfe43dc750 100644 --- a/test/files/run/pf-catch.scala +++ b/test/files/run/pf-catch.scala @@ -1,3 +1,5 @@ + +import scala.language.{ postfixOps } object Test { def shortName(x: AnyRef) = x.getClass.getName split '.' last type Handler[+T] = PartialFunction[Throwable, T] @@ -27,7 +29,7 @@ object Test { def main(args: Array[String]): Unit = { try f1 - catch { case x => println(shortName(x) + " slipped by.") } + catch { case x: Throwable => println(shortName(x) + " slipped by.") } f2 } diff --git a/test/files/run/preinits.check b/test/files/run/preinits.check index 5584ab261e..e97a14b77f 100644 --- a/test/files/run/preinits.check +++ b/test/files/run/preinits.check @@ -1,3 +1,9 @@ +preinits.scala:2: warning: Implementation restriction: early definitions in traits are not initialized before the super class is initialized. +trait B extends { override val x = 1 } with A { println("B") } + ^ +preinits.scala:3: warning: Implementation restriction: early definitions in traits are not initialized before the super class is initialized. +trait C extends { override val x = 2 } with A + ^ A B 2 diff --git a/test/files/run/primitive-sigs-2-new.scala b/test/files/run/primitive-sigs-2-new.scala index cf6de9c81b..1f39667b18 100644 --- a/test/files/run/primitive-sigs-2-new.scala +++ b/test/files/run/primitive-sigs-2-new.scala @@ -1,3 +1,5 @@ + +import scala.language.{ postfixOps } import scala.reflect.{ClassTag, classTag} import java.{ lang => jl } @@ -29,4 +31,4 @@ object Test { println(new C f) c3m.sorted foreach println } -}
\ No newline at end of file +} diff --git a/test/files/run/primitive-sigs-2-old.scala b/test/files/run/primitive-sigs-2-old.scala index b7152f7e3d..0a4be93f22 100644 --- a/test/files/run/primitive-sigs-2-old.scala +++ b/test/files/run/primitive-sigs-2-old.scala @@ -1,3 +1,5 @@ + +import scala.language.{ postfixOps } import java.{ lang => jl } trait T[A] { diff --git a/test/files/run/private-inline.check b/test/files/run/private-inline.check index 209e3ef4b6..eee7f2973b 100644 --- a/test/files/run/private-inline.check +++ b/test/files/run/private-inline.check @@ -1 +1,7 @@ +private-inline.scala:24: warning: Could not inline required method wrapper1 because callee contains exception handlers / finally clause, and is invoked with non-empty operand stack. + def f1b() = identity(wrapper1(5)) + ^ +private-inline.scala:29: warning: Could not inline required method wrapper2 because callee contains exception handlers / finally clause, and is invoked with non-empty operand stack. + def f2b() = identity(wrapper2(5)) + ^ 20 diff --git a/test/files/run/private-inline.flags b/test/files/run/private-inline.flags index eb4d19bcb9..00d3643fd4 100644 --- a/test/files/run/private-inline.flags +++ b/test/files/run/private-inline.flags @@ -1 +1 @@ --optimise
\ No newline at end of file +-optimise -Yinline-warnings diff --git a/test/files/run/private-inline.scala b/test/files/run/private-inline.scala index a62007779c..72cabaeff0 100644 --- a/test/files/run/private-inline.scala +++ b/test/files/run/private-inline.scala @@ -43,7 +43,7 @@ object Test { val foundClass = ( try Class.forName(clazz) - catch { case _ => null } + catch { case _: Throwable => null } ) assert(foundClass == null, foundClass) diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index bdf76ddce1..61b947214c 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -1,31 +1,32 @@ - phase name id description - ---------- -- ----------- - parser 1 parse source into ASTs, perform simple desugaring - namer 2 resolve names, attach symbols to named trees - packageobjects 3 load package objects - typer 4 the meat and potatoes: type the trees - patmat 5 translate match expressions - superaccessors 6 add super accessors in traits and nested classes - extmethods 7 add extension methods for inline classes - pickler 8 serialize symbol tables - refchecks 9 reference/override checking, translate nested objects - uncurry 10 uncurry, translate function values to anonymous classes - tailcalls 11 replace tail calls by jumps - specialize 12 @specialized-driven class and method specialization - explicitouter 13 this refs to outer pointers, translate patterns - erasure 14 erase types, add interfaces for traits - posterasure 15 clean up erased inline classes - lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 17 move nested functions to top level - constructors 18 move field definitions into constructors - flatten 19 eliminate inner classes - mixin 20 mixin composition - cleanup 21 platform-specific cleanups, generate reflective calls - icode 22 generate portable intermediate code - inliner 23 optimization: do inlining -inlineExceptionHandlers 24 optimization: inline exception handlers - closelim 25 optimization: eliminate uncalled closures - dce 26 optimization: eliminate dead code - jvm 27 generate JVM bytecode - terminal 28 The last phase in the compiler chain + phase name id description + ---------- -- ----------- + parser 1 parse source into ASTs, perform simple desugaring + namer 2 resolve names, attach symbols to named trees +packageobjects 3 load package objects + typer 4 the meat and potatoes: type the trees + patmat 5 translate match expressions +superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers, translate patterns + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + icode 22 generate portable intermediate code + inliner 23 optimization: do inlining +inlinehandlers 24 optimization: inline exception handlers + closelim 25 optimization: eliminate uncalled closures + constopt 26 optimization: optimize null and other constants + dce 27 optimization: eliminate dead code + jvm 28 generate JVM bytecode + terminal 29 The last phase in the compiler chain diff --git a/test/files/run/programmatic-main.scala b/test/files/run/programmatic-main.scala index 7bc5c5dfcf..08335ca6f6 100644 --- a/test/files/run/programmatic-main.scala +++ b/test/files/run/programmatic-main.scala @@ -1,3 +1,5 @@ + +import scala.language.postfixOps import scala.tools.nsc._ import io.Path diff --git a/test/files/run/range.scala b/test/files/run/range.scala index f08b2105d3..b81e67921a 100644 --- a/test/files/run/range.scala +++ b/test/files/run/range.scala @@ -16,6 +16,17 @@ object Test { catch { case _: IllegalArgumentException => true } ) assert(caught) + // #7432 + val noElemAtMin = ( + try { (10 until 10).min ; false } + catch { case _: NoSuchElementException => true } + ) + assert(noElemAtMin) + val noElemAtMax = ( + try { (10 until 10).max ; false } + catch { case _: NoSuchElementException => true } + ) + assert(noElemAtMax) } case class GR[T](val x: T)(implicit val num: Integral[T]) { diff --git a/test/files/run/records.scala b/test/files/run/records.scala index 96b0b4cb0f..bae0d943ff 100644 --- a/test/files/run/records.scala +++ b/test/files/run/records.scala @@ -1,3 +1,6 @@ + +import scala.language.{ reflectiveCalls } + trait C { def f: Int } diff --git a/test/files/run/reflection-allmirrors-tostring.scala b/test/files/run/reflection-allmirrors-tostring.scala index 73afff291c..41bab5ac0e 100644 --- a/test/files/run/reflection-allmirrors-tostring.scala +++ b/test/files/run/reflection-allmirrors-tostring.scala @@ -1,3 +1,5 @@ + +import scala.language.higherKinds import scala.reflect.runtime.universe._ class C { @@ -26,18 +28,18 @@ object Test extends App { println(cm.reflect(new C)) val im = cm.reflect(new C) - println(im.reflectField(typeOf[C].member(newTermName("f1")).asTerm)) - println(im.reflectField(typeOf[C].member(newTermName("f2")).asTerm)) - println(im.reflectMethod(typeOf[C].member(newTermName("m1")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m2")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m3")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m4")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m5")).asMethod)) - println(im.reflectClass(typeOf[C].member(newTypeName("C")).asClass)) - println(im.reflectModule(typeOf[C].member(newTermName("M")).asModule)) + println(im.reflectField(typeOf[C].member(TermName("f1")).asTerm)) + println(im.reflectField(typeOf[C].member(TermName("f2")).asTerm)) + println(im.reflectMethod(typeOf[C].member(TermName("m1")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m2")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m3")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m4")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m5")).asMethod)) + println(im.reflectClass(typeOf[C].member(TypeName("C")).asClass)) + println(im.reflectModule(typeOf[C].member(TermName("M")).asModule)) val c = cm.staticClass("C") - val cc = typeOf[C].member(newTypeName("C")).asClass + val cc = typeOf[C].member(TypeName("C")).asClass println(cm.reflectClass(c).reflectConstructor(c.typeSignature.member(nme.CONSTRUCTOR).asMethod)) println(im.reflectClass(cc).reflectConstructor(cc.typeSignature.member(nme.CONSTRUCTOR).asMethod)) -}
\ No newline at end of file +} diff --git a/test/files/run/reflection-enclosed-basic.scala b/test/files/run/reflection-enclosed-basic.scala index 1dcb6c2a27..7b9e0c20dc 100644 --- a/test/files/run/reflection-enclosed-basic.scala +++ b/test/files/run/reflection-enclosed-basic.scala @@ -12,7 +12,7 @@ private object B6 extends B2 { override def toString = "B6"; override def foo = object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } @@ -20,7 +20,7 @@ object Test extends App { def testNestedClass(name: String) = { val sym = cm.staticClass(name) println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) diff --git a/test/files/run/reflection-enclosed-inner-basic.scala b/test/files/run/reflection-enclosed-inner-basic.scala index 2b2c701993..c1cf9bc336 100644 --- a/test/files/run/reflection-enclosed-inner-basic.scala +++ b/test/files/run/reflection-enclosed-inner-basic.scala @@ -18,15 +18,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testInnerClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(new B).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -37,7 +37,7 @@ object Test extends App { testInnerClass("B2") def testInnerModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflect(new B).reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-inner-inner-basic.scala b/test/files/run/reflection-enclosed-inner-inner-basic.scala index 1b9e19d37d..8a73fac522 100644 --- a/test/files/run/reflection-enclosed-inner-inner-basic.scala +++ b/test/files/run/reflection-enclosed-inner-inner-basic.scala @@ -20,15 +20,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testInnerClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val outer1 = new B val outer2 = new outer1.BB val ctorMirror = cm.reflect(outer2).reflectClass(sym).reflectConstructor(ctor) @@ -41,7 +41,7 @@ object Test extends App { testInnerClass("B2") def testInnerModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val outer1 = new B val outer2 = new outer1.BB diff --git a/test/files/run/reflection-enclosed-inner-nested-basic.scala b/test/files/run/reflection-enclosed-inner-nested-basic.scala index 2800ee2548..6c2fc6df7a 100644 --- a/test/files/run/reflection-enclosed-inner-nested-basic.scala +++ b/test/files/run/reflection-enclosed-inner-nested-basic.scala @@ -21,15 +21,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testNestedClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(outer1.BB).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -40,7 +40,7 @@ object Test extends App { testNestedClass("B2") def testNestedModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflect(outer1.BB).reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-nested-basic.scala b/test/files/run/reflection-enclosed-nested-basic.scala index 8b740c2da2..180ac4ebee 100644 --- a/test/files/run/reflection-enclosed-nested-basic.scala +++ b/test/files/run/reflection-enclosed-nested-basic.scala @@ -18,15 +18,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testNestedClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -37,7 +37,7 @@ object Test extends App { testNestedClass("B2") def testNestedModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-nested-inner-basic.scala b/test/files/run/reflection-enclosed-nested-inner-basic.scala index 7466733d37..2558b8035a 100644 --- a/test/files/run/reflection-enclosed-nested-inner-basic.scala +++ b/test/files/run/reflection-enclosed-nested-inner-basic.scala @@ -20,15 +20,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testInnerClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(new B.BB).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -39,7 +39,7 @@ object Test extends App { testInnerClass("B2") def testInnerModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflect(new B.BB).reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-nested-nested-basic.scala b/test/files/run/reflection-enclosed-nested-nested-basic.scala index 8335ea482a..b4711c9a8c 100644 --- a/test/files/run/reflection-enclosed-nested-nested-basic.scala +++ b/test/files/run/reflection-enclosed-nested-nested-basic.scala @@ -20,15 +20,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testNestedClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -39,7 +39,7 @@ object Test extends App { testNestedClass("B2") def testNestedModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-equality.check b/test/files/run/reflection-equality.check index 65b525731f..b3b66f48d6 100644 --- a/test/files/run/reflection-equality.check +++ b/test/files/run/reflection-equality.check @@ -29,7 +29,7 @@ scala.AnyRef { def methodIntIntInt(x: scala.Int,y: scala.Int): scala.Int } -scala> val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethod +scala> val ms: MethodSymbol = ts.declaration(TermName("methodIntIntInt")).asMethod ms: reflect.runtime.universe.MethodSymbol = method methodIntIntInt scala> val MethodType( _, t1 ) = ms.typeSignature diff --git a/test/files/run/reflection-equality.scala b/test/files/run/reflection-equality.scala index 8fc82721e7..40f116bb53 100644 --- a/test/files/run/reflection-equality.scala +++ b/test/files/run/reflection-equality.scala @@ -11,7 +11,7 @@ object Test extends ReplTest { |def im: InstanceMirror = cm.reflect(new X) |val cs: ClassSymbol = im.symbol |val ts: Type = cs.typeSignature - |val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethod + |val ms: MethodSymbol = ts.declaration(TermName("methodIntIntInt")).asMethod |val MethodType( _, t1 ) = ms.typeSignature |val t2 = typeOf[scala.Int] |t1 == t2 diff --git a/test/files/run/reflection-fieldmirror-accessorsareokay.scala b/test/files/run/reflection-fieldmirror-accessorsareokay.scala index 16354025f3..3926ab7835 100644 --- a/test/files/run/reflection-fieldmirror-accessorsareokay.scala +++ b/test/files/run/reflection-fieldmirror-accessorsareokay.scala @@ -24,6 +24,6 @@ object Test extends App { } } - test(cs.typeSignature.declaration(newTermName("x")).asTerm) - test(cs.typeSignature.declaration(newTermName("x_$eq")).asTerm) + test(cs.typeSignature.declaration(TermName("x")).asTerm) + test(cs.typeSignature.declaration(TermName("x_$eq")).asTerm) } diff --git a/test/files/run/reflection-fieldmirror-ctorparam.scala b/test/files/run/reflection-fieldmirror-ctorparam.scala index b9d50fe97b..608adad27b 100644 --- a/test/files/run/reflection-fieldmirror-ctorparam.scala +++ b/test/files/run/reflection-fieldmirror-ctorparam.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x")).asTerm + val f = cs.typeSignature.declaration(TermName("x")).asTerm try { val fm: FieldMirror = im.reflectField(f) println(fm.get) diff --git a/test/files/run/reflection-fieldmirror-getsetval.scala b/test/files/run/reflection-fieldmirror-getsetval.scala index 90221481d4..6a88dc3118 100644 --- a/test/files/run/reflection-fieldmirror-getsetval.scala +++ b/test/files/run/reflection-fieldmirror-getsetval.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm + val f = cs.typeSignature.declaration(TermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.get) fm.set(2) diff --git a/test/files/run/reflection-fieldmirror-getsetvar.scala b/test/files/run/reflection-fieldmirror-getsetvar.scala index abcf396dd1..52c13a73bb 100644 --- a/test/files/run/reflection-fieldmirror-getsetvar.scala +++ b/test/files/run/reflection-fieldmirror-getsetvar.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm + val f = cs.typeSignature.declaration(TermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.get) fm.set(2) diff --git a/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala index 2b4a9bb55e..e070cdcfa3 100644 --- a/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala +++ b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm + val f = cs.typeSignature.declaration(TermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.symbol.isVar) } diff --git a/test/files/run/reflection-fieldmirror-privatethis.scala b/test/files/run/reflection-fieldmirror-privatethis.scala index ab838dbb1b..89948772b1 100644 --- a/test/files/run/reflection-fieldmirror-privatethis.scala +++ b/test/files/run/reflection-fieldmirror-privatethis.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x")).asTerm + val f = cs.typeSignature.declaration(TermName("x")).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.symbol.isVar) println(fm.get) diff --git a/test/files/run/reflection-fieldsymbol-navigation.scala b/test/files/run/reflection-fieldsymbol-navigation.scala index 4448724988..33dc18a7e3 100644 --- a/test/files/run/reflection-fieldsymbol-navigation.scala +++ b/test/files/run/reflection-fieldsymbol-navigation.scala @@ -5,7 +5,7 @@ class C { } object Test extends App { - val x = typeOf[C].member(newTermName("x")).asTerm + val x = typeOf[C].member(TermName("x")).asTerm println(x) println(x.isVar) println(x.accessed) diff --git a/test/files/run/reflection-implClass.scala b/test/files/run/reflection-implClass.scala index b3c0081ccf..db211fd9a8 100644 --- a/test/files/run/reflection-implClass.scala +++ b/test/files/run/reflection-implClass.scala @@ -10,19 +10,19 @@ object Test extends App with Outer { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} - assert(cm.classSymbol(classTag[Foo].runtimeClass).typeSignature.declaration(newTermName("bar")).typeSignature == - cm.classSymbol(classTag[Bar].runtimeClass).typeSignature.declaration(newTermName("foo")).typeSignature) + assert(cm.classSymbol(classTag[Foo].runtimeClass).typeSignature.declaration(TermName("bar")).typeSignature == + cm.classSymbol(classTag[Bar].runtimeClass).typeSignature.declaration(TermName("foo")).typeSignature) val s1 = implClass(classTag[Foo].runtimeClass) assert(s1 != NoSymbol) assert(s1.typeSignature != NoType) assert(s1.companionSymbol.typeSignature != NoType) - assert(s1.companionSymbol.typeSignature.declaration(newTermName("bar")) != NoSymbol) + assert(s1.companionSymbol.typeSignature.declaration(TermName("bar")) != NoSymbol) val s2 = implClass(classTag[Bar].runtimeClass) assert(s2 != NoSymbol) assert(s2.typeSignature != NoType) assert(s2.companionSymbol.typeSignature != NoType) - assert(s2.companionSymbol.typeSignature.declaration(newTermName("foo")) != NoSymbol) + assert(s2.companionSymbol.typeSignature.declaration(TermName("foo")) != NoSymbol) def implClass(clazz: Class[_]) = { val implClass = Class.forName(clazz.getName + "$class") cm.classSymbol(implClass) diff --git a/test/files/run/reflection-implicit.scala b/test/files/run/reflection-implicit.scala index 0bcb0bc3a0..f2b3ba960c 100644 --- a/test/files/run/reflection-implicit.scala +++ b/test/files/run/reflection-implicit.scala @@ -1,3 +1,5 @@ + +import scala.language.implicitConversions import scala.reflect.runtime.universe._ class C { @@ -12,4 +14,4 @@ object Test extends App { val param = decls.find(_.name.toString == "d").get.asMethod.paramss.last.head param.typeSignature println(param.isImplicit) -}
\ No newline at end of file +} diff --git a/test/files/run/reflection-magicsymbols-invoke.scala b/test/files/run/reflection-magicsymbols-invoke.scala index 5f39370708..ff3992709f 100644 --- a/test/files/run/reflection-magicsymbols-invoke.scala +++ b/test/files/run/reflection-magicsymbols-invoke.scala @@ -28,7 +28,7 @@ object Test extends App { val ctor = tpe.declaration(nme.CONSTRUCTOR).asMethod cm.reflectClass(ctor.owner.asClass).reflectConstructor(ctor)(args: _*) } else { - val meth = tpe.declaration(newTermName(method).encodedName.toTermName).asMethod + val meth = tpe.declaration(TermName(method).encodedName.toTermName).asMethod cm.reflect(receiver).reflectMethod(meth)(args: _*) } }) @@ -54,7 +54,7 @@ object Test extends App { println("it's important to print the list of AnyVal's members") println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") typeOf[AnyVal].declarations.toList.sortBy(key).foreach(sym => println(key(sym))) - test(typeOf[AnyVal], null, "<init>") + test(typeOf[AnyVal], null, nme.CONSTRUCTOR.toString) test(typeOf[AnyVal], 2, "getClass") println("============\nAnyRef") diff --git a/test/files/run/reflection-magicsymbols-repl.check b/test/files/run/reflection-magicsymbols-repl.check index 2535e3f43d..bb8bdc9dd9 100644 --- a/test/files/run/reflection-magicsymbols-repl.check +++ b/test/files/run/reflection-magicsymbols-repl.check @@ -19,7 +19,7 @@ scala> class A { defined class A scala> def test(n: Int): Unit = { - val sig = typeOf[A] member newTermName("foo" + n) typeSignature + val sig = typeOf[A] member TermName("foo" + n) typeSignature val x = sig.asInstanceOf[MethodType].params.head println(x.typeSignature) } diff --git a/test/files/run/reflection-magicsymbols-repl.scala b/test/files/run/reflection-magicsymbols-repl.scala index 26127b8661..6a432c2664 100644 --- a/test/files/run/reflection-magicsymbols-repl.scala +++ b/test/files/run/reflection-magicsymbols-repl.scala @@ -14,7 +14,7 @@ object Test extends ReplTest { | def foo8(x: Singleton) = ??? |} |def test(n: Int): Unit = { - | val sig = typeOf[A] member newTermName("foo" + n) typeSignature + | val sig = typeOf[A] member TermName("foo" + n) typeSignature | val x = sig.asInstanceOf[MethodType].params.head | println(x.typeSignature) |} diff --git a/test/files/run/reflection-magicsymbols-vanilla.scala b/test/files/run/reflection-magicsymbols-vanilla.scala index 32819dcc46..2bde3d8874 100644 --- a/test/files/run/reflection-magicsymbols-vanilla.scala +++ b/test/files/run/reflection-magicsymbols-vanilla.scala @@ -1,3 +1,5 @@ +import scala.language.postfixOps + class A { def foo1(x: Int*) = ??? def foo2(x: => Int) = ??? @@ -12,7 +14,7 @@ class A { object Test extends App { import scala.reflect.runtime.universe._ def test(n: Int): Unit = { - val sig = typeOf[A] member newTermName("foo" + n) typeSignature + val sig = typeOf[A] member TermName("foo" + n) typeSignature val x = sig.asInstanceOf[MethodType].params.head println(x.typeSignature) } diff --git a/test/files/run/reflection-methodsymbol-params.scala b/test/files/run/reflection-methodsymbol-params.scala index 45b1f9628f..baad8d6b9b 100644 --- a/test/files/run/reflection-methodsymbol-params.scala +++ b/test/files/run/reflection-methodsymbol-params.scala @@ -13,12 +13,12 @@ class C { } object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.paramss) - println(typeOf[C].member(newTermName("x2")).asMethod.paramss) - println(typeOf[C].member(newTermName("x3")).asMethod.paramss) - println(typeOf[C].member(newTermName("x4")).asMethod.paramss) - println(typeOf[C].member(newTermName("y1")).asMethod.paramss) - println(typeOf[C].member(newTermName("y2")).asMethod.paramss) - println(typeOf[C].member(newTermName("y3")).asMethod.paramss) - println(typeOf[C].member(newTermName("y4")).asMethod.paramss) + println(typeOf[C].member(TermName("x1")).asMethod.paramss) + println(typeOf[C].member(TermName("x2")).asMethod.paramss) + println(typeOf[C].member(TermName("x3")).asMethod.paramss) + println(typeOf[C].member(TermName("x4")).asMethod.paramss) + println(typeOf[C].member(TermName("y1")).asMethod.paramss) + println(typeOf[C].member(TermName("y2")).asMethod.paramss) + println(typeOf[C].member(TermName("y3")).asMethod.paramss) + println(typeOf[C].member(TermName("y4")).asMethod.paramss) }
\ No newline at end of file diff --git a/test/files/run/reflection-methodsymbol-returntype.scala b/test/files/run/reflection-methodsymbol-returntype.scala index 392754dbe4..74a9e5dac0 100644 --- a/test/files/run/reflection-methodsymbol-returntype.scala +++ b/test/files/run/reflection-methodsymbol-returntype.scala @@ -13,12 +13,12 @@ class C { } object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.returnType) - println(typeOf[C].member(newTermName("x2")).asMethod.returnType) - println(typeOf[C].member(newTermName("x3")).asMethod.returnType) - println(typeOf[C].member(newTermName("x4")).asMethod.returnType) - println(typeOf[C].member(newTermName("y1")).asMethod.returnType) - println(typeOf[C].member(newTermName("y2")).asMethod.returnType) - println(typeOf[C].member(newTermName("y3")).asMethod.returnType) - println(typeOf[C].member(newTermName("y4")).asMethod.returnType) + println(typeOf[C].member(TermName("x1")).asMethod.returnType) + println(typeOf[C].member(TermName("x2")).asMethod.returnType) + println(typeOf[C].member(TermName("x3")).asMethod.returnType) + println(typeOf[C].member(TermName("x4")).asMethod.returnType) + println(typeOf[C].member(TermName("y1")).asMethod.returnType) + println(typeOf[C].member(TermName("y2")).asMethod.returnType) + println(typeOf[C].member(TermName("y3")).asMethod.returnType) + println(typeOf[C].member(TermName("y4")).asMethod.returnType) }
\ No newline at end of file diff --git a/test/files/run/reflection-methodsymbol-typeparams.scala b/test/files/run/reflection-methodsymbol-typeparams.scala index bb0a3c3aec..56d37ebeaa 100644 --- a/test/files/run/reflection-methodsymbol-typeparams.scala +++ b/test/files/run/reflection-methodsymbol-typeparams.scala @@ -13,12 +13,12 @@ class C { } object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.typeParams) - println(typeOf[C].member(newTermName("x2")).asMethod.typeParams) - println(typeOf[C].member(newTermName("x3")).asMethod.typeParams) - println(typeOf[C].member(newTermName("x4")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y1")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y2")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y3")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y4")).asMethod.typeParams) + println(typeOf[C].member(TermName("x1")).asMethod.typeParams) + println(typeOf[C].member(TermName("x2")).asMethod.typeParams) + println(typeOf[C].member(TermName("x3")).asMethod.typeParams) + println(typeOf[C].member(TermName("x4")).asMethod.typeParams) + println(typeOf[C].member(TermName("y1")).asMethod.typeParams) + println(typeOf[C].member(TermName("y2")).asMethod.typeParams) + println(typeOf[C].member(TermName("y3")).asMethod.typeParams) + println(typeOf[C].member(TermName("y4")).asMethod.typeParams) }
\ No newline at end of file diff --git a/test/files/run/reflection-repl-classes.check b/test/files/run/reflection-repl-classes.check index 2dd96a93bf..d70db59b85 100644 --- a/test/files/run/reflection-repl-classes.check +++ b/test/files/run/reflection-repl-classes.check @@ -19,10 +19,10 @@ scala> object defs { val cm = reflect.runtime.currentMirror val u = cm.universe val im = cm.reflect(new B) - val method = im.symbol.typeSignature.member(u.newTermName("foo")).asMethod + val method = im.symbol.typeSignature.member(u.TermName("foo")).asMethod val mm = im.reflectMethod(method) } -defined module defs +defined object defs scala> import defs._ import defs._ diff --git a/test/files/run/reflection-repl-classes.scala b/test/files/run/reflection-repl-classes.scala index 80e332cde3..4bfb980498 100644 --- a/test/files/run/reflection-repl-classes.scala +++ b/test/files/run/reflection-repl-classes.scala @@ -12,7 +12,7 @@ object Test extends ReplTest { | val cm = reflect.runtime.currentMirror | val u = cm.universe | val im = cm.reflect(new B) - | val method = im.symbol.typeSignature.member(u.newTermName("foo")).asMethod + | val method = im.symbol.typeSignature.member(u.TermName("foo")).asMethod | val mm = im.reflectMethod(method) |} |import defs._ diff --git a/test/files/run/reflection-sanitychecks.scala b/test/files/run/reflection-sanitychecks.scala index f817f23731..6d3daff1f7 100644 --- a/test/files/run/reflection-sanitychecks.scala +++ b/test/files/run/reflection-sanitychecks.scala @@ -32,14 +32,14 @@ object Test extends App { def test(tpe: Type): Unit = { def failsafe(action: => Any): Any = try action catch { case ex: Throwable => ex.toString } println(s"=========members of ${tpe.typeSymbol.name} in a mirror of D=========") - println("field #1: " + failsafe(im.reflectField(tpe.member(newTermName("foo")).asTerm).get)) - println("method #1: " + failsafe(im.reflectMethod(tpe.member(newTermName("bar")).asMethod)())) - println("field #2: " + failsafe(im.reflectField(tpe.member(newTermName("quux")).asTerm).get)) - println("method #2: " + failsafe(im.reflectMethod(tpe.member(newTermName("baz")).asMethod)())) - println("constructor #1: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("bar")).asMethod)())) - println("constructor #2: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("<init>")).asMethod)())) - println("class: " + failsafe(im.reflectClass(tpe.member(newTypeName("C")).asClass).reflectConstructor(typeOf[C].member(newTypeName("C")).asClass.typeSignature.member(newTermName("<init>")).asMethod)())) - println("object: " + failsafe(im.reflectModule(tpe.member(newTermName("O")).asModule).instance)) + println("field #1: " + failsafe(im.reflectField(tpe.member(TermName("foo")).asTerm).get)) + println("method #1: " + failsafe(im.reflectMethod(tpe.member(TermName("bar")).asMethod)())) + println("field #2: " + failsafe(im.reflectField(tpe.member(TermName("quux")).asTerm).get)) + println("method #2: " + failsafe(im.reflectMethod(tpe.member(TermName("baz")).asMethod)())) + println("constructor #1: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(TermName("bar")).asMethod)())) + println("constructor #2: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(TermName("<init>")).asMethod)())) + println("class: " + failsafe(im.reflectClass(tpe.member(TypeName("C")).asClass).reflectConstructor(typeOf[C].member(TypeName("C")).asClass.typeSignature.member(nme.CONSTRUCTOR).asMethod)())) + println("object: " + failsafe(im.reflectModule(tpe.member(TermName("O")).asModule).instance)) println() } diff --git a/test/files/run/reflection-valueclasses-derived.scala b/test/files/run/reflection-valueclasses-derived.scala index 6b08f987ba..8d25e2929c 100644 --- a/test/files/run/reflection-valueclasses-derived.scala +++ b/test/files/run/reflection-valueclasses-derived.scala @@ -6,7 +6,7 @@ class C(val x: Int) extends AnyVal { } object Test extends App { - println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("foo")).asMethod)(2)) - println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("getClass")).asMethod)()) - println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("toString")).asMethod)()) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(TermName("foo")).asMethod)(2)) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(TermName("getClass")).asMethod)()) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(TermName("toString")).asMethod)()) }
\ No newline at end of file diff --git a/test/files/run/reflection-valueclasses-magic.scala b/test/files/run/reflection-valueclasses-magic.scala index c4a26e460a..33d4634397 100644 --- a/test/files/run/reflection-valueclasses-magic.scala +++ b/test/files/run/reflection-valueclasses-magic.scala @@ -44,7 +44,7 @@ object Test extends App { val realex = scala.ExceptionUtils.unwrapThrowable(ex) println(realex.getClass + ": " + realex.getMessage) } - val meth = tpe.declaration(newTermName(method).encodedName.toTermName) + val meth = tpe.declaration(TermName(method).encodedName.toTermName) val testees = if (meth.isMethod) List(meth.asMethod) else meth.asTerm.alternatives.map(_.asMethod) testees foreach (testee => { val convertedArgs = args.zipWithIndex.map { case (arg, i) => convert(arg, testee.paramss.flatten.apply(i).typeSignature) } diff --git a/test/files/run/reflection-valueclasses-standard.scala b/test/files/run/reflection-valueclasses-standard.scala index 18a3d1fa04..b6b5a2ede2 100644 --- a/test/files/run/reflection-valueclasses-standard.scala +++ b/test/files/run/reflection-valueclasses-standard.scala @@ -5,8 +5,8 @@ import scala.reflect.{ClassTag, classTag} object Test extends App { def test[T: ClassTag: TypeTag](x: T) = { println(s"========${classTag[T].runtimeClass}========") - println(cm.reflect(x).reflectMethod(typeOf[T].member(newTermName("getClass")).asMethod)()) - println(cm.reflect(x).reflectMethod(typeOf[T].member(newTermName("toString")).asMethod)()) + println(cm.reflect(x).reflectMethod(typeOf[T].member(TermName("getClass")).asMethod)()) + println(cm.reflect(x).reflectMethod(typeOf[T].member(TermName("toString")).asMethod)()) } test(2.toByte) diff --git a/test/files/run/reify-aliases.check b/test/files/run/reify-aliases.check index aa846b9bc6..da784227af 100644 --- a/test/files/run/reify-aliases.check +++ b/test/files/run/reify-aliases.check @@ -1 +1 @@ -TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()) +TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) diff --git a/test/files/run/reify-each-node-type.check b/test/files/run/reify-each-node-type.check new file mode 100644 index 0000000000..afc65add7a --- /dev/null +++ b/test/files/run/reify-each-node-type.check @@ -0,0 +1,35 @@ + 1 s Ident + 2 r.List Select + 3 r.List.apply() Apply + 4 r.List.apply(1) Literal + 5 r.List.apply[Int]() TypeApply + 6 (1: Int) Typed + 7 (null: r.List[Int]) AppliedTypeTree + 8 { (); () } Block + 9 { val x: Int = 0; () } ValDef +10 { val x = 0; () } TypeTree +11 if (true) () else () If +12 { def f: Unit = (); () } DefDef +13 { def m = NN.super.q; () } Super +14 { abstract trait A extends AnyRef; () } ClassDef Template +15 { def f(x: Any): Unit = (); () } EmptyTree +16 (null: r.D with r.E) CompoundTypeTree +17 { type T = Int; () } TypeDef +18 { type CC[T <: r.D] = r.C[T]; () } TypeBoundsTree +19 try { 0 } finally Predef.println("") Try +20 ((x: Int) => x) Function +21 { var v = 1; v = 2 } Assign +22 { class A extends AnyRef { def <init>() = { super.<init>(); This +23 new r.List[Int]() New +24 0: @unchecked Annotated +25 (null: r.Outer#Inner) SelectFromTypeTree +26 (null: Nil.type) SingletonTypeTree +27 (null: T forSome { type T }) ExistentialTypeTree +28 { import r.{A, B=>C}; () } Import +29 { def f: Int = return 0; () } Return +30 { object x extends AnyRef { def <init>() = { super.<init>(); ModuleDef +31 throw new Exception() Throw +32 0 match { case _ => 0 } Match CaseDef +33 0 match { case (1| 2) => 0 } Alternative +34 NN.q match { case (x @ r.List) => 0 } Bind +35 NN.q match { case r.UnSeq(1, (_)*) => 0 } Star diff --git a/test/files/run/reify-each-node-type.scala b/test/files/run/reify-each-node-type.scala new file mode 100644 index 0000000000..425061f955 --- /dev/null +++ b/test/files/run/reify-each-node-type.scala @@ -0,0 +1,110 @@ + +import scala.language.{ existentials, postfixOps } +import scala.reflect.runtime.universe._ + +object r { + class A + class B + class List[+A] + object List { def apply[A](xs: A*): List[A] = new List[A] } + object Nil extends List[Nothing] + + trait OuterP[A] { + trait Inner + trait InnerP[B] + } + trait Outer { + trait Inner + trait InnerP[B] + } + object Un { def unapply(x: Any) = Some(5) } + object UnSeq { def unapplySeq(x: Any) = Some(Seq(5)) } + class C[T] + class D + trait E + + trait SN { + def q: Any = null + } +} + +object s { + import r._ + + trait NN extends SN { + def act[T](expr: Expr[T]): Unit + + act(reify { s /* Ident */ }) + act(reify { r.List /* Select */ }) + act(reify { List() /* Apply */ }) + act(reify { List(1) /* Literal */ }) + act(reify { List[Int]() /* TypeApply */ }) + act(reify { 1: Int /* Typed */ }) + act(reify { null: List[Int] /* AppliedTypeTree */ }) + act(reify { () ; () /* Block */ }) + act(reify { val x: Int = 0 /* ValDef */ }) + act(reify { val x = 0 /* TypeTree */ }) + act(reify { if (true) () /* If */ }) + act(reify { def f { } /* DefDef */ }) + act(reify { def m = super.q /* Super */ }) + act(reify { trait A /* ClassDef Template */ }) + act(reify { def f(x: Any) { } /* EmptyTree */ }) + act(reify { null: D with E /* CompoundTypeTree */ }) + act(reify { type T = Int /* TypeDef */ }) + act(reify { type CC[T <: D] = C[T] /* TypeBoundsTree */ }) + act(reify { try 0 finally println("") /* Try */ }) + act(reify { (x: Int) => x /* Function */ }) + act(reify { var v = 1 ; v = 2 /* Assign */ }) + act(reify { class A() { def this(x: A) = this() } /* This */ }) + act(reify { new List[Int] /* New */ }) + act(reify { 0: @unchecked /* Annotated */ }) + act(reify { null: Outer#Inner /* SelectFromTypeTree */ }) + act(reify { null: Nil.type /* SingletonTypeTree */ }) + act(reify { null: (T forSome { type T }) /* ExistentialTypeTree */ }) + act(reify { import r.{ A, B => C }; /* Import */ }) + act(reify { def f: Int = return 0 /* Return */ }) + act(reify { object x /* ModuleDef */ }) + act(reify { throw new java.lang.Exception /* Throw */ }) + act(reify { 0 match { case _ => 0 } /* Match CaseDef */ }) + act(reify { 0 match { case 1 | 2 => 0 } /* Alternative */ }) + act(reify { q match { case x @ List => 0 } /* Bind */ }) + act(reify { q match { case UnSeq(1, _*) => 0 } /* Star */ }) + + // ``unexpected: bound type that doesn't have a tpe: Ident(newTypeName("Int"))'' + // act(reify { r.List[T forSome { type T <: Int }]() }) // Was crashing , no longer + // + // error: exception during macro expansion: + // scala.MatchError: collection.this.Seq.unapplySeq[A] (of class scala.reflect.internal.Trees$TypeApply) + // at scala.reflect.reify.phases.Reshape$$anon$1.extractExtractor$1(Reshape.scala:73) + // at scala.reflect.reify.phases.Reshape$$anon$1.transform(Reshape.scala:82) + // at scala.reflect.reify.phases.Reshape$$anon$1.transform(Reshape.scala:24) + // at scala.reflect.internal.Trees$class.itransform(Trees.scala:1290) + // + // act(reify { r.List[Any]() match { case Seq(1, _*) => 1 } } ) + + // act(reify { List[OuterP[Int]#InnerP[Byte]]() }) + // + // SI-7243 + // + // test/files/run/reify-each-node-type.scala:85: error: Cannot materialize r.List.apply[r.OuterP[Int]#InnerP[Byte]]() as { ... } because: + // scala.reflect.macros.TypecheckException: value TypeTreeWithDeferredRefCheck is not a member of type parameter U + // act(reify { List[OuterP[Int]#InnerP[Byte]]() }) + // ^ + // one error found + } +} + +object Test { + var idx = 0 + val seen = scala.collection.mutable.Set[String]() + + object N extends s.NN { + def act[T](expr: Expr[T]): Unit = { + idx += 1 + val ts = expr.tree filter (_ => true) map (_.getClass.getName split "[.$]" last) filterNot seen distinct; + println("%2d %60s %s".format(idx, expr.tree.toString.replaceAll("""\s+""", " ").take(60), ts mkString " ")) + seen ++= ts + } + } + def main(args: Array[String]): Unit = N +} diff --git a/test/files/run/reify-repl-fail-gracefully.check b/test/files/run/reify-repl-fail-gracefully.check index 1b0f3f2162..18cfd5a7ef 100644 --- a/test/files/run/reify-repl-fail-gracefully.check +++ b/test/files/run/reify-repl-fail-gracefully.check @@ -12,7 +12,7 @@ import scala.reflect.runtime.universe._ scala> scala> reify -<console>:12: error: macros cannot be partially applied +<console>:12: error: too few argument lists for macro invocation reify ^ diff --git a/test/files/run/reify_ann1a.check b/test/files/run/reify_ann1a.check index 99a966f38b..71841ff83b 100644 --- a/test/files/run/reify_ann1a.check +++ b/test/files/run/reify_ann1a.check @@ -1,5 +1,5 @@ { - @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T >: Nothing <: Any] extends AnyRef { + @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T] extends AnyRef { @new ann(List.apply("3a")) @new ann(List.apply("3b")) <paramaccessor> private[this] val x: T @ann(List.apply("4a")) @ann(List.apply("4b")) = _; def <init>(@new ann(List.apply("3a")) @new ann(List.apply("3b")) x: T @ann(List.apply("4a")) @ann(List.apply("4b"))) = { super.<init>(); diff --git a/test/files/run/reify_ann1b.check b/test/files/run/reify_ann1b.check index 6a5f32a492..a046dafeab 100644 --- a/test/files/run/reify_ann1b.check +++ b/test/files/run/reify_ann1b.check @@ -1,5 +1,10 @@ +reify_ann1b.scala:6: warning: Implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class ann(bar: String) extends annotation.ClassfileAnnotation + ^ { - @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T >: Nothing <: Any] extends AnyRef { + @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T] extends AnyRef { @new ann(bar = "3a") @new ann(bar = "3b") <paramaccessor> private[this] val x: T @ann(bar = "4a") @ann(bar = "4b") = _; def <init>(@new ann(bar = "3a") @new ann(bar = "3b") x: T @ann(bar = "4a") @ann(bar = "4b")) = { super.<init>(); diff --git a/test/files/run/reify_ann2a.check b/test/files/run/reify_ann2a.check index ccbcb4c31e..a26fa42045 100644 --- a/test/files/run/reify_ann2a.check +++ b/test/files/run/reify_ann2a.check @@ -6,7 +6,7 @@ () } }; - @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T >: Nothing <: Any] extends AnyRef { + @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T] extends AnyRef { @new ann(List.apply("3a")) @new ann(List.apply("3b")) <paramaccessor> private[this] val x: T @ann(List.apply("4a")) @ann(List.apply("4b")) = _; def <init>(@new ann(List.apply("3a")) @new ann(List.apply("3b")) x: T @ann(List.apply("4a")) @ann(List.apply("4b"))) = { super.<init>(); diff --git a/test/files/run/reify_ann3.check b/test/files/run/reify_ann3.check index 8caceb2696..d4cf660758 100644 --- a/test/files/run/reify_ann3.check +++ b/test/files/run/reify_ann3.check @@ -1,5 +1,5 @@ { - class Tree[A >: Nothing <: Any, B >: Nothing <: Any] extends AnyRef { + class Tree[A, B] extends AnyRef { @new inline @getter() final <paramaccessor> val key: A = _; def <init>(key: A) = { super.<init>(); diff --git a/test/files/run/reify_classfileann_a.check b/test/files/run/reify_classfileann_a.check index 0c919020a8..51f255b232 100644 --- a/test/files/run/reify_classfileann_a.check +++ b/test/files/run/reify_classfileann_a.check @@ -1,3 +1,8 @@ +reify_classfileann_a.scala:6: warning: Implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends annotation.ClassfileAnnotation + ^ { @new ann(bar = "1", quux = Array("2", "3"), baz = new ann(bar = "4")) class C extends AnyRef { def <init>() = { diff --git a/test/files/run/reify_classfileann_b.check b/test/files/run/reify_classfileann_b.check index c204fa8dc0..05f2e5bfc6 100644 --- a/test/files/run/reify_classfileann_b.check +++ b/test/files/run/reify_classfileann_b.check @@ -1,3 +1,8 @@ +reify_classfileann_b.scala:6: warning: Implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends annotation.ClassfileAnnotation + ^ { class C extends AnyRef { def <init>() = { diff --git a/test/files/run/reify_copypaste1.scala b/test/files/run/reify_copypaste1.scala index c597b7af19..b2eef28026 100644 --- a/test/files/run/reify_copypaste1.scala +++ b/test/files/run/reify_copypaste1.scala @@ -9,8 +9,8 @@ object Test extends App { val output = new java.io.ByteArrayOutputStream() System.setOut(new java.io.PrintStream(output)) val toolBox = currentMirror.mkToolBox(options = "-Yreify-copypaste") - val reify = Select(Select(Select(Select(Ident(ScalaPackage), newTermName("reflect")), newTermName("runtime")), newTermName("universe")), newTermName("reify")) - val reifee = Block(List(ValDef(Modifiers(LAZY), newTermName("x"), TypeTree(), Apply(Ident(ListModule), List(Literal(Constant(1)), Literal(Constant(2)))))), Ident(newTermName("x"))) + val reify = Select(Select(Select(Select(Ident(ScalaPackage), TermName("reflect")), TermName("runtime")), TermName("universe")), TermName("reify")) + val reifee = Block(List(ValDef(Modifiers(LAZY), TermName("x"), TypeTree(), Apply(Ident(ListModule), List(Literal(Constant(1)), Literal(Constant(2)))))), Ident(TermName("x"))) toolBox.eval(Apply(reify, List(reifee))) val Block(List(tpeCopypaste), exprCopypaste @ ModuleDef(_, _, Template(_, _, (_ :: stats) :+ expr))) = toolBox.parse(output.toString()) output.reset() diff --git a/test/files/run/reify_extendbuiltins.scala b/test/files/run/reify_extendbuiltins.scala index a2d546579d..46d5b7e55e 100644 --- a/test/files/run/reify_extendbuiltins.scala +++ b/test/files/run/reify_extendbuiltins.scala @@ -1,3 +1,5 @@ + +import scala.language.{ implicitConversions, postfixOps } import scala.reflect.runtime.universe._ import scala.tools.reflect.Eval @@ -12,4 +14,4 @@ object Test extends App { println("10! = " + (10!)) }.eval -}
\ No newline at end of file +} diff --git a/test/files/run/reify_implicits-new.check b/test/files/run/reify_implicits-new.check new file mode 100644 index 0000000000..e3aeb20f6b --- /dev/null +++ b/test/files/run/reify_implicits-new.check @@ -0,0 +1 @@ +x = List(1, 2, 3, 4) diff --git a/test/files/run/reify_implicits-new.scala b/test/files/run/reify_implicits-new.scala new file mode 100644 index 0000000000..1d90d907ea --- /dev/null +++ b/test/files/run/reify_implicits-new.scala @@ -0,0 +1,18 @@ + +import scala.language.{ implicitConversions, reflectiveCalls } +import scala.reflect.{ClassTag, classTag} +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + reify { + implicit def arrayWrapper[A : ClassTag](x: Array[A]) = + new { + def sort(p: (A, A) => Boolean) = { + util.Sorting.stableSort(x, p); x + } + } + val x = Array(2, 3, 1, 4) + println("x = "+ x.sort((x: Int, y: Int) => x < y).toList) + }.eval +} diff --git a/test/files/run/reify_implicits-old.check b/test/files/run/reify_implicits-old.check new file mode 100644 index 0000000000..e3aeb20f6b --- /dev/null +++ b/test/files/run/reify_implicits-old.check @@ -0,0 +1 @@ +x = List(1, 2, 3, 4) diff --git a/test/files/run/reify_implicits-old.scala b/test/files/run/reify_implicits-old.scala new file mode 100644 index 0000000000..a4e90488e5 --- /dev/null +++ b/test/files/run/reify_implicits-old.scala @@ -0,0 +1,17 @@ + +import scala.language.{ implicitConversions, reflectiveCalls } +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + reify { + implicit def arrayWrapper[A : ClassManifest](x: Array[A]) = + new { + def sort(p: (A, A) => Boolean) = { + util.Sorting.stableSort(x, p); x + } + } + val x = Array(2, 3, 1, 4) + println("x = "+ x.sort((x: Int, y: Int) => x < y).toList) + }.eval +} diff --git a/test/files/run/reify_lazyevaluation.scala b/test/files/run/reify_lazyevaluation.scala index 5b310d95f7..3f2530ddee 100644 --- a/test/files/run/reify_lazyevaluation.scala +++ b/test/files/run/reify_lazyevaluation.scala @@ -1,3 +1,5 @@ + +import scala.language.{ implicitConversions } import scala.reflect.runtime.universe._ import scala.tools.reflect.Eval diff --git a/test/files/run/reify_lazyunit.check b/test/files/run/reify_lazyunit.check index 1b46c909be..579ecfe8aa 100644 --- a/test/files/run/reify_lazyunit.check +++ b/test/files/run/reify_lazyunit.check @@ -1,3 +1,6 @@ +reify_lazyunit.scala:6: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + lazy val x = { 0; println("12")} + ^ 12 one two diff --git a/test/files/run/reify_newimpl_11.check b/test/files/run/reify_newimpl_11.check index 2f5cb581e6..c019c6db2d 100644 --- a/test/files/run/reify_newimpl_11.check +++ b/test/files/run/reify_newimpl_11.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_11.scala:6:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_11.scala:6:11 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_13.check b/test/files/run/reify_newimpl_13.check index d518cd7b84..13e3c9af1e 100644 --- a/test/files/run/reify_newimpl_13.check +++ b/test/files/run/reify_newimpl_13.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_13.scala:7:13). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_13.scala:7:13 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_19.check b/test/files/run/reify_newimpl_19.check index 8b8652f92c..c749d4f106 100644 --- a/test/files/run/reify_newimpl_19.check +++ b/test/files/run/reify_newimpl_19.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_19.scala:7:10). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_19.scala:7:10 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_22.check b/test/files/run/reify_newimpl_22.check index dcb3e2889b..e68fe2f6b1 100644 --- a/test/files/run/reify_newimpl_22.check +++ b/test/files/run/reify_newimpl_22.check @@ -19,7 +19,7 @@ scala> { } println(code.eval) } -<console>:15: free term: Ident(newTermName("x")) defined by res0 in <console>:14:21 +<console>:15: free term: Ident(TermName("x")) defined by res0 in <console>:14:21 val code = reify { ^ 2 diff --git a/test/files/run/reify_newimpl_23.check b/test/files/run/reify_newimpl_23.check index 882124657e..38c95646a8 100644 --- a/test/files/run/reify_newimpl_23.check +++ b/test/files/run/reify_newimpl_23.check @@ -18,7 +18,7 @@ scala> def foo[T]{ } println(code.eval) } -<console>:13: free type: Ident(newTypeName("T")) defined by foo in <console>:12:16 +<console>:13: free type: Ident(TypeName("T")) defined by foo in <console>:12:16 val code = reify { ^ foo: [T]=> Unit diff --git a/test/files/run/reify_newimpl_25.check b/test/files/run/reify_newimpl_25.check index d1028b94c7..86f6abce02 100644 --- a/test/files/run/reify_newimpl_25.check +++ b/test/files/run/reify_newimpl_25.check @@ -9,7 +9,7 @@ scala> { val tt = implicitly[TypeTag[x.type]] println(tt) } -<console>:11: free term: Ident(newTermName("x")) defined by res0 in <console>:10:21 +<console>:11: free term: Ident(TermName("x")) defined by res0 in <console>:10:21 val tt = implicitly[TypeTag[x.type]] ^ TypeTag[x.type] diff --git a/test/files/run/reify_newimpl_26.check b/test/files/run/reify_newimpl_26.check index 347f6365aa..d3e2540de0 100644 --- a/test/files/run/reify_newimpl_26.check +++ b/test/files/run/reify_newimpl_26.check @@ -8,7 +8,7 @@ scala> def foo[T]{ val tt = implicitly[WeakTypeTag[List[T]]] println(tt) } -<console>:9: free type: Ident(newTypeName("T")) defined by foo in <console>:7:16 +<console>:9: free type: Ident(TypeName("T")) defined by foo in <console>:7:16 val tt = implicitly[WeakTypeTag[List[T]]] ^ foo: [T]=> Unit diff --git a/test/files/run/reify_newimpl_30.check b/test/files/run/reify_newimpl_30.check index 29baac911e..7557c750a6 100644 --- a/test/files/run/reify_newimpl_30.check +++ b/test/files/run/reify_newimpl_30.check @@ -1,2 +1,4 @@ -reflective toolbox has failed: -unresolved free type variables (namely: C defined by <local Test> in reify_newimpl_30.scala:7:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +reflective toolbox failed due to unresolved free type variables: + C defined by <local Test> in reify_newimpl_30.scala:7:11 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_printf.check b/test/files/run/reify_printf.check index e69de29bb2..3b18e512db 100644 --- a/test/files/run/reify_printf.check +++ b/test/files/run/reify_printf.check @@ -0,0 +1 @@ +hello world diff --git a/test/files/run/reify_printf.scala b/test/files/run/reify_printf.scala index 272856b962..c4ade79837 100644 --- a/test/files/run/reify_printf.scala +++ b/test/files/run/reify_printf.scala @@ -9,13 +9,13 @@ import scala.reflect.internal.Types import scala.util.matching.Regex object Test extends App { - val output = new ByteArrayOutputStream() - Console.setOut(new PrintStream(output)) + //val output = new ByteArrayOutputStream() + //Console.setOut(new PrintStream(output)) val toolbox = cm.mkToolBox() val tree = tree_printf(reify("hello %s").tree, reify("world").tree) val evaluated = toolbox.eval(tree) - assert(output.toString() == "hello world", output.toString() +" == hello world") + //assert(output.toString() == "hello world", output.toString() +" == hello world") /* // upd. Oh, good old times, our very-very first experiments with macros :) @@ -23,7 +23,7 @@ object Test extends App { */ var i = 0 - def gensym(name: String) = { i += 1; newTermName(name + i) } + def gensym(name: String) = { i += 1; TermName(name + i) } def createTempValDef( value : Tree, tpe : Type ) : (Option[Tree],Tree) = { val local = gensym("temp") @@ -59,13 +59,13 @@ object Test extends App { Apply( Select( Select( - Ident( newTermName("scala") ) - , newTermName("Predef") + Ident( TermName("scala") ) + , TermName("Predef") ) - , newTermName("print") + , TermName("print") ) , List(ref) ): Tree Block((evals ++ prints).toList, Literal(Constant(()))) } -}
\ No newline at end of file +} diff --git a/test/files/run/reify_this.scala b/test/files/run/reify_this.scala index ecbf394bba..c385da6360 100644 --- a/test/files/run/reify_this.scala +++ b/test/files/run/reify_this.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ import scala.tools.reflect.Eval -trait Eval { +trait Transvaal { def eval(tree: Expr[_]) = tree.eval } -object Test extends App with Eval { +object Test extends App with Transvaal { // select a value from package eval(reify{println("foo")}) eval(reify{println((new Object).toString == (new Object).toString)}) @@ -17,4 +17,4 @@ object Test extends App with Eval { // select a value from module val x = 2 eval(reify{println(x)}) -}
\ No newline at end of file +} diff --git a/test/files/run/repl-backticks.scala b/test/files/run/repl-backticks.scala index 5eaa1ec4c1..ec2691d9c5 100644 --- a/test/files/run/repl-backticks.scala +++ b/test/files/run/repl-backticks.scala @@ -8,7 +8,7 @@ object Test { `yield` </code>.text - def main(args: Array[String]) = { + def main(args: Array[String]) { val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") val repl = new interpreter.IMain(settings) diff --git a/test/files/run/repl-bare-expr.check b/test/files/run/repl-bare-expr.check index 8b6434e986..a92243c7c0 100644 --- a/test/files/run/repl-bare-expr.check +++ b/test/files/run/repl-bare-expr.check @@ -31,7 +31,7 @@ scala> 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Mooo <console>:7: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { ^ -defined module Cow +defined object Cow defined class Moo bippy: Int res2: Int = 105 @@ -39,7 +39,7 @@ res2: Int = 105 scala> scala> object Bovine { var x: List[_] = null } ; case class Ruminant(x: Int) ; bippy * bippy * bippy -defined module Bovine +defined object Bovine defined class Ruminant res3: Int = 216 diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index 0cb18e989a..002316fd54 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -8,7 +8,6 @@ scala> :type List[1, 2, 3] List[1, 2, 3] ^ - scala> :type List(1, 2, 3) List[Int] @@ -43,10 +42,9 @@ scala> :type protected lazy val f = 5 Access to protected value f not permitted because enclosing object $eval in package $line13 is not a subclass of object $iw where target is defined - lazy val $result = `f` + lazy val $result = f ^ - scala> :type def f = 5 => Int @@ -81,7 +79,7 @@ TypeRef( ) TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List( @@ -148,7 +146,7 @@ TypeRef( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List( @@ -181,7 +179,7 @@ PolyType( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(T <: AnyVal))) @@ -204,7 +202,7 @@ PolyType( params = List(TermSymbol(x: T), TermSymbol(y: List[U])) resultType = TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(U >: T))) diff --git a/test/files/run/repl-empty-package.check b/test/files/run/repl-empty-package.check new file mode 100644 index 0000000000..ecf79c2c6d --- /dev/null +++ b/test/files/run/repl-empty-package.check @@ -0,0 +1,7 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> println(Bippy.bippy) +bippy! + +scala> diff --git a/test/files/run/repl-empty-package/s_1.scala b/test/files/run/repl-empty-package/s_1.scala new file mode 100644 index 0000000000..b59d16b338 --- /dev/null +++ b/test/files/run/repl-empty-package/s_1.scala @@ -0,0 +1,3 @@ +object Bippy { + def bippy = "bippy!" +} diff --git a/test/files/run/repl-empty-package/s_2.scala b/test/files/run/repl-empty-package/s_2.scala new file mode 100644 index 0000000000..512e6dd382 --- /dev/null +++ b/test/files/run/repl-empty-package/s_2.scala @@ -0,0 +1,5 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = "println(Bippy.bippy)" +} diff --git a/test/files/run/repl-javap-app.check b/test/files/run/repl-javap-app.check new file mode 100644 index 0000000000..db1f09b977 --- /dev/null +++ b/test/files/run/repl-javap-app.check @@ -0,0 +1,39 @@ +#partest java6 +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :javap -app MyApp$ +public final void delayedEndpoint$MyApp$1(); + Code: + Stack=2, Locals=1, Args_size=1 + 0: getstatic #61; //Field scala/Console$.MODULE$:Lscala/Console$; + 3: ldc #63; //String Hello, delayed world. + 5: invokevirtual #67; //Method scala/Console$.println:(Ljava/lang/Object;)V + 8: return + LocalVariableTable: + Start Length Slot Name Signature + 0 9 0 this LMyApp$; +} + +scala> +#partest !java6 +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :javap -app MyApp$ + public final void delayedEndpoint$MyApp$1(); + flags: ACC_PUBLIC, ACC_FINAL + Code: + stack=2, locals=1, args_size=1 + 0: getstatic #61 // Field scala/Console$.MODULE$:Lscala/Console$; + 3: ldc #63 // String Hello, delayed world. + 5: invokevirtual #67 // Method scala/Console$.println:(Ljava/lang/Object;)V + 8: return + LocalVariableTable: + Start Length Slot Name Signature + 0 9 0 this LMyApp$; + LineNumberTable: + line 5: 0 +} + +scala> diff --git a/test/files/run/repl-javap-app.scala b/test/files/run/repl-javap-app.scala new file mode 100644 index 0000000000..be04920be1 --- /dev/null +++ b/test/files/run/repl-javap-app.scala @@ -0,0 +1,10 @@ + +import scala.tools.partest.ReplTest + +object MyApp extends App { + Console println "Hello, delayed world." +} + +object Test extends ReplTest { + def code = ":javap -app MyApp$" +} diff --git a/test/files/run/repl-javap-def.scala b/test/files/run/repl-javap-def.scala new file mode 100644 index 0000000000..dbd769613a --- /dev/null +++ b/test/files/run/repl-javap-def.scala @@ -0,0 +1,17 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |def f = 7 + |:javap -public -raw f + """.stripMargin + + // it should find f wrapped in repl skins. replstiltskin. + override def yah(res: Seq[String]) = { + // replstiltskin: what be my name? + val keywords = List("public", "class", "line") + def isLineClass(s: String) = keywords forall (s contains _) + def filtered = res filter isLineClass + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap-fun.scala b/test/files/run/repl-javap-fun.scala new file mode 100644 index 0000000000..5c9a6b7691 --- /dev/null +++ b/test/files/run/repl-javap-fun.scala @@ -0,0 +1,16 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | List(1,2,3) filter (_ % 2 != 0) map (_ * 2) + |} + |:javap -fun Betty + """.stripMargin + + // two anonfuns of Betty + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public final class Betty") + 2 == filtered.size + } +} diff --git a/test/files/run/repl-javap-mem.scala b/test/files/run/repl-javap-mem.scala new file mode 100644 index 0000000000..8db30e835c --- /dev/null +++ b/test/files/run/repl-javap-mem.scala @@ -0,0 +1,19 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | val ds = List(1,2,3) filter (_ % 2 == 0) map (_ * 3) + | def m(vs: List[Int]) = vs filter (_ % 2 != 0) map (_ * 2) + |} + |:javap Betty#m + """.stripMargin + + // filter for requested method member + override def yah(res: Seq[String]) = { + // cheaply, methods end in arg list + val p = """.*m\(.*\);""".r + def filtered = res filter (_ match { case p() => true case _ => false }) + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap-memfun.scala b/test/files/run/repl-javap-memfun.scala new file mode 100644 index 0000000000..d2b4243c8b --- /dev/null +++ b/test/files/run/repl-javap-memfun.scala @@ -0,0 +1,18 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | List(1,2,3) count (_ % 2 != 0) + | def f = List(1,2,3) filter (_ % 2 != 0) map (_ * 2) + | def g = List(1,2,3) filter (_ % 2 == 0) map (_ * 3) map (_ + 1) + |} + |:javap -fun Betty#g + """.stripMargin + + // three anonfuns of Betty#g + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public final class Betty") + 3 == filtered.size + } +} diff --git a/test/files/run/repl-javap-more-fun.scala b/test/files/run/repl-javap-more-fun.scala new file mode 100644 index 0000000000..e603faf75a --- /dev/null +++ b/test/files/run/repl-javap-more-fun.scala @@ -0,0 +1,17 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | val ds = List(1,2,3) filter (_ % 2 == 0) map (_ * 3) + | def m(vs: List[Int]) = vs filter (_ % 2 != 0) map (_ * 2) + |} + |:javap -fun Betty + """.stripMargin + + // two anonfuns of Betty + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public final class Betty") + 4 == filtered.size + } +} diff --git a/test/files/run/repl-javap-outdir-funs/foo_1.scala b/test/files/run/repl-javap-outdir-funs/foo_1.scala new file mode 100644 index 0000000000..9b98e94733 --- /dev/null +++ b/test/files/run/repl-javap-outdir-funs/foo_1.scala @@ -0,0 +1,6 @@ + +package disktest + +class Foo { + def m(vs: List[Int]) = vs map (_ + 1) +} diff --git a/test/files/run/repl-javap-outdir-funs/run-repl_7.scala b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala new file mode 100644 index 0000000000..dfe3dae270 --- /dev/null +++ b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala @@ -0,0 +1,12 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |:javap -fun disktest/Foo.class + """.stripMargin + + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public final class disktest.Foo") + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap-outdir/foo_1.scala b/test/files/run/repl-javap-outdir/foo_1.scala new file mode 100644 index 0000000000..9b98e94733 --- /dev/null +++ b/test/files/run/repl-javap-outdir/foo_1.scala @@ -0,0 +1,6 @@ + +package disktest + +class Foo { + def m(vs: List[Int]) = vs map (_ + 1) +} diff --git a/test/files/run/repl-javap-outdir/run-repl_7.scala b/test/files/run/repl-javap-outdir/run-repl_7.scala new file mode 100644 index 0000000000..dc2c5719ff --- /dev/null +++ b/test/files/run/repl-javap-outdir/run-repl_7.scala @@ -0,0 +1,12 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |:javap disktest/Foo.class + """.stripMargin + + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public class disktest.Foo") + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap.scala b/test/files/run/repl-javap.scala new file mode 100644 index 0000000000..7a19852d4e --- /dev/null +++ b/test/files/run/repl-javap.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |case class Betty(i: Int) { def next = Betty(i+1) } + |:javap Betty + """.stripMargin + + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public class Betty") + 1 == filtered.size + } +} diff --git a/test/files/run/repl-out-dir.check b/test/files/run/repl-out-dir.check new file mode 100644 index 0000000000..a96f9ba9d9 --- /dev/null +++ b/test/files/run/repl-out-dir.check @@ -0,0 +1,53 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> case class Bippy(x: Int) +defined class Bippy + +scala> val x = Bippy(1) +x: Bippy = Bippy(1) + +scala> $intp.showDirectory +repl-out-dir-run.obj + $line1 + $eval$.class + $eval.class + $line2 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$.class + $read$.class + $read.class + $line3 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$$iw$Bippy$.class + $read$$iw$$iw$Bippy.class + $read$$iw$.class + $read$.class + $read.class + $line4 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$.class + $read$.class + $read.class + $line5 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$.class + $read$.class + $read.class + $repl_$init.class + Test$.class + Test.class + +scala> + +scala> diff --git a/test/files/run/repl-out-dir.scala b/test/files/run/repl-out-dir.scala new file mode 100644 index 0000000000..33c823aa2d --- /dev/null +++ b/test/files/run/repl-out-dir.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.ReplTest +import scala.tools.nsc.Settings + +object Test extends ReplTest { + override def extraSettings = s"-Yrepl-outdir ${testOutput.path}" + + def code = s""" +case class Bippy(x: Int) +val x = Bippy(1) +$$intp.showDirectory + """ + +} diff --git a/test/files/run/repl-paste-4.pastie b/test/files/run/repl-paste-4.pastie new file mode 100644 index 0000000000..853a66f6a4 --- /dev/null +++ b/test/files/run/repl-paste-4.pastie @@ -0,0 +1,4 @@ + +// if we are truly companions, I can see your foo +class Foo { private val foo = 7 } +object Foo { def apply(f: Foo) = f.foo } diff --git a/test/files/run/repl-paste-4.scala b/test/files/run/repl-paste-4.scala new file mode 100644 index 0000000000..0060dc1ff6 --- /dev/null +++ b/test/files/run/repl-paste-4.scala @@ -0,0 +1,20 @@ + +import scala.tools.partest.SessionTest + +object Test extends SessionTest { + def session = +s"""|Type in expressions to have them evaluated. + |Type :help for more information. + | + |scala> :paste $pastie + |Pasting file $pastie... + |defined class Foo + |defined object Foo + | + |scala> Foo(new Foo) + |res0: Int = 7 + | + |scala> """ + def pastie = testPath changeExtension "pastie" +} + diff --git a/test/files/run/repl-paste-raw.pastie b/test/files/run/repl-paste-raw.pastie new file mode 100644 index 0000000000..f13b4bcf8b --- /dev/null +++ b/test/files/run/repl-paste-raw.pastie @@ -0,0 +1,8 @@ + +// a raw paste is not a script +// hence it can be packaged + +package brown_paper + +// these are a few of my favorite things +case class Gift (hasString: Boolean) diff --git a/test/files/run/repl-paste-raw.scala b/test/files/run/repl-paste-raw.scala new file mode 100644 index 0000000000..2953796f99 --- /dev/null +++ b/test/files/run/repl-paste-raw.scala @@ -0,0 +1,20 @@ + +import scala.tools.partest.SessionTest + +object Test extends SessionTest { + def session = +s"""|Type in expressions to have them evaluated. + |Type :help for more information. + | + |scala> :paste -raw $pastie + |Pasting file $pastie... + | + |scala> val favoriteThing = brown_paper.Gift(true) + |favoriteThing: brown_paper.Gift = Gift(true) + | + |scala> favoriteThing.hasString + |res0: Boolean = true + | + |scala> """ + def pastie = testPath changeExtension "pastie" +} diff --git a/test/files/run/repl-paste.check b/test/files/run/repl-paste.check index d3e171fbfb..e4c407c6e8 100644 --- a/test/files/run/repl-paste.check +++ b/test/files/run/repl-paste.check @@ -21,7 +21,7 @@ val x = (new Dingus).y // Exiting paste mode, now interpreting. defined class Dingus -defined module Dingus +defined object Dingus x: Int = 110 scala> diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 9d63ecde94..1abb8e9d14 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -14,6 +14,7 @@ scala> global.emptyValDef // "it is imported twice in the same scope by ..." res0: $r.global.emptyValDef.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags +warning: there were 1 feature warning(s); re-run with -feature for details tp: $r.global.Type = Array[scala.util.Random] scala> tp.memberType(Array_apply) // evidence diff --git a/test/files/run/repl-save.check b/test/files/run/repl-save.check new file mode 100644 index 0000000000..5f928688d0 --- /dev/null +++ b/test/files/run/repl-save.check @@ -0,0 +1,3 @@ +val i = 7 +val j = 8 +i * j diff --git a/test/files/run/repl-save.scala b/test/files/run/repl-save.scala new file mode 100644 index 0000000000..4539790b1a --- /dev/null +++ b/test/files/run/repl-save.scala @@ -0,0 +1,25 @@ +import scala.tools.partest.SessionTest + +object Test extends SessionTest { + def session = +s"""|Type in expressions to have them evaluated. + |Type :help for more information. + | + |scala> val i = 7 + |i: Int = 7 + | + |scala> val j = 8 + |j: Int = 8 + | + |scala> i * j + |res0: Int = 56 + | + |scala> :save $saveto + | + |scala> """ + def saveto = testOutput / "session.repl" + override def show() = { + super.show() + Console print saveto.toFile.slurp + } +} diff --git a/test/files/run/repl-term-macros.check b/test/files/run/repl-term-macros.check new file mode 100644 index 0000000000..eae489c294 --- /dev/null +++ b/test/files/run/repl-term-macros.check @@ -0,0 +1,44 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> import scala.reflect.macros.Context +import scala.reflect.macros.Context + +scala> import language.experimental.macros +import language.experimental.macros + +scala> + +scala> def impl1(c: Context) = c.literalUnit +impl1: (c: scala.reflect.macros.Context)c.Expr[Unit] + +scala> def foo1 = macro impl1 +defined term macro foo1: Unit + +scala> foo1 + +scala> + +scala> def impl2(c: Context)() = c.literalUnit +impl2: (c: scala.reflect.macros.Context)()c.Expr[Unit] + +scala> def foo2() = macro impl2 +defined term macro foo2: ()Unit + +scala> foo2() + +scala> + +scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = c.literalUnit +impl3: (c: scala.reflect.macros.Context)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit] + +scala> def foo3(x: Int)(y: Int) = macro impl3 +defined term macro foo3: (x: Int)(y: Int)Unit + +scala> foo3(2)(3) + +scala> + +scala> diff --git a/test/files/run/repl-term-macros.scala b/test/files/run/repl-term-macros.scala new file mode 100644 index 0000000000..f826259be9 --- /dev/null +++ b/test/files/run/repl-term-macros.scala @@ -0,0 +1,20 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + import scala.reflect.macros.Context +import language.experimental.macros + +def impl1(c: Context) = c.literalUnit +def foo1 = macro impl1 +foo1 + +def impl2(c: Context)() = c.literalUnit +def foo2() = macro impl2 +foo2() + +def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = c.literalUnit +def foo3(x: Int)(y: Int) = macro impl3 +foo3(2)(3) + """ +}
\ No newline at end of file diff --git a/test/files/run/resetattrs-this.scala b/test/files/run/resetattrs-this.scala index 12afa3d712..2a55437273 100644 --- a/test/files/run/resetattrs-this.scala +++ b/test/files/run/resetattrs-this.scala @@ -4,8 +4,8 @@ import scala.tools.reflect.ToolBox object Test extends App { val tb = cm.mkToolBox() - val tree = Select(This(cm.staticPackage("scala").moduleClass), newTermName("Predef")) + val tree = Select(This(cm.staticPackage("scala").moduleClass), TermName("Predef")) val ttree = tb.typeCheck(tree) val rttree = tb.resetAllAttrs(ttree) println(tb.eval(rttree) == Predef) -}
\ No newline at end of file +} diff --git a/test/files/run/richs.check b/test/files/run/richs.check index a970a814b1..02a98b376d 100644 --- a/test/files/run/richs.check +++ b/test/files/run/richs.check @@ -1,3 +1,4 @@ +warning: there were 2 deprecation warning(s); re-run with -deprecation for details RichCharTest1: true diff --git a/test/files/run/richs.scala b/test/files/run/richs.scala index 5ee573673d..4b5345757c 100644 --- a/test/files/run/richs.scala +++ b/test/files/run/richs.scala @@ -11,8 +11,8 @@ trait RichTest { val cn = this.getClass().getName() cn.substring(0, cn.length-1) } - def length[A](it: Iterator[A]) = it.toList length - def length[A](it: Iterable[A]) = it.toList length + def length[A](it: Iterator[A]) = it.toList.length + def length[A](it: Iterable[A]) = it.toList.length def run: Unit } object RichCharTest1 extends RichTest { diff --git a/test/files/run/runtime.check b/test/files/run/runtime.check index 990a087da0..d613c9bd42 100644 --- a/test/files/run/runtime.check +++ b/test/files/run/runtime.check @@ -1,3 +1,9 @@ +runtime.scala:141: warning: comparing values of types Null and Null using `eq' will always yield true + check(true , null eq null, null ne null); + ^ +runtime.scala:141: warning: comparing values of types Null and Null using `ne' will always yield false + check(true , null eq null, null ne null); + ^ <<< Test0 [false,true] [0,1,2] diff --git a/test/files/run/runtime.scala b/test/files/run/runtime.scala index 2dcb41fb50..89348b294d 100644 --- a/test/files/run/runtime.scala +++ b/test/files/run/runtime.scala @@ -125,7 +125,7 @@ object Test2Test { object Test3Test { - class Foo { override def equals(that: Any) = error("abort"); } + class Foo { override def equals(that: Any) = sys.error("abort"); } def check(expected: Boolean, actual1: Boolean, actual2: Boolean): Unit = Console.println( @@ -171,7 +171,7 @@ object Test { try { test; } catch { - case exception => { + case exception: Throwable => { //val name: String = Thread.currentThread().getName(); Console.print("Exception in thread \"" + name + "\" " + exception); Console.println; diff --git a/test/files/run/search.check b/test/files/run/search.check new file mode 100644 index 0000000000..a885696509 --- /dev/null +++ b/test/files/run/search.check @@ -0,0 +1,6 @@ +Found(2) +Found(4) +InsertionPoint(9) +Found(2) +Found(4) +InsertionPoint(9) diff --git a/test/files/run/search.scala b/test/files/run/search.scala new file mode 100644 index 0000000000..ed7fed54a7 --- /dev/null +++ b/test/files/run/search.scala @@ -0,0 +1,14 @@ +object Test extends App { + import scala.collection.{LinearSeq, IndexedSeq} + import scala.collection.Searching.search + + val ls = LinearSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13) + println(ls.search(3)) + println(ls.search(5, 3, 8)) + println(ls.search(12)) + + val is = IndexedSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13) + println(is.search(3)) + println(is.search(5, 3, 8)) + println(is.search(12)) +} diff --git a/test/files/run/sequenceComparisons.scala b/test/files/run/sequenceComparisons.scala index 5d7958bc7e..f8ef17d77d 100644 --- a/test/files/run/sequenceComparisons.scala +++ b/test/files/run/sequenceComparisons.scala @@ -82,7 +82,7 @@ object Test { val sameElementsInputs = ( List(List(1,2,3,4,5)), - List(Nil, List(1), List(1,2), List(2,3,4), List(2,3,4,5), List(2,3,4,5,1), List(1,2,3,5,4), seq reverse) + List(Nil, List(1), List(1,2), List(2,3,4), List(2,3,4,5), List(2,3,4,5,1), List(1,2,3,5,4), seq.reverse) ) } diff --git a/test/files/run/settings-parse.check b/test/files/run/settings-parse.check new file mode 100644 index 0000000000..18145c9100 --- /dev/null +++ b/test/files/run/settings-parse.check @@ -0,0 +1,566 @@ +0) List(-cp, ) ==> Settings { + -d = . + -classpath = "" +} + +1) List(-cp, , ) ==> Settings { + -d = . + -classpath = "" +} + +2) List(, -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +3) List(-cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +4) List(-cp, , , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +5) List(-cp, , -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +6) List(, -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +7) List(-cp, , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +8) List(-cp, , , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +9) List(-cp, , -deprecation, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +10) List(-cp, , -deprecation, foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +11) List(, -cp, , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +12) List(-cp, , foo.scala) ==> Settings { + -d = . + -classpath = "" +} + +13) List(-cp, , , foo.scala) ==> Settings { + -d = . + -classpath = "" +} + +14) List(-cp, , foo.scala, ) ==> Settings { + -d = . + -classpath = "" +} + +15) List(, -cp, , foo.scala) ==> Settings { + -d = . + -classpath = "" +} + +16) List(-cp, , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +17) List(-cp, , , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +18) List(-cp, , foo.scala, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +19) List(-cp, , foo.scala, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +20) List(, -cp, , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +21) List(-deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +22) List(, -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +23) List(-deprecation, -cp, , ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +24) List(-deprecation, , -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +25) List(-deprecation, -cp, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +26) List(, -deprecation, -cp, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +27) List(-deprecation, -cp, , , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +28) List(-deprecation, -cp, , foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +29) List(-deprecation, , -cp, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +30) List(-deprecation, foo.scala, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +31) List(, -deprecation, foo.scala, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +32) List(-deprecation, , foo.scala, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +33) List(-deprecation, foo.scala, -cp, , ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +34) List(-deprecation, foo.scala, , -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +35) List(foo.scala, -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +36) List(, foo.scala, -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +37) List(foo.scala, -cp, , ) ==> Settings { + -d = . + -classpath = "" +} + +38) List(foo.scala, , -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +39) List(foo.scala, -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +40) List(, foo.scala, -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +41) List(foo.scala, -cp, , , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +42) List(foo.scala, -cp, , -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +43) List(foo.scala, , -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +44) List(foo.scala, -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +45) List(, foo.scala, -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +46) List(foo.scala, , -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +47) List(foo.scala, -deprecation, -cp, , ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +48) List(foo.scala, -deprecation, , -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +0) List(-cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +1) List(-cp, /tmp:/bippy, ) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +2) List(, -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +3) List(-cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +4) List(-cp, /tmp:/bippy, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +5) List(-cp, /tmp:/bippy, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +6) List(, -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +7) List(-cp, /tmp:/bippy, -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +8) List(-cp, /tmp:/bippy, , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +9) List(-cp, /tmp:/bippy, -deprecation, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +10) List(-cp, /tmp:/bippy, -deprecation, foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +11) List(, -cp, /tmp:/bippy, -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +12) List(-cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +13) List(-cp, /tmp:/bippy, , foo.scala) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +14) List(-cp, /tmp:/bippy, foo.scala, ) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +15) List(, -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +16) List(-cp, /tmp:/bippy, foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +17) List(-cp, /tmp:/bippy, , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +18) List(-cp, /tmp:/bippy, foo.scala, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +19) List(-cp, /tmp:/bippy, foo.scala, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +20) List(, -cp, /tmp:/bippy, foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +21) List(-deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +22) List(, -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +23) List(-deprecation, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +24) List(-deprecation, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +25) List(-deprecation, -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +26) List(, -deprecation, -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +27) List(-deprecation, -cp, /tmp:/bippy, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +28) List(-deprecation, -cp, /tmp:/bippy, foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +29) List(-deprecation, , -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +30) List(-deprecation, foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +31) List(, -deprecation, foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +32) List(-deprecation, , foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +33) List(-deprecation, foo.scala, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +34) List(-deprecation, foo.scala, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +35) List(foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +36) List(, foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +37) List(foo.scala, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +38) List(foo.scala, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +39) List(foo.scala, -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +40) List(, foo.scala, -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +41) List(foo.scala, -cp, /tmp:/bippy, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +42) List(foo.scala, -cp, /tmp:/bippy, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +43) List(foo.scala, , -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +44) List(foo.scala, -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +45) List(, foo.scala, -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +46) List(foo.scala, , -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +47) List(foo.scala, -deprecation, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +48) List(foo.scala, -deprecation, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + diff --git a/test/files/run/settings-parse.scala b/test/files/run/settings-parse.scala new file mode 100644 index 0000000000..2754feb972 --- /dev/null +++ b/test/files/run/settings-parse.scala @@ -0,0 +1,29 @@ + +import scala.language.postfixOps +import scala.tools.nsc._ + +object Test { + val tokens = List("", "-deprecation", "foo.scala") + val subsets = tokens.toSet.subsets.toList + val permutations0 = subsets.flatMap(_.toList.permutations).distinct + + def runWithCp(cp: String) = { + val permutations = permutations0 flatMap ("-cp CPTOKEN" :: _ permutations) + + for ((p, i) <- permutations.distinct.sortBy(_ mkString "").zipWithIndex) { + val args = p flatMap (_ split "\\s+") map (x => if (x == "CPTOKEN") cp else x) + val s = new settings.MutableSettings(println) + val (ok, residual) = s.processArguments(args, processAll = true) + + val expected = args filter (_ == "foo.scala") + assert(residual == expected, residual) + assert(ok, args) + println(s"$i) $args ==> $s") + } + } + + def main(args0: Array[String]): Unit = { + runWithCp("") + runWithCp("/tmp:/bippy") + } +} diff --git a/test/files/run/shortClass.check b/test/files/run/shortClass.check new file mode 100644 index 0000000000..fbdb725cca --- /dev/null +++ b/test/files/run/shortClass.check @@ -0,0 +1,10 @@ +bippity.bop.Foo +bippity.bop.Foo$Bar +bippity.bop.Foo$Bar$ +Test$$anon$1 +Test$$anon$2 +Foo +Bar +Bar$ +Foo with DingDongBippy +Bar with DingDongBippy diff --git a/test/files/run/shortClass.scala b/test/files/run/shortClass.scala new file mode 100644 index 0000000000..b7bb016896 --- /dev/null +++ b/test/files/run/shortClass.scala @@ -0,0 +1,24 @@ +import scala.reflect.internal.util._ + +package bippity { + trait DingDongBippy + + package bop { + class Foo { + class Bar + object Bar + } + } +} + +object Test { + import bippity._ + import bop._ + + def main(args: Array[String]): Unit = { + val f = new Foo + val instances = List(f, new f.Bar, f.Bar, new Foo with DingDongBippy, new f.Bar with DingDongBippy) + instances map (_.getClass.getName) foreach println + instances map shortClassOfInstance foreach println + } +} diff --git a/test/files/run/showraw_aliases.check b/test/files/run/showraw_aliases.check index aebd354031..d6a198b1cb 100644 --- a/test/files/run/showraw_aliases.check +++ b/test/files/run/showraw_aliases.check @@ -1,2 +1,2 @@ -Block(List(Import(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), List(ImportSelector(newTermName("universe"), <offset>, newTermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), scala.reflect.runtime.package), [newTermName("universe") aka newTermName("ru")])) -Block(List(Import(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), List(ImportSelector(newTermName("universe"), <offset>, newTermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), scala.reflect.runtime.package#<id>), [newTermName("universe")#<id> aka newTermName("ru")])) +Block(List(Import(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), List(ImportSelector(TermName("universe"), <offset>, TermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), scala.reflect.runtime.package), [TermName("universe") aka TermName("ru")])) +Block(List(Import(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), List(ImportSelector(TermName("universe"), <offset>, TermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), scala.reflect.runtime.package#<id>), [TermName("universe")#<id> aka TermName("ru")])) diff --git a/test/files/run/showraw_mods.check b/test/files/run/showraw_mods.check index 7fca027614..3ec868542d 100644 --- a/test/files/run/showraw_mods.check +++ b/test/files/run/showraw_mods.check @@ -1 +1 @@ -Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), newTypeName("C"), List(), Template(List(Ident(newTypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), newTermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), newTermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), newTermName("y"), TypeTree(), Select(This(newTypeName("C")), newTermName("x"))), ValDef(Modifiers(LAZY), newTermName("z"), TypeTree(), Select(This(newTypeName("C")), newTermName("y"))))))), Literal(Constant(()))) +Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), TypeName("C"), List(), Template(List(Ident(TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), TermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), TermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), TermName("y"), TypeTree(), Select(This(TypeName("C")), TermName("x"))), ValDef(Modifiers(LAZY), TermName("z"), TypeTree(), Select(This(TypeName("C")), TermName("y"))))))), Literal(Constant(()))) diff --git a/test/files/run/showraw_tree.check b/test/files/run/showraw_tree.check index b71018d4fe..eb74bd8b2b 100644 --- a/test/files/run/showraw_tree.check +++ b/test/files/run/showraw_tree.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Select(Ident(scala.Predef), newTypeName("String")), Select(Ident(scala.Predef), newTypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Select(Ident(scala.Predef), newTypeName("String")), Select(Ident(scala.Predef), newTypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_ids.check b/test/files/run/showraw_tree_ids.check index 5835ffa6de..7e0149a3c1 100644 --- a/test/files/run/showraw_tree_ids.check +++ b/test/files/run/showraw_tree_ids.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#<id>), List(Select(Ident(scala.Predef#<id>), newTypeName("String")), Select(Ident(scala.Predef#<id>), newTypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#<id>), List(Select(Ident(scala.Predef#<id>), newTypeName("String")), Select(Ident(scala.Predef#<id>), newTypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#<id>), List(Select(Ident(scala.Predef#<id>), TypeName("String")), Select(Ident(scala.Predef#<id>), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#<id>), List(Select(Ident(scala.Predef#<id>), TypeName("String")), Select(Ident(scala.Predef#<id>), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_kinds.check b/test/files/run/showraw_tree_kinds.check index c4d66856d4..577f447ae4 100644 --- a/test/files/run/showraw_tree_kinds.check +++ b/test/files/run/showraw_tree_kinds.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#CLS), List(Select(Ident(scala.Predef#MOD), newTypeName("String")), Select(Ident(scala.Predef#MOD), newTypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#CLS), List(Select(Ident(scala.Predef#MOD), newTypeName("String")), Select(Ident(scala.Predef#MOD), newTypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#CLS), List(Select(Ident(scala.Predef#MOD), TypeName("String")), Select(Ident(scala.Predef#MOD), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#CLS), List(Select(Ident(scala.Predef#MOD), TypeName("String")), Select(Ident(scala.Predef#MOD), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_types_ids.check b/test/files/run/showraw_tree_types_ids.check index fccb81d8df..6a73d77436 100644 --- a/test/files/run/showraw_tree_types_ids.check +++ b/test/files/run/showraw_tree_types_ids.check @@ -1,12 +1,12 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), newTypeName("String")#<id>)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), newTypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) -[1] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) +[1] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List())))) [3] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List()) -[4] TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()) +[4] TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()) [5] SingleType(ThisType(scala#<id>), scala.Predef#<id>) -Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), newTypeName("String")#<id>)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), newTypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) -[4] TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()) +Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) +[4] TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()) [5] SingleType(ThisType(scala#<id>), scala.Predef#<id>) -[6] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()))) -[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List())))) +[6] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()))) +[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List())))) [8] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List()) diff --git a/test/files/run/showraw_tree_types_typed.check b/test/files/run/showraw_tree_types_typed.check index f3e0f8c5f6..cf63ecb586 100644 --- a/test/files/run/showraw_tree_types_typed.check +++ b/test/files/run/showraw_tree_types_typed.check @@ -1,12 +1,12 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), newTypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), newTypeName("String"))))))), nme.CONSTRUCTOR), List()) -[1] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))))))), nme.CONSTRUCTOR), List()) +[1] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List())))) [3] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List()) -[4] TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()) +[4] TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) [5] SingleType(ThisType(scala), scala.Predef) -Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), newTypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), newTypeName("String"))))))), nme.CONSTRUCTOR), List()) -[4] TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()) +Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))))))), nme.CONSTRUCTOR), List()) +[4] TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) [5] SingleType(ThisType(scala), scala.Predef) -[6] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()))) -[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List())))) +[6] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()))) +[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List())))) [8] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List()) diff --git a/test/files/run/showraw_tree_types_untyped.check b/test/files/run/showraw_tree_types_untyped.check index b71018d4fe..eb74bd8b2b 100644 --- a/test/files/run/showraw_tree_types_untyped.check +++ b/test/files/run/showraw_tree_types_untyped.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Select(Ident(scala.Predef), newTypeName("String")), Select(Ident(scala.Predef), newTypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Select(Ident(scala.Predef), newTypeName("String")), Select(Ident(scala.Predef), newTypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_ultimate.check b/test/files/run/showraw_tree_ultimate.check index a6286ba754..63f72de50b 100644 --- a/test/files/run/showraw_tree_ultimate.check +++ b/test/files/run/showraw_tree_ultimate.check @@ -1,12 +1,12 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#PCTOR), List()) -[1] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#PCTOR), List()) +[1] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List())))) [3] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List()) -[4] TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()) +[4] TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()) [5] SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD) -Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#CTOR), List()) -[4] TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()) +Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#CTOR), List()) +[4] TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()) [5] SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD) -[6] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()))) -[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List())))) +[6] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()))) +[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List())))) [8] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List()) diff --git a/test/files/run/si5045.scala b/test/files/run/si5045.scala index e198b101f3..b0c3a4ddc4 100644 --- a/test/files/run/si5045.scala +++ b/test/files/run/si5045.scala @@ -1,3 +1,6 @@ + +import scala.language.postfixOps + object Test extends App { import scala.util.matching.{ Regex, UnanchoredRegex } diff --git a/test/files/run/slices.scala b/test/files/run/slices.scala index e31ea4046f..107b8e658a 100644 --- a/test/files/run/slices.scala +++ b/test/files/run/slices.scala @@ -1,3 +1,6 @@ + +import scala.language.postfixOps + object Test extends App { // lists diff --git a/test/files/run/spec-nlreturn.scala b/test/files/run/spec-nlreturn.scala index ec5e7229d3..a84160ecca 100644 --- a/test/files/run/spec-nlreturn.scala +++ b/test/files/run/spec-nlreturn.scala @@ -1,7 +1,8 @@ + object Test { def f(): Int = { try { - val g = 1 to 10 map { i => return 16 ; i } sum; + val g = (1 to 10 map { i => return 16 ; i }).sum g } catch { case x: runtime.NonLocalReturnControl[_] => diff --git a/test/files/run/stream_flatmap_odds.scala b/test/files/run/stream_flatmap_odds.scala index 6fb202ca68..1935253595 100644 --- a/test/files/run/stream_flatmap_odds.scala +++ b/test/files/run/stream_flatmap_odds.scala @@ -1,4 +1,4 @@ object Test extends App { lazy val odds: Stream[Int] = Stream(1) append ( odds flatMap {x => Stream(x + 2)} ) - println(odds take 42 force) + Console println (odds take 42).force } diff --git a/test/files/run/stream_length.check b/test/files/run/stream_length.check index 9906de773c..d1068f3247 100644 --- a/test/files/run/stream_length.check +++ b/test/files/run/stream_length.check @@ -1 +1,6 @@ +#partest !avian Length: 970299 + +#partest avian +!!!TEST SKIPPED!!! +See SI-7600 for further information. diff --git a/test/files/run/stream_length.scala b/test/files/run/stream_length.scala index 2808fbc495..33929f4b57 100644 --- a/test/files/run/stream_length.scala +++ b/test/files/run/stream_length.scala @@ -10,6 +10,10 @@ object Test { } def main(args: Array[String]) { - println("Length: " + walk(3, "---").length) + if (scala.tools.partest.utils.Properties.isAvian) { + println("!!!TEST SKIPPED!!!") + println("See SI-7600 for further information.") + } else + println("Length: " + walk(3, "---").length) } } diff --git a/test/files/run/stringbuilder-drop.scala b/test/files/run/stringbuilder-drop.scala index a9e5a71762..422fb2bc7c 100644 --- a/test/files/run/stringbuilder-drop.scala +++ b/test/files/run/stringbuilder-drop.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { - val s = (new StringBuilder ++= "hello world") dropRight 1 toString; - assert(s == "hello worl") + val s = (new StringBuilder ++= "hello world") dropRight 1 + assert("" + s == "hello worl") } } diff --git a/test/files/run/stringbuilder.scala b/test/files/run/stringbuilder.scala index ef85fc02a6..a88ea38b92 100644 --- a/test/files/run/stringbuilder.scala +++ b/test/files/run/stringbuilder.scala @@ -1,3 +1,6 @@ + +import scala.language.reflectiveCalls + object Test extends App { val str = "ABCDEFGHIJKLMABCDEFGHIJKLM" val surrogateStr = "an old Turkic letter: \uD803\uDC22" @@ -33,8 +36,8 @@ object Test extends App { sameAnswers(_.lastIndexOf("KLM", 22)) // testing that the "reverse" implementation avoids reversing surrogate pairs - val jsb = new JavaStringBuilder(surrogateStr) reverse - val ssb = new ScalaStringBuilder(surrogateStr) reverseContents ; + val jsb = new JavaStringBuilder(surrogateStr).reverse + val ssb = new ScalaStringBuilder(surrogateStr).reverseContents assert(jsb.toString == ssb.toString) } diff --git a/test/files/run/stringinterpolation_macro-run.scala b/test/files/run/stringinterpolation_macro-run.scala index 9c59c334f8..1138cd0860 100644 --- a/test/files/run/stringinterpolation_macro-run.scala +++ b/test/files/run/stringinterpolation_macro-run.scala @@ -1,3 +1,6 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ object Test extends App { // 'b' / 'B' (category: general) diff --git a/test/files/run/structural.scala b/test/files/run/structural.scala index 36af8c4bfc..2788717ec2 100644 --- a/test/files/run/structural.scala +++ b/test/files/run/structural.scala @@ -1,3 +1,6 @@ + +import scala.language.{ reflectiveCalls } + object test1 { val o1 = new Object { override def toString = "ohone" } @@ -152,7 +155,7 @@ object test2 { object test3 { - case class Exc extends Exception + case class Exc() extends Exception object Rec { def f = throw Exc() @@ -164,7 +167,7 @@ object test3 { } catch { case e: Exc => println("caught") - case e => println(e) + case e: Throwable => println(e) } m(Rec) diff --git a/test/files/run/synchronized.check b/test/files/run/synchronized.check index dd9f4ef424..6e99739633 100644 --- a/test/files/run/synchronized.check +++ b/test/files/run/synchronized.check @@ -1,3 +1,4 @@ +warning: there were 14 inliner warning(s); re-run with -Yinline-warnings for details .|. c1.f1: OK .|. c1.fi: OK .|... c1.fv: OK diff --git a/test/files/run/synchronized.flags b/test/files/run/synchronized.flags index 1182725e86..49d036a887 100644 --- a/test/files/run/synchronized.flags +++ b/test/files/run/synchronized.flags @@ -1 +1 @@ --optimize
\ No newline at end of file +-optimize diff --git a/test/files/run/t0091.check b/test/files/run/t0091.check index 7ed6ff82de..fd3c81a4d7 100644 --- a/test/files/run/t0091.check +++ b/test/files/run/t0091.check @@ -1 +1,2 @@ 5 +5 diff --git a/test/files/run/t0091.scala b/test/files/run/t0091.scala index eaddde0dbf..45235eb77b 100644 --- a/test/files/run/t0091.scala +++ b/test/files/run/t0091.scala @@ -4,10 +4,13 @@ object C extends B { object m extends A { def x = 5 } } object Test { - // The type annotation here is necessary, otherwise - // the compiler would reference C$m$ directly. - def o : B = C - def main(argv : Array[String]) : Unit = { - println(o.m.x) - } + // The type annotation here is necessary, otherwise + // the compiler would reference C$m$ directly. + def o1 : B = C + def o2 = C + + def main(argv : Array[String]) : Unit = { + println(o1.m.x) + println(o2.m.x) + } } diff --git a/test/files/run/t0325.scala b/test/files/run/t0325.scala index 92331ab05f..048303206c 100644 --- a/test/files/run/t0325.scala +++ b/test/files/run/t0325.scala @@ -24,7 +24,7 @@ object Test { else println(ret) } catch { - case e@_ => println(which + " failed with " + e.getClass) + case e: Throwable => println(which + " failed with " + e.getClass) } } diff --git a/test/files/run/t0421-old.scala b/test/files/run/t0421-old.scala index 8d51013924..9b88b4789b 100644 --- a/test/files/run/t0421-old.scala +++ b/test/files/run/t0421-old.scala @@ -1,4 +1,6 @@ // ticket #421 + +@deprecated("Suppress warnings", since="2.11") object Test extends App { def transpose[A: ClassManifest](xss: Array[Array[A]]) = { diff --git a/test/files/run/t0432.scala b/test/files/run/t0432.scala index 8ba9015d81..b860a0874f 100644 --- a/test/files/run/t0432.scala +++ b/test/files/run/t0432.scala @@ -1,3 +1,6 @@ + +import scala.language.reflectiveCalls + object Test { type valueType = { def value: this.type } diff --git a/test/files/run/t0528.scala b/test/files/run/t0528.scala index a76f602ed3..68a9975173 100644 --- a/test/files/run/t0528.scala +++ b/test/files/run/t0528.scala @@ -1,3 +1,5 @@ + +import scala.language.{ existentials } trait Sequ[A] { def toArray: Array[T forSome {type T <: A}] } diff --git a/test/files/run/t0677-old.scala b/test/files/run/t0677-old.scala index 6c8a3a7e99..c0f1abae53 100644 --- a/test/files/run/t0677-old.scala +++ b/test/files/run/t0677-old.scala @@ -1,3 +1,6 @@ + + +@deprecated("Suppress warnings", since="2.11") object Test extends App { class X[T: ClassManifest] { val a = Array.ofDim[T](3, 4) diff --git a/test/files/run/t1005.scala b/test/files/run/t1005.scala index 60129bcc51..575ec43565 100644 --- a/test/files/run/t1005.scala +++ b/test/files/run/t1005.scala @@ -1,19 +1,20 @@ +import scala.language.postfixOps object Test { class Foo[T](x : Array[AnyRef]) { def bar = x.asInstanceOf[Array[T]] } class Bar[T](x : Array[T]) { def bar = x.asInstanceOf[Array[AnyRef]] } object FromMono{ - def main(args : Array[String]) = (new Foo[AnyRef](Array[AnyRef]("Halp!"))).bar + def mainer(args : Array[String]) = (new Foo[AnyRef](Array[AnyRef]("Halp!"))).bar } object FromPoly{ - def main(args : Array[String]) = (new Bar[AnyRef](Array[AnyRef]("Halp!"))).bar + def mainer(args : Array[String]) = (new Bar[AnyRef](Array[AnyRef]("Halp!"))).bar } def main(args: Array[String]): Unit = { - println(FromMono main null mkString) - println(FromPoly main null mkString) + println(FromMono mainer null mkString) + println(FromPoly mainer null mkString) } } diff --git a/test/files/run/t1042.scala b/test/files/run/t1042.scala index 1f39fff24a..302ff31053 100644 --- a/test/files/run/t1042.scala +++ b/test/files/run/t1042.scala @@ -6,7 +6,7 @@ abstract class A { case class B() extends A { // overloaded version is implemented, causing toString not to be implemented? - def toString(sb: StringBuilder): StringBuilder = error("") + def toString(sb: StringBuilder): StringBuilder = sys.error("") } object Test extends App { diff --git a/test/files/run/t107.check b/test/files/run/t107.check new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/test/files/run/t107.check @@ -0,0 +1 @@ +1 diff --git a/test/files/run/t107.scala b/test/files/run/t107.scala new file mode 100644 index 0000000000..ab1b289882 --- /dev/null +++ b/test/files/run/t107.scala @@ -0,0 +1,8 @@ +object Test { + def main(args : Array[String]) : Unit = { + var hash : Long = 0 + val bytes = Array(1.toByte, 2.toByte, 3.toByte) + hash += bytes(0) + Console.println(hash) + } +}
\ No newline at end of file diff --git a/test/files/run/t1110.scala b/test/files/run/t1110.scala index 824643868c..81917789c8 100644 --- a/test/files/run/t1110.scala +++ b/test/files/run/t1110.scala @@ -1,8 +1,12 @@ + + +import scala.language.{ reflectiveCalls } + class Stuff { def zoop(p: Any{def &(q: Int): Int}) = p & 7 def floop = new { def & = "Hello" } - assert((floop &) == "Hello") + assert((floop.&) == "Hello") assert(zoop(10) == 2) } diff --git a/test/files/run/t1141.scala b/test/files/run/t1141.scala index ee4f2e7fd2..b907b4798f 100644 --- a/test/files/run/t1141.scala +++ b/test/files/run/t1141.scala @@ -1,3 +1,7 @@ + + +import scala.language.reflectiveCalls + object Test extends App { val foo = new { def apply(args : String*) = args foreach println diff --git a/test/files/run/t1195-new.scala b/test/files/run/t1195-new.scala index 0f62b140c9..4f068c7d42 100644 --- a/test/files/run/t1195-new.scala +++ b/test/files/run/t1195-new.scala @@ -1,3 +1,5 @@ + +import scala.language.{ existentials } import scala.reflect.runtime.universe._ object Test { @@ -25,4 +27,4 @@ class A1[T] { class B1[U] { def f = { case class D(x: Int) extends A1[String] ; new D(5) } } -}
\ No newline at end of file +} diff --git a/test/files/run/t1195-old.scala b/test/files/run/t1195-old.scala index b46a3b70f5..f80734c228 100644 --- a/test/files/run/t1195-old.scala +++ b/test/files/run/t1195-old.scala @@ -1,3 +1,6 @@ + +import scala.language.{ existentials } + object Test { def f() = { case class Bar(x: Int); Bar } def g() = { case class Bar(x: Int); Bar(5) } diff --git a/test/files/run/t1368.check b/test/files/run/t1368.check new file mode 100644 index 0000000000..581e8a4039 --- /dev/null +++ b/test/files/run/t1368.check @@ -0,0 +1,3 @@ +t1368.scala:7: warning: Reference to uninitialized value blurp + def go3 = (new AnyRef with Happy with Sad { override val status = blurp ; val blurp = "happysad" }).status + ^ diff --git a/test/files/run/t1427.check b/test/files/run/t1427.check new file mode 100644 index 0000000000..11a3d2f4a9 --- /dev/null +++ b/test/files/run/t1427.check @@ -0,0 +1,3 @@ +t1427.scala:6: warning: abstract type X in type pattern Bob[_[_] <: Any] is unchecked since it is eliminated by erasure + case x: (Bob[X] forSome { type X[_] }) => true + ^ diff --git a/test/files/run/t1427.scala b/test/files/run/t1427.scala index 21bd71ffef..eeb2603c26 100644 --- a/test/files/run/t1427.scala +++ b/test/files/run/t1427.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds } + class Bob[K[_]] { def foo(other: Any) = other match { case x: (Bob[X] forSome { type X[_] }) => true diff --git a/test/files/run/t1500.scala b/test/files/run/t1500.scala index ab132b724f..75a6e31cdf 100644 --- a/test/files/run/t1500.scala +++ b/test/files/run/t1500.scala @@ -16,12 +16,12 @@ object Test { </code>.text - def main(args: Array[String]) = { + def main(args: Array[String]) { val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") val tool = new interpreter.IMain(settings) - val global = tool.compiler + val global = tool.global import global._ import definitions._ diff --git a/test/files/run/t1501.scala b/test/files/run/t1501.scala index aba206bc7a..71ad0aeb5c 100644 --- a/test/files/run/t1501.scala +++ b/test/files/run/t1501.scala @@ -27,11 +27,11 @@ object Test { </code>.text - def main(args: Array[String]) = { + def main(args: Array[String]) { val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") val tool = new interpreter.IMain(settings) - val global = tool.compiler + val global = tool.global import global._ import definitions._ diff --git a/test/files/run/t1505.scala b/test/files/run/t1505.scala index a246e8a35b..d7feb30ce3 100644 --- a/test/files/run/t1505.scala +++ b/test/files/run/t1505.scala @@ -1,5 +1,3 @@ -object P extends Enumeration(0, "A", "B", "C") { val A, B, C = Value } - object Q extends Enumeration { val A = Value("A") val B = Value("B") @@ -11,9 +9,14 @@ object R extends Enumeration { } object Test extends App { - assert(P(0) == P.withName("A")) - assert(P.C == P.withName("C")) - assert(Q(0) == Q.withName("A")) assert(Q.C == Q.withName("C")) + + assert(R(0) == R.withName("A")) + assert(R.C == R.withName("C")) + + var failed = false + try { Q.withName("x") } catch { case _: NoSuchElementException => failed = true } + assert(failed) + } diff --git a/test/files/run/t153.scala b/test/files/run/t153.scala index 82492fdbe6..3fdb423865 100644 --- a/test/files/run/t153.scala +++ b/test/files/run/t153.scala @@ -1,5 +1,5 @@ object Test extends App { def powers(x: Int) = if ((x&(x-1))==0) Some(x) else None val res = (Stream.range(1, 500000) flatMap powers).reverse - println(res take 42 force) + println((res take 42).force) } diff --git a/test/files/run/t1766.scala b/test/files/run/t1766.scala index 2afd883755..7d12451092 100644 --- a/test/files/run/t1766.scala +++ b/test/files/run/t1766.scala @@ -1,3 +1,6 @@ + +import scala.language.{ reflectiveCalls } + object Test extends App { class C(s: String) { diff --git a/test/files/run/t2106.check b/test/files/run/t2106.check new file mode 100644 index 0000000000..b14e9d1c41 --- /dev/null +++ b/test/files/run/t2106.check @@ -0,0 +1,3 @@ +t2106.scala:7: warning: Could not inline required method foo because access level required by callee not matched by caller. + def main(args: Array[String]): Unit = x.foo + ^ diff --git a/test/files/run/t2106.flags b/test/files/run/t2106.flags index eb4d19bcb9..00d3643fd4 100644 --- a/test/files/run/t2106.flags +++ b/test/files/run/t2106.flags @@ -1 +1 @@ --optimise
\ No newline at end of file +-optimise -Yinline-warnings diff --git a/test/files/run/t2106.scala b/test/files/run/t2106.scala index e8124dabab..55b89da805 100644 --- a/test/files/run/t2106.scala +++ b/test/files/run/t2106.scala @@ -4,5 +4,5 @@ class A extends Cloneable { object Test { val x = new A - def main(args: Array[String]) = x.foo + def main(args: Array[String]): Unit = x.foo } diff --git a/test/files/run/t2251.check b/test/files/run/t2251.check new file mode 100644 index 0000000000..55ad2a5857 --- /dev/null +++ b/test/files/run/t2251.check @@ -0,0 +1 @@ +Set(List(List(C), Stream(D, ?))) diff --git a/test/files/run/t2251.scala b/test/files/run/t2251.scala new file mode 100644 index 0000000000..00c5619b49 --- /dev/null +++ b/test/files/run/t2251.scala @@ -0,0 +1,19 @@ +class A +trait B[T <: B[T]] extends A +class C extends B[C] { override def toString = "C" } +class D extends B[D] { override def toString = "D" } + +class E { + val ys = List(List(new C), Stream(new D)) +} + +object Test { + def trav = List(List(), Stream()) + + def main(args: Array[String]): Unit = { + val f = (new E).ys _ + var xs: Set[List[_ <: Seq[B[_]]]] = Set() + xs += f() + println(xs) + } +} diff --git a/test/files/run/t2251b.check b/test/files/run/t2251b.check new file mode 100644 index 0000000000..4231fc6ea6 --- /dev/null +++ b/test/files/run/t2251b.check @@ -0,0 +1,11 @@ +TypeTag[List[scala.collection.immutable.LinearSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with java.io.Serializable]] +TypeTag[List[scala.collection.immutable.Iterable[B[_ >: F with E with D with C <: B[_ >: F with E with D with C <: A]]] with F with Int => Any]] +TypeTag[List[scala.collection.immutable.Seq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with Serializable]] +TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[scala.collection.Map[_ >: F with C <: B[_ >: F with C <: B[_ >: F with C <: A]], B[_ >: G with D <: B[_ >: G with D <: A]]]]] +TypeTag[List[scala.collection.AbstractSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with scala.collection.LinearSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with java.io.Serializable]] +TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] diff --git a/test/files/run/t2251b.scala b/test/files/run/t2251b.scala new file mode 100644 index 0000000000..b67b3aec1e --- /dev/null +++ b/test/files/run/t2251b.scala @@ -0,0 +1,48 @@ +class A +trait B[T <: B[T]] extends A +class B1[T <: B1[T]] extends B[T] +class C extends B[C] { override def toString = "C" } +class D extends B[D] { override def toString = "D" } +class E extends B[E] { override def toString = "E" } +class F extends B[F] { override def toString = "F" } +class G extends B1[G] { override def toString = "G" } + +object Test { + import scala.collection.{ mutable, immutable } + import scala.collection.immutable.{ Vector } + import scala.reflect.runtime.universe._ + def what[T: TypeTag](x: T) = println(typeTag[T]) + + def main(args: Array[String]): Unit = { + what(List(List(new C), Stream(new D))) + what(List(List(new C), Stream(new D), Vector(new E), Set(new F))) + what(List(immutable.Vector(new C), Stream(new D))) + what(List(collection.Set(new F), mutable.Set(new G))) + what(List(collection.Set(new F), immutable.Set(new G))) + what(List(mutable.Set(new F), immutable.Set(new G))) + what(List(mutable.Seq(new F), immutable.Seq(new G))) + what(List(mutable.Map(new C -> new D), immutable.Map(new F -> new G))) + what(List(mutable.MutableList(new F), immutable.List(new G))) + what(List(mutable.Seq(new F), collection.Seq(new G))) + what(List(mutable.LinearSeq(new F), collection.IndexedSeq(new G))) + } +} + + +// class D extends B[D] { override def toString = "D" } + + +// class E { +// val ys = List(List(new C), Stream(new D)) +// } + +// object Test { +// def trav = List(List(), Stream()) + +// def main(args: Array[String]): Unit = { +// val f = (new E).ys _ +// var xs: Set[List[_ <: Seq[B[_]]]] = Set() +// xs += f() +// println(xs) +// } +// } diff --git a/test/files/run/t2308a.scala b/test/files/run/t2308a.scala index abb568064a..200dee1ef6 100644 --- a/test/files/run/t2308a.scala +++ b/test/files/run/t2308a.scala @@ -1,3 +1,5 @@ + +import scala.language.{ higherKinds } object Test { trait T[M[_]] diff --git a/test/files/run/t2318.check b/test/files/run/t2318.check new file mode 100644 index 0000000000..a486f1ac47 --- /dev/null +++ b/test/files/run/t2318.check @@ -0,0 +1,2 @@ +bar +bar diff --git a/test/files/run/t2318.scala b/test/files/run/t2318.scala new file mode 100644 index 0000000000..d7fd9fdd41 --- /dev/null +++ b/test/files/run/t2318.scala @@ -0,0 +1,41 @@ +import java.security._ + +import scala.language.{ reflectiveCalls } + +object Test { + trait Bar { def bar: Unit } + + object Mgr extends SecurityManager { + override def checkPermission(perm: Permission) = perm match { + case _: java.lang.RuntimePermission => () + case _: java.io.FilePermission => () + case x: java.security.SecurityPermission if x.getName contains ".networkaddress." => () // generality ftw + case x: java.util.PropertyPermission if x.getName == "sun.net.inetaddr.ttl" => () + case _ => super.checkPermission(perm) + } + } + + def t1() = { + val p = Runtime.getRuntime().exec("ls"); + type Destroyable = { def destroy() : Unit } + def doDestroy( obj : Destroyable ) : Unit = obj.destroy(); + doDestroy( p ); + } + def t2() = { + System.setSecurityManager(Mgr) + + val b = new Bar { def bar = println("bar") } + b.bar + + val structural = b.asInstanceOf[{ def bar: Unit }] + structural.bar + } + + def main(args: Array[String]) { + // figuring this will otherwise break on windows + try t1() + catch { case _: java.io.IOException => () } + + t2() + } +} diff --git a/test/files/run/t2333.scala b/test/files/run/t2333.scala index da43386572..7dc7a92df2 100644 --- a/test/files/run/t2333.scala +++ b/test/files/run/t2333.scala @@ -1,7 +1,7 @@ class A { def whatever() { lazy val a = 1 - lazy val b = try { 2 } catch { case _ => 0 } + lazy val b = try { 2 } catch { case _: Throwable => 0 } a b @@ -13,4 +13,4 @@ object Test { val a = new A a.whatever } -}
\ No newline at end of file +} diff --git a/test/files/run/t2417.scala b/test/files/run/t2417.scala index 2d0bc2d405..18b6c326b5 100644 --- a/test/files/run/t2417.scala +++ b/test/files/run/t2417.scala @@ -8,7 +8,7 @@ object Test { try { block } catch { - case x => failure = x + case x: Throwable => failure = x } } }) diff --git a/test/files/run/t2464/Annotated.java b/test/files/run/t2464/Annotated.java new file mode 100644 index 0000000000..d022f9852c --- /dev/null +++ b/test/files/run/t2464/Annotated.java @@ -0,0 +1,5 @@ +package test; + +@Connect(loadStyle = Connect.LoadStyle.EAGER) +public class Annotated { +} diff --git a/test/files/run/t2464/Connect.java b/test/files/run/t2464/Connect.java new file mode 100644 index 0000000000..59349f94c8 --- /dev/null +++ b/test/files/run/t2464/Connect.java @@ -0,0 +1,20 @@ +package test; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Connect { + + LoadStyle loadStyle() default LoadStyle.EAGER; + + public enum LoadStyle { + EAGER, + DEFERRED, + LAZY + } +} diff --git a/test/files/run/t2464/Test.scala b/test/files/run/t2464/Test.scala new file mode 100644 index 0000000000..90e1a03c17 --- /dev/null +++ b/test/files/run/t2464/Test.scala @@ -0,0 +1,35 @@ +import scala.reflect.io.Streamable +import scala.tools.asm.{ClassWriter, ClassReader} +import scala.tools.asm.tree.ClassNode +import scala.tools.partest._ +import scala.tools.partest.BytecodeTest.modifyClassFile +import java.io.{FileOutputStream, FileInputStream, File} + +object Test extends DirectTest { + 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 app = """ + object O { + new test.Annotated + } + """ + + def show(): Unit = { + compileCode(app) + modifyClassFile(new File(testOutput.toFile, "test/Annotated.class")) { + (cn: ClassNode) => + // As investigated https://issues.scala-lang.org/browse/SI-2464?focusedCommentId=64521&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-64521 + // classfiles in the wild sometimes lack the required InnerClass attribute for nested enums that + // are referenced in an annotation. I don't know what compiler or bytecode processor leaves things + // that way, but this test makes sure we don't crash. + cn.innerClasses.clear() + cn + } + compileCode(app) + } +} diff --git a/test/files/run/t2514.scala b/test/files/run/t2514.scala index 21c4afb472..cf5fa0ea02 100644 --- a/test/files/run/t2514.scala +++ b/test/files/run/t2514.scala @@ -1,3 +1,7 @@ + + +import scala.language.{ implicitConversions, postfixOps, reflectiveCalls } + object Test { implicit def x[A](a: A) = new { def xx = a } @@ -12,4 +16,4 @@ object Test assert(r5 == 24) } -}
\ No newline at end of file +} diff --git a/test/files/run/t2577.check b/test/files/run/t2577.check new file mode 100644 index 0000000000..4a584e4989 --- /dev/null +++ b/test/files/run/t2577.check @@ -0,0 +1 @@ +Nothing diff --git a/test/files/run/t2577.scala b/test/files/run/t2577.scala new file mode 100644 index 0000000000..6d836a3996 --- /dev/null +++ b/test/files/run/t2577.scala @@ -0,0 +1,17 @@ +case class annot[T]() extends scala.annotation.StaticAnnotation + +// type inference should infer @annot[Nothing] instead of @annot[T] +// note the T is not in scope here! +class Foo[@annot U] + +object Test { + import scala.reflect.runtime.universe._ + val x = new Foo + + def main(args: Array[String]): Unit = { + val targ = typeOf[x.type].widen match { + case TypeRef(_, _, arg :: _) => arg + } + println(targ) + } +} diff --git a/test/files/run/t2594_tcpoly.scala b/test/files/run/t2594_tcpoly.scala index e759ca8b0f..a9d26693f9 100644 --- a/test/files/run/t2594_tcpoly.scala +++ b/test/files/run/t2594_tcpoly.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds } + trait Monad[M[_]] { def foo[A](a: M[A]): M[A] } @@ -15,4 +18,4 @@ object Test { } def main(as: Array[String]) { BarMonad[Int] foo (new Bar[Int, Int]) } -}
\ No newline at end of file +} diff --git a/test/files/run/t2636.scala b/test/files/run/t2636.scala index 3271f79ffc..6ae2248a26 100644 --- a/test/files/run/t2636.scala +++ b/test/files/run/t2636.scala @@ -1,3 +1,6 @@ + +import scala.language.{ reflectiveCalls } + object Test { type Foo = { def update(x: Int, value: String): Unit } @@ -32,4 +35,4 @@ object Test assert(arrApply(arr, 1) == "o") assert(arrApply(new { def apply(x: Int) = "tom" }, -100) == "tom") } -}
\ No newline at end of file +} diff --git a/test/files/run/t2873.check b/test/files/run/t2873.check index 9198280f61..209b679c07 100644 --- a/test/files/run/t2873.check +++ b/test/files/run/t2873.check @@ -1 +1 @@ -scala.collection.immutable.RedBlack<A>.Empty$ +RedBlack<A>.Empty$ diff --git a/test/files/run/t2873.scala b/test/files/run/t2873.scala index 8d48a8dbb4..3a3cc59b46 100644 --- a/test/files/run/t2873.scala +++ b/test/files/run/t2873.scala @@ -1,5 +1,10 @@ +abstract class RedBlack[A] extends Serializable { + abstract class Tree[+B] extends Serializable + case object Empty extends Tree[Nothing] +} + object Test { def main(args: Array[String]): Unit = { - println(classOf[scala.collection.immutable.RedBlack[_]].getMethod("Empty").getGenericReturnType) + println(classOf[RedBlack[_]].getMethod("Empty").getGenericReturnType) } } diff --git a/test/files/run/t2886.check b/test/files/run/t2886.check index a70f9935ed..61e36948bd 100644 --- a/test/files/run/t2886.check +++ b/test/files/run/t2886.check @@ -1,5 +1,5 @@ ((x: Predef.String) => { - val x$1 = x; - val x$2 = x; + <artifact> val x$1 = x; + <artifact> val x$2 = x; Test.this.test(x$2, x$1) }) diff --git a/test/files/run/t3038d.scala b/test/files/run/t3038d.scala index 6cd2d83776..56cfcdb174 100644 --- a/test/files/run/t3038d.scala +++ b/test/files/run/t3038d.scala @@ -16,14 +16,12 @@ trait Foo { } } - -@serializable -class Bar extends Foo { +class Bar extends Foo with Serializable { @transient protected var first: Any = null def size = a @transient var second: Any = null - def checkMember { first } + def checkMember { if (first == null) print("") } private def writeObject(out: java.io.ObjectOutputStream) { serializeTo(out) diff --git a/test/files/run/t3050.scala b/test/files/run/t3050.scala index ca9d91e191..65b2674b69 100644 --- a/test/files/run/t3050.scala +++ b/test/files/run/t3050.scala @@ -2,7 +2,7 @@ object Test { def main(args: Array[String]): Unit = { val x = try { ("": Any) match { case List(_*) => true } } - catch { case _ => false } + catch { case _: Throwable => false } assert(!x) } diff --git a/test/files/run/t3175.scala b/test/files/run/t3175.scala index aff2e67d0d..5c6daead38 100644 --- a/test/files/run/t3175.scala +++ b/test/files/run/t3175.scala @@ -1,6 +1,9 @@ /** A bit down the road this test will examine * the bytecode. */ + +import scala.language.reflectiveCalls + object Test { def len(x:{ def length: Int }) = x.length def f1(x:{ def apply(x: Int): Long }) = x(0) diff --git a/test/files/run/t3232.scala b/test/files/run/t3232.scala index feff7e7089..4c6cb1e35c 100644 --- a/test/files/run/t3232.scala +++ b/test/files/run/t3232.scala @@ -15,7 +15,7 @@ object Test { // exception required List(e1, e2) foreach { f => try { f() ; assert(false) } - catch { case _ => () } + catch { case _: Throwable => () } } } } diff --git a/test/files/run/t3242.scala b/test/files/run/t3242.scala index f8defaa5cd..0a449d51f9 100644 --- a/test/files/run/t3242.scala +++ b/test/files/run/t3242.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds } + object Test { def benchmarkA(num: Int) { diff --git a/test/files/run/t3361.scala b/test/files/run/t3361.scala index 7fbc6777f2..f739d17b86 100644 --- a/test/files/run/t3361.scala +++ b/test/files/run/t3361.scala @@ -57,7 +57,7 @@ object Test extends App { DoubleLinkedList().insert(ten) } catch { case _: IllegalArgumentException => require(true) - case _ => require(false) + case _: Throwable => require(false) } val zero = DoubleLinkedList(0) zero.insert(ten) @@ -87,7 +87,7 @@ object Test extends App { DoubleLinkedList().append(ten) } catch { case _: IllegalArgumentException => require(true) - case _ => require(false) + case _: Throwable => require(false) } val zero = DoubleLinkedList(0) zero.append(ten) diff --git a/test/files/run/t3425.check b/test/files/run/t3425.check new file mode 100644 index 0000000000..5be779bd74 --- /dev/null +++ b/test/files/run/t3425.check @@ -0,0 +1,4 @@ +123 +456 +789 +789 diff --git a/test/files/run/t3425.scala b/test/files/run/t3425.scala new file mode 100644 index 0000000000..c61d1071a5 --- /dev/null +++ b/test/files/run/t3425.scala @@ -0,0 +1,41 @@ +import scala.language.reflectiveCalls +object Other { + abstract class Foo { + type R1 <: { def x: Any } + type R2 <: R1 { def x: Int } + + def f(x: R2) = x.x + } + + abstract class Bar { + trait R0 { def x: Any } + type R1 <: R0 { def x: AnyVal } + type R2 <: R1 { def x: Int } + + def f(x: R2) = x.x + } +} +object Test { + trait A + trait B + def x(a: (A { val y: Int }) with B { val y: Int }) = a.y + + class C extends A with B { + val y = 456 + } + + class Bippy { def x: Int = 789 } + + def main(args: Array[String]): Unit = { + println(x(new A with B { val y = 123 })) + println(x(new C)) + + { val foo = new Other.Foo { type R1 = Bippy ; type R2 = Bippy } + println(foo.f(new Bippy)) + } + { val bar = new Other.Bar { type R1 = Bippy with R0 ; type R2 = R1 } + println(bar.f(new Bippy with bar.R0)) + } + } +} + diff --git a/test/files/run/t3425b.check b/test/files/run/t3425b.check new file mode 100644 index 0000000000..5d34c43de3 --- /dev/null +++ b/test/files/run/t3425b.check @@ -0,0 +1,152 @@ +==== Direct Calls ==== + +Any{val y: P} with C{val y: P} +Any{val y: P} with C{val y: Q} +Any{val y: P} with C{val y: R forSome { type R <: P with Q }} +Any{val y: Q} with C{val y: P} +Any{val y: Q} with C{val y: Q} +Any{val y: Q} with C{val y: R forSome { type R <: P with Q }} +Any{val y: R forSome { type R <: P with Q }} with C{val y: P} +Any{val y: R forSome { type R <: P with Q }} with C{val y: Q} +Any{val y: R forSome { type R <: P with Q }} with C{val y: R forSome { type R <: P with Q }} +A{val y: P} with C{val y: P} +A{val y: P} with C{val y: Q} +A{val y: P} with C{val y: R forSome { type R <: P with Q }} +A{val y: Q} with C{val y: P} +A{val y: Q} with C{val y: Q} +A{val y: Q} with C{val y: R forSome { type R <: P with Q }} +A{val y: R forSome { type R <: P with Q }} with C{val y: P} +A{val y: R forSome { type R <: P with Q }} with C{val y: Q} +A{val y: R forSome { type R <: P with Q }} with C{val y: R forSome { type R <: P with Q }} +B{val y: P} with C{val y: P} +B{val y: P} with C{val y: Q} +B{val y: P} with C{val y: R forSome { type R <: P with Q }} +B{val y: Q} with C{val y: P} +B{val y: Q} with C{val y: Q} +B{val y: Q} with C{val y: R forSome { type R <: P with Q }} +B{val y: R forSome { type R <: P with Q }} with C{val y: P} +B{val y: R forSome { type R <: P with Q }} with C{val y: Q} +B{val y: R forSome { type R <: P with Q }} with C{val y: R forSome { type R <: P with Q }} +C{val y: P} with C{val y: P} +C{val y: P} with C{val y: Q} +C{val y: P} with C{val y: R forSome { type R <: P with Q }} +C{val y: Q} with C{val y: P} +C{val y: Q} with C{val y: Q} +C{val y: Q} with C{val y: R forSome { type R <: P with Q }} +C{val y: R forSome { type R <: P with Q }} with C{val y: P} +C{val y: R forSome { type R <: P with Q }} with C{val y: Q} +C{val y: R forSome { type R <: P with Q }} with C{val y: R forSome { type R <: P with Q }} + + +==== Reflective Calls ==== + +Any{val y: P} with Any{val y: P} +Any{val y: P} with Any{val y: Q} +Any{val y: P} with Any{val y: R forSome { type R <: P with Q }} +Any{val y: P} with A{val y: P} +Any{val y: P} with A{val y: Q} +Any{val y: P} with A{val y: R forSome { type R <: P with Q }} +Any{val y: P} with B{val y: P} +Any{val y: P} with B{val y: Q} +Any{val y: P} with B{val y: R forSome { type R <: P with Q }} +Any{val y: Q} with Any{val y: P} +Any{val y: Q} with Any{val y: Q} +Any{val y: Q} with Any{val y: R forSome { type R <: P with Q }} +Any{val y: Q} with A{val y: P} +Any{val y: Q} with A{val y: Q} +Any{val y: Q} with A{val y: R forSome { type R <: P with Q }} +Any{val y: Q} with B{val y: P} +Any{val y: Q} with B{val y: Q} +Any{val y: Q} with B{val y: R forSome { type R <: P with Q }} +Any{val y: R forSome { type R <: P with Q }} with Any{val y: P} +Any{val y: R forSome { type R <: P with Q }} with Any{val y: Q} +Any{val y: R forSome { type R <: P with Q }} with Any{val y: R forSome { type R <: P with Q }} +Any{val y: R forSome { type R <: P with Q }} with A{val y: P} +Any{val y: R forSome { type R <: P with Q }} with A{val y: Q} +Any{val y: R forSome { type R <: P with Q }} with A{val y: R forSome { type R <: P with Q }} +Any{val y: R forSome { type R <: P with Q }} with B{val y: P} +Any{val y: R forSome { type R <: P with Q }} with B{val y: Q} +Any{val y: R forSome { type R <: P with Q }} with B{val y: R forSome { type R <: P with Q }} +A{val y: P} with Any{val y: P} +A{val y: P} with Any{val y: Q} +A{val y: P} with Any{val y: R forSome { type R <: P with Q }} +A{val y: P} with A{val y: P} +A{val y: P} with A{val y: Q} +A{val y: P} with A{val y: R forSome { type R <: P with Q }} +A{val y: P} with B{val y: P} +A{val y: P} with B{val y: Q} +A{val y: P} with B{val y: R forSome { type R <: P with Q }} +A{val y: Q} with Any{val y: P} +A{val y: Q} with Any{val y: Q} +A{val y: Q} with Any{val y: R forSome { type R <: P with Q }} +A{val y: Q} with A{val y: P} +A{val y: Q} with A{val y: Q} +A{val y: Q} with A{val y: R forSome { type R <: P with Q }} +A{val y: Q} with B{val y: P} +A{val y: Q} with B{val y: Q} +A{val y: Q} with B{val y: R forSome { type R <: P with Q }} +A{val y: R forSome { type R <: P with Q }} with Any{val y: P} +A{val y: R forSome { type R <: P with Q }} with Any{val y: Q} +A{val y: R forSome { type R <: P with Q }} with Any{val y: R forSome { type R <: P with Q }} +A{val y: R forSome { type R <: P with Q }} with A{val y: P} +A{val y: R forSome { type R <: P with Q }} with A{val y: Q} +A{val y: R forSome { type R <: P with Q }} with A{val y: R forSome { type R <: P with Q }} +A{val y: R forSome { type R <: P with Q }} with B{val y: P} +A{val y: R forSome { type R <: P with Q }} with B{val y: Q} +A{val y: R forSome { type R <: P with Q }} with B{val y: R forSome { type R <: P with Q }} +B{val y: P} with Any{val y: P} +B{val y: P} with Any{val y: Q} +B{val y: P} with Any{val y: R forSome { type R <: P with Q }} +B{val y: P} with A{val y: P} +B{val y: P} with A{val y: Q} +B{val y: P} with A{val y: R forSome { type R <: P with Q }} +B{val y: P} with B{val y: P} +B{val y: P} with B{val y: Q} +B{val y: P} with B{val y: R forSome { type R <: P with Q }} +B{val y: Q} with Any{val y: P} +B{val y: Q} with Any{val y: Q} +B{val y: Q} with Any{val y: R forSome { type R <: P with Q }} +B{val y: Q} with A{val y: P} +B{val y: Q} with A{val y: Q} +B{val y: Q} with A{val y: R forSome { type R <: P with Q }} +B{val y: Q} with B{val y: P} +B{val y: Q} with B{val y: Q} +B{val y: Q} with B{val y: R forSome { type R <: P with Q }} +B{val y: R forSome { type R <: P with Q }} with Any{val y: P} +B{val y: R forSome { type R <: P with Q }} with Any{val y: Q} +B{val y: R forSome { type R <: P with Q }} with Any{val y: R forSome { type R <: P with Q }} +B{val y: R forSome { type R <: P with Q }} with A{val y: P} +B{val y: R forSome { type R <: P with Q }} with A{val y: Q} +B{val y: R forSome { type R <: P with Q }} with A{val y: R forSome { type R <: P with Q }} +B{val y: R forSome { type R <: P with Q }} with B{val y: P} +B{val y: R forSome { type R <: P with Q }} with B{val y: Q} +B{val y: R forSome { type R <: P with Q }} with B{val y: R forSome { type R <: P with Q }} +C{val y: P} with Any{val y: P} +C{val y: P} with Any{val y: Q} +C{val y: P} with Any{val y: R forSome { type R <: P with Q }} +C{val y: P} with A{val y: P} +C{val y: P} with A{val y: Q} +C{val y: P} with A{val y: R forSome { type R <: P with Q }} +C{val y: P} with B{val y: P} +C{val y: P} with B{val y: Q} +C{val y: P} with B{val y: R forSome { type R <: P with Q }} +C{val y: Q} with Any{val y: P} +C{val y: Q} with Any{val y: Q} +C{val y: Q} with Any{val y: R forSome { type R <: P with Q }} +C{val y: Q} with A{val y: P} +C{val y: Q} with A{val y: Q} +C{val y: Q} with A{val y: R forSome { type R <: P with Q }} +C{val y: Q} with B{val y: P} +C{val y: Q} with B{val y: Q} +C{val y: Q} with B{val y: R forSome { type R <: P with Q }} +C{val y: R forSome { type R <: P with Q }} with Any{val y: P} +C{val y: R forSome { type R <: P with Q }} with Any{val y: Q} +C{val y: R forSome { type R <: P with Q }} with Any{val y: R forSome { type R <: P with Q }} +C{val y: R forSome { type R <: P with Q }} with A{val y: P} +C{val y: R forSome { type R <: P with Q }} with A{val y: Q} +C{val y: R forSome { type R <: P with Q }} with A{val y: R forSome { type R <: P with Q }} +C{val y: R forSome { type R <: P with Q }} with B{val y: P} +C{val y: R forSome { type R <: P with Q }} with B{val y: Q} +C{val y: R forSome { type R <: P with Q }} with B{val y: R forSome { type R <: P with Q }} + + diff --git a/test/files/run/t3425b/Base_1.scala b/test/files/run/t3425b/Base_1.scala new file mode 100644 index 0000000000..5a660a89b2 --- /dev/null +++ b/test/files/run/t3425b/Base_1.scala @@ -0,0 +1,89 @@ +trait P { def reflected: Boolean } +trait Q { def reflected: Boolean } +class PQ(val reflected: Boolean) extends P with Q { } + +trait A +trait B +trait C { val y: P } +class ABC extends A with B with C { + private def reflected = ( + Thread.currentThread.getStackTrace + takeWhile (_.getMethodName != "main") + exists (_.toString contains "sun.reflect.") + ) + lazy val y: PQ = new PQ(reflected) +} + +/*** The source used to generate the second file + Not otherwise used in the test except that compiling + it helps make sure it still compiles. + +****/ + +object Gen { + case class Tp(outer: String, elem: String) { + override def toString = s"$outer { val y: $elem }" + } + case class Pair(tp1: Tp, tp2: Tp) { + def expr = s"((new ABC): $tp)" + def tp = s"($tp1) with ($tp2)" + } + val traits = Vector("Any", "A", "B", "C") map ("%6s" format _) + val types = Vector("P", "Q", "R forSome { type R <: P with Q }") + val allTypes = for (c <- traits ; tp <- types) yield Tp(c, tp) + val pairs = allTypes flatMap (t1 => allTypes map (t2 => Pair(t1, t2))) + val indices = pairs.indices + + def aliases(idx: Int) = { + val p = pairs(idx) + import p._ + List( + s"type R1_$idx = $tp", + s"type R2_$idx = R1_$idx { val y: (${tp1.elem}) with (${tp2.elem}) }" + ) + } + + def mkMethodContent(pre: String)(f: Int => String) = + indices map (i => s"def $pre$i${f(i)}") mkString "\n " + + def content = List( + indices flatMap aliases mkString "\n ", + mkMethodContent("f")(i => s" = { val x = ${pairs(i).expr} ; x.y.reflected -> whatis(x).toString }"), + mkMethodContent("g")(i => s"""(x: R1_$i) = x.y"""), + mkMethodContent("h")(i => s"""(x: R2_$i) = x.y""") + ) mkString "\n " + + def fCalls = indices map ("f" + _) mkString ("\n ", ",\n ", "\n ") + + def main(args: Array[String]): Unit = { + // One cannot attain proper appreciation for the inadequacies of + // string interpolation without becoming one with the newline. + val nl = "\\n" + + println(s""" + |import scala.reflect.runtime.universe._ + |import scala.language._ + | + |object Test { + | def whatis[T: TypeTag](x: T) = typeOf[T] + | def sshow(label: String, xs: Traversable[Any]) { + | println("==== " + label + " ====$nl") + | xs.toList.map("" + _).sorted foreach println + | println("$nl") + | } + | + | $content + | lazy val fcalls = List($fCalls) + | + | def main(args: Array[String]) { + | sshow("Direct Calls", fcalls collect { case (false, n) => n }) + | sshow("Reflective Calls", fcalls collect { case (true, n) => n }) + | // For a good time try printing this - have to fix bugs in + | // reflection before that's going to be a good idea + | // println(typeOf[Test.type].typeSymbol.asClass.typeSignature) + | } + |} + """.stripMargin.trim + ) + } +} diff --git a/test/files/run/t3425b/Generated_2.scala b/test/files/run/t3425b/Generated_2.scala new file mode 100644 index 0000000000..f1699636f6 --- /dev/null +++ b/test/files/run/t3425b/Generated_2.scala @@ -0,0 +1,886 @@ +import scala.reflect.runtime.universe._ +import scala.language._ + +object Test { + def whatis[T: TypeTag](x: T) = typeOf[T] + def sshow(label: String, xs: Traversable[Any]) { + println("==== " + label + " ====\n") + xs.toList.map("" + _).sorted foreach println + println("\n") + } + + type R1_0 = ( Any { val y: P }) with ( Any { val y: P }) + type R2_0 = R1_0 { val y: (P) with (P) } + type R1_1 = ( Any { val y: P }) with ( Any { val y: Q }) + type R2_1 = R1_1 { val y: (P) with (Q) } + type R1_2 = ( Any { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_2 = R1_2 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_3 = ( Any { val y: P }) with ( A { val y: P }) + type R2_3 = R1_3 { val y: (P) with (P) } + type R1_4 = ( Any { val y: P }) with ( A { val y: Q }) + type R2_4 = R1_4 { val y: (P) with (Q) } + type R1_5 = ( Any { val y: P }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_5 = R1_5 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_6 = ( Any { val y: P }) with ( B { val y: P }) + type R2_6 = R1_6 { val y: (P) with (P) } + type R1_7 = ( Any { val y: P }) with ( B { val y: Q }) + type R2_7 = R1_7 { val y: (P) with (Q) } + type R1_8 = ( Any { val y: P }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_8 = R1_8 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_9 = ( Any { val y: P }) with ( C { val y: P }) + type R2_9 = R1_9 { val y: (P) with (P) } + type R1_10 = ( Any { val y: P }) with ( C { val y: Q }) + type R2_10 = R1_10 { val y: (P) with (Q) } + type R1_11 = ( Any { val y: P }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_11 = R1_11 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_12 = ( Any { val y: Q }) with ( Any { val y: P }) + type R2_12 = R1_12 { val y: (Q) with (P) } + type R1_13 = ( Any { val y: Q }) with ( Any { val y: Q }) + type R2_13 = R1_13 { val y: (Q) with (Q) } + type R1_14 = ( Any { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_14 = R1_14 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_15 = ( Any { val y: Q }) with ( A { val y: P }) + type R2_15 = R1_15 { val y: (Q) with (P) } + type R1_16 = ( Any { val y: Q }) with ( A { val y: Q }) + type R2_16 = R1_16 { val y: (Q) with (Q) } + type R1_17 = ( Any { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_17 = R1_17 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_18 = ( Any { val y: Q }) with ( B { val y: P }) + type R2_18 = R1_18 { val y: (Q) with (P) } + type R1_19 = ( Any { val y: Q }) with ( B { val y: Q }) + type R2_19 = R1_19 { val y: (Q) with (Q) } + type R1_20 = ( Any { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_20 = R1_20 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_21 = ( Any { val y: Q }) with ( C { val y: P }) + type R2_21 = R1_21 { val y: (Q) with (P) } + type R1_22 = ( Any { val y: Q }) with ( C { val y: Q }) + type R2_22 = R1_22 { val y: (Q) with (Q) } + type R1_23 = ( Any { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_23 = R1_23 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_24 = ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P }) + type R2_24 = R1_24 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_25 = ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q }) + type R2_25 = R1_25 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_26 = ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_26 = R1_26 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_27 = ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: P }) + type R2_27 = R1_27 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_28 = ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q }) + type R2_28 = R1_28 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_29 = ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_29 = R1_29 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_30 = ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: P }) + type R2_30 = R1_30 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_31 = ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q }) + type R2_31 = R1_31 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_32 = ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_32 = R1_32 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_33 = ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: P }) + type R2_33 = R1_33 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_34 = ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q }) + type R2_34 = R1_34 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_35 = ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_35 = R1_35 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_36 = ( A { val y: P }) with ( Any { val y: P }) + type R2_36 = R1_36 { val y: (P) with (P) } + type R1_37 = ( A { val y: P }) with ( Any { val y: Q }) + type R2_37 = R1_37 { val y: (P) with (Q) } + type R1_38 = ( A { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_38 = R1_38 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_39 = ( A { val y: P }) with ( A { val y: P }) + type R2_39 = R1_39 { val y: (P) with (P) } + type R1_40 = ( A { val y: P }) with ( A { val y: Q }) + type R2_40 = R1_40 { val y: (P) with (Q) } + type R1_41 = ( A { val y: P }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_41 = R1_41 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_42 = ( A { val y: P }) with ( B { val y: P }) + type R2_42 = R1_42 { val y: (P) with (P) } + type R1_43 = ( A { val y: P }) with ( B { val y: Q }) + type R2_43 = R1_43 { val y: (P) with (Q) } + type R1_44 = ( A { val y: P }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_44 = R1_44 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_45 = ( A { val y: P }) with ( C { val y: P }) + type R2_45 = R1_45 { val y: (P) with (P) } + type R1_46 = ( A { val y: P }) with ( C { val y: Q }) + type R2_46 = R1_46 { val y: (P) with (Q) } + type R1_47 = ( A { val y: P }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_47 = R1_47 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_48 = ( A { val y: Q }) with ( Any { val y: P }) + type R2_48 = R1_48 { val y: (Q) with (P) } + type R1_49 = ( A { val y: Q }) with ( Any { val y: Q }) + type R2_49 = R1_49 { val y: (Q) with (Q) } + type R1_50 = ( A { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_50 = R1_50 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_51 = ( A { val y: Q }) with ( A { val y: P }) + type R2_51 = R1_51 { val y: (Q) with (P) } + type R1_52 = ( A { val y: Q }) with ( A { val y: Q }) + type R2_52 = R1_52 { val y: (Q) with (Q) } + type R1_53 = ( A { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_53 = R1_53 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_54 = ( A { val y: Q }) with ( B { val y: P }) + type R2_54 = R1_54 { val y: (Q) with (P) } + type R1_55 = ( A { val y: Q }) with ( B { val y: Q }) + type R2_55 = R1_55 { val y: (Q) with (Q) } + type R1_56 = ( A { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_56 = R1_56 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_57 = ( A { val y: Q }) with ( C { val y: P }) + type R2_57 = R1_57 { val y: (Q) with (P) } + type R1_58 = ( A { val y: Q }) with ( C { val y: Q }) + type R2_58 = R1_58 { val y: (Q) with (Q) } + type R1_59 = ( A { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_59 = R1_59 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_60 = ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P }) + type R2_60 = R1_60 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_61 = ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q }) + type R2_61 = R1_61 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_62 = ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_62 = R1_62 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_63 = ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: P }) + type R2_63 = R1_63 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_64 = ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q }) + type R2_64 = R1_64 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_65 = ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_65 = R1_65 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_66 = ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: P }) + type R2_66 = R1_66 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_67 = ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q }) + type R2_67 = R1_67 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_68 = ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_68 = R1_68 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_69 = ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: P }) + type R2_69 = R1_69 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_70 = ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q }) + type R2_70 = R1_70 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_71 = ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_71 = R1_71 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_72 = ( B { val y: P }) with ( Any { val y: P }) + type R2_72 = R1_72 { val y: (P) with (P) } + type R1_73 = ( B { val y: P }) with ( Any { val y: Q }) + type R2_73 = R1_73 { val y: (P) with (Q) } + type R1_74 = ( B { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_74 = R1_74 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_75 = ( B { val y: P }) with ( A { val y: P }) + type R2_75 = R1_75 { val y: (P) with (P) } + type R1_76 = ( B { val y: P }) with ( A { val y: Q }) + type R2_76 = R1_76 { val y: (P) with (Q) } + type R1_77 = ( B { val y: P }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_77 = R1_77 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_78 = ( B { val y: P }) with ( B { val y: P }) + type R2_78 = R1_78 { val y: (P) with (P) } + type R1_79 = ( B { val y: P }) with ( B { val y: Q }) + type R2_79 = R1_79 { val y: (P) with (Q) } + type R1_80 = ( B { val y: P }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_80 = R1_80 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_81 = ( B { val y: P }) with ( C { val y: P }) + type R2_81 = R1_81 { val y: (P) with (P) } + type R1_82 = ( B { val y: P }) with ( C { val y: Q }) + type R2_82 = R1_82 { val y: (P) with (Q) } + type R1_83 = ( B { val y: P }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_83 = R1_83 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_84 = ( B { val y: Q }) with ( Any { val y: P }) + type R2_84 = R1_84 { val y: (Q) with (P) } + type R1_85 = ( B { val y: Q }) with ( Any { val y: Q }) + type R2_85 = R1_85 { val y: (Q) with (Q) } + type R1_86 = ( B { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_86 = R1_86 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_87 = ( B { val y: Q }) with ( A { val y: P }) + type R2_87 = R1_87 { val y: (Q) with (P) } + type R1_88 = ( B { val y: Q }) with ( A { val y: Q }) + type R2_88 = R1_88 { val y: (Q) with (Q) } + type R1_89 = ( B { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_89 = R1_89 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_90 = ( B { val y: Q }) with ( B { val y: P }) + type R2_90 = R1_90 { val y: (Q) with (P) } + type R1_91 = ( B { val y: Q }) with ( B { val y: Q }) + type R2_91 = R1_91 { val y: (Q) with (Q) } + type R1_92 = ( B { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_92 = R1_92 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_93 = ( B { val y: Q }) with ( C { val y: P }) + type R2_93 = R1_93 { val y: (Q) with (P) } + type R1_94 = ( B { val y: Q }) with ( C { val y: Q }) + type R2_94 = R1_94 { val y: (Q) with (Q) } + type R1_95 = ( B { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_95 = R1_95 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_96 = ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P }) + type R2_96 = R1_96 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_97 = ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q }) + type R2_97 = R1_97 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_98 = ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_98 = R1_98 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_99 = ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: P }) + type R2_99 = R1_99 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_100 = ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q }) + type R2_100 = R1_100 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_101 = ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_101 = R1_101 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_102 = ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: P }) + type R2_102 = R1_102 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_103 = ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q }) + type R2_103 = R1_103 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_104 = ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_104 = R1_104 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_105 = ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: P }) + type R2_105 = R1_105 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_106 = ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q }) + type R2_106 = R1_106 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_107 = ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_107 = R1_107 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_108 = ( C { val y: P }) with ( Any { val y: P }) + type R2_108 = R1_108 { val y: (P) with (P) } + type R1_109 = ( C { val y: P }) with ( Any { val y: Q }) + type R2_109 = R1_109 { val y: (P) with (Q) } + type R1_110 = ( C { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_110 = R1_110 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_111 = ( C { val y: P }) with ( A { val y: P }) + type R2_111 = R1_111 { val y: (P) with (P) } + type R1_112 = ( C { val y: P }) with ( A { val y: Q }) + type R2_112 = R1_112 { val y: (P) with (Q) } + type R1_113 = ( C { val y: P }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_113 = R1_113 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_114 = ( C { val y: P }) with ( B { val y: P }) + type R2_114 = R1_114 { val y: (P) with (P) } + type R1_115 = ( C { val y: P }) with ( B { val y: Q }) + type R2_115 = R1_115 { val y: (P) with (Q) } + type R1_116 = ( C { val y: P }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_116 = R1_116 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_117 = ( C { val y: P }) with ( C { val y: P }) + type R2_117 = R1_117 { val y: (P) with (P) } + type R1_118 = ( C { val y: P }) with ( C { val y: Q }) + type R2_118 = R1_118 { val y: (P) with (Q) } + type R1_119 = ( C { val y: P }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_119 = R1_119 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_120 = ( C { val y: Q }) with ( Any { val y: P }) + type R2_120 = R1_120 { val y: (Q) with (P) } + type R1_121 = ( C { val y: Q }) with ( Any { val y: Q }) + type R2_121 = R1_121 { val y: (Q) with (Q) } + type R1_122 = ( C { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_122 = R1_122 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_123 = ( C { val y: Q }) with ( A { val y: P }) + type R2_123 = R1_123 { val y: (Q) with (P) } + type R1_124 = ( C { val y: Q }) with ( A { val y: Q }) + type R2_124 = R1_124 { val y: (Q) with (Q) } + type R1_125 = ( C { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_125 = R1_125 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_126 = ( C { val y: Q }) with ( B { val y: P }) + type R2_126 = R1_126 { val y: (Q) with (P) } + type R1_127 = ( C { val y: Q }) with ( B { val y: Q }) + type R2_127 = R1_127 { val y: (Q) with (Q) } + type R1_128 = ( C { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_128 = R1_128 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_129 = ( C { val y: Q }) with ( C { val y: P }) + type R2_129 = R1_129 { val y: (Q) with (P) } + type R1_130 = ( C { val y: Q }) with ( C { val y: Q }) + type R2_130 = R1_130 { val y: (Q) with (Q) } + type R1_131 = ( C { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_131 = R1_131 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_132 = ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P }) + type R2_132 = R1_132 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_133 = ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q }) + type R2_133 = R1_133 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_134 = ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_134 = R1_134 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_135 = ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: P }) + type R2_135 = R1_135 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_136 = ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q }) + type R2_136 = R1_136 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_137 = ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_137 = R1_137 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_138 = ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: P }) + type R2_138 = R1_138 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_139 = ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q }) + type R2_139 = R1_139 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_140 = ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_140 = R1_140 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_141 = ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: P }) + type R2_141 = R1_141 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_142 = ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q }) + type R2_142 = R1_142 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_143 = ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_143 = R1_143 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + def f0 = { val x = ((new ABC): ( Any { val y: P }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f1 = { val x = ((new ABC): ( Any { val y: P }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f2 = { val x = ((new ABC): ( Any { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f3 = { val x = ((new ABC): ( Any { val y: P }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f4 = { val x = ((new ABC): ( Any { val y: P }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f5 = { val x = ((new ABC): ( Any { val y: P }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f6 = { val x = ((new ABC): ( Any { val y: P }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f7 = { val x = ((new ABC): ( Any { val y: P }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f8 = { val x = ((new ABC): ( Any { val y: P }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f9 = { val x = ((new ABC): ( Any { val y: P }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f10 = { val x = ((new ABC): ( Any { val y: P }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f11 = { val x = ((new ABC): ( Any { val y: P }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f12 = { val x = ((new ABC): ( Any { val y: Q }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f13 = { val x = ((new ABC): ( Any { val y: Q }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f14 = { val x = ((new ABC): ( Any { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f15 = { val x = ((new ABC): ( Any { val y: Q }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f16 = { val x = ((new ABC): ( Any { val y: Q }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f17 = { val x = ((new ABC): ( Any { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f18 = { val x = ((new ABC): ( Any { val y: Q }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f19 = { val x = ((new ABC): ( Any { val y: Q }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f20 = { val x = ((new ABC): ( Any { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f21 = { val x = ((new ABC): ( Any { val y: Q }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f22 = { val x = ((new ABC): ( Any { val y: Q }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f23 = { val x = ((new ABC): ( Any { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f24 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f25 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f26 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f27 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f28 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f29 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f30 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f31 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f32 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f33 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f34 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f35 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f36 = { val x = ((new ABC): ( A { val y: P }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f37 = { val x = ((new ABC): ( A { val y: P }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f38 = { val x = ((new ABC): ( A { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f39 = { val x = ((new ABC): ( A { val y: P }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f40 = { val x = ((new ABC): ( A { val y: P }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f41 = { val x = ((new ABC): ( A { val y: P }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f42 = { val x = ((new ABC): ( A { val y: P }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f43 = { val x = ((new ABC): ( A { val y: P }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f44 = { val x = ((new ABC): ( A { val y: P }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f45 = { val x = ((new ABC): ( A { val y: P }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f46 = { val x = ((new ABC): ( A { val y: P }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f47 = { val x = ((new ABC): ( A { val y: P }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f48 = { val x = ((new ABC): ( A { val y: Q }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f49 = { val x = ((new ABC): ( A { val y: Q }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f50 = { val x = ((new ABC): ( A { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f51 = { val x = ((new ABC): ( A { val y: Q }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f52 = { val x = ((new ABC): ( A { val y: Q }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f53 = { val x = ((new ABC): ( A { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f54 = { val x = ((new ABC): ( A { val y: Q }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f55 = { val x = ((new ABC): ( A { val y: Q }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f56 = { val x = ((new ABC): ( A { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f57 = { val x = ((new ABC): ( A { val y: Q }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f58 = { val x = ((new ABC): ( A { val y: Q }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f59 = { val x = ((new ABC): ( A { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f60 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f61 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f62 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f63 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f64 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f65 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f66 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f67 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f68 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f69 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f70 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f71 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f72 = { val x = ((new ABC): ( B { val y: P }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f73 = { val x = ((new ABC): ( B { val y: P }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f74 = { val x = ((new ABC): ( B { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f75 = { val x = ((new ABC): ( B { val y: P }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f76 = { val x = ((new ABC): ( B { val y: P }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f77 = { val x = ((new ABC): ( B { val y: P }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f78 = { val x = ((new ABC): ( B { val y: P }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f79 = { val x = ((new ABC): ( B { val y: P }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f80 = { val x = ((new ABC): ( B { val y: P }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f81 = { val x = ((new ABC): ( B { val y: P }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f82 = { val x = ((new ABC): ( B { val y: P }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f83 = { val x = ((new ABC): ( B { val y: P }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f84 = { val x = ((new ABC): ( B { val y: Q }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f85 = { val x = ((new ABC): ( B { val y: Q }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f86 = { val x = ((new ABC): ( B { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f87 = { val x = ((new ABC): ( B { val y: Q }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f88 = { val x = ((new ABC): ( B { val y: Q }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f89 = { val x = ((new ABC): ( B { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f90 = { val x = ((new ABC): ( B { val y: Q }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f91 = { val x = ((new ABC): ( B { val y: Q }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f92 = { val x = ((new ABC): ( B { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f93 = { val x = ((new ABC): ( B { val y: Q }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f94 = { val x = ((new ABC): ( B { val y: Q }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f95 = { val x = ((new ABC): ( B { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f96 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f97 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f98 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f99 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f100 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f101 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f102 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f103 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f104 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f105 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f106 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f107 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f108 = { val x = ((new ABC): ( C { val y: P }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f109 = { val x = ((new ABC): ( C { val y: P }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f110 = { val x = ((new ABC): ( C { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f111 = { val x = ((new ABC): ( C { val y: P }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f112 = { val x = ((new ABC): ( C { val y: P }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f113 = { val x = ((new ABC): ( C { val y: P }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f114 = { val x = ((new ABC): ( C { val y: P }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f115 = { val x = ((new ABC): ( C { val y: P }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f116 = { val x = ((new ABC): ( C { val y: P }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f117 = { val x = ((new ABC): ( C { val y: P }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f118 = { val x = ((new ABC): ( C { val y: P }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f119 = { val x = ((new ABC): ( C { val y: P }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f120 = { val x = ((new ABC): ( C { val y: Q }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f121 = { val x = ((new ABC): ( C { val y: Q }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f122 = { val x = ((new ABC): ( C { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f123 = { val x = ((new ABC): ( C { val y: Q }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f124 = { val x = ((new ABC): ( C { val y: Q }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f125 = { val x = ((new ABC): ( C { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f126 = { val x = ((new ABC): ( C { val y: Q }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f127 = { val x = ((new ABC): ( C { val y: Q }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f128 = { val x = ((new ABC): ( C { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f129 = { val x = ((new ABC): ( C { val y: Q }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f130 = { val x = ((new ABC): ( C { val y: Q }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f131 = { val x = ((new ABC): ( C { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f132 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f133 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f134 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f135 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f136 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f137 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f138 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f139 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f140 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f141 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f142 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f143 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def g0(x: R1_0) = x.y + def g1(x: R1_1) = x.y + def g2(x: R1_2) = x.y + def g3(x: R1_3) = x.y + def g4(x: R1_4) = x.y + def g5(x: R1_5) = x.y + def g6(x: R1_6) = x.y + def g7(x: R1_7) = x.y + def g8(x: R1_8) = x.y + def g9(x: R1_9) = x.y + def g10(x: R1_10) = x.y + def g11(x: R1_11) = x.y + def g12(x: R1_12) = x.y + def g13(x: R1_13) = x.y + def g14(x: R1_14) = x.y + def g15(x: R1_15) = x.y + def g16(x: R1_16) = x.y + def g17(x: R1_17) = x.y + def g18(x: R1_18) = x.y + def g19(x: R1_19) = x.y + def g20(x: R1_20) = x.y + def g21(x: R1_21) = x.y + def g22(x: R1_22) = x.y + def g23(x: R1_23) = x.y + def g24(x: R1_24) = x.y + def g25(x: R1_25) = x.y + def g26(x: R1_26) = x.y + def g27(x: R1_27) = x.y + def g28(x: R1_28) = x.y + def g29(x: R1_29) = x.y + def g30(x: R1_30) = x.y + def g31(x: R1_31) = x.y + def g32(x: R1_32) = x.y + def g33(x: R1_33) = x.y + def g34(x: R1_34) = x.y + def g35(x: R1_35) = x.y + def g36(x: R1_36) = x.y + def g37(x: R1_37) = x.y + def g38(x: R1_38) = x.y + def g39(x: R1_39) = x.y + def g40(x: R1_40) = x.y + def g41(x: R1_41) = x.y + def g42(x: R1_42) = x.y + def g43(x: R1_43) = x.y + def g44(x: R1_44) = x.y + def g45(x: R1_45) = x.y + def g46(x: R1_46) = x.y + def g47(x: R1_47) = x.y + def g48(x: R1_48) = x.y + def g49(x: R1_49) = x.y + def g50(x: R1_50) = x.y + def g51(x: R1_51) = x.y + def g52(x: R1_52) = x.y + def g53(x: R1_53) = x.y + def g54(x: R1_54) = x.y + def g55(x: R1_55) = x.y + def g56(x: R1_56) = x.y + def g57(x: R1_57) = x.y + def g58(x: R1_58) = x.y + def g59(x: R1_59) = x.y + def g60(x: R1_60) = x.y + def g61(x: R1_61) = x.y + def g62(x: R1_62) = x.y + def g63(x: R1_63) = x.y + def g64(x: R1_64) = x.y + def g65(x: R1_65) = x.y + def g66(x: R1_66) = x.y + def g67(x: R1_67) = x.y + def g68(x: R1_68) = x.y + def g69(x: R1_69) = x.y + def g70(x: R1_70) = x.y + def g71(x: R1_71) = x.y + def g72(x: R1_72) = x.y + def g73(x: R1_73) = x.y + def g74(x: R1_74) = x.y + def g75(x: R1_75) = x.y + def g76(x: R1_76) = x.y + def g77(x: R1_77) = x.y + def g78(x: R1_78) = x.y + def g79(x: R1_79) = x.y + def g80(x: R1_80) = x.y + def g81(x: R1_81) = x.y + def g82(x: R1_82) = x.y + def g83(x: R1_83) = x.y + def g84(x: R1_84) = x.y + def g85(x: R1_85) = x.y + def g86(x: R1_86) = x.y + def g87(x: R1_87) = x.y + def g88(x: R1_88) = x.y + def g89(x: R1_89) = x.y + def g90(x: R1_90) = x.y + def g91(x: R1_91) = x.y + def g92(x: R1_92) = x.y + def g93(x: R1_93) = x.y + def g94(x: R1_94) = x.y + def g95(x: R1_95) = x.y + def g96(x: R1_96) = x.y + def g97(x: R1_97) = x.y + def g98(x: R1_98) = x.y + def g99(x: R1_99) = x.y + def g100(x: R1_100) = x.y + def g101(x: R1_101) = x.y + def g102(x: R1_102) = x.y + def g103(x: R1_103) = x.y + def g104(x: R1_104) = x.y + def g105(x: R1_105) = x.y + def g106(x: R1_106) = x.y + def g107(x: R1_107) = x.y + def g108(x: R1_108) = x.y + def g109(x: R1_109) = x.y + def g110(x: R1_110) = x.y + def g111(x: R1_111) = x.y + def g112(x: R1_112) = x.y + def g113(x: R1_113) = x.y + def g114(x: R1_114) = x.y + def g115(x: R1_115) = x.y + def g116(x: R1_116) = x.y + def g117(x: R1_117) = x.y + def g118(x: R1_118) = x.y + def g119(x: R1_119) = x.y + def g120(x: R1_120) = x.y + def g121(x: R1_121) = x.y + def g122(x: R1_122) = x.y + def g123(x: R1_123) = x.y + def g124(x: R1_124) = x.y + def g125(x: R1_125) = x.y + def g126(x: R1_126) = x.y + def g127(x: R1_127) = x.y + def g128(x: R1_128) = x.y + def g129(x: R1_129) = x.y + def g130(x: R1_130) = x.y + def g131(x: R1_131) = x.y + def g132(x: R1_132) = x.y + def g133(x: R1_133) = x.y + def g134(x: R1_134) = x.y + def g135(x: R1_135) = x.y + def g136(x: R1_136) = x.y + def g137(x: R1_137) = x.y + def g138(x: R1_138) = x.y + def g139(x: R1_139) = x.y + def g140(x: R1_140) = x.y + def g141(x: R1_141) = x.y + def g142(x: R1_142) = x.y + def g143(x: R1_143) = x.y + def h0(x: R2_0) = x.y + def h1(x: R2_1) = x.y + def h2(x: R2_2) = x.y + def h3(x: R2_3) = x.y + def h4(x: R2_4) = x.y + def h5(x: R2_5) = x.y + def h6(x: R2_6) = x.y + def h7(x: R2_7) = x.y + def h8(x: R2_8) = x.y + def h9(x: R2_9) = x.y + def h10(x: R2_10) = x.y + def h11(x: R2_11) = x.y + def h12(x: R2_12) = x.y + def h13(x: R2_13) = x.y + def h14(x: R2_14) = x.y + def h15(x: R2_15) = x.y + def h16(x: R2_16) = x.y + def h17(x: R2_17) = x.y + def h18(x: R2_18) = x.y + def h19(x: R2_19) = x.y + def h20(x: R2_20) = x.y + def h21(x: R2_21) = x.y + def h22(x: R2_22) = x.y + def h23(x: R2_23) = x.y + def h24(x: R2_24) = x.y + def h25(x: R2_25) = x.y + def h26(x: R2_26) = x.y + def h27(x: R2_27) = x.y + def h28(x: R2_28) = x.y + def h29(x: R2_29) = x.y + def h30(x: R2_30) = x.y + def h31(x: R2_31) = x.y + def h32(x: R2_32) = x.y + def h33(x: R2_33) = x.y + def h34(x: R2_34) = x.y + def h35(x: R2_35) = x.y + def h36(x: R2_36) = x.y + def h37(x: R2_37) = x.y + def h38(x: R2_38) = x.y + def h39(x: R2_39) = x.y + def h40(x: R2_40) = x.y + def h41(x: R2_41) = x.y + def h42(x: R2_42) = x.y + def h43(x: R2_43) = x.y + def h44(x: R2_44) = x.y + def h45(x: R2_45) = x.y + def h46(x: R2_46) = x.y + def h47(x: R2_47) = x.y + def h48(x: R2_48) = x.y + def h49(x: R2_49) = x.y + def h50(x: R2_50) = x.y + def h51(x: R2_51) = x.y + def h52(x: R2_52) = x.y + def h53(x: R2_53) = x.y + def h54(x: R2_54) = x.y + def h55(x: R2_55) = x.y + def h56(x: R2_56) = x.y + def h57(x: R2_57) = x.y + def h58(x: R2_58) = x.y + def h59(x: R2_59) = x.y + def h60(x: R2_60) = x.y + def h61(x: R2_61) = x.y + def h62(x: R2_62) = x.y + def h63(x: R2_63) = x.y + def h64(x: R2_64) = x.y + def h65(x: R2_65) = x.y + def h66(x: R2_66) = x.y + def h67(x: R2_67) = x.y + def h68(x: R2_68) = x.y + def h69(x: R2_69) = x.y + def h70(x: R2_70) = x.y + def h71(x: R2_71) = x.y + def h72(x: R2_72) = x.y + def h73(x: R2_73) = x.y + def h74(x: R2_74) = x.y + def h75(x: R2_75) = x.y + def h76(x: R2_76) = x.y + def h77(x: R2_77) = x.y + def h78(x: R2_78) = x.y + def h79(x: R2_79) = x.y + def h80(x: R2_80) = x.y + def h81(x: R2_81) = x.y + def h82(x: R2_82) = x.y + def h83(x: R2_83) = x.y + def h84(x: R2_84) = x.y + def h85(x: R2_85) = x.y + def h86(x: R2_86) = x.y + def h87(x: R2_87) = x.y + def h88(x: R2_88) = x.y + def h89(x: R2_89) = x.y + def h90(x: R2_90) = x.y + def h91(x: R2_91) = x.y + def h92(x: R2_92) = x.y + def h93(x: R2_93) = x.y + def h94(x: R2_94) = x.y + def h95(x: R2_95) = x.y + def h96(x: R2_96) = x.y + def h97(x: R2_97) = x.y + def h98(x: R2_98) = x.y + def h99(x: R2_99) = x.y + def h100(x: R2_100) = x.y + def h101(x: R2_101) = x.y + def h102(x: R2_102) = x.y + def h103(x: R2_103) = x.y + def h104(x: R2_104) = x.y + def h105(x: R2_105) = x.y + def h106(x: R2_106) = x.y + def h107(x: R2_107) = x.y + def h108(x: R2_108) = x.y + def h109(x: R2_109) = x.y + def h110(x: R2_110) = x.y + def h111(x: R2_111) = x.y + def h112(x: R2_112) = x.y + def h113(x: R2_113) = x.y + def h114(x: R2_114) = x.y + def h115(x: R2_115) = x.y + def h116(x: R2_116) = x.y + def h117(x: R2_117) = x.y + def h118(x: R2_118) = x.y + def h119(x: R2_119) = x.y + def h120(x: R2_120) = x.y + def h121(x: R2_121) = x.y + def h122(x: R2_122) = x.y + def h123(x: R2_123) = x.y + def h124(x: R2_124) = x.y + def h125(x: R2_125) = x.y + def h126(x: R2_126) = x.y + def h127(x: R2_127) = x.y + def h128(x: R2_128) = x.y + def h129(x: R2_129) = x.y + def h130(x: R2_130) = x.y + def h131(x: R2_131) = x.y + def h132(x: R2_132) = x.y + def h133(x: R2_133) = x.y + def h134(x: R2_134) = x.y + def h135(x: R2_135) = x.y + def h136(x: R2_136) = x.y + def h137(x: R2_137) = x.y + def h138(x: R2_138) = x.y + def h139(x: R2_139) = x.y + def h140(x: R2_140) = x.y + def h141(x: R2_141) = x.y + def h142(x: R2_142) = x.y + def h143(x: R2_143) = x.y + lazy val fcalls = List( + f0, + f1, + f2, + f3, + f4, + f5, + f6, + f7, + f8, + f9, + f10, + f11, + f12, + f13, + f14, + f15, + f16, + f17, + f18, + f19, + f20, + f21, + f22, + f23, + f24, + f25, + f26, + f27, + f28, + f29, + f30, + f31, + f32, + f33, + f34, + f35, + f36, + f37, + f38, + f39, + f40, + f41, + f42, + f43, + f44, + f45, + f46, + f47, + f48, + f49, + f50, + f51, + f52, + f53, + f54, + f55, + f56, + f57, + f58, + f59, + f60, + f61, + f62, + f63, + f64, + f65, + f66, + f67, + f68, + f69, + f70, + f71, + f72, + f73, + f74, + f75, + f76, + f77, + f78, + f79, + f80, + f81, + f82, + f83, + f84, + f85, + f86, + f87, + f88, + f89, + f90, + f91, + f92, + f93, + f94, + f95, + f96, + f97, + f98, + f99, + f100, + f101, + f102, + f103, + f104, + f105, + f106, + f107, + f108, + f109, + f110, + f111, + f112, + f113, + f114, + f115, + f116, + f117, + f118, + f119, + f120, + f121, + f122, + f123, + f124, + f125, + f126, + f127, + f128, + f129, + f130, + f131, + f132, + f133, + f134, + f135, + f136, + f137, + f138, + f139, + f140, + f141, + f142, + f143 + ) + + def main(args: Array[String]) { + sshow("Direct Calls", fcalls collect { case (false, n) => n }) + sshow("Reflective Calls", fcalls collect { case (true, n) => n }) + // For a good time try printing this - have to fix bugs in + // reflection before that's going to be a good idea + // println(typeOf[Test.type].typeSymbol.asClass.typeSignature) + } +} diff --git a/test/files/run/t3488.check b/test/files/run/t3488.check index 0d66ea1aee..314dfc7838 100644 --- a/test/files/run/t3488.check +++ b/test/files/run/t3488.check @@ -1,2 +1,8 @@ +t3488.scala:4: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + println(foo { val List(_*)=List(0); 1 } ()) + ^ +t3488.scala:5: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + println(foo { val List(_*)=List(0); 1 } (1)) + ^ 0 1 diff --git a/test/files/run/t3507-new.scala b/test/files/run/t3507-new.scala index f045755b8f..bd16849e8a 100644 --- a/test/files/run/t3507-new.scala +++ b/test/files/run/t3507-new.scala @@ -1,3 +1,5 @@ + +import scala.language.{ existentials } import scala.reflect.runtime.universe._ class A { @@ -14,4 +16,4 @@ object Test extends App { def mani[T: TypeTag](x: T) = println(typeOf[T]) mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier // --> _1 is not in scope here -}
\ No newline at end of file +} diff --git a/test/files/run/t3529.scala b/test/files/run/t3529.scala index bb82424bf6..a5977d0a6c 100644 --- a/test/files/run/t3529.scala +++ b/test/files/run/t3529.scala @@ -1,3 +1,4 @@ +import scala.language.postfixOps object Test { def main(args: Array[String]): Unit = { assert(1 to 10 drop 10 isEmpty) diff --git a/test/files/run/t3651.scala b/test/files/run/t3651.scala index 49ae173249..3a6dda0de3 100644 --- a/test/files/run/t3651.scala +++ b/test/files/run/t3651.scala @@ -5,6 +5,6 @@ class LongKlass( override val a: Long ) extends Klass[Long](a) object Test { def main(args: Array[String]) { val lk = new LongKlass(10) - lk.a + val a = lk.a } } diff --git a/test/files/run/t3667.check b/test/files/run/t3667.check index bbe5d1bc48..6375c88997 100644 --- a/test/files/run/t3667.check +++ b/test/files/run/t3667.check @@ -1,6 +1,3 @@ -1 -2 -3 4 2 3 diff --git a/test/files/run/t3667.scala b/test/files/run/t3667.scala index f30d57ce3a..ada09d5886 100644 --- a/test/files/run/t3667.scala +++ b/test/files/run/t3667.scala @@ -1,27 +1,9 @@ object Test { def main(args: Array[String]) { - val o1 = new Outer1 - val o2 = new Outer2 - val o3 = new Outer3 val o4 = new Outer4 val o5 = new Outer5 val o6 = new Outer6 - println(1) - ser(new o1.Inner(1)) - o1.Inner // make sure the Inner$module field of the Outer1 instance is initialized! - ser(new o1.Inner(1)) - - println(2) - ser(new o2.Inner(1)) - o2.Inner - ser(new o2.Inner(1)) - - println(3) - ser(new o3.Inner(1)) - o3.Inner - ser(new o3.Inner(1)) - println(4) ser(new o4.Inner(1)) o4.Inner @@ -54,23 +36,6 @@ object Test { } -@serializable -class Outer1 { - @serializable - class Inner(x: Int = 1) -} - -@serializable -class Outer2 { - case class Inner(x: Int = 1) -} - -@serializable -class Outer3 { - case class Inner(x: Int) -} - - class Outer4 extends Serializable { class Inner(x: Int = 1) extends Serializable } diff --git a/test/files/run/t3705.scala b/test/files/run/t3705.scala index fcc020f28c..3ebf6fc95d 100644 --- a/test/files/run/t3705.scala +++ b/test/files/run/t3705.scala @@ -2,16 +2,16 @@ import scala.xml._ object Test { + // guard caused verifyerror in oldpatmat def updateNodes(ns: Seq[Node]): Seq[Node] = for(subnode <- ns) yield subnode match { case <d>{_}</d> if true => <d>abc</d> case Elem(prefix, label, attribs, scope, children @ _*) => - Elem(prefix, label, attribs, scope, updateNodes(children) : _*) + Elem(prefix, label, attribs, scope, minimizeEmpty = true, updateNodes(children) : _*) case other => other } def main(args: Array[String]): Unit = { updateNodes(<b />) - } } diff --git a/test/files/run/t3758-old.scala b/test/files/run/t3758-old.scala index f00254afee..d5e4a6cc1c 100644 --- a/test/files/run/t3758-old.scala +++ b/test/files/run/t3758-old.scala @@ -1,3 +1,5 @@ + +@deprecated("Suppress warnings", since="2.11") object Test { def main(args: Array[String]): Unit = { assert(classManifest[Array[String]].typeArguments contains classManifest[String]) @@ -7,4 +9,4 @@ object Test { assert(manifest[Array[Int]].typeArguments contains manifest[Int]) assert(manifest[Array[Float]].typeArguments contains manifest[Float]) } -}
\ No newline at end of file +} diff --git a/test/files/run/t3835.scala b/test/files/run/t3835.scala index c120a61f6e..766b6ddc2e 100644 --- a/test/files/run/t3835.scala +++ b/test/files/run/t3835.scala @@ -1,6 +1,6 @@ object Test extends App { // work around optimizer bug SI-5672 -- generates wrong bytecode for switches in arguments - // virtpatmat happily emits a switch for a one-case switch, whereas -Xoldpatmat did not + // virtpatmat happily emits a switch for a one-case switch // this is not the focus of this test, hence the temporary workaround def a = (1, 2, 3) match { case (r, \u03b8, \u03c6) => r + \u03b8 + \u03c6 } println(a) diff --git a/test/files/run/t3855.scala b/test/files/run/t3855.scala index e55714201f..d8029e16f0 100644 --- a/test/files/run/t3855.scala +++ b/test/files/run/t3855.scala @@ -3,11 +3,11 @@ object Test { def closure[A](f: () => A) = f() def f1(s: String) = { - var n = try { s.toInt } catch { case _ => 1 } + var n = try { s.toInt } catch { case _: Throwable => 1 } byval(n) } def f2(s: String) = { - var n = try { s.toInt } catch { case _ => 1 } + var n = try { s.toInt } catch { case _: Throwable => 1 } closure(() => n) } diff --git a/test/files/run/t3888.check b/test/files/run/t3888.check new file mode 100644 index 0000000000..844ca54682 --- /dev/null +++ b/test/files/run/t3888.check @@ -0,0 +1 @@ +warning: there were 1 deprecation warning(s); re-run with -deprecation for details diff --git a/test/files/run/t3888.scala b/test/files/run/t3888.scala index e0f1453b1d..1914072599 100644 --- a/test/files/run/t3888.scala +++ b/test/files/run/t3888.scala @@ -1,3 +1,6 @@ + +// in a match, which notion of equals prevails? +// extending Tuple doesn't seem to be at issue here. object Test { val T1 = new P @@ -23,4 +26,4 @@ object Test { class P extends Pair(1, 1) { override def equals(x: Any) = true -}
\ No newline at end of file +} diff --git a/test/files/run/t3897.check b/test/files/run/t3897.check new file mode 100644 index 0000000000..244b83716f --- /dev/null +++ b/test/files/run/t3897.check @@ -0,0 +1,8 @@ +(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) +(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) +(messages,scala.collection.mutable.MutableList<java.lang.String>) +(messages,scala.collection.mutable.MutableList<java.lang.String>) +(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) +(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) +(messages,scala.collection.mutable.MutableList<java.lang.String>) +(messages,scala.collection.mutable.MutableList<java.lang.String>) diff --git a/test/files/run/t3897/J_2.java b/test/files/run/t3897/J_2.java new file mode 100644 index 0000000000..178412dc92 --- /dev/null +++ b/test/files/run/t3897/J_2.java @@ -0,0 +1,27 @@ +import java.lang.reflect.*; + +public class J_2 { + public void f1(Class<?> clazz) { + Field[] fields = clazz.getDeclaredFields(); + for (int i = 0 ; i < fields.length; i++) { + String name = fields[i].getName(); + if (name.length() >= 7 && name.substring(0, 7).equals("bitmap$")) { } + else System.out.println("(" + name + "," + fields[i].getGenericType() + ")"); + } + } + public void f2(Class<?> clazz) { + Method[] methods = clazz.getDeclaredMethods(); + for (int i = 0 ; i < methods.length; i++) { + String name = methods[i].getName(); + if (name.length() >= 7 && name.substring(0, 7).equals("bitmap$")) { } + else System.out.println("(" + name + "," + methods[i].getGenericReturnType() + ")"); + } + } + + public void javaRun() { + f1(One.class); + f2(One.class); + f1(Two.class); + f2(Two.class); + } +}
\ No newline at end of file diff --git a/test/files/run/t3897/a_1.scala b/test/files/run/t3897/a_1.scala new file mode 100644 index 0000000000..4da959e2ac --- /dev/null +++ b/test/files/run/t3897/a_1.scala @@ -0,0 +1,8 @@ +class One { + private val messages = new collection.mutable.MutableList[String] + List("a") foreach { messages += _ } +} + +class Two { + private val messages = new collection.mutable.MutableList[String] +} diff --git a/test/files/run/t3897/a_2.scala b/test/files/run/t3897/a_2.scala new file mode 100644 index 0000000000..4d9e59ef05 --- /dev/null +++ b/test/files/run/t3897/a_2.scala @@ -0,0 +1,23 @@ +object Test { + def f1(clazz: Class[_]) = ( + clazz.getDeclaredFields.toList + . filterNot (_.getName contains "bitmap$") + . map (f => (f.getName, f.getGenericType)) + . foreach (println) + ) + def f2(clazz: Class[_]) = ( + clazz.getDeclaredMethods.toList + . filterNot (_.getName contains "bitmap$") + . map (f => (f.getName, f.getGenericReturnType)) + . foreach (println) + ) + + def main(args: Array[String]): Unit = { + f1(classOf[One]) + f2(classOf[One]) + f1(classOf[Two]) + f2(classOf[Two]) + + new J_2().javaRun + } +} diff --git a/test/files/run/t3935.scala b/test/files/run/t3935.scala index c66b1b0599..fa1bbf8d3f 100644 --- a/test/files/run/t3935.scala +++ b/test/files/run/t3935.scala @@ -9,7 +9,7 @@ object Test { try { assert(q.front != null) } catch { - case _ => + case _: Throwable => } } } diff --git a/test/files/run/t3964.scala b/test/files/run/t3964.scala index 80ba361a20..68ff9a44c4 100644 --- a/test/files/run/t3964.scala +++ b/test/files/run/t3964.scala @@ -1,3 +1,6 @@ + +import scala.language.implicitConversions + object Test { class Base object Bob extends Base diff --git a/test/files/run/t4023.check b/test/files/run/t4023.check new file mode 100644 index 0000000000..05f867c397 --- /dev/null +++ b/test/files/run/t4023.check @@ -0,0 +1,21 @@ +Try 1: (6 classes) +class Test$C$B1 +class Test$C$B2 +class Test$C$B3$ +class Test$C$B4$ +class Test$C$B5$ +class Test$C$B6$ +Try 2: (6 classes) +class Test$C$B1 +class Test$C$B2 +class Test$C$B3$ +class Test$C$B4$ +class Test$C$B5$ +class Test$C$B6$ +Try 3: (6 classes) +class Test$C$B1 +class Test$C$B2 +class Test$C$B3$ +class Test$C$B4$ +class Test$C$B5$ +class Test$C$B6$ diff --git a/test/files/run/t4023.scala b/test/files/run/t4023.scala new file mode 100644 index 0000000000..38190cfa5c --- /dev/null +++ b/test/files/run/t4023.scala @@ -0,0 +1,34 @@ +object Test { + object C { + class B1 + private class B2 + object B3 + private object B4 + object B5 extends B1 + private object B6 extends B2 + + val classes1 = this.getClass.getDeclaredClasses + val classes2 = C.getClass .getDeclaredClasses + val classes3 = getClass .getDeclaredClasses + } + + // sortBy(_.getName) introduces additional classes which we don't want to see in C, + // so we call sortBy outside of C. + object TestHelper { + val valuesTry1 = C.classes1.sortBy(_.getName) + val valuesTry2 = C.classes2.sortBy(_.getName) + val valuesTry3 = C.classes3.sortBy(_.getName) + } + + def main(args: Array[String]) { + println("Try 1: (" + TestHelper.valuesTry1.length + " classes)") + TestHelper.valuesTry1.foreach(println) + println("Try 2: (" + TestHelper.valuesTry2.length + " classes)") + TestHelper.valuesTry2.foreach(println) + println("Try 3: (" + TestHelper.valuesTry3.length + " classes)") + TestHelper.valuesTry3.foreach(println) + } + + +} + diff --git a/test/files/run/t4047.check b/test/files/run/t4047.check index 2a942a70e0..3c41e6e244 100644 --- a/test/files/run/t4047.check +++ b/test/files/run/t4047.check @@ -1,3 +1,15 @@ +t4047.scala:23: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + a.foo + ^ +t4047.scala:24: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + a.foo + ^ +t4047.scala:26: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + b.foo + ^ +t4047.scala:27: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + b.foo + ^ Unit: called A.foo Unit: called B.foo Unit: called C.foo diff --git a/test/files/run/t4047.scala b/test/files/run/t4047.scala index cd42a8b4df..08989bd278 100644 --- a/test/files/run/t4047.scala +++ b/test/files/run/t4047.scala @@ -18,7 +18,7 @@ class D extends Bar[Unit]{ def foo = println("Unit: called D.foo") } -object Test extends Application { +object Test extends App { val a: Foo[Unit] = new A a.foo a.foo diff --git a/test/files/run/t4072.scala b/test/files/run/t4072.scala index 872072a4ce..bff2e0c7d2 100644 --- a/test/files/run/t4072.scala +++ b/test/files/run/t4072.scala @@ -1,5 +1,7 @@ import scala.tools.nsc._ +import scala.language.{ reflectiveCalls } + object Test { class DryRun { val compiler = new Global(new Settings()) { diff --git a/test/files/run/t4080.scala b/test/files/run/t4080.scala index 92740ed776..1d1418847d 100644 --- a/test/files/run/t4080.scala +++ b/test/files/run/t4080.scala @@ -1,4 +1,5 @@ import scala.collection.mutable.LinkedList +import java.util.NoSuchElementException object Test { def main(args: Array[String]) { @@ -6,7 +7,7 @@ object Test { ll.insert(LinkedList(0)) println(ll) val ll2 = LinkedList[Int]() - try println(ll2.head) - catch { case _ => () } + try println("Empty head? " + ll2.head) + catch { case _: NoSuchElementException => () } } } diff --git a/test/files/run/t4146.scala b/test/files/run/t4146.scala deleted file mode 100644 index 93ce22b519..0000000000 --- a/test/files/run/t4146.scala +++ /dev/null @@ -1,7 +0,0 @@ -object bob extends Application { - var name = "Bob" -} - -object Test extends App { - assert(bob.name == "Bob") -} diff --git a/test/files/run/t4148.scala b/test/files/run/t4148.scala index 0739403594..6de0c8fe7a 100644 --- a/test/files/run/t4148.scala +++ b/test/files/run/t4148.scala @@ -1,7 +1,7 @@ object Test { - val x1 = try { "aaa".asInstanceOf[Int] } catch { case _ => "cce1" } - val x2 = try { (5: Any).asInstanceOf[Int] } catch { case _ => "cce2" } - val x3 = try { (new java.lang.Short(100.toShort).asInstanceOf[Int]) } catch { case _ => "cce3" } + val x1 = try { "aaa".asInstanceOf[Int] } catch { case _: Throwable => "cce1" } + val x2 = try { (5: Any).asInstanceOf[Int] } catch { case _: Throwable => "cce2" } + val x3 = try { (new java.lang.Short(100.toShort).asInstanceOf[Int]) } catch { case _: Throwable => "cce3" } def main(args: Array[String]): Unit = { List(x1, x2, x3) foreach println diff --git a/test/files/run/t4171.scala b/test/files/run/t4171.scala index fba2fb5ed6..7f6dfd48ce 100644 --- a/test/files/run/t4171.scala +++ b/test/files/run/t4171.scala @@ -1,3 +1,6 @@ + +import scala.language.{ reflectiveCalls } + object Test { val c = { class C; new C { def foo = 1 } } val a = { class B { def bar = 5 }; class C extends B; new C } diff --git a/test/files/run/t4294.scala b/test/files/run/t4294.scala index fafaf1d8ef..e15c716047 100644 --- a/test/files/run/t4294.scala +++ b/test/files/run/t4294.scala @@ -1,7 +1,12 @@ object Test { def main(args: Array[String]) { + // Skip test on Avian, see SI-7600 for further information + if (!scala.tools.partest.utils.Properties.isAvian) + run() + } + + def run(): Unit = { (Stream.from(1).collect{case x if x > 5000000 => x}: Stream[Int]) - assert((Stream from 1 take 10 collect { case x if x <= 3 => x*x }).sum == 14) } } diff --git a/test/files/run/t4351.check b/test/files/run/t4351.check new file mode 100644 index 0000000000..cb5d407e13 --- /dev/null +++ b/test/files/run/t4351.check @@ -0,0 +1 @@ +runtime exception diff --git a/test/files/run/t4351.scala b/test/files/run/t4351.scala new file mode 100644 index 0000000000..d954d748b7 --- /dev/null +++ b/test/files/run/t4351.scala @@ -0,0 +1,21 @@ +object Test { + def main(args: Array[String]): Unit = { + try new BooleanPropImpl().value + catch { + // was: StackOverflowError + case e: RuntimeException => println("runtime exception") + } + } +} + +trait Prop[@specialized(Boolean) +T] { + def value: T +} + +class PropImpl[+T] extends Prop[T] { + def value: T = scala.sys.error("") +} + +trait BooleanProp extends Prop[Boolean] + +class BooleanPropImpl() extends PropImpl[Boolean] with BooleanProp diff --git a/test/files/run/t4398.scala b/test/files/run/t4398.scala index 1d57eb688d..87dc870afc 100644 --- a/test/files/run/t4398.scala +++ b/test/files/run/t4398.scala @@ -1,5 +1,7 @@ +import scala.language.{ postfixOps } + object Test { def main(args: Array[String]) { val x = 1 to 10 toSet diff --git a/test/files/run/t4415.scala b/test/files/run/t4415.scala index f96031d650..caf1609b9e 100644 --- a/test/files/run/t4415.scala +++ b/test/files/run/t4415.scala @@ -39,7 +39,7 @@ class SecondProperty extends TopProperty class SubclassSecondProperty extends StandardProperty trait MyProp[T] -case class MyPropImpl[T] extends MyProp[T] +case class MyPropImpl[T]() extends MyProp[T] object SubclassMatch { diff --git a/test/files/run/t4537.check b/test/files/run/t4537.check new file mode 100644 index 0000000000..63739ca64a --- /dev/null +++ b/test/files/run/t4537.check @@ -0,0 +1 @@ +b.Settings diff --git a/test/files/run/t4537/a.scala b/test/files/run/t4537/a.scala new file mode 100644 index 0000000000..125e223e13 --- /dev/null +++ b/test/files/run/t4537/a.scala @@ -0,0 +1,5 @@ +package a + +private[a] object Settings { + val X = "a.Settings" +} diff --git a/test/files/run/t4537/b.scala b/test/files/run/t4537/b.scala new file mode 100644 index 0000000000..c709d49b04 --- /dev/null +++ b/test/files/run/t4537/b.scala @@ -0,0 +1,5 @@ +package b + +object Settings { + val Y = "b.Settings" +} diff --git a/test/files/run/t4537/c.scala b/test/files/run/t4537/c.scala new file mode 100644 index 0000000000..ee05d4bbfb --- /dev/null +++ b/test/files/run/t4537/c.scala @@ -0,0 +1,8 @@ +package b +package c + +import a._ + +object Unambiguous { + println(Settings.Y) +} diff --git a/test/files/run/t4537/d.scala b/test/files/run/t4537/d.scala new file mode 100644 index 0000000000..dd1d2045ed --- /dev/null +++ b/test/files/run/t4537/d.scala @@ -0,0 +1,6 @@ +import a._ +import b._ + +object Test extends App { + println(Settings.Y) +} diff --git a/test/files/run/t4560.scala b/test/files/run/t4560.scala index 9979199067..ee657e47eb 100644 --- a/test/files/run/t4560.scala +++ b/test/files/run/t4560.scala @@ -7,6 +7,9 @@ // TEST 1 // self-type is other trait + +import scala.language.{ reflectiveCalls } + trait Aa trait Ab diff --git a/test/files/run/t4594-repl-settings.scala b/test/files/run/t4594-repl-settings.scala new file mode 100644 index 0000000000..d2335460e5 --- /dev/null +++ b/test/files/run/t4594-repl-settings.scala @@ -0,0 +1,26 @@ + +import scala.tools.partest.SessionTest + +// Detected repl transcript paste: ctrl-D to finish. +object Test extends SessionTest { + def session = +""" |Type in expressions to have them evaluated. + |Type :help for more information. + | + |scala> @deprecated(message="Please don't do that.", since="Time began.") def depp = "john" + |depp: String + | + |scala> def a = depp + |warning: there were 1 deprecation warning(s); re-run with -deprecation for details + |a: String + | + |scala> :settings +deprecation + | + |scala> def b = depp + |<console>:8: warning: method depp is deprecated: Please don't do that. + | def b = depp + | ^ + |b: String + | + |scala> """ +} diff --git a/test/files/run/t4660.scala b/test/files/run/t4660.scala index e57bb4bf25..9aac10ddfd 100644 --- a/test/files/run/t4660.scala +++ b/test/files/run/t4660.scala @@ -3,7 +3,7 @@ object Test { val traversable = 1 to 20 map (_.toString) def normalize(m: Map[Char, Traversable[String]]) = m.map { case (k,v) => (k, v.toList) } - val groupedFromView = (traversable view).groupBy(_(0)) + val groupedFromView = traversable.view.groupBy(_(0)) val groupedFromStrict = traversable.groupBy(_(0)) assert(normalize(groupedFromView) == normalize(groupedFromStrict)) diff --git a/test/files/run/t4671.check b/test/files/run/t4671.check index 4699818cd4..d4f8af480a 100644 --- a/test/files/run/t4671.check +++ b/test/files/run/t4671.check @@ -2,7 +2,7 @@ Type in expressions to have them evaluated. Type :help for more information. scala> object o { val file = sys.props("partest.cwd") + "/t4671.scala" } -defined module o +defined object o scala> val s = scala.io.Source.fromFile(o.file) s: scala.io.BufferedSource = non-empty iterator diff --git a/test/files/run/t4680.check b/test/files/run/t4680.check index b5cfc651f2..b2e5209dc5 100644 --- a/test/files/run/t4680.check +++ b/test/files/run/t4680.check @@ -1,3 +1,9 @@ +t4680.scala:51: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + new C { 5 } + ^ +t4680.scala:69: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + new { val x = 5 } with E() { 5 } + ^ // new C { } diff --git a/test/files/run/t4729/S_2.scala b/test/files/run/t4729/S_2.scala index e34e3d34d4..f823433ded 100644 --- a/test/files/run/t4729/S_2.scala +++ b/test/files/run/t4729/S_2.scala @@ -1,3 +1,4 @@ +import scala.language.reflectiveCalls // Scala class: class ScalaVarArgs extends J_1 { // -- no problem on overriding it using ordinary class @@ -20,7 +21,7 @@ object Test { (new ScalaVarArgs).method("1", "2") (new ScalaVarArgs: J_1).method("1", "2") - //[4] Not Ok -- error when assigning anonymous class to a explictly typed val + //[4] Not Ok -- error when assigning anonymous class to an explictly typed val // Compiler error: object creation impossible, since method method in trait VarArgs of type (s: <repeated...>[java.lang.String])Unit is not defined val tagged: J_1 = new J_1 { def method(s: String*) { println(s) } diff --git a/test/files/run/t4766.scala b/test/files/run/t4766.scala index c2a864ddb2..d67431f50e 100644 --- a/test/files/run/t4766.scala +++ b/test/files/run/t4766.scala @@ -1,3 +1,7 @@ + +import scala.language.postfixOps +import scala.language.reflectiveCalls + object Test extends App { val x = new { def > = 1 diff --git a/test/files/run/t4777.scala b/test/files/run/t4777.scala index 4a811d3b9a..6c7b856e39 100644 --- a/test/files/run/t4777.scala +++ b/test/files/run/t4777.scala @@ -3,6 +3,6 @@ class DefaultsTest(x: Int = 25) extends A(28) object DefaultsTest extends DefaultsTest(12) object Test extends App { - println(new DefaultsTest() a) - println(DefaultsTest a) + println(new DefaultsTest().a) + println(DefaultsTest.a) } diff --git a/test/files/run/t4794.scala b/test/files/run/t4794.scala index afe89fa429..720906f507 100644 --- a/test/files/run/t4794.scala +++ b/test/files/run/t4794.scala @@ -7,6 +7,7 @@ class Arr[@specialized A](val arr: Array[A]) { object Test { def main(args: Array[String]): Unit = { - println(classOf[Arr[_]].getMethods filter (_.getName contains "quux") size) // expect 10, not 1 + def quuxae = classOf[Arr[_]].getMethods filter (_.getName contains "quux") + println(quuxae.size) // expect 10, not 1 } } diff --git a/test/files/run/t4859.check b/test/files/run/t4859.check new file mode 100644 index 0000000000..d329744ca0 --- /dev/null +++ b/test/files/run/t4859.check @@ -0,0 +1,8 @@ +Inner +Inner.i +About to reference Inner.i +Outer +Inner.i +About to reference O.N +About to reference O.N +About to reference O.N.apply() diff --git a/test/files/run/t4859.scala b/test/files/run/t4859.scala new file mode 100644 index 0000000000..3c20cea983 --- /dev/null +++ b/test/files/run/t4859.scala @@ -0,0 +1,29 @@ +object O { + case class N() + object P +} + +object Outer { + println("Outer") + object Inner { + println("Inner") + def i { + println("Inner.i") + } + } +} + +object Test { + def main(args: Array[String]) { + Outer.Inner.i // we still don't initialize Outer here (but should we?) + + {println("About to reference Inner.i"); Outer}.Inner.i // Outer will be initialized. + + {println("About to reference O.N" ); O}.N + + {println("About to reference O.N" ); O}.N + + {println("About to reference O.N.apply()"); O}.N.apply() + } +} + diff --git a/test/files/run/t4929.scala b/test/files/run/t4929.scala index 3208cd1b09..1b0e8672d5 100644 --- a/test/files/run/t4929.scala +++ b/test/files/run/t4929.scala @@ -2,6 +2,7 @@ import scala.util.parsing.json._ import java.util.concurrent._ import collection.JavaConversions._ +@deprecated("Suppress warnings", since="2.11") object Test extends App { val LIMIT = 2000 diff --git a/test/files/run/t4935.flags b/test/files/run/t4935.flags index ac14fe5dbd..49d036a887 100644 --- a/test/files/run/t4935.flags +++ b/test/files/run/t4935.flags @@ -1 +1 @@ --optimize
+-optimize diff --git a/test/files/run/t498.scala b/test/files/run/t498.scala index b4ede951f0..5c10e6630f 100644 --- a/test/files/run/t498.scala +++ b/test/files/run/t498.scala @@ -1,3 +1,6 @@ + +import scala.language.postfixOps + object Test extends App { // the function passed to flatMap produces lots of empty streams, but this should not overflow the stack val res = Stream.from(1).flatMap(i => if (i < 3000) Stream.empty else List(1)) diff --git a/test/files/run/t4996.check b/test/files/run/t4996.check new file mode 100644 index 0000000000..8d45b413c9 --- /dev/null +++ b/test/files/run/t4996.check @@ -0,0 +1,4 @@ +B.foo +M.foo +B.foo +M.foo
\ No newline at end of file diff --git a/test/files/run/t4996.scala b/test/files/run/t4996.scala new file mode 100644 index 0000000000..8e7636aaac --- /dev/null +++ b/test/files/run/t4996.scala @@ -0,0 +1,47 @@ + + + + + + +trait A[@specialized(Int) T] { + def foo(t: T) +} + + +trait B extends A[Int] { + def foo(t: Int) { + println("B.foo") + } +} + + +trait M extends B { + abstract override def foo(t: Int) { + super.foo(t) + println("M.foo") + } +} + + +object C extends B with M + + +object D extends B { + override def foo(t: Int) { + super.foo(t) + println("M.foo") + } +} + + +object Test { + + def main(args: Array[String]) { + D.foo(42) // OK, prints B.foo M.foo + C.foo(42) // was StackOverflowError + } + +} + + diff --git a/test/files/run/t5053.scala b/test/files/run/t5053.scala index e46dad5ac6..233edf6780 100644 --- a/test/files/run/t5053.scala +++ b/test/files/run/t5053.scala @@ -1,3 +1,6 @@ + +import scala.language.{ existentials } + object Test extends App { { val (left, right) = Seq((1, "a"), (1, "a"), (1, "a"), (3, "c")).view.unzip diff --git a/test/files/run/t5064.check b/test/files/run/t5064.check index 077006abd9..61ccfd16e7 100644 --- a/test/files/run/t5064.check +++ b/test/files/run/t5064.check @@ -1,6 +1,6 @@ -[12] T5064.super.<init>() -[12] T5064.super.<init> -[12] this +[53] T5064.super.<init>() +[53] T5064.super.<init> +[53] this [16:23] immutable.this.List.apply(scala.this.Predef.wrapIntArray(Array[Int]{1})) [16:20] immutable.this.List.apply <16:20> immutable.this.List diff --git a/test/files/run/t5080.scala b/test/files/run/t5080.scala index ce72d13a54..acb6167f46 100644 --- a/test/files/run/t5080.scala +++ b/test/files/run/t5080.scala @@ -1,3 +1,7 @@ + +import scala.language.implicitConversions +import scala.language.reflectiveCalls + object Test extends App { abstract class Value { diff --git a/test/files/run/t5224.check b/test/files/run/t5224.check index e15c1c90eb..b11480acdf 100644 --- a/test/files/run/t5224.check +++ b/test/files/run/t5224.check @@ -1,3 +1,8 @@ +t5224.scala:3: warning: Implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class Foo(bar: String) extends annotation.ClassfileAnnotation + ^ { @new Foo(bar = "qwe") class C extends AnyRef { def <init>() = { diff --git a/test/files/run/t5225_2.check b/test/files/run/t5225_2.check index 5faa365bce..477ea4eb6d 100644 --- a/test/files/run/t5225_2.check +++ b/test/files/run/t5225_2.check @@ -1,4 +1,4 @@ { - def foo(@new `package`.cloneable() x: Int) = ""; + def foo(@new elidable(0) x: Int) = ""; () } diff --git a/test/files/run/t5225_2.scala b/test/files/run/t5225_2.scala index d1b607499c..cf0f23a5c8 100644 --- a/test/files/run/t5225_2.scala +++ b/test/files/run/t5225_2.scala @@ -1,6 +1,6 @@ import scala.reflect.runtime.universe._ object Test extends App { - val tree = reify{def foo(@cloneable x: Int) = ""}.tree + val tree = reify{def foo(@annotation.elidable(0) x: Int) = ""}.tree println(tree.toString) }
\ No newline at end of file diff --git a/test/files/run/t5277_1.scala b/test/files/run/t5277_1.scala index a2d546579d..65232967c2 100644 --- a/test/files/run/t5277_1.scala +++ b/test/files/run/t5277_1.scala @@ -1,6 +1,7 @@ import scala.reflect.runtime.universe._ import scala.tools.reflect.Eval +import scala.language.{ implicitConversions, postfixOps } object Test extends App { reify { def fact(n: Int): BigInt = @@ -12,4 +13,4 @@ object Test extends App { println("10! = " + (10!)) }.eval -}
\ No newline at end of file +} diff --git a/test/files/run/t5284b.check b/test/files/run/t5284b.check index 98d9bcb75a..71426ad0b7 100644 --- a/test/files/run/t5284b.check +++ b/test/files/run/t5284b.check @@ -1 +1,4 @@ +t5284b.scala:27: warning: type S is unused or used in non-specializable positions. + def bar[@specialized(Int) W <: T, @specialized(Int) S](w: W) = id(w) + ^ 17 diff --git a/test/files/run/t5284c.check b/test/files/run/t5284c.check index 00750edc07..cf578ad102 100644 --- a/test/files/run/t5284c.check +++ b/test/files/run/t5284c.check @@ -1 +1,4 @@ +t5284c.scala:29: warning: type W is unused or used in non-specializable positions. + def bar[@specialized(Int) W <: T](ws: List[W]) = len(ws) + ^ 3 diff --git a/test/files/run/t5293-map.scala b/test/files/run/t5293-map.scala new file mode 100644 index 0000000000..2707aed07e --- /dev/null +++ b/test/files/run/t5293-map.scala @@ -0,0 +1,88 @@ + + + +import scala.collection.JavaConverters._ + + + +object Test extends App { + + def bench(label: String)(body: => Unit): Long = { + val start = System.nanoTime + + 0.until(10).foreach(_ => body) + + val end = System.nanoTime + + //println("%s: %s ms".format(label, (end - start) / 1000.0 / 1000.0)) + + end - start + } + + def benchJava(values: java.util.Map[Int, Int]) = { + bench("Java Map") { + val m = new java.util.HashMap[Int, Int] + + m.putAll(values) + } + } + + def benchScala(values: Iterable[(Int, Int)]) = { + bench("Scala Map") { + val m = new scala.collection.mutable.HashMap[Int, Int] + + m ++= values + } + } + + def benchScalaSorted(values: Iterable[(Int, Int)]) = { + bench("Scala Map sorted") { + val m = new scala.collection.mutable.HashMap[Int, Int] + + m ++= values.toArray.sorted + } + } + + def benchScalaPar(values: Iterable[(Int, Int)]) = { + bench("Scala ParMap") { + val m = new scala.collection.parallel.mutable.ParHashMap[Int, Int] map { x => x } + + m ++= values + } + } + + val total = 50000 + val values = (0 until total) zip (0 until total) + val map = scala.collection.mutable.HashMap.empty[Int, Int] + + map ++= values + + // warmup + for (x <- 0 until 5) { + benchJava(map.asJava) + benchScala(map) + benchScalaPar(map) + benchJava(map.asJava) + benchScala(map) + benchScalaPar(map) + } + + val javamap = benchJava(map.asJava) + val scalamap = benchScala(map) + val scalaparmap = benchScalaPar(map) + + // println(javamap) + // println(scalamap) + // println(scalaparmap) + + assert(scalamap < (javamap * 10), "scalamap: " + scalamap + " vs. javamap: " + javamap) + assert(scalaparmap < (javamap * 10), "scalaparmap: " + scalaparmap + " vs. javamap: " + javamap) +} + + + + + + + + diff --git a/test/files/run/t5293.scala b/test/files/run/t5293.scala new file mode 100644 index 0000000000..01ead45d2a --- /dev/null +++ b/test/files/run/t5293.scala @@ -0,0 +1,83 @@ + + + +import scala.collection.JavaConverters._ + + + +object Test extends App { + + def bench(label: String)(body: => Unit): Long = { + val start = System.nanoTime + + 0.until(10).foreach(_ => body) + + val end = System.nanoTime + + //println("%s: %s ms".format(label, (end - start) / 1000.0 / 1000.0)) + + end - start + } + + def benchJava(values: java.util.Collection[Int]) = { + bench("Java Set") { + val set = new java.util.HashSet[Int] + + set.addAll(values) + } + } + + def benchScala(values: Iterable[Int]) = { + bench("Scala Set") { + val set = new scala.collection.mutable.HashSet[Int] + + set ++= values + } + } + + def benchScalaSorted(values: Iterable[Int]) = { + bench("Scala Set sorted") { + val set = new scala.collection.mutable.HashSet[Int] + + set ++= values.toArray.sorted + } + } + + def benchScalaPar(values: Iterable[Int]) = { + bench("Scala ParSet") { + val set = new scala.collection.parallel.mutable.ParHashSet[Int] map { x => x } + + set ++= values + } + } + + val values = 0 until 50000 + val set = scala.collection.mutable.HashSet.empty[Int] + + set ++= values + + // warmup + for (x <- 0 until 5) { + benchJava(set.asJava) + benchScala(set) + benchScalaPar(set) + benchJava(set.asJava) + benchScala(set) + benchScalaPar(set) + } + + val javaset = benchJava(set.asJava) + val scalaset = benchScala(set) + val scalaparset = benchScalaPar(set) + + assert(scalaset < (javaset * 8), "scalaset: " + scalaset + " vs. javaset: " + javaset) + assert(scalaparset < (javaset * 8), "scalaparset: " + scalaparset + " vs. javaset: " + javaset) +} + + + + + + + + diff --git a/test/files/run/t5313.scala b/test/files/run/t5313.scala index 7da8726a1f..febfd9c3ed 100644 --- a/test/files/run/t5313.scala +++ b/test/files/run/t5313.scala @@ -7,7 +7,7 @@ object Test extends IcodeTest { override def code = """class Foo { - def randomBoolean = util.Random.nextInt % 2 == 0 + def randomBoolean = scala.util.Random.nextInt % 2 == 0 def bar = { var kept1 = new Object val result = new java.lang.ref.WeakReference(kept1) diff --git a/test/files/run/t5353.check b/test/files/run/t5353.check new file mode 100644 index 0000000000..a2906793ed --- /dev/null +++ b/test/files/run/t5353.check @@ -0,0 +1,2 @@ +1 +[Ljava.lang.Object; cannot be cast to [Ljava.lang.String; diff --git a/test/files/run/t5356.scala b/test/files/run/t5356.scala index ec17e036ad..dabb9ef855 100644 --- a/test/files/run/t5356.scala +++ b/test/files/run/t5356.scala @@ -1,3 +1,5 @@ + +import scala.language.{ reflectiveCalls } object Test { def f(x: Any { def toInt: Int }) = println(x.toInt + " " + x.getClass.getName) diff --git a/test/files/run/t5375.check b/test/files/run/t5375.check index 7d3002ffda..b1a57eeeec 100644 --- a/test/files/run/t5375.check +++ b/test/files/run/t5375.check @@ -1 +1 @@ -Composite throwable
\ No newline at end of file +Runtime exception diff --git a/test/files/run/t5375.scala b/test/files/run/t5375.scala index e4b329deae..826ecd841e 100644 --- a/test/files/run/t5375.scala +++ b/test/files/run/t5375.scala @@ -1,19 +1,8 @@ - - - -import collection.parallel.CompositeThrowable - - - -object Test { - - def main(args: Array[String]) { - val foos = (1 to 1000) toSeq; - try { - foos.par.map(i => if (i % 37 == 0) sys.error("i div 37") else i) - } catch { - case CompositeThrowable(thr) => println("Composite throwable") - } +object Test extends App { + val foos = (1 to 1000).toSeq + try + foos.par.map(i => if (i % 37 == 0) sys.error("i div 37") else i) + catch { + case ex: RuntimeException => println("Runtime exception") } - } diff --git a/test/files/run/t5380.check b/test/files/run/t5380.check new file mode 100644 index 0000000000..731a798301 --- /dev/null +++ b/test/files/run/t5380.check @@ -0,0 +1,9 @@ +t5380.scala:3: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + val f = () => return try { 1 } catch { case _: Throwable => 0 } + ^ +t5380.scala:3: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + val f = () => return try { 1 } catch { case _: Throwable => 0 } + ^ +t5380.scala:3: warning: enclosing method main has result type Unit: return value discarded + val f = () => return try { 1 } catch { case _: Throwable => 0 } + ^ diff --git a/test/files/run/t5380.scala b/test/files/run/t5380.scala index 6083161a9b..66d12a0ca6 100644 --- a/test/files/run/t5380.scala +++ b/test/files/run/t5380.scala @@ -1,6 +1,6 @@ object Test { def main(args: Array[String]) { - val f = () => return try { 1 } catch { case _ => 0 } + val f = () => return try { 1 } catch { case _: Throwable => 0 } f() } } diff --git a/test/files/run/t5418.check b/test/files/run/t5418.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t5418.check diff --git a/test/files/run/t5418.scala b/test/files/run/t5418.scala new file mode 100644 index 0000000000..e3cb20cf82 --- /dev/null +++ b/test/files/run/t5418.scala @@ -0,0 +1,8 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + reify { + new Object().getClass + }.eval +}
\ No newline at end of file diff --git a/test/files/run/t5418b.check b/test/files/run/t5418b.check index 48d82a2aae..f036a4be84 100644 --- a/test/files/run/t5418b.check +++ b/test/files/run/t5418b.check @@ -1,2 +1,2 @@ new Object().getClass() -TypeRef(ThisType(java.lang), java.lang.Class, List(TypeRef(NoPrefix, newTypeName("?0"), List()))) +TypeRef(ThisType(java.lang), java.lang.Class, List(TypeRef(NoPrefix, TypeName("?0"), List()))) diff --git a/test/files/run/t5428.scala b/test/files/run/t5428.scala index 106bb7fc31..fb58cbbe24 100644 --- a/test/files/run/t5428.scala +++ b/test/files/run/t5428.scala @@ -23,7 +23,7 @@ object Test { println(a) - a pop + a.pop } } diff --git a/test/files/run/t5527.check b/test/files/run/t5527.check deleted file mode 100644 index 36bee9bb55..0000000000 --- a/test/files/run/t5527.check +++ /dev/null @@ -1,99 +0,0 @@ -[[syntax trees at end of parser]] // newSource1.scala -package <empty> { - object UselessComments extends scala.AnyRef { - def <init>() = { - super.<init>(); - () - }; - var z = 0; - def test1 = { - object Maybe extends scala.AnyRef { - def <init>() = { - super.<init>(); - () - }; - /** Some comment inside */ - def nothing() = () - }; - () - }; - def test2 = { - var x = 4; - if (true) - { - x = 5; - val y = 6; - () - } - else - () - }; - def test3 = { - if (true) - z = 3 - else - (); - val t = 4; - 0.to(4).foreach(((i) => println(i))) - }; - val test4 = 'a' match { - case ('0'| '1'| '2'| '3'| '4'| '5'| '6'| '7'| '8'| '9') => true - case _ => false - } - }; - /** comments that we should keep */ - object UsefulComments extends scala.AnyRef { - def <init>() = { - super.<init>(); - () - }; - /** class A */ - class A extends scala.AnyRef { - def <init>() = { - super.<init>(); - () - }; - /** f */ - def f(i: Int) = i; - /** v */ - val v = 1; - /** u */ - var u = 2 - }; - /** trait B */ - abstract trait B extends scala.AnyRef { - def $init$() = { - () - }; - /** T */ - type T >: _root_.scala.Nothing <: _root_.scala.Any; - /** f */ - def f(i: Int): scala.Unit; - /** v */ - val v = 1; - /** u */ - var u = 2 - }; - /** object C */ - object C extends scala.AnyRef { - def <init>() = { - super.<init>(); - () - }; - /** f */ - def f(i: Int) = i; - /** v */ - val v = 1; - /** u */ - var u = 2 - }; - /** class D */ - @new deprecated("use ... instead", "2.10.0") class D extends scala.AnyRef { - def <init>() = { - super.<init>(); - () - } - } - } -} - diff --git a/test/files/run/t5527.scala b/test/files/run/t5527.scala deleted file mode 100644 index 2449ff60c3..0000000000 --- a/test/files/run/t5527.scala +++ /dev/null @@ -1,107 +0,0 @@ -import scala.tools.partest._ -import java.io._ -import scala.tools.nsc._ -import scala.tools.nsc.util.CommandLineParser -import scala.tools.nsc.doc.{Settings, DocFactory} -import scala.tools.nsc.reporters.ConsoleReporter - -object Test extends DirectTest { - - override def extraSettings: String = "-usejavacp -Xprint:parser -Yrangepos -Ystop-after:parser -d " + testOutput.path - - override def code = """ - // SI-5527 - object UselessComments { - - var z = 0 - - def test1 = { - /** Some comment here */ - object Maybe { - /** Some comment inside */ - def nothing() = () - } - } - - def test2 = { - var x = 4 - if (true) { - /** Testing 123 */ - x = 5 - val y = 6 - } - } - - def test3 = { - if (true) - z = 3 - - /** Calculate this result. */ - val t = 4 - for (i <- 0 to 4) - println(i) - } - - val test4 = ('a') match { - /** Another digit is a giveaway. */ - case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' => - true - case _ => - false - } - } - - /** comments that we should keep */ - object UsefulComments { - /** class A */ - class A { - /** f */ - def f(i: Int) = i - /** v */ - val v = 1 - /** u */ - var u = 2 - } - /** trait B */ - trait B { - /** T */ - type T - /** f */ - def f(i: Int) - /** v */ - val v = 1 - /** u */ - var u = 2 - } - /** object C */ - object C { - /** f */ - def f(i: Int) = i - /** v */ - val v = 1 - /** u */ - var u = 2 - } - /** class D */ - @deprecated("use ... instead", "2.10.0") - class D - } - """.trim - - override def show(): Unit = { - // redirect err to out, for logging - val prevErr = System.err - System.setErr(System.out) - compile() - System.setErr(prevErr) - } - - override def newCompiler(args: String*): Global = { - // we want the Scaladoc compiler here, because it keeps DocDef nodes in the tree - val settings = new Settings(_ => ()) - val command = new ScalaDoc.Command((CommandLineParser tokenize extraSettings) ++ args.toList, settings) - new DocFactory(new ConsoleReporter(settings), settings).compiler - } - - override def isDebug = false // so we don't get the newSettings warning -} diff --git a/test/files/run/t5568.flags b/test/files/run/t5568.flags new file mode 100644 index 0000000000..ad51758c39 --- /dev/null +++ b/test/files/run/t5568.flags @@ -0,0 +1 @@ +-nowarn diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check index 3f19a0a4b1..188f39ff82 100644 --- a/test/files/run/t5603.check +++ b/test/files/run/t5603.check @@ -12,7 +12,7 @@ [95:101]<paramaccessor> private[this] val i: [98:101]Int = _; <119:139>def <init>([95]i: [98]Int) = <119:139>{ <119:139>val nameElse = <134:139>"Bob"; - [94][94][94]super.<init>(); + [NoPosition][NoPosition][NoPosition]super.<init>(); [94]() }; [168:184]val name = [179:184]"avc"; @@ -20,7 +20,7 @@ }; [215:241]object Test extends [227:241][235:238]App { [227]def <init>() = [227]{ - [227][227][227]super.<init>(); + [NoPosition][NoPosition][NoPosition]super.<init>(); [227]() }; [NoPosition]<empty> diff --git a/test/files/run/t5603.scala b/test/files/run/t5603.scala index 60dfd01fee..77c2775cc3 100644 --- a/test/files/run/t5603.scala +++ b/test/files/run/t5603.scala @@ -1,7 +1,7 @@ import scala.tools.partest._ import java.io._ import scala.tools.nsc._ -import scala.tools.nsc.util.CommandLineParser +import scala.tools.cmd.CommandLineParser import scala.tools.nsc.{Global, Settings, CompilerCommand} import scala.tools.nsc.reporters.ConsoleReporter @@ -36,7 +36,8 @@ object Test extends DirectTest { val settings = new Settings() settings.Xprintpos.value = true + settings.Yrangepos.value = true val command = new CompilerCommand((CommandLineParser tokenize extraSettings) ++ args.toList, settings) - new Global(command.settings, new ConsoleReporter(settings)) with interactive.RangePositions + Global(command.settings, new ConsoleReporter(settings)) } } diff --git a/test/files/run/t5610a.check b/test/files/run/t5610a.check new file mode 100644 index 0000000000..2aa46b3b91 --- /dev/null +++ b/test/files/run/t5610a.check @@ -0,0 +1 @@ +Stroke a kitten diff --git a/test/files/run/t5610a.scala b/test/files/run/t5610a.scala new file mode 100644 index 0000000000..f20b295762 --- /dev/null +++ b/test/files/run/t5610a.scala @@ -0,0 +1,19 @@ +object Test extends App { + class Result(_str: => String) { + lazy val str = _str + } + + def foo(str: => String)(i: Int) = new Result(str) + + def bar(f: Int => Result) = f(42) + + var test: String = null + val result = bar(foo(test)) + test = "bar" + + if (result.str == null) { + println("Destroy ALL THE THINGS!!!") + } else { + println("Stroke a kitten") + } +}
\ No newline at end of file diff --git a/test/files/run/t5629b.scala b/test/files/run/t5629b.scala index 6c908081b9..adb9ca5498 100644 --- a/test/files/run/t5629b.scala +++ b/test/files/run/t5629b.scala @@ -33,7 +33,7 @@ object Test extends App { val pf = newPF(1) println("=== pf(1):") - try { pf(1) } catch { case x => println(x) } + try { pf(1) } catch { case x: Throwable => println(x) } println("=== pf(42):") pf(42) println("=== done") diff --git a/test/files/run/t5655.check b/test/files/run/t5655.check index 43ebd50e7a..1103b0e36f 100644 --- a/test/files/run/t5655.check +++ b/test/files/run/t5655.check @@ -4,7 +4,7 @@ Type :help for more information. scala> scala> object x { def x={} } -defined module x +defined object x scala> import x._ import x._ diff --git a/test/files/run/t5699.scala b/test/files/run/t5699.scala index 5cef67e3b1..ec3b1d26b4 100755 --- a/test/files/run/t5699.scala +++ b/test/files/run/t5699.scala @@ -1,5 +1,5 @@ import scala.tools.partest.DirectTest -import scala.tools.nsc.util.BatchSourceFile +import scala.reflect.internal.util.BatchSourceFile object Test extends DirectTest { // Java code diff --git a/test/files/run/t5717.scala b/test/files/run/t5717.scala new file mode 100755 index 0000000000..a0997f5a49 --- /dev/null +++ b/test/files/run/t5717.scala @@ -0,0 +1,21 @@ +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) + } + // TODO + // Don't assume output is on physical disk + // Let the compiler tell us output dir + // val sc = newCompiler("-cp", classpath, "-d", testOutput.path) + // val out = sc.settings.outputDirs.getSingleOutput.get + def show(): Unit = { + // Don't crash when we find a file 'a' where package 'a' should go. + scala.reflect.io.File(testOutput.path + "/a").writeAll("a") + compileCode("package a { class B }") + } +} diff --git a/test/files/run/t576.scala b/test/files/run/t576.scala index 756a241572..5c8c9a90cb 100644 --- a/test/files/run/t576.scala +++ b/test/files/run/t576.scala @@ -1,3 +1,5 @@ +import scala.language.reflectiveCalls + class A { override def equals(other: Any) = other match { case _: this.type => true diff --git a/test/files/run/t5879.check b/test/files/run/t5879.check index b6cbda35a7..4bdf3f5fcf 100644 --- a/test/files/run/t5879.check +++ b/test/files/run/t5879.check @@ -1,16 +1,8 @@ Map(1 -> 1) 1 -Map(1 -> 1) -1 -(1,1) -Map(1 -> 1) -1 (1,1) Map(1 -> 1) 1 (1,2) Map(1 -> 2) 2 -(1,2) -Map(1 -> 2) -2
\ No newline at end of file diff --git a/test/files/run/t5879.scala b/test/files/run/t5879.scala index e1c07fc4c2..18dd94289d 100644 --- a/test/files/run/t5879.scala +++ b/test/files/run/t5879.scala @@ -17,10 +17,6 @@ object Test { val r = a.merged(b)(null) println(r) println(r(1)) - - val rold = a.merge(b) - println(rold) - println(rold(1)) } def resolveFirst() { @@ -34,10 +30,6 @@ object Test { val r = a.merged(b) { collision } println(r) println(r(1)) - - val rold = a.merge(b, collision) - println(rold) - println(rold(1)) } def resolveSecond() { @@ -51,10 +43,6 @@ object Test { val r = a.merged(b) { collision } println(r) println(r(1)) - - val rold = a.merge(b, collision) - println(rold) - println(rold(1)) } def resolveMany() { @@ -66,9 +54,6 @@ object Test { val r = a.merged(b) { collision } for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v)) - - val rold = a.merge(b, collision) - for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v)) } } diff --git a/test/files/run/t5881.scala b/test/files/run/t5881.scala index 01bee29181..04b24b713d 100644 --- a/test/files/run/t5881.scala +++ b/test/files/run/t5881.scala @@ -1,6 +1,7 @@ +import scala.language.existentials import scala.reflect.ClassTag object Test extends App { println(implicitly[ClassTag[List[T forSome {type T <: List[T]}]]]) println(implicitly[ClassTag[List[Any]]]) -}
\ No newline at end of file +} diff --git a/test/files/run/t5912.scala b/test/files/run/t5912.scala index 7710d04396..9418e946d0 100644 --- a/test/files/run/t5912.scala +++ b/test/files/run/t5912.scala @@ -1,6 +1,7 @@ +import scala.language.existentials object Test extends App{ import scala.reflect.runtime.{currentMirror=>cm} import scala.tools.reflect._ import scala.reflect.runtime.universe._ val tree = cm.mkToolBox().typeCheck( Literal(Constant("test")) ) -}
\ No newline at end of file +} diff --git a/test/files/run/t5942.scala b/test/files/run/t5942.scala index 44a8be93f6..c90d29e1ca 100644 --- a/test/files/run/t5942.scala +++ b/test/files/run/t5942.scala @@ -5,6 +5,6 @@ import scala.tools.reflect._ object Test extends App { val tb = cm.mkToolBox() tb.parse("def x = {}") - try { tb.parse("def x = {") } catch { case _ => } + try { tb.parse("def x = {") } catch { case _: Throwable => } tb.parse("def x = {}") } diff --git a/test/files/run/t6011c.check b/test/files/run/t6011c.check new file mode 100644 index 0000000000..088e6fdaae --- /dev/null +++ b/test/files/run/t6011c.check @@ -0,0 +1,3 @@ +t6011c.scala:11: warning: unreachable code + case 1 => 3 // crash + ^ diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 613d25b075..46974589d3 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -1,7 +1,7 @@ [[syntax trees at end of lambdalift]] // newSource1.scala package <empty> { class T extends Object { - <paramaccessor> val T$$classParam: Int = _; + <paramaccessor> val classParam: Int = _; def <init>(classParam: Int): T = { T.super.<init>(); () @@ -15,11 +15,11 @@ package <empty> { } }; def bar(barParam: Int): Object = { - @volatile var MethodLocalObject$module: runtime.VolatileObjectRef = new runtime.VolatileObjectRef(null); + @volatile var MethodLocalObject$module: runtime.VolatileObjectRef = scala.runtime.VolatileObjectRef.zero(); T.this.MethodLocalObject$1(barParam, MethodLocalObject$module) }; def tryy(tryyParam: Int): Function0 = { - var tryyLocal: runtime.IntRef = new runtime.IntRef(0); + var tryyLocal: runtime.IntRef = scala.runtime.IntRef.create(0); { (new anonymous class $anonfun$tryy$1(T.this, tryyParam, tryyLocal): Function0) } @@ -30,15 +30,15 @@ package <empty> { () }; final def apply(): Int = $anonfun$foo$1.this.apply$mcI$sp(); - <specialized> def apply$mcI$sp(): Int = $anonfun$foo$1.this.$outer.T$$classParam.+($anonfun$foo$1.this.$outer.field()).+($anonfun$foo$1.this.methodParam$1).+($anonfun$foo$1.this.methodLocal$1); - <synthetic> <paramaccessor> private[this] val $outer: T = _; - <synthetic> <stable> def T$$anonfun$$$outer(): T = $anonfun$foo$1.this.$outer; - final <bridge> def apply(): Object = scala.Int.box($anonfun$foo$1.this.apply()); + <specialized> def apply$mcI$sp(): Int = $anonfun$foo$1.this.$outer.classParam.+($anonfun$foo$1.this.$outer.field()).+($anonfun$foo$1.this.methodParam$1).+($anonfun$foo$1.this.methodLocal$1); + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def $outer(): T = $anonfun$foo$1.this.$outer; + final <bridge> <artifact> def apply(): Object = scala.Int.box($anonfun$foo$1.this.apply()); <synthetic> <paramaccessor> private[this] val methodParam$1: Int = _; <synthetic> <paramaccessor> private[this] val methodLocal$1: Int = _ }; abstract trait MethodLocalTrait$1 extends Object { - <synthetic> <stable> def T$MethodLocalTrait$$$outer(): T + <synthetic> <stable> <artifact> def $outer(): T }; object MethodLocalObject$2 extends Object with T#MethodLocalTrait$1 { def <init>($outer: T, barParam$1: Int): T#MethodLocalObject$2.type = { @@ -46,9 +46,9 @@ package <empty> { MethodLocalObject$2.this.$asInstanceOf[T#MethodLocalTrait$1$class]()./*MethodLocalTrait$1$class*/$init$(barParam$1); () }; - <synthetic> <paramaccessor> private[this] val $outer: T = _; - <synthetic> <stable> def T$MethodLocalObject$$$outer(): T = MethodLocalObject$2.this.$outer; - <synthetic> <stable> def T$MethodLocalTrait$$$outer(): T = MethodLocalObject$2.this.$outer + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer; + <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer }; final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); @@ -69,9 +69,9 @@ package <empty> { <specialized> def apply$mcV$sp(): Unit = try { $anonfun$tryy$1.this.tryyLocal$1.elem = $anonfun$tryy$1.this.tryyParam$1 } finally (); - <synthetic> <paramaccessor> private[this] val $outer: T = _; - <synthetic> <stable> def T$$anonfun$$$outer(): T = $anonfun$tryy$1.this.$outer; - final <bridge> def apply(): Object = { + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def $outer(): T = $anonfun$tryy$1.this.$outer; + final <bridge> <artifact> def apply(): Object = { $anonfun$tryy$1.this.apply(); scala.runtime.BoxedUnit.UNIT }; diff --git a/test/files/run/t603.scala b/test/files/run/t603.scala index b8825c933b..54fb8e6974 100644 --- a/test/files/run/t603.scala +++ b/test/files/run/t603.scala @@ -1,4 +1,6 @@ object forceDelay { + import scala.language.implicitConversions + class Susp[+A](lazyValue: => A) extends Function0[A] { private var func: () => Any = () => lazyValue private var value: Any = null diff --git a/test/files/run/t6064.scala b/test/files/run/t6064.scala new file mode 100644 index 0000000000..fc184dd92d --- /dev/null +++ b/test/files/run/t6064.scala @@ -0,0 +1,9 @@ +object Test extends App { + assert(Option(42) contains 42) + assert(Some(42) contains 42) + assert(Option(BigInt(42)) contains 42) + assert(Option(42) contains BigInt(42)) + assert(!(None contains 42)) + assert(Some(null) contains null) + assert(!(Option(null) contains null)) +}
\ No newline at end of file diff --git a/test/files/run/t6102.check b/test/files/run/t6102.check index b6fc4c620b..97e455647b 100644 --- a/test/files/run/t6102.check +++ b/test/files/run/t6102.check @@ -1 +1,29 @@ -hello
\ No newline at end of file +[running phase parser on t6102.scala] +[running phase namer on t6102.scala] +[running phase packageobjects on t6102.scala] +[running phase typer on t6102.scala] +[running phase patmat on t6102.scala] +[running phase superaccessors on t6102.scala] +[running phase extmethods on t6102.scala] +[running phase pickler on t6102.scala] +[running phase refchecks on t6102.scala] +[running phase uncurry on t6102.scala] +[running phase tailcalls on t6102.scala] +[running phase specialize on t6102.scala] +[running phase explicitouter on t6102.scala] +[running phase erasure on t6102.scala] +[running phase posterasure on t6102.scala] +[running phase lazyvals on t6102.scala] +[running phase lambdalift on t6102.scala] +[running phase constructors on t6102.scala] +[running phase flatten on t6102.scala] +[running phase mixin on t6102.scala] +[running phase cleanup on t6102.scala] +[running phase icode on t6102.scala] +[running phase inliner on t6102.scala] +[running phase inlinehandlers on t6102.scala] +[running phase closelim on t6102.scala] +[running phase constopt on t6102.scala] +[running phase dce on t6102.scala] +[running phase jvm on icode] +hello diff --git a/test/files/run/t6102.flags b/test/files/run/t6102.flags index e35535c8ea..72fe7b1aa0 100644 --- a/test/files/run/t6102.flags +++ b/test/files/run/t6102.flags @@ -1 +1 @@ - -Ydead-code + -Ydead-code -Ydebug -Xfatal-warnings diff --git a/test/files/run/t6113.scala b/test/files/run/t6113.scala index 321cae86a3..b77a56029a 100644 --- a/test/files/run/t6113.scala +++ b/test/files/run/t6113.scala @@ -1,6 +1,8 @@ +import scala.language.higherKinds + trait Foo[C[_]] object Test extends App { import scala.reflect.runtime.universe._ println(typeOf[Foo[({type l[X] = (Int, X)})#l]]) -}
\ No newline at end of file +} diff --git a/test/files/run/t6146b.check b/test/files/run/t6146b.check index 49ff70697e..2333b9d986 100644 --- a/test/files/run/t6146b.check +++ b/test/files/run/t6146b.check @@ -1,3 +1,7 @@ +t6146b.scala:15: warning: match may not be exhaustive. +It would fail on the following inputs: S2(), S3() + def foo(f: F[Int]) = f match { case X.S1 => } + ^ Type in expressions to have them evaluated. Type :help for more information. diff --git a/test/files/run/t6150.scala b/test/files/run/t6150.scala index bd8af5d460..f3e83e1549 100644 --- a/test/files/run/t6150.scala +++ b/test/files/run/t6150.scala @@ -1,7 +1,3 @@ - - - - object Test { import collection.{ immutable, mutable, generic } def TheOneTrueCBF = collection.IndexedSeq.ReusableCBF @@ -38,7 +34,3 @@ object Test { check(iv.:+(4)(cbf3)) } } - - - - diff --git a/test/files/run/t6168/Context.java b/test/files/run/t6168/Context.java new file mode 100644 index 0000000000..e527844563 --- /dev/null +++ b/test/files/run/t6168/Context.java @@ -0,0 +1,34 @@ +public class Context<ParentType> { + private ParentType parent; + + public Context() {} + + public ParentType getParent() { + return parent; + } + + public void setParent(ParentType parent) { + this.parent = parent; + } + + public Field<Integer> intField() { + return new Field<Integer>() { + @Override + public Integer get() { + return 0; + } + + @Override + public ParentType set(Integer t) { + return parent; + } + }; + } + + public abstract class Field<T> { //Note this is a path dependent type + + public abstract T get(); + + public abstract ParentType set(T t); + } +}
\ No newline at end of file diff --git a/test/files/run/t6168/JavaTest.java b/test/files/run/t6168/JavaTest.java new file mode 100644 index 0000000000..94ae91661d --- /dev/null +++ b/test/files/run/t6168/JavaTest.java @@ -0,0 +1,8 @@ +public class JavaTest { + public static void main(String[] args) { + SomeClass a = new SomeClass(); + SomeClass2 a2 = new SomeClass2(); + SomeClass b = a.f.set(23).f.set(23); + SomeClass2 b2 = a2.f.set(23).f.set(23); + } +}
\ No newline at end of file diff --git a/test/files/run/t6168/SomeClass.java b/test/files/run/t6168/SomeClass.java new file mode 100644 index 0000000000..6f76b829bb --- /dev/null +++ b/test/files/run/t6168/SomeClass.java @@ -0,0 +1,14 @@ +public class SomeClass { + private final Context<SomeClass> context = new Context<SomeClass>(); + { + context.setParent(this); + } + + public final Context<SomeClass>.Field<Integer> f = context.intField(); + + public SomeClass() { + f.set(23).f.set(23); + } +} + + diff --git a/test/files/run/t6168/SomeClass2.java b/test/files/run/t6168/SomeClass2.java new file mode 100644 index 0000000000..b2c7a7540b --- /dev/null +++ b/test/files/run/t6168/SomeClass2.java @@ -0,0 +1,12 @@ +public class SomeClass2 { + private final Context<SomeClass2> context = new Context<SomeClass2>(); + { + context.setParent(this); + } + + public final Context<SomeClass2>.Field<Integer> f = context.intField(); + + public SomeClass2() { + f.set(23).f.set(23); + } +}
\ No newline at end of file diff --git a/test/files/run/t6168/main.scala b/test/files/run/t6168/main.scala new file mode 100644 index 0000000000..c7ad37830b --- /dev/null +++ b/test/files/run/t6168/main.scala @@ -0,0 +1,15 @@ + + +object Test extends App { + JavaTest.main(null) + + var a1 : SomeClass = new SomeClass + var a2 : SomeClass2 = new SomeClass2 + //import language.implicitConversions + //implicit def setParentType2SomeClass(x:Any) = x.asInstanceOf[SomeClass] + //implicit def setParentType2SomeClass2(x:Any) = x.asInstanceOf[SomeClass2] + //var b : SomeClass = a.f.set(23).asInstanceOf[SomeClass].f.set(23).asInstanceOf[SomeClass] + //var b2 : SomeClass2 = a2.f.set(23).asInstanceOf[SomeClass2].f.set(23).asInstanceOf[SomeClass2] + var b1 : SomeClass = a1.f.set(23).f.set(23) + var b2 : SomeClass2 = a2.f.set(23).f.set(23) +} diff --git a/test/files/run/t6168b/Context.java b/test/files/run/t6168b/Context.java new file mode 100644 index 0000000000..b3ea22126f --- /dev/null +++ b/test/files/run/t6168b/Context.java @@ -0,0 +1,34 @@ +public class Context<ParentType> { + private ParentType parent; + + public Context() {} + + public ParentType getParent() { + return parent; + } + + public void setParent(ParentType parent) { + this.parent = parent; + } + + public Field<Integer> intField() { + return new Field<Integer>() { + @Override + public Integer get() { + return 0; + } + + @Override + public ParentType set(Integer t) { + return parent; + } + }; + } + + public static abstract class Field<T> { + + public abstract T get(); + + public abstract Object set(T t); + } +}
\ No newline at end of file diff --git a/test/files/run/t6168b/JavaTest.java b/test/files/run/t6168b/JavaTest.java new file mode 100644 index 0000000000..a09fa0382d --- /dev/null +++ b/test/files/run/t6168b/JavaTest.java @@ -0,0 +1,6 @@ +public class JavaTest { + public static void main(String[] args) { + SomeClass a = new SomeClass(); + Object b = a.f.set(23); + } +}
\ No newline at end of file diff --git a/test/files/run/t6168b/SomeClass.java b/test/files/run/t6168b/SomeClass.java new file mode 100644 index 0000000000..566c55e1c5 --- /dev/null +++ b/test/files/run/t6168b/SomeClass.java @@ -0,0 +1,11 @@ +public class SomeClass { + private final Context<SomeClass> context = new Context<SomeClass>(); + { + context.setParent(this); + } + + public final Context.Field<Integer> f = context.intField(); + +} + + diff --git a/test/files/run/t6168b/main.scala b/test/files/run/t6168b/main.scala new file mode 100644 index 0000000000..187e9fe85e --- /dev/null +++ b/test/files/run/t6168b/main.scala @@ -0,0 +1,8 @@ + + +object Test extends App { + JavaTest.main(null) + + var a1 : SomeClass = new SomeClass + var b1 : Object = a1.f.set(23) +} diff --git a/test/files/run/t6178.scala b/test/files/run/t6178.scala index 0b4cf0bbf5..41e148af91 100644 --- a/test/files/run/t6178.scala +++ b/test/files/run/t6178.scala @@ -2,6 +2,6 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { - val plus = typeOf[java.lang.String].member(newTermName("$plus")).asMethod + val plus = typeOf[java.lang.String].member(TermName("$plus")).asMethod println(cm.reflect("").reflectMethod(plus).apply("2")) }
\ No newline at end of file diff --git a/test/files/run/t6181.scala b/test/files/run/t6181.scala index fb23eaff63..eaa7340178 100644 --- a/test/files/run/t6181.scala +++ b/test/files/run/t6181.scala @@ -3,6 +3,6 @@ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { class C { def test(x: => Int) = println(x) } - val mm = cm.reflect(new C).reflectMethod(typeOf[C].member(newTermName("test")).asMethod) + val mm = cm.reflect(new C).reflectMethod(typeOf[C].member(TermName("test")).asMethod) mm(2) }
\ No newline at end of file diff --git a/test/files/run/t6187.check b/test/files/run/t6187.check index c0ca02923b..621306b2ef 100644 --- a/test/files/run/t6187.check +++ b/test/files/run/t6187.check @@ -12,7 +12,7 @@ scala> def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T] macroImpl: [T](c: scala.reflect.macros.Context)(t: c.Expr[T])(implicit evidence$1: c.WeakTypeTag[T])c.Expr[List[T]] scala> def demo[T](t: T): List[T] = macro macroImpl[T] -demo: [T](t: T)List[T] +defined term macro demo: [T](t: T)List[T] scala> def m[T](t: T): List[List[T]] = demo( List((t,true)) collect { case (x,true) => x } ) diff --git a/test/files/run/t6199-mirror.scala b/test/files/run/t6199-mirror.scala index 772a384542..3fda56bf7c 100644 --- a/test/files/run/t6199-mirror.scala +++ b/test/files/run/t6199-mirror.scala @@ -3,5 +3,5 @@ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { class C { def foo = () } - println(cm.reflect(new C).reflectMethod(typeOf[C].member(newTermName("foo")).asMethod)()) + println(cm.reflect(new C).reflectMethod(typeOf[C].member(TermName("foo")).asMethod)()) }
\ No newline at end of file diff --git a/test/files/run/t6221.check b/test/files/run/t6221.check new file mode 100644 index 0000000000..aa1bdd0e6e --- /dev/null +++ b/test/files/run/t6221.check @@ -0,0 +1 @@ +((x) => x.$percent(2).$eq$eq(0)) diff --git a/test/files/run/t6221/Macros_1.scala b/test/files/run/t6221/Macros_1.scala new file mode 100644 index 0000000000..c9500626d8 --- /dev/null +++ b/test/files/run/t6221/Macros_1.scala @@ -0,0 +1,22 @@ +import language.experimental.macros +import language.implicitConversions +import scala.reflect.macros.Context +import scala.reflect.runtime.universe.Tree + +class ReflectiveClosure[A, B](val tree: Tree, fn: A => B) extends (A => B) { + def apply(x: A) = fn(x) +} + +object ReflectiveClosure { + implicit def reflectClosure[A, B](f: A => B): ReflectiveClosure[A, B] = macro Macros.reflectiveClosureImpl[A, B] +} + +object Macros { + def reflectiveClosureImpl[A, B](c: Context)(f: c.Expr[A => B]): c.Expr[ReflectiveClosure[A, B]] = { + import c.universe._ + val u = treeBuild.mkRuntimeUniverseRef + val m = EmptyTree + val tree = c.Expr[scala.reflect.runtime.universe.Tree](Select(c.reifyTree(u, m, f.tree), newTermName("tree"))) + c.universe.reify(new ReflectiveClosure(tree.splice, f.splice)) + } +} diff --git a/test/files/run/t6221/Test_2.scala b/test/files/run/t6221/Test_2.scala new file mode 100644 index 0000000000..9f6b2280a7 --- /dev/null +++ b/test/files/run/t6221/Test_2.scala @@ -0,0 +1,10 @@ +object Test extends App { + implicit class PimpedList[T](val list: List[T]) { + def query(predicate: ReflectiveClosure[T, Boolean]): List[T] = { + println(predicate.tree) + list filter predicate + } + } + + List(1, 2, 3).query(x => x % 2 == 0) +}
\ No newline at end of file diff --git a/test/files/run/t6223.check b/test/files/run/t6223.check index f83799bab1..4a09d1930f 100644 --- a/test/files/run/t6223.check +++ b/test/files/run/t6223.check @@ -1,4 +1,4 @@ bar bar$mIc$sp bar$mIcI$sp -bar$mcI$sp
\ No newline at end of file +bar$mcI$sp diff --git a/test/files/run/t6246.scala b/test/files/run/t6246.scala index 28765e1adf..2db87aa6d2 100644 --- a/test/files/run/t6246.scala +++ b/test/files/run/t6246.scala @@ -1,5 +1,6 @@ import scala.reflect.{ClassTag, classTag} +@deprecated("Suppress warnings", since="2.11") object Test extends App { def testValueClass(tag: ClassTag[_]) { println(s"runtimeClass = ${tag.runtimeClass}, toString = ${tag.toString}") @@ -23,4 +24,4 @@ object Test extends App { testValueClass(ClassTag.Double) testValueClass(ClassTag.Unit) testValueClass(ClassTag.Boolean) -}
\ No newline at end of file +} diff --git a/test/files/run/t6288.check b/test/files/run/t6288.check index e940975e44..a032a10de6 100644 --- a/test/files/run/t6288.check +++ b/test/files/run/t6288.check @@ -1,8 +1,8 @@ [[syntax trees at end of patmat]] // newSource1.scala [7]package [7]<empty> { [7]object Case3 extends [13][106]scala.AnyRef { - [13]def <init>(): [13]Case3.type = [13]{ - [13][13][13]Case3.super.<init>(); + [106]def <init>(): [13]Case3.type = [106]{ + [106][106][106]Case3.super.<init>(); [13]() }; [21]def unapply([29]z: [32]<type: [32]scala.Any>): [21]Option[Int] = [56][52][52]scala.Some.apply[[52]Int]([58]-1); @@ -24,8 +24,8 @@ } }; [113]object Case4 extends [119][217]scala.AnyRef { - [119]def <init>(): [119]Case4.type = [119]{ - [119][119][119]Case4.super.<init>(); + [217]def <init>(): [119]Case4.type = [217]{ + [217][217][217]Case4.super.<init>(); [119]() }; [127]def unapplySeq([138]z: [141]<type: [141]scala.Any>): [127]Option[List[Int]] = [167]scala.None; @@ -50,8 +50,8 @@ } }; [224]object Case5 extends [230][312]scala.AnyRef { - [230]def <init>(): [230]Case5.type = [230]{ - [230][230][230]Case5.super.<init>(); + [312]def <init>(): [230]Case5.type = [312]{ + [312][312][312]Case5.super.<init>(); [230]() }; [238]def unapply([246]z: [249]<type: [249]scala.Any>): [238]Boolean = [265]true; @@ -60,7 +60,7 @@ [273]case5()[293]{ [293]<synthetic> val o7: [293]Option[List[Int]] = [293][293]Case4.unapplySeq([293]x1); [293]if ([293]o7.isEmpty.unary_!) - [293]if ([293][293][293][293]o7.get.!=([293]null).&&([293][293][293][293]o7.get.lengthCompare([293]0).==([195]0))) + [293]if ([293][293][293][293]o7.get.!=([293]null).&&([293][293][293][293]o7.get.lengthCompare([293]0).==([293]0))) [304][304]matchEnd4([304]()) else [293][293]case6() diff --git a/test/files/run/t6288b-jump-position.check b/test/files/run/t6288b-jump-position.check index 83ba810958..ece88b18f0 100644 --- a/test/files/run/t6288b-jump-position.check +++ b/test/files/run/t6288b-jump-position.check @@ -65,9 +65,9 @@ object Case3 extends Object { blocks: [1] 1: - 1 THIS(Case3) - 1 CALL_METHOD java.lang.Object.<init> (super()) - 1 RETURN(UNIT) + 12 THIS(Case3) + 12 CALL_METHOD java.lang.Object.<init> (super()) + 12 RETURN(UNIT) } Exception handlers: diff --git a/test/files/run/t6308.check b/test/files/run/t6308.check new file mode 100644 index 0000000000..e2577db72a --- /dev/null +++ b/test/files/run/t6308.check @@ -0,0 +1,16 @@ +- Unspecialized type args +// Specialized +f1 f1$mIc$sp +f2 f2$mIc$sp +f3 f3$mIc$sp +f4 f4$mIc$sp +f5 f5$mIc$sp + +// Unspecialized type args +f4(Boolean) f4 +f4(String) f4 + +// Ideally these would be specialized +todo1 todo1 +todo2 todo2 +todo3 todo3 diff --git a/test/files/run/t6308.scala b/test/files/run/t6308.scala new file mode 100644 index 0000000000..d23cd6e13e --- /dev/null +++ b/test/files/run/t6308.scala @@ -0,0 +1,45 @@ +import scala.{specialized => sp} + +// NOTE: `{ val c = caller; print(""); c }` is used instead of a simple `caller`, +// because we want to prevent tail-call optimization from eliding the stack- +// frames we want to inspect. + +object Test { + def caller = new Exception().getStackTrace()(1).getMethodName + def f1[@sp(Int) A](a: A, b: Any) = { val c = caller; print(""); c } + def f2[@sp(Int) A, B](a: A, b: String) = { val c = caller; print(""); c } + def f3[B, @sp(Int) A](a: A, b: List[B]) = { val c = caller; print(""); c } + def f4[B, @sp(Int) A](a: A, b: List[(A, B)]) = { val c = caller; print(""); c } + + def f5[@sp(Int) A, B <: Object](a: A, b: B) = { val c = caller; print(""); c } + + // `uncurryTreeType` calls a TypeMap on the call to this method and we end up with new + // type parameter symbols, which are not found in `TypeEnv.includes(typeEnv(member), env)` + // in `specSym`. (One of `uncurry`'s tasks is to expand type aliases in signatures.) + type T = Object + def todo1[@sp(Int) A, B <: T](a: A, b: String) = { val c = caller; print(""); c } + def todo2[@sp(Int) A, B <: AnyRef](a: A, b: String) = { val c = caller; print(""); c } + def todo3[B <: List[A], @specialized(Int) A](a: A, b: B) = { val c = caller; print(""); c } + + def main(args: Array[String]) { + val s = "" + val result = + s"""|- Unspecialized type args + |// Specialized + |f1 ${f1(1,"some ref")} + |f2 ${f2(1,"some ref")} + |f3 ${f3(1,List("some ref"))} + |f4 ${f4(1,Nil)} + |f5 ${f5(1,s)} + | + |// Unspecialized type args + |f4(Boolean) ${f4(Boolean,Nil)} + |f4(String) ${f4("",Nil)} + | + |// Ideally these would be specialized + |todo1 ${todo1(1,s)} + |todo2 ${todo2(1,s)} + |todo3 ${todo3(1,List(0))}""".stripMargin + println(result) + } +} diff --git a/test/files/run/t6309.check b/test/files/run/t6309.check new file mode 100644 index 0000000000..7f8f011eb7 --- /dev/null +++ b/test/files/run/t6309.check @@ -0,0 +1 @@ +7 diff --git a/test/files/run/t6309.scala b/test/files/run/t6309.scala new file mode 100644 index 0000000000..7bbca63c2a --- /dev/null +++ b/test/files/run/t6309.scala @@ -0,0 +1,16 @@ +trait A { + def a: Int +} + +object Test { + def f(a: Int) = new { + //private val b = a + private[this] val b = a // crashes, sorry scalac + } with A { + def a = b + } + + def main(args: Array[String]) { + println(f(7).a) + } +} diff --git a/test/files/run/t6329_repl.check b/test/files/run/t6329_repl.check index 693263a5c2..3480bbdd0b 100644 --- a/test/files/run/t6329_repl.check +++ b/test/files/run/t6329_repl.check @@ -3,11 +3,37 @@ Type :help for more information. scala> -scala> classManifest[List[_]] +scala> import scala.reflect.classTag +import scala.reflect.classTag + +scala> classManifest[scala.List[_]] warning: there were 1 deprecation warning(s); re-run with -deprecation for details -res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[Any] +res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] -scala> scala.reflect.classTag[List[_]] +scala> classTag[scala.List[_]] res1: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List +scala> classManifest[scala.collection.immutable.List[_]] +warning: there were 1 deprecation warning(s); re-run with -deprecation for details +res2: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] + +scala> classTag[scala.collection.immutable.List[_]] +res3: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List + +scala> classManifest[Predef.Set[_]] +warning: there were 1 deprecation warning(s); re-run with -deprecation for details +res4: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[<?>] + +scala> classTag[Predef.Set[_]] +res5: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set + +scala> classManifest[scala.collection.immutable.Set[_]] +warning: there were 1 deprecation warning(s); re-run with -deprecation for details +res6: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[<?>] + +scala> classTag[scala.collection.immutable.Set[_]] +res7: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set + +scala> + scala> diff --git a/test/files/run/t6329_repl.scala b/test/files/run/t6329_repl.scala index add6d64962..f210d6512c 100644 --- a/test/files/run/t6329_repl.scala +++ b/test/files/run/t6329_repl.scala @@ -2,7 +2,14 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ - |classManifest[List[_]] - |scala.reflect.classTag[List[_]] - |""".stripMargin + |import scala.reflect.classTag + |classManifest[scala.List[_]] + |classTag[scala.List[_]] + |classManifest[scala.collection.immutable.List[_]] + |classTag[scala.collection.immutable.List[_]] + |classManifest[Predef.Set[_]] + |classTag[Predef.Set[_]] + |classManifest[scala.collection.immutable.Set[_]] + |classTag[scala.collection.immutable.Set[_]] + """.stripMargin } diff --git a/test/files/run/t6329_vanilla.check b/test/files/run/t6329_vanilla.check index 8282afaeba..ad8f4b5c77 100644 --- a/test/files/run/t6329_vanilla.check +++ b/test/files/run/t6329_vanilla.check @@ -1,2 +1,8 @@ -scala.collection.immutable.List[Any] +scala.collection.immutable.List[<?>] scala.collection.immutable.List +scala.collection.immutable.List[<?>] +scala.collection.immutable.List +scala.collection.immutable.Set[<?>] +scala.collection.immutable.Set +scala.collection.immutable.Set[<?>] +scala.collection.immutable.Set diff --git a/test/files/run/t6329_vanilla.scala b/test/files/run/t6329_vanilla.scala index a31cd5c72e..ec84f1f938 100644 --- a/test/files/run/t6329_vanilla.scala +++ b/test/files/run/t6329_vanilla.scala @@ -1,4 +1,13 @@ +import scala.reflect.classTag + +@deprecated("Suppress warnings", since="2.11") object Test extends App { - println(classManifest[List[_]]) - println(scala.reflect.classTag[List[_]]) -}
\ No newline at end of file + println(classManifest[scala.List[_]]) + println(classTag[scala.List[_]]) + println(classManifest[scala.collection.immutable.List[_]]) + println(classTag[scala.collection.immutable.List[_]]) + println(classManifest[Predef.Set[_]]) + println(classTag[Predef.Set[_]]) + println(classManifest[scala.collection.immutable.Set[_]]) + println(classTag[scala.collection.immutable.Set[_]]) +} diff --git a/test/files/run/t6331.scala b/test/files/run/t6331.scala index 4e43a7686e..d9d46f10ea 100644 --- a/test/files/run/t6331.scala +++ b/test/files/run/t6331.scala @@ -1,9 +1,4 @@ -import scala.tools.partest._ -import java.io._ -import scala.tools.nsc._ -import scala.tools.nsc.util.CommandLineParser -import scala.tools.nsc.{Global, Settings, CompilerCommand} -import scala.tools.nsc.reporters.ConsoleReporter +import scala.tools.partest.DirectTest // Test of Constant#equals, which must must account for floating point intricacies. object Test extends DirectTest { diff --git a/test/files/run/t6331b.scala b/test/files/run/t6331b.scala index f966abea51..3e09965ee8 100644 --- a/test/files/run/t6331b.scala +++ b/test/files/run/t6331b.scala @@ -1,12 +1,5 @@ -import scala.tools.partest._ -import java.io._ -import scala.tools.nsc._ -import scala.tools.nsc.util.CommandLineParser -import scala.tools.nsc.{Global, Settings, CompilerCommand} -import scala.tools.nsc.reporters.ConsoleReporter - import scala.tools.partest.trace -import scala.util.control.Exception._ +import scala.util.control.Exception.allCatch object Test extends App { diff --git a/test/files/run/t6381.check b/test/files/run/t6381.check new file mode 100644 index 0000000000..5070b67e46 --- /dev/null +++ b/test/files/run/t6381.check @@ -0,0 +1,17 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> import language.experimental.macros +import language.experimental.macros + +scala> def pos_impl(c: reflect.macros.Context): c.Expr[String] = + c.literal(c.enclosingPosition.getClass.toString) +pos_impl: (c: scala.reflect.macros.Context)c.Expr[String] + +scala> def pos = macro pos_impl +defined term macro pos: String + +scala> pos +res0: String = class scala.reflect.internal.util.RangePosition + +scala> diff --git a/test/files/run/t6381.scala b/test/files/run/t6381.scala new file mode 100644 index 0000000000..859ec3cb30 --- /dev/null +++ b/test/files/run/t6381.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + |import language.experimental.macros + |def pos_impl(c: reflect.macros.Context): c.Expr[String] = + | c.literal(c.enclosingPosition.getClass.toString) + |def pos = macro pos_impl + |pos + |""".stripMargin.trim + + override def extraSettings: String = "-Yrangepos" +} diff --git a/test/files/run/t6392b.check b/test/files/run/t6392b.check index e9c7ecaa34..2afc48495f 100644 --- a/test/files/run/t6392b.check +++ b/test/files/run/t6392b.check @@ -1 +1 @@ -ModuleDef(Modifiers(), newTermName("C"), Template(List(Select(Ident(scala#PK), newTypeName("AnyRef")#TPE)), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(newTypeName("C")), tpnme.EMPTY), nme.CONSTRUCTOR#PCTOR), List())), Literal(Constant(()))))))) +ModuleDef(Modifiers(), TermName("C"), Template(List(Select(Ident(scala#PK), TypeName("AnyRef")#TPE)), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(TypeName("C")), tpnme.EMPTY), nme.CONSTRUCTOR#PCTOR), List())), Literal(Constant(()))))))) diff --git a/test/files/run/t6394a/Macros_1.scala b/test/files/run/t6394a/Macros_1.scala index 3d39d3e40a..5aa07e7f41 100644 --- a/test/files/run/t6394a/Macros_1.scala +++ b/test/files/run/t6394a/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def impl(c:Context): c.Expr[Any] = { import c.universe._ - val selfTree = This(c.enclosingClass.symbol.asModule.moduleClass) + val selfTree = This(c.enclosingImpl.symbol.asModule.moduleClass) c.Expr[AnyRef](selfTree) } diff --git a/test/files/run/t6406-regextract.check b/test/files/run/t6406-regextract.check new file mode 100644 index 0000000000..88c5a52eb3 --- /dev/null +++ b/test/files/run/t6406-regextract.check @@ -0,0 +1,4 @@ +List(1, 3) +List(1, 3) +List(1, 3) +Some(2011) Some(2011) diff --git a/test/files/run/t6406-regextract.scala b/test/files/run/t6406-regextract.scala new file mode 100644 index 0000000000..83679a5167 --- /dev/null +++ b/test/files/run/t6406-regextract.scala @@ -0,0 +1,30 @@ + +object Test extends App { + import util.matching._ + import Regex._ + + val r = "(\\d+)".r + val q = """(\d)""".r + val ns = List("1,2","x","3,4") + val u = r.unanchored + + val is = ns collect { case u(x) => x } map { case r(x) => x } + println(is) + // Match from same pattern + val js = (ns map { u findFirstMatchIn _ }).flatten map { case r(x) => x } + println(js) + // Match not from same pattern + val ks = (ns map { q findFirstMatchIn _ }).flatten map { case r(x) => x } + println(ks) + + val t = "Last modified 2011-07-15" + val p1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r + val y1: Option[String] = for { + p1(year, month, day) <- p1 findFirstIn t + } yield year + val y2: Option[String] = for { + p1(year, month, day) <- p1 findFirstMatchIn t + } yield year + println(s"$y1 $y2") + +} diff --git a/test/files/run/t6439.check b/test/files/run/t6439.check index 178ea739f5..3f5f7dc8a4 100644 --- a/test/files/run/t6439.check +++ b/test/files/run/t6439.check @@ -7,7 +7,7 @@ scala> class A defined class A scala> object A // warn -defined module A +defined object A warning: previously defined class A is not a companion to object A. Companions must be defined together; you may wish to use :paste mode for this. @@ -15,15 +15,15 @@ scala> trait B defined trait B scala> object B // warn -defined module B +defined object B warning: previously defined trait B is not a companion to object B. Companions must be defined together; you may wish to use :paste mode for this. scala> object C -defined module C +defined object C scala> object Bippy -defined module Bippy +defined object Bippy scala> class C // warn defined class C @@ -40,13 +40,13 @@ scala> val D = 0 // no warn D: Int = 0 scala> object E -defined module E +defined object E scala> var E = 0 // no warn E: Int = 0 scala> object F -defined module F +defined object F scala> type F = Int // no warn defined type alias F @@ -58,7 +58,18 @@ scala> :power ** global._, definitions._ also imported ** ** Try :help, :vals, power.<tab> ** -scala> intp("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols +scala> object lookup { + import intp._ + def apply(name: String): Symbol = types(name) orElse terms(name) + def types(name: String): Symbol = replScope lookup (name: TypeName) orElse getClassIfDefined(name) + def terms(name: String): Symbol = replScope lookup (name: TermName) orElse getModuleIfDefined(name) + def types[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol + def terms[T: global.TypeTag] : Symbol = typeOf[T].termSymbol + def apply[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol +} +defined object lookup + +scala> lookup("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols res0: $r.intp.global.Symbol = type F scala> diff --git a/test/files/run/t6439.scala b/test/files/run/t6439.scala index 70a2dbafaf..175a1d134f 100644 --- a/test/files/run/t6439.scala +++ b/test/files/run/t6439.scala @@ -1,6 +1,7 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { + def code = """ class A object A // warn @@ -17,6 +18,15 @@ var E = 0 // no warn object F type F = Int // no warn :power -intp("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols +object lookup { + import intp._ + def apply(name: String): Symbol = types(name) orElse terms(name) + def types(name: String): Symbol = replScope lookup (name: TypeName) orElse getClassIfDefined(name) + def terms(name: String): Symbol = replScope lookup (name: TermName) orElse getModuleIfDefined(name) + def types[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol + def terms[T: global.TypeTag] : Symbol = typeOf[T].termSymbol + def apply[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol +} +lookup("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols """ } diff --git a/test/files/run/t6443.scala b/test/files/run/t6443.scala index 67fe2cab22..3ab8c345fe 100644 --- a/test/files/run/t6443.scala +++ b/test/files/run/t6443.scala @@ -1,3 +1,5 @@ +import scala.language.existentials + class Base class Derived extends Base diff --git a/test/files/run/t6448.check b/test/files/run/t6448.check new file mode 100644 index 0000000000..9401568319 --- /dev/null +++ b/test/files/run/t6448.check @@ -0,0 +1,32 @@ + +=List.collect= +f(1) +f(2) +List(1) + +=List.collectFirst= +f(1) +Some(1) + +=Option.collect= +f(1) +Some(1) + +=Option.collect= +f(2) +None + +=Stream.collect= +f(1) +f(2) +List(1) + +=Stream.collectFirst= +f(1) +Some(1) + +=ParVector.collect= +(ParVector(1),2) + +=ParArray.collect= +(ParArray(1),2) diff --git a/test/files/run/t6448.scala b/test/files/run/t6448.scala new file mode 100644 index 0000000000..4d1528e500 --- /dev/null +++ b/test/files/run/t6448.scala @@ -0,0 +1,61 @@ +// Tests to show that various `collect` functions avoid calling +// both `PartialFunction#isDefinedAt` and `PartialFunction#apply`. +// +object Test { + def f(i: Int) = { println("f(" + i + ")"); true } + class Counter { + var count = 0 + def apply(i: Int) = synchronized {count += 1; true} + } + + def testing(label: String)(body: => Any) { + println(s"\n=$label=") + println(body) + } + + def main(args: Array[String]) { + testing("List.collect")(List(1, 2) collect { case x if f(x) && x < 2 => x}) + testing("List.collectFirst")(List(1, 2) collectFirst { case x if f(x) && x < 2 => x}) + testing("Option.collect")(Some(1) collect { case x if f(x) && x < 2 => x}) + testing("Option.collect")(Some(2) collect { case x if f(x) && x < 2 => x}) + testing("Stream.collect")((Stream(1, 2).collect { case x if f(x) && x < 2 => x}).toList) + testing("Stream.collectFirst")(Stream.continually(1) collectFirst { case x if f(x) && x < 2 => x}) + + import collection.parallel.ParIterable + import collection.parallel.immutable.ParVector + import collection.parallel.mutable.ParArray + testing("ParVector.collect") { + val counter = new Counter() + (ParVector(1, 2) collect { case x if counter(x) && x < 2 => x}, counter.synchronized(counter.count)) + } + + testing("ParArray.collect") { + val counter = new Counter() + (ParArray(1, 2) collect { case x if counter(x) && x < 2 => x}, counter.synchronized(counter.count)) + } + + object PendingTests { + testing("Iterator.collect")((Iterator(1, 2) collect { case x if f(x) && x < 2 => x}).toList) + + testing("List.view.collect")((List(1, 2).view collect { case x if f(x) && x < 2 => x}).force) + + // This would do the trick in Future.collect, but I haven't added this yet as there is a tradeoff + // with extra allocations to consider. + // + // pf.lift(v) match { + // case Some(x) => p success x + // case None => fail(v) + // } + testing("Future.collect") { + import concurrent.ExecutionContext.Implicits.global + import concurrent.Await + import concurrent.duration.Duration + val result = concurrent.future(1) collect { case x if f(x) => x} + Await.result(result, Duration.Inf) + } + + // TODO Future.{onSuccess, onFailure, recoverWith, andThen} + } + + } +} diff --git a/test/files/run/t6467.scala b/test/files/run/t6467.scala new file mode 100644 index 0000000000..dc93b69fdc --- /dev/null +++ b/test/files/run/t6467.scala @@ -0,0 +1,20 @@ + + + + +import collection._ + + + +object Test extends App { + + def compare(s1: String, s2: String) { + assert(s1 == s2, s1 + "\nvs.\n" + s2) + } + + compare(List(1, 2, 3, 4).aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, "1234") + compare(List(1, 2, 3, 4).par.aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, "1234") + compare(Seq(0 until 100: _*).aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, (0 until 100).mkString) + compare(Seq(0 until 100: _*).par.aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, (0 until 100).mkString) + +}
\ No newline at end of file diff --git a/test/files/run/t6488.check b/test/files/run/t6488.check deleted file mode 100644 index 35821117c8..0000000000 --- a/test/files/run/t6488.check +++ /dev/null @@ -1 +0,0 @@ -Success diff --git a/test/files/run/t6488.scala b/test/files/run/t6488.scala index 487614ecfd..e234876fbe 100644 --- a/test/files/run/t6488.scala +++ b/test/files/run/t6488.scala @@ -1,11 +1,64 @@ -import sys.process._ +import scala.sys.process._ +import scala.util.Try +import scala.util.Properties.{ javaHome, javaClassPath } +import java.io.{ File, IOException } +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit._ +import java.util.concurrent.atomic._ + object Test { + /* // Program that prints "Success" if the command was successfully run then destroyed // It will silently pass if the command "/bin/ls" does not exist - // It will fail due to the uncatchable exception in t6488 race condition + // It will fail due to the uncatchable exception in t6488 race condition, + // i.e., if any uncaught exceptions on spawned threads are printed. def main(args: Array[String]) { try Process("/bin/ls").run(ProcessLogger { _ => () }).destroy catch { case _ => () } println("Success") } + */ + + // Show that no uncaught exceptions are thrown on spawned I/O threads + // when the process is destroyed. The default handler will print + // stack traces in the failing case. + def main(args: Array[String]) { + if (args.nonEmpty && args(0) == "data") + data() + else + test() // args(0) == "jvm" + } + + // fork the data spewer, wait for input, then destroy the process + def test() { + val f = new File(javaHome, "bin").listFiles.sorted filter (_.getName startsWith "java") find (_.canExecute) getOrElse { + // todo signal test runner that test is skipped + new File("/bin/ls") // innocuous + } + //Process(f.getAbsolutePath).run(ProcessLogger { _ => () }).destroy + val reading = new CountDownLatch(1) + val count = new AtomicInteger + def counted = count.get + val command = s"${f.getAbsolutePath} -classpath ${javaClassPath} Test data" + Try { + Process(command) run ProcessLogger { (s: String) => + //Console println s"[[$s]]" // java help + count.getAndIncrement + reading.countDown + Thread.`yield`() + } + } foreach { (p: Process) => + val ok = reading.await(10, SECONDS) + if (!ok) Console println "Timed out waiting for process output!" + p.destroy() + } + //Console println s"Read count $counted lines" + } + + // spew something + def data() { + def filler = "." * 100 + for (i <- 1 to 1000) + Console println s"Outputting data line $i $filler" + } } diff --git a/test/files/run/t6548.check b/test/files/run/t6548.check new file mode 100644 index 0000000000..5dfcb12e02 --- /dev/null +++ b/test/files/run/t6548.check @@ -0,0 +1,2 @@ +false +List(JavaAnnotationWithNestedEnum_1(value = VALUE)) diff --git a/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java b/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java new file mode 100644 index 0000000000..32004de537 --- /dev/null +++ b/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java @@ -0,0 +1,17 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, + ElementType.TYPE, ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +public @interface JavaAnnotationWithNestedEnum_1 +{ + public Value value() default Value.VALUE; + + public enum Value + { + VALUE; + } +}
\ No newline at end of file diff --git a/test/files/run/t6548/Test_2.scala b/test/files/run/t6548/Test_2.scala new file mode 100644 index 0000000000..7200259d36 --- /dev/null +++ b/test/files/run/t6548/Test_2.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +class Bean { + @JavaAnnotationWithNestedEnum_1(JavaAnnotationWithNestedEnum_1.Value.VALUE) + def value = 1 +} + +object Test extends App { + println(cm.staticClass("Bean").isCaseClass) + println(typeOf[Bean].declaration(TermName("value")).annotations) +} diff --git a/test/files/run/t657.scala b/test/files/run/t657.scala index a9726092e7..e76b0292dd 100644 --- a/test/files/run/t657.scala +++ b/test/files/run/t657.scala @@ -1,3 +1,5 @@ + +import scala.language.{ implicitConversions } abstract class BaseList { type Node <: NodeImpl; implicit def convertNode(ni : NodeImpl) = ni.asInstanceOf[Node]; diff --git a/test/files/run/t6572/bar_1.scala b/test/files/run/t6572/bar_1.scala deleted file mode 100644 index 5518ced7af..0000000000 --- a/test/files/run/t6572/bar_1.scala +++ /dev/null @@ -1,19 +0,0 @@ -package bar - -abstract class IntBase[V] extends Base[Int, V] - -class DefaultIntBase[V <: IntProvider] extends IntBase[V] { - override protected def hashCode(key: Int) = key -} - -trait IntProvider { - def int: Int -} - -abstract class Base[@specialized K, V] { - - protected def hashCode(key: K) = key.hashCode - - def get(key: K): V = throw new RuntimeException - -}
\ No newline at end of file diff --git a/test/files/run/t6572/foo_2.scala b/test/files/run/t6572/foo_2.scala deleted file mode 100644 index 465f0b7c3c..0000000000 --- a/test/files/run/t6572/foo_2.scala +++ /dev/null @@ -1,17 +0,0 @@ -//package foo - -import bar._ - -class FooProvider extends IntProvider { - def int = 3 -} - -class Wrapper(users: DefaultIntBase[FooProvider]) { - final def user(userId: Int) = users.get(userId) -} - -object Test { - def main(args: Array[String]) { - new Wrapper(new DefaultIntBase) - } -}
\ No newline at end of file diff --git a/test/files/run/t6574b.check b/test/files/run/t6574b.check new file mode 100644 index 0000000000..e10fa4f810 --- /dev/null +++ b/test/files/run/t6574b.check @@ -0,0 +1 @@ +List(5, 4, 3, 2, 1) diff --git a/test/files/run/t6574b.scala b/test/files/run/t6574b.scala new file mode 100644 index 0000000000..df329a31ca --- /dev/null +++ b/test/files/run/t6574b.scala @@ -0,0 +1,7 @@ +object Test extends App { + implicit class AnyOps(val i: Int) extends AnyVal { + private def parentsOf(x: Int): List[Int] = if (x == 0) Nil else x :: parentsOf(x - 1) + def parents: List[Int] = parentsOf(i) + } + println((5).parents) +} diff --git a/test/files/run/t6591_1.check b/test/files/run/t6591_1.check index b6cb6c286d..d1d448f283 100644 --- a/test/files/run/t6591_1.check +++ b/test/files/run/t6591_1.check @@ -1 +1 @@ -Block(List(ValDef(Modifiers(), newTermName("v"), Select(Ident(A), newTypeName("I")), Select(Ident(A), newTermName("impl")))), Ident(newTermName("v"))) +Block(List(ValDef(Modifiers(), TermName("v"), Select(Ident(A), TypeName("I")), Select(Ident(A), TermName("impl")))), Ident(TermName("v"))) diff --git a/test/files/run/t6591_2.check b/test/files/run/t6591_2.check index b2d5797cbf..8c972ef920 100644 --- a/test/files/run/t6591_2.check +++ b/test/files/run/t6591_2.check @@ -1 +1 @@ -Block(List(ValDef(Modifiers(), newTermName("v"), SelectFromTypeTree(Ident(A), newTypeName("I")), Select(Apply(Select(New(Ident(A)), nme.CONSTRUCTOR), List()), newTermName("impl")))), Ident(newTermName("v"))) +Block(List(ValDef(Modifiers(), TermName("v"), SelectFromTypeTree(Ident(A), TypeName("I")), Select(Apply(Select(New(Ident(A)), nme.CONSTRUCTOR), List()), TermName("impl")))), Ident(TermName("v"))) diff --git a/test/files/run/t6591_3.check b/test/files/run/t6591_3.check index a7b594ba65..f4592adce9 100644 --- a/test/files/run/t6591_3.check +++ b/test/files/run/t6591_3.check @@ -1 +1 @@ -Block(List(ValDef(Modifiers(), newTermName("v"), Select(This(newTypeName("A")), newTypeName("I")), Apply(Select(New(Select(This(newTypeName("A")), newTypeName("I"))), nme.CONSTRUCTOR), List()))), Ident(newTermName("v"))) +Block(List(ValDef(Modifiers(), TermName("v"), Select(This(TypeName("A")), TypeName("I")), Apply(Select(New(Select(This(TypeName("A")), TypeName("I"))), nme.CONSTRUCTOR), List()))), Ident(TermName("v"))) diff --git a/test/files/run/t6591_5.check b/test/files/run/t6591_5.check index e0b6d06e6b..4ebc2236af 100644 --- a/test/files/run/t6591_5.check +++ b/test/files/run/t6591_5.check @@ -1 +1 @@ -Expr(Block(List(ValDef(Modifiers(), newTermName("v"), Select(Select(This(newTypeName("A")), newTermName("x")), newTypeName("I")), Select(Ident(scala.Predef), newTermName("$qmark$qmark$qmark")))), Ident(newTermName("v")))) +Expr(Block(List(ValDef(Modifiers(), TermName("v"), Select(Select(This(TypeName("A")), TermName("x")), TypeName("I")), Select(Ident(scala.Predef), TermName("$qmark$qmark$qmark")))), Ident(TermName("v")))) diff --git a/test/files/run/t6591_6.check b/test/files/run/t6591_6.check index 0c4847b628..940e2026fe 100644 --- a/test/files/run/t6591_6.check +++ b/test/files/run/t6591_6.check @@ -1 +1 @@ -Expr(Block(List(ValDef(Modifiers(), newTermName("v"), Select(Select(Ident(newTermName("A")), newTermName("x")), newTypeName("I")), Select(Ident(scala.Predef), newTermName("$qmark$qmark$qmark")))), Ident(newTermName("v")))) +Expr(Block(List(ValDef(Modifiers(), TermName("v"), Select(Select(Ident(TermName("A")), TermName("x")), TypeName("I")), Select(Ident(scala.Predef), TermName("$qmark$qmark$qmark")))), Ident(TermName("v")))) diff --git a/test/files/run/t6608.check b/test/files/run/t6608.check new file mode 100644 index 0000000000..15628b322e --- /dev/null +++ b/test/files/run/t6608.check @@ -0,0 +1 @@ +(C$$yyy,true) diff --git a/test/files/run/t6608.scala b/test/files/run/t6608.scala new file mode 100644 index 0000000000..2f956bfb35 --- /dev/null +++ b/test/files/run/t6608.scala @@ -0,0 +1,16 @@ +import reflect.runtime.universe + +class C { + private val yyy: Any = 1 + @inline def foo = yyy +} + +object Test extends App { + import universe._ + val access = typeOf[C].declarations + .toList + .filter(_.name.toString.endsWith("yyy")) + .map(x => (x.name, x.isPrivate)) + println(access.head) +} + diff --git a/test/files/run/t6611.scala b/test/files/run/t6611.scala index 0947a48f90..c295368aea 100644 --- a/test/files/run/t6611.scala +++ b/test/files/run/t6611.scala @@ -7,55 +7,55 @@ object Test extends App { locally { val a = Array("1": Object) - val a2 = Array[Object](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(true) - val a2 = Array[Boolean](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1: Short) - val a2 = Array[Short](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1: Byte) - val a2 = Array[Byte](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1) - val a2 = Array[Int](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1L) - val a2 = Array[Long](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1f) - val a2 = Array[Float](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1d) - val a2 = Array[Double](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(()) - val a2 = Array[Unit](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } } diff --git a/test/files/run/t6646.check b/test/files/run/t6646.check index b0b7ad32f3..15715dae91 100644 --- a/test/files/run/t6646.check +++ b/test/files/run/t6646.check @@ -1,4 +1,4 @@ -Found NotNull +Found NoNull Found lower Found 2 A single ident is always a pattern diff --git a/test/files/run/t6646.scala b/test/files/run/t6646.scala index 150b0df11e..a377ac274e 100644 --- a/test/files/run/t6646.scala +++ b/test/files/run/t6646.scala @@ -1,14 +1,14 @@ sealed trait ColumnOption -case object NotNull extends ColumnOption +case object NoNull extends ColumnOption case object PrimaryKey extends ColumnOption case object lower extends ColumnOption object Test { def main(args: Array[String]) { - val l = List(PrimaryKey, NotNull, lower) + val l = List(PrimaryKey, NoNull, lower) // withFilter must be generated in these - for (option @ NotNull <- l) println("Found " + option) + for (option @ NoNull <- l) println("Found " + option) for (option @ `lower` <- l) println("Found " + option) for ((`lower`, i) <- l.zipWithIndex) println("Found " + i) diff --git a/test/files/run/t6690.scala b/test/files/run/t6690.scala index 43ede967a0..15b1817e87 100644 --- a/test/files/run/t6690.scala +++ b/test/files/run/t6690.scala @@ -1,5 +1,7 @@ import scala.collection.mutable +import scala.language.{ reflectiveCalls } + object Test extends App { def last0(ml: mutable.MutableList[Int]) = ml.asInstanceOf[{def last0: mutable.LinkedList[Int]}].last0 diff --git a/test/files/run/t6731.scala b/test/files/run/t6731.scala index 89d212e91e..12357b935e 100644 --- a/test/files/run/t6731.scala +++ b/test/files/run/t6731.scala @@ -12,7 +12,7 @@ abstract class MonoDynamic extends Dynamic { def applyDynamic(name: String)(args: Any*): String = show(this + "." + name + mkArgs(args: _*)) def applyDynamicNamed(name: String)(args: (String, Any)*): String = show(this + "." + name + mkArgs(args: _*)) - override def toString = this.getClass.getName split '.' last + override def toString = (this.getClass.getName split '.').last } object Mono extends MonoDynamic { diff --git a/test/files/run/t6745-2.scala b/test/files/run/t6745-2.scala new file mode 100644 index 0000000000..31ecd42bd1 --- /dev/null +++ b/test/files/run/t6745-2.scala @@ -0,0 +1,22 @@ +import scala.tools.nsc._ +import scala.tools.partest.CompilerTest +import scala.collection.{ mutable, immutable, generic } + +object Test extends CompilerTest { + import global._ + import rootMirror._ + import definitions._ + import global.analyzer.{Context, ImportInfo} + + override def code = """ +package context { +} + """ + + def check(source: String, unit: global.CompilationUnit) = { + val context: Context = global.analyzer.rootContext(unit) + val importInfo: ImportInfo = context.imports.head // Predef._ + val importedSym = importInfo.importedSymbol(nme.CONSTRUCTOR) + assert(importedSym == NoSymbol, importedSym) // was "constructor Predef" + } +} diff --git a/test/files/run/t6860.check b/test/files/run/t6860.check new file mode 100644 index 0000000000..c96331f540 --- /dev/null +++ b/test/files/run/t6860.check @@ -0,0 +1,4 @@ +Bippy[String] +Bippy[String] +throws[Nothing] +throws[RuntimeException] diff --git a/test/files/run/t6860.scala b/test/files/run/t6860.scala new file mode 100644 index 0000000000..2dcc2a67f7 --- /dev/null +++ b/test/files/run/t6860.scala @@ -0,0 +1,20 @@ +class Bippy[T](val value: T) extends annotation.StaticAnnotation + +class A { + @Bippy("hi") def f1: Int = 1 + @Bippy[String]("hi") def f2: Int = 2 + + @throws("what do I throw?") def f3 = throw new RuntimeException + @throws[RuntimeException]("that's good to know!") def f4 = throw new RuntimeException +} + +object Test { + import scala.reflect.runtime.universe._ + + def main(args: Array[String]): Unit = { + val members = typeOf[A].declarations.toList + val tpes = members flatMap (_.annotations) map (_.tpe) + + tpes.map(_.toString).sorted foreach println + } +} diff --git a/test/files/run/t6863.check b/test/files/run/t6863.check new file mode 100644 index 0000000000..030cb8b265 --- /dev/null +++ b/test/files/run/t6863.check @@ -0,0 +1,12 @@ +t6863.scala:38: warning: comparing values of types Unit and Unit using `==' will always yield true + assert({ () => x}.apply == ()) + ^ +t6863.scala:42: warning: comparing values of types Unit and Unit using `==' will always yield true + assert({ () => x}.apply == ()) + ^ +t6863.scala:46: warning: comparing values of types Unit and Unit using `==' will always yield true + assert({ () => x}.apply == ()) + ^ +t6863.scala:59: warning: comparing values of types Unit and Unit using `==' will always yield true + assert({ () => x }.apply == ()) + ^ diff --git a/test/files/run/t6863.scala b/test/files/run/t6863.scala index d77adb6af4..c4f3c2c885 100644 --- a/test/files/run/t6863.scala +++ b/test/files/run/t6863.scala @@ -51,7 +51,7 @@ object Test { assert({ () => x }.apply == "42") } def tryCatch() = { - var x = try { "42" } catch { case _ => "43" } + var x = try { "42" } catch { case _: Throwable => "43" } assert({ () => x }.apply == "42") } def `if`() = { @@ -85,7 +85,7 @@ object Test { def nested() = { var x = { val y = 42 - if(true) try "42" catch {case _ => "43"} + if(true) try "42" catch {case _: Throwable => "43"} else "44" } assert({ () => x }.apply == "42") diff --git a/test/files/run/t6939.scala b/test/files/run/t6939.scala new file mode 100644 index 0000000000..9fe721555f --- /dev/null +++ b/test/files/run/t6939.scala @@ -0,0 +1,13 @@ +object Test extends App { + val foo = <x:foo xmlns:x="http://foo.com/"><x:bar xmlns:x="http://bar.com/"><x:baz/></x:bar></x:foo> + assert(foo.child.head.scope.toString == """ xmlns:x="http://bar.com/"""") + + val fooDefault = <foo xmlns="http://foo.com/"><bar xmlns="http://bar.com/"><baz/></bar></foo> + assert(fooDefault.child.head.scope.toString == """ xmlns="http://bar.com/"""") + + val foo2 = scala.xml.XML.loadString("""<x:foo xmlns:x="http://foo.com/"><x:bar xmlns:x="http://bar.com/"><x:baz/></x:bar></x:foo>""") + assert(foo2.child.head.scope.toString == """ xmlns:x="http://bar.com/"""") + + val foo2Default = scala.xml.XML.loadString("""<foo xmlns="http://foo.com/"><bar xmlns="http://bar.com/"><baz/></bar></foo>""") + assert(foo2Default.child.head.scope.toString == """ xmlns="http://bar.com/"""") +} diff --git a/test/files/run/t6955.scala b/test/files/run/t6955.scala index 2610acdec4..980aa420cc 100644 --- a/test/files/run/t6955.scala +++ b/test/files/run/t6955.scala @@ -1,5 +1,6 @@ import scala.tools.partest.IcodeTest +// this class should compile to code that uses switches (twice) class Switches { type Tag = Byte @@ -10,7 +11,8 @@ class Switches { case _ => 0 } - def switchOkay(i: Byte): Int = i match { // notice type of i is Byte + // this worked before, should keep working + def switchOkay(i: Byte): Int = i match { case 1 => 1 case 2 => 2 case 3 => 3 diff --git a/test/files/run/t6969.scala b/test/files/run/t6969.scala index 8cfc28c1e5..c4561b4424 100644 --- a/test/files/run/t6969.scala +++ b/test/files/run/t6969.scala @@ -1,3 +1,7 @@ + + +import scala.language.{ reflectiveCalls } + object Test { private type Clearable = { def clear(): Unit } private def choke() = { diff --git a/test/files/run/t7008-scala-defined.flags b/test/files/run/t7008-scala-defined.flags new file mode 100644 index 0000000000..49f2d2c4c8 --- /dev/null +++ b/test/files/run/t7008-scala-defined.flags @@ -0,0 +1 @@ +-Ybackend:GenASM diff --git a/test/files/run/t7015.check b/test/files/run/t7015.check new file mode 100644 index 0000000000..7651fe06b0 --- /dev/null +++ b/test/files/run/t7015.check @@ -0,0 +1,11 @@ +Method returns Null type: null +Method takes non Null type: null +call through method null +call through bridge null +fetch field: null +fetch field on companion: null +fetch local: null +fetch array element: null +method that takes object: null +method that takes anyref: null +method that takes any: null diff --git a/test/files/run/t7015.scala b/test/files/run/t7015.scala new file mode 100644 index 0000000000..37a73a9fc4 --- /dev/null +++ b/test/files/run/t7015.scala @@ -0,0 +1,49 @@ +object Test { + def main(args : Array[String]) : Unit = { + println(s"Method returns Null type: $f") + println(s"Method takes non Null type: ${g(null)}") + + // pass things through the g function because it expects + // a string. If we haven't adapted properly then we'll + // get verify errors + val b = new B + println(s"call through method ${g(b.f(null))}") + println(s"call through bridge ${g((b: A).f(null))}") + + println(s"fetch field: ${g(b.nullField)}") + println(s"fetch field on companion: ${g(B.nullCompanionField)}") + + val x = f + println(s"fetch local: ${g(x)}") + + val nulls = Array(f, f, f) + println(s"fetch array element: ${g(nulls(0))}") + + println(s"method that takes object: ${q(f)}") + println(s"method that takes anyref: ${r(f)}") + println(s"method that takes any: ${s(f)}") + } + + def f: Null = null + + def g(x: String) = x + + def q(x: java.lang.Object) = x + def r(x: AnyRef) = x + def s(x: Any) = x +} + +abstract class A { + def f(x: String): String +} + +class B extends A { + val nullField = null + + // this forces a bridge method because the return type is different + override def f(x: String) : Null = null +} + +object B { + val nullCompanionField = null +}
\ No newline at end of file diff --git a/test/files/run/t7047.check b/test/files/run/t7047.check index e69de29bb2..32bd581094 100644 --- a/test/files/run/t7047.check +++ b/test/files/run/t7047.check @@ -0,0 +1,3 @@ +Test_2.scala:2: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + Macros.foo + ^ diff --git a/test/files/run/t7064-old-style-supercalls.scala b/test/files/run/t7064-old-style-supercalls.scala deleted file mode 100644 index cffa7b1888..0000000000 --- a/test/files/run/t7064-old-style-supercalls.scala +++ /dev/null @@ -1,48 +0,0 @@ -import scala.reflect.runtime.universe._ -import Flag._ -import definitions._ -import scala.reflect.runtime.{currentMirror => cm} -import scala.tools.reflect.ToolBox -import scala.tools.reflect.Eval - -object Test extends App { - val PARAMACCESSOR = (1L << 29).asInstanceOf[FlagSet] - - // these trees can be acquired by running the following incantation: - // echo 'class C(val x: Int); class D extends C(2)' > foo.scala - // ./scalac -Xprint:parser -Yshow-trees-stringified -Yshow-trees-compact foo.scala - - val c = ClassDef( - Modifiers(), newTypeName("C"), List(), - Template( - List(Select(Ident(ScalaPackage), newTypeName("AnyRef"))), - emptyValDef, - List( - ValDef(Modifiers(PARAMACCESSOR), newTermName("x"), Ident(newTypeName("Int")), EmptyTree), - DefDef( - Modifiers(), - nme.CONSTRUCTOR, - List(), - List(List(ValDef(Modifiers(PARAM | PARAMACCESSOR), newTermName("x"), Ident(newTypeName("Int")), EmptyTree))), - TypeTree(), - Block( - List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), - Literal(Constant(()))))))) - val d = ClassDef( - Modifiers(), newTypeName("D"), List(), - Template( - List(Ident(newTypeName("C"))), - emptyValDef, - List( - DefDef( - Modifiers(), - nme.CONSTRUCTOR, - List(), - List(List()), - TypeTree(), - Block( - List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List(Literal(Constant(2))))), - Literal(Constant(()))))))) - val result = Select(Apply(Select(New(Ident(newTypeName("D"))), nme.CONSTRUCTOR), List()), newTermName("x")) - println(cm.mkToolBox().eval(Block(List(c, d), result))) -}
\ No newline at end of file diff --git a/test/files/run/t7064-old-style-supercalls.check b/test/files/run/t7088.check index 0cfbf08886..1191247b6d 100644 --- a/test/files/run/t7064-old-style-supercalls.check +++ b/test/files/run/t7088.check @@ -1 +1,2 @@ +1 2 diff --git a/test/files/run/t7088.scala b/test/files/run/t7088.scala new file mode 100644 index 0000000000..5f0114b940 --- /dev/null +++ b/test/files/run/t7088.scala @@ -0,0 +1,13 @@ +object Test { + type Tag[X] = {type Tag = X} + type TaggedArray[T] = Array[T] with Tag[Any] + + def method[T: scala.reflect.ClassTag](a: TaggedArray[T], value: T) { + a.update(0, value) + a foreach println + } + + def main(args: Array[String]): Unit = { + method(Array(1, 2).asInstanceOf[TaggedArray[Int]], 1) + } +} diff --git a/test/files/run/t7096.scala b/test/files/run/t7096.scala index e9c0323c2e..2495102899 100644 --- a/test/files/run/t7096.scala +++ b/test/files/run/t7096.scala @@ -1,3 +1,6 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import scala.tools.partest._ import scala.tools.nsc._ @@ -23,7 +26,7 @@ class Sub extends Base { import syms._ def check(source: String, unit: global.CompilationUnit) { - afterTyper { + exitingTyper { terms.filter(_.name.toString == "foo").foreach(sym => { val xParam = sym.tpe.paramss.flatten.head val annot = sym.tpe.finalResultType.annotations.head diff --git a/test/files/run/t7120.check b/test/files/run/t7120.check new file mode 100644 index 0000000000..45a4fb75db --- /dev/null +++ b/test/files/run/t7120.check @@ -0,0 +1 @@ +8 diff --git a/test/files/run/t7120/Base_1.scala b/test/files/run/t7120/Base_1.scala new file mode 100644 index 0000000000..be07b4f34f --- /dev/null +++ b/test/files/run/t7120/Base_1.scala @@ -0,0 +1,10 @@ +// This bug doesn't depend on separate compilation, +// in the interests of minimizing the log output during +// debugging this problem, I've split the compilation. + +case class Container( v: String ) + +trait Base[ T <: AnyRef ] { + type UserType = T + protected def defect: PartialFunction[ UserType, String ] +} diff --git a/test/files/run/t7120/Derived_2.scala b/test/files/run/t7120/Derived_2.scala new file mode 100644 index 0000000000..e0de629f82 --- /dev/null +++ b/test/files/run/t7120/Derived_2.scala @@ -0,0 +1,9 @@ +trait Derived extends Base[ Container ] { + protected def defect = { case c: Container => c.v.toString } +} + +// Erasure was ignoring the prefix `Derived#7001.this` when erasing +// A1, and consequently used `Object` rather than `Container`, which +// was only seen because that signature clashed with the bridge method. +// +// applyOrElse[A1 <: Derived#7001.this.UserType#7318, B1 >: String](x1: A1) diff --git a/test/files/run/t7120/Run_3.scala b/test/files/run/t7120/Run_3.scala new file mode 100644 index 0000000000..95e7f994ff --- /dev/null +++ b/test/files/run/t7120/Run_3.scala @@ -0,0 +1,3 @@ +object Test extends Derived with App { + println( defect( Container( "8" ) ) ) +} diff --git a/test/files/run/t7120b.check b/test/files/run/t7120b.check new file mode 100644 index 0000000000..aa2f5e7c9f --- /dev/null +++ b/test/files/run/t7120b.check @@ -0,0 +1,2 @@ +public int C$D.foo(java.lang.String) +public int C$D.foo(java.lang.String) diff --git a/test/files/run/t7120b.scala b/test/files/run/t7120b.scala new file mode 100644 index 0000000000..0be4eb70a7 --- /dev/null +++ b/test/files/run/t7120b.scala @@ -0,0 +1,30 @@ + +import scala.language.higherKinds + +trait Base[A] { type B = A; } +class C extends Base[String] { + class D { + def foo[B1 <: B](b: B1) = 0 + } +} + +trait BaseHK[M[_], A] { type B = M[A]; } +object BaseHK { type Id[X] = X } +class CHK extends BaseHK[BaseHK.Id, String] { + class D { + def foo[B1 <: B](b: B1) = 0 + } +} + + +object Test extends App { + val c = new C + val d = new c.D() + val meth = d.getClass.getMethods.find(_.getName == "foo").get + println(meth) + + val chk = new CHK + val dhk = new chk.D() + val methhk = d.getClass.getMethods.find(_.getName == "foo").get + println(methhk) +} diff --git a/test/files/run/t7151.check b/test/files/run/t7151.check new file mode 100644 index 0000000000..d532d9589f --- /dev/null +++ b/test/files/run/t7151.check @@ -0,0 +1,6 @@ +class Test$InnerObject$ isFinal = false +class Test$InnerCase isFinal = true +class Test$InnerNonCase isFinal = true +class TopLevelObject$ isFinal = true +class TopLevelCase isFinal = true +class TopLevelNonCase isFinal = true diff --git a/test/files/run/t7151.scala b/test/files/run/t7151.scala new file mode 100644 index 0000000000..f6492ba43c --- /dev/null +++ b/test/files/run/t7151.scala @@ -0,0 +1,24 @@ +import java.lang.reflect.Modifier.isFinal + +object Test { + object InnerObject + final case class InnerCase() + final class InnerNonCase() + + def main(args: Array[String]) { + def checkFinal(clazz: Class[_]) = + println(s"${clazz} isFinal = ${isFinal(clazz.getModifiers())}") + + checkFinal(InnerObject.getClass) + checkFinal(classOf[InnerCase]) + checkFinal(classOf[InnerNonCase]) + + checkFinal(TopLevelObject.getClass) + checkFinal(classOf[TopLevelCase]) + checkFinal(classOf[TopLevelNonCase]) + } +} + +object TopLevelObject +final case class TopLevelCase() +final case class TopLevelNonCase() diff --git a/test/files/run/t7157.check b/test/files/run/t7157.check new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/test/files/run/t7157.check @@ -0,0 +1 @@ +1 diff --git a/test/files/run/t7157/Impls_Macros_1.scala b/test/files/run/t7157/Impls_Macros_1.scala new file mode 100644 index 0000000000..ad3d96eb85 --- /dev/null +++ b/test/files/run/t7157/Impls_Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Macros { + object AImpl { + def a(ctx: Context)(args: ctx.Expr[Any]*): ctx.Expr[Unit] = { + import ctx.universe._ + ctx.Expr[Unit](Apply(Ident(TermName("println")), List(Literal(Constant(1))))) + } + } + + implicit class A(context: StringContext) { + def a(args: Any*): Unit = macro AImpl.a + } +}
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-b/Test_2.scala b/test/files/run/t7157/Test_2.scala index 7dffc5107d..cceb5ca177 100644 --- a/test/files/run/macro-def-path-dependent-b/Test_2.scala +++ b/test/files/run/t7157/Test_2.scala @@ -1,3 +1,5 @@ +import Macros._ + object Test extends App { - println("it works") + a"" }
\ No newline at end of file diff --git a/test/files/run/t7171.check b/test/files/run/t7171.check new file mode 100644 index 0000000000..d826f6cb94 --- /dev/null +++ b/test/files/run/t7171.check @@ -0,0 +1,3 @@ +t7171.scala:2: warning: The outer reference in this type test cannot be checked at run time. + final case class A() + ^ diff --git a/test/files/run/t7171.flags b/test/files/run/t7171.flags new file mode 100644 index 0000000000..c02e5f2461 --- /dev/null +++ b/test/files/run/t7171.flags @@ -0,0 +1 @@ +-unchecked diff --git a/test/files/run/t7171.scala b/test/files/run/t7171.scala index 97585b9860..e0a1192228 100644 --- a/test/files/run/t7171.scala +++ b/test/files/run/t7171.scala @@ -16,7 +16,7 @@ object Test extends App { val a1 = new t1.A() val a2 = new t1.A() assert(t1.foo(a1)) - // as noted in the unchecked warning (tested in the corresponding neg test), + // as noted in the unchecked warning (also tested in the corresponding neg test), // the outer pointer isn't checked assert(t1.foo(a2)) } diff --git a/test/files/run/t7181.check b/test/files/run/t7181.check new file mode 100644 index 0000000000..e4b8e30dfe --- /dev/null +++ b/test/files/run/t7181.check @@ -0,0 +1,23 @@ +normal exit MainNormalExit +finally MainNormalExit +normal flow MainNormalExit + +return MainReturn +finally MainReturn + +uncaught exception MainUncaughtException +finally MainUncaughtException + +caught exception ExceptionNormalExit +normal exit ExceptionNormalExit +finally ExceptionNormalExit +normal flow ExceptionNormalExit + +caught exception ExceptionReturn +return ExceptionReturn +finally ExceptionReturn + +caught exception ExceptionUncaughtException +uncaught exception ExceptionUncaughtException +finally ExceptionUncaughtException + diff --git a/test/files/run/t7181.scala b/test/files/run/t7181.scala new file mode 100644 index 0000000000..a055e43481 --- /dev/null +++ b/test/files/run/t7181.scala @@ -0,0 +1,78 @@ +sealed abstract class Action +// exit the try body normally +case object MainNormalExit extends Action +// exit the try body with a 'return' +case object MainReturn extends Action +// exit the try body with an uncaught exception +case object MainUncaughtException extends Action +// exit the try body with a caught exception and exit the exception handler normally +case object ExceptionNormalExit extends Action +// exit the try body with a caught exception and exit the exception handler with a 'return' +case object ExceptionReturn extends Action +// exit the try body with a caught exception and exit the exception handler with an uncaught exception +case object ExceptionUncaughtException extends Action + +case class UncaughtException(action: Action) extends RuntimeException +case class CaughtException(action: Action) extends RuntimeException + +object Test extends App { + def test(action: Action, expectException: Boolean = false) { + var gotException = false + val result = try + driver(action) + catch { + case UncaughtException(a) => + gotException = true + a + } + if (gotException) assert(expectException, "Got unexpected exception") + else assert(!expectException, "Did not get expected exception") + + assert(result == action, s"Expected $action but got $result") + println() + } + + def driver(action: Action): Action = { + val result = try { + action match { + case MainNormalExit => + println(s"normal exit $action") + action + case MainReturn => + println(s"return $action") + return action + case MainUncaughtException => + println(s"uncaught exception $action") + throw UncaughtException(action) + case _ => + println(s"caught exception $action") + throw CaughtException(action) + } + } catch { + case CaughtException(action) => action match { + case ExceptionNormalExit => + println(s"normal exit $action") + action + case ExceptionReturn => + println(s"return $action") + return action + case ExceptionUncaughtException => + println(s"uncaught exception $action") + throw UncaughtException(action) + case _ => + sys.error(s"unexpected $action in exception handler") + } + } finally { + println(s"finally $action") + } + println(s"normal flow $action") + result + } + + test(MainNormalExit) + test(MainReturn) + test(MainUncaughtException, true) + test(ExceptionNormalExit) + test(ExceptionReturn) + test(ExceptionUncaughtException, true) +} diff --git a/test/files/run/t7185.check b/test/files/run/t7185.check index 455c1aa3b7..f95910ba5f 100644 --- a/test/files/run/t7185.check +++ b/test/files/run/t7185.check @@ -10,7 +10,7 @@ scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ scala> object O { def apply() = 0 } -defined module O +defined object O scala> val ORef = reify { O }.tree ORef: reflect.runtime.universe.Tree = $read.O diff --git a/test/files/run/t7198.check b/test/files/run/t7198.check new file mode 100644 index 0000000000..6dad496f49 --- /dev/null +++ b/test/files/run/t7198.check @@ -0,0 +1,2 @@ +The quick brown fox jumped +And ran away with the vixen. diff --git a/test/files/run/t7198.scala b/test/files/run/t7198.scala new file mode 100644 index 0000000000..26e1d8805a --- /dev/null +++ b/test/files/run/t7198.scala @@ -0,0 +1,9 @@ +/* spew a few lines + * filter: Over the moon + */ +object Test extends App { + Console println "The quick brown fox jumped" + Console println "Over the moon" + Console println "And ran away with the vixen." + Console println "Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 28)." +} diff --git a/test/files/run/t7231.check b/test/files/run/t7231.check new file mode 100644 index 0000000000..c1e4b6c175 --- /dev/null +++ b/test/files/run/t7231.check @@ -0,0 +1,2 @@ +null +null diff --git a/test/files/run/t7231.scala b/test/files/run/t7231.scala new file mode 100644 index 0000000000..7d6bc81f3f --- /dev/null +++ b/test/files/run/t7231.scala @@ -0,0 +1,11 @@ +object Test extends App { + val bar: Null = null + + def foo(x: Array[Int]) = x + def baz(x: String) = x + + // first line was failing + println(foo(bar)) + // this line worked but good to have a double check + println(baz(bar)) +}
\ No newline at end of file diff --git a/test/files/run/t7240/Test_2.scala b/test/files/run/t7240/Test_2.scala index 2450bdabf9..5cc2cc7f78 100644 --- a/test/files/run/t7240/Test_2.scala +++ b/test/files/run/t7240/Test_2.scala @@ -1,3 +1,3 @@ object Test extends App { - bakery.Bakery.failure -}
\ No newline at end of file + val v = bakery.Bakery.failure +} diff --git a/test/files/run/t7271.check b/test/files/run/t7271.check index dcd828a307..f7a23018ca 100644 --- a/test/files/run/t7271.check +++ b/test/files/run/t7271.check @@ -1,12 +1,12 @@ [[syntax trees at end of parser]] // newSource1.scala -[0:91]package [0:0]<empty> { - [0:91]class C extends [8:91][91]scala.AnyRef { +[6]package [6]<empty> { + [6]class C extends [8][91]scala.AnyRef { [8]def <init>() = [8]{ - [8][8][8]super.<init>(); + [NoPosition][NoPosition][NoPosition]super.<init>(); [8]() }; - [16:44]def quote = [28:44]<28:44><28:44>[28]StringContext([30:34]"foo", [40:44]"baz").s([35:39]this); - [51:85]def tripleQuote = [69:85]<69:85><69:85>[69]StringContext([71:75]"foo", [81:85]"baz").s([76:80]this) + [20]def quote = [28][28][28][28]StringContext([30]"foo", [40]"baz").s([35]this); + [55]def tripleQuote = [69][69][69][69]StringContext([71]"foo", [81]"baz").s([76]this) } } diff --git a/test/files/run/t7271.scala b/test/files/run/t7271.scala index 6fccf14d20..69d5ea377e 100644 --- a/test/files/run/t7271.scala +++ b/test/files/run/t7271.scala @@ -1,9 +1,9 @@ import scala.tools.partest._ -import java.io._ import scala.tools.nsc._ -import scala.tools.nsc.util.CommandLineParser +import scala.tools.cmd.CommandLineParser import scala.tools.nsc.{Global, Settings, CompilerCommand} import scala.tools.nsc.reporters.ConsoleReporter +import scala.reflect.internal.Positions object Test extends DirectTest { @@ -29,6 +29,6 @@ object Test extends DirectTest { val settings = new Settings() settings.Xprintpos.value = true val command = new CompilerCommand((CommandLineParser tokenize extraSettings) ++ args.toList, settings) - new Global(command.settings, new ConsoleReporter(settings)) with interactive.RangePositions + new Global(command.settings, new ConsoleReporter(settings)) with Positions } } diff --git a/test/files/run/t7290.check b/test/files/run/t7290.check new file mode 100644 index 0000000000..aff48abd4a --- /dev/null +++ b/test/files/run/t7290.check @@ -0,0 +1,6 @@ +t7290.scala:4: warning: Pattern contains duplicate alternatives: 0 + case 0 | 0 => 0 + ^ +t7290.scala:5: warning: Pattern contains duplicate alternatives: 2, 3 + case 2 | 2 | 2 | 3 | 2 | 3 => 0 + ^ diff --git a/test/files/run/t7291b.check b/test/files/run/t7291.check index c07ba986a3..c07ba986a3 100644 --- a/test/files/run/t7291b.check +++ b/test/files/run/t7291.check diff --git a/test/files/run/t7291b.scala b/test/files/run/t7291.scala index 30c4261a81..d996c615ce 100644 --- a/test/files/run/t7291b.scala +++ b/test/files/run/t7291.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds, implicitConversions } + trait Fooable[T] object Fooable { implicit def conjure[T]: Fooable[T] = { diff --git a/test/files/run/t7291a.check b/test/files/run/t7291a.check deleted file mode 100644 index 126faa15b4..0000000000 --- a/test/files/run/t7291a.check +++ /dev/null @@ -1 +0,0 @@ -conjure diff --git a/test/files/run/t7291a.scala b/test/files/run/t7291a.scala deleted file mode 100644 index 4b7c4a4184..0000000000 --- a/test/files/run/t7291a.scala +++ /dev/null @@ -1,19 +0,0 @@ -trait Fooable[T] -object Fooable { - implicit def conjure[T]: Fooable[T] = { - println("conjure") - new Fooable[T]{} - } - -} - -object Test { - implicit def traversable[T, Coll[_] <: Traversable[_]](implicit -elem: Fooable[T]): Fooable[Coll[T]] = { - println("traversable") - new Fooable[Coll[T]]{} - } - def main(args: Array[String]) { - implicitly[Fooable[List[Any]]] - } -} diff --git a/test/files/run/t7291b.flags b/test/files/run/t7291b.flags deleted file mode 100644 index d564f2b1f8..0000000000 --- a/test/files/run/t7291b.flags +++ /dev/null @@ -1 +0,0 @@ --Xdivergence211
\ No newline at end of file diff --git a/test/files/run/t7300.check b/test/files/run/t7300.check new file mode 100644 index 0000000000..51993f072d --- /dev/null +++ b/test/files/run/t7300.check @@ -0,0 +1,2 @@ +2 +2 diff --git a/test/files/run/t7300.scala b/test/files/run/t7300.scala new file mode 100644 index 0000000000..ec841690df --- /dev/null +++ b/test/files/run/t7300.scala @@ -0,0 +1,11 @@ +object Test extends App { + // single line comment in multi line comment + /*//*/ val x = 1 */*/ + val x = 2 + println(x) + + // single line comment in nested multi line comment + /*/*//*/ val y = 1 */*/*/ + val y = 2 + println(y) +} diff --git a/test/files/run/t7319.check b/test/files/run/t7319.check index 966736915e..b5081f2d00 100644 --- a/test/files/run/t7319.check +++ b/test/files/run/t7319.check @@ -32,7 +32,14 @@ argument expression's type is not compatible with formal parameter type; convert(Some[Int](0)) ^ +scala> Range(1,2).toArray: Seq[_] +<console>:11: error: polymorphic expression cannot be instantiated to expected type; + found : [B >: Int]Array[B] + required: Seq[_] + Range(1,2).toArray: Seq[_] + ^ + scala> 0 -res1: Int = 0 +res2: Int = 0 scala> diff --git a/test/files/run/t7319.scala b/test/files/run/t7319.scala index 23ffeb977d..65a3ed922d 100644 --- a/test/files/run/t7319.scala +++ b/test/files/run/t7319.scala @@ -9,5 +9,6 @@ implicit def ma0[A](a: A): M[A] = null implicit def ma1[A](a: A): M[A] = null def convert[F[X <: F[X]]](builder: F[_ <: F[_]]) = 0 convert(Some[Int](0)) +Range(1,2).toArray: Seq[_] 0""" // before the fix, this line, and all that followed, re-issued the implicit ambiguity error. } diff --git a/test/files/run/t7337.check b/test/files/run/t7337.check new file mode 100644 index 0000000000..dd2b31f23c --- /dev/null +++ b/test/files/run/t7337.check @@ -0,0 +1 @@ +doesnotexist does not exist or is not a directory diff --git a/test/files/run/t7337.scala b/test/files/run/t7337.scala new file mode 100644 index 0000000000..9913f8ae45 --- /dev/null +++ b/test/files/run/t7337.scala @@ -0,0 +1,19 @@ +import scala.tools.partest._ +import scala.tools.nsc._ +import scala.tools.cmd.CommandLineParser + +object Test extends DirectTest { + override def code = "class C" + override def newCompiler(args: String*): Global = { + val settings = newSettings((CommandLineParser tokenize ("-d doesnotexist " + extraSettings)) ++ args.toList) + newCompiler(settings) + } + + override def show() { + try { + newCompiler() + } catch { + case fe: FatalError => println(fe.getMessage) + } + } +} diff --git a/test/files/run/t7436.scala b/test/files/run/t7436.scala new file mode 100644 index 0000000000..867a931e05 --- /dev/null +++ b/test/files/run/t7436.scala @@ -0,0 +1,9 @@ +class A(val p: Int*) + +class B(val p1: Int) extends A(p1) + +object Test { + def main(args: Array[String]) { + new B(1).p1 // threw java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofInt cannot be cast to java.lang.Integer + } +} diff --git a/test/files/run/t7439.check b/test/files/run/t7439.check new file mode 100644 index 0000000000..9ea09f9c40 --- /dev/null +++ b/test/files/run/t7439.check @@ -0,0 +1,2 @@ +Recompiling after deleting t7439-run.obj/A_1.class +pos: NoPosition Class A_1 not found - continuing with a stub. WARNING diff --git a/test/files/run/t7439/A_1.java b/test/files/run/t7439/A_1.java new file mode 100644 index 0000000000..4accd95d57 --- /dev/null +++ b/test/files/run/t7439/A_1.java @@ -0,0 +1,3 @@ +public class A_1 { + +}
\ No newline at end of file diff --git a/test/files/run/t7439/B_1.java b/test/files/run/t7439/B_1.java new file mode 100644 index 0000000000..5dd3b93d6f --- /dev/null +++ b/test/files/run/t7439/B_1.java @@ -0,0 +1,3 @@ +public class B_1 { + public void b(A_1[] a) {} +} diff --git a/test/files/run/t7439/Test_2.scala b/test/files/run/t7439/Test_2.scala new file mode 100644 index 0000000000..ce9b907145 --- /dev/null +++ b/test/files/run/t7439/Test_2.scala @@ -0,0 +1,33 @@ +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 C = """ + class C { + new B_1 + } + """ + + def show(): Unit = { + //compileCode(C) + assert(filteredInfos.isEmpty, filteredInfos) + + // blow away the entire package + val a1Class = new File(testOutput.path, "A_1.class") + assert(a1Class.exists) + assert(a1Class.delete()) + // testIdent normalizes to separate names using '/' regardless of platform, drops all but last two parts + println(s"Recompiling after deleting ${a1Class.testIdent}") + + // bad symbolic reference error expected (but no stack trace!) + compileCode(C) + println(storeReporter.infos.mkString("\n")) // Included a NullPointerException before. + } +} diff --git a/test/files/run/t7482a.check b/test/files/run/t7482a.check new file mode 100644 index 0000000000..b26e685784 --- /dev/null +++ b/test/files/run/t7482a.check @@ -0,0 +1,14 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> val v: java.util.ArrayList[String] = new java.util.ArrayList[String](5) +v: java.util.ArrayList[String] = [] + +scala> val v: java.util.ArrayList[String] = new java.util.ArrayList[String](5) +v: java.util.ArrayList[String] = [] + +scala> + +scala> diff --git a/test/files/run/t7482a.scala b/test/files/run/t7482a.scala new file mode 100644 index 0000000000..d674558b98 --- /dev/null +++ b/test/files/run/t7482a.scala @@ -0,0 +1,8 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def code = """ + val v: java.util.ArrayList[String] = new java.util.ArrayList[String](5) + val v: java.util.ArrayList[String] = new java.util.ArrayList[String](5) + """ +}
\ No newline at end of file diff --git a/test/files/run/t7569.check b/test/files/run/t7569.check index aade96d233..98513c3ab2 100644 --- a/test/files/run/t7569.check +++ b/test/files/run/t7569.check @@ -1,8 +1,8 @@ source-newSource1.scala,line-3,offset=49 A.this.one source-newSource1.scala,line-3,offset=49 A.this -source-newSource1.scala,line-2,offset=41 A.super.<init>() -source-newSource1.scala,line-2,offset=41 A.super.<init> -source-newSource1.scala,line-2,offset=41 this +source-newSource1.scala,line-4,offset=67 A.super.<init>() +source-newSource1.scala,line-4,offset=67 A.super.<init> +source-newSource1.scala,line-4,offset=67 this source-newSource1.scala,line-3,offset=49 A.this.one source-newSource1.scala,line-3,offset=49 A.this RangePosition(newSource1.scala, 55, 57, 65) scala.Int.box(1).toString() diff --git a/test/files/run/t7582-private-within.check b/test/files/run/t7582-private-within.check new file mode 100644 index 0000000000..b2743ffa06 --- /dev/null +++ b/test/files/run/t7582-private-within.check @@ -0,0 +1,12 @@ +private[package pack] class JavaPackagePrivate +private[package pack] module JavaPackagePrivate +private[package pack] module class JavaPackagePrivate +private[package pack] field field +private[package pack] primary constructor <init> +private[package pack] method meth +private[package pack] field staticField +private[package pack] method staticMeth +private[package pack] method <clinit> +private[package pack] field staticField +private[package pack] method staticMeth +private[package pack] method <clinit> diff --git a/test/files/run/t7582-private-within/JavaPackagePrivate.java b/test/files/run/t7582-private-within/JavaPackagePrivate.java new file mode 100644 index 0000000000..672d19b57e --- /dev/null +++ b/test/files/run/t7582-private-within/JavaPackagePrivate.java @@ -0,0 +1,8 @@ +package pack; + +class JavaPackagePrivate { + int field = 0; + static int staticField = 0; + void meth() { } + static void staticMeth() { } +} diff --git a/test/files/run/t7582-private-within/Test.scala b/test/files/run/t7582-private-within/Test.scala new file mode 100644 index 0000000000..3d581f063b --- /dev/null +++ b/test/files/run/t7582-private-within/Test.scala @@ -0,0 +1,22 @@ +import scala.tools.partest.DirectTest + +// Testing that the `privateWithin` field is correctly populated on all +// the related symbols (e.g. module class) under separate compilation. +object Test extends DirectTest { + def code = ??? + + def show(): Unit = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + val global = newCompiler("-usejavacp", "-cp", classpath, "-d", testOutput.path) + import global._ + withRun(global) { _ => + def check(sym: Symbol) = { + sym.initialize + println(f"${sym.accessString}%12s ${sym.accurateKindString} ${sym.name.decode}") // we want to see private[pack] for all of these. + } + val sym = rootMirror.getRequiredClass("pack.JavaPackagePrivate") + val syms = Seq(sym, sym.companionModule, sym.companionModule.moduleClass) + (syms ++ syms.flatMap(_.info.decls)).foreach(check) + } + } +} diff --git a/test/files/run/t7582.check b/test/files/run/t7582.check new file mode 100644 index 0000000000..225fb1ace8 --- /dev/null +++ b/test/files/run/t7582.check @@ -0,0 +1,2 @@ +warning: there were 1 inliner warning(s); re-run with -Yinline-warnings for details +2 diff --git a/test/files/run/t7582.flags b/test/files/run/t7582.flags new file mode 100644 index 0000000000..1182725e86 --- /dev/null +++ b/test/files/run/t7582.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/test/files/run/t7582/InlineHolder.scala b/test/files/run/t7582/InlineHolder.scala new file mode 100644 index 0000000000..a18b9effaa --- /dev/null +++ b/test/files/run/t7582/InlineHolder.scala @@ -0,0 +1,16 @@ +package p1 { + object InlineHolder { + @inline def inlinable = p1.PackageProtectedJava.protectedMethod() + 1 + } +} + +object O { + @noinline + def x = p1.InlineHolder.inlinable +} + +object Test { + def main(args: Array[String]) { + println(O.x) + } +} diff --git a/test/files/run/t7582/PackageProtectedJava.java b/test/files/run/t7582/PackageProtectedJava.java new file mode 100644 index 0000000000..b7ea2a7676 --- /dev/null +++ b/test/files/run/t7582/PackageProtectedJava.java @@ -0,0 +1,6 @@ +package p1; + +// public class, protected method +public class PackageProtectedJava { + static final int protectedMethod() { return 1; } +} diff --git a/test/files/run/t7582b.check b/test/files/run/t7582b.check new file mode 100644 index 0000000000..225fb1ace8 --- /dev/null +++ b/test/files/run/t7582b.check @@ -0,0 +1,2 @@ +warning: there were 1 inliner warning(s); re-run with -Yinline-warnings for details +2 diff --git a/test/files/run/t7582b.flags b/test/files/run/t7582b.flags new file mode 100644 index 0000000000..1182725e86 --- /dev/null +++ b/test/files/run/t7582b.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/test/files/run/t7582b/InlineHolder.scala b/test/files/run/t7582b/InlineHolder.scala new file mode 100644 index 0000000000..a18b9effaa --- /dev/null +++ b/test/files/run/t7582b/InlineHolder.scala @@ -0,0 +1,16 @@ +package p1 { + object InlineHolder { + @inline def inlinable = p1.PackageProtectedJava.protectedMethod() + 1 + } +} + +object O { + @noinline + def x = p1.InlineHolder.inlinable +} + +object Test { + def main(args: Array[String]) { + println(O.x) + } +} diff --git a/test/files/run/t7582b/PackageProtectedJava.java b/test/files/run/t7582b/PackageProtectedJava.java new file mode 100644 index 0000000000..55a44b79f9 --- /dev/null +++ b/test/files/run/t7582b/PackageProtectedJava.java @@ -0,0 +1,6 @@ +package p1; + +// protected class, public method +class PackageProtectedJava { + public static final int protectedMethod() { return 1; } +} diff --git a/test/files/run/t7584.check b/test/files/run/t7584.check new file mode 100644 index 0000000000..9f53e5dde5 --- /dev/null +++ b/test/files/run/t7584.check @@ -0,0 +1,6 @@ +no calls +call A +a +call B twice +b +b diff --git a/test/files/run/t7584.flags b/test/files/run/t7584.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/run/t7584.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/run/t7584.scala b/test/files/run/t7584.scala new file mode 100644 index 0000000000..6d7f4f7ebb --- /dev/null +++ b/test/files/run/t7584.scala @@ -0,0 +1,14 @@ +// Test case added to show the behaviour of functions with +// by-name parameters. The evaluation behaviour was already correct. +// +// We did flush out a spurious "pure expression does nothing in statement position" +// warning, hence -Xfatal-warnings in the flags file. +object Test extends App { + def foo(f: (=> Int, => Int) => Unit) = f({println("a"); 0}, {println("b"); 1}) + println("no calls") + foo((a, b) => ()) + println("call A") + foo((a, b) => a) + println("call B twice") + foo((a, b) => {b; b}) +} diff --git a/test/files/run/t874.scala b/test/files/run/t874.scala index 41d124f728..7e70fc34eb 100644 --- a/test/files/run/t874.scala +++ b/test/files/run/t874.scala @@ -1,3 +1,5 @@ + +import scala.language.{ reflectiveCalls } object Test { abstract class Base { val U: { diff --git a/test/files/run/tailcalls.check b/test/files/run/tailcalls.check index f123bc8f25..10384ac46e 100644 --- a/test/files/run/tailcalls.check +++ b/test/files/run/tailcalls.check @@ -1,3 +1,4 @@ +#partest !avian test Object .f was successful test Final .f was successful test Class .f raised exception java.lang.StackOverflowError @@ -51,3 +52,58 @@ test TailCall.b2 was successful test FancyTailCalls.tcTryLocal was successful test FancyTailCalls.differentInstance was successful test PolyObject.tramp was successful + +#partest avian +test Object .f was successful +test Final .f was successful +test Class .f was successful +test SubClass .f was successful +test Sealed .f was successful +test SubSealed.f was successful + +test O .f was successful +test c .f was successful +test O.O .f was successful +test O.c .f was successful +test c.O .f was successful +test c.c .f was successful +test O.O.O .f was successful +test O.O.c .f was successful +test O.c.O .f was successful +test O.c.c .f was successful +test c.O.O .f was successful +test c.O.c .f was successful +test c.c.O .f was successful +test c.c.c .f was successful +test O.O.O.O.f was successful +test O.O.O.c.f was successful +test O.O.c.O.f was successful +test O.O.c.c.f was successful +test O.c.O.O.f was successful +test O.c.O.c.f was successful +test O.c.c.O.f was successful +test O.c.c.c.f was successful +test c.O.O.O.f was successful +test c.O.O.c.f was successful +test c.O.c.O.f was successful +test c.O.c.c.f was successful +test c.c.O.O.f was successful +test c.c.O.c.f was successful +test c.c.c.O.f was successful +test c.c.c.c.f was successful + +test TailCall.f1 was successful +test TailCall.f2 was successful +test TailCall.f3 was successful +test TailCall.g1 was successful +test TailCall.g2 was successful +test TailCall.g3 was successful +test TailCall.h1 was successful + +test NonTailCall.f1 0 1 2 was successful +test NonTailCall.f2 +test TailCall.b1 was successful +test TailCall.b2 was successful +test FancyTailCalls.tcTryLocal was successful +test FancyTailCalls.differentInstance was successful +test PolyObject.tramp was successful
\ No newline at end of file diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala index 04a1a8ba19..1d4124e138 100644 --- a/test/files/run/tailcalls.scala +++ b/test/files/run/tailcalls.scala @@ -194,10 +194,10 @@ object FancyTailCalls { } object PolyObject extends App { - def tramp[A](x: Int): Int = + def tramp[A](x: Int): Int = if (x > 0) tramp[A](x - 1) - else + else 0 } @@ -233,7 +233,7 @@ class NonTailCall { if (n == 0) 0 else f2(n - 1) } - + } //############################################################################ @@ -273,7 +273,7 @@ object Test { } println } - + def check_overflow(name: String, closure: => Int) { print("test " + name) try { @@ -295,7 +295,7 @@ object Test { while (!stop) { try { calibrator.f(n, n); - if (n >= Int.MaxValue / 2) error("calibration failure"); + if (n >= Int.MaxValue / 2) sys.error("calibration failure"); n = 2 * n; } catch { case exception: compat.Platform.StackOverflowError => stop = true @@ -307,7 +307,7 @@ object Test { def main(args: Array[String]) { // compute min and max iteration number val min = 16; - val max = calibrate; + val max = if (scala.tools.partest.utils.Properties.isAvian) 10000 else calibrate // test tail calls in different contexts val Final = new Final() @@ -367,7 +367,7 @@ object Test { check_success("TailCall.g3", TailCall.g3(max, max, Nil), 0) check_success("TailCall.h1", TailCall.h1(max, max ), 0) println - + val NonTailCall = new NonTailCall check_success("NonTailCall.f1", NonTailCall.f1(2), 0) check_overflow("NonTailCall.f2", NonTailCall.f2(max)) @@ -382,17 +382,17 @@ object Test { } // testing explicit tailcalls. - + import scala.util.control.TailCalls._ def isEven(xs: List[Int]): TailRec[Boolean] = if (xs.isEmpty) done(true) else tailcall(isOdd(xs.tail)) def isOdd(xs: List[Int]): TailRec[Boolean] = - if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail)) + if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail)) assert(isEven((1 to 100000).toList).result) - + } //############################################################################ diff --git a/test/files/run/tcpoly_monads.scala b/test/files/run/tcpoly_monads.scala index cffbcc963b..6372851451 100644 --- a/test/files/run/tcpoly_monads.scala +++ b/test/files/run/tcpoly_monads.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds, implicitConversions } + trait Monads { /** * class Monad m where diff --git a/test/files/run/tcpoly_overriding.scala b/test/files/run/tcpoly_overriding.scala index 86ba89f530..32174ad8bf 100644 --- a/test/files/run/tcpoly_overriding.scala +++ b/test/files/run/tcpoly_overriding.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds } + abstract class A[t[x]] { def b: t[Int] } diff --git a/test/files/run/tcpoly_parseridioms.check b/test/files/run/tcpoly_parseridioms.check index 5fff2efb15..ab829e0a0e 100644 --- a/test/files/run/tcpoly_parseridioms.check +++ b/test/files/run/tcpoly_parseridioms.check @@ -1 +1,21 @@ +tcpoly_parseridioms.scala:18: warning: match may not be exhaustive. +It would fail on the following input: ParseResult() + case Success(next, x) => b(next) match { + ^ +tcpoly_parseridioms.scala:17: warning: match may not be exhaustive. +It would fail on the following input: ParseResult() + def apply(in: Input): ParseResult[Pair[T, U]] = a(in) match { + ^ +tcpoly_parseridioms.scala:30: warning: match may not be exhaustive. +It would fail on the following input: ParseResult() + case Failure(_, _) => b(in) match { + ^ +tcpoly_parseridioms.scala:28: warning: match may not be exhaustive. +It would fail on the following input: ParseResult() + def apply(in: Input): ParseResult[T] = a(in) match { + ^ +tcpoly_parseridioms.scala:39: warning: match may not be exhaustive. +It would fail on the following input: ParseResult() + def apply(in: Input): ParseResult[U] = a(in) match { + ^ Success(List(),Plus(1,2)) diff --git a/test/files/run/tcpoly_parseridioms.scala b/test/files/run/tcpoly_parseridioms.scala index 634240e44d..ec17e062db 100644 --- a/test/files/run/tcpoly_parseridioms.scala +++ b/test/files/run/tcpoly_parseridioms.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds, implicitConversions, postfixOps } + trait Parsers { type Input = List[Char] diff --git a/test/files/run/test-cpp.scala b/test/files/run/test-cpp.scala index 5b3bc7b746..f9fa85c4d0 100644 --- a/test/files/run/test-cpp.scala +++ b/test/files/run/test-cpp.scala @@ -3,7 +3,7 @@ * in the copy-propagation performed before ClosureElimination. * * In the general case, the local variable 'l' is connected through - * a alias chain with other local variables and at the end of the + * an alias chain with other local variables and at the end of the * alias chain there may be a Value, call it 'v'. * * If 'v' is cheaper to access (it is a Deref(This) or Const(_)), then diff --git a/test/files/run/toolbox_console_reporter.scala b/test/files/run/toolbox_console_reporter.scala index d672ccb9cb..ce28086c25 100644 --- a/test/files/run/toolbox_console_reporter.scala +++ b/test/files/run/toolbox_console_reporter.scala @@ -4,10 +4,10 @@ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.{ToolBox, mkConsoleFrontEnd} object Test extends App { - val oldErr = Console.err; - val baos = new java.io.ByteArrayOutputStream(); - Console.setErr(new java.io.PrintStream(baos)); - try { + //val oldErr = Console.err; + val baos = new java.io.ByteArrayOutputStream() + val errs = new java.io.PrintStream(baos) + (Console withErr errs) { val toolbox = cm.mkToolBox(frontEnd = mkConsoleFrontEnd(), options = "-deprecation") toolbox.eval(reify{ object Utils { @@ -18,12 +18,11 @@ object Test extends App { Utils.foo }.tree) println("============compiler console=============") + errs.flush() println(baos.toString); println("=========================================") println("============compiler messages============") toolbox.frontEnd.infos.foreach(println(_)) println("=========================================") - } finally { - Console.setErr(oldErr); } -}
\ No newline at end of file +} diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.check b/test/files/run/toolbox_typecheck_implicitsdisabled.check index db64e118ca..009ba651fe 100644 --- a/test/files/run/toolbox_typecheck_implicitsdisabled.check +++ b/test/files/run/toolbox_typecheck_implicitsdisabled.check @@ -1,5 +1,5 @@ { import scala.Predef._; - scala.Predef.any2ArrowAssoc[Int](1).->[Int](2) + scala.Predef.ArrowAssoc[Int](1).->[Int](2) } scala.tools.reflect.ToolBoxError: reflective typecheck has failed: value -> is not a member of Int diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.scala b/test/files/run/toolbox_typecheck_implicitsdisabled.scala index 8a3d433142..95a7056279 100644 --- a/test/files/run/toolbox_typecheck_implicitsdisabled.scala +++ b/test/files/run/toolbox_typecheck_implicitsdisabled.scala @@ -7,16 +7,16 @@ object Test extends App { val toolbox = cm.mkToolBox() val tree1 = Block(List( - Import(Select(Ident(newTermName("scala")), newTermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), - Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + Import(Select(Ident(TermName("scala")), TermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), + Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) ) val ttree1 = toolbox.typeCheck(tree1, withImplicitViewsDisabled = false) println(ttree1) try { val tree2 = Block(List( - Import(Select(Ident(newTermName("scala")), newTermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), - Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + Import(Select(Ident(TermName("scala")), TermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), + Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) ) val ttree2 = toolbox.typeCheck(tree2, withImplicitViewsDisabled = true) println(ttree2) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala index 51eb63f294..1f7fda8575 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala @@ -15,11 +15,11 @@ object Test extends App { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) + val tree1 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) println(ttree1) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) + val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) println(ttree2) } diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check index e7011d1ae2..bdcdb421fd 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -19,7 +19,7 @@ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) } }; new $treecreator1() diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala index 74fd09d9fd..7bfe3ba8a4 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala @@ -15,11 +15,11 @@ object Test extends App { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val tree1 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) println(ttree1) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) println(ttree2) } diff --git a/test/files/run/tpeCache-tyconCache.check b/test/files/run/tpeCache-tyconCache.check new file mode 100644 index 0000000000..a892f5477a --- /dev/null +++ b/test/files/run/tpeCache-tyconCache.check @@ -0,0 +1,19 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :power +** Power User mode enabled - BEEP WHIR GYVE ** +** :phase has been set to 'typer'. ** +** scala.tools.nsc._ has been imported ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** + +scala> + +scala> AnyRefClass.tpe eq AnyRefClass.typeConstructor +res0: Boolean = true + +scala> AnyRefClass.tpe eq AnyRefClass.typeConstructor +res1: Boolean = true + +scala> diff --git a/test/files/run/tpeCache-tyconCache.scala b/test/files/run/tpeCache-tyconCache.scala new file mode 100644 index 0000000000..f907167a33 --- /dev/null +++ b/test/files/run/tpeCache-tyconCache.scala @@ -0,0 +1,10 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def code = """ +:power + +AnyRefClass.tpe eq AnyRefClass.typeConstructor +AnyRefClass.tpe eq AnyRefClass.typeConstructor + """.trim +} diff --git a/test/files/run/transform.scala b/test/files/run/transform.scala index 5cc1c49d6f..82f924950d 100644 --- a/test/files/run/transform.scala +++ b/test/files/run/transform.scala @@ -1,5 +1,5 @@ object Test { - val x = 1 to 10 toBuffer + val x = (1 to 10).toBuffer def main(args: Array[String]): Unit = { x transform (_ * 2) diff --git a/test/files/run/try-2.check b/test/files/run/try-2.check index 6c4a024c93..987d3462df 100644 --- a/test/files/run/try-2.check +++ b/test/files/run/try-2.check @@ -1,3 +1,6 @@ +try-2.scala:41: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 10; + ^ exception happened Nothin diff --git a/test/files/run/try-2.scala b/test/files/run/try-2.scala index 677f0b48eb..b55977ba8b 100644 --- a/test/files/run/try-2.scala +++ b/test/files/run/try-2.scala @@ -7,47 +7,47 @@ object Test { - def tryAllUnit: Unit = + def tryAllUnit: Unit = try { throw new Error(); } catch { - case _ => Console.println("exception happened\n"); + case _: Throwable => Console.println("exception happened\n"); } - def tryUnitAll: Unit = + def tryUnitAll: Unit = try { Console.println("Nothin"); } catch { - case _ => error("Bad, bad, lama!"); + case _: Throwable => sys.error("Bad, bad, lama!"); } - def tryAllAll: Unit = + def tryAllAll: Unit = try { throw new Error(); } catch { - case _ => error("Bad, bad, lama!"); + case _: Throwable => sys.error("Bad, bad, lama!"); } - def tryUnitUnit: Unit = + def tryUnitUnit: Unit = try { Console.println("Nothin"); } catch { - case _ => Console.println("Nothin"); + case _: Throwable => Console.println("Nothin"); } - def tryIntUnit: Unit = + def tryIntUnit: Unit = try { 10; } catch { - case _ => Console.println("Huh?"); + case _: Throwable => Console.println("Huh?"); } def execute(f: => Unit) = try { f; } catch { - case _ => (); + case _: Throwable => (); } @@ -55,7 +55,7 @@ object Test { execute(tryAllUnit); execute(tryUnitAll); execute(tryAllAll); - execute(tryUnitUnit); + execute(tryUnitUnit); execute(tryIntUnit); } } diff --git a/test/files/run/try-catch-unify.scala b/test/files/run/try-catch-unify.scala index 8cb14d060e..151e549e5f 100644 --- a/test/files/run/try-catch-unify.scala +++ b/test/files/run/try-catch-unify.scala @@ -9,7 +9,7 @@ object Test { try { catching(classOf[NumberFormatException]) withTry (sys.error("O NOES")) } catch { - case t => println(t.getMessage) + case t: Throwable => println(t.getMessage) } println(nonFatalCatch withTry ("Hi".toDouble)) } diff --git a/test/files/run/try.check b/test/files/run/try.check index 3983e26060..f742ccb0df 100644 --- a/test/files/run/try.check +++ b/test/files/run/try.check @@ -1,3 +1,6 @@ +try.scala:65: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 1+1; + ^ 1 + 1 = 2 1 + 1 = 2 1 + 1 = 2 diff --git a/test/files/run/try.scala b/test/files/run/try.scala index ad3d606246..a4fdfd796b 100644 --- a/test/files/run/try.scala +++ b/test/files/run/try.scala @@ -17,8 +17,8 @@ object Test extends AnyRef with App { Console.println( (try { x } catch { case _: Error => 1; - }) - + + }) + + (try { x } catch { case _: Error => 1; }) @@ -45,7 +45,7 @@ object Test extends AnyRef with App { instance = try { "" //new String(); } catch { - case _ => + case _: Throwable => val cs = "aaa"; if (cs.length() > 0) { "" //new String(); @@ -61,17 +61,17 @@ object Test extends AnyRef with App { Console.print("1 + 1 = "); try { if (true) - error("exit"); + sys.error("exit"); 1+1; () } catch { - case _ => + case _: Throwable => Console.println("2"); - error("for good"); + sys.error("for good"); } Console.println("a"); } catch { - case _ => (); + case _: Throwable => (); } class A { @@ -95,7 +95,7 @@ object Test extends AnyRef with App { try { null } catch { - case _ => null + case _: Throwable => null } new AnyRef { @@ -116,7 +116,7 @@ object Test extends AnyRef with App { } */ - + try1; try2; try3; diff --git a/test/files/run/tuple-zipped.scala b/test/files/run/tuple-zipped.scala index b197183844..c8ba41f042 100644 --- a/test/files/run/tuple-zipped.scala +++ b/test/files/run/tuple-zipped.scala @@ -1,3 +1,6 @@ + +import scala.language.postfixOps + object Test { val xs1 = List.range(1, 100) val xs2 = xs1.view diff --git a/test/files/run/tuples.scala b/test/files/run/tuples.scala index 4854e36c96..a4ea9ddbcc 100644 --- a/test/files/run/tuples.scala +++ b/test/files/run/tuples.scala @@ -6,6 +6,7 @@ object Test extends App { Console.println(xyz) xyz match { case (1, "abc", true) => Console.println("OK") + case _ => ??? } def func(x: Int, y: String, z: Double) { Console.println("x = " + x + "; y = " + y + "; z = " + z); diff --git a/test/files/run/type-currying.scala b/test/files/run/type-currying.scala index f9764c64f0..5e31fef403 100644 --- a/test/files/run/type-currying.scala +++ b/test/files/run/type-currying.scala @@ -1,3 +1,6 @@ + + +import scala.language.{ higherKinds, reflectiveCalls } import scala.collection.{ mutable, immutable, generic } import generic.CanBuildFrom diff --git a/test/files/run/unapply.check b/test/files/run/unapply.check new file mode 100644 index 0000000000..847e3b381e --- /dev/null +++ b/test/files/run/unapply.check @@ -0,0 +1,3 @@ +unapply.scala:57: warning: comparing values of types Null and Null using `==' will always yield true + assert(doMatch2(b) == null) + ^ diff --git a/test/files/run/unittest_io.scala b/test/files/run/unittest_io.scala index 2cadb9b1df..2c3dacdf91 100644 --- a/test/files/run/unittest_io.scala +++ b/test/files/run/unittest_io.scala @@ -1,3 +1,5 @@ + +@deprecated("Suppress warnings", since="2.11") object Test { def main(args: Array[String]) { diff --git a/test/files/run/unreachable.scala b/test/files/run/unreachable.scala new file mode 100644 index 0000000000..99ac730746 --- /dev/null +++ b/test/files/run/unreachable.scala @@ -0,0 +1,128 @@ +import scala.util.Random.nextInt +import scala.sys.error + +object Test extends App { + def unreachableNormalExit: Int = { + return 42 + 0 + } + + def unreachableIf: Int = { + return 42 + if (nextInt % 2 == 0) + 0 + else + 1 + } + + def unreachableIfBranches: Int = { + if (nextInt % 2 == 0) + return 42 + else + return 42 + + return 0 + } + + def unreachableOneLegIf: Int = { + if (nextInt % 2 == 0) + return 42 + + return 42 + } + + def unreachableLeftBranch: Int = { + val result = if (nextInt % 2 == 0) + return 42 + else + 42 + + return result + } + + def unreachableRightBranch: Int = { + val result = if (nextInt % 2 == 0) + 42 + else + return 42 + + return result + } + + def unreachableTryCatchFinally: Int = { + return 42 + try { + return 0 + } catch { + case x: Throwable => return 1 + } finally { + return 2 + } + return 3 + } + + def unreachableAfterTry: Int = { + try { + return 42 + } catch { + case x: Throwable => return 2 + } + return 3 + } + + def unreachableAfterCatch: Int = { + try { + error("haha") + } catch { + case x: Throwable => return 42 + } + return 3 + } + + def unreachableAfterFinally: Int = { + try { + return 1 + } catch { + case x: Throwable => return 2 + } finally { + return 42 + } + return 3 + } + + def unreachableSwitch: Int = { + return 42 + val x = nextInt % 2 + x match { + case 0 => return 0 + case 1 => return 1 + case -1 => return 2 + } + 3 + } + + def unreachableAfterSwitch: Int = { + val x = nextInt % 2 + x match { + case 0 => return 42 + case 1 => return 41 + x + case -1 => return 43 + x + } + 2 + } + + def check(f: Int) = assert(f == 42, s"Expected 42 but got $f") + + check(unreachableNormalExit) + check(unreachableIf) + check(unreachableIfBranches) + check(unreachableOneLegIf) + check(unreachableLeftBranch) + check(unreachableRightBranch) + check(unreachableTryCatchFinally) + check(unreachableAfterTry) + check(unreachableAfterCatch) + check(unreachableAfterFinally) + check(unreachableSwitch) + check(unreachableAfterSwitch) +} diff --git a/test/files/run/valueclasses-classmanifest-basic.scala b/test/files/run/valueclasses-classmanifest-basic.scala index c2aa08ef86..50addda359 100644 --- a/test/files/run/valueclasses-classmanifest-basic.scala +++ b/test/files/run/valueclasses-classmanifest-basic.scala @@ -1,5 +1,6 @@ class Foo(val x: Int) extends AnyVal +@deprecated("Suppress warnings", since="2.11") object Test extends App { println(classManifest[Foo]) -}
\ No newline at end of file +} diff --git a/test/files/run/valueclasses-classmanifest-existential.scala b/test/files/run/valueclasses-classmanifest-existential.scala index 11999df678..6bcd7cf942 100644 --- a/test/files/run/valueclasses-classmanifest-existential.scala +++ b/test/files/run/valueclasses-classmanifest-existential.scala @@ -1,5 +1,6 @@ class Foo[T](val x: T) extends AnyVal +@deprecated("Suppress warnings", since="2.11") object Test extends App { println(classManifest[Foo[_]]) -}
\ No newline at end of file +} diff --git a/test/files/run/valueclasses-classmanifest-generic.scala b/test/files/run/valueclasses-classmanifest-generic.scala index 280152dc1d..5efcaed959 100644 --- a/test/files/run/valueclasses-classmanifest-generic.scala +++ b/test/files/run/valueclasses-classmanifest-generic.scala @@ -1,5 +1,6 @@ class Foo[T](val x: T) extends AnyVal +@deprecated("Suppress warnings", since="2.11") object Test extends App { println(classManifest[Foo[String]]) -}
\ No newline at end of file +} diff --git a/test/files/run/vector1.scala b/test/files/run/vector1.scala index b37cfe82e8..2e335aded4 100644 --- a/test/files/run/vector1.scala +++ b/test/files/run/vector1.scala @@ -102,7 +102,7 @@ object Test { seqBack() } } catch { - case ex => + case ex: Throwable => //println("----------------") //a.debug throw ex diff --git a/test/files/run/verify-ctor.scala b/test/files/run/verify-ctor.scala index 17e4f71be5..528d038a8e 100644 --- a/test/files/run/verify-ctor.scala +++ b/test/files/run/verify-ctor.scala @@ -1,6 +1,6 @@ class Foo(val str: String) { def this(arr: Array[Char]) = this({ - if (arr.length == 0) exit(1) + if (arr.length == 0) sys.exit(1) new String(arr) }) } diff --git a/test/files/run/view-iterator-stream.scala b/test/files/run/view-iterator-stream.scala index f91407f92c..c172b5cb99 100644 --- a/test/files/run/view-iterator-stream.scala +++ b/test/files/run/view-iterator-stream.scala @@ -1,3 +1,6 @@ + +import scala.language.postfixOps + import scala.collection.{ mutable, immutable, generic } import collection.TraversableView diff --git a/test/files/run/virtpatmat_alts.check b/test/files/run/virtpatmat_alts.check index 7a4ad0a741..f39e292fef 100644 --- a/test/files/run/virtpatmat_alts.check +++ b/test/files/run/virtpatmat_alts.check @@ -1 +1,7 @@ +virtpatmat_alts.scala:5: warning: match may not be exhaustive. + (true, true) match { + ^ +virtpatmat_alts.scala:9: warning: match may not be exhaustive. + List(5) match { + ^ OK 5 diff --git a/test/files/run/virtpatmat_alts.flags b/test/files/run/virtpatmat_alts.flags deleted file mode 100644 index 3f5a3100e4..0000000000 --- a/test/files/run/virtpatmat_alts.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_alts.scala b/test/files/run/virtpatmat_alts.scala index b7717524e2..d1dfa8a4a1 100644 --- a/test/files/run/virtpatmat_alts.scala +++ b/test/files/run/virtpatmat_alts.scala @@ -1,3 +1,6 @@ +/* + * filter: It would fail on the following input + */ object Test extends App { (true, true) match { case (true, true) | (false, false) => 1 @@ -9,4 +12,4 @@ object Test extends App { case 7 :: Nil => println("FAILED") case Nil => println("FAILED") } -}
\ No newline at end of file +} diff --git a/test/files/run/virtpatmat_casting.scala b/test/files/run/virtpatmat_casting.scala index d970abae90..22ac29bc3b 100644 --- a/test/files/run/virtpatmat_casting.scala +++ b/test/files/run/virtpatmat_casting.scala @@ -4,5 +4,6 @@ object Test extends App { // since the :: extractor's argument must be a ::, there has to be a cast before its unapply is invoked case x :: y :: z :: a :: xs => xs ++ List(x) case x :: y :: z :: xs => xs ++ List(x) + case _ => List(0) }) } diff --git a/test/files/run/virtpatmat_nested_lists.check b/test/files/run/virtpatmat_nested_lists.check index d8263ee986..ddf68eeedd 100644 --- a/test/files/run/virtpatmat_nested_lists.check +++ b/test/files/run/virtpatmat_nested_lists.check @@ -1 +1,4 @@ -2
\ No newline at end of file +virtpatmat_nested_lists.scala:5: warning: match may not be exhaustive. + List(List(1), List(2)) match { case x :: (y :: Nil) :: Nil => println(y) } + ^ +2 diff --git a/test/files/run/virtpatmat_nested_lists.flags b/test/files/run/virtpatmat_nested_lists.flags deleted file mode 100644 index 3f5a3100e4..0000000000 --- a/test/files/run/virtpatmat_nested_lists.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_nested_lists.scala b/test/files/run/virtpatmat_nested_lists.scala index fef74cea15..d1aa68ea93 100644 --- a/test/files/run/virtpatmat_nested_lists.scala +++ b/test/files/run/virtpatmat_nested_lists.scala @@ -1,3 +1,6 @@ +/* + * filter: It would fail on the following input + */ object Test extends App { List(List(1), List(2)) match { case x :: (y :: Nil) :: Nil => println(y) } } diff --git a/test/files/run/virtpatmat_opt_sharing.check b/test/files/run/virtpatmat_opt_sharing.check index d00491fd7e..78ec61f19d 100644 --- a/test/files/run/virtpatmat_opt_sharing.check +++ b/test/files/run/virtpatmat_opt_sharing.check @@ -1 +1,4 @@ +virtpatmat_opt_sharing.scala:7: warning: match may not be exhaustive. + List(1, 3, 4, 7) match { + ^ 1 diff --git a/test/files/run/virtpatmat_opt_sharing.flags b/test/files/run/virtpatmat_opt_sharing.flags deleted file mode 100644 index 3f5a3100e4..0000000000 --- a/test/files/run/virtpatmat_opt_sharing.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_opt_sharing.scala b/test/files/run/virtpatmat_opt_sharing.scala index 119e3050ea..d2c42cab48 100644 --- a/test/files/run/virtpatmat_opt_sharing.scala +++ b/test/files/run/virtpatmat_opt_sharing.scala @@ -1,3 +1,6 @@ +/* + * filter: It would fail on the following input + */ object Test extends App { virtMatch() def virtMatch() = { @@ -7,4 +10,4 @@ object Test extends App { case 1 :: 3 :: 4 :: 7 :: x => println(1) } } -}
\ No newline at end of file +} diff --git a/test/files/run/virtpatmat_staging.scala b/test/files/run/virtpatmat_staging.scala index c17b45043b..d444829b02 100644 --- a/test/files/run/virtpatmat_staging.scala +++ b/test/files/run/virtpatmat_staging.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds, implicitConversions } + trait Intf { type Rep[+T] type M[+T] = Rep[Maybe[T]] @@ -9,7 +12,7 @@ trait Intf { def zero: M[Nothing] def one[T](x: Rep[T]): M[T] - def guard[T](cond: Rep[Boolean], then: => Rep[T]): M[T] + def guard[T](cond: Rep[Boolean], dann: => Rep[T]): M[T] def isSuccess[T, U](x: Rep[T])(f: Rep[T] => M[U]): Rep[Boolean] // used for isDefinedAt } @@ -33,7 +36,7 @@ trait Impl extends Intf { def runOrElse[T, U](in: Rep[T])(matcher: Rep[T] => M[U]): Rep[U] = ("runOrElse("+ in +", ?" + matcher("?") + ")") def zero: M[Nothing] = "zero" def one[T](x: Rep[T]): M[T] = "one("+x.toString+")" - def guard[T](cond: Rep[Boolean], then: => Rep[T]): M[T] = "guard("+cond+","+then+")" + def guard[T](cond: Rep[Boolean], dann: => Rep[T]): M[T] = s"guard($cond,$dann)" def isSuccess[T, U](x: Rep[T])(f: Rep[T] => M[U]): Rep[Boolean] = ("isSuccess("+x+", ?" + f("?") + ")") } diff --git a/test/files/run/virtpatmat_stringinterp.scala b/test/files/run/virtpatmat_stringinterp.scala index 213712f17a..c6c951e6e5 100644 --- a/test/files/run/virtpatmat_stringinterp.scala +++ b/test/files/run/virtpatmat_stringinterp.scala @@ -1,3 +1,6 @@ + +import scala.language.{ implicitConversions } + object Test extends App { case class Node(x: Int) @@ -10,4 +13,4 @@ object Test extends App { val x: Node = Node(0) x match { case xml"""<foo arg=$a/>""" => println(a) } -}
\ No newline at end of file +} diff --git a/test/files/run/virtpatmat_try.scala b/test/files/run/virtpatmat_try.scala index 46e67cb72e..dab2c89227 100644 --- a/test/files/run/virtpatmat_try.scala +++ b/test/files/run/virtpatmat_try.scala @@ -8,7 +8,7 @@ object Test extends App { } catch { // this should emit a "catch-switch" case y: A => println(y.x) case (_ : A | _ : B) => println("B") - case _ => println("other") + case _: Throwable => println("other") } try { @@ -17,7 +17,7 @@ object Test extends App { // case A(x) => println(x) case y: A => println(y.x) case x@((_ : A) | (_ : B)) => println(x) - case _ => println("other") + case _: Throwable => println("other") } def simpleTry { @@ -34,7 +34,7 @@ object Test extends App { } def wildcardTry { - try { bla } catch { case _ => bla } + try { bla } catch { case _: Throwable => bla } } def tryPlusFinally { @@ -44,4 +44,4 @@ object Test extends App { def catchAndPassToLambda { try { bla } catch { case ex: Exception => val f = () => ex } } -}
\ No newline at end of file +} diff --git a/test/files/run/virtpatmat_typed.check b/test/files/run/virtpatmat_typed.check index cec2740d18..9924d84148 100644 --- a/test/files/run/virtpatmat_typed.check +++ b/test/files/run/virtpatmat_typed.check @@ -1 +1,4 @@ +virtpatmat_typed.scala:5: warning: unreachable code + case x: String => println("FAILED") + ^ OK foo diff --git a/test/files/run/xml-loop-bug.scala b/test/files/run/xml-loop-bug.scala index 67637674b2..dc155dbb02 100644 --- a/test/files/run/xml-loop-bug.scala +++ b/test/files/run/xml-loop-bug.scala @@ -1,8 +1,14 @@ +import java.io.{ Console => _, _ } +import scala.io._ +import scala.xml.parsing._ object Test { def main(args: Array[String]): Unit = { - val sink = new java.io.PrintStream(new java.io.ByteArrayOutputStream()) - Console setOut sink - Console setErr sink - scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString("<!DOCTYPE xmeml SYSTEM> <xmeml> <sequence> </sequence> </xmeml> "), true).document.docElem + val xml = "<!DOCTYPE xmeml SYSTEM> <xmeml> <sequence> </sequence> </xmeml> " + val sink = new PrintStream(new ByteArrayOutputStream()) + (Console withOut sink) { + (Console withErr sink) { + ConstructingParser.fromSource((Source fromString xml), true).document.docElem + } + } } } |