Skip to content

Commit 73c2790

Browse files
committed
Always use WildcardType for ExtMethodApply
1 parent f28a83c commit 73c2790

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,11 @@ object Applications {
216216
/** A wrapper indicating that its argument is an application of an extension method.
217217
*/
218218
class ExtMethodApply(app: Tree)(implicit @constructorOnly src: SourceFile)
219-
extends IntegratedTypeArgs(app)
220-
219+
extends IntegratedTypeArgs(app) {
220+
overwriteType(WildcardType)
221+
// ExtMethodApply always has wildcard type in order not to prompt any further adaptations
222+
// such as eta expansion before the method is fully applied.
223+
}
221224
}
222225

223226
trait Applications extends Compatibility { self: Typer with Dynamic =>

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,10 +1348,7 @@ trait Implicits { self: Typer =>
13481348
}
13491349
else {
13501350
val returned =
1351-
if (cand.isExtension)
1352-
new Applications.ExtMethodApply(adapted).withType(WildcardType)
1353-
// Use wildcard type in order not to prompt any further adaptations such as eta expansion
1354-
// before the method is fully applied.
1351+
if (cand.isExtension) Applications.ExtMethodApply(adapted)
13551352
else adapted
13561353
SearchSuccess(returned, ref, cand.level)(ctx.typerState, ctx.gadt)
13571354
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,9 +3021,7 @@ class Typer extends Namer
30213021
val app = tryExtension(nestedCtx)
30223022
if (!app.isEmpty && !nestedCtx.reporter.hasErrors) {
30233023
nestedCtx.typerState.commit()
3024-
return new ExtMethodApply(app).withType(WildcardType)
3025-
// Use wildcard type in order not to prompt any further adaptations such as eta expansion
3026-
// before the method is fully applied.
3024+
return ExtMethodApply(app)
30273025
}
30283026
case _ =>
30293027
}

0 commit comments

Comments
 (0)