diff options
Diffstat (limited to 'test/files/run')
37 files changed, 778 insertions, 196 deletions
diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check new file mode 100644 index 0000000000..8856fef5b3 --- /dev/null +++ b/test/files/run/analyzerPlugins.check @@ -0,0 +1,197 @@ +adaptBoundsToAnnots(List( <: Int), List(type T), List(Int @testAnn)) [2] +annotationsConform(Boolean @testAnn, Boolean) [1] +annotationsConform(Boolean(false), Boolean @testAnn) [1] +annotationsConform(Int @testAnn, ?A) [1] +annotationsConform(Int @testAnn, Any) [1] +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] +canAdaptAnnotations(Trees$Ident, String) [1] +canAdaptAnnotations(Trees$Select, ?) [1] +canAdaptAnnotations(Trees$Select, Boolean @testAnn) [1] +canAdaptAnnotations(Trees$Select, Boolean) [1] +canAdaptAnnotations(Trees$Select, String @testAnn) [1] +canAdaptAnnotations(Trees$TypeTree, ?) [10] +canAdaptAnnotations(Trees$Typed, ?) [3] +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$ApplyImplicitView) [2] +pluginsPt(?, Trees$Assign) [7] +pluginsPt(?, Trees$Block) [4] +pluginsPt(?, Trees$ClassDef) [2] +pluginsPt(?, Trees$DefDef) [14] +pluginsPt(?, Trees$Ident) [51] +pluginsPt(?, Trees$If) [2] +pluginsPt(?, Trees$Literal) [16] +pluginsPt(?, Trees$New) [5] +pluginsPt(?, Trees$PackageDef) [1] +pluginsPt(?, Trees$Return) [1] +pluginsPt(?, Trees$Select) [51] +pluginsPt(?, Trees$Super) [2] +pluginsPt(?, Trees$This) [20] +pluginsPt(?, Trees$TypeApply) [3] +pluginsPt(?, Trees$TypeBoundsTree) [2] +pluginsPt(?, Trees$TypeDef) [1] +pluginsPt(?, Trees$TypeTree) [38] +pluginsPt(?, Trees$Typed) [1] +pluginsPt(?, Trees$ValDef) [21] +pluginsPt(Any, Trees$Literal) [2] +pluginsPt(Any, Trees$Typed) [1] +pluginsPt(Array[Any], Trees$ArrayValue) [1] +pluginsPt(Boolean @testAnn, Trees$Literal) [1] +pluginsPt(Boolean @testAnn, Trees$Select) [1] +pluginsPt(Boolean, Trees$Apply) [1] +pluginsPt(Boolean, Trees$Ident) [1] +pluginsPt(Boolean, Trees$Literal) [1] +pluginsPt(Double, Trees$Select) [1] +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) [5] +pluginsPt(Int, Trees$Select) [3] +pluginsPt(List, Trees$Apply) [1] +pluginsPt(List[Any], Trees$Select) [1] +pluginsPt(String @testAnn, Trees$Select) [1] +pluginsPt(String, Trees$Apply) [1] +pluginsPt(String, Trees$Block) [2] +pluginsPt(String, Trees$Ident) [4] +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] +pluginsTypeSig(<none>, Trees$Template) [2] +pluginsTypeSig(class A, Trees$ClassDef) [1] +pluginsTypeSig(class testAnn, Trees$ClassDef) [1] +pluginsTypeSig(constructor A, Trees$DefDef) [2] +pluginsTypeSig(constructor testAnn, Trees$DefDef) [1] +pluginsTypeSig(method foo, Trees$DefDef) [1] +pluginsTypeSig(method method, Trees$DefDef) [1] +pluginsTypeSig(method nested, Trees$DefDef) [1] +pluginsTypeSig(type T, Trees$TypeDef) [2] +pluginsTypeSig(value annotField, Trees$ValDef) [2] +pluginsTypeSig(value f, Trees$ValDef) [1] +pluginsTypeSig(value inferField, Trees$ValDef) [2] +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) [4] +pluginsTypeSig(value y, Trees$ValDef) [4] +pluginsTypeSig(variable count, Trees$ValDef) [3] +pluginsTypeSigAccessor(value annotField) [1] +pluginsTypeSigAccessor(value inferField) [1] +pluginsTypeSigAccessor(value lub1) [1] +pluginsTypeSigAccessor(value lub2) [1] +pluginsTypeSigAccessor(value x) [1] +pluginsTypeSigAccessor(value y) [1] +pluginsTypeSigAccessor(variable count) [2] +pluginsTyped( <: Int, Trees$TypeBoundsTree) [2] +pluginsTyped(()Object, Trees$Select) [1] +pluginsTyped(()String, Trees$Ident) [1] +pluginsTyped(()String, Trees$TypeApply) [1] +pluginsTyped(()scala.annotation.Annotation, Trees$Select) [1] +pluginsTyped(()testAnn, Trees$Select) [10] +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] +pluginsTyped((x: Double)Double <and> (x: Float)Float <and> (x: Long)Long <and> (x: Int)Int <and> (x: Char)Int <and> (x: Short)Int <and> (x: Byte)Int <and> (x: String)String, Trees$Select) [1] +pluginsTyped((x: String)scala.collection.immutable.StringOps, Trees$Select) [2] +pluginsTyped((xs: Array[Any])scala.collection.mutable.WrappedArray[Any], Trees$TypeApply) [1] +pluginsTyped(<empty>.type, Trees$Ident) [1] +pluginsTyped(<error>, Trees$Select) [1] +pluginsTyped(<notype>, Trees$ClassDef) [2] +pluginsTyped(<notype>, Trees$DefDef) [14] +pluginsTyped(<notype>, Trees$PackageDef) [1] +pluginsTyped(<notype>, Trees$TypeDef) [1] +pluginsTyped(<notype>, Trees$ValDef) [21] +pluginsTyped(<root>, Trees$Ident) [1] +pluginsTyped(=> Boolean @testAnn, Trees$Select) [1] +pluginsTyped(=> Double, Trees$Select) [4] +pluginsTyped(=> Int, Trees$Select) [5] +pluginsTyped(=> Int, Trees$TypeApply) [1] +pluginsTyped(=> String @testAnn, Trees$Select) [1] +pluginsTyped(A, Trees$Apply) [1] +pluginsTyped(A, Trees$Ident) [2] +pluginsTyped(A, Trees$This) [8] +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) [4] +pluginsTyped(Array[Any], Trees$ArrayValue) [1] +pluginsTyped(Boolean @testAnn, Trees$Select) [1] +pluginsTyped(Boolean @testAnn, Trees$TypeTree) [4] +pluginsTyped(Boolean(false), Trees$Literal) [2] +pluginsTyped(Boolean, Trees$Apply) [1] +pluginsTyped(Boolean, Trees$Select) [4] +pluginsTyped(Char('c'), Trees$Literal) [2] +pluginsTyped(Double, Trees$Select) [6] +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) [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) [15] +pluginsTyped(Int, Trees$TypeTree) [13] +pluginsTyped(List, Trees$Apply) [1] +pluginsTyped(List, Trees$Select) [1] +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] +pluginsTyped(String @testAnn, Trees$TypeTree) [4] +pluginsTyped(String(""), Trees$Literal) [2] +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) [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) [7] +pluginsTyped(Unit, Trees$Apply) [2] +pluginsTyped(Unit, Trees$Assign) [8] +pluginsTyped(Unit, Trees$Block) [4] +pluginsTyped(Unit, Trees$If) [1] +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([T](xs: Array[T])scala.collection.mutable.WrappedArray[T], Trees$Select) [1] +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] +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$Select) [1] +pluginsTypedReturn(return f, String) [1] diff --git a/test/files/run/analyzerPlugins.scala b/test/files/run/analyzerPlugins.scala new file mode 100644 index 0000000000..daef83fa30 --- /dev/null +++ b/test/files/run/analyzerPlugins.scala @@ -0,0 +1,121 @@ +import scala.tools.partest._ +import scala.tools.nsc._ + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp" + + def code = """ + class testAnn extends annotation.TypeConstraint + + class A(param: Double) extends { val x: Int = 1; val y = "two"; type T = A } with AnyRef { + val inferField = ("str": @testAnn) + val annotField: Boolean @testAnn = false + + val lub1 = List('c', (1: Int @testAnn), "") + val lub2 = if (annotField) (1: @testAnn) else 2 + + def foo[T <: Int] = 0 + foo[Int @testAnn] + + var count = 0 + + math.random // some statement + + def method: String = { + math.random + val f = inferField + + def nested(): String = { + if(count == 1) + return f + "huhu" + } + nested() + } + + def this(str: String) { + this(str.toDouble) + math.random + count += 1 + } + } + """.trim + + + def show() { + val global = newCompiler() + import global._ + import analyzer._ + + val output = collection.mutable.ListBuffer[String]() + + object annotChecker extends AnnotationChecker { + def hasTestAnn(tps: Type*) = { + tps exists (_.annotations.map(_.toString) contains "testAnn") + } + + def annotationsConform(tpe1: Type, tpe2: Type): Boolean = { + if (hasTestAnn(tpe1, tpe2)) + output += s"annotationsConform($tpe1, $tpe2)" + true + } + + override def annotationsLub(tp: Type, ts: List[Type]): Type = { + if (hasTestAnn(ts: _*)) + output += s"lub($ts)" + tp + } + + override def adaptBoundsToAnnotations(bounds: List[TypeBounds], tparams: List[Symbol], targs: List[Type]): List[TypeBounds] = { + if (hasTestAnn(targs: _*)) + output += s"adaptBoundsToAnnots($bounds, $tparams, $targs)" + bounds + } + } + + 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 = { + output += s"pluginsPt($pt, ${treeClass(tree)})" + pt + } + + override def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Int, pt: Type): Type = { + output += s"pluginsTyped($tpe, ${treeClass(tree)})" + tpe + } + + override def pluginsTypeSig(tpe: Type, typer: Typer, defTree: Tree, pt: Type): Type = { + output += s"pluginsTypeSig(${defTree.symbol}, ${treeClass(defTree)})" + tpe + } + + override def pluginsTypeSigAccessor(tpe: Type, typer: Typer, tree: ValDef, sym: Symbol): Type = { + output += s"pluginsTypeSigAccessor(${tree.symbol})" + tpe + } + + + override def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Int, pt: Type): Boolean = { + output += s"canAdaptAnnotations(${treeClass(tree)}, $pt)" + false + } + + override def pluginsTypedReturn(tpe: Type, typer: Typer, tree: Return, pt: Type): Type = { + output += s"pluginsTypedReturn($tree, $pt)" + tpe + } + + } + + addAnnotationChecker(annotChecker) + addAnalyzerPlugin(analyzerPlugin) + compileString(global)(code) + + val res = output.groupBy(identity).mapValues(_.size).map { case (k,v) => s"$k [$v]" }.toList.sorted + println(res.mkString("\n")) + } + +} diff --git a/test/files/run/idempotency-case-classes.check b/test/files/run/idempotency-case-classes.check index 700af3b81b..80d178cba3 100644 --- a/test/files/run/idempotency-case-classes.check +++ b/test/files/run/idempotency-case-classes.check @@ -42,7 +42,7 @@ C(2,3) C.super.<init>(); () }; - final override def toString(): String = "C"; + final override <synthetic> def toString(): String = "C"; case <synthetic> def apply(x: Int, y: Int): C = new C(x, y); case <synthetic> def unapply(x$0: C): Option[(Int, Int)] = if (x$0.==(null)) scala.this.None diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check index 282542a732..f2f0b60687 100644 --- a/test/files/run/inline-ex-handlers.check +++ b/test/files/run/inline-ex-handlers.check @@ -21,59 +21,60 @@ < 92 JUMP 7 < < 7: -395c391 +391c387 < 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 -397c393 -< blocks: [1,2,3,4,5,8,11,13,14,16] +393c389 +< blocks: [1,2,3,4,5,8,10,11,13] --- -> blocks: [1,2,3,5,8,11,13,14,16,17] -421c417,426 +> blocks: [1,2,3,5,8,10,11,13,14] +417c413,422 < 103 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 17 +> ? JUMP 14 > -> 17: +> 14: > 101 LOAD_LOCAL(value ex6) > 101 STORE_LOCAL(value x4) > 101 SCOPE_ENTER value x4 > 106 LOAD_LOCAL(value x4) > 106 IS_INSTANCE REF(class MyException) -> 106 CZJUMP (BOOL)NE ? 5 : 11 -434,436d438 +> 106 CZJUMP (BOOL)NE ? 5 : 8 +430,432d434 < 101 JUMP 4 < < 4: -450,453d451 +442,445d443 < 106 LOAD_LOCAL(value x5) < 106 CALL_METHOD MyException.message (dynamic) < 106 STORE_LOCAL(value message) < 106 SCOPE_ENTER value message -455c453,454 +447c445,446 < 106 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 106 CALL_METHOD MyException.message (dynamic) -527c526 +519c518 < blocks: [1,2,3,4,6,7,8,9,10] --- > blocks: [1,2,3,4,6,7,8,9,10,11,12,13] -556c555,560 +548c547 < 306 THROW(MyException) --- > ? JUMP 11 -> +549a549,553 > 11: > ? LOAD_LOCAL(variable monitor4) > 305 MONITOR_EXIT > ? JUMP 12 -562c566 +> +554c558 < ? THROW(Throwable) --- > ? JUMP 12 -568c572,579 +560c564,571 < ? THROW(Throwable) --- > ? STORE_LOCAL(value t) @@ -84,7 +85,7 @@ > 304 MONITOR_EXIT > ? STORE_LOCAL(value t) > ? JUMP 13 -583a595,606 +575a587,598 > 13: > 310 LOAD_MODULE object Predef > 310 CALL_PRIMITIVE(StartConcat) @@ -97,35 +98,35 @@ > 310 CALL_METHOD scala.Predef.println (dynamic) > 310 JUMP 2 > -592c615 +584c607 < catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6 --- > catch (Throwable) in ArrayBuffer(7, 8, 9, 10, 11) starting at: 6 -595c618 +587c610 < 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 -627c650 +619c642 < blocks: [1,2,3,4,5,6,7,9,10] --- > blocks: [1,2,3,4,5,6,7,9,10,11,12] -651c674,675 +643c666,667 < 78 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) > ? JUMP 11 -652a677,681 +644a669,673 > 11: > 81 LOAD_LOCAL(value e) > ? STORE_LOCAL(variable exc1) > ? JUMP 12 > -680c709,710 +672c701,702 < 81 THROW(Exception) --- > ? STORE_LOCAL(variable exc1) > ? JUMP 12 -696a727,739 +688a719,731 > 12: > 83 LOAD_MODULE object Predef > 83 CONSTANT("finally") @@ -139,88 +140,88 @@ > 84 LOAD_LOCAL(variable exc1) > 84 THROW(Throwable) > -702c745 +694c737 < catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3 --- > catch (<none>) in ArrayBuffer(4, 6, 7, 9, 11) starting at: 3 -726c769 +718c761 < 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 -728c771 -< blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31] +720c763 +< 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,12,14,17,18,19,22,25,27,28,30,31,32,33,34] -752c795,802 +> blocks: [1,2,3,4,5,6,9,11,14,15,16,19,21,22,24,25,26,27,28] +744c787,794 < 172 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 32 +> ? JUMP 26 > -> 32: +> 26: > 170 LOAD_LOCAL(value ex6) > 170 STORE_LOCAL(value x4) > 170 SCOPE_ENTER value x4 -> 170 JUMP 18 -799,802d848 +> 170 JUMP 15 +787,790d836 < 175 LOAD_LOCAL(value x5) < 175 CALL_METHOD MyException.message (dynamic) < 175 STORE_LOCAL(value message) < 175 SCOPE_ENTER value message -804c850,851 +792c838,839 < 176 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 176 CALL_METHOD MyException.message (dynamic) -808c855,856 +796c843,844 < 177 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 177 CALL_METHOD MyException.message (dynamic) -810c858,859 +798c846,847 < 177 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 33 -814c863,864 +> ? JUMP 27 +802c851,852 < 170 THROW(Throwable) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 33 -823a874,879 -> 33: +> ? JUMP 27 +811a862,867 +> 27: > 169 LOAD_LOCAL(value ex6) > 169 STORE_LOCAL(value x4) > 169 SCOPE_ENTER value x4 > 169 JUMP 5 > -838,841d893 +822,825d877 < 180 LOAD_LOCAL(value x5) < 180 CALL_METHOD MyException.message (dynamic) < 180 STORE_LOCAL(value message) < 180 SCOPE_ENTER value message -843c895,896 +827c879,880 < 181 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 181 CALL_METHOD MyException.message (dynamic) -847c900,901 +831c884,885 < 182 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 182 CALL_METHOD MyException.message (dynamic) -849c903,904 +833c887,888 < 182 THROW(MyException) --- > ? STORE_LOCAL(variable exc2) -> ? JUMP 34 -853c908,909 +> ? JUMP 28 +837c892,893 < 169 THROW(Throwable) --- > ? STORE_LOCAL(variable exc2) -> ? JUMP 34 -869a926,938 -> 34: +> ? JUMP 28 +853a910,922 +> 28: > 184 LOAD_MODULE object Predef > 184 CONSTANT("finally") > 184 CALL_METHOD scala.Predef.println (dynamic) @@ -233,159 +234,158 @@ > 185 LOAD_LOCAL(variable exc2) > 185 THROW(Throwable) > -875c944 -< catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30) starting at: 4 +859c928 +< catch (Throwable) in ArrayBuffer(14, 15, 16, 19, 21, 22, 24) starting at: 4 --- -> catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30, 32) starting at: 4 -878c947 -< catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30) starting at: 3 +> catch (Throwable) in ArrayBuffer(14, 15, 16, 19, 21, 22, 24, 26) starting at: 4 +862c931 +< 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, 12, 17, 18, 19, 22, 25, 27, 28, 30, 32, 33) starting at: 3 -902c971 +> catch (<none>) in ArrayBuffer(4, 5, 6, 9, 14, 15, 16, 19, 21, 22, 24, 26, 27) starting at: 3 +886c955 < 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 -904c973 -< blocks: [1,2,3,6,7,8,11,14,16,17,19] +888c957 +< blocks: [1,2,3,6,7,8,11,13,14,16] --- -> blocks: [1,2,3,6,7,8,11,14,16,17,19,20] -928c997,1004 +> blocks: [1,2,3,6,7,8,11,13,14,16,17] +912c981,988 < 124 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 20 +> ? JUMP 17 > -> 20: +> 17: > 122 LOAD_LOCAL(value ex6) > 122 STORE_LOCAL(value x4) > 122 SCOPE_ENTER value x4 > 122 JUMP 7 -957,960d1032 +937,940d1012 < 127 LOAD_LOCAL(value x5) < 127 CALL_METHOD MyException.message (dynamic) < 127 STORE_LOCAL(value message) < 127 SCOPE_ENTER value message -962c1034,1035 +942c1014,1015 < 127 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 127 CALL_METHOD MyException.message (dynamic) -991c1064 -< catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19) starting at: 3 +971c1044 +< catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 13, 14, 16) starting at: 3 --- -> catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19, 20) starting at: 3 -1015c1088 +> catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 13, 14, 16, 17) starting at: 3 +995c1068 < 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 -1017c1090 -< blocks: [1,2,3,4,5,8,11,15,16,17,19] +997c1070 +< blocks: [1,2,3,4,5,8,12,13,14,16] --- -> blocks: [1,2,3,5,8,11,15,16,17,19,20] -1041c1114,1123 +> blocks: [1,2,3,5,8,12,13,14,16,17] +1021c1094,1103 < 148 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 20 +> ? JUMP 17 > -> 20: +> 17: > 145 LOAD_LOCAL(value ex6) > 145 STORE_LOCAL(value x4) > 145 SCOPE_ENTER value x4 > 154 LOAD_LOCAL(value x4) > 154 IS_INSTANCE REF(class MyException) -> 154 CZJUMP (BOOL)NE ? 5 : 11 -1062,1064d1143 +> 154 CZJUMP (BOOL)NE ? 5 : 8 +1042,1044d1123 < 145 JUMP 4 < < 4: -1078,1081d1156 +1054,1057d1132 < 154 LOAD_LOCAL(value x5) < 154 CALL_METHOD MyException.message (dynamic) < 154 STORE_LOCAL(value message) < 154 SCOPE_ENTER value message -1083c1158,1159 +1059c1134,1135 < 154 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 154 CALL_METHOD MyException.message (dynamic) -1300c1376 +1276c1352 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1324c1400,1401 +1300c1376,1383 < 38 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) > ? JUMP 8 -1325a1403,1408 +> > 8: > 42 LOAD_MODULE object Predef > 42 CONSTANT("IllegalArgumentException") > 42 CALL_METHOD scala.Predef.println (dynamic) > 42 JUMP 2 -> -1371c1454 +1347c1430 < 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 -1373c1456 -< blocks: [1,2,3,4,5,8,11,13,14,16,17,19] +1349c1432 +< blocks: [1,2,3,4,5,8,10,11,13,14,16] --- -> blocks: [1,2,3,5,8,11,13,14,16,17,19,20] -1397c1480,1481 +> blocks: [1,2,3,5,8,10,11,13,14,16,17] +1373c1456,1457 < 203 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 20 -1417c1501,1510 +> ? JUMP 17 +1393c1477,1486 < 209 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 20 +> ? JUMP 17 > -> 20: +> 17: > 200 LOAD_LOCAL(value ex6) > 200 STORE_LOCAL(value x4) > 200 SCOPE_ENTER value x4 > 212 LOAD_LOCAL(value x4) > 212 IS_INSTANCE REF(class MyException) -> 212 CZJUMP (BOOL)NE ? 5 : 11 -1430,1432d1522 +> 212 CZJUMP (BOOL)NE ? 5 : 8 +1406,1408d1498 < 200 JUMP 4 < < 4: -1446,1449d1535 +1418,1421d1507 < 212 LOAD_LOCAL(value x5) < 212 CALL_METHOD MyException.message (dynamic) < 212 STORE_LOCAL(value message) < 212 SCOPE_ENTER value message -1451c1537,1538 +1423c1509,1510 < 213 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 213 CALL_METHOD MyException.message (dynamic) -1495c1582 +1467c1554 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1519c1606,1607 +1491c1578,1579 < 58 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) > ? JUMP 8 -1520a1609,1614 +1492a1581,1586 > 8: > 62 LOAD_MODULE object Predef > 62 CONSTANT("RuntimeException") > 62 CALL_METHOD scala.Predef.println (dynamic) > 62 JUMP 2 > -1568c1662 +1540c1634 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1588c1682,1687 +1560c1654,1659 < 229 THROW(MyException) --- > ? JUMP 5 @@ -394,19 +394,19 @@ > ? LOAD_LOCAL(variable monitor1) > 228 MONITOR_EXIT > 228 THROW(Throwable) -1594c1693 +1566c1665 < ? THROW(Throwable) --- > 228 THROW(Throwable) -1622c1721 +1594c1693 < locals: value args, variable result, variable monitor2, variable monitorResult1 --- > locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1 -1624c1723 +1596c1695 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1647c1746,1754 +1619c1718,1726 < 245 THROW(MyException) --- > ? STORE_LOCAL(value exception$1) @@ -418,7 +418,7 @@ > ? LOAD_LOCAL(variable monitor2) > 244 MONITOR_EXIT > 244 THROW(Throwable) -1653c1760 +1625c1732 < ? THROW(Throwable) --- > 244 THROW(Throwable) diff --git a/test/files/run/reify-staticXXX.scala b/test/files/run/reify-staticXXX.scala index dc861f843e..e80157dd8f 100644 --- a/test/files/run/reify-staticXXX.scala +++ b/test/files/run/reify-staticXXX.scala @@ -4,12 +4,12 @@ import scala.tools.reflect.Eval object B { override def toString = "object" } class C { override def toString = "class" } -package foo { +package foo1 { object B { override def toString = "package > object" } class C { override def toString = "package > class" } } -object foo { +object Foo2 { object B { override def toString = "object > object" } class C { override def toString = "object > class" } } @@ -20,14 +20,14 @@ object packageless { println(reify(B).eval) println(new C) println(reify(new C).eval) - println(foo.B) - println(reify(foo.B).eval) - println(new foo.C) - println(reify(new foo.C).eval) - println(_root_.foo.B) - println(reify(_root_.foo.B).eval) - println(new _root_.foo.C) - println(reify(new _root_.foo.C).eval) + println(Foo2.B) + println(reify(Foo2.B).eval) + println(new Foo2.C) + println(reify(new Foo2.C).eval) + println(_root_.foo1.B) + println(reify(_root_.foo1.B).eval) + println(new _root_.foo1.C) + println(reify(new _root_.foo1.C).eval) } } @@ -38,14 +38,14 @@ package packageful { println(reify(B).eval) println(new C) println(reify(new C).eval) - println(foo.B) - println(reify(foo.B).eval) - println(new foo.C) - println(reify(new foo.C).eval) - println(_root_.foo.B) - println(reify(_root_.foo.B).eval) - println(new _root_.foo.C) - println(reify(new _root_.foo.C).eval) + println(Foo2.B) + println(reify(Foo2.B).eval) + println(new Foo2.C) + println(reify(new Foo2.C).eval) + println(_root_.foo1.B) + println(reify(_root_.foo1.B).eval) + println(new _root_.foo1.C) + println(reify(new _root_.foo1.C).eval) } } } diff --git a/test/files/run/t2418.check b/test/files/run/t2418.check new file mode 100644 index 0000000000..f599e28b8a --- /dev/null +++ b/test/files/run/t2418.check @@ -0,0 +1 @@ +10 diff --git a/test/files/run/t2418.scala b/test/files/run/t2418.scala new file mode 100644 index 0000000000..f330bef60a --- /dev/null +++ b/test/files/run/t2418.scala @@ -0,0 +1,10 @@ +class Foo { + @volatile final var x=10 + override def toString = "" + x +} + +object Test { + def main(args: Array[String]): Unit = { + println((new Foo)) + } +} diff --git a/test/files/run/t2818.check b/test/files/run/t2818.check new file mode 100644 index 0000000000..31286c990b --- /dev/null +++ b/test/files/run/t2818.check @@ -0,0 +1,4 @@ +105 +499999500000 +0 +1 diff --git a/test/files/run/t2818.scala b/test/files/run/t2818.scala new file mode 100644 index 0000000000..19b67cbc88 --- /dev/null +++ b/test/files/run/t2818.scala @@ -0,0 +1,6 @@ +object Test extends App { + println((List.range(1L, 15L) :\ 0L) (_ + _)) + println((List.range(1L, 1000000L) :\ 0L) (_ + _)) + println((List.fill(5)(1) :\ 1) (_ - _)) + println((List.fill(1000000)(1) :\ 1) (_ - _)) +} diff --git a/test/files/run/t3353.check b/test/files/run/t3353.check new file mode 100644 index 0000000000..8b4ae1fe69 --- /dev/null +++ b/test/files/run/t3353.check @@ -0,0 +1 @@ +Got: foo and None diff --git a/test/files/run/t3353.scala b/test/files/run/t3353.scala new file mode 100644 index 0000000000..eeb63c1b05 --- /dev/null +++ b/test/files/run/t3353.scala @@ -0,0 +1,10 @@ +object Test extends App { + + "foo" match { + case Matcher(result) => println(result) + } + + object Matcher{ + def unapply(s: String)(implicit secondParam: Option[String] = None) = Some("Got: " + s + " and " + secondParam) + } +} diff --git a/test/files/run/t4574.scala b/test/files/run/t4574.scala deleted file mode 100644 index 1dde496aca..0000000000 --- a/test/files/run/t4574.scala +++ /dev/null @@ -1,13 +0,0 @@ -object Test { - val xs: List[(Int, Int)] = List((2, 2), null) - - def expectMatchError[T](msg: String)(body: => T) { - try { body ; assert(false, "Should not succeed.") } - catch { case _: MatchError => println(msg) } - } - - def main(args: Array[String]): Unit = { - expectMatchError("I hereby refute null!")( for ((x, y) <- xs) yield x ) - expectMatchError("I denounce null as unListLike!")( (null: Any) match { case List(_*) => true } ) - } -} diff --git a/test/files/run/t4729.check b/test/files/run/t4729.check new file mode 100644 index 0000000000..9a2aa56d99 --- /dev/null +++ b/test/files/run/t4729.check @@ -0,0 +1,4 @@ +WrappedArray(1, 2) +WrappedArray(1, 2) +WrappedArray(1, 2) +WrappedArray(1, 2) diff --git a/test/files/run/t4729/J_1.java b/test/files/run/t4729/J_1.java new file mode 100644 index 0000000000..2ffb5a88d1 --- /dev/null +++ b/test/files/run/t4729/J_1.java @@ -0,0 +1,4 @@ +// Java Interface: +public interface J_1 { + public void method(String... s); +} diff --git a/test/files/run/t4729/S_2.scala b/test/files/run/t4729/S_2.scala new file mode 100644 index 0000000000..e34e3d34d4 --- /dev/null +++ b/test/files/run/t4729/S_2.scala @@ -0,0 +1,29 @@ + // Scala class: +class ScalaVarArgs extends J_1 { + // -- no problem on overriding it using ordinary class + def method(s: String*) { println(s) } +} + +object Test { + def main(args: Array[String]) { + //[1] Ok - no problem using inferred type + val varArgs = new J_1 { + def method(s: String*) { println(s) } + } + varArgs.method("1", "2") + + //[2] Ok -- no problem when explicit set its type after construction + val b: J_1 = varArgs + b.method("1", "2") + + //[3] Ok -- no problem on calling its method + (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 + // 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/t5543.check b/test/files/run/t5543.check index 517038f4c7..2ef2d51ff4 100644 --- a/test/files/run/t5543.check +++ b/test/files/run/t5543.check @@ -1,3 +1,9 @@ Test, 7, 119 m, 3, 19 Test, 5, 85 +T +C +T +T +D +T diff --git a/test/files/run/t5543.scala b/test/files/run/t5543.scala index 651bc7f2b2..3684bf9690 100644 --- a/test/files/run/t5543.scala +++ b/test/files/run/t5543.scala @@ -22,5 +22,24 @@ object Test extends Function0[Int] { println(sut.toString) println(sut.m()) println(A.init()()) + + println((new T.C()).x) + println((new T.D(0,0)).x) + } +} + +object T { + override def toString = "T" + + // `this` refers to T + class C(val x: Any = {println(this); this}) { // prints T + println(this) // prints C + override def toString() = "C" + } + + class D(val x: Any) { + override def toString() = "D" + // `this` refers again to T + def this(a: Int, b: Int, c: Any = {println(this); this}) { this(c); println(this) } // prints T, then prints D } } diff --git a/test/files/run/t5604.check b/test/files/run/t5604.check new file mode 100644 index 0000000000..53a2fc8894 --- /dev/null +++ b/test/files/run/t5604.check @@ -0,0 +1,8 @@ +long +double +long +double +long +double +long +double diff --git a/test/files/run/t5604.scala b/test/files/run/t5604.scala new file mode 100644 index 0000000000..a06c8aab3e --- /dev/null +++ b/test/files/run/t5604.scala @@ -0,0 +1,50 @@ +// a.scala +// Fri Jan 13 11:31:47 PST 2012 + +package foo { + object regular extends Duh { + def buh(n: Long) = println("long") + def buh(n: Double) = println("double") + } + class regular { + import regular._ + + duh(33L) + duh(3.0d) + foo.regular.duh(33L) + foo.regular.duh(3.0d) + buh(66L) + buh(6.0d) + foo.regular.buh(66L) + foo.regular.buh(6.0d) + } + + trait Duh { + def duh(n: Long) = println("long") + def duh(n: Double) = println("double") + } + package object bar extends Duh { + def buh(n: Long) = println("long") + def buh(n: Double) = println("double") + } + package bar { + object Main { + def main(args:Array[String]) { + duh(33L) + duh(3.0d) + foo.bar.duh(33L) + foo.bar.duh(3.0d) + buh(66L) + buh(6.0d) + foo.bar.buh(66L) + foo.bar.buh(6.0d) + } + } + } +} + +object Test { + def main(args: Array[String]): Unit = { + foo.bar.Main.main(null) + } +} diff --git a/test/files/run/t6154.check b/test/files/run/t6154.check new file mode 100644 index 0000000000..9766475a41 --- /dev/null +++ b/test/files/run/t6154.check @@ -0,0 +1 @@ +ok diff --git a/test/files/run/t6154.scala b/test/files/run/t6154.scala new file mode 100644 index 0000000000..02ef62905f --- /dev/null +++ b/test/files/run/t6154.scala @@ -0,0 +1,10 @@ +object Test { + def foo(a: Int) { + var bar: Int = 0 + bar = try { 0 } catch { case ex: Throwable => 0 } + new { foo(bar) } + } + + def main(args: Array[String]): Unit = + try foo(0) catch { case _: java.lang.StackOverflowError => println("ok") } +} diff --git a/test/files/run/t6206.check b/test/files/run/t6206.check new file mode 100644 index 0000000000..8064573667 --- /dev/null +++ b/test/files/run/t6206.check @@ -0,0 +1,4 @@ +outer +outer +inner +inner diff --git a/test/files/run/t6206.scala b/test/files/run/t6206.scala new file mode 100644 index 0000000000..07ff246d02 --- /dev/null +++ b/test/files/run/t6206.scala @@ -0,0 +1,37 @@ +class Outer { + def apply( position : Inner ) {} + class Inner + + this.apply(new Inner) + this (new Inner) // error, +} + + +class Outer1 { + + self => + + def apply( position : Inner ) : String = "outer" + + class Inner( ) { + + def apply(arg: Inner): String = "inner" + + def testMe = { + List( + self.apply( this ), // a) this works + self( this ), // b) this does not work! + this apply this, + this(this) + ) foreach println + } + } +} + +object Test { + def main(args: Array[String]): Unit = { + val o = new Outer1 + val i = new o.Inner + i.testMe + } +} diff --git a/test/files/run/t6288.check b/test/files/run/t6288.check index af6bd5d269..4895c2c007 100644 --- a/test/files/run/t6288.check +++ b/test/files/run/t6288.check @@ -11,10 +11,7 @@ [64]case5()[84]{ [84]<synthetic> val o7: [84]Option[Int] = [84][84]Case3.unapply([84]x1); [84]if ([84]o7.isEmpty.unary_!) - [84]{ - [90]val nr: [90]Int = [90]o7.get; - [97][97]matchEnd4([97]()) - } + [97][97]matchEnd4([97]()) else [84][84]case6() }; @@ -38,10 +35,7 @@ [195]<synthetic> val o7: [195]Option[List[Int]] = [195][195]Case4.unapplySeq([195]x1); [195]if ([195]o7.isEmpty.unary_!) [195]if ([195][195][195][195]o7.get.!=([195]null).&&([195][195][195][195]o7.get.lengthCompare([195]1).==([195]0))) - [195]{ - [201]val nr: [201]Int = [201][201]o7.get.apply([201]0); - [208][208]matchEnd4([208]()) - } + [208][208]matchEnd4([208]()) else [195][195]case6() else diff --git a/test/files/run/t6288b-jump-position.check b/test/files/run/t6288b-jump-position.check index 45ec31c308..ece88b18f0 100644 --- a/test/files/run/t6288b-jump-position.check +++ b/test/files/run/t6288b-jump-position.check @@ -19,7 +19,7 @@ object Case3 extends Object { Exception handlers: def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, value x1, value x2, value x + locals: value args, value x1, value x startBlock: 1 blocks: [1,2,3,6,7] @@ -35,10 +35,6 @@ object Case3 extends Object { 5 CZJUMP (BOOL)NE ? 3 : 6 3: - 5 LOAD_LOCAL(value x1) - 5 CHECK_CAST REF(class String) - 5 STORE_LOCAL(value x2) - 5 SCOPE_ENTER value x2 6 LOAD_MODULE object Predef 6 CONSTANT("case 0") 6 CALL_METHOD scala.Predef.println (dynamic) diff --git a/test/files/run/t6572/bar_1.scala b/test/files/run/t6572/bar_1.scala new file mode 100644 index 0000000000..5518ced7af --- /dev/null +++ b/test/files/run/t6572/bar_1.scala @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000000..465f0b7c3c --- /dev/null +++ b/test/files/run/t6572/foo_2.scala @@ -0,0 +1,17 @@ +//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/t6584.check b/test/files/run/t6584.check new file mode 100644 index 0000000000..35c8688751 --- /dev/null +++ b/test/files/run/t6584.check @@ -0,0 +1,8 @@ +Array: 102400 +Vector: 102400 +List: 102400 +Stream: 102400 +Array: 102400 +Vector: 102400 +List: 102400 +Stream: 102400 diff --git a/test/files/run/t6584.scala b/test/files/run/t6584.scala new file mode 100644 index 0000000000..24c236ef35 --- /dev/null +++ b/test/files/run/t6584.scala @@ -0,0 +1,16 @@ +object Test { + def main(args: Array[String]): Unit = { + val size = 100 * 1024 + val doubled = (1 to size) ++ (1 to size) + + println("Array: " + Array.tabulate(size)(x => x).distinct.size) + println("Vector: " + Vector.tabulate(size)(x => x).distinct.size) + println("List: " + List.tabulate(size)(x => x).distinct.size) + println("Stream: " + Stream.tabulate(size)(x => x).distinct.size) + + println("Array: " + doubled.toArray.distinct.size) + println("Vector: " + doubled.toVector.distinct.size) + println("List: " + doubled.toList.distinct.size) + println("Stream: " + doubled.toStream.distinct.size) + } +} diff --git a/test/files/run/t6669.scala b/test/files/run/t6669.scala new file mode 100644 index 0000000000..b55718b12b --- /dev/null +++ b/test/files/run/t6669.scala @@ -0,0 +1,26 @@ +import java.io.{ByteArrayOutputStream, PrintStream} + +object Test extends App { + val baos = new ByteArrayOutputStream() + val ps = new PrintStream(baos) + + // first test with the default classpath + (scala.Console withOut ps) { + scala.tools.scalap.Main.main(Array("-verbose", "java.lang.Object")) + } + + // now make sure we saw the '.' in the classpath + val msg1 = baos.toString() + assert(msg1 contains "directory classpath: .", s"Did not see '.' in the default class path. Full results were:\n$msg1") + + // then test again with a user specified classpath + baos.reset + + (scala.Console withOut ps) { + scala.tools.scalap.Main.main(Array("-verbose", "-cp", "whatever", "java.lang.Object")) + } + + // now make sure we did not see the '.' in the classpath + val msg2 = baos.toString() + assert(!(msg2 contains "directory classpath: ."), s"Did saw '.' in the user specified class path. Full results were:\n$msg2") +} diff --git a/test/files/run/t6853.scala b/test/files/run/t6853.scala new file mode 100644 index 0000000000..352375c99c --- /dev/null +++ b/test/files/run/t6853.scala @@ -0,0 +1,18 @@ +// Test cases: the only place we can cut and paste without crying +// ourself to sleep. +object Test { + + def main(args: Array[String]): Unit = { + // First testing the basic operations + val m = collection.mutable.ListMap[String, Int]() + var i = 0 + while(i < 2) { m += ("foo" + i) -> i; i = i+1} + assert(m == Map("foo1"->1,"foo0"->0)) + m-= "foo0" + assert(m == Map("foo1"->1)) + // Now checking if it scales as described in SI-6853 + i = 0 + while(i < 80000) { m += ("foo" + i) -> i; i = i+1} + assert(m.size == 80000) + } +} diff --git a/test/files/run/t6968.check b/test/files/run/t6968.check new file mode 100644 index 0000000000..7a18941537 --- /dev/null +++ b/test/files/run/t6968.check @@ -0,0 +1 @@ +1, 3, 5 diff --git a/test/files/run/t6968.scala b/test/files/run/t6968.scala new file mode 100644 index 0000000000..b5cadfd9e1 --- /dev/null +++ b/test/files/run/t6968.scala @@ -0,0 +1,7 @@ +object Test { + def main(args: Array[String]) { + val mixedList = List(1,(1,2),4,(3,1),(5,4),6) + val as = for((a,b) <- mixedList) yield a + println(as.mkString(", ")) + } +} diff --git a/test/files/run/t6987.check b/test/files/run/t6987.check deleted file mode 100644 index 86fc96c679..0000000000 --- a/test/files/run/t6987.check +++ /dev/null @@ -1 +0,0 @@ -got successful verbose results! diff --git a/test/files/run/t6987.scala b/test/files/run/t6987.scala deleted file mode 100644 index 37e91d61ae..0000000000 --- a/test/files/run/t6987.scala +++ /dev/null @@ -1,43 +0,0 @@ -import java.io._ -import tools.nsc.{CompileClient, CompileServer} -import java.util.concurrent.{CountDownLatch, TimeUnit} - -object Test extends App { - val startupLatch = new CountDownLatch(1) - // we have to explicitly launch our server because when the client launches a server it uses - // the "scala" shell command meaning whatever version of scala (and whatever version of libraries) - // happens to be in the path gets used - val t = new Thread(new Runnable { - def run() = { - CompileServer.execute(() => startupLatch.countDown(), Array[String]()) - } - }) - t setDaemon true - t.start() - if (!startupLatch.await(2, TimeUnit.MINUTES)) - sys error "Timeout waiting for server to start" - - val baos = new ByteArrayOutputStream() - val ps = new PrintStream(baos) - - val success = (scala.Console withOut ps) { - // shut down the server via the client using the verbose flag - CompileClient.process(Array("-shutdown", "-verbose")) - } - - // now make sure we got success and a verbose result - val msg = baos.toString() - - if (success) { - if (msg contains "Settings after normalizing paths") { - println("got successful verbose results!") - } else { - println("did not get the string expected, full results were:") - println(msg) - } - } else { - println("got a failure. Full results were:") - println(msg) - } - scala.Console.flush -} diff --git a/test/files/run/t7046.check b/test/files/run/t7046.check new file mode 100644 index 0000000000..427f1ce610 --- /dev/null +++ b/test/files/run/t7046.check @@ -0,0 +1,2 @@ +Set(class D, class E) +Set(class D, class E) diff --git a/test/files/run/t7046.scala b/test/files/run/t7046.scala new file mode 100644 index 0000000000..647a15cd18 --- /dev/null +++ b/test/files/run/t7046.scala @@ -0,0 +1,13 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +sealed class C +class D extends C +class E extends C + +object Test extends App { + val c = cm.staticClass("C") + println(c.knownDirectSubclasses) + c.typeSignature + println(c.knownDirectSubclasses) +}
\ No newline at end of file |