diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-01-15 16:48:56 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-01-16 10:35:09 -0800 |
commit | 77dffe4aa79b414ab3f3a0a24c34140f1bbd6024 (patch) | |
tree | 9f737ea5aff9db636e5c01b3792c675463957b43 /test/files/neg | |
parent | ef332d2a265ab86a6ec415be61b7896a83068bca (diff) | |
parent | 6f3ea77870ab5e17805ef0fc338c251e87870b8c (diff) | |
download | scala-77dffe4aa79b414ab3f3a0a24c34140f1bbd6024.tar.gz scala-77dffe4aa79b414ab3f3a0a24c34140f1bbd6024.tar.bz2 scala-77dffe4aa79b414ab3f3a0a24c34140f1bbd6024.zip |
Merge branch '2.10.x'
Conflicts:
src/compiler/scala/tools/nsc/doc/Settings.scala
src/compiler/scala/tools/nsc/interpreter/CompletionOutput.scala
src/compiler/scala/tools/nsc/matching/Patterns.scala
src/compiler/scala/tools/nsc/transform/UnCurry.scala
src/compiler/scala/tools/nsc/typechecker/Infer.scala
src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
src/compiler/scala/tools/nsc/typechecker/Typers.scala
src/reflect/scala/reflect/internal/settings/MutableSettings.scala
src/reflect/scala/reflect/runtime/Settings.scala
src/swing/scala/swing/SwingActor.scala
src/swing/scala/swing/SwingWorker.scala
test/files/run/t6955.scala
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/package-ob-case.check | 4 | ||||
-rw-r--r-- | test/files/neg/t5340.check | 6 | ||||
-rw-r--r-- | test/files/neg/t5340.scala | 29 | ||||
-rw-r--r-- | test/files/neg/t5440.check | 7 | ||||
-rw-r--r-- | test/files/neg/t5440.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t5440.scala | 7 | ||||
-rw-r--r-- | test/files/neg/t5954.check | 16 | ||||
-rw-r--r-- | test/files/neg/t5954.scala | 46 | ||||
-rw-r--r-- | test/files/neg/t6082.check | 13 | ||||
-rw-r--r-- | test/files/neg/t6082.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t6675.check | 6 | ||||
-rw-r--r-- | test/files/neg/t6675.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t6675.scala | 13 | ||||
-rw-r--r-- | test/files/neg/t6912.check | 4 | ||||
-rw-r--r-- | test/files/neg/t6912.scala | 9 | ||||
-rw-r--r-- | test/files/neg/t6928.check | 7 | ||||
-rw-r--r-- | test/files/neg/t6928.scala | 10 | ||||
-rw-r--r-- | test/files/neg/t6963.check | 4 | ||||
-rw-r--r-- | test/files/neg/t6963.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t6963.scala | 3 |
20 files changed, 188 insertions, 1 deletions
diff --git a/test/files/neg/package-ob-case.check b/test/files/neg/package-ob-case.check index 063a120db1..9031ad13e7 100644 --- a/test/files/neg/package-ob-case.check +++ b/test/files/neg/package-ob-case.check @@ -2,6 +2,8 @@ package-ob-case.scala:3: warning: it is not recommended to define classes/object If possible, define class X in package foo instead. case class X(z: Int) { } ^ -error: No warnings can be incurred under -Xfatal-warnings. +package-ob-case.scala:3: error: implementation restriction: package object foo cannot contain case class X. Instead, class X should be placed directly in package foo. + case class X(z: Int) { } + ^ one warning found one error found diff --git a/test/files/neg/t5340.check b/test/files/neg/t5340.check new file mode 100644 index 0000000000..2de19293c4 --- /dev/null +++ b/test/files/neg/t5340.check @@ -0,0 +1,6 @@ +t5340.scala:17: error: type mismatch; + found : MyApp.r.E + required: MyApp.s.E + println(b: s.E) + ^ +one error found diff --git a/test/files/neg/t5340.scala b/test/files/neg/t5340.scala new file mode 100644 index 0000000000..b283f13338 --- /dev/null +++ b/test/files/neg/t5340.scala @@ -0,0 +1,29 @@ +class Poly { + class E + object E { + implicit def conv(value: Any): E = sys.error("") + } +} + +object MyApp { + val r: Poly = sys.error("") + val s: Poly = sys.error("") + val b: r.E = sys.error("") + + // okay + s.E.conv(b): s.E + + // compilation fails with error below + println(b: s.E) + + // amb prefix: MyApp.s.type#class E MyApp.r.type#class E + // amb prefix: MyApp.s.type#class E MyApp.r.type#class E + // ../test/pending/run/t5310.scala:17: error: type mismatch; + // found : MyApp.r.E + // required: MyApp.s.E + // println(b: s.E) + // ^ + + // The type error is as expected, but the `amb prefix` should be logged, + // rather than printed to standard out. +} diff --git a/test/files/neg/t5440.check b/test/files/neg/t5440.check new file mode 100644 index 0000000000..1c4592ccec --- /dev/null +++ b/test/files/neg/t5440.check @@ -0,0 +1,7 @@ +t5440.scala:3: warning: match may not be exhaustive. +It would fail on the following inputs: (List(_), Nil), (Nil, List(_)) + (list1, list2) match { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t5440.flags b/test/files/neg/t5440.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/t5440.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t5440.scala b/test/files/neg/t5440.scala new file mode 100644 index 0000000000..d9cf5d6252 --- /dev/null +++ b/test/files/neg/t5440.scala @@ -0,0 +1,7 @@ +object Test { + def merge(list1: List[Long], list2: List[Long]): Boolean = + (list1, list2) match { + case (hd1::_, hd2::_) => true + case (Nil, Nil) => true + } +}
\ No newline at end of file diff --git a/test/files/neg/t5954.check b/test/files/neg/t5954.check new file mode 100644 index 0000000000..3ca47cd430 --- /dev/null +++ b/test/files/neg/t5954.check @@ -0,0 +1,16 @@ +t5954.scala:36: error: implementation restriction: package object A cannot contain case class D. Instead, class D should be placed directly in package A. + case class D() + ^ +t5954.scala:35: error: implementation restriction: package object A cannot contain companion object C. Instead, object C should be placed directly in package A. + object C + ^ +t5954.scala:34: error: implementation restriction: package object A cannot contain companion trait C. Instead, trait C should be placed directly in package A. + trait C + ^ +t5954.scala:33: error: implementation restriction: package object A cannot contain companion object B. Instead, object B should be placed directly in package A. + object B + ^ +t5954.scala:32: error: implementation restriction: package object A cannot contain companion class B. Instead, class B should be placed directly in package A. + class B + ^ +5 errors found diff --git a/test/files/neg/t5954.scala b/test/files/neg/t5954.scala new file mode 100644 index 0000000000..9e6f5392c7 --- /dev/null +++ b/test/files/neg/t5954.scala @@ -0,0 +1,46 @@ +// if you ever think you've fixed the underlying reason for the implementation restrictions +// imposed by SI-5954, then here's a test that should pass with two "succes"es +// +//import scala.tools.partest._ +// +//object Test extends DirectTest { +// def code = ??? +// +// def problemCode = """ +// package object A { +// class B +// object B +// case class C() +// } +// """ +// +// def compileProblemCode() = { +// val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") +// compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(problemCode) +// } +// +// def show() : Unit = { +// for (i <- 0 until 2) { +// compileProblemCode() +// println(s"success ${i + 1}") +// } +// } +//} + +package object A { + // these should be prevented by the implementation restriction + class B + object B + trait C + object C + case class D() + // all the rest of these should be ok + class E + object F + val g = "omg" + var h = "wtf" + def i = "lol" + type j = String + class K(val k : Int) extends AnyVal + implicit class L(val l : Int) +} diff --git a/test/files/neg/t6082.check b/test/files/neg/t6082.check new file mode 100644 index 0000000000..b68de5ce08 --- /dev/null +++ b/test/files/neg/t6082.check @@ -0,0 +1,13 @@ +t6082.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 annot(notValue: String) extends annotation.ClassfileAnnotation + ^ +t6082.scala:2: error: classfile annotation arguments have to be supplied as named arguments +@annot("") class C + ^ +t6082.scala:2: error: annotation annot is missing argument notValue +@annot("") class C + ^ +one warning found +two errors found diff --git a/test/files/neg/t6082.scala b/test/files/neg/t6082.scala new file mode 100644 index 0000000000..30de91a4c9 --- /dev/null +++ b/test/files/neg/t6082.scala @@ -0,0 +1,2 @@ +class annot(notValue: String) extends annotation.ClassfileAnnotation +@annot("") class C
\ No newline at end of file diff --git a/test/files/neg/t6675.check b/test/files/neg/t6675.check new file mode 100644 index 0000000000..3a277af866 --- /dev/null +++ b/test/files/neg/t6675.check @@ -0,0 +1,6 @@ +t6675.scala:10: warning: extractor pattern binds a single value to a Product3 of type (Int, Int, Int) + "" match { case X(b) => b } // should warn under -Xlint. Not an error because of SI-6111 + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t6675.flags b/test/files/neg/t6675.flags new file mode 100644 index 0000000000..e93641e931 --- /dev/null +++ b/test/files/neg/t6675.flags @@ -0,0 +1 @@ +-Xlint -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t6675.scala b/test/files/neg/t6675.scala new file mode 100644 index 0000000000..4d500b77ba --- /dev/null +++ b/test/files/neg/t6675.scala @@ -0,0 +1,13 @@ +object X { + def unapply(s: String): Option[(Int,Int,Int)] = Some((1,2,3)) +} + +object Y { + def unapplySeq(s: String): Option[Seq[(Int,Int,Int)]] = Some(Seq((1,2,3))) +} + +object Test { + "" match { case X(b) => b } // should warn under -Xlint. Not an error because of SI-6111 + + "" match { case Y(b) => b } // no warning +} diff --git a/test/files/neg/t6912.check b/test/files/neg/t6912.check new file mode 100644 index 0000000000..137b651705 --- /dev/null +++ b/test/files/neg/t6912.check @@ -0,0 +1,4 @@ +t6912.scala:8: error: not found: type Xxxx + def test[T]: Xxxx = Foo1[T] + ^ +one error found diff --git a/test/files/neg/t6912.scala b/test/files/neg/t6912.scala new file mode 100644 index 0000000000..f2540ee8c6 --- /dev/null +++ b/test/files/neg/t6912.scala @@ -0,0 +1,9 @@ +object Foo1 { + def apply[T](a: Int = 0): Nothing = sys.error("") + def apply[T](z: String = ""): Nothing = sys.error("") +} + +object Test { + // Triggered a cycle in Typers#adapt + def test[T]: Xxxx = Foo1[T] +} diff --git a/test/files/neg/t6928.check b/test/files/neg/t6928.check new file mode 100644 index 0000000000..28b8e382dc --- /dev/null +++ b/test/files/neg/t6928.check @@ -0,0 +1,7 @@ +t6928.scala:2: error: super constructor cannot be passed a self reference unless parameter is declared by-name +object B extends A(B) + ^ +t6928.scala:3: error: super constructor cannot be passed a self reference unless parameter is declared by-name +object C extends A(null, null, C) + ^ +two errors found diff --git a/test/files/neg/t6928.scala b/test/files/neg/t6928.scala new file mode 100644 index 0000000000..84bdcde45a --- /dev/null +++ b/test/files/neg/t6928.scala @@ -0,0 +1,10 @@ +abstract class A( val someAs: A* ) +object B extends A(B) +object C extends A(null, null, C) + +object Test { + def main(args: Array[String]): Unit = { + println(B.someAs) + println(C.someAs) + } +} diff --git a/test/files/neg/t6963.check b/test/files/neg/t6963.check new file mode 100644 index 0000000000..cc4a7a48fc --- /dev/null +++ b/test/files/neg/t6963.check @@ -0,0 +1,4 @@ +warning: -Xmigration is deprecated: This setting is no longer useful and will be removed. Please remove it from your build. +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t6963.flags b/test/files/neg/t6963.flags new file mode 100644 index 0000000000..0b6d71496a --- /dev/null +++ b/test/files/neg/t6963.flags @@ -0,0 +1 @@ +-Xmigration -deprecation -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t6963.scala b/test/files/neg/t6963.scala new file mode 100644 index 0000000000..4da52764f5 --- /dev/null +++ b/test/files/neg/t6963.scala @@ -0,0 +1,3 @@ + +object test { +} |