Skip to content

Commit 0f8d801

Browse files
committed
Avoid creation of Type lists when assigning types to Apply nodes
1 parent e59e751 commit 0f8d801

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,14 @@ trait TypeAssigner {
279279

280280
def safeSubstMethodParams(mt: MethodType, argTypes: List[Type])(using Context): Type =
281281
if mt.isResultDependent then safeSubstParams(mt.resultType, mt.paramRefs, argTypes)
282-
else if mt.isCaptureDependent then mt.resultType.substParams(mt, argTypes)
283282
else mt.resultType
284283

285284
def assignType(tree: untpd.Apply, fn: Tree, args: List[Tree])(using Context): Apply = {
286285
val ownType = fn.tpe.widen match {
287286
case fntpe: MethodType =>
288-
if (fntpe.paramInfos.hasSameLengthAs(args) || ctx.phase.prev.relaxedTyping)
289-
safeSubstMethodParams(fntpe, args.tpes)
287+
if fntpe.paramInfos.hasSameLengthAs(args) || ctx.phase.prev.relaxedTyping then
288+
if fntpe.isResultDependent then safeSubstMethodParams(fntpe, args.tpes)
289+
else fntpe.resultType // fast path optimization
290290
else
291291
errorType(em"wrong number of arguments at ${ctx.phase.prev} for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.srcPos)
292292
case t =>

0 commit comments

Comments
 (0)