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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user