Skip to content

Commit 79d9a6f

Browse files
authored
Merge pull request #15636 from griggt/fix-13668
Merge nested polytypes in more cases in resolveOverloaded
2 parents 11d65aa + 49af4fb commit 79d9a6f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/Applications.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ trait Applications extends Compatibility {
14661466
case mt: MethodType if mt.isImplicitMethod =>
14671467
stripImplicit(resultTypeApprox(mt))
14681468
case pt: PolyType =>
1469-
pt.derivedLambdaType(pt.paramNames, pt.paramInfos, stripImplicit(pt.resultType))
1469+
pt.derivedLambdaType(pt.paramNames, pt.paramInfos, stripImplicit(pt.resultType)).asInstanceOf[PolyType].flatten
14701470
case _ =>
14711471
tp
14721472
}
@@ -1520,7 +1520,7 @@ trait Applications extends Compatibility {
15201520
else compareOwner(cls1, sym2)
15211521
else 0
15221522

1523-
/** Compare to alternatives of an overloaded call or an implicit search.
1523+
/** Compare two alternatives of an overloaded call or an implicit search.
15241524
*
15251525
* @param alt1, alt2 Non-overloaded references indicating the two choices
15261526
* @return 1 if 1st alternative is preferred over 2nd

Diff for: tests/pos/i11713.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extension [T1](x: T1)(using Numeric[T1])
2+
def combine[T2](y: T2)(using Numeric[T2]) = ???
3+
def combine(y: String) = ???
4+
5+
val res = 100.combine(200)

Diff for: tests/pos/i13668.scala

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class MyType()
2+
trait Candidate[R]
3+
given Candidate[MyType] with {}
4+
class Fuzzy[W]()
5+
class Fuzzy1()
6+
class Bear()
7+
8+
extension [L](lhs: L)(using Candidate[L])
9+
def +[RW](rhs: Fuzzy[RW]): Unit = {}
10+
def +(rhs: Bear): Unit = {}
11+
def -(rhs: Fuzzy1): Unit = {}
12+
def -(rhs: Bear): Unit = {}
13+
14+
val works = MyType() - Fuzzy1()
15+
val fails = MyType() + Fuzzy[1]()

0 commit comments

Comments
 (0)