From 4cea282d8153cd96cc1b5261ac3ddfb166b34b9f Mon Sep 17 00:00:00 2001 From: odersky Date: Sun, 14 Apr 2024 13:38:25 +0200 Subject: [PATCH] Discard poly-functions when trying to resolve overloading Discard poly-functions when trying to resolve overloading using subsequent parameter lists. Polyfunctions don't have a symbol, so the logic of remapping arguments does not work for them. --- .../src/dotty/tools/dotc/typer/Applications.scala | 4 ++-- tests/pos/i20176.scala | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 tests/pos/i20176.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index abe69d36cb69..184b250e94fb 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -2267,13 +2267,13 @@ trait Applications extends Compatibility { case _ => (Nil, 0) /** Resolve overloading by mapping to a different problem where each alternative's - * type is mapped with `f`, alternatives with non-existing types are dropped, and the + * type is mapped with `f`, alternatives with non-existing types or symbols are dropped, and the * expected type is `pt`. Map the results back to the original alternatives. */ def resolveMapped(alts: List[TermRef], f: TermRef => Type, pt: Type)(using Context): List[TermRef] = val reverseMapping = alts.flatMap { alt => val t = f(alt) - if t.exists then + if t.exists && alt.symbol.exists then val (trimmed, skipped) = trimParamss(t.stripPoly, alt.symbol.rawParamss) val mappedSym = alt.symbol.asTerm.copy(info = t) mappedSym.rawParamss = trimmed diff --git a/tests/pos/i20176.scala b/tests/pos/i20176.scala new file mode 100644 index 000000000000..df0c6cc1e8a7 --- /dev/null +++ b/tests/pos/i20176.scala @@ -0,0 +1,12 @@ +type Accumulator[A] + +object Accumulator { + + val usage = + use[Int]: + "asd" + + inline def use[A](using DummyImplicit): [B] => Any => Any = ??? + + inline def use[A]: [B] => Any => Any = ??? +}