Revert "Suppress "nothing to override" on equals, hashCode, toString"

This reverts commit 640dac834f.
This commit is contained in:
Alexander Udalov
2014-03-02 21:38:25 +04:00
parent bd80e325b3
commit afc3d33576
@@ -534,34 +534,12 @@ public class OverrideResolver {
if (invisibleOverriddenDescriptor != null) {
reportError.cannotOverrideInvisibleMember(invisibleOverriddenDescriptor);
}
else if (!shouldSuppressOverride(declared)) {
else {
reportError.nothingToOverride();
}
}
}
// TODO: this is temporary to migrate equals, hashCode, toString from extensions to Any
private static boolean shouldSuppressOverride(@NotNull CallableMemberDescriptor descriptor) {
String name = descriptor.getName().asString();
JetType returnType = descriptor.getReturnType();
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
if (name.equals("equals") && builtIns.getBooleanType().equals(returnType)) {
List<ValueParameterDescriptor> parameters = descriptor.getValueParameters();
return parameters.size() == 1 && builtIns.isAnyOrNullableAny(parameters.iterator().next().getType());
}
if (name.equals("hashCode") && builtIns.getIntType().equals(returnType)) {
return descriptor.getValueParameters().isEmpty();
}
if (name.equals("toString") && builtIns.getStringType().equals(returnType)) {
return descriptor.getValueParameters().isEmpty();
}
return false;
}
private void checkOverrideForComponentFunction(@NotNull final CallableMemberDescriptor componentFunction) {
final JetAnnotationEntry dataAnnotation = findDataAnnotationForDataClass(componentFunction.getContainingDeclaration());