mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
guava type migration: fix stack overflow when lambda implements guava & java function EA-92353
This commit is contained in:
+3
@@ -69,6 +69,9 @@ public enum GuavaLambda {
|
||||
if (aClass == null) return null;
|
||||
for (GuavaLambda lambda : values()) {
|
||||
if (InheritanceUtil.isInheritor(aClass, lambda.getClassQName())) {
|
||||
if (PREDICATE != lambda && InheritanceUtil.isInheritor(aClass, lambda.getJavaAnalogueClassQName())) {
|
||||
return null;
|
||||
}
|
||||
return lambda;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,6 +293,10 @@ public class GuavaInspectionTest extends JavaCodeInsightFixtureTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLambdaImplementsBothInterfaces() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTestNoQuickFixes(Class<? extends PsiElement>... highlightedElements) {
|
||||
myFixture.configureByFile(getTestName(true) + ".java");
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
class Test {
|
||||
public interface HasCode {
|
||||
String getCode();
|
||||
}
|
||||
|
||||
public enum GetCode implements com.google.common.base.Function<HasCode, String>, java.util.function.Function<HasCode, String> {
|
||||
FUNC;
|
||||
|
||||
@Override
|
||||
public String apply(HasCode e) {
|
||||
return e.getCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Set<String> getRegionCodeList(Set<HasCode> regions) {
|
||||
return FluentIterable.f<caret>rom(regions).transform(GetCode.FUNC::apply).toSet();
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Test {
|
||||
public interface HasCode {
|
||||
String getCode();
|
||||
}
|
||||
|
||||
public enum GetCode implements Function<HasCode, String>, java.util.function.Function<HasCode, String> {
|
||||
FUNC;
|
||||
|
||||
@Override
|
||||
public String apply(HasCode e) {
|
||||
return e.getCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Set<String> getRegionCodeList(Set<HasCode> regions) {
|
||||
return regions.stream().map(GetCode.FUNC).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user