Skip to content

Commit

Permalink
Merge pull request #15636 from griggt/fix-13668
Browse files Browse the repository at this point in the history
Merge nested polytypes in more cases in resolveOverloaded
  • Loading branch information
odersky authored Jul 10, 2022
2 parents 11d65aa + 49af4fb commit 79d9a6f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
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]()

0 comments on commit 79d9a6f

Please sign in to comment.