aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/hk.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-31 10:36:42 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-31 11:44:17 +0100
commit3edab6ec1444b19203381612fba3e16ca1bafc95 (patch)
tree7e1985909b62c47004aeb29017bc05375eeba39d /tests/pos/hk.scala
parent4a175b13e4fcefc7cb3cf70da254205a14dc2418 (diff)
downloaddotty-3edab6ec1444b19203381612fba3e16ca1bafc95.tar.gz
dotty-3edab6ec1444b19203381612fba3e16ca1bafc95.tar.bz2
dotty-3edab6ec1444b19203381612fba3e16ca1bafc95.zip
Upgrades to handle subtyping between parameterized and higher-kinded types.
Diffstat (limited to 'tests/pos/hk.scala')
-rw-r--r--tests/pos/hk.scala35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/pos/hk.scala b/tests/pos/hk.scala
new file mode 100644
index 000000000..f2f10bbfb
--- /dev/null
+++ b/tests/pos/hk.scala
@@ -0,0 +1,35 @@
+import language.higherKinds
+
+object higherKinded {
+
+ type Untyped = Null
+
+ class Tree[-T >: Untyped] {
+ type ThisType[-U >: Untyped] <: Tree[U]
+ def withString(s: String): ThisType[String] = withString(s)
+ }
+
+ class Ident[-T >: Untyped] extends Tree[T] {
+ type ThisType[-U] = Ident[U]
+ }
+
+ val id = new Ident[Integer]
+
+ val y = id.withString("abc")
+
+ val z: Ident[String] = y
+
+ val zz: tpd.Tree = y
+
+ abstract class Instance[T >: Untyped] {
+ type Tree = higherKinded.Tree[T]
+ }
+
+ object tpd extends Instance[String]
+
+ def transform(tree: Tree[String]) = {
+ val tree1 = tree.withString("")
+ tree1: Tree[String]
+ }
+
+} \ No newline at end of file