diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 954bd38ec216..431721dc44e6 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1821,6 +1821,7 @@ class Typer extends Namer xtree.isTerm && !untpd.isImplicitClosure(xtree) && !ctx.mode.is(Mode.ImplicitShadowing) && + !ctx.mode.is(Mode.Pattern) && !ctx.isAfterTyper) makeImplicitFunction(xtree, ifpt) else xtree match { @@ -2317,6 +2318,7 @@ class Typer extends Namer if (defn.isImplicitFunctionClass(wtp.underlyingClassRef(refinementOK = false).classSymbol) && !untpd.isImplicitClosure(tree) && !isApplyProto(pt) && + !ctx.mode.is(Mode.Pattern) && !ctx.isAfterTyper) { typr.println(i"insert apply on implicit $tree") typed(untpd.Select(untpd.TypedSplice(tree), nme.apply), pt, locked) diff --git a/tests/pos/i4203.scala b/tests/pos/i4203.scala new file mode 100644 index 000000000000..3549237bff2a --- /dev/null +++ b/tests/pos/i4203.scala @@ -0,0 +1,9 @@ +case class Box[Z](unbox: Z) + +object Test { + def foo(b: Box[implicit Int => Int]): Int = b match { + case Box(f) => + implicit val i: Int = 1 + f + } +}