summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authoraleksandar <aleksandar@lampmac14.epfl.ch>2012-01-12 15:38:55 +0100
committeraleksandar <aleksandar@lampmac14.epfl.ch>2012-01-12 15:38:55 +0100
commit91fcdf64d406aed26d473091c3328c0cf089e115 (patch)
treee3897d0cc6b680d32581a740b16a4ad5ef0839ef /test/files/neg
parent51ddeb372b3f0b22041d9a51f3faee17acd7b749 (diff)
parent5f5029d2ac6348ecb07fc11f6656621c662ced92 (diff)
downloadscala-91fcdf64d406aed26d473091c3328c0cf089e115.tar.gz
scala-91fcdf64d406aed26d473091c3328c0cf089e115.tar.bz2
scala-91fcdf64d406aed26d473091c3328c0cf089e115.zip
Merge branch 'master' into issue/4147
Conflicts: .gitignore
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/checksensible.check8
-rw-r--r--test/files/neg/logImplicits.check19
-rw-r--r--test/files/neg/logImplicits.flags1
-rw-r--r--test/files/neg/logImplicits.scala25
-rw-r--r--test/files/neg/main1.check20
-rw-r--r--test/files/neg/names-defaults-neg.check17
-rw-r--r--test/files/neg/t1960.check2
-rw-r--r--test/files/neg/t4749.check28
-rw-r--r--test/files/neg/t4749.flags1
-rw-r--r--test/files/neg/t4749.scala44
-rw-r--r--test/files/neg/t5354.check7
-rw-r--r--test/files/neg/t5354.scala15
-rw-r--r--test/files/neg/t5357.check4
-rw-r--r--test/files/neg/t5357.scala9
-rw-r--r--test/files/neg/t692.check7
15 files changed, 172 insertions, 35 deletions
diff --git a/test/files/neg/checksensible.check b/test/files/neg/checksensible.check
index d45d16165f..0881205bb4 100644
--- a/test/files/neg/checksensible.check
+++ b/test/files/neg/checksensible.check
@@ -28,12 +28,6 @@ checksensible.scala:27: error: comparing values of types Int and Unit using `=='
checksensible.scala:29: error: comparing values of types Int and String using `==' will always yield false
1 == "abc"
^
-checksensible.scala:32: error: String and Int are unrelated: they will most likely never compare equal
- "abc" == 1 // warns because the lub of String and Int is Any
- ^
-checksensible.scala:33: error: Some[Int] and Int are unrelated: they will most likely never compare equal
- Some(1) == 1 // as above
- ^
checksensible.scala:38: error: comparing a fresh object using `==' will always yield false
new AnyRef == 1
^
@@ -100,4 +94,4 @@ checksensible.scala:84: error: comparing values of types EqEqRefTest.this.C3 and
checksensible.scala:95: error: comparing values of types Unit and Int using `!=' will always yield true
while ((c = in.read) != -1)
^
-34 errors found
+32 errors found
diff --git a/test/files/neg/logImplicits.check b/test/files/neg/logImplicits.check
new file mode 100644
index 0000000000..d98422dacb
--- /dev/null
+++ b/test/files/neg/logImplicits.check
@@ -0,0 +1,19 @@
+logImplicits.scala:2: applied implicit conversion from xs.type to ?{val size: ?} = implicit def byteArrayOps(xs: Array[Byte]): scala.collection.mutable.ArrayOps[Byte]
+ def f(xs: Array[Byte]) = xs.size
+ ^
+logImplicits.scala:7: applied implicit conversion from String("abc") to ?{val map: ?} = implicit def augmentString(x: String): scala.collection.immutable.StringOps
+ def f = "abc" map (_ + 1)
+ ^
+logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String("abc"))Int
+ math.max(122, x: Int)
+ ^
+logImplicits.scala:19: applied implicit conversion from Int(1) to ?{val ->: ?} = implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A]
+ def f = (1 -> 2) + "c"
+ ^
+logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{val +: ?} = implicit def any2stringadd(x: Any): scala.runtime.StringAdd
+ def f = (1 -> 2) + "c"
+ ^
+logImplicits.scala:22: error: class Un needs to be abstract, since method unimplemented is not defined
+class Un {
+ ^
+one error found
diff --git a/test/files/neg/logImplicits.flags b/test/files/neg/logImplicits.flags
new file mode 100644
index 0000000000..97e5ae94ef
--- /dev/null
+++ b/test/files/neg/logImplicits.flags
@@ -0,0 +1 @@
+-Xlog-implicit-conversions \ No newline at end of file
diff --git a/test/files/neg/logImplicits.scala b/test/files/neg/logImplicits.scala
new file mode 100644
index 0000000000..fb5dd8a025
--- /dev/null
+++ b/test/files/neg/logImplicits.scala
@@ -0,0 +1,25 @@
+class A {
+ def f(xs: Array[Byte]) = xs.size
+ def g(xs: Array[Byte]) = xs.length
+}
+
+class B {
+ def f = "abc" map (_ + 1)
+}
+
+object C {
+ final val x = "abc"
+
+ implicit def convert(p: x.type): Int = 123
+
+ math.max(122, x: Int)
+}
+
+class D {
+ def f = (1 -> 2) + "c"
+}
+
+class Un {
+ // forcing post-typer failure, since we're only interested in the output from the above
+ def unimplemented: Int
+} \ No newline at end of file
diff --git a/test/files/neg/main1.check b/test/files/neg/main1.check
index 734c78e54d..1a7a13e1e9 100644
--- a/test/files/neg/main1.check
+++ b/test/files/neg/main1.check
@@ -1,25 +1,25 @@
-main1.scala:3: error: Foo has a main method, but foo1.Foo will not be a runnable program.
- Its companion is a trait, which means no static forwarder can be generated.
+main1.scala:3: error: Foo has a main method with parameter type Array[String], but foo1.Foo will not be a runnable program.
+ Reason: companion is a trait, which means no static forwarder can be generated.
object Foo { // companion is trait
^
-main1.scala:10: error: Foo has a main method, but foo2.Foo will not be a runnable program.
- Its companion contains its own main method, which means no static forwarder can be generated.
+main1.scala:10: error: Foo has a main method with parameter type Array[String], but foo2.Foo will not be a runnable program.
+ Reason: companion contains its own main method, which means no static forwarder can be generated.
object Foo { // companion has its own main
^
-main1.scala:22: error: Foo has a main method, but foo3.Foo will not be a runnable program.
- Its companion contains its own main method (implementation restriction: no main is allowed, regardless of signature), which means no static forwarder can be generated.
+main1.scala:22: error: Foo has a main method with parameter type Array[String], but foo3.Foo will not be a runnable program.
+ Reason: companion contains its own main method (implementation restriction: no main is allowed, regardless of signature), which means no static forwarder can be generated.
object Foo { // Companion contains main, but not an interfering main.
^
-main1.scala:31: error: Foo has a main method, but foo4.Foo will not be a runnable program.
- Its companion contains its own main method (implementation restriction: no main is allowed, regardless of signature), which means no static forwarder can be generated.
+main1.scala:31: error: Foo has a main method with parameter type Array[String], but foo4.Foo will not be a runnable program.
+ Reason: companion contains its own main method, which means no static forwarder can be generated.
object Foo extends Foo { // Inherits main from the class
^
-main1.scala:39: error: Foo has a main method, but foo5.Foo will not be a runnable program.
- Its companion contains its own main method (implementation restriction: no main is allowed, regardless of signature), which means no static forwarder can be generated.
+main1.scala:39: error: Foo has a main method with parameter type Array[String], but foo5.Foo will not be a runnable program.
+ Reason: companion contains its own main method, which means no static forwarder can be generated.
object Foo extends Foo { // Overrides main from the class
^
diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check
index 03e44f745d..01bbe2de4e 100644
--- a/test/files/neg/names-defaults-neg.check
+++ b/test/files/neg/names-defaults-neg.check
@@ -10,8 +10,7 @@ names-defaults-neg.scala:5: error: type mismatch;
names-defaults-neg.scala:8: error: positional after named argument.
test1(b = "(*", 23)
^
-names-defaults-neg.scala:13: error: reference to x is ambiguous; it is both, a parameter
-name of the method and the name of a variable currently in scope.
+names-defaults-neg.scala:13: error: reference to x is ambiguous; it is both a method parameter and a variable in scope.
test2(x = 1)
^
names-defaults-neg.scala:15: error: not found: value c
@@ -26,8 +25,7 @@ names-defaults-neg.scala:17: error: not found: value m
names-defaults-neg.scala:18: error: not found: value m
test7 { m = 1 } // no named arguments in argument block
^
-names-defaults-neg.scala:19: error: reference to x is ambiguous; it is both, a parameter
-name of the method and the name of a variable currently in scope.
+names-defaults-neg.scala:19: error: reference to x is ambiguous; it is both a method parameter and a variable in scope.
test8(x = 1)
^
names-defaults-neg.scala:22: error: parameter specified twice: a
@@ -85,7 +83,7 @@ names-defaults-neg.scala:76: error: no type parameters for method test4: (x: T[T
--- because ---
argument expression's type is not compatible with formal parameter type;
found : List[Int]
- required: ?T[?T[List[?T[X forSome { type X }]]]]
+ required: ?T
Error occurred in an application involving default arguments.
test4()
^
@@ -118,8 +116,7 @@ names-defaults-neg.scala:93: error: parameter specified twice: b
names-defaults-neg.scala:98: error: unknown parameter name: m
f3818(y = 1, m = 1)
^
-names-defaults-neg.scala:131: error: reference to var2 is ambiguous; it is both, a parameter
-name of the method and the name of a variable currently in scope.
+names-defaults-neg.scala:131: error: reference to var2 is ambiguous; it is both a method parameter and a variable in scope.
delay(var2 = 40)
^
names-defaults-neg.scala:134: error: missing parameter type for expanded function ((x$1) => a = x$1)
@@ -146,15 +143,13 @@ names-defaults-neg.scala:164: error: variable definition needs type because 'x'
names-defaults-neg.scala:167: error: variable definition needs type because 'x' is used as a named argument in its body.
def u6 { var x = u.f(x = "32") }
^
-names-defaults-neg.scala:170: error: reference to x is ambiguous; it is both, a parameter
-name of the method and the name of a variable currently in scope.
+names-defaults-neg.scala:170: error: reference to x is ambiguous; it is both a method parameter and a variable in scope.
def u9 { var x: Int = u.f(x = 1) }
^
names-defaults-neg.scala:177: error: variable definition needs type because 'x' is used as a named argument in its body.
class u15 { var x = u.f(x = 1) }
^
-names-defaults-neg.scala:180: error: reference to x is ambiguous; it is both, a parameter
-name of the method and the name of a variable currently in scope.
+names-defaults-neg.scala:180: error: reference to x is ambiguous; it is both a method parameter and a variable in scope.
class u18 { var x: Int = u.f(x = 1) }
^
one warning found
diff --git a/test/files/neg/t1960.check b/test/files/neg/t1960.check
index dabf53f126..5238141c4e 100644
--- a/test/files/neg/t1960.check
+++ b/test/files/neg/t1960.check
@@ -1,4 +1,4 @@
-t1960.scala:5: error: parameter 'p' requires field but conflicts with p in 'TBase'
+t1960.scala:5: error: parameter 'p' requires field but conflicts with method p in trait TBase
class Aclass (p: Int) extends TBase { def g() { f(p) } }
^
one error found
diff --git a/test/files/neg/t4749.check b/test/files/neg/t4749.check
new file mode 100644
index 0000000000..93ad3935fa
--- /dev/null
+++ b/test/files/neg/t4749.check
@@ -0,0 +1,28 @@
+t4749.scala:2: error: Fail1 has a main method with parameter type Array[String], but bippy.Fail1 will not be a runnable program.
+ Reason: main method must have exact signature (Array[String])Unit
+ object Fail1 {
+ ^
+t4749.scala:6: error: Fail2 has a main method with parameter type Array[String], but bippy.Fail2 will not be a runnable program.
+ Reason: main methods cannot be generic.
+ object Fail2 {
+ ^
+t4749.scala:13: error: Fail3 has a main method with parameter type Array[String], but bippy.Fail3 will not be a runnable program.
+ Reason: main methods cannot refer to type parameters or abstract types.
+ object Fail3 extends Bippy[Unit] { }
+ ^
+t4749.scala:16: error: Fail4 has a main method with parameter type Array[String], but bippy.Fail4 will not be a runnable program.
+ Reason: companion is a trait, which means no static forwarder can be generated.
+
+ object Fail4 {
+ ^
+t4749.scala:21: error: Fail5 has a main method with parameter type Array[String], but bippy.Fail5 will not be a runnable program.
+ Reason: companion contains its own main method, which means no static forwarder can be generated.
+
+ object Fail5 extends Fail5 { }
+ ^
+t4749.scala:26: error: Fail6 has a main method with parameter type Array[String], but bippy.Fail6 will not be a runnable program.
+ Reason: companion contains its own main method (implementation restriction: no main is allowed, regardless of signature), which means no static forwarder can be generated.
+
+ object Fail6 {
+ ^
+6 errors found
diff --git a/test/files/neg/t4749.flags b/test/files/neg/t4749.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/neg/t4749.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t4749.scala b/test/files/neg/t4749.scala
new file mode 100644
index 0000000000..0973c36097
--- /dev/null
+++ b/test/files/neg/t4749.scala
@@ -0,0 +1,44 @@
+package bippy {
+ object Fail1 {
+ def main(args: Array[String]): Any = ()
+ }
+
+ object Fail2 {
+ def main[T](args: Array[String]): T = null.asInstanceOf[T]
+ }
+
+ abstract class Bippy[T] {
+ def main(args: Array[String]): T = null.asInstanceOf[T]
+ }
+ object Fail3 extends Bippy[Unit] { }
+
+
+ object Fail4 {
+ def main(args: Array[String]): Unit = ()
+ }
+ trait Fail4 { }
+
+ object Fail5 extends Fail5 { }
+ class Fail5 {
+ def main(args: Array[String]): Unit = ()
+ }
+
+ object Fail6 {
+ def main(args: Array[String]): Unit = ()
+ }
+ class Fail6 {
+ def main = "bippy"
+ }
+
+ object Win1 {
+ def main(args: Array[String]): Unit = ()
+ }
+ object Win2 extends Bippy[Unit] {
+ override def main(args: Array[String]): Unit = ()
+ }
+ trait WinBippy[T] {
+ def main(args: Array[String]): T = null.asInstanceOf[T]
+ }
+ object Win3 extends WinBippy[Unit] { }
+}
+
diff --git a/test/files/neg/t5354.check b/test/files/neg/t5354.check
new file mode 100644
index 0000000000..e47cecb5fe
--- /dev/null
+++ b/test/files/neg/t5354.check
@@ -0,0 +1,7 @@
+t5354.scala:9: error: ambiguous implicit values:
+ both method x123 in package foo of type => foo.Bippy
+ and method z of type => foo.Bippy
+ match expected type foo.Bippy
+ implicitly[Bippy]
+ ^
+one error found
diff --git a/test/files/neg/t5354.scala b/test/files/neg/t5354.scala
new file mode 100644
index 0000000000..99b5650155
--- /dev/null
+++ b/test/files/neg/t5354.scala
@@ -0,0 +1,15 @@
+package object foo {
+ implicit def x123: Bippy = new Bippy("x")
+}
+package foo {
+ class Bippy(override val toString: String){ }
+ class Dingus {
+ def f1 = {
+ implicit def z: Bippy = new Bippy("z")
+ implicitly[Bippy]
+ }
+ }
+ object Test extends App {
+ println(new Dingus().f1)
+ }
+}
diff --git a/test/files/neg/t5357.check b/test/files/neg/t5357.check
new file mode 100644
index 0000000000..3385559071
--- /dev/null
+++ b/test/files/neg/t5357.check
@@ -0,0 +1,4 @@
+t5357.scala:5: error: Pattern variables must start with a lower-case letter. (SLS 8.1.1.)
+ case A: N => 1
+ ^
+one error found
diff --git a/test/files/neg/t5357.scala b/test/files/neg/t5357.scala
new file mode 100644
index 0000000000..369a5568a4
--- /dev/null
+++ b/test/files/neg/t5357.scala
@@ -0,0 +1,9 @@
+trait M
+
+case class N() extends M {
+ def mytest(x: M) = x match {
+ case A: N => 1
+ case _ => 0
+ }
+}
+
diff --git a/test/files/neg/t692.check b/test/files/neg/t692.check
index 12b7d40ba5..4149366309 100644
--- a/test/files/neg/t692.check
+++ b/test/files/neg/t692.check
@@ -13,12 +13,7 @@ t692.scala:13: error: class Foo takes type parameters
t692.scala:14: error: class Foo takes type parameters
implicit def typeOfBar[T4 <: Foo](implicit elem : RefType[T4]) : RefType[Bar[T4]] =
^
-t692.scala:15: error: type mismatch;
- found : test3.this.BarType[T4]
- required: test3.this.RefType[test3.this.Bar[T4]]
- BarType(elem);
- ^
t692.scala:19: error: class Foo takes type parameters
class Bar[A <: Foo](implicit tpeA : Type[A]) extends Foo;
^
-7 errors found
+6 errors found