aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala12
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala6
2 files changed, 11 insertions, 7 deletions
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) =>
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 3b8ada2a8..fac24e440 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1518,7 +1518,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val tvarsToInstantiate = tvarsInParams(tree)
wtp.paramTypes.foreach(instantiateSelected(_, tvarsToInstantiate))
val constr = ctx.typerState.constraint
- def addImplicitArgs = {
+ def addImplicitArgs(implicit ctx: Context) = {
val errors = new mutable.ListBuffer[() => String]
def implicitArgError(msg: => String) = {
errors += (() => msg)
@@ -1565,9 +1565,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
else adapt(tpd.Apply(tree, args), pt)
}
- if ((pt eq WildcardType) || original.isEmpty) addImplicitArgs
+ if ((pt eq WildcardType) || original.isEmpty) addImplicitArgs(argCtx(tree))
else
- ctx.typerState.tryWithFallback(addImplicitArgs) {
+ ctx.typerState.tryWithFallback(addImplicitArgs(argCtx(tree))) {
adapt(typed(original, WildcardType), pt, EmptyTree)
}
case wtp: MethodType if !pt.isInstanceOf[SingletonType] =>