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