Skip to content

Commit 5eb0d10

Browse files
committed
Avoid more constraints in result if trying views
1 parent 4edbdc2 commit 5eb0d10

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4447,12 +4447,15 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
44474447
def argHasDefault = hasDefaultParams && !defaultArg.isEmpty
44484448

44494449
def canProfitFromMoreConstraints =
4450+
!ctx.mode.is(Mode.ImplicitExploration)
4451+
&& {
44504452
arg.tpe.isInstanceOf[AmbiguousImplicits]
44514453
// Ambiguity could be decided by more constraints
44524454
|| !isFullyDefined(formal, ForceDegree.none) && !argHasDefault
44534455
// More context might constrain type variables which could make implicit scope larger.
44544456
// But in this case we should search with additional arguments typed only if there
44554457
// is no default argument.
4458+
}
44564459

44574460
// Try to constrain the result using `pt1`, but back out if a BadTyperStateAssertion
44584461
// is thrown. TODO Find out why the bad typer state arises and prevent it. The try-catch
@@ -4560,9 +4563,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
45604563
else
45614564
val app = cpy.Apply(tree)(untpd.TypedSplice(tree), namedArgs)
45624565
// old-style implicit needs to be marked using so that implicits are searched
4566+
/*
45634567
val needsUsing = wtp.isImplicitMethod || wtp.match
45644568
case MethodType(ContextBoundParamName(_) :: _) => sourceVersion.isAtLeast(`3.4`)
45654569
case _ => false
4570+
*/
4571+
val needsUsing = true //wtp.isImplicitMethod is asserted at beginning of method
45664572
if needsUsing then app.setApplyKind(ApplyKind.Using)
45674573
typr.println(i"try with default implicit args $app")
45684574
// If the retyped tree still has an error type and is an `Apply`

0 commit comments

Comments
 (0)