Skip to content

Commit f3339f3

Browse files
committed
Avoid more constraints in result if trying views
1 parent f1df986 commit f3339f3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4473,12 +4473,15 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
44734473
def argHasDefault = hasDefaultParams && !defaultArg.isEmpty
44744474

44754475
def canProfitFromMoreConstraints =
4476+
!ctx.mode.is(Mode.ImplicitExploration)
4477+
&& {
44764478
arg.tpe.isInstanceOf[AmbiguousImplicits]
44774479
// Ambiguity could be decided by more constraints
44784480
|| !isFullyDefined(formal, ForceDegree.none) && !argHasDefault
44794481
// More context might constrain type variables which could make implicit scope larger.
44804482
// But in this case we should search with additional arguments typed only if there
44814483
// is no default argument.
4484+
}
44824485

44834486
// Try to constrain the result using `pt1`, but back out if a BadTyperStateAssertion
44844487
// is thrown. TODO Find out why the bad typer state arises and prevent it. The try-catch
@@ -4586,7 +4589,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
45864589
else
45874590
val app = cpy.Apply(tree)(untpd.TypedSplice(tree), namedArgs)
45884591
// old-style implicit needs to be marked using so that implicits are searched
4589-
val needsUsing = wtp.isImplicitMethod || wtp.match
4592+
// wtp.isImplicitMethod is asserted at beginning of method
4593+
val needsUsing = wtp.match
45904594
case MethodType(ContextBoundParamName(_) :: _) => sourceVersion.isAtLeast(`3.4`)
45914595
case _ => false
45924596
if needsUsing then app.setApplyKind(ApplyKind.Using)

0 commit comments

Comments
 (0)