Skip to content

Commit

Permalink
Merge pull request #9829 from joroKr21/finch-fix
Browse files Browse the repository at this point in the history
Tweak inferMethodInstance to consider if implicits are enabled
  • Loading branch information
lrytz committed Dec 15, 2021
2 parents 6b55d57 + b1c2238 commit 1042160
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/compiler/scala/tools/nsc/typechecker/Infer.scala
Expand Up @@ -1076,7 +1076,11 @@ trait Infer extends Checkable {
*/
def inferMethodInstance(fn: Tree, undetParams: List[Symbol],
args: List[Tree], pt0: Type): List[Symbol] = fn.tpe match {
case mt @ MethodType(_, _) =>
case mt: MethodType =>
// If we can't infer the type parameters, we can recover in `tryTypedApply` with an implicit conversion,
// but only when implicit conversions are enabled. In that case we have to infer the type parameters again.
def noInstanceResult = if (context.implicitsEnabled) undetParams else Nil

try {
val pt = if (pt0.typeSymbol == UnitClass) WildcardType else pt0
val formals = formalTypes(mt.paramTypes, args.length)
Expand All @@ -1101,10 +1105,10 @@ trait Infer extends Checkable {
enhanceBounds(adjusted.okParams, adjusted.okArgs, xs1)
xs1
}
} else undetParams
} else noInstanceResult
} catch ifNoInstance { msg =>
NoMethodInstanceError(fn, args, msg)
undetParams
noInstanceResult
}
case x => throw new MatchError(x)
}
Expand Down

0 comments on commit 1042160

Please sign in to comment.