TRAIT -> INTERFACE in diagnostics

This commit is contained in:
Andrey Breslav
2015-10-09 16:02:10 +03:00
parent ff1bf673ba
commit a2e5e60c68
38 changed files with 110 additions and 111 deletions
@@ -114,7 +114,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
public void addSupertype(@NotNull JetType supertype) { public void addSupertype(@NotNull JetType supertype) {
assert !supertype.isError() : "Error types must be filtered out in DescriptorResolver"; assert !supertype.isError() : "Error types must be filtered out in DescriptorResolver";
if (TypeUtils.getClassDescriptor(supertype) != null) { if (TypeUtils.getClassDescriptor(supertype) != null) {
// See the Errors.SUPERTYPE_NOT_A_CLASS_OR_TRAIT // See the Errors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE
supertypes.add(supertype); supertypes.add(supertype);
} }
} }
@@ -55,7 +55,7 @@ public class NativeFunChecker : DeclarationChecker {
if (!descriptor.hasNativeAnnotation()) return if (!descriptor.hasNativeAnnotation()) return
if (DescriptorUtils.isInterface(descriptor.getContainingDeclaration())) { if (DescriptorUtils.isInterface(descriptor.getContainingDeclaration())) {
diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_IN_TRAIT.on(declaration)) diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_IN_INTERFACE.on(declaration))
} }
else if (descriptor is CallableMemberDescriptor && else if (descriptor is CallableMemberDescriptor &&
descriptor.getModality() == Modality.ABSTRACT) { descriptor.getModality() == Modality.ABSTRACT) {
@@ -42,7 +42,7 @@ public class TraitDefaultMethodCallChecker : CallChecker {
if (classifier != null && DescriptorUtils.isInterface(classifier)) { if (classifier != null && DescriptorUtils.isInterface(classifier)) {
context.trace.report( context.trace.report(
ErrorsJvm.TRAIT_CANT_CALL_DEFAULT_METHOD_VIA_SUPER.on( ErrorsJvm.INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER.on(
PsiTreeUtil.getParentOfType(resolvedCall.getCall().getCallElement(), javaClass<JetExpression>()) PsiTreeUtil.getParentOfType(resolvedCall.getCall().getCallElement(), javaClass<JetExpression>())
) )
) )
@@ -55,7 +55,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
MAP.put(ErrorsJvm.ILLEGAL_JVM_NAME, "Illegal JVM name"); MAP.put(ErrorsJvm.ILLEGAL_JVM_NAME, "Illegal JVM name");
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT, "External declaration can not be abstract"); MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT, "External declaration can not be abstract");
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_HAVE_BODY, "External declaration can not have a body"); MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_HAVE_BODY, "External declaration can not have a body");
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_IN_TRAIT, "Members of interfaces can not be external"); MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_IN_INTERFACE, "Members of interfaces can not be external");
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_INLINED, "Members of interfaces can not be external"); MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_INLINED, "Members of interfaces can not be external");
MAP.put(ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION, "Only named arguments are available for Java annotations"); MAP.put(ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION, "Only named arguments are available for Java annotations");
@@ -70,7 +70,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
MAP.put(ErrorsJvm.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, MAP.put(ErrorsJvm.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS,
"Expected type does not accept nulls in {0}, but the value may be null in {1}", Renderers.TO_STRING, Renderers.TO_STRING); "Expected type does not accept nulls in {0}, but the value may be null in {1}", Renderers.TO_STRING, Renderers.TO_STRING);
MAP.put(ErrorsJvm.TRAIT_CANT_CALL_DEFAULT_METHOD_VIA_SUPER, "Interfaces can't call Java default methods via super"); MAP.put(ErrorsJvm.INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER, "Interfaces can't call Java default methods via super");
MAP.put(ErrorsJvm.WHEN_ENUM_CAN_BE_NULL_IN_JAVA, "Enum argument can be null in Java, but exhaustive when contains no null branch"); MAP.put(ErrorsJvm.WHEN_ENUM_CAN_BE_NULL_IN_JAVA, "Enum argument can be null in Java, but exhaustive when contains no null branch");
@@ -54,7 +54,7 @@ public interface ErrorsJvm {
DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER); DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER);
DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_CANNOT_HAVE_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_CANNOT_HAVE_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_IN_TRAIT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_CANNOT_BE_INLINED = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_CANNOT_BE_INLINED = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
DiagnosticFactory0<JetExpression> POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetExpression> POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION = DiagnosticFactory0.create(ERROR);
@@ -63,7 +63,7 @@ public interface ErrorsJvm {
DiagnosticFactory0<JetAnnotationEntry> NON_SOURCE_REPEATED_ANNOTATION = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetAnnotationEntry> NON_SOURCE_REPEATED_ANNOTATION = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<JetAnnotationEntry, FqName> ANNOTATION_IS_NOT_APPLICABLE_TO_MULTIFILE_CLASSES = DiagnosticFactory1.create(ERROR); DiagnosticFactory1<JetAnnotationEntry, FqName> ANNOTATION_IS_NOT_APPLICABLE_TO_MULTIFILE_CLASSES = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0<JetElement> TRAIT_CANT_CALL_DEFAULT_METHOD_VIA_SUPER = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetElement> INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetElement> INAPPLICABLE_PUBLIC_FIELD = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetElement> INAPPLICABLE_PUBLIC_FIELD = DiagnosticFactory0.create(ERROR);
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.diagnostics;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiIdentifier;
import com.intellij.psi.impl.source.tree.LeafPsiElement; import com.intellij.psi.impl.source.tree.LeafPsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.*;
@@ -87,7 +86,7 @@ public interface Errors {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Errors/warnings in types // Errors/warnings in types
// Note: class/trait declaration is NOT a type. A type is something that may be written on the right-hand side of ":" // Note: class/interface declaration is NOT a type. A type is something that may be written on the right-hand side of ":"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -162,7 +161,7 @@ public interface Errors {
DiagnosticFactory0<PsiElement> INAPPLICABLE_PARAM_TARGET = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<PsiElement> INAPPLICABLE_PARAM_TARGET = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<PsiElement, String> REDUNDANT_ANNOTATION_TARGET = DiagnosticFactory1.create(WARNING); DiagnosticFactory1<PsiElement, String> REDUNDANT_ANNOTATION_TARGET = DiagnosticFactory1.create(WARNING);
// Classes and traits // Classes and interfaces
DiagnosticFactory0<JetTypeProjection> PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE = DiagnosticFactory0<JetTypeProjection> PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE =
DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION); DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION);
@@ -171,8 +170,8 @@ public interface Errors {
DiagnosticFactory0<JetDelegatorToSuperClass> SUPERTYPE_NOT_INITIALIZED = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetDelegatorToSuperClass> SUPERTYPE_NOT_INITIALIZED = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetTypeReference> DELEGATION_NOT_TO_TRAIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetTypeReference> DELEGATION_NOT_TO_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetTypeReference> SUPERTYPE_NOT_A_CLASS_OR_TRAIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetTypeReference> SUPERTYPE_NOT_A_CLASS_OR_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> NO_GENERICS_IN_SUPERTYPE_SPECIFIER = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<PsiElement> NO_GENERICS_IN_SUPERTYPE_SPECIFIER = DiagnosticFactory0.create(ERROR);
@@ -211,19 +210,19 @@ public interface Errors {
DiagnosticFactory1<PsiElement, DeclarationDescriptor> INSTANCE_ACCESS_BEFORE_SUPER_CALL = DiagnosticFactory1.create(ERROR); DiagnosticFactory1<PsiElement, DeclarationDescriptor> INSTANCE_ACCESS_BEFORE_SUPER_CALL = DiagnosticFactory1.create(ERROR);
// Trait-specific // Interface-specific
DiagnosticFactory0<JetModifierListOwner> ABSTRACT_MODIFIER_IN_TRAIT = DiagnosticFactory0 DiagnosticFactory0<JetModifierListOwner> ABSTRACT_MODIFIER_IN_INTERFACE = DiagnosticFactory0
.create(WARNING, ABSTRACT_MODIFIER); .create(WARNING, ABSTRACT_MODIFIER);
DiagnosticFactory0<JetDeclaration> CONSTRUCTOR_IN_TRAIT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0<JetDeclaration> CONSTRUCTOR_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
DiagnosticFactory0<JetDeclaration> METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetDeclaration> METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> SUPERTYPE_INITIALIZED_IN_TRAIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<PsiElement> SUPERTYPE_INITIALIZED_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetDelegatorByExpressionSpecifier> DELEGATION_IN_TRAIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetDelegatorByExpressionSpecifier> DELEGATION_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> TRAIT_WITH_SUPERCLASS = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<PsiElement> INTERFACE_WITH_SUPERCLASS = DiagnosticFactory0.create(ERROR);
// Enum-specific // Enum-specific
@@ -339,7 +338,7 @@ public interface Errors {
DiagnosticFactory0<JetPropertyDelegate> ABSTRACT_DELEGATED_PROPERTY = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetPropertyDelegate> ABSTRACT_DELEGATED_PROPERTY = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetPropertyAccessor> ACCESSOR_FOR_DELEGATED_PROPERTY = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetPropertyAccessor> ACCESSOR_FOR_DELEGATED_PROPERTY = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetPropertyDelegate> DELEGATED_PROPERTY_IN_TRAIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetPropertyDelegate> DELEGATED_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetPropertyDelegate> LOCAL_VARIABLE_WITH_DELEGATE = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetPropertyDelegate> LOCAL_VARIABLE_WITH_DELEGATE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetProperty> PROPERTY_WITH_NO_TYPE_NO_INITIALIZER = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0<JetProperty> PROPERTY_WITH_NO_TYPE_NO_INITIALIZER = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
@@ -349,10 +348,10 @@ public interface Errors {
DiagnosticFactory0<JetExpression> EXTENSION_PROPERTY_WITH_BACKING_FIELD = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetExpression> EXTENSION_PROPERTY_WITH_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetExpression> PROPERTY_INITIALIZER_NO_BACKING_FIELD = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetExpression> PROPERTY_INITIALIZER_NO_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetExpression> PROPERTY_INITIALIZER_IN_TRAIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetExpression> PROPERTY_INITIALIZER_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetProperty> FINAL_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, FINAL_MODIFIER); DiagnosticFactory0<JetProperty> FINAL_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, FINAL_MODIFIER);
DiagnosticFactory0<JetProperty> PRIVATE_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, PRIVATE_MODIFIER); DiagnosticFactory0<JetProperty> PRIVATE_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, PRIVATE_MODIFIER);
DiagnosticFactory0<JetProperty> BACKING_FIELD_IN_TRAIT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0<JetProperty> BACKING_FIELD_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
DiagnosticFactory0<JetSimpleNameExpression> BACKING_FIELD_OLD_SYNTAX = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetSimpleNameExpression> BACKING_FIELD_OLD_SYNTAX = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetSimpleNameExpression> BACKING_FIELD_USAGE_FORBIDDEN = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetSimpleNameExpression> BACKING_FIELD_USAGE_FORBIDDEN = DiagnosticFactory0.create(ERROR);
@@ -514,7 +513,7 @@ public interface Errors {
DiagnosticFactory1<JetSuperExpression, String> SUPER_IS_NOT_AN_EXPRESSION = DiagnosticFactory1.create(ERROR); DiagnosticFactory1<JetSuperExpression, String> SUPER_IS_NOT_AN_EXPRESSION = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<JetSuperExpression, String> SUPER_CANT_BE_EXTENSION_RECEIVER = DiagnosticFactory1.create(ERROR); DiagnosticFactory1<JetSuperExpression, String> SUPER_CANT_BE_EXTENSION_RECEIVER = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0<JetSuperExpression> SUPER_NOT_AVAILABLE = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetSuperExpression> SUPER_NOT_AVAILABLE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetSuperExpression> SUPERCLASS_NOT_ACCESSIBLE_FROM_TRAIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetSuperExpression> SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetSuperExpression> AMBIGUOUS_SUPER = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetSuperExpression> AMBIGUOUS_SUPER = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetExpression> ABSTRACT_SUPER_CALL = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetExpression> ABSTRACT_SUPER_CALL = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetTypeReference> NOT_A_SUPERTYPE = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetTypeReference> NOT_A_SUPERTYPE = DiagnosticFactory0.create(ERROR);
@@ -715,7 +714,7 @@ public interface Errors {
DiagnosticFactory0<JetDeclarationWithBody> DiagnosticFactory0<JetDeclarationWithBody>
NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_WITH_BODY); NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_WITH_BODY);
DiagnosticFactory0<JetClassInitializer> ANONYMOUS_INITIALIZER_IN_TRAIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetClassInitializer> ANONYMOUS_INITIALIZER_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetThisExpression> NO_THIS = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetThisExpression> NO_THIS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetRootPackageExpression> PACKAGE_IS_NOT_AN_EXPRESSION = DiagnosticFactory0.create(ERROR); DiagnosticFactory0<JetRootPackageExpression> PACKAGE_IS_NOT_AN_EXPRESSION = DiagnosticFactory0.create(ERROR);
@@ -145,7 +145,7 @@ public class DefaultErrorMessages {
MAP.put(REDUNDANT_ANNOTATION_TARGET, "Redundant annotation target ''{0}''", STRING); MAP.put(REDUNDANT_ANNOTATION_TARGET, "Redundant annotation target ''{0}''", STRING);
MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING); MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING);
MAP.put(ABSTRACT_MODIFIER_IN_TRAIT, "Modifier ''abstract'' is redundant in interface"); MAP.put(ABSTRACT_MODIFIER_IN_INTERFACE, "Modifier ''abstract'' is redundant in interface");
MAP.put(REDUNDANT_MODIFIER_IN_GETTER, "Visibility modifiers are redundant in getter"); MAP.put(REDUNDANT_MODIFIER_IN_GETTER, "Visibility modifiers are redundant in getter");
MAP.put(TYPE_PARAMETERS_IN_ENUM, "Enum class cannot have type parameters"); MAP.put(TYPE_PARAMETERS_IN_ENUM, "Enum class cannot have type parameters");
MAP.put(TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM, MAP.put(TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM,
@@ -210,7 +210,7 @@ public class DefaultErrorMessages {
MAP.put(ABSTRACT_DELEGATED_PROPERTY, "Delegated property cannot be abstract"); MAP.put(ABSTRACT_DELEGATED_PROPERTY, "Delegated property cannot be abstract");
MAP.put(ACCESSOR_FOR_DELEGATED_PROPERTY, "Delegated property cannot have accessors with non-default implementations"); MAP.put(ACCESSOR_FOR_DELEGATED_PROPERTY, "Delegated property cannot have accessors with non-default implementations");
MAP.put(DELEGATED_PROPERTY_IN_TRAIT, "Delegated properties are not allowed in interfaces"); MAP.put(DELEGATED_PROPERTY_IN_INTERFACE, "Delegated properties are not allowed in interfaces");
MAP.put(LOCAL_VARIABLE_WITH_DELEGATE, "Local variables are not allowed to have delegates"); MAP.put(LOCAL_VARIABLE_WITH_DELEGATE, "Local variables are not allowed to have delegates");
MAP.put(INAPPLICABLE_LATEINIT_MODIFIER, "''lateinit'' modifier is allowed only on member properties with a backing field"); MAP.put(INAPPLICABLE_LATEINIT_MODIFIER, "''lateinit'' modifier is allowed only on member properties with a backing field");
@@ -222,10 +222,10 @@ public class DefaultErrorMessages {
MAP.put(GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY, "Getter visibility must be the same as property visibility"); MAP.put(GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY, "Getter visibility must be the same as property visibility");
MAP.put(PRIVATE_SETTER_ON_NON_PRIVATE_LATE_INIT_VAR, "Private setter is not allowed on non-private lateinit property"); MAP.put(PRIVATE_SETTER_ON_NON_PRIVATE_LATE_INIT_VAR, "Private setter is not allowed on non-private lateinit property");
MAP.put(BACKING_FIELD_IN_TRAIT, "Property in an interface cannot have a backing field"); MAP.put(BACKING_FIELD_IN_INTERFACE, "Property in an interface cannot have a backing field");
MAP.put(MUST_BE_INITIALIZED, "Property must be initialized"); MAP.put(MUST_BE_INITIALIZED, "Property must be initialized");
MAP.put(MUST_BE_INITIALIZED_OR_BE_ABSTRACT, "Property must be initialized or be abstract"); MAP.put(MUST_BE_INITIALIZED_OR_BE_ABSTRACT, "Property must be initialized or be abstract");
MAP.put(PROPERTY_INITIALIZER_IN_TRAIT, "Property initializers are not allowed in interfaces"); MAP.put(PROPERTY_INITIALIZER_IN_INTERFACE, "Property initializers are not allowed in interfaces");
MAP.put(FINAL_PROPERTY_IN_INTERFACE, "Abstract property in an interface cannot be final"); MAP.put(FINAL_PROPERTY_IN_INTERFACE, "Abstract property in an interface cannot be final");
MAP.put(PRIVATE_PROPERTY_IN_INTERFACE, "Abstract property in an interface cannot be private"); MAP.put(PRIVATE_PROPERTY_IN_INTERFACE, "Abstract property in an interface cannot be private");
MAP.put(EXTENSION_PROPERTY_WITH_BACKING_FIELD, "Extension property cannot be initialized because it has no backing field"); MAP.put(EXTENSION_PROPERTY_WITH_BACKING_FIELD, "Extension property cannot be initialized because it has no backing field");
@@ -297,8 +297,8 @@ public class DefaultErrorMessages {
MAP.put(ENUM_CLASS_CONSTRUCTOR_CALL, "Enum types cannot be instantiated"); MAP.put(ENUM_CLASS_CONSTRUCTOR_CALL, "Enum types cannot be instantiated");
MAP.put(SEALED_CLASS_CONSTRUCTOR_CALL, "Sealed types cannot be instantiated"); MAP.put(SEALED_CLASS_CONSTRUCTOR_CALL, "Sealed types cannot be instantiated");
MAP.put(DELEGATION_IN_TRAIT, "Interfaces cannot use delegation"); MAP.put(DELEGATION_IN_INTERFACE, "Interfaces cannot use delegation");
MAP.put(DELEGATION_NOT_TO_TRAIT, "Only interfaces can be delegated to"); MAP.put(DELEGATION_NOT_TO_INTERFACE, "Only interfaces can be delegated to");
MAP.put(NO_CONSTRUCTOR, "This class does not have a constructor"); MAP.put(NO_CONSTRUCTOR, "This class does not have a constructor");
MAP.put(NOT_A_CLASS, "Not a class"); MAP.put(NOT_A_CLASS, "Not a class");
MAP.put(ILLEGAL_ESCAPE_SEQUENCE, "Illegal escape sequence"); MAP.put(ILLEGAL_ESCAPE_SEQUENCE, "Illegal escape sequence");
@@ -327,7 +327,7 @@ public class DefaultErrorMessages {
MAP.put(SETTER_PARAMETER_WITH_DEFAULT_VALUE, "Setter parameters cannot have default values"); MAP.put(SETTER_PARAMETER_WITH_DEFAULT_VALUE, "Setter parameters cannot have default values");
MAP.put(NO_THIS, "'this' is not defined in this context"); MAP.put(NO_THIS, "'this' is not defined in this context");
MAP.put(SUPER_NOT_AVAILABLE, "No supertypes are accessible in this context"); MAP.put(SUPER_NOT_AVAILABLE, "No supertypes are accessible in this context");
MAP.put(SUPERCLASS_NOT_ACCESSIBLE_FROM_TRAIT, "Superclass is not accessible from interface"); MAP.put(SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE, "Superclass is not accessible from interface");
MAP.put(AMBIGUOUS_SUPER, "Many supertypes available, please specify the one you mean in angle brackets, e.g. 'super<Foo>'"); MAP.put(AMBIGUOUS_SUPER, "Many supertypes available, please specify the one you mean in angle brackets, e.g. 'super<Foo>'");
MAP.put(ABSTRACT_SUPER_CALL, "Abstract member cannot be accessed directly"); MAP.put(ABSTRACT_SUPER_CALL, "Abstract member cannot be accessed directly");
MAP.put(NOT_A_SUPERTYPE, "Not a supertype"); MAP.put(NOT_A_SUPERTYPE, "Not a supertype");
@@ -435,12 +435,12 @@ public class DefaultErrorMessages {
MAP.put(CYCLIC_GENERIC_UPPER_BOUND, "Type parameter has itself as an upper bound"); MAP.put(CYCLIC_GENERIC_UPPER_BOUND, "Type parameter has itself as an upper bound");
MAP.put(MANY_CLASSES_IN_SUPERTYPE_LIST, "Only one class may appear in a supertype list"); MAP.put(MANY_CLASSES_IN_SUPERTYPE_LIST, "Only one class may appear in a supertype list");
MAP.put(SUPERTYPE_NOT_A_CLASS_OR_TRAIT, "Only classes and interfaces may serve as supertypes"); MAP.put(SUPERTYPE_NOT_A_CLASS_OR_INTERFACE, "Only classes and interfaces may serve as supertypes");
MAP.put(SUPERTYPE_INITIALIZED_IN_TRAIT, "Interfaces cannot initialize supertypes"); MAP.put(SUPERTYPE_INITIALIZED_IN_INTERFACE, "Interfaces cannot initialize supertypes");
MAP.put(CLASS_IN_SUPERTYPE_FOR_ENUM, "Enum class cannot inherit from classes"); MAP.put(CLASS_IN_SUPERTYPE_FOR_ENUM, "Enum class cannot inherit from classes");
MAP.put(CONSTRUCTOR_IN_TRAIT, "An interface may not have a constructor"); MAP.put(CONSTRUCTOR_IN_INTERFACE, "An interface may not have a constructor");
MAP.put(METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE, "An interface may not implement a method of 'kotlin.Any'"); MAP.put(METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE, "An interface may not implement a method of 'kotlin.Any'");
MAP.put(TRAIT_WITH_SUPERCLASS, "An interface cannot inherit from a class"); MAP.put(INTERFACE_WITH_SUPERCLASS, "An interface cannot inherit from a class");
MAP.put(SUPERTYPE_APPEARS_TWICE, "A supertype appears twice"); MAP.put(SUPERTYPE_APPEARS_TWICE, "A supertype appears twice");
MAP.put(FINAL_SUPERTYPE, "This type is final, so it cannot be inherited from"); MAP.put(FINAL_SUPERTYPE, "This type is final, so it cannot be inherited from");
MAP.put(DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES, "Data class inheritance from other classes is deprecated"); MAP.put(DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES, "Data class inheritance from other classes is deprecated");
@@ -471,7 +471,7 @@ public class DefaultErrorMessages {
MAP.put(NOT_A_LOOP_LABEL, "The label ''{0}'' does not denote a loop", STRING); MAP.put(NOT_A_LOOP_LABEL, "The label ''{0}'' does not denote a loop", STRING);
MAP.put(NOT_A_RETURN_LABEL, "The label ''{0}'' does not reference to a context from which we can return", STRING); MAP.put(NOT_A_RETURN_LABEL, "The label ''{0}'' does not reference to a context from which we can return", STRING);
MAP.put(ANONYMOUS_INITIALIZER_IN_TRAIT, "Anonymous initializers are not allowed in interfaces"); MAP.put(ANONYMOUS_INITIALIZER_IN_INTERFACE, "Anonymous initializers are not allowed in interfaces");
MAP.put(NULLABLE_SUPERTYPE, "A supertype cannot be nullable"); MAP.put(NULLABLE_SUPERTYPE, "A supertype cannot be nullable");
MAP.put(DYNAMIC_SUPERTYPE, "A supertype cannot be dynamic"); MAP.put(DYNAMIC_SUPERTYPE, "A supertype cannot be dynamic");
MAP.put(REDUNDANT_NULLABLE, "Redundant '?'"); MAP.put(REDUNDANT_NULLABLE, "Redundant '?'");
@@ -271,7 +271,7 @@ public class BodyResolver {
@Override @Override
public void visitDelegationByExpressionSpecifier(@NotNull JetDelegatorByExpressionSpecifier specifier) { public void visitDelegationByExpressionSpecifier(@NotNull JetDelegatorByExpressionSpecifier specifier) {
if (descriptor.getKind() == ClassKind.INTERFACE) { if (descriptor.getKind() == ClassKind.INTERFACE) {
trace.report(DELEGATION_IN_TRAIT.on(specifier)); trace.report(DELEGATION_IN_INTERFACE.on(specifier));
} }
JetType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference()); JetType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
recordSupertype(specifier.getTypeReference(), supertype); recordSupertype(specifier.getTypeReference(), supertype);
@@ -280,7 +280,7 @@ public class BodyResolver {
if (declarationDescriptor instanceof ClassDescriptor) { if (declarationDescriptor instanceof ClassDescriptor) {
ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor; ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor;
if (classDescriptor.getKind() != ClassKind.INTERFACE) { if (classDescriptor.getKind() != ClassKind.INTERFACE) {
trace.report(DELEGATION_NOT_TO_TRAIT.on(specifier.getTypeReference())); trace.report(DELEGATION_NOT_TO_INTERFACE.on(specifier.getTypeReference()));
} }
} }
} }
@@ -300,7 +300,7 @@ public class BodyResolver {
JetValueArgumentList valueArgumentList = call.getValueArgumentList(); JetValueArgumentList valueArgumentList = call.getValueArgumentList();
PsiElement elementToMark = valueArgumentList == null ? call : valueArgumentList; PsiElement elementToMark = valueArgumentList == null ? call : valueArgumentList;
if (descriptor.getKind() == ClassKind.INTERFACE) { if (descriptor.getKind() == ClassKind.INTERFACE) {
trace.report(SUPERTYPE_INITIALIZED_IN_TRAIT.on(elementToMark)); trace.report(SUPERTYPE_INITIALIZED_IN_INTERFACE.on(elementToMark));
} }
JetTypeReference typeReference = call.getTypeReference(); JetTypeReference typeReference = call.getTypeReference();
if (typeReference == null) return; if (typeReference == null) return;
@@ -440,7 +440,7 @@ public class BodyResolver {
} }
else if (supertypeOwner.getKind() == ClassKind.INTERFACE && else if (supertypeOwner.getKind() == ClassKind.INTERFACE &&
!classAppeared && !TypesPackage.isDynamic(supertype) /* avoid duplicate diagnostics */) { !classAppeared && !TypesPackage.isDynamic(supertype) /* avoid duplicate diagnostics */) {
trace.report(TRAIT_WITH_SUPERCLASS.on(typeReference)); trace.report(INTERFACE_WITH_SUPERCLASS.on(typeReference));
addSupertype = false; addSupertype = false;
} }
else if (jetClass.hasModifier(JetTokens.DATA_KEYWORD)) { else if (jetClass.hasModifier(JetTokens.DATA_KEYWORD)) {
@@ -457,7 +457,7 @@ public class BodyResolver {
} }
} }
else { else {
trace.report(SUPERTYPE_NOT_A_CLASS_OR_TRAIT.on(typeReference)); trace.report(SUPERTYPE_NOT_A_CLASS_OR_INTERFACE.on(typeReference));
} }
TypeConstructor constructor = supertype.getConstructor(); TypeConstructor constructor = supertype.getConstructor();
@@ -510,7 +510,7 @@ public class BodyResolver {
processModifiersOnInitializer(anonymousInitializer, scopeForInitializers); processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
} }
else { else {
trace.report(ANONYMOUS_INITIALIZER_IN_TRAIT.on(anonymousInitializer)); trace.report(ANONYMOUS_INITIALIZER_IN_INTERFACE.on(anonymousInitializer));
processModifiersOnInitializer(anonymousInitializer, scopeForInitializers); processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
} }
} }
@@ -372,7 +372,7 @@ public class DeclarationsChecker {
private void checkConstructorInInterface(JetClass klass) { private void checkConstructorInInterface(JetClass klass) {
JetPrimaryConstructor primaryConstructor = klass.getPrimaryConstructor(); JetPrimaryConstructor primaryConstructor = klass.getPrimaryConstructor();
if (primaryConstructor != null) { if (primaryConstructor != null) {
trace.report(CONSTRUCTOR_IN_TRAIT.on(primaryConstructor)); trace.report(CONSTRUCTOR_IN_INTERFACE.on(primaryConstructor));
} }
} }
@@ -554,7 +554,7 @@ public class DeclarationsChecker {
return; return;
} }
if (classDescriptor.getKind() == ClassKind.INTERFACE) { if (classDescriptor.getKind() == ClassKind.INTERFACE) {
trace.report(ABSTRACT_MODIFIER_IN_TRAIT.on(property)); trace.report(ABSTRACT_MODIFIER_IN_INTERFACE.on(property));
} }
} }
@@ -599,7 +599,7 @@ public class DeclarationsChecker {
Boolean.TRUE.equals(trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)); Boolean.TRUE.equals(trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor));
if (inTrait && backingFieldRequired && hasAccessorImplementation) { if (inTrait && backingFieldRequired && hasAccessorImplementation) {
trace.report(BACKING_FIELD_IN_TRAIT.on(property)); trace.report(BACKING_FIELD_IN_INTERFACE.on(property));
} }
if (initializer == null && delegate == null) { if (initializer == null && delegate == null) {
@@ -626,10 +626,10 @@ public class DeclarationsChecker {
if (inTrait) { if (inTrait) {
if (delegate != null) { if (delegate != null) {
trace.report(DELEGATED_PROPERTY_IN_TRAIT.on(delegate)); trace.report(DELEGATED_PROPERTY_IN_INTERFACE.on(delegate));
} }
else { else {
trace.report(PROPERTY_INITIALIZER_IN_TRAIT.on(initializer)); trace.report(PROPERTY_INITIALIZER_IN_INTERFACE.on(initializer));
} }
} }
else if (delegate == null) { else if (delegate == null) {
@@ -680,7 +680,7 @@ public class DeclarationsChecker {
trace.report(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(function, functionDescriptor.getName().asString(), classDescriptor)); trace.report(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(function, functionDescriptor.getName().asString(), classDescriptor));
} }
if (hasAbstractModifier && inTrait) { if (hasAbstractModifier && inTrait) {
trace.report(ABSTRACT_MODIFIER_IN_TRAIT.on(function)); trace.report(ABSTRACT_MODIFIER_IN_INTERFACE.on(function));
} }
boolean hasBody = function.hasBody(); boolean hasBody = function.hasBody();
if (hasBody && hasAbstractModifier) { if (hasBody && hasAbstractModifier) {
@@ -22,7 +22,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.Errors.CONSTRUCTOR_IN_OBJECT import org.jetbrains.kotlin.diagnostics.Errors.CONSTRUCTOR_IN_OBJECT
import org.jetbrains.kotlin.diagnostics.Errors.CONSTRUCTOR_IN_TRAIT import org.jetbrains.kotlin.diagnostics.Errors.CONSTRUCTOR_IN_INTERFACE
import org.jetbrains.kotlin.diagnostics.Errors.MANY_COMPANION_OBJECTS import org.jetbrains.kotlin.diagnostics.Errors.MANY_COMPANION_OBJECTS
import org.jetbrains.kotlin.diagnostics.Errors.UNSUPPORTED import org.jetbrains.kotlin.diagnostics.Errors.UNSUPPORTED
import org.jetbrains.kotlin.incremental.KotlinLookupLocation import org.jetbrains.kotlin.incremental.KotlinLookupLocation
@@ -126,7 +126,7 @@ public class LazyTopDownAnalyzer(
trace.report(CONSTRUCTOR_IN_OBJECT.on(jetDeclaration)) trace.report(CONSTRUCTOR_IN_OBJECT.on(jetDeclaration))
} }
else if (classDescriptor.getKind() == ClassKind.INTERFACE) { else if (classDescriptor.getKind() == ClassKind.INTERFACE) {
trace.report(CONSTRUCTOR_IN_TRAIT.on(jetDeclaration)) trace.report(CONSTRUCTOR_IN_INTERFACE.on(jetDeclaration))
} }
} }
} }
@@ -408,7 +408,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
if (result != null) { if (result != null) {
if (DescriptorUtils.isInterface(thisType.getConstructor().getDeclarationDescriptor())) { if (DescriptorUtils.isInterface(thisType.getConstructor().getDeclarationDescriptor())) {
if (DescriptorUtils.isClass(result.getConstructor().getDeclarationDescriptor())) { if (DescriptorUtils.isClass(result.getConstructor().getDeclarationDescriptor())) {
context.trace.report(SUPERCLASS_NOT_ACCESSIBLE_FROM_TRAIT.on(expression)); context.trace.report(SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE.on(expression));
} }
} }
context.trace.recordType(expression.getInstanceReference(), result); context.trace.recordType(expression.getInstanceReference(), result);
+19 -19
View File
@@ -3,43 +3,43 @@ package abstract
interface MyTrait { interface MyTrait {
//properties //properties
val a: Int val a: Int
val a1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>1<!> val a1: Int = <!PROPERTY_INITIALIZER_IN_INTERFACE!>1<!>
<!ABSTRACT_MODIFIER_IN_TRAIT!>abstract<!> val a2: Int <!ABSTRACT_MODIFIER_IN_INTERFACE!>abstract<!> val a2: Int
<!ABSTRACT_MODIFIER_IN_TRAIT!>abstract<!> val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!> <!ABSTRACT_MODIFIER_IN_INTERFACE!>abstract<!> val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!>
var b: Int private set var b: Int private set
var b1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; private set var b1: Int = <!PROPERTY_INITIALIZER_IN_INTERFACE!>0<!>; private set
<!ABSTRACT_MODIFIER_IN_TRAIT!>abstract<!> var b2: Int private set <!ABSTRACT_MODIFIER_IN_INTERFACE!>abstract<!> var b2: Int private set
<!ABSTRACT_MODIFIER_IN_TRAIT!>abstract<!> var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set <!ABSTRACT_MODIFIER_IN_INTERFACE!>abstract<!> var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set
<!BACKING_FIELD_IN_TRAIT!>var c: Int<!> set(v: Int) { field = v } <!BACKING_FIELD_IN_INTERFACE!>var c: Int<!> set(v: Int) { field = v }
<!BACKING_FIELD_IN_TRAIT!>var c1: Int<!> = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; set(v: Int) { field = v } <!BACKING_FIELD_IN_INTERFACE!>var c1: Int<!> = <!PROPERTY_INITIALIZER_IN_INTERFACE!>0<!>; set(v: Int) { field = v }
<!ABSTRACT_MODIFIER_IN_TRAIT!>abstract<!> var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { field = v }<!> <!ABSTRACT_MODIFIER_IN_INTERFACE!>abstract<!> var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { field = v }<!>
<!ABSTRACT_MODIFIER_IN_TRAIT!>abstract<!> var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { field = v }<!> <!ABSTRACT_MODIFIER_IN_INTERFACE!>abstract<!> var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { field = v }<!>
val e: Int get() = a val e: Int get() = a
val e1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; get() = a val e1: Int = <!PROPERTY_INITIALIZER_IN_INTERFACE!>0<!>; get() = a
<!ABSTRACT_MODIFIER_IN_TRAIT!>abstract<!> val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!> <!ABSTRACT_MODIFIER_IN_INTERFACE!>abstract<!> val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
<!ABSTRACT_MODIFIER_IN_TRAIT!>abstract<!> val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!> <!ABSTRACT_MODIFIER_IN_INTERFACE!>abstract<!> val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
//methods //methods
fun f() fun f()
fun g() {} fun g() {}
<!ABSTRACT_MODIFIER_IN_TRAIT!>abstract<!> fun h() <!ABSTRACT_MODIFIER_IN_INTERFACE!>abstract<!> fun h()
<!ABSTRACT_MODIFIER_IN_TRAIT, ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {} <!ABSTRACT_MODIFIER_IN_INTERFACE, ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
//property accessors //property accessors
var i: Int <!WRONG_MODIFIER_TARGET!>abstract<!> get <!WRONG_MODIFIER_TARGET!>abstract<!> set var i: Int <!WRONG_MODIFIER_TARGET!>abstract<!> get <!WRONG_MODIFIER_TARGET!>abstract<!> set
var i1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; <!WRONG_MODIFIER_TARGET!>abstract<!> get <!WRONG_MODIFIER_TARGET!>abstract<!> set var i1: Int = <!PROPERTY_INITIALIZER_IN_INTERFACE!>0<!>; <!WRONG_MODIFIER_TARGET!>abstract<!> get <!WRONG_MODIFIER_TARGET!>abstract<!> set
var j: Int get() = i; <!WRONG_MODIFIER_TARGET!>abstract<!> set var j: Int get() = i; <!WRONG_MODIFIER_TARGET!>abstract<!> set
var j1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; get() = i; <!WRONG_MODIFIER_TARGET!>abstract<!> set var j1: Int = <!PROPERTY_INITIALIZER_IN_INTERFACE!>0<!>; get() = i; <!WRONG_MODIFIER_TARGET!>abstract<!> set
var k: Int <!WRONG_MODIFIER_TARGET!>abstract<!> set var k: Int <!WRONG_MODIFIER_TARGET!>abstract<!> set
var k1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; <!WRONG_MODIFIER_TARGET!>abstract<!> set var k1: Int = <!PROPERTY_INITIALIZER_IN_INTERFACE!>0<!>; <!WRONG_MODIFIER_TARGET!>abstract<!> set
var l: Int <!WRONG_MODIFIER_TARGET!>abstract<!> get <!WRONG_MODIFIER_TARGET!>abstract<!> set var l: Int <!WRONG_MODIFIER_TARGET!>abstract<!> get <!WRONG_MODIFIER_TARGET!>abstract<!> set
var l1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; <!WRONG_MODIFIER_TARGET!>abstract<!> get <!WRONG_MODIFIER_TARGET!>abstract<!> set var l1: Int = <!PROPERTY_INITIALIZER_IN_INTERFACE!>0<!>; <!WRONG_MODIFIER_TARGET!>abstract<!> get <!WRONG_MODIFIER_TARGET!>abstract<!> set
var n: Int <!WRONG_MODIFIER_TARGET!>abstract<!> get <!WRONG_MODIFIER_TARGET!>abstract<!> set(v: Int) {} var n: Int <!WRONG_MODIFIER_TARGET!>abstract<!> get <!WRONG_MODIFIER_TARGET!>abstract<!> set(v: Int) {}
} }
@@ -1,11 +1,11 @@
interface NoC { interface NoC {
<!ANONYMOUS_INITIALIZER_IN_TRAIT!>init { <!ANONYMOUS_INITIALIZER_IN_INTERFACE!>init {
}<!> }<!>
val a : Int get() = 1 val a : Int get() = 1
<!ANONYMOUS_INITIALIZER_IN_TRAIT!>init { <!ANONYMOUS_INITIALIZER_IN_INTERFACE!>init {
}<!> }<!>
} }
+1 -1
View File
@@ -1,3 +1,3 @@
interface T { interface T {
val a = <!PROPERTY_INITIALIZER_IN_TRAIT!><!UNRESOLVED_REFERENCE!>Foo<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>bar<!>()<!> val a = <!PROPERTY_INITIALIZER_IN_INTERFACE!><!UNRESOLVED_REFERENCE!>Foo<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>bar<!>()<!>
} }
+5 -5
View File
@@ -21,20 +21,20 @@ interface T1 {}
interface T2<T> {} interface T2<T> {}
interface Test<!CONSTRUCTOR_IN_TRAIT!>()<!> { interface Test<!CONSTRUCTOR_IN_INTERFACE!>()<!> {
} }
interface Test1 : <!TRAIT_WITH_SUPERCLASS!>C2<!><!SUPERTYPE_INITIALIZED_IN_TRAIT!>()<!> {} interface Test1 : <!INTERFACE_WITH_SUPERCLASS!>C2<!><!SUPERTYPE_INITIALIZED_IN_INTERFACE!>()<!> {}
interface Test2 : <!TRAIT_WITH_SUPERCLASS!>C2<!> {} interface Test2 : <!INTERFACE_WITH_SUPERCLASS!>C2<!> {}
interface Test3 : <!TRAIT_WITH_SUPERCLASS!>C2<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>C3<!> {} interface Test3 : <!INTERFACE_WITH_SUPERCLASS!>C2<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>C3<!> {}
interface Test4 : T1 {} interface Test4 : T1 {}
interface Test5 : T1, <!SUPERTYPE_APPEARS_TWICE!>T1<!> {} interface Test5 : T1, <!SUPERTYPE_APPEARS_TWICE!>T1<!> {}
interface Test6 : <!TRAIT_WITH_SUPERCLASS, FINAL_SUPERTYPE!>C1<!> {} interface Test6 : <!INTERFACE_WITH_SUPERCLASS, FINAL_SUPERTYPE!>C1<!> {}
class CTest1() : OC1() {} class CTest1() : OC1() {}
@@ -1,4 +1,4 @@
interface MyTrait: <!PLATFORM_CLASS_MAPPED_TO_KOTLIN, TRAIT_WITH_SUPERCLASS!>Object<!> { interface MyTrait: <!PLATFORM_CLASS_MAPPED_TO_KOTLIN, INTERFACE_WITH_SUPERCLASS!>Object<!> {
override fun toString(): String override fun toString(): String
public override fun finalize() public override fun finalize()
public <!OVERRIDING_FINAL_MEMBER!>override<!> fun wait() public <!OVERRIDING_FINAL_MEMBER!>override<!> fun wait()
@@ -2,17 +2,17 @@
class C(val a: String) {} class C(val a: String) {}
interface T1<!CONSTRUCTOR_IN_TRAIT!>(val x: String)<!> {} interface T1<!CONSTRUCTOR_IN_INTERFACE!>(val x: String)<!> {}
interface T2 <!CONSTRUCTOR_IN_TRAIT!>constructor()<!> {} interface T2 <!CONSTRUCTOR_IN_INTERFACE!>constructor()<!> {}
interface T3 private <!CONSTRUCTOR_IN_TRAIT!>constructor(<!UNUSED_PARAMETER!>a<!>: Int)<!> {} interface T3 private <!CONSTRUCTOR_IN_INTERFACE!>constructor(<!UNUSED_PARAMETER!>a<!>: Int)<!> {}
interface T4 { interface T4 {
<!CONSTRUCTOR_IN_TRAIT!>constructor(<!UNUSED_PARAMETER!>a<!>: Int)<!> { <!CONSTRUCTOR_IN_INTERFACE!>constructor(<!UNUSED_PARAMETER!>a<!>: Int)<!> {
val <!UNUSED_VARIABLE!>b<!>: Int = 1 val <!UNUSED_VARIABLE!>b<!>: Int = 1
} }
} }
interface T5 private <!CONSTRUCTOR_IN_TRAIT!>()<!> : T4 {} interface T5 private <!CONSTRUCTOR_IN_INTERFACE!>()<!> : T4 {}
interface T6 <!CONSTRUCTOR_IN_TRAIT!>private<!><!SYNTAX!><!> : T5 {} interface T6 <!CONSTRUCTOR_IN_INTERFACE!>private<!><!SYNTAX!><!> : T5 {}
@@ -4,8 +4,8 @@ class A {
} }
interface T { interface T {
<!ANONYMOUS_INITIALIZER_IN_TRAIT!><!WRONG_ANNOTATION_TARGET!>@ann<!> init {}<!> <!ANONYMOUS_INITIALIZER_IN_INTERFACE!><!WRONG_ANNOTATION_TARGET!>@ann<!> init {}<!>
<!ANONYMOUS_INITIALIZER_IN_TRAIT!><!WRONG_ANNOTATION_TARGET, UNRESOLVED_REFERENCE!>@aaa<!> init {}<!> <!ANONYMOUS_INITIALIZER_IN_INTERFACE!><!WRONG_ANNOTATION_TARGET, UNRESOLVED_REFERENCE!>@aaa<!> init {}<!>
} }
annotation class ann annotation class ann
@@ -1,4 +1,4 @@
interface My { interface My {
<!BACKING_FIELD_IN_TRAIT!>val x: Int<!> = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!> <!BACKING_FIELD_IN_INTERFACE!>val x: Int<!> = <!PROPERTY_INITIALIZER_IN_INTERFACE!>0<!>
get() = field get() = field
} }
@@ -5,7 +5,7 @@ interface T3
open class OC1: T1 open class OC1: T1
open class OC2: OC1(), T2 open class OC2: OC1(), T2
class FC1: OC2(), T3 class FC1: OC2(), T3
interface T4: <!TRAIT_WITH_SUPERCLASS!>OC1<!> interface T4: <!INTERFACE_WITH_SUPERCLASS!>OC1<!>
interface T5: T2 interface T5: T2
fun test<TP1: OC1, TP2: T2, TP3: OC2>( fun test<TP1: OC1, TP2: T2, TP3: OC2>(
@@ -9,7 +9,7 @@ interface T {
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>final<!> val c : Int <!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>final<!> val c : Int
get() = 42 get() = 42
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>final<!> val d = <!PROPERTY_INITIALIZER_IN_TRAIT!>1<!> <!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>final<!> val d = <!PROPERTY_INITIALIZER_IN_INTERFACE!>1<!>
} }
class A { class A {
@@ -1,7 +1,7 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
interface T { interface T {
val a: Int <!DELEGATED_PROPERTY_IN_TRAIT!>by Delegate()<!> val a: Int <!DELEGATED_PROPERTY_IN_INTERFACE!>by Delegate()<!>
} }
class Delegate { class Delegate {
@@ -2,7 +2,7 @@ open class Foo() {
} }
class Barrr() : <!DELEGATION_NOT_TO_TRAIT!>Foo<!> by Foo() {} class Barrr() : <!DELEGATION_NOT_TO_INTERFACE!>Foo<!> by Foo() {}
interface T {} interface T {}
@@ -12,4 +12,4 @@ class Br(t : T) : T by t {}
A A
} }
class Test2(e : EN) : <!DELEGATION_NOT_TO_TRAIT!>EN<!> by e {} class Test2(e : EN) : <!DELEGATION_NOT_TO_INTERFACE!>EN<!> by e {}
@@ -1,3 +1,3 @@
class TestIface(r : Runnable) : Runnable by r {} class TestIface(r : Runnable) : Runnable by r {}
class TestObject(o : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Object<!>) : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN, DELEGATION_NOT_TO_TRAIT!>Object<!> by o {} class TestObject(o : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Object<!>) : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN, DELEGATION_NOT_TO_INTERFACE!>Object<!> by o {}
@@ -2,6 +2,6 @@ open class C {
val x = 1 val x = 1
} }
interface Tr : <!TRAIT_WITH_SUPERCLASS!>C<!> { interface Tr : <!INTERFACE_WITH_SUPERCLASS!>C<!> {
<!ACCIDENTAL_OVERRIDE!>fun getX()<!> = 1 <!ACCIDENTAL_OVERRIDE!>fun getX()<!> = 1
} }
@@ -8,7 +8,7 @@ public interface Test {
// FILE: test.kt // FILE: test.kt
interface KTrait : Test { interface KTrait : Test {
fun ktest() { fun ktest() {
<!TRAIT_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>super.test()<!> <!INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER!>super.test()<!>
test() test()
} }
@@ -1,6 +1,6 @@
interface My { interface My {
<!PRIVATE_PROPERTY_IN_INTERFACE!>private<!> val x: Int <!PRIVATE_PROPERTY_IN_INTERFACE!>private<!> val x: Int
<!INCOMPATIBLE_MODIFIERS!>private<!> <!ABSTRACT_MODIFIER_IN_TRAIT, INCOMPATIBLE_MODIFIERS!>abstract<!> val xx: Int <!INCOMPATIBLE_MODIFIERS!>private<!> <!ABSTRACT_MODIFIER_IN_INTERFACE, INCOMPATIBLE_MODIFIERS!>abstract<!> val xx: Int
private val xxx: Int private val xxx: Int
get() = 0 get() = 0
<!FINAL_PROPERTY_IN_INTERFACE, DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>final<!> val y: Int <!FINAL_PROPERTY_IN_INTERFACE, DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>final<!> val y: Int
@@ -1,3 +1,3 @@
class C : <!UNRESOLVED_REFERENCE, DELEGATION_NOT_TO_TRAIT!>Base1<!> by <!UNRESOLVED_REFERENCE!>Base2<!>(1) { class C : <!UNRESOLVED_REFERENCE, DELEGATION_NOT_TO_INTERFACE!>Base1<!> by <!UNRESOLVED_REFERENCE!>Base2<!>(1) {
fun test() { } fun test() { }
} }
+1 -1
View File
@@ -6,6 +6,6 @@ open class Bbb() : Aaa() {
override fun foo() = 2 override fun foo() = 2
} }
interface Ccc : <!TRAIT_WITH_SUPERCLASS!>Aaa<!> interface Ccc : <!INTERFACE_WITH_SUPERCLASS!>Aaa<!>
class Ddd() : Bbb(), Ccc class Ddd() : Bbb(), Ccc
@@ -1 +1 @@
class A<T> : <!SUPERTYPE_NOT_A_CLASS_OR_TRAIT!>T<!> {} class A<T> : <!SUPERTYPE_NOT_A_CLASS_OR_INTERFACE!>T<!> {}
+1 -1
View File
@@ -4,7 +4,7 @@ open class AL {
fun get(i : Int) : Any? = i fun get(i : Int) : Any? = i
} }
interface ALE<T> : <!TRAIT_WITH_SUPERCLASS!>AL<!> { interface ALE<T> : <!INTERFACE_WITH_SUPERCLASS!>AL<!> {
fun getOrNull(index: Int, value: T) : T { fun getOrNull(index: Int, value: T) : T {
return <!UNCHECKED_CAST!>get(index) as? T<!> ?: value return <!UNCHECKED_CAST!>get(index) as? T<!> ?: value
} }
@@ -1,3 +1,3 @@
interface A { interface A {
<!CONSTRUCTOR_IN_TRAIT!>constructor()<!> <!CONSTRUCTOR_IN_INTERFACE!>constructor()<!>
} }
@@ -1,6 +1,6 @@
interface A1 : <!UNRESOLVED_REFERENCE!>B<!> interface A1 : <!UNRESOLVED_REFERENCE!>B<!>
interface A2 : <!UNRESOLVED_REFERENCE!>B<!><!SUPERTYPE_INITIALIZED_IN_TRAIT!>()<!> interface A2 : <!UNRESOLVED_REFERENCE!>B<!><!SUPERTYPE_INITIALIZED_IN_INTERFACE!>()<!>
class A3 : <!UNRESOLVED_REFERENCE!>B<!>, <!UNRESOLVED_REFERENCE!>B<!> class A3 : <!UNRESOLVED_REFERENCE!>B<!>, <!UNRESOLVED_REFERENCE!>B<!>
@@ -2,9 +2,9 @@ open class A {
open fun foo() {} open fun foo() {}
} }
interface ATrait : <!TRAIT_WITH_SUPERCLASS!>A<!> { interface ATrait : <!INTERFACE_WITH_SUPERCLASS!>A<!> {
override fun foo() { override fun foo() {
<!SUPERCLASS_NOT_ACCESSIBLE_FROM_TRAIT!>super<A><!>.foo() <!SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE!>super<A><!>.foo()
} }
} }
@@ -1,4 +1,4 @@
interface AnyTrait : <!TRAIT_WITH_SUPERCLASS!>Any<!> interface AnyTrait : <!INTERFACE_WITH_SUPERCLASS!>Any<!>
class Foo : AnyTrait class Foo : AnyTrait
@@ -1,9 +1,9 @@
open class bar() open class bar()
interface Foo<!CONSTRUCTOR_IN_TRAIT!>()<!> : <!TRAIT_WITH_SUPERCLASS!>bar<!><!SUPERTYPE_INITIALIZED_IN_TRAIT!>()<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>bar<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!> { interface Foo<!CONSTRUCTOR_IN_INTERFACE!>()<!> : <!INTERFACE_WITH_SUPERCLASS!>bar<!><!SUPERTYPE_INITIALIZED_IN_INTERFACE!>()<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>bar<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!> {
} }
interface Foo2 : <!TRAIT_WITH_SUPERCLASS!>bar<!>, Foo { interface Foo2 : <!INTERFACE_WITH_SUPERCLASS!>bar<!>, Foo {
} }
open class Foo1() : bar(), <!SUPERTYPE_NOT_INITIALIZED, MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!>, Foo, <!SUPERTYPE_APPEARS_TWICE!>Foo<!>() {} open class Foo1() : bar(), <!SUPERTYPE_NOT_INITIALIZED, MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!>, Foo, <!SUPERTYPE_APPEARS_TWICE!>Foo<!>() {}
@@ -1,8 +1,8 @@
import kotlin.jvm.* import kotlin.jvm.*
interface Tr { interface Tr {
<!EXTERNAL_DECLARATION_IN_TRAIT!>external fun foo()<!> <!EXTERNAL_DECLARATION_IN_INTERFACE!>external fun foo()<!>
<!EXTERNAL_DECLARATION_IN_TRAIT, EXTERNAL_DECLARATION_CANNOT_HAVE_BODY!>external fun bar()<!> {} <!EXTERNAL_DECLARATION_IN_INTERFACE, EXTERNAL_DECLARATION_CANNOT_HAVE_BODY!>external fun bar()<!> {}
companion object { companion object {
external fun foo() external fun foo()
@@ -62,7 +62,7 @@ public class QuickFixRegistrar : QuickFixContributor {
ABSTRACT_PROPERTY_WITH_GETTER.registerFactory(removeAbstractModifierFactory, removePartsFromPropertyFactory) ABSTRACT_PROPERTY_WITH_GETTER.registerFactory(removeAbstractModifierFactory, removePartsFromPropertyFactory)
ABSTRACT_PROPERTY_WITH_SETTER.registerFactory(removeAbstractModifierFactory, removePartsFromPropertyFactory) ABSTRACT_PROPERTY_WITH_SETTER.registerFactory(removeAbstractModifierFactory, removePartsFromPropertyFactory)
PROPERTY_INITIALIZER_IN_TRAIT.registerFactory(removePartsFromPropertyFactory) PROPERTY_INITIALIZER_IN_INTERFACE.registerFactory(removePartsFromPropertyFactory)
MUST_BE_INITIALIZED_OR_BE_ABSTRACT.registerFactory(addAbstractModifierFactory) MUST_BE_INITIALIZED_OR_BE_ABSTRACT.registerFactory(addAbstractModifierFactory)
ABSTRACT_MEMBER_NOT_IMPLEMENTED.registerFactory(addAbstractModifierFactory) ABSTRACT_MEMBER_NOT_IMPLEMENTED.registerFactory(addAbstractModifierFactory)
@@ -104,7 +104,7 @@ public class QuickFixRegistrar : QuickFixContributor {
val removeRedundantModifierFactory = RemoveModifierFix.createRemoveModifierFactory(true) val removeRedundantModifierFactory = RemoveModifierFix.createRemoveModifierFactory(true)
REDUNDANT_MODIFIER.registerFactory(removeRedundantModifierFactory) REDUNDANT_MODIFIER.registerFactory(removeRedundantModifierFactory)
ABSTRACT_MODIFIER_IN_TRAIT.registerFactory(RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD, true)) ABSTRACT_MODIFIER_IN_INTERFACE.registerFactory(RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD, true))
REDUNDANT_PROJECTION.registerFactory(RemoveModifierFix.createRemoveProjectionFactory(true)) REDUNDANT_PROJECTION.registerFactory(RemoveModifierFix.createRemoveProjectionFactory(true))
INCOMPATIBLE_MODIFIERS.registerFactory(RemoveModifierFix.createRemoveModifierFactory(false)) INCOMPATIBLE_MODIFIERS.registerFactory(RemoveModifierFix.createRemoveModifierFactory(false))