Skip to content

Commit

Permalink
Set the type on J.Identifier to null if it resolves to J.Unknown.
Browse files Browse the repository at this point in the history
  • Loading branch information
traceyyoshima committed Nov 30, 2023
1 parent 2500034 commit 6d3188b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3430,7 +3430,7 @@ private J.Identifier createIdentifier(String name, Space prefix,
Markers.EMPTY,
emptyList(),
name,
type,
type instanceof JavaType.Unknown ? null : type,
fieldType
);
}
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/org/openrewrite/kotlin/KotlinTypeMappingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,27 @@ class A : RemoteStub()
);
}

@Test
void unknownIdentifier() {
rewriteRun(
kotlin(
//language=none
"class A : RemoteStub",
spec -> spec.afterRecipe(cu -> {
new KotlinIsoVisitor<Integer>() {
@Override
public J.Identifier visitIdentifier(J.Identifier identifier, Integer integer) {
if ("RemoteStub".equals(identifier.getSimpleName())) {
assertThat(identifier.getType()).isNull();
}
return super.visitIdentifier(identifier, integer);
}
}.visit(cu, 0);
})
)
);
}

@Issue("https://github.com/openrewrite/rewrite-kotlin/issues/461")
@Test
void multipleBounds() {
Expand Down

0 comments on commit 6d3188b

Please sign in to comment.