Skip to content

Merge nested polytypes in more cases in resolveOverloaded #15636

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

Merged
merged 1 commit into from
Jul 10, 2022
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
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ trait Applications extends Compatibility {
case mt: MethodType if mt.isImplicitMethod =>
stripImplicit(resultTypeApprox(mt))
case pt: PolyType =>
pt.derivedLambdaType(pt.paramNames, pt.paramInfos, stripImplicit(pt.resultType))
pt.derivedLambdaType(pt.paramNames, pt.paramInfos, stripImplicit(pt.resultType)).asInstanceOf[PolyType].flatten
case _ =>
tp
}
Expand Down Expand Up @@ -1520,7 +1520,7 @@ trait Applications extends Compatibility {
else compareOwner(cls1, sym2)
else 0

/** Compare to alternatives of an overloaded call or an implicit search.
/** Compare two alternatives of an overloaded call or an implicit search.
*
* @param alt1, alt2 Non-overloaded references indicating the two choices
* @return 1 if 1st alternative is preferred over 2nd
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/i11713.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extension [T1](x: T1)(using Numeric[T1])
def combine[T2](y: T2)(using Numeric[T2]) = ???
def combine(y: String) = ???

val res = 100.combine(200)
15 changes: 15 additions & 0 deletions tests/pos/i13668.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class MyType()
trait Candidate[R]
given Candidate[MyType] with {}
class Fuzzy[W]()
class Fuzzy1()
class Bear()

extension [L](lhs: L)(using Candidate[L])
def +[RW](rhs: Fuzzy[RW]): Unit = {}
def +(rhs: Bear): Unit = {}
def -(rhs: Fuzzy1): Unit = {}
def -(rhs: Bear): Unit = {}

val works = MyType() - Fuzzy1()
val fails = MyType() + Fuzzy[1]()