Skip to content

Commit 6a7681f

Browse files
oderskynicolasstucki
authored andcommitted
Merge multiple parameter lists in resolveOverloaded
Resolve overloaded does an applicability test which can make use of only a single type parameter list. When going deeper into several alternatives that contain a common prefex we might uncover other type parameter lists. These need to be merged.
1 parent a27ffeb commit 6a7681f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ trait Applications extends Compatibility {
19031903
def skip(tp: Type): Type = tp match {
19041904
case tp: PolyType =>
19051905
val rt = skip(tp.resultType)
1906-
if (rt.exists) tp.derivedLambdaType(resType = rt) else rt
1906+
if rt.exists then tp.derivedLambdaType(resType = rt).asInstanceOf[PolyType].flatten else rt
19071907
case tp: MethodType =>
19081908
tp.instantiate(argTypes)
19091909
case _ =>
@@ -1974,7 +1974,7 @@ trait Applications extends Compatibility {
19741974
None
19751975
}
19761976
val mapped = reverseMapping.map(_._1)
1977-
overload.println(i"resolve mapped: $mapped")
1977+
overload.println(i"resolve mapped: ${mapped.map(_.widen)}%, % with $pt")
19781978
resolveOverloaded(mapped, pt).map(reverseMapping.toMap)
19791979

19801980
/** Try to typecheck any arguments in `pt` that are function values missing a

tests/pos/i11358.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Test:
2+
3+
def test1: IArray[Int] = IArray(1, 2) +++ IArray(2, 3)
4+
def test2: IArray[Int] = IArray(1, 2) +++ List(2, 3)
5+
6+
extension [A: reflect.ClassTag](arr: IArray[A])
7+
def +++[B >: A: reflect.ClassTag](suffix: IArray[B]): IArray[B] = ???
8+
def +++[B >: A: reflect.ClassTag](suffix: IterableOnce[B]): IArray[B] = ???

0 commit comments

Comments
 (0)