Skip to content

Commit

Permalink
Retract SynthesizeExtMethodReceiver mode when when going deeper in ov…
Browse files Browse the repository at this point in the history
…erloading resolution (#18759)
  • Loading branch information
dwijnand authored Oct 25, 2023
2 parents 38559d7 + edc4bc8 commit f98a3aa
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 @@ -2226,7 +2226,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 f98a3aa

Please sign in to comment.