diff --git a/compiler/src/dotty/tools/dotc/transform/ElimByName.scala b/compiler/src/dotty/tools/dotc/transform/ElimByName.scala index 151e841f0e48..587403caebc3 100644 --- a/compiler/src/dotty/tools/dotc/transform/ElimByName.scala +++ b/compiler/src/dotty/tools/dotc/transform/ElimByName.scala @@ -60,7 +60,7 @@ class ElimByName extends MiniPhase, InfoTransformer: override def description: String = ElimByName.description override def runsAfterGroupsOf: Set[String] = Set(ExpandSAMs.name, ElimRepeated.name, RefChecks.name) - // - ExpanSAMs applied to partial functions creates methods that need + // - ExpandSAMs applied to partial functions creates methods that need // to be fully defined before converting. Test case is pos/i9391.scala. // - ElimByName needs to run in a group after ElimRepeated since ElimRepeated // works on simple arguments but not converted closures, and it sees the arguments @@ -147,7 +147,7 @@ class ElimByName extends MiniPhase, InfoTransformer: case _ => arg - val mt @ MethodType(_) = tree.fun.tpe.widen: @unchecked + val mt @ MethodType(_) = transformInfo(tree.fun.tpe.widen, tree.fun.symbol): @unchecked val args1 = tree.args.zipWithConserve(mt.paramInfos)(transformArg) cpy.Apply(tree)(tree.fun, args1) } diff --git a/compiler/src/dotty/tools/dotc/transform/SpecializeFunctions.scala b/compiler/src/dotty/tools/dotc/transform/SpecializeFunctions.scala index c50eaddd3213..6308c7cc0889 100644 --- a/compiler/src/dotty/tools/dotc/transform/SpecializeFunctions.scala +++ b/compiler/src/dotty/tools/dotc/transform/SpecializeFunctions.scala @@ -71,7 +71,8 @@ class SpecializeFunctions extends MiniPhase { override def transformApply(tree: Apply)(using Context) = tree match { case Apply(fun: NameTree, args) if fun.name == nme.apply && args.size <= 3 && fun.symbol.maybeOwner.isType => - val argTypes = fun.tpe.widen.firstParamTypes.map(_.widenSingleton.dealias) + val info = (new ElimByName).transformInfo(fun.tpe.widen, fun.symbol) + val argTypes = info.firstParamTypes.map(_.widenSingleton.dealias) val retType = tree.tpe.widenSingleton.dealias val isSpecializable = defn.isSpecializableFunction( diff --git a/compiler/test-resources/repl/i18756 b/compiler/test-resources/repl/i18756 new file mode 100644 index 000000000000..722c665999b6 --- /dev/null +++ b/compiler/test-resources/repl/i18756 @@ -0,0 +1,5 @@ +scala> def f: ( => Int) => Int = i => i ; f(1) +def f: (=> Int) => Int +val res0: Int = 1 +scala> f(1) +val res1: Int = 1