diff options
author | Aleksandar Prokopec <axel22@gmail.com> | 2012-04-30 18:02:15 +0200 |
---|---|---|
committer | Aleksandar Prokopec <axel22@gmail.com> | 2012-04-30 18:02:15 +0200 |
commit | 594fe16b97524f6e587ccecc72121979288d370e (patch) | |
tree | 664a1e81e2ebd11a28ee4ce07cd1db5653962983 /test/files | |
parent | 22475695bd3aa71e814744f3bfef4988b6de1672 (diff) | |
parent | 94c63f5da548996535cad43142758c9405118828 (diff) | |
download | scala-594fe16b97524f6e587ccecc72121979288d370e.tar.gz scala-594fe16b97524f6e587ccecc72121979288d370e.tar.bz2 scala-594fe16b97524f6e587ccecc72121979288d370e.zip |
Merge branch 'master' into feature/future-compat
Diffstat (limited to 'test/files')
56 files changed, 420 insertions, 72 deletions
diff --git a/test/files/neg/annot-nonconst.check b/test/files/neg/annot-nonconst.check index e4166e08b6..b43e58a0ca 100644 --- a/test/files/neg/annot-nonconst.check +++ b/test/files/neg/annot-nonconst.check @@ -1,12 +1,12 @@ annot-nonconst.scala:1: 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 Length(value: Int) extends ClassfileAnnotation +class Length(value: Int) extends annotation.ClassfileAnnotation ^ annot-nonconst.scala:2: 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 Ann2(value: String) extends ClassfileAnnotation +class Ann2(value: String) extends annotation.ClassfileAnnotation ^ annot-nonconst.scala:6: error: annotation argument needs to be a constant; found: n @Length(n) def foo = "foo" diff --git a/test/files/neg/annot-nonconst.scala b/test/files/neg/annot-nonconst.scala index 69bb60d34e..1b5856f8b2 100644 --- a/test/files/neg/annot-nonconst.scala +++ b/test/files/neg/annot-nonconst.scala @@ -1,5 +1,5 @@ -class Length(value: Int) extends ClassfileAnnotation -class Ann2(value: String) extends ClassfileAnnotation +class Length(value: Int) extends annotation.ClassfileAnnotation +class Ann2(value: String) extends annotation.ClassfileAnnotation object Test { def n = 15 diff --git a/test/files/neg/reify_ann2b.check b/test/files/neg/reify_ann2b.check index b9dd84c1ee..52bdbe5b7c 100644 --- a/test/files/neg/reify_ann2b.check +++ b/test/files/neg/reify_ann2b.check @@ -1,4 +1,4 @@ -reify_ann2b.scala:6: error: inner classes cannot be classfile annotations
- class ann(bar: String) extends ClassfileAnnotation
- ^
-one error found
+reify_ann2b.scala:6: error: inner classes cannot be classfile annotations + class ann(bar: String) extends annotation.ClassfileAnnotation + ^ +one error found diff --git a/test/files/neg/reify_ann2b.scala b/test/files/neg/reify_ann2b.scala index 6b6da8f790..397d00210d 100644 --- a/test/files/neg/reify_ann2b.scala +++ b/test/files/neg/reify_ann2b.scala @@ -3,7 +3,7 @@ import scala.reflect.mirror._ object Test extends App { // test 1: reify val tree = reify{ - class ann(bar: String) extends ClassfileAnnotation + class ann(bar: String) extends annotation.ClassfileAnnotation @ann(bar="1a") @ann(bar="1b") class C[@ann(bar="2a") @ann(bar="2b") T](@ann(bar="3a") @ann(bar="3b") x: T @ann(bar="4a") @ann(bar="4b")) { @ann(bar="5a") @ann(bar="5b") def f(x: Int @ann(bar="6a") @ann(bar="6b")) = { diff --git a/test/files/neg/t1878-typer.check b/test/files/neg/t1878-typer.check new file mode 100644 index 0000000000..e3a20d0be7 --- /dev/null +++ b/test/files/neg/t1878-typer.check @@ -0,0 +1,4 @@ +t1878-typer.scala:4: error: _* may only come last + case <p> { _* } </p> => + ^ +one error found diff --git a/test/files/neg/t1878-typer.scala b/test/files/neg/t1878-typer.scala new file mode 100644 index 0000000000..1eb0cb7dff --- /dev/null +++ b/test/files/neg/t1878-typer.scala @@ -0,0 +1,6 @@ +object Test extends App { + // illegal - bug #1764 + null match { + case <p> { _* } </p> => + } +} diff --git a/test/files/neg/t1878.check b/test/files/neg/t1878.check index b47367e12c..ac2071c3d8 100644 --- a/test/files/neg/t1878.check +++ b/test/files/neg/t1878.check @@ -1,21 +1,7 @@ -t1878.scala:3: error: _* may only come last +t1878.scala:3: error: bad use of _* (a sequence pattern must be the last pattern) val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:3: error: scrutinee is incompatible with pattern type; - found : Seq[A] - required: String - val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:3: error: not found: value f - val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:3: error: value _2 is not a member of object Seq - val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:9: error: _* may only come last + ^ +t1878.scala:9: error: bad use of _* (a sequence pattern must be the last pattern) val List(List(_*, arg2), _) = List(List(1,2,3), List(4,5,6)) - ^ -t1878.scala:13: error: _* may only come last - case <p> { _* } </p> => - ^ -6 errors found + ^ +two errors found diff --git a/test/files/neg/t1878.scala b/test/files/neg/t1878.scala index 5278fbb7bd..99fee48a96 100644 --- a/test/files/neg/t1878.scala +++ b/test/files/neg/t1878.scala @@ -8,8 +8,10 @@ object Test extends App { // illegal val List(List(_*, arg2), _) = List(List(1,2,3), List(4,5,6)) + /* see t1878-typer.scala // illegal - bug #1764 null match { case <p> { _* } </p> => } + */ } diff --git a/test/files/neg/t3189.check b/test/files/neg/t3189.check new file mode 100644 index 0000000000..3913c526a2 --- /dev/null +++ b/test/files/neg/t3189.check @@ -0,0 +1,4 @@ +t3189.scala:2: error: use _* to match a sequence + val Array(a,b*) = ("": Any) + ^ +one error found diff --git a/test/files/neg/t3189.scala b/test/files/neg/t3189.scala new file mode 100644 index 0000000000..4ea4bb7581 --- /dev/null +++ b/test/files/neg/t3189.scala @@ -0,0 +1,3 @@ +object A { + val Array(a,b*) = ("": Any) +}
\ No newline at end of file diff --git a/test/files/neg/t5067.check b/test/files/neg/t5067.check index 395eda7442..32491766d7 100644 --- a/test/files/neg/t5067.check +++ b/test/files/neg/t5067.check @@ -1,6 +1,6 @@ t5067.scala:3: error: type mismatch; - found : ((Int, Int, Int)) => Int - required: (Int, Int, Int) => Int - override def tupled: (Int, Int, Int) => Int = super.tupled - ^ + found : ((Int, Int)) => Int + required: (Int, Int) => Int + override def tupled: (Int, Int) => Int = super.tupled + ^ one error found diff --git a/test/files/neg/t5067.scala b/test/files/neg/t5067.scala index 0a961d2f40..f8235c0e83 100644 --- a/test/files/neg/t5067.scala +++ b/test/files/neg/t5067.scala @@ -1,4 +1,4 @@ -class Foo extends Function3[Int, Int, Int, Int] { - def apply(x: Int, y: Int, z: Int) = x + y + z - override def tupled: (Int, Int, Int) => Int = super.tupled +class Foo extends Function2[Int, Int, Int] { + def apply(x: Int, y: Int) = x + y + override def tupled: (Int, Int) => Int = super.tupled } diff --git a/test/files/neg/t5702-neg-bad-and-wild.check b/test/files/neg/t5702-neg-bad-and-wild.check new file mode 100644 index 0000000000..eae81ad5f2 --- /dev/null +++ b/test/files/neg/t5702-neg-bad-and-wild.check @@ -0,0 +1,28 @@ +t5702-neg-bad-and-wild.scala:10: error: bad use of _* (a sequence pattern must be the last pattern) + case List(1, _*,) => // bad use of _* (a sequence pattern must be the last pattern) + ^ +t5702-neg-bad-and-wild.scala:10: error: illegal start of simple pattern + case List(1, _*,) => // bad use of _* (a sequence pattern must be the last pattern) + ^ +t5702-neg-bad-and-wild.scala:12: error: illegal start of simple pattern + case List(1, _*3,) => // illegal start of simple pattern + ^ +t5702-neg-bad-and-wild.scala:14: error: use _* to match a sequence + case List(1, x*) => // use _* to match a sequence + ^ +t5702-neg-bad-and-wild.scala:15: error: trailing * is not a valid pattern + case List(x*, 1) => // trailing * is not a valid pattern + ^ +t5702-neg-bad-and-wild.scala:16: error: trailing * is not a valid pattern + case (1, x*) => // trailing * is not a valid pattern + ^ +t5702-neg-bad-and-wild.scala:17: error: bad use of _* (sequence pattern not allowed) + case (1, x@_*) => // bad use of _* (sequence pattern not allowed) + ^ +t5702-neg-bad-and-wild.scala:23: error: bad use of _* (a sequence pattern must be the last pattern) + val K(ns @ _*, x) = k // bad use of _* (a sequence pattern must be the last pattern) + ^ +t5702-neg-bad-and-wild.scala:24: error: bad use of _* (sequence pattern not allowed) + val (b, _ * ) = Pair(5,6) // bad use of _* (sequence pattern not allowed) + ^ +9 errors found diff --git a/test/files/neg/t5702-neg-bad-and-wild.scala b/test/files/neg/t5702-neg-bad-and-wild.scala new file mode 100644 index 0000000000..3833a002b1 --- /dev/null +++ b/test/files/neg/t5702-neg-bad-and-wild.scala @@ -0,0 +1,29 @@ + +object Test { + case class K(i: Int) + + def main(args: Array[String]) { + val k = new K(9) + val is = List(1,2,3) + + is match { + case List(1, _*,) => // bad use of _* (a sequence pattern must be the last pattern) + // illegal start of simple pattern + case List(1, _*3,) => // illegal start of simple pattern + //case List(1, _*3:) => // poor recovery by parens + case List(1, x*) => // use _* to match a sequence + case List(x*, 1) => // trailing * is not a valid pattern + case (1, x*) => // trailing * is not a valid pattern + case (1, x@_*) => // bad use of _* (sequence pattern not allowed) + } + +// good syntax, bad semantics, detected by typer +//gowild.scala:14: error: star patterns must correspond with varargs parameters + val K(is @ _*) = k + val K(ns @ _*, x) = k // bad use of _* (a sequence pattern must be the last pattern) + val (b, _ * ) = Pair(5,6) // bad use of _* (sequence pattern not allowed) +// no longer complains +//bad-and-wild.scala:15: error: ')' expected but '}' found. + } +} + diff --git a/test/files/neg/t5702-neg-bad-brace.check b/test/files/neg/t5702-neg-bad-brace.check new file mode 100644 index 0000000000..503f7d95ed --- /dev/null +++ b/test/files/neg/t5702-neg-bad-brace.check @@ -0,0 +1,10 @@ +t5702-neg-bad-brace.scala:14: error: Unmatched closing brace '}' ignored here + case List(1, _*} => + ^ +t5702-neg-bad-brace.scala:14: error: illegal start of simple pattern + case List(1, _*} => + ^ +t5702-neg-bad-brace.scala:15: error: ')' expected but '}' found. + } + ^ +three errors found diff --git a/test/files/neg/t5702-neg-bad-brace.scala b/test/files/neg/t5702-neg-bad-brace.scala new file mode 100644 index 0000000000..16a341cf8c --- /dev/null +++ b/test/files/neg/t5702-neg-bad-brace.scala @@ -0,0 +1,17 @@ + +object Test { + + def main(args: Array[String]) { + val is = List(1,2,3) + + is match { +// the erroneous brace is ignored, so we can't halt on it. +// maybe brace healing can detect overlapping unmatched (...} +// In this case, the fix emits an extra error: +// t5702-neg-bad-brace.scala:10: error: Unmatched closing brace '}' ignored here +// t5702-neg-bad-brace.scala:10: error: illegal start of simple pattern (i.e., =>) +// t5702-neg-bad-brace.scala:11: error: ')' expected but '}' found. + case List(1, _*} => + } + } +} diff --git a/test/files/neg/t5702-neg-bad-xbrace.check b/test/files/neg/t5702-neg-bad-xbrace.check new file mode 100644 index 0000000000..d88638aee9 --- /dev/null +++ b/test/files/neg/t5702-neg-bad-xbrace.check @@ -0,0 +1,7 @@ +t5702-neg-bad-xbrace.scala:19: error: bad brace or paren after _* + case <year>{_*)}</year> => y + ^ +t5702-neg-bad-xbrace.scala:28: error: bad brace or paren after _* + val <top>{a, z@_*)}</top> = xml + ^ +two errors found diff --git a/test/files/neg/t5702-neg-bad-xbrace.scala b/test/files/neg/t5702-neg-bad-xbrace.scala new file mode 100644 index 0000000000..64bbdb18be --- /dev/null +++ b/test/files/neg/t5702-neg-bad-xbrace.scala @@ -0,0 +1,31 @@ + +object Test { + def main(args: Array[String]) { + /* PiS example, minus a brace + val yearMade = 1965 + val old = + <a>{ if (yearMade < 2000) <old>yearMade}</old> + else xml.NodeSeq.Empty } </a> + println(old) + */ + + // bad brace or paren after _* + // actually, we know it's a bad paren... + // we skip it because not in a context looking for rparen + val xyear = <year>1965</year> + val ancient = + <b>{ + val when = xyear match { + case <year>{_*)}</year> => y + case _ => "2035" + } + <old>{when}</old> + }</b> + println(ancient) + + val xml = <top><a>apple</a><b>boy</b><c>child</c></top> + // bad brace or paren after _* + val <top>{a, z@_*)}</top> = xml + println("A for "+ a +", ending with "+ z) + } +} diff --git a/test/files/neg/t5702-neg-ugly-xbrace.check b/test/files/neg/t5702-neg-ugly-xbrace.check new file mode 100644 index 0000000000..7d80bbf6be --- /dev/null +++ b/test/files/neg/t5702-neg-ugly-xbrace.check @@ -0,0 +1,19 @@ +t5702-neg-ugly-xbrace.scala:11: error: bad brace or paren after _* + val <top>{a, z@_*)</top> = xml + ^ +t5702-neg-ugly-xbrace.scala:12: error: Missing closing brace `}' assumed here + println("A for "+ a +", ending with "+ z) + ^ +t5702-neg-ugly-xbrace.scala:13: error: in XML literal: in XML content, please use '}}' to express '}' + } + ^ +t5702-neg-ugly-xbrace.scala:11: error: I encountered a '}' where I didn't expect one, maybe this tag isn't closed <top> + val <top>{a, z@_*)</top> = xml + ^ +t5702-neg-ugly-xbrace.scala:14: error: illegal start of simple pattern +} +^ +t5702-neg-ugly-xbrace.scala:14: error: '}' expected but eof found. +} + ^ +6 errors found diff --git a/test/files/neg/t5702-neg-ugly-xbrace.scala b/test/files/neg/t5702-neg-ugly-xbrace.scala new file mode 100644 index 0000000000..0ff7bfa09d --- /dev/null +++ b/test/files/neg/t5702-neg-ugly-xbrace.scala @@ -0,0 +1,14 @@ + +object Test { + def main(args: Array[String]) { + + val xml = <top><a>apple</a><b>boy</b><c>child</c></top> + // This is the more likely typo, and the uglier parse. + // We could turn it into a } if } does not follow (to + // avoid handing }} back to xml) but that is quite ad hoc. + // Assuming } for ) after _* would not be not outlandish. + // bad brace or paren after _* + val <top>{a, z@_*)</top> = xml + println("A for "+ a +", ending with "+ z) + } +} diff --git a/test/files/pos/annot-inner.scala b/test/files/pos/annot-inner.scala index f2ecb5ddb3..9f155a5a83 100644 --- a/test/files/pos/annot-inner.scala +++ b/test/files/pos/annot-inner.scala @@ -1,5 +1,5 @@ object test { - class annot extends Annotation + class annot extends scala.annotation.Annotation def foo { @annot def bar(i: Int): Int = i diff --git a/test/files/pos/annotDepMethType.scala b/test/files/pos/annotDepMethType.scala index b5e7cb9e8b..079ca6224c 100644 --- a/test/files/pos/annotDepMethType.scala +++ b/test/files/pos/annotDepMethType.scala @@ -1,4 +1,4 @@ -case class pc(calls: Any*) extends TypeConstraint +case class pc(calls: Any*) extends annotation.TypeConstraint object Main { class C0 { def baz: String = "" } diff --git a/test/files/pos/annotations.scala b/test/files/pos/annotations.scala index 4e5fddda39..706a715bad 100644 --- a/test/files/pos/annotations.scala +++ b/test/files/pos/annotations.scala @@ -1,5 +1,5 @@ -class ann(i: Int) extends Annotation -class cfann(x: String) extends ClassfileAnnotation +class ann(i: Int) extends scala.annotation.Annotation +class cfann(x: String) extends annotation.ClassfileAnnotation // annotations on abstract types abstract class C1[@serializable @cloneable +T, U, V[_]] @@ -91,9 +91,9 @@ trait BeanF { } -class Ann3(arr: Array[String]) extends ClassfileAnnotation -class Ann4(i: Int) extends ClassfileAnnotation -class Ann5(value: Class[_]) extends ClassfileAnnotation +class Ann3(arr: Array[String]) extends annotation.ClassfileAnnotation +class Ann4(i: Int) extends annotation.ClassfileAnnotation +class Ann5(value: Class[_]) extends annotation.ClassfileAnnotation object Test3 { final val i = 1083 diff --git a/test/files/pos/attributes.scala b/test/files/pos/attributes.scala index f3bbb4c42e..ec735d0aae 100644 --- a/test/files/pos/attributes.scala +++ b/test/files/pos/attributes.scala @@ -52,15 +52,15 @@ object O6 { } object myAttrs { - class a1 extends scala.Annotation; - class a2(x: Int) extends scala.Annotation; - class a3(x: a1) extends scala.Annotation; + class a1 extends scala.annotation.Annotation; + class a2(x: Int) extends scala.annotation.Annotation; + class a3(x: a1) extends scala.annotation.Annotation; } -class a4(ns: Array[Int]) extends scala.Annotation; +class a4(ns: Array[Int]) extends scala.annotation.Annotation; object O7 { - class a1 extends scala.Annotation; - class a2(x: Int) extends scala.Annotation; - class a3(x: a1) extends scala.Annotation; + class a1 extends scala.annotation.Annotation; + class a2(x: Int) extends scala.annotation.Annotation; + class a3(x: a1) extends scala.annotation.Annotation; final val x = new a1; @a1 class C1; diff --git a/test/files/pos/spec-annotations.scala b/test/files/pos/spec-annotations.scala index 35cab6de09..48281e5df5 100644 --- a/test/files/pos/spec-annotations.scala +++ b/test/files/pos/spec-annotations.scala @@ -1,4 +1,4 @@ -class ann(i: Int) extends Annotation +class ann(i: Int) extends scala.annotation.Annotation // annotations on abstract types abstract class C1[@serializable @cloneable +T, U, V[_]] diff --git a/test/files/pos/t1029/Test_1.scala b/test/files/pos/t1029/Test_1.scala index e828087f2c..d268c71429 100644 --- a/test/files/pos/t1029/Test_1.scala +++ b/test/files/pos/t1029/Test_1.scala @@ -1,4 +1,4 @@ -class ann(a: Array[Int]) extends StaticAnnotation +class ann(a: Array[Int]) extends annotation.StaticAnnotation object Test1 { // bug #1029 diff --git a/test/files/pos/t1203.scala b/test/files/pos/t1203.scala index 4938621aa9..062ef93fc6 100644 --- a/test/files/pos/t1203.scala +++ b/test/files/pos/t1203.scala @@ -1,4 +1,4 @@ -case class ant(t: String) extends Annotation +case class ant(t: String) extends scala.annotation.Annotation object Test { def main(args: Array[String]): Unit = { val a: scala.xml.NodeSeq @ant("12") = Nil diff --git a/test/files/pos/t1942/A_1.scala b/test/files/pos/t1942/A_1.scala index 19a7575a0a..4915b54a64 100644 --- a/test/files/pos/t1942/A_1.scala +++ b/test/files/pos/t1942/A_1.scala @@ -3,7 +3,7 @@ class A { def foo(x: String) = 1 } -class ann(x: Int) extends StaticAnnotation +class ann(x: Int) extends annotation.StaticAnnotation class t { val a = new A diff --git a/test/files/pos/t2868/pick_1.scala b/test/files/pos/t2868/pick_1.scala index e91728ec2f..a211687432 100644 --- a/test/files/pos/t2868/pick_1.scala +++ b/test/files/pos/t2868/pick_1.scala @@ -1,4 +1,4 @@ -class ann(s: String) extends StaticAnnotation +class ann(s: String) extends annotation.StaticAnnotation class pick { final val s = "bang!" @ann("bang!") def foo = 1 diff --git a/test/files/pos/t3800.scala b/test/files/pos/t3800.scala index 796eb268c5..61dbeafff3 100644 --- a/test/files/pos/t3800.scala +++ b/test/files/pos/t3800.scala @@ -1,4 +1,4 @@ -class meh extends StaticAnnotation +class meh extends annotation.StaticAnnotation class ALike[C] abstract class AFactory[CC[x] <: ALike[CC[x]]] { diff --git a/test/files/pos/t3951/Coll_1.scala b/test/files/pos/t3951/Coll_1.scala index c2cc39a1a9..556c848688 100644 --- a/test/files/pos/t3951/Coll_1.scala +++ b/test/files/pos/t3951/Coll_1.scala @@ -15,7 +15,7 @@ sealed trait DynamicDocument extends Document { class Coll extends StaticDocument // similiar issue with annotations -class ann[T] extends StaticAnnotation +class ann[T] extends annotation.StaticAnnotation trait StatDoc extends Doc { @ann[StatFB] diff --git a/test/files/pos/t5702-pos-infix-star.scala b/test/files/pos/t5702-pos-infix-star.scala new file mode 100644 index 0000000000..756bcdd8de --- /dev/null +++ b/test/files/pos/t5702-pos-infix-star.scala @@ -0,0 +1,15 @@ + +object Test { + case class *(a: Int, b: Int) + type Star = * + case class P(a: Int, b: Star) // alias still required + + def main(args: Array[String]) { + val v = new *(6,7) + val x * y = v + printf("%d,%d\n",x,y) + val p = P(5, v) + val P(a, b * c) = p + printf("%d,%d,%d\n",a,b,c) + } +} diff --git a/test/files/pos/virtpatmat_partialfun_nsdnho.scala b/test/files/pos/virtpatmat_partialfun_nsdnho.scala new file mode 100644 index 0000000000..f79e82813c --- /dev/null +++ b/test/files/pos/virtpatmat_partialfun_nsdnho.scala @@ -0,0 +1,18 @@ +class Test { + // m.$minus(1) + // at scala.Predef$.assert(Predef.scala:185) + // at scala.tools.nsc.Global.assert(Global.scala:187) + // at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.transform(SuperAccessors.scala:291) + val a: (Map[Int, Int] => (Any => Any)) = { m => { case _ => m - 1} } + + // patmat-crash.scala:9: error: erroneous or inaccessible type + val b: (Int => (Any => Any)) = { m => { case _ => m } } + + // no-symbol does not have an owner (this is a bug: scala version 2.10.0-20120420-170445-56c1f29250) + // at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:45) + // at scala.tools.nsc.Global.abort(Global.scala:202) + // at scala.reflect.internal.Symbols$NoSymbol.owner(Symbols.scala:3031) + // at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.hostForAccessorOf(SuperAccessors.scala:474) + // at scala.tools.nsc.typechecker.SuperAccessors$SuperAccTransformer.needsProtectedAccessor(SuperAccessors.scala:457) + val c: (Int => (Any => Any)) = { m => { case _ => m.toInt } } +}
\ No newline at end of file diff --git a/test/files/run/bugs.scala b/test/files/run/bugs.scala index d5905af76c..ca598603bb 100644 --- a/test/files/run/bugs.scala +++ b/test/files/run/bugs.scala @@ -445,8 +445,7 @@ object Test { test; } catch { case exception => - val curr: String = currentThread.toString(); - Console.print("Exception in thread \"" + curr + "\" " + exception); + Console.print("Exception in thread \"" + Thread.currentThread + "\" " + exception); Console.println; errors += 1 } diff --git a/test/files/run/inner-parse.check b/test/files/run/inner-parse.check new file mode 100644 index 0000000000..87ea9ddeb5 --- /dev/null +++ b/test/files/run/inner-parse.check @@ -0,0 +1,86 @@ +file Test$$anonfun$main$1.class +class Test$$anonfun$main$1 extends scala.runtime.AbstractFunction1$mcVL$sp + interface scala.Serializable + inner/anon anonymous class: Test$$anonfun$main$1 + descriptor <clinit> ()V + descriptor apply (Lscala/Tuple2;)V + descriptor apply (Ljava/lang/Object;)Ljava/lang/Object; + descriptor cwd$1 Ljava/lang/String; + descriptor serialVersionUID J + descriptor <init> (Ljava/lang/String;)V + signature apply (Lscala/Tuple2<Ljava/lang/String;Lscala/reflect/internal/JvmClassInfo;>;)V + +file Test$.class +class Test$ extends java.lang.Object + inner/anon anonymous class: Test$$anonfun$main$1 + descriptor <clinit> ()V + descriptor MODULE$ LTest$; + descriptor main ([Ljava/lang/String;)V + descriptor <init> ()V + +file Test.class +class Test extends java.lang.Object + inner/anon anonymous class: Test$$anonfun$main$1 + descriptor main ([Ljava/lang/String;)V + +file j/J_1$B$C$D.class +class j.J_1$B$C$D extends java.lang.Object + inner B j.J_1$B in j.J_1 + inner C j.J_1$B$C in j.J_1$B + inner/enclosing D enclosing class: j.J_1$B$C + descriptor <init> (Lj/J_1$B$C;)V + descriptor this$2 Lj/J_1$B$C; + +file j/J_1$B$C.class +class j.J_1$B$C extends java.lang.Object + inner B j.J_1$B in j.J_1 + inner/enclosing C enclosing class: j.J_1$B + inner/nested D member class: j.J_1$B$C$D + descriptor <init> (Lj/J_1$B;)V + descriptor this$1 Lj/J_1$B; + +file j/J_1$B.class +class j.J_1$B extends java.lang.Object + inner/enclosing B enclosing class: j.J_1 + inner/nested C member class: j.J_1$B$C + descriptor <init> (Lj/J_1;)V + descriptor this$0 Lj/J_1; + +file j/J_1.class +class j.J_1 extends java.lang.Object + interface java.util.RandomAccess + inner/nested B member class: j.J_1$B + descriptor <init> ()V + +file s/J_1$B$C$D.class +class s.J_1$B$C$D extends java.lang.Object + inner B s.J_1$B in s.J_1 + inner C s.J_1$B$C in s.J_1$B + inner/enclosing D enclosing class: s.J_1$B$C + descriptor $outer Ls/J_1$B$C; + descriptor s$J_1$B$C$D$$$outer ()Ls/J_1$B$C; + descriptor <init> (Ls/J_1$B$C;)V + +file s/J_1$B$C.class +class s.J_1$B$C extends java.lang.Object + inner B s.J_1$B in s.J_1 + inner/enclosing C enclosing class: s.J_1$B + inner/nested D member class: s.J_1$B$C$D + descriptor $outer Ls/J_1$B; + descriptor s$J_1$B$C$$$outer ()Ls/J_1$B; + descriptor <init> (Ls/J_1$B;)V + +file s/J_1$B.class +class s.J_1$B extends java.lang.Object + inner/enclosing B enclosing class: s.J_1 + inner/nested C member class: s.J_1$B$C + descriptor $outer Ls/J_1; + descriptor s$J_1$B$$$outer ()Ls/J_1; + descriptor <init> (Ls/J_1;)V + +file s/J_1.class +class s.J_1 extends java.lang.Object + interface java.util.RandomAccess + inner/nested B member class: s.J_1$B + descriptor <init> ()V + diff --git a/test/files/run/inner-parse/J_1.java b/test/files/run/inner-parse/J_1.java new file mode 100644 index 0000000000..920ab951ab --- /dev/null +++ b/test/files/run/inner-parse/J_1.java @@ -0,0 +1,9 @@ +package j; + +public class J_1 implements java.util.RandomAccess { // "random" marker interface + class B { + class C { + class D { } + } + } +} diff --git a/test/files/run/inner-parse/S_2.scala b/test/files/run/inner-parse/S_2.scala new file mode 100644 index 0000000000..fd144a40b7 --- /dev/null +++ b/test/files/run/inner-parse/S_2.scala @@ -0,0 +1,9 @@ +package s; + +class J_1 extends java.util.RandomAccess { + class B { + class C { + class D { } + } + } +} diff --git a/test/files/run/inner-parse/S_3.scala b/test/files/run/inner-parse/S_3.scala new file mode 100644 index 0000000000..aaa6a6ad35 --- /dev/null +++ b/test/files/run/inner-parse/S_3.scala @@ -0,0 +1,12 @@ +import scala.reflect.internal.JvmClassInfo + +object Test { + def main(args: Array[String]): Unit = { + val cwd = sys.props("partest.output") + + for ((f, info) <- JvmClassInfo.classInfoList(cwd)) { + println("file " + f.stripPrefix(cwd).substring(1).replace('\\', '/')) + println(info) + } + } +} diff --git a/test/files/run/macro-declared-in-annotation/Macros_2.scala b/test/files/run/macro-declared-in-annotation/Macros_2.scala index a565849aa9..40d71c62fb 100644 --- a/test/files/run/macro-declared-in-annotation/Macros_2.scala +++ b/test/files/run/macro-declared-in-annotation/Macros_2.scala @@ -1,4 +1,4 @@ -class foo(val bar: String) extends StaticAnnotation +class foo(val bar: String) extends annotation.StaticAnnotation object Api { // foo in ann must have a different name diff --git a/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala index 13b603d610..086f9aeef2 100644 --- a/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala @@ -1,7 +1,10 @@ import scala.reflect.makro.{Context => Ctx} object Impls { - def foo(c: Ctx)(x: c.Expr[Int]) = c.literal(x.eval) + def foo(c: Ctx)(x: c.Expr[Int]) = { + val x1 = c.Expr[Int](c.resetAllAttrs(x.tree)) + c.literal(x1.eval) + } } object Macros { diff --git a/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala index 28ec1ace67..109e19e44a 100644 --- a/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala @@ -1,7 +1,10 @@ import scala.reflect.makro.{Context => Ctx} object Impls { - def foo(c: Ctx)(x: c.Expr[Int]) = c.literal(x.value) + def foo(c: Ctx)(x: c.Expr[Int]) = { + val x1 = c.Expr[Int](c.resetAllAttrs(x.tree)) + c.literal(x1.value) + } } object Macros { diff --git a/test/files/run/reify_ann1a.scala b/test/files/run/reify_ann1a.scala index 1f5d1daccd..6c062ca2c2 100644 --- a/test/files/run/reify_ann1a.scala +++ b/test/files/run/reify_ann1a.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class ann(bar: List[String]) extends StaticAnnotation +class ann(bar: List[String]) extends annotation.StaticAnnotation object Test extends App { // test 1: reify diff --git a/test/files/run/reify_ann1b.scala b/test/files/run/reify_ann1b.scala index 13d861a15c..4faddef72c 100644 --- a/test/files/run/reify_ann1b.scala +++ b/test/files/run/reify_ann1b.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class ann(bar: String) extends ClassfileAnnotation +class ann(bar: String) extends annotation.ClassfileAnnotation object Test extends App { // test 1: reify diff --git a/test/files/run/reify_ann2a.scala b/test/files/run/reify_ann2a.scala index 370abadba0..a1723c221d 100644 --- a/test/files/run/reify_ann2a.scala +++ b/test/files/run/reify_ann2a.scala @@ -3,7 +3,7 @@ import scala.reflect.mirror._ object Test extends App { // test 1: reify val tree = reify{ - class ann(bar: List[String]) extends StaticAnnotation + class ann(bar: List[String]) extends annotation.StaticAnnotation @ann(bar=List("1a")) @ann(bar=List("1b")) class C[@ann(bar=List("2a")) @ann(bar=List("2b")) T](@ann(bar=List("3a")) @ann(bar=List("3b")) x: T @ann(bar=List("4a")) @ann(bar=List("4b"))) { @ann(bar=List("5a")) @ann(bar=List("5b")) def f(x: Int @ann(bar=List("6a")) @ann(bar=List("6b"))) = { diff --git a/test/files/run/reify_classfileann_a.scala b/test/files/run/reify_classfileann_a.scala index c3e7d8d2e9..9aec69b4a3 100644 --- a/test/files/run/reify_classfileann_a.scala +++ b/test/files/run/reify_classfileann_a.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends ClassfileAnnotation +class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends annotation.ClassfileAnnotation object Test extends App { // test 1: reify diff --git a/test/files/run/reify_classfileann_b.scala b/test/files/run/reify_classfileann_b.scala index 4e50494af3..a37f20e72e 100644 --- a/test/files/run/reify_classfileann_b.scala +++ b/test/files/run/reify_classfileann_b.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends ClassfileAnnotation +class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends annotation.ClassfileAnnotation object Test extends App { // test 1: reify diff --git a/test/files/run/t1500.scala b/test/files/run/t1500.scala index c312a9a883..586a2666ad 100644 --- a/test/files/run/t1500.scala +++ b/test/files/run/t1500.scala @@ -8,7 +8,7 @@ object Test { val testCode = <code> - class posingAs[A] extends TypeConstraint + class posingAs[A] extends annotation.TypeConstraint def resolve[A,B](x: A @posingAs[B]): B = x.asInstanceOf[B] diff --git a/test/files/run/t1501.scala b/test/files/run/t1501.scala index 05e4da8c7a..dee6e0c68e 100644 --- a/test/files/run/t1501.scala +++ b/test/files/run/t1501.scala @@ -8,7 +8,7 @@ object Test { val testCode = <code> - class xyz[A] extends TypeConstraint + class xyz[A] extends annotation.TypeConstraint def loopWhile[T](cond: =>Boolean)(body: =>(Unit @xyz[T])): Unit @ xyz[T] = {{ if (cond) {{ diff --git a/test/files/run/t5224.scala b/test/files/run/t5224.scala index 93b244e03e..cf65f16457 100644 --- a/test/files/run/t5224.scala +++ b/test/files/run/t5224.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class Foo(bar: String) extends ClassfileAnnotation +class Foo(bar: String) extends annotation.ClassfileAnnotation object Test extends App { val tree = reify{@Foo(bar = "qwe") class C}.tree diff --git a/test/files/run/t5419.scala b/test/files/run/t5419.scala index d65d8f38c8..5f11f5056c 100644 --- a/test/files/run/t5419.scala +++ b/test/files/run/t5419.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -class Foo extends StaticAnnotation +class Foo extends annotation.StaticAnnotation object Test extends App { val tree = reify{(5: @Foo).asInstanceOf[Int]}.tree diff --git a/test/files/run/t5423.scala b/test/files/run/t5423.scala index 645c8c7c1d..ed1faf0429 100644 --- a/test/files/run/t5423.scala +++ b/test/files/run/t5423.scala @@ -1,6 +1,6 @@ import scala.reflect.mirror._ -final class table extends StaticAnnotation +final class table extends annotation.StaticAnnotation @table class A object Test extends App { diff --git a/test/files/run/t5713.check b/test/files/run/t5713.check new file mode 100644 index 0000000000..d3e9348123 --- /dev/null +++ b/test/files/run/t5713.check @@ -0,0 +1 @@ +err
diff --git a/test/files/run/t5713.flags b/test/files/run/t5713.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/t5713.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/t5713/Impls_Macros_1.scala b/test/files/run/t5713/Impls_Macros_1.scala new file mode 100644 index 0000000000..b499bc7e4e --- /dev/null +++ b/test/files/run/t5713/Impls_Macros_1.scala @@ -0,0 +1,27 @@ +package m + +import language.experimental.macros +import scala.reflect.makro.Context + +object Level extends Enumeration { + val Error = Value(5) +} + +object Logger { + def error(message: String): Unit = macro LoggerMacros.error +} + +private object LoggerMacros { + + type LoggerContext = Context { type PrefixType = Logger.type } + + def error(c: LoggerContext)(message: c.Expr[String]): c.Expr[Unit] = + log(c)(c.reify(Level.Error), message) + + private def log(c: LoggerContext)(level: c.Expr[Level.Value], message: c.Expr[String]): c.Expr[Unit] = + if (level.eval.id < 4) // TODO Remove hack! + c.reify(()) + else { + c.reify(println(message.eval)) + } +}
\ No newline at end of file diff --git a/test/files/run/t5713/Test_2.scala b/test/files/run/t5713/Test_2.scala new file mode 100644 index 0000000000..24f9e79b11 --- /dev/null +++ b/test/files/run/t5713/Test_2.scala @@ -0,0 +1,5 @@ +import m._ + +object Test extends App { + Logger.error("err") +}
\ No newline at end of file diff --git a/test/files/run/tuple-zipped.scala b/test/files/run/tuple-zipped.scala index 08dcc82de6..a9851346bc 100644 --- a/test/files/run/tuple-zipped.scala +++ b/test/files/run/tuple-zipped.scala @@ -15,7 +15,7 @@ object Test { def main(args: Array[String]): Unit = { for (cc1 <- xss1 ; cc2 <- xss2) { - val sum1 = (cc1 zip cc2) map { case (x, y) => x + y } sum + val sum1 = (cc1, cc2).zip map { case (x, y) => x + y } sum val sum2 = (cc1, cc2).zipped map (_ + _) sum assert(sum1 == sum2) |