Skip to content

Commit c3bce86

Browse files
committed
Fix #7084: Drop revealProtoOfExtMethod
Don't call `revealProtoOfExtMethod` wehn constraining results in adaptation. Revealing the proottype too early disables further implicit searches, as is demonstrated by i7084.scala. The original reason to have `revealProtoOfExtMethod` was to typecheck i5773a. But it looks like this is no longer valid. i5773a now compiles regardless.
1 parent c9d2f34 commit c3bce86

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,13 +2485,6 @@ class Typer extends Namer
24852485
}
24862486
}
24872487

2488-
/** Reveal ignored parts of prototype when synthesizing the receiver
2489-
* of an extension method. This is necessary for pos/i5773a.scala
2490-
*/
2491-
def revealProtoOfExtMethod(tp: Type)(implicit ctx: Context): Type =
2492-
if (ctx.mode.is(Mode.SynthesizeExtMethodReceiver)) tp.deepenProto
2493-
else tp
2494-
24952488
def adaptNoArgsImplicitMethod(wtp: MethodType): Tree = {
24962489
assert(wtp.isImplicitMethod)
24972490
val tvarsToInstantiate = tvarsInParams(tree, locked).distinct
@@ -2512,7 +2505,7 @@ class Typer extends Namer
25122505
arg.tpe match {
25132506
case failed: AmbiguousImplicits =>
25142507
val pt1 = pt.deepenProto
2515-
if ((pt1 `ne` pt) && resultMatches(wtp, pt1)) implicitArgs(formals, argIndex, pt1)
2508+
if ((pt1 `ne` pt) && constrainResult(tree.symbol, wtp, pt1)) implicitArgs(formals, argIndex, pt1)
25162509
else arg :: implicitArgs(formals1, argIndex + 1, pt1)
25172510
case failed: SearchFailureType if !tree.symbol.hasDefaultParams =>
25182511
// no need to search further, the adapt fails in any case
@@ -2742,9 +2735,6 @@ class Typer extends Namer
27422735
case _ => tp
27432736
}
27442737

2745-
def resultMatches(wtp: Type, pt: Type) =
2746-
constrainResult(tree.symbol, wtp, revealProtoOfExtMethod(pt))
2747-
27482738
def adaptNoArgs(wtp: Type): Tree = {
27492739
val ptNorm = underlyingApplied(pt)
27502740
def functionExpected = defn.isFunctionType(ptNorm)
@@ -2758,7 +2748,7 @@ class Typer extends Namer
27582748
case wtp: ExprType =>
27592749
readaptSimplified(tree.withType(wtp.resultType))
27602750
case wtp: MethodType if wtp.isImplicitMethod &&
2761-
({ resMatch = resultMatches(wtp, pt); resMatch } || !functionExpected) =>
2751+
({ resMatch = constrainResult(tree.symbol, wtp, pt); resMatch } || !functionExpected) =>
27622752
if (resMatch || ctx.mode.is(Mode.ImplicitsEnabled))
27632753
adaptNoArgsImplicitMethod(wtp)
27642754
else {

0 commit comments

Comments
 (0)