What is the smallest, simplest way to reproduce the problem?
No guarantee on completeness of imports 😄
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertTrue;
class A {
class MyLang { MyLang(String l){} Locale asLocale(){return null;}}
@Test
void regressionAsLocaleShouldStay() {
MyLang underTest = new MyLang("he");
Set<Locale> localeSet = new HashSet<>();
assertTrue(localeSet.contains(underTest.asLocale()));
}
}
What did you expect to see?
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
class A {
class MyLang { MyLang(String l){} Locale asLocale(){return null;}}
@Test
void regressionAsLocaleShouldStay() {
MyLang underTest = new MyLang("he");
Set<Locale> localeSet = new HashSet<>();
assertThat(localeSet).contains(underTest.asLocale());
}
}
What did you see instead?
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
class A {
class MyLang { MyLang(String l){} Locale asLocale(){return null;}}
@Test
void regressionAsLocaleShouldStay() {
MyLang underTest = new MyLang("he");
Set<Locale> localeSet = new HashSet<>();
assertThat(localeSet).contains(underTest);
}
}
Comment
In a nutshell: the asLocale call on my custom class is erroneously dropped.
I suppose the asLocale can be skipped for some jdk class but that the recipe does not check for this type
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a multi module project.
What is the smallest, simplest way to reproduce the problem?
No guarantee on completeness of imports 😄
What did you expect to see?
What did you see instead?
Comment
In a nutshell: the
asLocale
call on my custom class is erroneously dropped. I suppose theasLocale
can be skipped for some jdk class but that the recipe does not check for this type