@@ -1514,13 +1514,18 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
15141514 assert(tree.hasType, tree)
15151515 val qual1 = typed(tree.qualifier, shallowSelectionProto(tree.name, pt, this ))
15161516 val resNoReduce = untpd.cpy.Select (tree)(qual1, tree.name).withType(tree.typeOpt)
1517- val resMaybeReduced = constToLiteral(reducer.reduceProjection(resNoReduce))
1518- if (resNoReduce ne resMaybeReduced)
1519- typed(resMaybeReduced, pt) // redo typecheck if reduction changed something
1517+ val reducedProjection = reducer.reduceProjection(resNoReduce)
1518+ if reducedProjection.isType then
1519+ // if the projection leads to a typed tree then we stop reduction
1520+ resNoReduce
15201521 else
1521- val res = resMaybeReduced
1522- ensureAccessible(res.tpe, tree.qualifier.isInstanceOf [untpd.Super ], tree.srcPos)
1523- inlineIfNeeded(res)
1522+ val resMaybeReduced = constToLiteral(reducedProjection)
1523+ if resNoReduce ne resMaybeReduced then
1524+ typed(resMaybeReduced, pt) // redo typecheck if reduction changed something
1525+ else
1526+ val res = resMaybeReduced
1527+ ensureAccessible(res.tpe, tree.qualifier.isInstanceOf [untpd.Super ], tree.srcPos)
1528+ inlineIfNeeded(res)
15241529 }
15251530
15261531 override def typedIf (tree : untpd.If , pt : Type )(using Context ): Tree =
0 commit comments