Disabled super functions checking on error types.
This commit is contained in:
+38
-5
@@ -38,10 +38,7 @@ import org.jetbrains.jet.lang.resolve.java.provider.NamedMembers;
|
|||||||
import org.jetbrains.jet.lang.resolve.java.provider.PsiDeclarationProvider;
|
import org.jetbrains.jet.lang.resolve.java.provider.PsiDeclarationProvider;
|
||||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiMethodWrapper;
|
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiMethodWrapper;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
import org.jetbrains.jet.lang.types.SubstitutionUtils;
|
|
||||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
|
||||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
|
||||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
|
|
||||||
@@ -197,7 +194,9 @@ public final class JavaFunctionResolver {
|
|||||||
throw new IllegalStateException("non-static method in subclass");
|
throw new IllegalStateException("non-static method in subclass");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RawTypesCheck.hasRawTypesInHierarchicalSignature(psiMethod) && JavaMethodSignatureUtil.isMethodReturnTypeCompatible(psiMethod)) {
|
if (!RawTypesCheck.hasRawTypesInHierarchicalSignature(psiMethod)
|
||||||
|
&& JavaMethodSignatureUtil.isMethodReturnTypeCompatible(psiMethod)
|
||||||
|
&& !containsErrorType(superFunctions, functionDescriptorImpl)) {
|
||||||
if (signatureErrors.isEmpty()) {
|
if (signatureErrors.isEmpty()) {
|
||||||
checkFunctionsOverrideCorrectly(method, superFunctions, functionDescriptorImpl);
|
checkFunctionsOverrideCorrectly(method, superFunctions, functionDescriptorImpl);
|
||||||
}
|
}
|
||||||
@@ -364,4 +363,38 @@ public final class JavaFunctionResolver {
|
|||||||
}
|
}
|
||||||
return (methodName.equals("values") && methodTypeParameters.isEmpty());
|
return (methodName.equals("values") && methodTypeParameters.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean containsErrorType(@NotNull List<FunctionDescriptor> superFunctions, @NotNull FunctionDescriptor function) {
|
||||||
|
if (containsErrorType(function)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (FunctionDescriptor superFunction : superFunctions) {
|
||||||
|
if (containsErrorType(superFunction)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean containsErrorType(@NotNull FunctionDescriptor function) {
|
||||||
|
if (ErrorUtils.containsErrorType(function.getReturnType())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (ValueParameterDescriptor parameter : function.getValueParameters()) {
|
||||||
|
if (ErrorUtils.containsErrorType(parameter.getType())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (TypeParameterDescriptor parameter : function.getTypeParameters()) {
|
||||||
|
for (JetType upperBound : parameter.getUpperBounds()) {
|
||||||
|
if (ErrorUtils.containsErrorType(upperBound)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -112,6 +112,17 @@ public class MemberComparator implements Comparator<DeclarationDescriptor> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return c1TypeParameters.size() - c2TypeParameters.size();
|
int typeParametersCompareTo = c1TypeParameters.size() - c2TypeParameters.size();
|
||||||
|
if (typeParametersCompareTo != 0) {
|
||||||
|
return typeParametersCompareTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c1 instanceof CallableMemberDescriptor && c2 instanceof CallableMemberDescriptor) {
|
||||||
|
CallableMemberDescriptor.Kind c1Kind = ((CallableMemberDescriptor) c1).getKind();
|
||||||
|
CallableMemberDescriptor.Kind c2Kind = ((CallableMemberDescriptor) c2).getKind();
|
||||||
|
return c1Kind.ordinal() - c2Kind.ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
public trait ErrorTypes : java.lang.Object {
|
||||||
|
|
||||||
|
public trait Sub : test.ErrorTypes.Super {
|
||||||
|
public abstract fun errorTypeInParameter(/*0*/ list : jet.List<jet.Array<[ERROR : Unresolved java class: T]>?>?) : Unit
|
||||||
|
public abstract override /*1*/ /*fake_override*/ fun errorTypeInParameter(/*0*/ list : jet.List<jet.Array<[ERROR : Unresolved java class: T]>?>?) : Unit
|
||||||
|
public abstract override /*1*/ fun returnErrorType() : [ERROR : Unresolved java class: T]
|
||||||
|
}
|
||||||
|
|
||||||
|
public trait Super : java.lang.Object {
|
||||||
|
public abstract fun errorTypeInParameter(/*0*/ list : jet.List<jet.Array<[ERROR : Unresolved java class: T]>?>?) : Unit
|
||||||
|
public abstract fun returnErrorType() : [ERROR : Unresolved java class: T]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ErrorTypes {
|
||||||
|
interface Super {
|
||||||
|
void errorTypeInParameter(List<T[]> list);
|
||||||
|
|
||||||
|
T returnErrorType();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Sub extends Super {
|
||||||
|
void errorTypeInParameter(List<T[]> list);
|
||||||
|
|
||||||
|
T returnErrorType();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -187,9 +187,9 @@ public final class LoadJavaCustomTest extends KotlinTestWithEnvironment {
|
|||||||
doTestNoCompile(dir + "ReturnNotSubtype.txt", dir);
|
doTestNoCompile(dir + "ReturnNotSubtype.txt", dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWrongNumberOfGenericParameters() throws Exception {
|
public void testErrorTypes() throws Exception {
|
||||||
String dir = PATH + "/errors/";
|
String dir = PATH + "/errorTypes/";
|
||||||
doTestNoCompile(dir + "WrongNumberOfGenericParameters.txt", dir);
|
doTestNoCompile(dir + "ErrorTypes.txt", dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SubclassingKotlinInJavaTest extends KotlinTestWithEnvironmentManagement {
|
public static class SubclassingKotlinInJavaTest extends KotlinTestWithEnvironmentManagement {
|
||||||
|
|||||||
Reference in New Issue
Block a user