If interface method has generic parameters, interface is not functional.
This commit is contained in:
+7
-2
@@ -42,7 +42,13 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
List<CallableMemberDescriptor> abstractMembers = getAbstractMembers(klass);
|
||||
return abstractMembers.size() == 1 && abstractMembers.get(0) instanceof SimpleFunctionDescriptor;
|
||||
if (abstractMembers.size() == 1) {
|
||||
CallableMemberDescriptor member = abstractMembers.get(0);
|
||||
if (member instanceof SimpleFunctionDescriptor) {
|
||||
return member.getTypeParameters().isEmpty();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -58,7 +64,6 @@ public class SingleAbstractMethodUtils {
|
||||
|
||||
@NotNull
|
||||
private static JetType getFunctionalTypeForFunction(@NotNull FunctionDescriptor function) {
|
||||
// TODO substitute type parameters of function with star projections
|
||||
JetType returnType = function.getReturnType();
|
||||
assert returnType != null : "function is not initialized: " + function;
|
||||
List<JetType> parameterTypes = Lists.newArrayList();
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GenericMethodParameters {
|
||||
<A extends CharSequence, B extends List<A>> void method(A[] a, B b);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
public trait GenericMethodParameters : java.lang.Object {
|
||||
public abstract fun </*0*/ A : jet.CharSequence?, /*1*/ B : jet.List<A>?> method(/*0*/ p0 : jet.Array<out A>?, /*1*/ p1 : B?) : jet.Unit
|
||||
}
|
||||
@@ -1140,6 +1140,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/singleAbstractMethod/FilenameFilter.java");
|
||||
}
|
||||
|
||||
@TestMetadata("GenericMethodParameters.java")
|
||||
public void testGenericMethodParameters() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericMethodParameters.java");
|
||||
}
|
||||
|
||||
@TestMetadata("InterfaceWithObjectMethod.java")
|
||||
public void testInterfaceWithObjectMethod() throws Exception {
|
||||
doTestCompiledJava("compiler/testData/loadJava/compiledJava/singleAbstractMethod/InterfaceWithObjectMethod.java");
|
||||
|
||||
Reference in New Issue
Block a user