KT-1141 No check that object in 'object expression' implements all abstract members of supertype
This commit is contained in:
@@ -401,10 +401,14 @@ public interface Errors {
|
|||||||
|
|
||||||
ParameterizedDiagnosticFactory2<PropertyDescriptor, PropertyDescriptor> VAR_OVERRIDDEN_BY_VAL = new ParameterizedDiagnosticFactory2<PropertyDescriptor, PropertyDescriptor>(ERROR, "Var-property {0} cannot be overridden by val-property {1}", DescriptorRenderer.TEXT);
|
ParameterizedDiagnosticFactory2<PropertyDescriptor, PropertyDescriptor> VAR_OVERRIDDEN_BY_VAL = new ParameterizedDiagnosticFactory2<PropertyDescriptor, PropertyDescriptor>(ERROR, "Var-property {0} cannot be overridden by val-property {1}", DescriptorRenderer.TEXT);
|
||||||
|
|
||||||
ParameterizedDiagnosticFactory2<JetClassOrObject, CallableMemberDescriptor> ABSTRACT_MEMBER_NOT_IMPLEMENTED = new ParameterizedDiagnosticFactory2<JetClassOrObject, CallableMemberDescriptor>(ERROR, "Class ''{0}'' must be declared abstract or implement abstract member {1}") {
|
ParameterizedDiagnosticFactory2<JetClassOrObject, CallableMemberDescriptor> ABSTRACT_MEMBER_NOT_IMPLEMENTED = new ParameterizedDiagnosticFactory2<JetClassOrObject, CallableMemberDescriptor>(ERROR, "{0} must be declared abstract or implement abstract member {1}") {
|
||||||
@Override
|
@Override
|
||||||
protected String makeMessageForA(@NotNull JetClassOrObject jetClassOrObject) {
|
protected String makeMessageForA(@NotNull JetClassOrObject jetClassOrObject) {
|
||||||
return JetPsiUtil.safeName(jetClassOrObject.getName());
|
String name = jetClassOrObject.getName() != null ? " '" + jetClassOrObject.getName() + "'" : "";
|
||||||
|
if (jetClassOrObject instanceof JetClass) {
|
||||||
|
return "Class" + name;
|
||||||
|
}
|
||||||
|
return "Object" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.jetbrains.annotations.NonNls;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.JetNodeTypes;
|
import org.jetbrains.jet.JetNodeTypes;
|
||||||
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -96,4 +97,9 @@ public class JetObjectDeclaration extends JetNamedDeclaration implements JetClas
|
|||||||
public boolean isObjectLiteral() {
|
public boolean isObjectLiteral() {
|
||||||
return getNameAsDeclaration() == null;
|
return getNameAsDeclaration() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public PsiElement getObjectKeyword() {
|
||||||
|
return findChildByType(JetTokens.OBJECT_KEYWORD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ public class OverrideResolver {
|
|||||||
}
|
}
|
||||||
else if (klass instanceof JetObjectDeclaration) {
|
else if (klass instanceof JetObjectDeclaration) {
|
||||||
nameIdentifier = ((JetObjectDeclaration) klass).getNameIdentifier();
|
nameIdentifier = ((JetObjectDeclaration) klass).getNameIdentifier();
|
||||||
|
if (nameIdentifier == null) {
|
||||||
|
nameIdentifier = ((JetObjectDeclaration) klass).getObjectKeyword();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (nameIdentifier == null) return;
|
if (nameIdentifier == null) return;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ fun box() : String {
|
|||||||
val l2 = o2?.length ?: 0
|
val l2 = o2?.length ?: 0
|
||||||
return l1 - l2
|
return l1 - l2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(obj: Any?): Boolean = obj === this
|
||||||
}
|
}
|
||||||
|
|
||||||
w.compare("aaa", "bbb")
|
w.compare("aaa", "bbb")
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
//KT-1141 No check that object in 'object expression' implements all abstract members of supertype
|
||||||
|
//+JDK
|
||||||
|
|
||||||
|
package kt1141
|
||||||
|
|
||||||
|
public trait SomeTrait {
|
||||||
|
fun foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
val x = <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>object<!> : SomeTrait {
|
||||||
|
}
|
||||||
|
x.foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
object <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>Rr<!> : SomeTrait {}
|
||||||
|
|
||||||
|
class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>C<!> : SomeTrait {}
|
||||||
|
|
||||||
|
fun foo2() {
|
||||||
|
val <!UNUSED_VARIABLE!>r<!> = <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>object<!> : Runnable {} //no error
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user