Skip to content

Commit c80d3ad

Browse files
Fix dependent3.scala
1 parent ee42662 commit c80d3ad

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,21 +377,25 @@ trait TypeAssigner {
377377
}
378378

379379
def assignType(tree: untpd.Apply, fn: Tree, args: List[Tree])(implicit ctx: Context): Apply = {
380+
val inTypeOf = !ctx.erasedTypes && (fn.symbol.isDependentMethod || ctx.isDependent)
380381
val ownType = fn.tpe.widen match {
381382
case fntpe: MethodType =>
382383
if (sameLength(fntpe.paramInfos, args) || ctx.phase.prev.relaxedTyping) {
383384
val tpe =
384385
if (fntpe.isResultDependent) safeSubstParams(fntpe.resultType, fntpe.paramRefs, args.tpes)
385386
else fntpe.resultType
386-
if (!ctx.erasedTypes && (fn.symbol.isDependentMethod || ctx.isDependent))
387+
if (inTypeOf)
387388
ctx.normalizedType(TypeOf(tpe, tree))
388389
else tpe
389390
} else
390391
errorType(i"wrong number of arguments at ${ctx.phase.prev} for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.sourcePos)
391392
case t =>
392393
errorType(err.takesNoParamsStr(fn, ""), tree.sourcePos)
393394
}
394-
ConstFold(tree.withType(ownType))
395+
if (inTypeOf)
396+
tree.withType(ownType)
397+
else
398+
ConstFold(tree.withType(ownType))
395399
}
396400

397401
def assignType(tree: untpd.TypeApply, fn: Tree, args: List[Tree])(implicit ctx: Context): TypeApply = {

0 commit comments

Comments
 (0)