diff --git a/compiler/src/dotty/tools/dotc/transform/Erasure.scala b/compiler/src/dotty/tools/dotc/transform/Erasure.scala index c743e757b8b4..cef21af23683 100644 --- a/compiler/src/dotty/tools/dotc/transform/Erasure.scala +++ b/compiler/src/dotty/tools/dotc/transform/Erasure.scala @@ -483,8 +483,13 @@ object Erasure { def sameClass(tp1: Type, tp2: Type) = tp1.classSymbol == tp2.classSymbol val paramAdaptationNeeded = - implParamTypes.lazyZip(samParamTypes).exists((implType, samType) => - !sameClass(implType, samType) && !autoAdaptedParam(implType)) + implParamTypes.lazyZip(samParamTypes).exists: (implType, samType) => + !sameClass(implType, samType) && !autoAdaptedParam(implType) + || (samType, implType).match { + case (defn.ArrayOf(_), defn.ArrayOf(_)) => false + case (defn.ArrayOf(_), _) => true // see #23179 + case _ => false + } val resultAdaptationNeeded = !sameClass(implResultType, samResultType) && !autoAdaptedResult diff --git a/tests/run/i23179.scala b/tests/run/i23179.scala new file mode 100644 index 000000000000..4085e56a03ea --- /dev/null +++ b/tests/run/i23179.scala @@ -0,0 +1,8 @@ +object Test { + trait A { def f(a: Array[AnyRef]): Any } + def g(a: A) = a.f(Array.empty[AnyRef]) + + def main(args: Array[String]): Unit = { + g((x: Array[? >: AnyRef]) => x.headOption) + } +}