diff options
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/annot-nonconst.check | 4 | ||||
-rw-r--r-- | test/files/neg/annot-nonconst.scala | 4 | ||||
-rw-r--r-- | test/files/neg/reify_ann2b.check | 8 | ||||
-rw-r--r-- | test/files/neg/reify_ann2b.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t1878-typer.check | 4 | ||||
-rw-r--r-- | test/files/neg/t1878-typer.scala | 6 | ||||
-rw-r--r-- | test/files/neg/t1878.check | 24 | ||||
-rw-r--r-- | test/files/neg/t1878.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t3189.check | 4 | ||||
-rw-r--r-- | test/files/neg/t3189.scala | 3 | ||||
-rw-r--r-- | test/files/neg/t5067.check | 8 | ||||
-rw-r--r-- | test/files/neg/t5067.scala | 6 | ||||
-rw-r--r-- | test/files/neg/t5702-neg-bad-and-wild.check | 28 | ||||
-rw-r--r-- | test/files/neg/t5702-neg-bad-and-wild.scala | 29 | ||||
-rw-r--r-- | test/files/neg/t5702-neg-bad-brace.check | 10 | ||||
-rw-r--r-- | test/files/neg/t5702-neg-bad-brace.scala | 17 | ||||
-rw-r--r-- | test/files/neg/t5702-neg-bad-xbrace.check | 7 | ||||
-rw-r--r-- | test/files/neg/t5702-neg-bad-xbrace.scala | 31 | ||||
-rw-r--r-- | test/files/neg/t5702-neg-ugly-xbrace.check | 19 | ||||
-rw-r--r-- | test/files/neg/t5702-neg-ugly-xbrace.scala | 14 |
20 files changed, 195 insertions, 35 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) + } +} |