guava type migration: fix stack overflow when lambda implements guava & java function EA-92353

This commit is contained in:
Dmitry Batkovich
2017-01-20 11:52:41 +03:00
parent 7b3e65b2ad
commit be230d90bf
4 changed files with 54 additions and 0 deletions
@@ -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();
}
}
@@ -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());
}
}