Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types on J.FieldAccess aren't completely accurate #381

Open
traceyyoshima opened this issue Nov 10, 2023 · 0 comments
Open

Types on J.FieldAccess aren't completely accurate #381

traceyyoshima opened this issue Nov 10, 2023 · 0 comments
Assignees
Labels
bug Something isn't working parser-kotlin

Comments

@traceyyoshima
Copy link
Contributor

traceyyoshima commented Nov 10, 2023

Comparing the types from the Java compiler with the PSI-based parser shows incorrect type attribution:

class A {
    public Integer id = 0;
}
class B extends A {
    Integer getId() {
        return super.id;
    }
}

J.FieldAccess#type: JavaType.Class with signature: java.lang.Integer
J.FieldAccess#target#type: JavaType.Class with signature: A
J.FieldAccess#target#fieldType: JavaType.Variable with signature: B{name=super,type=A}

open class A {
    val id: Int = 0
}
class B : A() {
    fun get(): Int {
        return super.id
    }
}

J.FieldAccess#type: JavaType.Class with signature: kotlin.int
J.FieldAccess#target#type: JavaType.Class with signature: A
J.FieldAccess#target#fieldType: null

The issue is caused by visitSimpleNameExpression not having context to the necessary types and might cause incorrect types in many other places. We don't test the type of every identifier, which might be necessary now that we've switched to the PSI. This issue might not exist in the IR, but we'd need to check.

@timtebeek timtebeek added the bug Something isn't working label Nov 11, 2023
@timtebeek timtebeek moved this to Backlog in OpenRewrite Nov 11, 2023
@traceyyoshima traceyyoshima self-assigned this Nov 28, 2023
@traceyyoshima traceyyoshima moved this from Backlog to In Progress in OpenRewrite Nov 28, 2023
@traceyyoshima traceyyoshima moved this from In Progress to Backlog in OpenRewrite Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser-kotlin
Projects
Status: Backlog
Development

No branches or pull requests

2 participants