@@ -1504,13 +1504,18 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
15041504 assert(tree.hasType, tree)
15051505 val qual1 = typed(tree.qualifier, shallowSelectionProto(tree.name, pt, this ))
15061506 val resNoReduce = untpd.cpy.Select (tree)(qual1, tree.name).withType(tree.typeOpt)
1507- val resMaybeReduced = constToLiteral(reducer.reduceProjection(resNoReduce))
1508- if (resNoReduce ne resMaybeReduced)
1509- typed(resMaybeReduced, pt) // redo typecheck if reduction changed something
1507+ val reducedProjection = reducer.reduceProjection(resNoReduce)
1508+ if (reducedProjection.isType)
1509+ // in case the projection leads to a typed tree, then there is nothing to reduce
1510+ resNoReduce
15101511 else
1511- val res = resMaybeReduced
1512- ensureAccessible(res.tpe, tree.qualifier.isInstanceOf [untpd.Super ], tree.srcPos)
1513- inlineIfNeeded(res)
1512+ val resMaybeReduced = constToLiteral(reducedProjection)
1513+ if (resNoReduce ne resMaybeReduced)
1514+ typed(resMaybeReduced, pt) // redo typecheck if reduction changed something
1515+ else
1516+ val res = resMaybeReduced
1517+ ensureAccessible(res.tpe, tree.qualifier.isInstanceOf [untpd.Super ], tree.srcPos)
1518+ inlineIfNeeded(res)
15141519 }
15151520
15161521 override def typedIf (tree : untpd.If , pt : Type )(using Context ): Tree =
0 commit comments