rename JetClass.isTrait() to isInterface(); rename ClassKind.TRAIT to INTERACE
This commit is contained in:
@@ -195,7 +195,7 @@ public class AsmUtil {
|
||||
if (functionDescriptor.getModality() == Modality.FINAL && !(functionDescriptor instanceof ConstructorDescriptor)) {
|
||||
DeclarationDescriptor containingDeclaration = functionDescriptor.getContainingDeclaration();
|
||||
if (!(containingDeclaration instanceof ClassDescriptor) ||
|
||||
((ClassDescriptor) containingDeclaration).getKind() != ClassKind.TRAIT) {
|
||||
((ClassDescriptor) containingDeclaration).getKind() != ClassKind.INTERFACE) {
|
||||
flags |= ACC_FINAL;
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class AsmUtil {
|
||||
|
||||
private static int innerAccessFlagsForModalityAndKind(@NotNull ClassDescriptor innerClass) {
|
||||
switch (innerClass.getKind()) {
|
||||
case TRAIT:
|
||||
case INTERFACE:
|
||||
return ACC_ABSTRACT | ACC_INTERFACE;
|
||||
case ENUM_CLASS:
|
||||
return ACC_FINAL | ACC_ENUM;
|
||||
|
||||
@@ -216,13 +216,13 @@ class CollectionStubMethodGenerator(
|
||||
private fun generateMethodStub(signature: JvmMethodSignature, synthetic: Boolean) {
|
||||
// TODO: investigate if it makes sense to generate abstract stubs in traits
|
||||
var access = ACC_PUBLIC
|
||||
if (descriptor.getKind() == ClassKind.TRAIT) access = access or ACC_ABSTRACT
|
||||
if (descriptor.getKind() == ClassKind.INTERFACE) access = access or ACC_ABSTRACT
|
||||
if (synthetic) access = access or ACC_SYNTHETIC
|
||||
|
||||
val asmMethod = signature.getAsmMethod()
|
||||
val genericSignature = if (synthetic) null else signature.getGenericsSignature()
|
||||
val mv = v.newMethod(JvmDeclarationOrigin.NO_ORIGIN, access, asmMethod.getName(), asmMethod.getDescriptor(), genericSignature, null)
|
||||
if (descriptor.getKind() != ClassKind.TRAIT) {
|
||||
if (descriptor.getKind() != ClassKind.INTERFACE) {
|
||||
mv.visitCode()
|
||||
AsmUtil.genThrow(InstructionAdapter(mv), "java/lang/UnsupportedOperationException", "Mutating immutable collection")
|
||||
FunctionCodegen.endVisit(mv, "built-in stub for $signature", null)
|
||||
|
||||
@@ -333,7 +333,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
ClassContext objectContext = context.intoAnonymousClass(descriptor, this, OwnerKind.IMPLEMENTATION);
|
||||
new ImplementationBodyCodegen(declaration, objectContext, classBuilder, state, getParentCodegen()).generate();
|
||||
|
||||
if (declaration instanceof JetClass && ((JetClass) declaration).isTrait()) {
|
||||
if (declaration instanceof JetClass && ((JetClass) declaration).isInterface()) {
|
||||
Type traitImplType = state.getTypeMapper().mapTraitImpl(descriptor);
|
||||
ClassBuilder traitImplBuilder = state.getFactory().newVisitor(TraitImpl(declaration, descriptor), traitImplType, declaration.getContainingFile());
|
||||
ClassContext traitImplContext = context.intoAnonymousClass(descriptor, this, OwnerKind.TRAIT_IMPL);
|
||||
|
||||
@@ -568,7 +568,7 @@ public class FunctionCodegen {
|
||||
|
||||
if (kind != OwnerKind.TRAIT_IMPL &&
|
||||
contextClass instanceof ClassDescriptor &&
|
||||
((ClassDescriptor) contextClass).getKind() == ClassKind.TRAIT) {
|
||||
((ClassDescriptor) contextClass).getKind() == ClassKind.INTERFACE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -812,7 +812,7 @@ public class FunctionCodegen {
|
||||
}
|
||||
|
||||
String internalName = typeMapper.mapType(toClass).getInternalName();
|
||||
if (toClass.getKind() == ClassKind.TRAIT) {
|
||||
if (toClass.getKind() == ClassKind.INTERFACE) {
|
||||
iv.invokeinterface(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -126,7 +126,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (jetClass.hasModifier(JetTokens.ABSTRACT_KEYWORD)) {
|
||||
isAbstract = true;
|
||||
}
|
||||
if (jetClass.isTrait()) {
|
||||
if (jetClass.isInterface()) {
|
||||
isAbstract = true;
|
||||
isInterface = true;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
List<JetDelegationSpecifier> delegationSpecifiers = myClass.getDelegationSpecifiers();
|
||||
|
||||
if (myClass instanceof JetClass && ((JetClass) myClass).isTrait()) {
|
||||
if (myClass instanceof JetClass && ((JetClass) myClass).isInterface()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -437,13 +437,13 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
KotlinBuiltIns builtIns = getBuiltIns(descriptor);
|
||||
if (!isSubclass(descriptor, builtIns.getCollection())) return;
|
||||
|
||||
int access = descriptor.getKind() == ClassKind.TRAIT ?
|
||||
int access = descriptor.getKind() == ClassKind.INTERFACE ?
|
||||
ACC_PUBLIC | ACC_ABSTRACT :
|
||||
ACC_PUBLIC;
|
||||
if (CodegenUtil.getDeclaredFunctionByRawSignature(descriptor, Name.identifier("toArray"), builtIns.getArray()) == null) {
|
||||
MethodVisitor mv = v.newMethod(NO_ORIGIN, access, "toArray", "()[Ljava/lang/Object;", null, null);
|
||||
|
||||
if (descriptor.getKind() != ClassKind.TRAIT) {
|
||||
if (descriptor.getKind() != ClassKind.INTERFACE) {
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
mv.visitCode();
|
||||
|
||||
@@ -458,7 +458,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (!isGenericToArrayPresent()) {
|
||||
MethodVisitor mv = v.newMethod(NO_ORIGIN, access, "toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;", null, null);
|
||||
|
||||
if (descriptor.getKind() != ClassKind.TRAIT) {
|
||||
if (descriptor.getKind() != ClassKind.INTERFACE) {
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
mv.visitCode();
|
||||
|
||||
@@ -1394,7 +1394,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private boolean ignoreIfTraitOrAnnotation() {
|
||||
if (myClass instanceof JetClass) {
|
||||
JetClass aClass = (JetClass) myClass;
|
||||
if (aClass.isTrait()) {
|
||||
if (aClass.isInterface()) {
|
||||
return true;
|
||||
}
|
||||
if (aClass.isAnnotation()) {
|
||||
|
||||
@@ -59,7 +59,7 @@ public class JvmCodegenUtil {
|
||||
public static boolean isInterface(DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
ClassKind kind = ((ClassDescriptor) descriptor).getKind();
|
||||
return kind == ClassKind.TRAIT || kind == ClassKind.ANNOTATION_CLASS;
|
||||
return kind == ClassKind.INTERFACE || kind == ClassKind.ANNOTATION_CLASS;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
|
||||
ClassContext classContext = parentContext.intoClass(descriptor, OwnerKind.IMPLEMENTATION, state);
|
||||
new ImplementationBodyCodegen(aClass, classContext, classBuilder, state, parentCodegen).generate();
|
||||
|
||||
if (aClass instanceof JetClass && ((JetClass) aClass).isTrait()) {
|
||||
if (aClass instanceof JetClass && ((JetClass) aClass).isInterface()) {
|
||||
Type traitImplType = state.getTypeMapper().mapTraitImpl(descriptor);
|
||||
ClassBuilder traitImplBuilder = state.getFactory().newVisitor(TraitImpl(aClass, descriptor), traitImplType, aClass.getContainingFile());
|
||||
ClassContext traitImplContext = parentContext.intoClass(descriptor, OwnerKind.TRAIT_IMPL, state);
|
||||
|
||||
@@ -443,7 +443,7 @@ public abstract class StackValue {
|
||||
// Coerce this/super for traits to support traits with required classes.
|
||||
// Coerce explicit 'this' for the case when it is smart cast.
|
||||
// Do not coerce for other classes due to the 'protected' access issues (JVMS 7, 4.9.2 Structural Constraints).
|
||||
boolean coerceType = descriptor.getKind() == ClassKind.TRAIT || (isExplicit && !isSuper);
|
||||
boolean coerceType = descriptor.getKind() == ClassKind.INTERFACE || (isExplicit && !isSuper);
|
||||
return new ThisOuter(codegen, descriptor, isSuper, coerceType);
|
||||
}
|
||||
|
||||
|
||||
@@ -844,7 +844,7 @@ public class JetTypeMapper {
|
||||
@NotNull
|
||||
private static ClassDescriptor getTraitImplThisParameterClass(@NotNull ClassDescriptor traitDescriptor) {
|
||||
for (ClassDescriptor descriptor : DescriptorUtils.getSuperclassDescriptors(traitDescriptor)) {
|
||||
if (descriptor.getKind() != ClassKind.TRAIT) {
|
||||
if (descriptor.getKind() != ClassKind.INTERFACE) {
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
private static boolean isSamInterface(@NotNull ClassDescriptor klass) {
|
||||
if (klass.getKind() != ClassKind.TRAIT) {
|
||||
if (klass.getKind() != ClassKind.INTERFACE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
||||
this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, redeclarationHandler, "MemberResolution")
|
||||
.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
|
||||
if (kind == ClassKind.TRAIT) {
|
||||
if (kind == ClassKind.INTERFACE) {
|
||||
setUpScopeForInitializers(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -132,10 +132,10 @@ public class JetClass extends JetTypeParameterListOwnerStub<KotlinClassStub> imp
|
||||
return body.getProperties();
|
||||
}
|
||||
|
||||
public boolean isTrait() {
|
||||
public boolean isInterface() {
|
||||
KotlinClassStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.isTrait();
|
||||
return stub.isInterface();
|
||||
}
|
||||
|
||||
return findChildByType(JetTokens.TRAIT_KEYWORD) != null ||
|
||||
|
||||
@@ -427,7 +427,7 @@ public class JetPsiUtil {
|
||||
}
|
||||
|
||||
public static boolean isTrait(@NotNull JetClassOrObject classOrObject) {
|
||||
return classOrObject instanceof JetClass && ((JetClass) classOrObject).isTrait();
|
||||
return classOrObject instanceof JetClass && ((JetClass) classOrObject).isInterface();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -116,7 +116,7 @@ public fun JetClassOrObject.effectiveDeclarations(): List<JetDeclaration> =
|
||||
getDeclarations()
|
||||
}
|
||||
|
||||
public fun JetClass.isAbstract(): Boolean = isTrait() || hasModifier(JetTokens.ABSTRACT_KEYWORD)
|
||||
public fun JetClass.isAbstract(): Boolean = isInterface() || hasModifier(JetTokens.ABSTRACT_KEYWORD)
|
||||
|
||||
[suppress("UNCHECKED_CAST")]
|
||||
public fun <T: PsiElement> PsiElement.replaced(newElement: T): T = replace(newElement) as T
|
||||
@@ -201,7 +201,7 @@ public fun <T: JetClassOrObject> StubBasedPsiElementBase<out KotlinClassOrObject
|
||||
public fun SearchScope.contains(element: PsiElement): Boolean = PsiSearchScopeUtil.isInScope(this, element)
|
||||
|
||||
public fun JetClass.isInheritable(): Boolean {
|
||||
return isTrait() || hasModifier(JetTokens.OPEN_KEYWORD) || hasModifier(JetTokens.ABSTRACT_KEYWORD)
|
||||
return isInterface() || hasModifier(JetTokens.OPEN_KEYWORD) || hasModifier(JetTokens.ABSTRACT_KEYWORD)
|
||||
}
|
||||
|
||||
public fun JetDeclaration.isOverridable(): Boolean {
|
||||
@@ -213,7 +213,7 @@ public fun JetDeclaration.isOverridable(): Boolean {
|
||||
|
||||
if (hasModifier(JetTokens.FINAL_KEYWORD) || hasModifier(JetTokens.PRIVATE_KEYWORD)) return false
|
||||
|
||||
return klass.isTrait() ||
|
||||
return klass.isInterface() ||
|
||||
hasModifier(JetTokens.ABSTRACT_KEYWORD) || hasModifier(JetTokens.OPEN_KEYWORD) || hasModifier(JetTokens.OVERRIDE_KEYWORD)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public trait KotlinClassOrObjectStub<T : JetClassOrObject> : KotlinStubWithFqNam
|
||||
}
|
||||
|
||||
public trait KotlinClassStub : KotlinClassOrObjectStub<JetClass> {
|
||||
public fun isTrait(): Boolean
|
||||
public fun isInterface(): Boolean
|
||||
public fun isEnumEntry(): Boolean
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ public class JetClassElementType extends JetStubElementType<KotlinClassStub, Jet
|
||||
List<String> superNames = PsiUtilPackage.getSuperNames(psi);
|
||||
return new KotlinClassStubImpl(
|
||||
getStubType(isEnumEntry), parentStub, StringRef.fromString(fqName != null ? fqName.asString() : null),
|
||||
StringRef.fromString(psi.getName()), Utils.INSTANCE$.wrapStrings(superNames), psi.isTrait(), isEnumEntry,
|
||||
StringRef.fromString(psi.getName()), Utils.INSTANCE$.wrapStrings(superNames), psi.isInterface(), isEnumEntry,
|
||||
psi.isLocal(), psi.isTopLevel());
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class JetClassElementType extends JetStubElementType<KotlinClassStub, Jet
|
||||
dataStream.writeName(stub.getName());
|
||||
FqName fqName = stub.getFqName();
|
||||
dataStream.writeName(fqName == null ? null : fqName.asString());
|
||||
dataStream.writeBoolean(stub.isTrait());
|
||||
dataStream.writeBoolean(stub.isInterface());
|
||||
dataStream.writeBoolean(stub.isEnumEntry());
|
||||
dataStream.writeBoolean(stub.isLocal());
|
||||
dataStream.writeBoolean(stub.isTopLevel());
|
||||
|
||||
@@ -46,7 +46,7 @@ public class KotlinClassStubImpl(
|
||||
return FqName(stringRef)
|
||||
}
|
||||
|
||||
override fun isTrait() = isTrait
|
||||
override fun isInterface() = isTrait
|
||||
override fun isEnumEntry() = isEnumEntry
|
||||
override fun isLocal() = isLocal
|
||||
override fun getName() = StringRef.toString(name)
|
||||
|
||||
@@ -290,7 +290,7 @@ public class BodyResolver {
|
||||
|
||||
@Override
|
||||
public void visitDelegationByExpressionSpecifier(@NotNull JetDelegatorByExpressionSpecifier specifier) {
|
||||
if (descriptor.getKind() == ClassKind.TRAIT) {
|
||||
if (descriptor.getKind() == ClassKind.INTERFACE) {
|
||||
trace.report(DELEGATION_IN_TRAIT.on(specifier));
|
||||
}
|
||||
JetType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
|
||||
@@ -299,7 +299,7 @@ public class BodyResolver {
|
||||
DeclarationDescriptor declarationDescriptor = supertype.getConstructor().getDeclarationDescriptor();
|
||||
if (declarationDescriptor instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor;
|
||||
if (classDescriptor.getKind() != ClassKind.TRAIT) {
|
||||
if (classDescriptor.getKind() != ClassKind.INTERFACE) {
|
||||
trace.report(DELEGATION_NOT_TO_TRAIT.on(specifier.getTypeReference()));
|
||||
}
|
||||
}
|
||||
@@ -319,13 +319,13 @@ public class BodyResolver {
|
||||
public void visitDelegationToSuperCallSpecifier(@NotNull JetDelegatorToSuperCall call) {
|
||||
JetValueArgumentList valueArgumentList = call.getValueArgumentList();
|
||||
PsiElement elementToMark = valueArgumentList == null ? call : valueArgumentList;
|
||||
if (descriptor.getKind() == ClassKind.TRAIT) {
|
||||
if (descriptor.getKind() == ClassKind.INTERFACE) {
|
||||
trace.report(SUPERTYPE_INITIALIZED_IN_TRAIT.on(elementToMark));
|
||||
}
|
||||
JetTypeReference typeReference = call.getTypeReference();
|
||||
if (typeReference == null) return;
|
||||
if (primaryConstructor == null) {
|
||||
if (descriptor.getKind() != ClassKind.TRAIT) {
|
||||
if (descriptor.getKind() != ClassKind.INTERFACE) {
|
||||
trace.report(SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR.on(call));
|
||||
}
|
||||
recordSupertype(typeReference, trace.getBindingContext().get(BindingContext.TYPE, typeReference));
|
||||
@@ -339,7 +339,7 @@ public class BodyResolver {
|
||||
recordSupertype(typeReference, supertype);
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
|
||||
if (classDescriptor != null) {
|
||||
if (classDescriptor.getKind() == ClassKind.TRAIT) {
|
||||
if (classDescriptor.getKind() == ClassKind.INTERFACE) {
|
||||
trace.report(CONSTRUCTOR_IN_TRAIT.on(elementToMark));
|
||||
}
|
||||
// allow only one delegating constructor
|
||||
@@ -368,7 +368,7 @@ public class BodyResolver {
|
||||
// A "singleton in supertype" diagnostic will be reported later
|
||||
return;
|
||||
}
|
||||
if (descriptor.getKind() != ClassKind.TRAIT &&
|
||||
if (descriptor.getKind() != ClassKind.INTERFACE &&
|
||||
descriptor.getUnsubstitutedPrimaryConstructor() != null &&
|
||||
!superClass.getConstructors().isEmpty() &&
|
||||
!ErrorUtils.isError(superClass)
|
||||
@@ -425,11 +425,11 @@ public class BodyResolver {
|
||||
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
|
||||
if (classDescriptor != null) {
|
||||
if (classDescriptor.getKind() != ClassKind.TRAIT) {
|
||||
if (classDescriptor.getKind() != ClassKind.INTERFACE) {
|
||||
if (supertypeOwner.getKind() == ClassKind.ENUM_CLASS) {
|
||||
trace.report(CLASS_IN_SUPERTYPE_FOR_ENUM.on(typeReference));
|
||||
}
|
||||
else if (supertypeOwner.getKind() == ClassKind.TRAIT &&
|
||||
else if (supertypeOwner.getKind() == ClassKind.INTERFACE &&
|
||||
!classAppeared && !TypesPackage.isDynamic(supertype) /* avoid duplicate diagnostics */) {
|
||||
trace.report(TRAIT_WITH_SUPERCLASS.on(typeReference));
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ public class DeclarationsChecker {
|
||||
checkPrimaryConstructor(aClass, classDescriptor);
|
||||
checkTypeParameters(aClass);
|
||||
|
||||
if (aClass.isTrait()) {
|
||||
if (aClass.isInterface()) {
|
||||
checkTraitModifiers(aClass);
|
||||
checkConstructorInTrait(aClass);
|
||||
}
|
||||
@@ -380,7 +380,7 @@ public class DeclarationsChecker {
|
||||
trace.report(ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS.on(property, name != null ? name : "", classDescriptor));
|
||||
return;
|
||||
}
|
||||
if (classDescriptor.getKind() == ClassKind.TRAIT) {
|
||||
if (classDescriptor.getKind() == ClassKind.INTERFACE) {
|
||||
trace.report(ABSTRACT_MODIFIER_IN_TRAIT.on(property));
|
||||
}
|
||||
}
|
||||
@@ -416,7 +416,7 @@ public class DeclarationsChecker {
|
||||
return;
|
||||
}
|
||||
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
||||
boolean inTrait = containingDeclaration instanceof ClassDescriptor && ((ClassDescriptor)containingDeclaration).getKind() == ClassKind.TRAIT;
|
||||
boolean inTrait = containingDeclaration instanceof ClassDescriptor && ((ClassDescriptor)containingDeclaration).getKind() == ClassKind.INTERFACE;
|
||||
JetExpression initializer = property.getInitializer();
|
||||
JetPropertyDelegate delegate = property.getDelegate();
|
||||
boolean backingFieldRequired =
|
||||
@@ -473,7 +473,7 @@ public class DeclarationsChecker {
|
||||
checkDeclaredTypeInPublicMember(function, functionDescriptor);
|
||||
if (containingDescriptor instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) containingDescriptor;
|
||||
boolean inTrait = classDescriptor.getKind() == ClassKind.TRAIT;
|
||||
boolean inTrait = classDescriptor.getKind() == ClassKind.INTERFACE;
|
||||
if (hasAbstractModifier && !classCanHaveAbstractMembers(classDescriptor)) {
|
||||
trace.report(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(function, functionDescriptor.getName().asString(), classDescriptor));
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
private static boolean isNotTrait(@Nullable DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
ClassKind kind = ((ClassDescriptor) descriptor).getKind();
|
||||
return kind != ClassKind.TRAIT;
|
||||
return kind != ClassKind.INTERFACE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class DescriptorResolver {
|
||||
private boolean containsClass(Collection<JetType> result) {
|
||||
for (JetType type : result) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() != ClassKind.TRAIT) {
|
||||
if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() != ClassKind.INTERFACE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -331,7 +331,7 @@ public class DescriptorResolver {
|
||||
public static Modality getDefaultModality(DeclarationDescriptor containingDescriptor, Visibility visibility, boolean isBodyPresent) {
|
||||
Modality defaultModality;
|
||||
if (containingDescriptor instanceof ClassDescriptor) {
|
||||
boolean isTrait = ((ClassDescriptor) containingDescriptor).getKind() == ClassKind.TRAIT;
|
||||
boolean isTrait = ((ClassDescriptor) containingDescriptor).getKind() == ClassKind.INTERFACE;
|
||||
boolean isDefinitelyAbstract = isTrait && !isBodyPresent;
|
||||
Modality basicModality = isTrait && !Visibilities.isPrivate(visibility) ? Modality.OPEN : Modality.FINAL;
|
||||
defaultModality = isDefinitelyAbstract ? Modality.ABSTRACT : basicModality;
|
||||
|
||||
@@ -204,7 +204,7 @@ public class LazyTopDownAnalyzer {
|
||||
if (DescriptorUtils.isSingletonOrAnonymousObject(classDescriptor)) {
|
||||
trace.report(SECONDARY_CONSTRUCTOR_IN_OBJECT.on((JetSecondaryConstructor) jetDeclaration));
|
||||
}
|
||||
else if (classDescriptor.getKind() == ClassKind.TRAIT) {
|
||||
else if (classDescriptor.getKind() == ClassKind.INTERFACE) {
|
||||
trace.report(CONSTRUCTOR_IN_TRAIT.on(jetDeclaration));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class JetClassInfo extends JetClassOrObjectInfo<JetClass> {
|
||||
if (element instanceof JetEnumEntry) {
|
||||
this.kind = ClassKind.ENUM_ENTRY;
|
||||
}
|
||||
else if (element.isTrait()) {
|
||||
this.kind = ClassKind.TRAIT;
|
||||
else if (element.isInterface()) {
|
||||
this.kind = ClassKind.INTERFACE;
|
||||
}
|
||||
else if (element.isAnnotation()) {
|
||||
this.kind = ClassKind.ANNOTATION_CLASS;
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
this.modality = Modality.FINAL;
|
||||
}
|
||||
else {
|
||||
Modality defaultModality = kind == ClassKind.TRAIT ? Modality.ABSTRACT : Modality.FINAL;
|
||||
Modality defaultModality = kind == ClassKind.INTERFACE ? Modality.ABSTRACT : Modality.FINAL;
|
||||
this.modality = resolveModalityFromModifiers(modifierList, defaultModality);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class CastDiagnosticsUtil {
|
||||
|
||||
private static boolean isTrait(@NotNull JetType type) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
return descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() == ClassKind.TRAIT;
|
||||
return descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() == ClassKind.INTERFACE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-2
@@ -25,7 +25,6 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiPackage;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.intellij.psi.impl.compiled.ClsFileImpl;
|
||||
import com.intellij.psi.impl.java.stubs.PsiJavaFileStub;
|
||||
import com.intellij.psi.impl.light.LightClass;
|
||||
@@ -500,7 +499,7 @@ public class KotlinLightClassForExplicitDeclaration extends KotlinWrappingLightC
|
||||
public boolean isInterface() {
|
||||
if (!(classOrObject instanceof JetClass)) return false;
|
||||
JetClass jetClass = (JetClass) classOrObject;
|
||||
return jetClass.isTrait() || jetClass.isAnnotation();
|
||||
return jetClass.isInterface() || jetClass.isAnnotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -235,7 +235,7 @@ public class DescriptorValidator {
|
||||
validateTypeParameters(collector, descriptor.getTypeConstructor().getParameters());
|
||||
|
||||
Collection<JetType> supertypes = descriptor.getTypeConstructor().getSupertypes();
|
||||
if (supertypes.isEmpty() && descriptor.getKind() != ClassKind.TRAIT
|
||||
if (supertypes.isEmpty() && descriptor.getKind() != ClassKind.INTERFACE
|
||||
&& !KotlinBuiltIns.isSpecialClassWithNoSupertypes(descriptor)) {
|
||||
report(collector, descriptor, "No supertypes for non-trait");
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public void testTraitModality(String classDeclaration, Modality expectedModality) {
|
||||
testClassModality(classDeclaration, ClassKind.TRAIT, expectedModality);
|
||||
testClassModality(classDeclaration, ClassKind.INTERFACE, expectedModality);
|
||||
}
|
||||
|
||||
public void testEnumModality(String classDeclaration, Modality expectedModality) {
|
||||
@@ -187,7 +187,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public void testFunctionModalityInTrait(String classWithFunction, Modality expectedModality) {
|
||||
testFunctionModality(classWithFunction, ClassKind.TRAIT, expectedModality);
|
||||
testFunctionModality(classWithFunction, ClassKind.INTERFACE, expectedModality);
|
||||
}
|
||||
|
||||
public void testPropertyModalityInClass(String classWithProperty, Modality expectedModality) {
|
||||
@@ -199,7 +199,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public void testPropertyModalityInTrait(String classWithProperty, Modality expectedModality) {
|
||||
testPropertyModality(classWithProperty, ClassKind.TRAIT, expectedModality);
|
||||
testPropertyModality(classWithProperty, ClassKind.INTERFACE, expectedModality);
|
||||
}
|
||||
|
||||
public void testPropertyAccessorModalityInClass(String classWithPropertyWithAccessor, Modality expectedModality) {
|
||||
@@ -207,7 +207,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public void testPropertyAccessorModalityInTrait(String classWithPropertyWithAccessor, Modality expectedModality) {
|
||||
testPropertyAccessorModality(classWithPropertyWithAccessor, ClassKind.TRAIT, expectedModality, true);
|
||||
testPropertyAccessorModality(classWithPropertyWithAccessor, ClassKind.INTERFACE, expectedModality, true);
|
||||
}
|
||||
|
||||
public void testPropertyAccessorModalityInClass(String classWithPropertyWithAccessor, Modality expectedModality, boolean isGetter) {
|
||||
@@ -215,7 +215,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public void testPropertyAccessorModalityInTrait(String classWithPropertyWithAccessor, Modality expectedModality, boolean isGetter) {
|
||||
testPropertyAccessorModality(classWithPropertyWithAccessor, ClassKind.TRAIT, expectedModality, isGetter);
|
||||
testPropertyAccessorModality(classWithPropertyWithAccessor, ClassKind.INTERFACE, expectedModality, isGetter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ class LazyJavaClassDescriptor(
|
||||
|
||||
private val kind = when {
|
||||
jClass.isAnnotationType() -> ClassKind.ANNOTATION_CLASS
|
||||
jClass.isInterface() -> ClassKind.TRAIT
|
||||
jClass.isInterface() -> ClassKind.INTERFACE
|
||||
jClass.isEnum() -> ClassKind.ENUM_CLASS
|
||||
else -> ClassKind.CLASS
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
public enum ClassKind {
|
||||
CLASS,
|
||||
TRAIT,
|
||||
INTERFACE,
|
||||
ENUM_CLASS,
|
||||
ENUM_ENTRY,
|
||||
ANNOTATION_CLASS,
|
||||
|
||||
@@ -988,7 +988,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
||||
if (!startFromName) {
|
||||
renderAnnotations(klass, builder);
|
||||
renderVisibility(klass.getVisibility(), builder);
|
||||
if (!(klass.getKind() == ClassKind.TRAIT && klass.getModality() == Modality.ABSTRACT
|
||||
if (!(klass.getKind() == ClassKind.INTERFACE && klass.getModality() == Modality.ABSTRACT
|
||||
|| klass.getKind().isSingleton() && klass.getModality() == Modality.FINAL)) {
|
||||
renderModality(klass.getModality(), builder);
|
||||
}
|
||||
@@ -1056,7 +1056,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
||||
switch (klass.getKind()) {
|
||||
case CLASS:
|
||||
return "class";
|
||||
case TRAIT:
|
||||
case INTERFACE:
|
||||
return "trait";
|
||||
case ENUM_CLASS:
|
||||
return "enum class";
|
||||
|
||||
@@ -303,7 +303,7 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
public static boolean isTrait(@Nullable DeclarationDescriptor descriptor) {
|
||||
return isKindOf(descriptor, ClassKind.TRAIT);
|
||||
return isKindOf(descriptor, ClassKind.INTERFACE);
|
||||
}
|
||||
|
||||
public static boolean isClass(@Nullable DeclarationDescriptor descriptor) {
|
||||
@@ -332,7 +332,7 @@ public class DescriptorUtils {
|
||||
Collection<JetType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
for (JetType type : superclassTypes) {
|
||||
ClassDescriptor superClassDescriptor = getClassDescriptorForType(type);
|
||||
if (superClassDescriptor.getKind() != ClassKind.TRAIT) {
|
||||
if (superClassDescriptor.getKind() != ClassKind.INTERFACE) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -361,7 +361,7 @@ public class DescriptorUtils {
|
||||
if (isAnonymousObject(classDescriptor)) {
|
||||
return Visibilities.INTERNAL;
|
||||
}
|
||||
assert classKind == ClassKind.CLASS || classKind == ClassKind.TRAIT || classKind == ClassKind.ANNOTATION_CLASS;
|
||||
assert classKind == ClassKind.CLASS || classKind == ClassKind.INTERFACE || classKind == ClassKind.ANNOTATION_CLASS;
|
||||
return Visibilities.PUBLIC;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class Flags {
|
||||
switch (kind) {
|
||||
case CLASS:
|
||||
return ProtoBuf.Class.Kind.CLASS;
|
||||
case TRAIT:
|
||||
case INTERFACE:
|
||||
return ProtoBuf.Class.Kind.TRAIT;
|
||||
case ENUM_CLASS:
|
||||
return ProtoBuf.Class.Kind.ENUM_CLASS;
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ fun visibility(visibility: ProtoBuf.Visibility) = when (visibility) {
|
||||
|
||||
public fun classKind(kind: ProtoBuf.Class.Kind): ClassKind = when (kind) {
|
||||
ProtoBuf.Class.Kind.CLASS -> ClassKind.CLASS
|
||||
ProtoBuf.Class.Kind.TRAIT -> ClassKind.TRAIT
|
||||
ProtoBuf.Class.Kind.TRAIT -> ClassKind.INTERFACE
|
||||
ProtoBuf.Class.Kind.ENUM_CLASS -> ClassKind.ENUM_CLASS
|
||||
ProtoBuf.Class.Kind.ENUM_ENTRY -> ClassKind.ENUM_ENTRY
|
||||
ProtoBuf.Class.Kind.ANNOTATION_CLASS -> ClassKind.ANNOTATION_CLASS
|
||||
|
||||
@@ -101,7 +101,7 @@ public final class JetDescriptorIconProvider {
|
||||
}
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
switch (((ClassDescriptor) descriptor).getKind()) {
|
||||
case TRAIT:
|
||||
case INTERFACE:
|
||||
return JetIcons.TRAIT;
|
||||
case ENUM_CLASS:
|
||||
return JetIcons.ENUM;
|
||||
|
||||
@@ -142,7 +142,7 @@ public class JetIconProvider extends IconProvider implements DumbAware {
|
||||
|
||||
if (psiElement instanceof JetClass) {
|
||||
JetClass jetClass = (JetClass) psiElement;
|
||||
if (jetClass.isTrait()) {
|
||||
if (jetClass.isInterface()) {
|
||||
return JetIcons.TRAIT;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ private object DeclarationKindDetector : JetVisitor<AnnotationHostKind?, Unit?>(
|
||||
|
||||
override fun visitDeclaration(d: JetDeclaration, _: Unit?) = null
|
||||
|
||||
override fun visitClass(d: JetClass, _: Unit?) = detect(d, if (d.isTrait()) "trait" else "class")
|
||||
override fun visitClass(d: JetClass, _: Unit?) = detect(d, if (d.isInterface()) "trait" else "class")
|
||||
|
||||
override fun visitNamedFunction(d: JetNamedFunction, _: Unit?) = detect(d, "fun")
|
||||
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ class TypeKindHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
@NotNull
|
||||
private static TextAttributesKey textAttributesKeyForClass(@NotNull ClassDescriptor descriptor) {
|
||||
switch (descriptor.getKind()) {
|
||||
case TRAIT:
|
||||
case INTERFACE:
|
||||
return JetHighlightingColors.TRAIT;
|
||||
case ANNOTATION_CLASS:
|
||||
return JetHighlightingColors.ANNOTATION;
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ class AllClassesCompletion(val parameters: CompletionParameters,
|
||||
if (psiClass!! !is KotlinLightClass) { // Kotlin class should have already been added as kotlin element before
|
||||
val kind = when {
|
||||
psiClass.isAnnotationType() -> ClassKind.ANNOTATION_CLASS
|
||||
psiClass.isInterface() -> ClassKind.TRAIT
|
||||
psiClass.isInterface() -> ClassKind.INTERFACE
|
||||
psiClass.isEnum() -> ClassKind.ENUM_CLASS
|
||||
else -> ClassKind.CLASS
|
||||
}
|
||||
|
||||
+2
-2
@@ -153,7 +153,7 @@ class TypeInstantiationItems(
|
||||
val insertHandler: InsertHandler<LookupElement>
|
||||
val typeText = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(classifier) + IdeDescriptorRenderers.SOURCE_CODE.renderTypeArguments(typeArgsToUse)
|
||||
if (isAbstract) {
|
||||
val constructorParenthesis = if (classifier.getKind() != ClassKind.TRAIT) "()" else ""
|
||||
val constructorParenthesis = if (classifier.getKind() != ClassKind.INTERFACE) "()" else ""
|
||||
itemText += constructorParenthesis
|
||||
itemText = "object: " + itemText + "{...}"
|
||||
lookupString = "object"
|
||||
@@ -242,7 +242,7 @@ class TypeInstantiationItems(
|
||||
}
|
||||
|
||||
private fun addSamConstructorItem(collection: MutableCollection<LookupElement>, `class`: ClassDescriptor, tail: Tail?) {
|
||||
if (`class`.getKind() == ClassKind.TRAIT) {
|
||||
if (`class`.getKind() == ClassKind.INTERFACE) {
|
||||
val container = `class`.getContainingDeclaration()
|
||||
val scope = when (container) {
|
||||
is PackageFragmentDescriptor -> container.getMemberScope()
|
||||
|
||||
@@ -94,7 +94,7 @@ public class JetAddFunctionToClassifierAction implements QuestionAction {
|
||||
}
|
||||
|
||||
String functionBody = "";
|
||||
if (typeDescriptor.getKind() != ClassKind.TRAIT && functionDescriptor.getModality() != Modality.ABSTRACT) {
|
||||
if (typeDescriptor.getKind() != ClassKind.INTERFACE && functionDescriptor.getModality() != Modality.ABSTRACT) {
|
||||
functionBody = "{}";
|
||||
JetType returnType = functionDescriptor.getReturnType();
|
||||
if (returnType == null || !KotlinBuiltIns.isUnit(returnType)) {
|
||||
|
||||
@@ -371,7 +371,7 @@ public class JetPositionManager(private val myDebugProcess: DebugProcess) : Mult
|
||||
return null
|
||||
}
|
||||
|
||||
if (jetClass is JetClass && jetClass.isTrait()) {
|
||||
if (jetClass is JetClass && jetClass.isInterface()) {
|
||||
return typeMapper.mapTraitImpl(classDescriptor).getInternalName()
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class JetElementDescriptionProvider : ElementDescriptionProvider {
|
||||
val targetElement = element.unwrapped
|
||||
|
||||
fun elementKind() = when (targetElement) {
|
||||
is JetClass -> if (targetElement.isTrait()) "trait" else "class"
|
||||
is JetClass -> if (targetElement.isInterface()) "trait" else "class"
|
||||
is JetObjectDeclaration -> "object"
|
||||
is JetNamedFunction -> "function"
|
||||
is JetSecondaryConstructor -> "constructor"
|
||||
|
||||
@@ -136,7 +136,7 @@ private fun collectSuperDeclarationMarkers(declaration: JetDeclaration, result:
|
||||
}
|
||||
|
||||
private fun collectInheritedClassMarker(element: JetClass, result: MutableCollection<LineMarkerInfo<*>>) {
|
||||
val isTrait = element.isTrait()
|
||||
val isTrait = element.isInterface()
|
||||
if (!(isTrait || element.hasModifier(JetTokens.OPEN_KEYWORD) || element.hasModifier(JetTokens.ABSTRACT_KEYWORD))) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -123,6 +123,6 @@ public fun isImplemented(declaration: JetNamedDeclaration): Boolean {
|
||||
|
||||
if (parent !is JetClass) return false
|
||||
|
||||
return (parent as JetClass).isTrait() && (declaration !is JetDeclarationWithBody || !declaration.hasBody()) && (declaration !is JetWithExpressionInitializer || !declaration.hasInitializer())
|
||||
return (parent as JetClass).isInterface() && (declaration !is JetDeclarationWithBody || !declaration.hasBody()) && (declaration !is JetWithExpressionInitializer || !declaration.hasInitializer())
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class JetAnonymousSuperMacro extends Macro {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) descriptor;
|
||||
if (!classDescriptor.getModality().isOverridable()) continue;
|
||||
ClassKind kind = classDescriptor.getKind();
|
||||
if (kind == ClassKind.TRAIT || kind == ClassKind.CLASS) {
|
||||
if (kind == ClassKind.INTERFACE || kind == ClassKind.CLASS) {
|
||||
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||
if (declaration != null) {
|
||||
result.add((PsiNamedElement) declaration);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class AddFunctionToSupertypeFix extends JetHintAction<JetNamedFunction> {
|
||||
) {
|
||||
// TODO: support for generics.
|
||||
Modality modality = typeDescriptor.getModality();
|
||||
if (typeDescriptor.getKind() == ClassKind.TRAIT) {
|
||||
if (typeDescriptor.getKind() == ClassKind.INTERFACE) {
|
||||
modality = Modality.OPEN;
|
||||
}
|
||||
return functionDescriptor.copy(
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class AddOpenModifierToClassDeclarationFix extends JetIntentionAction<Jet
|
||||
}
|
||||
if (target instanceof JetClass && QuickFixUtil.canModifyElement(target)) {
|
||||
classDeclaration = (JetClass) target;
|
||||
return !(classDeclaration.isEnum() || classDeclaration.isTrait());
|
||||
return !(classDeclaration.isEnum() || classDeclaration.isInterface());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -452,7 +452,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
val declaration : JetNamedDeclaration = when (callableInfo.kind) {
|
||||
CallableKind.FUNCTION, CallableKind.SECONDARY_CONSTRUCTOR -> {
|
||||
val body = when {
|
||||
containingElement is JetClass && containingElement.isTrait() && !config.isExtension -> ""
|
||||
containingElement is JetClass && containingElement.isInterface() && !config.isExtension -> ""
|
||||
else -> "{}"
|
||||
}
|
||||
if (callableInfo.kind == CallableKind.FUNCTION) {
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ private abstract class TypeExpression(public val typeCandidates: List<TypeCandid
|
||||
override val cachedLookupElements: Array<LookupElement> =
|
||||
typeCandidates.map {
|
||||
val descriptor = it.theType.getConstructor().getDeclarationDescriptor() as ClassDescriptor
|
||||
val text = it.renderedType!! + if (descriptor.getKind() == ClassKind.TRAIT) "" else "()"
|
||||
val text = it.renderedType!! + if (descriptor.getKind() == ClassKind.INTERFACE) "" else "()"
|
||||
LookupElementBuilder.create(it, text)
|
||||
}.copyToArray()
|
||||
}
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ private fun JetExpression.getInheritableTypeInfo(
|
||||
when (classKind) {
|
||||
ClassKind.ENUM_ENTRY -> isEnum && containingDeclaration == DescriptorToSourceUtils.descriptorToDeclaration(descriptor)
|
||||
ClassKind.TRAIT -> containingDeclaration !is PsiClass
|
||||
|| (descriptor as? ClassDescriptor)?.getKind() == ClassDescriptorKind.TRAIT
|
||||
|| (descriptor as? ClassDescriptor)?.getKind() == ClassDescriptorKind.INTERFACE
|
||||
else -> canHaveSubtypes
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -92,13 +92,13 @@ object CreateParameterActionFactory: JetSingleIntentionActionFactory() {
|
||||
it is JetClassInitializer -> it.getParent()?.getParent() as? JetClass
|
||||
it is JetDelegationSpecifier -> {
|
||||
val klass = it.getStrictParentOfType<JetClass>()
|
||||
if (klass != null && !klass.isTrait() && klass !is JetEnumEntry) klass else null
|
||||
if (klass != null && !klass.isInterface() && klass !is JetEnumEntry) klass else null
|
||||
}
|
||||
it is JetClassBody -> {
|
||||
val klass = it.getParent() as? JetClass
|
||||
when {
|
||||
klass is JetEnumEntry -> chooseContainingClass(klass)
|
||||
klass != null && klass.isTrait() -> null
|
||||
klass != null && klass.isInterface() -> null
|
||||
else -> klass
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ public class JetChangeSignature(project: Project,
|
||||
private fun preferContainedInClass(descriptorsForSignatureChange: Collection<FunctionDescriptor>): FunctionDescriptor {
|
||||
for (descriptor in descriptorsForSignatureChange) {
|
||||
val containingDeclaration = descriptor.getContainingDeclaration()
|
||||
if (containingDeclaration is ClassDescriptor && containingDeclaration.getKind() != ClassKind.TRAIT) {
|
||||
if (containingDeclaration is ClassDescriptor && containingDeclaration.getKind() != ClassKind.INTERFACE) {
|
||||
return descriptor
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ public class JetChangeSignatureData(
|
||||
override fun canChangeVisibility(): Boolean {
|
||||
if (DescriptorUtils.isLocal(baseDescriptor)) return false;
|
||||
val parent = baseDescriptor.getContainingDeclaration()
|
||||
return !(baseDescriptor is AnonymousFunctionDescriptor || parent is ClassDescriptor && parent.getKind() == ClassKind.TRAIT)
|
||||
return !(baseDescriptor is AnonymousFunctionDescriptor || parent is ClassDescriptor && parent.getKind() == ClassKind.INTERFACE)
|
||||
}
|
||||
|
||||
override fun canChangeParameters(): Boolean {
|
||||
|
||||
+1
-1
@@ -347,7 +347,7 @@ enum class ExtractionTarget(val name: String) {
|
||||
companion object {
|
||||
fun checkNotTrait(descriptor: ExtractableCodeDescriptor): Boolean {
|
||||
val parent = descriptor.extractionData.targetSibling.getStrictParentOfType<JetDeclaration>()
|
||||
return !(parent is JetClass && parent.isTrait())
|
||||
return !(parent is JetClass && parent.isInterface())
|
||||
}
|
||||
|
||||
fun checkSimpleBody(descriptor: ExtractableCodeDescriptor): Boolean {
|
||||
|
||||
+1
-1
@@ -802,7 +802,7 @@ fun ExtractionData.getDefaultVisibility(): String {
|
||||
if (!isVisibilityApplicable()) return ""
|
||||
|
||||
val parent = targetSibling.getStrictParentOfType<JetDeclaration>()
|
||||
if (parent is JetClass && parent.isTrait()) return ""
|
||||
if (parent is JetClass && parent.isInterface()) return ""
|
||||
|
||||
return "private"
|
||||
}
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ fun selectNewParameterContext(
|
||||
|
||||
(if (stopAt != null) parent.parents(withItself = false).takeWhile { it != stopAt } else parents)
|
||||
.filter {
|
||||
((it is JetClass && !it.isTrait() && it !is JetEnumEntry) || it is JetNamedFunction || it is JetSecondaryConstructor) &&
|
||||
((it is JetClass && !it.isInterface() && it !is JetEnumEntry) || it is JetNamedFunction || it is JetSecondaryConstructor) &&
|
||||
((it as JetNamedDeclaration).getValueParameterList() != null || it.getNameIdentifier() != null)
|
||||
}
|
||||
.toList()
|
||||
|
||||
@@ -510,7 +510,7 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember {
|
||||
val factory = PsiElementFactory.SERVICE.getInstance(klass.getProject())
|
||||
val javaClassToAdd = when (kind) {
|
||||
ClassKind.CLASS -> factory.createClass(klass.getName())
|
||||
ClassKind.TRAIT -> factory.createInterface(klass.getName())
|
||||
ClassKind.INTERFACE -> factory.createInterface(klass.getName())
|
||||
ClassKind.ANNOTATION_CLASS -> factory.createAnnotationType(klass.getName())
|
||||
ClassKind.ENUM_CLASS -> factory.createEnum(klass.getName())
|
||||
else -> throw AssertionError("Unexpected class kind: ${klass.getElementTextWithContext()}")
|
||||
|
||||
@@ -50,6 +50,6 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
List<JetDeclaration> declarations = ((JetFile) psiFile).getDeclarations();
|
||||
JetClass jetClass = (JetClass) declarations.get(0);
|
||||
KotlinClassStub stub = JetStubElementTypes.CLASS.createStub(jetClass, null);
|
||||
assertEquals(true, stub.isTrait());
|
||||
assertEquals(true, stub.isInterface());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ public final class Namer {
|
||||
@NotNull
|
||||
public JsExpression classCreateInvocation(@NotNull ClassDescriptor descriptor) {
|
||||
switch (descriptor.getKind()) {
|
||||
case TRAIT:
|
||||
case INTERFACE:
|
||||
return traitCreationMethodReference();
|
||||
case ENUM_CLASS:
|
||||
return enumClassCreationMethodReference();
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ public final class ClassTranslator extends AbstractTranslator {
|
||||
}
|
||||
|
||||
private boolean isTrait() {
|
||||
return descriptor.getKind().equals(ClassKind.TRAIT);
|
||||
return descriptor.getKind().equals(ClassKind.INTERFACE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -89,7 +89,7 @@ public final class JsDescriptorUtils {
|
||||
ClassDescriptor classDescriptor = getClassDescriptorForType(type);
|
||||
|
||||
return !FAKE_CLASSES.contains(getFqNameSafe(classDescriptor).asString()) &&
|
||||
!(classDescriptor.getKind() == ClassKind.TRAIT && isNativeObject(classDescriptor));
|
||||
!(classDescriptor.getKind() == ClassKind.INTERFACE && isNativeObject(classDescriptor));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user