diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-08-17 15:36:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-17 15:36:07 -0700 |
commit | 83adc75d50e319d1d2c3e2d88b69ee4393bd3525 (patch) | |
tree | 1672c92618f9cfbfbe801e9099f5bc41793a7a90 /tests | |
parent | aaa520d869c3cc3860d522b1630c042c169ec85d (diff) | |
parent | 401b421430592b213220b74ae1c394ba7f8bd479 (diff) | |
download | dotty-83adc75d50e319d1d2c3e2d88b69ee4393bd3525.tar.gz dotty-83adc75d50e319d1d2c3e2d88b69ee4393bd3525.tar.bz2 dotty-83adc75d50e319d1d2c3e2d88b69ee4393bd3525.zip |
Merge pull request #1434 from dotty-staging/fix-#1430
Fix #1430: Better error messages for type errors involving type variables
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/i1424.scala | 3 | ||||
-rw-r--r-- | tests/neg/i1430.scala | 34 | ||||
-rw-r--r-- | tests/repl/errmsgs.check | 74 |
3 files changed, 111 insertions, 0 deletions
diff --git a/tests/neg/i1424.scala b/tests/neg/i1424.scala new file mode 100644 index 000000000..3586260c1 --- /dev/null +++ b/tests/neg/i1424.scala @@ -0,0 +1,3 @@ +class Test { + (x: Int) => x // error: not a legal self type clause // error: package x is not a value // error: package x is not a value +} diff --git a/tests/neg/i1430.scala b/tests/neg/i1430.scala new file mode 100644 index 000000000..d988ba3f2 --- /dev/null +++ b/tests/neg/i1430.scala @@ -0,0 +1,34 @@ +class Inv[T](x: T) +object Test { + + val x: List[String] = List(1) // error: found Int(1), expected: String + + val y: List[List[String]] = List(List(1)) // error: found Int(1), expected: String + + val z: (List[String], List[Int]) = (List(1), List("a")) // error: found Int(1), expected: String // error: found String(a), expected: Int + + val a: Inv[String] = new Inv(new Inv(1)) // error: found Inv[T], expected: String ... where T ... + + val b: Inv[String] = new Inv(1) // error: found Int, expected: String + + abstract class C { + type T + val x: T + val s: Unit = { + type T = String + var y: T = x // error + locally { def f() = { + new { + type T = Int + val z: T = y // error + } + Nil map { _ => + type T = Int + val z: T = y // error + } + } + f() + } + } + } +} diff --git a/tests/repl/errmsgs.check b/tests/repl/errmsgs.check new file mode 100644 index 000000000..d8e863a28 --- /dev/null +++ b/tests/repl/errmsgs.check @@ -0,0 +1,74 @@ +scala> class Inv[T](x: T) +defined class Inv +scala> val x: List[String] = List(1) +<console>:4: error: type mismatch: + found : Int(1) + required: String +val x: List[String] = List(1) + ^ +scala> val y: List[List[String]] = List(List(1)) +<console>:4: error: type mismatch: + found : Int(1) + required: String +val y: List[List[String]] = List(List(1)) + ^ +scala> val z: (List[String], List[Int]) = (List(1), List("a")) +<console>:4: error: type mismatch: + found : Int(1) + required: String +val z: (List[String], List[Int]) = (List(1), List("a")) + ^ +<console>:4: error: type mismatch: + found : String("a") + required: Int +val z: (List[String], List[Int]) = (List(1), List("a")) + ^ +scala> val a: Inv[String] = new Inv(new Inv(1)) +<console>:5: error: type mismatch: + found : Inv[T] + required: String + +where T is a type variable with constraint >: Int(1) + +val a: Inv[String] = new Inv(new Inv(1)) + ^ +scala> val b: Inv[String] = new Inv(1) +<console>:5: error: type mismatch: + found : Int(1) + required: String +val b: Inv[String] = new Inv(1) + ^ +scala> abstract class C { + type T + val x: T + val s: Unit = { + type T = String + var y: T = x + locally { + def f() = { + type T = Int + val z: T = y + } + f() + } + } + } +<console>:9: error: type mismatch: + found : C.this.T(C.this.x) + required: T' + +where T is a type in class C + T' is a type in the initalizer of value s which is an alias of String + + var y: T = x + ^ +<console>:13: error: type mismatch: + found : T(y) + required: T' + +where T is a type in the initalizer of value s which is an alias of String + T' is a type in method f which is an alias of Int + + val z: T = y + ^ +scala> :quit |