From 82fc27f0c2c800de786b54110cfd8627b043fe6d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 14 Jul 2016 18:06:48 +0200 Subject: Fix bounds checking of hk applied typed Previous logic could only handle classes as constructors. Also, address other reviewers comments. --- tests/neg/t7278.scala | 8 ++++---- tests/pos-scala2/t2994.scala | 2 +- tests/pos/hklower.scala | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/neg/t7278.scala b/tests/neg/t7278.scala index 7aafbb76f..643a3c858 100644 --- a/tests/neg/t7278.scala +++ b/tests/neg/t7278.scala @@ -13,8 +13,8 @@ object Test { def fail1(): Unit = { val b = new B - var x1: EE[A] = null - var x2: EE[B] = new b.E // old-error: found: B#E, required: A#E + var x1: EE[A] = null // error: Type argument A does not conform to upper bound EC + var x2: EE[B] = new b.E // error: Type argument B does not conform to upper bound EC // x1 = x2 // gives a prior type error: B#E, required: A#E, masked to get at the real thing. } @@ -27,8 +27,8 @@ object Test { } */ def fail3(): Unit = { - var x1: EE[C] = 5 - var x2: EE[C & D] = "" + var x1: EE[C] = 5 // error: Type argument C does not conform to upper bound EC + var x2: EE[C & D] = "" // error: Type argument C & D does not conform to upper bound EC x1 = x2 } diff --git a/tests/pos-scala2/t2994.scala b/tests/pos-scala2/t2994.scala index c7421c42a..f3009b12f 100644 --- a/tests/pos-scala2/t2994.scala +++ b/tests/pos-scala2/t2994.scala @@ -20,7 +20,7 @@ object Naturals { // crashes scala-2.8.0 beta1 trait MUL[n <: NAT, m <: NAT] extends NAT { - trait curry[n[_, _], s[_]] { type f[z <: NAT] = n[s, z] } + trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] } type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] } diff --git a/tests/pos/hklower.scala b/tests/pos/hklower.scala index 033ee3a34..90aa343ba 100644 --- a/tests/pos/hklower.scala +++ b/tests/pos/hklower.scala @@ -1,4 +1,4 @@ -class Test { // error: conflicting bounds +class Test { type T[X] type U[X] = T[X] @@ -6,6 +6,36 @@ class Test { // error: conflicting bounds type V[X] >: T[X] type W[X] >: T[X] <: T[X] - def f[C[X] >: T[X]]() = ??? + def f[C[X] >: T[X]](x: C[Int]) = ??? + + val v: V[Int] = ??? + val t: T[Int] = ??? + + f[V](v) + + f[V](t) + + +} +class Test2 { + + class T[X] + type U[X] = T[X] + + type V[X] >: T[X] + type W[X] >: T[X] <: T[X] + + def f[C[X] >: T[X]](x: C[Int]) = ??? + + val v: V[Int] = ??? + val t: T[Int] = ??? + + f[V](v) + + f[V](t) + + var x: V[Int] = _ + x = t + } -- cgit v1.2.3