8000 [Bug]: LocalVariableReference does not link to declaration within Type Pattern · Issue #6318 · INRIA/spoon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Bug]: LocalVariableReference does not link to declaration within Type Pattern #6318
Open
@MaxAtoms

Description

@MaxAtoms

Describe the bug

I recently noticed that when using Refactoring.changeLocalVariableName(...) on a LocalVariable declared in a Type Pattern, references will not be renamed.
I suspect this is because the LocalVariableReferences are not linked to the declaration.

Image

Source code you are trying to analyze/transform

public class SomeOtherClass extends SomeClass{ }

public class SomeClass {
    public void someMethod(SomeClass someParameter) {
        SomeOtherClass b;
        if (someParameter instanceof SomeOtherClass i) {
            b = i;
        }
    }
}

Source code for your Spoon processing

Actual output

`getDeclaration()` returns `null`

Expected output

The `CtLocalVariableReference` should link to the CtLocalVariable declaration under the TypePattern

Spoon Version

a9bf1eb

JVM Version

openjdk 24.0.1 2025-04-15

What operating system are you using?

Arch Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0