diff options
author | odersky <odersky@gmail.com> | 2015-01-31 19:19:07 +0100 |
---|---|---|
committer | odersky <odersky@gmail.com> | 2015-01-31 19:19:07 +0100 |
commit | a822fc15235d9cc91302bd82d180830eff357ae2 (patch) | |
tree | 3bd15eecb77b1fca0b944ba5f203ba6f5c41a582 /tests | |
parent | 537c53b2eba195317f0e7f0ede0cf3fdbd80e790 (diff) | |
parent | 70e55d26100199b99502705233786bbdc15c4c6b (diff) | |
download | dotty-a822fc15235d9cc91302bd82d180830eff357ae2.tar.gz dotty-a822fc15235d9cc91302bd82d180830eff357ae2.tar.bz2 dotty-a822fc15235d9cc91302bd82d180830eff357ae2.zip |
Merge pull request #331 from dotty-staging/fix/refined-subtyping
Fix/refined subtyping
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/moduleSubtyping.scala | 23 | ||||
-rw-r--r-- | tests/pending/pos/channels.scala | 4 | ||||
-rw-r--r-- | tests/pending/pos/subtypcycle.scala | 10 | ||||
-rw-r--r-- | tests/pending/pos/t2624.scala | 4 | ||||
-rw-r--r-- | tests/pending/pos/t267.scala | 55 | ||||
-rw-r--r-- | tests/pos/Patterns.scala | 2 | ||||
-rw-r--r-- | tests/pos/bounds.scala (renamed from tests/pending/pos/bounds.scala) | 0 | ||||
-rw-r--r-- | tests/pos/caseClassInMethod.scala (renamed from tests/pending/pos/caseClassInMethod.scala) | 2 | ||||
-rw-r--r-- | tests/pos/class-dependent-extension-method.scala (renamed from tests/pending/pos/class-dependent-extension-method.scala) | 0 | ||||
-rw-r--r-- | tests/pos/compound.scala (renamed from tests/pending/pos/compound.scala) | 5 | ||||
-rw-r--r-- | tests/pos/refinedSubtyping.scala | 10 | ||||
-rw-r--r-- | tests/pos/subtyping.scala | 13 | ||||
-rw-r--r-- | tests/pos/t0674.scala | 10 | ||||
-rw-r--r-- | tests/pos/t1208.scala (renamed from tests/pending/pos/t1208.scala) | 0 |
14 files changed, 71 insertions, 67 deletions
diff --git a/tests/neg/moduleSubtyping.scala b/tests/neg/moduleSubtyping.scala new file mode 100644 index 000000000..18e93d5ac --- /dev/null +++ b/tests/neg/moduleSubtyping.scala @@ -0,0 +1,23 @@ +class C { + + object o { + + var a: C.this.o.type = ??? + var b: this.type = ??? + a = b // OK + b = a // OK + + var c: Test.o.type = ??? + a = c // error + b = c // error + c = a // error + c = b // error + } + +} + +object Test extends C { + + + +} diff --git a/tests/pending/pos/channels.scala b/tests/pending/pos/channels.scala index b2f0cdc32..77736305f 100644 --- a/tests/pending/pos/channels.scala +++ b/tests/pending/pos/channels.scala @@ -1,3 +1,5 @@ +// To compile this test, we need some more elaborate GADT capabilities. +// Not sure yet we should invest to get them. class Channel[a] import collection.mutable.Set @@ -16,7 +18,7 @@ object Test extends App { def f[b](x: ![b]): Int = x match { case send: ![c] => send.chan match { - case IC => send.data + case IC => send.data // Here, from the fact that `chan` is an IC, we need to conclude that `c` is Int. } } } diff --git a/tests/pending/pos/subtypcycle.scala b/tests/pending/pos/subtypcycle.scala new file mode 100644 index 000000000..76eb7ffec --- /dev/null +++ b/tests/pending/pos/subtypcycle.scala @@ -0,0 +1,10 @@ +object subtypcycle { + trait Y { + type A <: { type T >: B } + type B >: { type T >: A } + } + + val y: Y = ??? + val a: y.A = ??? + val b: y.B = a +} diff --git a/tests/pending/pos/t2624.scala b/tests/pending/pos/t2624.scala deleted file mode 100644 index 76f0e3036..000000000 --- a/tests/pending/pos/t2624.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test { - List(1).map(identity(_)) - List(1).map(identity) // this didn't typecheck before the fix -} diff --git a/tests/pending/pos/t267.scala b/tests/pending/pos/t267.scala deleted file mode 100644 index 7e5876eae..000000000 --- a/tests/pending/pos/t267.scala +++ /dev/null @@ -1,55 +0,0 @@ -package expAbstractData - -/** A base class consisting of - * - a root trait (i.e. abstract class) `Exp' with an `eval' function - * - an abstract type `exp' bounded by `Exp' - * - a concrete instance class `Num' of `Exp' for numeric literals - */ -trait Base { - type exp <: Exp - - trait Exp { - def eval: Int - } - class Num(v: Int) extends Exp { self: exp => - val value = v - def eval = value - } -} - -object testBase extends App with Base { - type exp = Exp - val term = new Num(2); - Console.println(term.eval) -} - -/** Data extension: An extension of `Base' with `Plus' expressions - */ -trait BasePlus extends Base { - class Plus(l: exp, r: exp) extends Exp { self: exp => - val left = l - val right = r - def eval = left.eval + right.eval - } -} - -/** Operation extension: An extension of `Base' with 'show' methods. - */ -trait Show extends Base { - type exp <: Exp1 - - trait Exp1 extends Exp { - def show: String - } - class Num1(v: Int) extends Num(v) with Exp1 { self: exp with Num1 => - def show = value.toString() - } -} - -/** Operation extension: An extension of `BasePlus' with 'show' methods. - */ -trait ShowPlus extends BasePlus with Show { - class Plus1(l: exp, r: exp) extends Plus(l, r) with Exp1 { self: exp with Plus1 => - def show = left.show + " + " + right.show - } -} diff --git a/tests/pos/Patterns.scala b/tests/pos/Patterns.scala index 54c4d8ab2..e443c2ab5 100644 --- a/tests/pos/Patterns.scala +++ b/tests/pos/Patterns.scala @@ -6,7 +6,7 @@ object Patterns { private def rebase(tp: NamedType): Type = { def rebaseFrom(prefix: Type): Type = ??? tp.prefix match { - case RefinedThis(rt) => rebaseFrom(rt) + case SkolemType(rt) => rebaseFrom(rt) case pre: ThisType => rebaseFrom(pre) case _ => tp } diff --git a/tests/pending/pos/bounds.scala b/tests/pos/bounds.scala index 26bc84a1b..26bc84a1b 100644 --- a/tests/pending/pos/bounds.scala +++ b/tests/pos/bounds.scala diff --git a/tests/pending/pos/caseClassInMethod.scala b/tests/pos/caseClassInMethod.scala index 958e5dd47..2e6484792 100644 --- a/tests/pending/pos/caseClassInMethod.scala +++ b/tests/pos/caseClassInMethod.scala @@ -1,5 +1,5 @@ object t { def f = { object C; case class C(); 1 } - // pending: def g = { case class D(x: Int); object D; 2 } + def g = { case class D(x: Int); object D; 2 } def h = { case class E(y: Int = 10); 3 } } diff --git a/tests/pending/pos/class-dependent-extension-method.scala b/tests/pos/class-dependent-extension-method.scala index b557dfa8f..b557dfa8f 100644 --- a/tests/pending/pos/class-dependent-extension-method.scala +++ b/tests/pos/class-dependent-extension-method.scala diff --git a/tests/pending/pos/compound.scala b/tests/pos/compound.scala index 60890f910..24a936f13 100644 --- a/tests/pending/pos/compound.scala +++ b/tests/pos/compound.scala @@ -7,3 +7,8 @@ abstract class Test { var xx: A with B { type T; val xz: T } = null; xx = yy; } + +abstract class Test2 { + var yy: A with B { type T; val xz: T } = null; + val xx: A with B { type T; val xz: T } = yy +} diff --git a/tests/pos/refinedSubtyping.scala b/tests/pos/refinedSubtyping.scala index a01be181d..e6a972e1c 100644 --- a/tests/pos/refinedSubtyping.scala +++ b/tests/pos/refinedSubtyping.scala @@ -60,3 +60,13 @@ class Test3 { y = x } +class Test4 { + + abstract class A { type T; val xz: Any } + + val yy: A { val xz: T } = null; +// val xx: A { val xz: T } = null; + val zz: A { val xz: T } = yy; + +} + diff --git a/tests/pos/subtyping.scala b/tests/pos/subtyping.scala index 95e813bdd..29d830dd2 100644 --- a/tests/pos/subtyping.scala +++ b/tests/pos/subtyping.scala @@ -16,4 +16,17 @@ object test { } +object test2 { + + class A + class B + + val x: A | B = ??? + val y: B | A = x + + val a: A & B = ??? + val b: B & A = a + +} + diff --git a/tests/pos/t0674.scala b/tests/pos/t0674.scala index 589eeec9f..a734091da 100644 --- a/tests/pos/t0674.scala +++ b/tests/pos/t0674.scala @@ -39,10 +39,10 @@ for(a <- Some(1); l <- Some(12); m <- Some(13); n <- Some(14); - o <- Some(15) -// p <- Some(16); -// q <- Some(17) -// r <- Some(18); -// s <- Some(19) + o <- Some(15); + p <- Some(16); + q <- Some(17); + r <- Some(18); + s <- Some(19) ) yield a) } diff --git a/tests/pending/pos/t1208.scala b/tests/pos/t1208.scala index 7b14aadca..7b14aadca 100644 --- a/tests/pending/pos/t1208.scala +++ b/tests/pos/t1208.scala |