Confusion between vals and funs fixed
This commit is contained in:
@@ -171,48 +171,48 @@ public class OverrideResolver {
|
||||
nameIdentifier = ((JetObjectDeclaration) klass).getNameIdentifier();
|
||||
}
|
||||
|
||||
// for (CallableMemberDescriptor memberDescriptor : manyImpl) {
|
||||
// context.getTrace().report(MANY_IMPL_MEMBER_NOT_IMPLEMENTED.on(nameIdentifier, klass, memberDescriptor));
|
||||
// break;
|
||||
// }
|
||||
for (CallableMemberDescriptor memberDescriptor : manyImpl) {
|
||||
context.getTrace().report(MANY_IMPL_MEMBER_NOT_IMPLEMENTED.on(nameIdentifier, klass, memberDescriptor));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (classDescriptor.getModality() == Modality.ABSTRACT) {
|
||||
return;
|
||||
}
|
||||
|
||||
// for (CallableMemberDescriptor memberDescriptor : abstractNoImpl) {
|
||||
// context.getTrace().report(ABSTRACT_MEMBER_NOT_IMPLEMENTED.on(nameIdentifier, klass, memberDescriptor));
|
||||
// break;
|
||||
// }
|
||||
for (CallableMemberDescriptor memberDescriptor : abstractNoImpl) {
|
||||
context.getTrace().report(ABSTRACT_MEMBER_NOT_IMPLEMENTED.on(nameIdentifier, klass, memberDescriptor));
|
||||
break;
|
||||
}
|
||||
|
||||
Set<FunctionDescriptor> allOverriddenFunctions = Sets.newHashSet();
|
||||
Collection<DeclarationDescriptor> allDescriptors = classDescriptor.getDefaultType().getMemberScope().getAllDescriptors();
|
||||
for (DeclarationDescriptor descriptor : allDescriptors) {
|
||||
if (descriptor instanceof FunctionDescriptor) {
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
if (functionDescriptor.getModality() != Modality.ABSTRACT) {
|
||||
for (FunctionDescriptor overriddenDescriptor : functionDescriptor.getOverriddenDescriptors()) {
|
||||
allOverriddenFunctions.add(overriddenDescriptor.getOriginal());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean foundError = false;
|
||||
for (DeclarationDescriptor descriptor : allDescriptors) {
|
||||
if (descriptor instanceof FunctionDescriptor) {
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
if (functionDescriptor.getModality() == Modality.ABSTRACT && !allOverriddenFunctions.contains(functionDescriptor.getOriginal()) && !foundError && nameIdentifier != null) {
|
||||
DeclarationDescriptor declarationDescriptor = functionDescriptor.getContainingDeclaration();
|
||||
if (declarationDescriptor != classDescriptor) {
|
||||
// context.getTrace().getErrorHandler().genericError(nameIdentifier.getNode(), "Class '" + klass.getName() + "' must be declared abstract or implement abstract method '" +
|
||||
// functionDescriptor.getName() + "' declared in " + declarationDescriptor.getName());
|
||||
context.getTrace().report(ABSTRACT_MEMBER_NOT_IMPLEMENTED.on(nameIdentifier, klass, functionDescriptor));
|
||||
foundError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Set<FunctionDescriptor> allOverriddenFunctions = Sets.newHashSet();
|
||||
// Collection<DeclarationDescriptor> allDescriptors = classDescriptor.getDefaultType().getMemberScope().getAllDescriptors();
|
||||
// for (DeclarationDescriptor descriptor : allDescriptors) {
|
||||
// if (descriptor instanceof FunctionDescriptor) {
|
||||
// FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
// if (functionDescriptor.getModality() != Modality.ABSTRACT) {
|
||||
// for (FunctionDescriptor overriddenDescriptor : functionDescriptor.getOverriddenDescriptors()) {
|
||||
// allOverriddenFunctions.add(overriddenDescriptor.getOriginal());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// boolean foundError = false;
|
||||
// for (DeclarationDescriptor descriptor : allDescriptors) {
|
||||
// if (descriptor instanceof FunctionDescriptor) {
|
||||
// FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
// if (functionDescriptor.getModality() == Modality.ABSTRACT && !allOverriddenFunctions.contains(functionDescriptor.getOriginal()) && !foundError && nameIdentifier != null) {
|
||||
// DeclarationDescriptor declarationDescriptor = functionDescriptor.getContainingDeclaration();
|
||||
// if (declarationDescriptor != classDescriptor) {
|
||||
//// context.getTrace().getErrorHandler().genericError(nameIdentifier.getNode(), "Class '" + klass.getName() + "' must be declared abstract or implement abstract method '" +
|
||||
//// functionDescriptor.getName() + "' declared in " + declarationDescriptor.getName());
|
||||
// context.getTrace().report(ABSTRACT_MEMBER_NOT_IMPLEMENTED.on(nameIdentifier, klass, functionDescriptor));
|
||||
// foundError = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private void checkOverride(CallableMemberDescriptor declared) {
|
||||
|
||||
@@ -85,6 +85,12 @@ public class OverridingUtil {
|
||||
|
||||
@NotNull
|
||||
public static OverrideCompatibilityInfo isOverridableBy(@NotNull CallableDescriptor superDescriptor, @NotNull CallableDescriptor subDescriptor) {
|
||||
if (superDescriptor instanceof FunctionDescriptor) {
|
||||
if (subDescriptor instanceof PropertyDescriptor) return OverrideCompatibilityInfo.memberKindMismatch();
|
||||
}
|
||||
if (superDescriptor instanceof PropertyDescriptor) {
|
||||
if (subDescriptor instanceof FunctionDescriptor) return OverrideCompatibilityInfo.memberKindMismatch();
|
||||
}
|
||||
if (!superDescriptor.getName().equals(subDescriptor.getName())) {
|
||||
return OverrideCompatibilityInfo.nameMismatch();
|
||||
}
|
||||
@@ -192,6 +198,11 @@ public class OverridingUtil {
|
||||
return new OverrideCompatibilityInfo(false, "valueParameterTypeMismatch"); // TODO
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static OverrideCompatibilityInfo memberKindMismatch() {
|
||||
return new OverrideCompatibilityInfo(false, "memberKindMismatch"); // TODO
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static OverrideCompatibilityInfo returnTypeMismatch(JetType substitutedSuperReturnType, JetType unsubstitutedSubReturnType) {
|
||||
return new OverrideCompatibilityInfo(true, "returnTypeMismatch: " + unsubstitutedSubReturnType + " >< " + substitutedSuperReturnType); // TODO
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class Foo1() : java.util.ArrayList<Int>()
|
||||
|
||||
open class Bar() {
|
||||
fun v() : Int = 1
|
||||
val v : Int = 1
|
||||
}
|
||||
|
||||
class Barr() : Bar() {}
|
||||
Reference in New Issue
Block a user