Skip to content

Inconsistent renaming when LVT entries clash #501

@PiTheGuy

Description

@PiTheGuy

Vineflower version

1.11.1

Describe the bug

Conflicting LVT's within inner classes can cause variable references to reference the wrong variable

Additional information

in.jar.zip

The JAR file enclosed in the above zip generates the following code when decompiled:

public class Util {
   public static <T, R> Function<T, R> memoize(final Function<T, R> $$0) {
      return new Function<T, R>() {
         private final Map<T, R> cache = new ConcurrentHashMap<>();

         @Override
         public R apply(T $$0x) {
            return this.cache.computeIfAbsent($$0, $$0);
         }
      };
   }
}

The first parameter to computeIfAbsent should be $$0x (the apply parameter), not $$0 (the function parameter in the enclosing method). The parameter's name in the LVT for the apply method is $$0, but because it conflicted with an outside variable, Vineflower renamed it to $$0x, but it didn't rename it's usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: MediumMedium prioritySubsystem: VariablesAnything concerning variables, types, assignments, and castingType: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions