Skip to content

Commit

Permalink
Backport "Retract SynthesizeExtMethodReceiver mode when when going de…
Browse files Browse the repository at this point in the history
…eper in overloading resolution" to LTS (#20739)

Backports #18759 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jun 23, 2024
2 parents df3dc4f + 68127fd commit ead65d8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,8 @@ trait Applications extends Compatibility {
}
val mapped = reverseMapping.map(_._1)
overload.println(i"resolve mapped: ${mapped.map(_.widen)}%, % with $pt")
resolveOverloaded(mapped, pt).map(reverseMapping.toMap)
resolveOverloaded(mapped, pt)(using ctx.retractMode(Mode.SynthesizeExtMethodReceiver))
.map(reverseMapping.toMap)

/** Try to typecheck any arguments in `pt` that are function values missing a
* parameter type. If the formal parameter types corresponding to a closure argument
Expand Down
13 changes: 13 additions & 0 deletions tests/pos/i18744.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package dotty.tools.dotc.typer

object Color:
def apply(): Int = ???

extension (u: Unit)
def foo(that: String, f: Int => Int): Int = ???
def foo(that: Long, f: Int => Int): Int = ???

def test =
val c = Color()
().foo("", (_: Int) => c)
().foo("", (_: Int) => Color())
14 changes: 14 additions & 0 deletions tests/pos/i18745.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
object Color:
def apply(i: Int): Int = i

type Plane

object Plane:
extension (plane: Plane)
def zipWith(that: String, f: Int => Int): Int = ???
def zipWith(that: Int, f: Int => Int): Int = ???

import Plane.zipWith

def test(p: Plane) =
p.zipWith("", (_: Int) => Color(25))

0 comments on commit ead65d8

Please sign in to comment.