diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 7 |
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 |