@@ -3752,7 +3752,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3752
3752
3753
3753
def dummyArg (tp : Type ) = untpd.Ident (nme.??? ).withTypeUnchecked(tp)
3754
3754
3755
- def addImplicitArgs (using Context ) = {
3755
+ val origCtx = ctx
3756
+
3757
+ def addImplicitArgs (using Context ) =
3756
3758
def hasDefaultParams = methPart(tree).symbol.hasDefaultParams
3757
3759
def implicitArgs (formals : List [Type ], argIndex : Int , pt : Type ): List [Tree ] = formals match
3758
3760
case Nil => Nil
@@ -3872,15 +3874,20 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3872
3874
case _ => retyped
3873
3875
else issueErrors(tree, args)
3874
3876
}
3875
- else tree match {
3876
- case tree : Block =>
3877
- readaptSimplified(tpd.Block (tree.stats, tpd.Apply (tree.expr, args)))
3878
- case tree : NamedArg =>
3879
- readaptSimplified(tpd.NamedArg (tree.name, tpd.Apply (tree.arg, args)))
3880
- case _ =>
3881
- readaptSimplified(tpd.Apply (tree, args))
3882
- }
3883
- }
3877
+ else
3878
+ inContext(origCtx):
3879
+ // Reset context in case it was set to a supercall context before.
3880
+ // otherwise the invariant for taking another this or super call context is not met.
3881
+ // Test case is i20483.scala
3882
+ tree match
3883
+ case tree : Block =>
3884
+ readaptSimplified(tpd.Block (tree.stats, tpd.Apply (tree.expr, args)))
3885
+ case tree : NamedArg =>
3886
+ readaptSimplified(tpd.NamedArg (tree.name, tpd.Apply (tree.arg, args)))
3887
+ case _ =>
3888
+ readaptSimplified(tpd.Apply (tree, args))
3889
+ end addImplicitArgs
3890
+
3884
3891
pt.revealIgnored match {
3885
3892
case pt : FunProto if pt.applyKind == ApplyKind .Using =>
3886
3893
// We can end up here if extension methods are called with explicit given arguments.
0 commit comments