Skip to content

Commit f98a3aa

Browse files
authored
Retract SynthesizeExtMethodReceiver mode when when going deeper in overloading resolution (#18759)
2 parents 38559d7 + edc4bc8 commit f98a3aa

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,8 @@ trait Applications extends Compatibility {
22262226
}
22272227
val mapped = reverseMapping.map(_._1)
22282228
overload.println(i"resolve mapped: ${mapped.map(_.widen)}%, % with $pt")
2229-
resolveOverloaded(mapped, pt).map(reverseMapping.toMap)
2229+
resolveOverloaded(mapped, pt)(using ctx.retractMode(Mode.SynthesizeExtMethodReceiver))
2230+
.map(reverseMapping.toMap)
22302231

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

tests/pos/i18744.scala

+13
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

+14
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)