@@ -1514,13 +1514,18 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
1514
1514
assert(tree.hasType, tree)
1515
1515
val qual1 = typed(tree.qualifier, shallowSelectionProto(tree.name, pt, this ))
1516
1516
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
1520
1521
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)
1524
1529
}
1525
1530
1526
1531
override def typedIf (tree : untpd.If , pt : Type )(using Context ): Tree =
0 commit comments