Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport "Retract SynthesizeExtMethodReceiver mode when when going deeper in overloading resolution" to LTS #20739

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Loading