From 422b06126d3809f4db11dba0988cd21857e1f9de Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 7 Apr 2016 17:49:15 +0200 Subject: Search implicit arguments in the same context as typing explicit ones For explicit arguments of this(...) constrictor calls we have a special context that hides members of the current class. But for implicit arguments we did not. This led to implicit shadowing errors for scala.collection.immutable.PagedSeq when secondary constructor type parameters were fixed (as done in subsequent commits). --- src/dotty/tools/dotc/typer/Applications.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Applications.scala') diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index f3903e539..ec2508580 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -531,12 +531,16 @@ trait Applications extends Compatibility { self: Typer => def treeToArg(arg: Tree): Tree = arg } + /** If `app` is a `this(...)` constructor call, the this-call argument context, + * otherwise the current context. + */ + def argCtx(app: untpd.Tree)(implicit ctx: Context): Context = + if (untpd.isSelfConstrCall(app)) ctx.thisCallArgContext else ctx + def typedApply(tree: untpd.Apply, pt: Type)(implicit ctx: Context): Tree = { def realApply(implicit ctx: Context): Tree = track("realApply") { - def argCtx(implicit ctx: Context) = - if (untpd.isSelfConstrCall(tree)) ctx.thisCallArgContext else ctx - var proto = new FunProto(tree.args, IgnoredProto(pt), this)(argCtx) + var proto = new FunProto(tree.args, IgnoredProto(pt), this)(argCtx(tree)) val fun1 = typedExpr(tree.fun, proto) // Warning: The following line is dirty and fragile. We record that auto-tupling was demanded as @@ -554,7 +558,7 @@ trait Applications extends Compatibility { self: Typer => tryEither { implicit ctx => val app = if (proto.argsAreTyped) new ApplyToTyped(tree, fun1, funRef, proto.typedArgs, pt) - else new ApplyToUntyped(tree, fun1, funRef, proto, pt)(argCtx) + else new ApplyToUntyped(tree, fun1, funRef, proto, pt)(argCtx(tree)) val result = app.result convertNewArray(ConstFold(result)) } { (failedVal, failedState) => -- cgit v1.2.3