summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2010-09-16 22:26:04 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2010-09-16 22:26:04 +0000
commitce223fe7abc47af712382a64404604e75f9f4d20 (patch)
tree2af8639c5c9d9bcda88ef59b4598b2b4d5221406 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent44784f3e41c2cc141c3eb5a0dcb656005befcfa4 (diff)
downloadscala-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 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 7ef494ea73..e71ad5475c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1751,7 +1751,7 @@ trait Typers { self: Analyzer =>
error(vparam1.pos, "*-parameter must come last")
var tpt1 = checkNoEscaping.privates(meth, typedType(ddef.tpt))
- if (!settings.Xexperimental.value) {
+ if (!settings.YdepMethTpes.value) {
for (vparams <- vparamss1; vparam <- vparams) {
checkNoEscaping.locals(context.scope, WildcardType, vparam.tpt); ()
}
@@ -2420,7 +2420,10 @@ trait Typers { self: Analyzer =>
val tparams = context.extractUndetparams()
if (tparams.isEmpty) { // all type params are defined
val args1 = typedArgs(args, argMode(fun, mode), paramTypes, formals)
- val restpe = mt.resultType(args1 map (_.tpe)) // instantiate dependent method types
+ // instantiate dependent method types, must preserve singleton types where possible (stableTypeFor) -- example use case:
+ // val foo = "foo"; def precise(x: String)(y: x.type): x.type = {...}; val bar : foo.type = precise(foo)(foo)
+ // precise(foo) : foo.type => foo.type
+ val restpe = mt.resultType(args1 map (arg => gen.stableTypeFor(arg) getOrElse arg.tpe))
def ifPatternSkipFormals(tp: Type) = tp match {
case MethodType(_, rtp) if ((mode & PATTERNmode) != 0) => rtp
case _ => tp