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