Skip to content

Fix init of RemoveInstanceOfPatternMatch - #1044

Merged
greg-at-moderne merged 1 commit into
mainfrom
greg-instanceof-pattern-kotlin-npe
Sep 2, 2026
Merged

Fix init of RemoveInstanceOfPatternMatch#1044
greg-at-moderne merged 1 commit into
mainfrom
greg-instanceof-pattern-kotlin-npe

Conversation

@greg-at-moderne

@greg-at-moderne greg-at-moderne commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What's changed?

Fix the initialization of internal data structures in RemoveInstanceOfPatternMatch.

What's your motivation?

Fixing NPE observed for some non-Java sources as they "follow" Java visitors, but visitCompilationUnit(J.CompilationUnit) is never called for them:

Cannot read field "conditions" because "this.variableUsage" is null
Detail:

java.lang.NullPointerException: Cannot read field "conditions" because "this.variableUsage" is null
  org.openrewrite.staticanalysis.RemoveInstanceOfPatternMatch$RemoveInstanceOfPatternMatchVisitor.visitIdentifier(RemoveInstanceOfPatternMatch.java:99)
  org.openrewrite.staticanalysis.RemoveInstanceOfPatternMatch$RemoveInstanceOfPatternMatchVisitor.visitIdentifier(RemoveInstanceOfPatternMatch.java:63)
  org.openrewrite.staticanalysis.RemoveInstanceOfPatternMatch_RemoveInstanceOfPatternMatchVisitor_KotlinVisitor.visitIdentifier(RemoveInstanceOfPatternMatch_RemoveInstanceOfPatternMatchVisitor_KotlinVisitor.zig:119)

@greg-at-moderne greg-at-moderne self-assigned this Sep 1, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Sep 1, 2026
@greg-at-moderne
greg-at-moderne marked this pull request as ready for review September 2, 2026 07:59
@greg-at-moderne
greg-at-moderne merged commit 82ce337 into main Sep 2, 2026
1 check passed
@greg-at-moderne
greg-at-moderne deleted the greg-instanceof-pattern-kotlin-npe branch September 2, 2026 07:59
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant