diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 180ff505e76c..6592afe03da5 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -433,15 +433,18 @@ trait Applications extends Compatibility { protected def init(): Unit = methType match { case methType: MethodType => - // apply the result type constraint, unless method type is dependent val resultApprox = resultTypeApprox(methType) - if (!constrainResult(methRef.symbol, resultApprox, resultType)) - if (ctx.typerState.isCommittable) - // defer the problem until after the application; - // it might be healed by an implicit conversion - () - else - fail(TypeMismatch(methType.resultType, resultType, None)) + val sym = methRef.symbol + if ctx.typerState.isCommittable then + // Here we call `resultType` only to accumulate constraints (even if + // it fails, we might be able to heal the expression to conform to the + // result type) so don't check for views since `viewExists` doesn't + // have any side-effect and would only slow the compiler down (cf #14333). + NoViewsAllowed.constrainResult(sym, resultApprox, resultType) + else if !constrainResult(sym, resultApprox, resultType) then + // Here we actually record that this alternative failed so that + // overloading resolution might prune it. + fail(TypeMismatch(methType.resultType, resultType, None)) // match all arguments with corresponding formal parameters matchArgs(orderedArgs, methType.paramInfos, 0)