Skip to content

Commit ab8df25

Browse files
Backport "Discard poly-functions when trying to resolve overloading" to LTS (#21076)
Backports #20181 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 114be22 + 1021ffd commit ab8df25

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-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
@@ -2214,13 +2214,13 @@ trait Applications extends Compatibility {
22142214
case _ => (Nil, 0)
22152215

22162216
/** Resolve overloading by mapping to a different problem where each alternative's
2217-
* type is mapped with `f`, alternatives with non-existing types are dropped, and the
2217+
* type is mapped with `f`, alternatives with non-existing types or symbols are dropped, and the
22182218
* expected type is `pt`. Map the results back to the original alternatives.
22192219
*/
22202220
def resolveMapped(alts: List[TermRef], f: TermRef => Type, pt: Type)(using Context): List[TermRef] =
22212221
val reverseMapping = alts.flatMap { alt =>
22222222
val t = f(alt)
2223-
if t.exists then
2223+
if t.exists && alt.symbol.exists then
22242224
val (trimmed, skipped) = trimParamss(t.stripPoly, alt.symbol.rawParamss)
22252225
val mappedSym = alt.symbol.asTerm.copy(info = t)
22262226
mappedSym.rawParamss = trimmed

tests/pos/i20176.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
type Accumulator[A]
2+
3+
object Accumulator {
4+
5+
val usage =
6+
use[Int]:
7+
"asd"
8+
9+
inline def use[A](using DummyImplicit): [B] => Any => Any = ???
10+
11+
inline def use[A]: [B] => Any => Any = ???
12+
}

0 commit comments

Comments
 (0)