Skip to content

Commit

Permalink
Avoid eagerly calculating scope.getClosestHoistScope() in property co…
Browse files Browse the repository at this point in the history
…llapsing

PiperOrigin-RevId: 704754433
  • Loading branch information
lauraharker authored and copybara-github committed Dec 10, 2024
1 parent 54f9f2f commit 6f54038
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,15 @@ private void inlineAliases(GlobalNamespace namespace) {
private void inlineAliasesForName(Name name, GlobalNamespace namespace) {
List<Ref> refs = new ArrayList<>(name.getRefs());
for (Ref ref : refs) {
Scope hoistScope = ref.scope.getClosestHoistScope();
if (ref.isAliasingGet() && !mayBeGlobalAlias(ref) && !ref.isTwin()) {
// {@code name} meets condition (c). Try to inline it.
// TODO(johnlenz): consider picking up new aliases at the end
// of the pass instead of immediately like we do for global
// inlines.
inlineAliasIfPossible(name, ref, namespace);
} else if (ref.isAliasingGet() && hoistScope.isGlobal() && !ref.isTwin()) {
} else if (ref.isAliasingGet()
&& ref.scope.getClosestHoistScope().isGlobal()
&& !ref.isTwin()) {
inlineGlobalAliasIfPossible(name, ref, namespace);
} else if (name.isClass() && ref.isSubclassingGet() && name.props != null) {
for (Name prop : name.props) {
Expand Down

0 comments on commit 6f54038

Please sign in to comment.