aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/Main.scala4
-rw-r--r--tests/neg/arrayclone-new.scala38
-rw-r--r--tests/neg/compExceptions/structural.scala (renamed from tests/neg/structural.scala)0
-rw-r--r--tests/neg/customArgs/autoTuplingTest.scala9
-rw-r--r--tests/neg/customArgs/i1050.scala (renamed from tests/neg/i1050.scala)0
-rw-r--r--tests/neg/customArgs/overrideClass.scala (renamed from tests/neg/overrideClass.scala)0
-rw-r--r--tests/neg/customArgs/typers.scala (renamed from tests/neg/typers.scala)0
-rw-r--r--tests/neg/i827.scala4
-rw-r--r--tests/neg/implicitDefs.scala6
-rw-r--r--tests/neg/t1292.scala4
-rw-r--r--tests/neg/t7278.scala6
-rw-r--r--tests/pos/autoTuplingTest.scala4
-rw-r--r--tests/pos/patternUnsoundness.scala (renamed from tests/neg/patternUnsoundness.scala)0
-rw-r--r--tests/pos/t1164.scala (renamed from tests/neg/t1164.scala)0
-rw-r--r--tests/run/i1099.scala25
15 files changed, 48 insertions, 52 deletions
diff --git a/tests/neg/Main.scala b/tests/neg/Main.scala
index 2cc7ad50e..24a94d654 100644
--- a/tests/neg/Main.scala
+++ b/tests/neg/Main.scala
@@ -17,7 +17,7 @@ object Main extends Driver {
override def newCompiler(): Compiler = new Compiler
override def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context): Unit = {
- if (new config.Settings.Setting.SettingDecorator(ctx.base.settings.resident).value) resident(compiler)
- else super.doCompile(compiler,123)
+ if (new config.Settings.Setting.SettingDecorator(ctx.base.settings.resident).value) resident(compiler) // error
+ else super.doCompile(compiler,123) // error: type mismatch
}
}
diff --git a/tests/neg/arrayclone-new.scala b/tests/neg/arrayclone-new.scala
deleted file mode 100644
index 0e42545f8..000000000
--- a/tests/neg/arrayclone-new.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-// Run with -explaintypes to see information about shadowing failures
-import scala.reflect.{ClassTag, classTag}
-
-object Test extends dotty.runtime.LegacyApp{
- ObjectArrayClone;
- PolymorphicArrayClone;
-}
-
-object ObjectArrayClone{
- val it : Array[String] = Array("1", "0"); // error
- val cloned = it.clone();
- assert(cloned.sameElements(it));
- cloned(0) = "0";
- assert(it(0) == "1")
-}
-
-object PolymorphicArrayClone{
- def testIt[T](it : Array[T], one : T, zero : T) = {
- val cloned = it.clone();
- assert(cloned.sameElements(it));
- cloned(0) = zero;
- assert(it(0) == one)
- }
-
- testIt(Array("one", "two"), "one", "two"); // error
-
- class Mangler[T: ClassTag](ts : T*){
- // this will always be a BoxedAnyArray even after we've unboxed its contents.
- val it = ts.toArray[T];
- }
-
- val mangled = new Mangler[Int](0, 1);
-
- val y : Array[Int] = mangled.it; // make sure it's unboxed
-
- testIt(mangled.it, 0, 1);
-}
-
diff --git a/tests/neg/structural.scala b/tests/neg/compExceptions/structural.scala
index 1d2506290..1d2506290 100644
--- a/tests/neg/structural.scala
+++ b/tests/neg/compExceptions/structural.scala
diff --git a/tests/neg/customArgs/autoTuplingTest.scala b/tests/neg/customArgs/autoTuplingTest.scala
new file mode 100644
index 000000000..7321a8382
--- /dev/null
+++ b/tests/neg/customArgs/autoTuplingTest.scala
@@ -0,0 +1,9 @@
+object autoTupling {
+
+ val x = Some(1, 2) // error when running with -language:noAutoTupling
+
+ x match {
+ case Some(a, b) => a + b // error // error when running with -language:noAutoTupling
+ case None =>
+ }
+}
diff --git a/tests/neg/i1050.scala b/tests/neg/customArgs/i1050.scala
index 1ade1366a..1ade1366a 100644
--- a/tests/neg/i1050.scala
+++ b/tests/neg/customArgs/i1050.scala
diff --git a/tests/neg/overrideClass.scala b/tests/neg/customArgs/overrideClass.scala
index 803d97dd9..803d97dd9 100644
--- a/tests/neg/overrideClass.scala
+++ b/tests/neg/customArgs/overrideClass.scala
diff --git a/tests/neg/typers.scala b/tests/neg/customArgs/typers.scala
index 49742ebbd..49742ebbd 100644
--- a/tests/neg/typers.scala
+++ b/tests/neg/customArgs/typers.scala
diff --git a/tests/neg/i827.scala b/tests/neg/i827.scala
index cc795b590..182ffe0b1 100644
--- a/tests/neg/i827.scala
+++ b/tests/neg/i827.scala
@@ -1,7 +1,7 @@
trait A { trait Inner }
trait B { self: A =>
- trait Inner extends self.Inner
+ trait Inner extends self.Inner // error: cannot merge trait Inner in trait A with trait Inner in trait B as members of type (A & B)(B.this)
}
-class C extends C
+class C extends C // error: cyclic inheritance: class C extends itself
diff --git a/tests/neg/implicitDefs.scala b/tests/neg/implicitDefs.scala
index 28ac32656..1489344c8 100644
--- a/tests/neg/implicitDefs.scala
+++ b/tests/neg/implicitDefs.scala
@@ -5,7 +5,7 @@ import Predef.{any2stringadd => _, StringAdd => _, _}
object implicitDefs {
- implicit val x = 2
- implicit def y(x: Int) = 3
- implicit def z(a: x.type): String = ""
+ implicit val x = 2 // error: type of implicit definition needs to be given explicitly
+ implicit def y(x: Int) = 3 // error: result type of implicit definition needs to be given explicitly
+ implicit def z(a: x.type): String = "" // error: implicit conversion may not have a parameter of singleton type
}
diff --git a/tests/neg/t1292.scala b/tests/neg/t1292.scala
index 69e680320..de74dc159 100644
--- a/tests/neg/t1292.scala
+++ b/tests/neg/t1292.scala
@@ -1,5 +1,5 @@
trait Foo[T <: Foo[T, Enum], Enum <: Enumeration] {
- type StV = Enum#Value
+ type StV = Enum#Value // error: Enum is not a legal path
type Meta = MegaFoo[T, Enum]
type Slog <: Enumeration
@@ -9,7 +9,7 @@ trait Foo[T <: Foo[T, Enum], Enum <: Enumeration] {
trait MegaFoo[T <: Foo[T, Enum], Enum <: Enumeration] extends Foo[T, Enum] {
def doSomething(what: T, misc: StV, dog: Meta#Event) = None
- // error: Meta is not a valid prefix for '#'.
+ // old-error: Meta is not a valid prefix for '#'.
// The error is correct. Meta is not stable, and it has an abstract type member Slog
abstract class Event
object Event
diff --git a/tests/neg/t7278.scala b/tests/neg/t7278.scala
index 9a8292409..7aafbb76f 100644
--- a/tests/neg/t7278.scala
+++ b/tests/neg/t7278.scala
@@ -8,13 +8,13 @@ object Test {
// should not compile (?)
// martin says "I'd argue about that"
// martin retracts his statement: this should not compile
- type EE[+X <: EC] = X#E
- type EE2[+X <: EC] = X#E // repeat to get error count to 2
+ type EE[+X <: EC] = X#E // error: X is not a legal path;
+ type EE2[+X <: EC] = X#E // error: X is not a legal path; repeat to get error count to 2
def fail1(): Unit = {
val b = new B
var x1: EE[A] = null
- var x2: EE[B] = new b.E // error: found: B#E, required: A#E
+ var x2: EE[B] = new b.E // old-error: found: B#E, required: A#E
// x1 = x2 // gives a prior type error: B#E, required: A#E, masked to get at the real thing.
}
diff --git a/tests/pos/autoTuplingTest.scala b/tests/pos/autoTuplingTest.scala
index 7321a8382..523411a1a 100644
--- a/tests/pos/autoTuplingTest.scala
+++ b/tests/pos/autoTuplingTest.scala
@@ -1,9 +1,9 @@
object autoTupling {
- val x = Some(1, 2) // error when running with -language:noAutoTupling
+ val x = Some(1, 2)
x match {
- case Some(a, b) => a + b // error // error when running with -language:noAutoTupling
+ case Some(a, b) => a + b
case None =>
}
}
diff --git a/tests/neg/patternUnsoundness.scala b/tests/pos/patternUnsoundness.scala
index 4620f6c7d..4620f6c7d 100644
--- a/tests/neg/patternUnsoundness.scala
+++ b/tests/pos/patternUnsoundness.scala
diff --git a/tests/neg/t1164.scala b/tests/pos/t1164.scala
index 7775b5e86..7775b5e86 100644
--- a/tests/neg/t1164.scala
+++ b/tests/pos/t1164.scala
diff --git a/tests/run/i1099.scala b/tests/run/i1099.scala
new file mode 100644
index 000000000..15a428cc3
--- /dev/null
+++ b/tests/run/i1099.scala
@@ -0,0 +1,25 @@
+import scala.reflect.ClassTag
+object Test {
+ def foo[T: ClassTag](x: Any) =
+ x match {
+ case t: T => true
+ case _ => false
+ }
+ // This is what `foo` expands to
+ def foo2[T](x: Any)(implicit ev: ClassTag[T]) =
+ x match {
+ case t @ ev(_) => true
+ case _ => false
+ }
+ def main(args: Array[String]): Unit = {
+ assert(foo[String]("a"))
+ assert(!foo[String](new Integer(1)))
+ assert(foo[Int](1))
+ assert(!foo[Int](true))
+
+ assert(foo2[String]("a"))
+ assert(!foo2[String](new Integer(1)))
+ assert(foo2[Int](1))
+ assert(!foo2[Int](true))
+ }
+}