Skip to content

Conversation

timtebeek
Copy link
Member

@timtebeek timtebeek self-assigned this Dec 15, 2024
@timtebeek timtebeek added the recipe Recipe requested label Dec 15, 2024
@timtebeek timtebeek changed the title Add explicit imports for record classes past Java 14+ Add explicit imports for Record classes past Java 14+ Dec 15, 2024
@timtebeek timtebeek merged commit 17de874 into main Dec 15, 2024
2 checks passed
@timtebeek timtebeek deleted the add-explicit-imports-for-record-classes branch December 15, 2024 16:13
@BramliAK
Copy link
Contributor

hello @timtebeek
i think we must add this test

@Test
    void addImportFromSamePackage2() {
        rewriteRun(
          //language=java
          java(
            """
              package com.acme.music;

              import com.acme.music.*;

              public class Test {
                  Record record;
              }
              """,
            """
              package com.acme.music;

              import com.acme.music.*;
              import com.acme.music.Record;

              public class Test {
                  Record record;
              }
              """
          )
        );
    }

to force Record implementation.
What do you think ?
if we must add it, just i will update this block https://github.com/openrewrite/rewrite/blob/601fec7db38de41e05d1cb75a2b86a6963574c2f/rewrite-java/src/main/java/org/openrewrite/java/AddImport.java#L125C17-L130C71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recipe Recipe requested

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add explicit imports to avoid conflicts with classes added to java.lang, like Record

2 participants