diff options
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/checksensible.check | 17 | ||||
-rw-r--r-- | test/files/neg/t5426.check | 8 | ||||
-rw-r--r-- | test/files/neg/t5663-badwarneq.check | 5 | ||||
-rw-r--r-- | test/files/neg/t6231.check | 6 | ||||
-rw-r--r-- | test/files/neg/t6231.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t6231.scala | 15 | ||||
-rw-r--r-- | test/files/neg/t6355.check | 7 | ||||
-rw-r--r-- | test/files/neg/t6355a.check | 7 | ||||
-rw-r--r-- | test/files/neg/t6355a.scala (renamed from test/files/neg/t6355.scala) | 0 | ||||
-rw-r--r-- | test/files/neg/t6355b.check | 11 | ||||
-rw-r--r-- | test/files/neg/t6355b.scala | 17 | ||||
-rw-r--r-- | test/files/neg/t6920.check | 6 | ||||
-rw-r--r-- | test/files/neg/t6920.scala | 10 | ||||
-rw-r--r-- | test/files/neg/t7756b.check | 5 | ||||
-rw-r--r-- | test/files/neg/t8006.check | 6 | ||||
-rw-r--r-- | test/files/neg/t8006.scala | 8 | ||||
-rw-r--r-- | test/files/neg/t8104.check | 4 | ||||
-rw-r--r-- | test/files/neg/t8104/Macros_1.scala | 11 | ||||
-rw-r--r-- | test/files/neg/t8104/Test_2.scala | 21 |
19 files changed, 105 insertions, 60 deletions
diff --git a/test/files/neg/checksensible.check b/test/files/neg/checksensible.check index ef3aee5ee4..e5f1a38d96 100644 --- a/test/files/neg/checksensible.check +++ b/test/files/neg/checksensible.check @@ -28,9 +28,6 @@ checksensible.scala:27: warning: comparing values of types Int and Unit using `= checksensible.scala:29: warning: comparing values of types Int and String using `==' will always yield false 1 == "abc" ^ -checksensible.scala:29: warning: Int and String are unrelated: they will most likely never compare equal - 1 == "abc" - ^ checksensible.scala:33: warning: comparing values of types Some[Int] and Int using `==' will always yield false Some(1) == 1 // as above ^ @@ -64,18 +61,12 @@ checksensible.scala:51: warning: comparing values of types Int and Unit using `! checksensible.scala:52: warning: comparing values of types Int and Symbol using `!=' will always yield true (1 != 'sym) ^ -checksensible.scala:52: warning: Int and Symbol are unrelated: they will most likely always compare unequal - (1 != 'sym) - ^ checksensible.scala:58: warning: comparing a fresh object using `==' will always yield false ((x: Int) => x + 1) == null ^ checksensible.scala:59: warning: comparing a fresh object using `==' will always yield false Bep == ((_: Int) + 1) ^ -checksensible.scala:59: warning: Bep.type and Int => Int are unrelated: they will most likely never compare equal - Bep == ((_: Int) + 1) - ^ checksensible.scala:61: warning: comparing a fresh object using `==' will always yield false new Object == new Object ^ @@ -91,9 +82,6 @@ checksensible.scala:66: warning: comparing values of types Int and Null using `= checksensible.scala:71: warning: comparing values of types Bip and Bop using `==' will always yield false (x1 == x2) ^ -checksensible.scala:71: warning: Bip and Bop are unrelated: they will most likely never compare equal - (x1 == x2) - ^ checksensible.scala:81: warning: comparing values of types EqEqRefTest.this.C3 and EqEqRefTest.this.Z1 using `==' will always yield false c3 == z1 ^ @@ -106,12 +94,9 @@ checksensible.scala:83: warning: comparing values of types EqEqRefTest.this.Z1 a checksensible.scala:84: warning: comparing values of types EqEqRefTest.this.C3 and String using `!=' will always yield true c3 != "abc" ^ -checksensible.scala:84: warning: EqEqRefTest.this.C3 and String are unrelated: they will most likely always compare unequal - c3 != "abc" - ^ checksensible.scala:95: warning: comparing values of types Unit and Int using `!=' will always yield true while ((c = in.read) != -1) ^ error: No warnings can be incurred under -Xfatal-warnings. -38 warnings found +33 warnings found one error found diff --git a/test/files/neg/t5426.check b/test/files/neg/t5426.check index c042cdcec3..98f3ddaaae 100644 --- a/test/files/neg/t5426.check +++ b/test/files/neg/t5426.check @@ -4,18 +4,12 @@ t5426.scala:2: warning: comparing values of types Some[Int] and Int using `==' w t5426.scala:3: warning: comparing values of types Int and Some[Int] using `==' will always yield false def f2 = 5 == Some(5) ^ -t5426.scala:3: warning: Int and Some[Int] are unrelated: they will most likely never compare equal - def f2 = 5 == Some(5) - ^ t5426.scala:8: warning: comparing values of types Int and Some[Int] using `==' will always yield false (x1 == x2) ^ -t5426.scala:8: warning: Int and Some[Int] are unrelated: they will most likely never compare equal - (x1 == x2) - ^ t5426.scala:9: warning: comparing values of types Some[Int] and Int using `==' will always yield false (x2 == x1) ^ error: No warnings can be incurred under -Xfatal-warnings. -6 warnings found +four warnings found one error found diff --git a/test/files/neg/t5663-badwarneq.check b/test/files/neg/t5663-badwarneq.check index 4b7795585b..732e4f44d0 100644 --- a/test/files/neg/t5663-badwarneq.check +++ b/test/files/neg/t5663-badwarneq.check @@ -25,9 +25,6 @@ t5663-badwarneq.scala:72: warning: ValueClass1 and Int are unrelated: they will t5663-badwarneq.scala:74: warning: comparing values of types Int and ValueClass1 using `==' will always yield false println(5 == new ValueClass1(5)) // bad ^ -t5663-badwarneq.scala:74: warning: Int and ValueClass1 are unrelated: they will never compare equal - println(5 == new ValueClass1(5)) // bad - ^ t5663-badwarneq.scala:78: warning: ValueClass2[String] and String are unrelated: they will never compare equal println(new ValueClass2("abc") == "abc") // bad ^ @@ -41,5 +38,5 @@ t5663-badwarneq.scala:82: warning: comparing values of types ValueClass3 and Int println(ValueClass3(5) == 5) // bad ^ error: No warnings can be incurred under -Xfatal-warnings. -14 warnings found +13 warnings found one error found diff --git a/test/files/neg/t6231.check b/test/files/neg/t6231.check deleted file mode 100644 index 6e107c97c7..0000000000 --- a/test/files/neg/t6231.check +++ /dev/null @@ -1,6 +0,0 @@ -t6231.scala:4: error: Implementation restriction: local trait Bug$X$1 is unable to automatically capture the -free variable value ev$1 on behalf of <$anon: Function0>. You can manually assign it to a val inside the trait, -and refer to that val in <$anon: Function0>. For more details, see SI-6231. - def qux = { () => ev } - ^ -one error found diff --git a/test/files/neg/t6231.flags b/test/files/neg/t6231.flags deleted file mode 100644 index ac96850b69..0000000000 --- a/test/files/neg/t6231.flags +++ /dev/null @@ -1 +0,0 @@ --Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/neg/t6231.scala b/test/files/neg/t6231.scala deleted file mode 100644 index 1e5b4e0e1a..0000000000 --- a/test/files/neg/t6231.scala +++ /dev/null @@ -1,15 +0,0 @@ -object Bug { - def bar(ev: Any) = { - trait X { - def qux = { () => ev } - } - new X {}.qux() - - // workaround - trait Y { - val ev2 = ev // manually capture `ev` so that `ev2` is added to the trait interface. - def qux = { () => ev2 } - } - } -} - diff --git a/test/files/neg/t6355.check b/test/files/neg/t6355.check deleted file mode 100644 index 607829d99a..0000000000 --- a/test/files/neg/t6355.check +++ /dev/null @@ -1,7 +0,0 @@ -t6355.scala:12: error: implementation restriction: applyDynamic cannot be overloaded except by methods with different numbers of type parameters, e.g. applyDynamic[T1](method: String)(arg: T1) and applyDynamic[T1, T2](method: String)(arg1: T1, arg2: T2) - def applyDynamic(name: String)(x: Int): Int = 2 - ^ -t6355.scala:18: error: implementation restriction: applyDynamic cannot be overloaded except by methods with different numbers of type parameters, e.g. applyDynamic[T1](method: String)(arg: T1) and applyDynamic[T1, T2](method: String)(arg1: T1, arg2: T2) - def applyDynamic[T1, T2](name: String)(x: String, y: T1, z: T2): Int = 3 - ^ -two errors found diff --git a/test/files/neg/t6355a.check b/test/files/neg/t6355a.check new file mode 100644 index 0000000000..5768d31f0b --- /dev/null +++ b/test/files/neg/t6355a.check @@ -0,0 +1,7 @@ +t6355a.scala:12: error: implementation restriction: applyDynamic cannot be overloaded except by methods with different numbers of type parameters, e.g. applyDynamic[T1](method: String)(arg: T1) and applyDynamic[T1, T2](method: String)(arg1: T1, arg2: T2) + def applyDynamic(name: String)(x: Int): Int = 2 + ^ +t6355a.scala:18: error: implementation restriction: applyDynamic cannot be overloaded except by methods with different numbers of type parameters, e.g. applyDynamic[T1](method: String)(arg: T1) and applyDynamic[T1, T2](method: String)(arg1: T1, arg2: T2) + def applyDynamic[T1, T2](name: String)(x: String, y: T1, z: T2): Int = 3 + ^ +two errors found diff --git a/test/files/neg/t6355.scala b/test/files/neg/t6355a.scala index 0500ed04c6..0500ed04c6 100644 --- a/test/files/neg/t6355.scala +++ b/test/files/neg/t6355a.scala diff --git a/test/files/neg/t6355b.check b/test/files/neg/t6355b.check new file mode 100644 index 0000000000..f827f07e53 --- /dev/null +++ b/test/files/neg/t6355b.check @@ -0,0 +1,11 @@ +t6355b.scala:14: error: value applyDynamic is not a member of A +error after rewriting to x.<applyDynamic: error>("bippy") +possible cause: maybe a wrong Dynamic method signature? + println(x.bippy(42)) + ^ +t6355b.scala:15: error: value applyDynamic is not a member of A +error after rewriting to x.<applyDynamic: error>("bippy") +possible cause: maybe a wrong Dynamic method signature? + println(x.bippy("42")) + ^ +two errors found diff --git a/test/files/neg/t6355b.scala b/test/files/neg/t6355b.scala new file mode 100644 index 0000000000..5f3c97cb0c --- /dev/null +++ b/test/files/neg/t6355b.scala @@ -0,0 +1,17 @@ +import scala.language.dynamics + +class A extends Dynamic { + def selectDynamic(method: String): B = new B(method) +} +class B(method: String) { + def apply(x: Int) = s"$method(x: Int) called with x = $x" + def apply(x: String) = s"""$method(x: String) called with x = "$x"""" +} + +object Test { + def main(args: Array[String]): Unit = { + val x = new A + println(x.bippy(42)) + println(x.bippy("42")) + } +} diff --git a/test/files/neg/t6920.check b/test/files/neg/t6920.check new file mode 100644 index 0000000000..ee4eafb83e --- /dev/null +++ b/test/files/neg/t6920.check @@ -0,0 +1,6 @@ +t6920.scala:9: error: too many arguments for method applyDynamicNamed: (values: Seq[(String, Any)])String +error after rewriting to CompilerError.this.test.applyDynamicNamed("crushTheCompiler")(scala.Tuple2("a", 1), scala.Tuple2("b", 2)) +possible cause: maybe a wrong Dynamic method signature? + test.crushTheCompiler(a = 1, b = 2) + ^ +one error found diff --git a/test/files/neg/t6920.scala b/test/files/neg/t6920.scala new file mode 100644 index 0000000000..b79d641698 --- /dev/null +++ b/test/files/neg/t6920.scala @@ -0,0 +1,10 @@ +import scala.language.dynamics + +class DynTest extends Dynamic { + def applyDynamicNamed(name: String)(values: Seq[(String, Any)]) = "test" +} + +class CompilerError { + val test = new DynTest + test.crushTheCompiler(a = 1, b = 2) +}
\ No newline at end of file diff --git a/test/files/neg/t7756b.check b/test/files/neg/t7756b.check index e764783241..2817a7e230 100644 --- a/test/files/neg/t7756b.check +++ b/test/files/neg/t7756b.check @@ -1,9 +1,6 @@ t7756b.scala:3: warning: comparing values of types Int and String using `==' will always yield false case _ => 0 == "" ^ -t7756b.scala:3: warning: Int and String are unrelated: they will most likely never compare equal - case _ => 0 == "" - ^ error: No warnings can be incurred under -Xfatal-warnings. -two warnings found +one warning found one error found diff --git a/test/files/neg/t8006.check b/test/files/neg/t8006.check new file mode 100644 index 0000000000..fbac26e3ad --- /dev/null +++ b/test/files/neg/t8006.check @@ -0,0 +1,6 @@ +t8006.scala:3: error: too many arguments for method applyDynamicNamed: (value: (String, Any))String +error after rewriting to X.this.d.applyDynamicNamed("meth")(scala.Tuple2("value1", 10), scala.Tuple2("value2", 100)) +possible cause: maybe a wrong Dynamic method signature? + d.meth(value1 = 10, value2 = 100) // two arguments here, but only one is allowed + ^ +one error found diff --git a/test/files/neg/t8006.scala b/test/files/neg/t8006.scala new file mode 100644 index 0000000000..b2f71c1587 --- /dev/null +++ b/test/files/neg/t8006.scala @@ -0,0 +1,8 @@ +object X { + val d = new D + d.meth(value1 = 10, value2 = 100) // two arguments here, but only one is allowed +} +import language.dynamics +class D extends Dynamic { + def applyDynamicNamed(name: String)(value: (String, Any)) = name +}
\ No newline at end of file diff --git a/test/files/neg/t8104.check b/test/files/neg/t8104.check new file mode 100644 index 0000000000..69b3461bd5 --- /dev/null +++ b/test/files/neg/t8104.check @@ -0,0 +1,4 @@ +Test_2.scala:20: error: could not find implicit value for parameter e: Generic.Aux[Test.C,(Int, Int)] + implicitly[Generic.Aux[C, (Int, Int)]] + ^ +one error found diff --git a/test/files/neg/t8104/Macros_1.scala b/test/files/neg/t8104/Macros_1.scala new file mode 100644 index 0000000000..21d81a3687 --- /dev/null +++ b/test/files/neg/t8104/Macros_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.WhiteboxContext + +object Macros { + def impl[T](c: WhiteboxContext)(implicit T: c.WeakTypeTag[T]) = { + import c.universe._ + import definitions._ + val fields = T.tpe.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } + val Repr = appliedType(TupleClass(fields.length).asType.toType, fields.map(_.typeSignature)) + q"new Generic[$T]{ type Repr = $Repr }" + } +}
\ No newline at end of file diff --git a/test/files/neg/t8104/Test_2.scala b/test/files/neg/t8104/Test_2.scala new file mode 100644 index 0000000000..585f76c00f --- /dev/null +++ b/test/files/neg/t8104/Test_2.scala @@ -0,0 +1,21 @@ +trait Generic[T] { type Repr } +object Generic { + type Aux[T, Repr0] = Generic[T] { type Repr = Repr0 } + import scala.language.experimental.macros + implicit def materializeGeneric[T]: Generic[T] = macro Macros.impl[T] +} + +object Test extends App { + case class C(x: Int, y: Int) + + import scala.reflect.runtime.universe._ + def reprify[T, Repr](x: T)(implicit generic: Generic.Aux[T, Repr], tag: TypeTag[Repr]) = println(tag) + reprify(C(40, 2)) + + // this is a compilation error at the moment as explained in SI-8104 + // because matchesPt in implicit search says that depoly(<type of materializeGeneric>) isn't a subtype of Generic.Aux[C, (Int, Int)] + // which is rightfully so, because depoly only replaces type parameters, not type members with wildcard types + // however in the future we might want to relax the matchesPt check, so this might start compiling + // therefore, if you've broken this test, then you should be happy, because most likely you've just enabled an interesting use case! + implicitly[Generic.Aux[C, (Int, Int)]] +} |