diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2010-09-16 22:26:04 +0000 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2010-09-16 22:26:04 +0000 |
commit | ce223fe7abc47af712382a64404604e75f9f4d20 (patch) | |
tree | 2af8639c5c9d9bcda88ef59b4598b2b4d5221406 /test | |
parent | 44784f3e41c2cc141c3eb5a0dcb656005befcfa4 (diff) | |
download | scala-ce223fe7abc47af712382a64404604e75f9f4d20.tar.gz scala-ce223fe7abc47af712382a64404604e75f9f4d20.tar.bz2 scala-ce223fe7abc47af712382a64404604e75f9f4d20.zip |
closes #1569, #3731: refactored dependent metho...
closes #1569, #3731: refactored dependent method types to get rid of
debruijn indices and use singleton types instead.
this is the core of the dependent types refactoring, no implicit or
inference changes
(one baffling discovery: resultType should drop annotations that don't subclass TypeConstraint, even in the trivial case... wow -- thanks to Tiark for helping me figure it out on a terrace in Barcelona
TODO: probably need a more principled approach to the propagation of plugin type-annotations)
review by odersky
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/depmet_1.check | 10 | ||||
-rw-r--r-- | test/files/neg/depmet_1.flags | 1 | ||||
-rw-r--r-- | test/files/neg/depmet_1.scala | 5 | ||||
-rw-r--r-- | test/files/pos/depmet_1.flags | 1 | ||||
-rw-r--r-- | test/files/pos/depmet_1.scala | 6 | ||||
-rw-r--r-- | test/files/pos/t1569.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t1569.scala | 5 | ||||
-rw-r--r-- | test/files/run/constrained-types.check | 4 | ||||
-rw-r--r-- | test/files/run/constrained-types.scala | 2 |
9 files changed, 32 insertions, 3 deletions
diff --git a/test/files/neg/depmet_1.check b/test/files/neg/depmet_1.check new file mode 100644 index 0000000000..7a4f845fd5 --- /dev/null +++ b/test/files/neg/depmet_1.check @@ -0,0 +1,10 @@ +depmet_1.scala:2: error: illegal dependent method type: parameter appears in the type of another parameter in the same section or an earlier one + def precise0(y: x.type)(x: String): Unit = {} + ^ +depmet_1.scala:3: error: illegal dependent method type: parameter appears in the type of another parameter in the same section or an earlier one + def precise1(x: String, y: x.type): Unit = {} + ^ +depmet_1.scala:4: error: not found: value y + def precise2[T <: y.type](y: String): Unit = {} + ^ +three errors found diff --git a/test/files/neg/depmet_1.flags b/test/files/neg/depmet_1.flags new file mode 100644 index 0000000000..1c26b24745 --- /dev/null +++ b/test/files/neg/depmet_1.flags @@ -0,0 +1 @@ +-Ydependent-method-types
\ No newline at end of file diff --git a/test/files/neg/depmet_1.scala b/test/files/neg/depmet_1.scala new file mode 100644 index 0000000000..fc672e1ed8 --- /dev/null +++ b/test/files/neg/depmet_1.scala @@ -0,0 +1,5 @@ +object Test { + def precise0(y: x.type)(x: String): Unit = {} + def precise1(x: String, y: x.type): Unit = {} + def precise2[T <: y.type](y: String): Unit = {} +}
\ No newline at end of file diff --git a/test/files/pos/depmet_1.flags b/test/files/pos/depmet_1.flags new file mode 100644 index 0000000000..1c26b24745 --- /dev/null +++ b/test/files/pos/depmet_1.flags @@ -0,0 +1 @@ +-Ydependent-method-types
\ No newline at end of file diff --git a/test/files/pos/depmet_1.scala b/test/files/pos/depmet_1.scala new file mode 100644 index 0000000000..166e991817 --- /dev/null +++ b/test/files/pos/depmet_1.scala @@ -0,0 +1,6 @@ +object Test { + def precise(x: String)(y: x.type): x.type = y + val foo = "foo" + val fun : foo.type => foo.type = precise(foo) + val bar : foo.type = precise(foo)(foo) +}
\ No newline at end of file diff --git a/test/files/pos/t1569.flags b/test/files/pos/t1569.flags new file mode 100644 index 0000000000..1c26b24745 --- /dev/null +++ b/test/files/pos/t1569.flags @@ -0,0 +1 @@ +-Ydependent-method-types
\ No newline at end of file diff --git a/test/files/pos/t1569.scala b/test/files/pos/t1569.scala new file mode 100644 index 0000000000..e5f9553268 --- /dev/null +++ b/test/files/pos/t1569.scala @@ -0,0 +1,5 @@ +object Bug { + class C { type T } + def foo(x: Int)(y: C)(z: y.T) {} + foo(3)(new C { type T = String })("hello") +}
\ No newline at end of file diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index cc00a7c46b..8050017659 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -52,8 +52,8 @@ val y = b.y // should keep the annotation y: Int @Annot(Stuff.x) = 10 ----- -def m(x: String): String @Annot(x) = x // m should be annotated with a debruijn -m: (x$0:String)String @Annot(x) +def m(x: String): String @Annot(x) = x +m: (x: String)String @Annot(x) ----- val three = "three" diff --git a/test/files/run/constrained-types.scala b/test/files/run/constrained-types.scala index 59fd0b1b8c..c03c144ad1 100644 --- a/test/files/run/constrained-types.scala +++ b/test/files/run/constrained-types.scala @@ -45,7 +45,7 @@ object Test { "val y = b.y // should keep the annotation", - "def m(x: String): String @Annot(x) = x // m should be annotated with a debruijn", + "def m(x: String): String @Annot(x) = x", "val three = \"three\"", "val three2 = m(three:three.type) // should change x to three", "var four = \"four\"", |