Skip to content

Commit ead65d8

Browse files
Backport "Retract SynthesizeExtMethodReceiver mode when when going deeper in overloading resolution" to LTS (#20739)
Backports #18759 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents df3dc4f + 68127fd commit ead65d8

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2212,7 +2212,8 @@ trait Applications extends Compatibility {
22122212
}
22132213
val mapped = reverseMapping.map(_._1)
22142214
overload.println(i"resolve mapped: ${mapped.map(_.widen)}%, % with $pt")
2215-
resolveOverloaded(mapped, pt).map(reverseMapping.toMap)
2215+
resolveOverloaded(mapped, pt)(using ctx.retractMode(Mode.SynthesizeExtMethodReceiver))
2216+
.map(reverseMapping.toMap)
22162217

22172218
/** Try to typecheck any arguments in `pt` that are function values missing a
22182219
* parameter type. If the formal parameter types corresponding to a closure argument

tests/pos/i18744.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package dotty.tools.dotc.typer
2+
3+
object Color:
4+
def apply(): Int = ???
5+
6+
extension (u: Unit)
7+
def foo(that: String, f: Int => Int): Int = ???
8+
def foo(that: Long, f: Int => Int): Int = ???
9+
10+
def test =
11+
val c = Color()
12+
().foo("", (_: Int) => c)
13+
().foo("", (_: Int) => Color())

tests/pos/i18745.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
object Color:
2+
def apply(i: Int): Int = i
3+
4+
type Plane
5+
6+
object Plane:
7+
extension (plane: Plane)
8+
def zipWith(that: String, f: Int => Int): Int = ???
9+
def zipWith(that: Int, f: Int => Int): Int = ???
10+
11+
import Plane.zipWith
12+
13+
def test(p: Plane) =
14+
p.zipWith("", (_: Int) => Color(25))

0 commit comments

Comments
 (0)