Minor. Rename constants: TRAIT_IMPL* -> DEFAULT_IMPLS*
This commit is contained in:
@@ -179,7 +179,7 @@ public class AsmUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isStaticKind(OwnerKind kind) {
|
public static boolean isStaticKind(OwnerKind kind) {
|
||||||
return kind == OwnerKind.PACKAGE || kind == OwnerKind.TRAIT_IMPL;
|
return kind == OwnerKind.PACKAGE || kind == OwnerKind.DEFAULT_IMPLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMethodAsmFlags(FunctionDescriptor functionDescriptor, OwnerKind kind) {
|
public static int getMethodAsmFlags(FunctionDescriptor functionDescriptor, OwnerKind kind) {
|
||||||
@@ -908,6 +908,6 @@ public class AsmUtil {
|
|||||||
public static int getReceiverIndex(@NotNull CodegenContext context, @NotNull CallableMemberDescriptor descriptor) {
|
public static int getReceiverIndex(@NotNull CodegenContext context, @NotNull CallableMemberDescriptor descriptor) {
|
||||||
OwnerKind kind = context.getContextKind();
|
OwnerKind kind = context.getContextKind();
|
||||||
//Trait always should have this descriptor
|
//Trait always should have this descriptor
|
||||||
return kind != OwnerKind.TRAIT_IMPL && isStaticMethod(kind, descriptor) ? 0 : 1;
|
return kind != OwnerKind.DEFAULT_IMPLS && isStaticMethod(kind, descriptor) ? 0 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen<JetClassOrObject> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void generateBody() {
|
protected void generateBody() {
|
||||||
if (kind != OwnerKind.TRAIT_IMPL) {
|
if (kind != OwnerKind.DEFAULT_IMPLS) {
|
||||||
//generate nested classes first and only then generate class body. It necessary to access to nested CodegenContexts
|
//generate nested classes first and only then generate class body. It necessary to access to nested CodegenContexts
|
||||||
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
||||||
if (shouldProcessFirst(declaration)) {
|
if (shouldProcessFirst(declaration)) {
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
if (declaration instanceof JetClass && ((JetClass) declaration).isInterface()) {
|
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.DEFAULT_IMPLS);
|
||||||
new TraitImplBodyCodegen(declaration, traitImplContext, traitImplBuilder, state, parentCodegen).generate();
|
new TraitImplBodyCodegen(declaration, traitImplContext, traitImplBuilder, state, parentCodegen).generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2012,7 +2012,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
|
|
||||||
boolean directToField =
|
boolean directToField =
|
||||||
(expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER || isSyntheticField)
|
(expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER || isSyntheticField)
|
||||||
&& contextKind() != OwnerKind.TRAIT_IMPL;
|
&& contextKind() != OwnerKind.DEFAULT_IMPLS;
|
||||||
JetSuperExpression superExpression =
|
JetSuperExpression superExpression =
|
||||||
resolvedCall == null ? null : CallResolverUtilPackage.getSuperCallExpression(resolvedCall.getCall());
|
resolvedCall == null ? null : CallResolverUtilPackage.getSuperCallExpression(resolvedCall.getCall());
|
||||||
propertyDescriptor = context.accessibleDescriptor(propertyDescriptor, superExpression);
|
propertyDescriptor = context.accessibleDescriptor(propertyDescriptor, superExpression);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class FunctionCodegen {
|
|||||||
assert functionDescriptor != null : "No descriptor for function " + function.getText() + "\n" +
|
assert functionDescriptor != null : "No descriptor for function " + function.getText() + "\n" +
|
||||||
"in " + function.getContainingFile().getVirtualFile();
|
"in " + function.getContainingFile().getVirtualFile();
|
||||||
|
|
||||||
if (owner.getContextKind() != OwnerKind.TRAIT_IMPL || function.hasBody()) {
|
if (owner.getContextKind() != OwnerKind.DEFAULT_IMPLS || function.hasBody()) {
|
||||||
generateMethod(OtherOrigin(function, functionDescriptor), functionDescriptor,
|
generateMethod(OtherOrigin(function, functionDescriptor), functionDescriptor,
|
||||||
new FunctionGenerationStrategy.FunctionDefault(state, functionDescriptor, function));
|
new FunctionGenerationStrategy.FunctionDefault(state, functionDescriptor, function));
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ public class FunctionCodegen {
|
|||||||
OwnerKind contextKind = methodContext.getContextKind();
|
OwnerKind contextKind = methodContext.getContextKind();
|
||||||
if (isTrait(functionDescriptor.getContainingDeclaration()) &&
|
if (isTrait(functionDescriptor.getContainingDeclaration()) &&
|
||||||
functionDescriptor.getVisibility() == Visibilities.PRIVATE &&
|
functionDescriptor.getVisibility() == Visibilities.PRIVATE &&
|
||||||
contextKind != OwnerKind.TRAIT_IMPL) {
|
contextKind != OwnerKind.DEFAULT_IMPLS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,7 +504,7 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
public void generateBridges(@NotNull FunctionDescriptor descriptor) {
|
public void generateBridges(@NotNull FunctionDescriptor descriptor) {
|
||||||
if (descriptor instanceof ConstructorDescriptor) return;
|
if (descriptor instanceof ConstructorDescriptor) return;
|
||||||
if (owner.getContextKind() == OwnerKind.TRAIT_IMPL) return;
|
if (owner.getContextKind() == OwnerKind.DEFAULT_IMPLS) return;
|
||||||
if (isTrait(descriptor.getContainingDeclaration())) return;
|
if (isTrait(descriptor.getContainingDeclaration())) return;
|
||||||
|
|
||||||
// equals(Any?), hashCode(), toString() never need bridges
|
// equals(Any?), hashCode(), toString() never need bridges
|
||||||
@@ -585,7 +585,7 @@ public class FunctionCodegen {
|
|||||||
) {
|
) {
|
||||||
DeclarationDescriptor contextClass = owner.getContextDescriptor().getContainingDeclaration();
|
DeclarationDescriptor contextClass = owner.getContextDescriptor().getContainingDeclaration();
|
||||||
|
|
||||||
if (kind != OwnerKind.TRAIT_IMPL && isTrait(contextClass)) {
|
if (kind != OwnerKind.DEFAULT_IMPLS && isTrait(contextClass)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1423,7 +1423,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
ClassDescriptor containingTrait = (ClassDescriptor) containingDeclaration;
|
ClassDescriptor containingTrait = (ClassDescriptor) containingDeclaration;
|
||||||
Type traitImplType = typeMapper.mapTraitImpl(containingTrait);
|
Type traitImplType = typeMapper.mapTraitImpl(containingTrait);
|
||||||
|
|
||||||
Method traitMethod = typeMapper.mapSignature(traitFun.getOriginal(), OwnerKind.TRAIT_IMPL).getAsmMethod();
|
Method traitMethod = typeMapper.mapSignature(traitFun.getOriginal(), OwnerKind.DEFAULT_IMPLS).getAsmMethod();
|
||||||
|
|
||||||
Type[] argTypes = signature.getAsmMethod().getArgumentTypes();
|
Type[] argTypes = signature.getAsmMethod().getArgumentTypes();
|
||||||
Type[] originalArgTypes = traitMethod.getArgumentTypes();
|
Type[] originalArgTypes = traitMethod.getArgumentTypes();
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ import java.io.File;
|
|||||||
|
|
||||||
import static org.jetbrains.kotlin.descriptors.Modality.ABSTRACT;
|
import static org.jetbrains.kotlin.descriptors.Modality.ABSTRACT;
|
||||||
import static org.jetbrains.kotlin.descriptors.Modality.FINAL;
|
import static org.jetbrains.kotlin.descriptors.Modality.FINAL;
|
||||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isTrait;
|
|
||||||
|
|
||||||
public class JvmCodegenUtil {
|
public class JvmCodegenUtil {
|
||||||
|
|
||||||
@@ -82,7 +81,7 @@ public class JvmCodegenUtil {
|
|||||||
(((context.hasThisDescriptor() && containingDeclaration == context.getThisDescriptor()) ||
|
(((context.hasThisDescriptor() && containingDeclaration == context.getThisDescriptor()) ||
|
||||||
(context.getParentContext() instanceof PackageContext
|
(context.getParentContext() instanceof PackageContext
|
||||||
&& isSamePackageInSameModule(context.getParentContext().getContextDescriptor(), containingDeclaration)))
|
&& isSamePackageInSameModule(context.getParentContext().getContextDescriptor(), containingDeclaration)))
|
||||||
&& context.getContextKind() != OwnerKind.TRAIT_IMPL);
|
&& context.getContextKind() != OwnerKind.DEFAULT_IMPLS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSamePackageInSameModule(
|
private static boolean isSamePackageInSameModule(
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
|
|||||||
if (aClass instanceof JetClass && ((JetClass) aClass).isInterface()) {
|
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.DEFAULT_IMPLS, state);
|
||||||
new TraitImplBodyCodegen(aClass, traitImplContext, traitImplBuilder, state, parentCodegen).generate();
|
new TraitImplBodyCodegen(aClass, traitImplContext, traitImplBuilder, state, parentCodegen).generate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ public enum OwnerKind {
|
|||||||
|
|
||||||
IMPLEMENTATION,
|
IMPLEMENTATION,
|
||||||
|
|
||||||
TRAIT_IMPL
|
DEFAULT_IMPLS
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class PropertyCodegen {
|
|||||||
@Nullable JetPropertyAccessor getter,
|
@Nullable JetPropertyAccessor getter,
|
||||||
@Nullable JetPropertyAccessor setter
|
@Nullable JetPropertyAccessor setter
|
||||||
) {
|
) {
|
||||||
assert kind == OwnerKind.PACKAGE || kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.TRAIT_IMPL
|
assert kind == OwnerKind.PACKAGE || kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.DEFAULT_IMPLS
|
||||||
: "Generating property with a wrong kind (" + kind + "): " + descriptor;
|
: "Generating property with a wrong kind (" + kind + "): " + descriptor;
|
||||||
|
|
||||||
String implClassName = CodegenContextUtil.getImplementationClassShortName(context);
|
String implClassName = CodegenContextUtil.getImplementationClassShortName(context);
|
||||||
@@ -154,7 +154,7 @@ public class PropertyCodegen {
|
|||||||
boolean isDefaultAccessor = accessor == null || !accessor.hasBody();
|
boolean isDefaultAccessor = accessor == null || !accessor.hasBody();
|
||||||
|
|
||||||
// Don't generate accessors for trait properties with default accessors in TRAIT_IMPL
|
// Don't generate accessors for trait properties with default accessors in TRAIT_IMPL
|
||||||
if (kind == OwnerKind.TRAIT_IMPL && isDefaultAccessor) return false;
|
if (kind == OwnerKind.DEFAULT_IMPLS && isDefaultAccessor) return false;
|
||||||
|
|
||||||
if (declaration == null) return true;
|
if (declaration == null) return true;
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ public class PropertyCodegen {
|
|||||||
|
|
||||||
private boolean hasBackingField(@NotNull JetNamedDeclaration p, @NotNull PropertyDescriptor descriptor) {
|
private boolean hasBackingField(@NotNull JetNamedDeclaration p, @NotNull PropertyDescriptor descriptor) {
|
||||||
return !isInterface(descriptor.getContainingDeclaration()) &&
|
return !isInterface(descriptor.getContainingDeclaration()) &&
|
||||||
kind != OwnerKind.TRAIT_IMPL &&
|
kind != OwnerKind.DEFAULT_IMPLS &&
|
||||||
!Boolean.FALSE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor));
|
!Boolean.FALSE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ public class PropertyCodegen {
|
|||||||
@NotNull PropertyDescriptor descriptor,
|
@NotNull PropertyDescriptor descriptor,
|
||||||
@NotNull Annotations annotations
|
@NotNull Annotations annotations
|
||||||
) {
|
) {
|
||||||
if (isInterface(descriptor.getContainingDeclaration()) || kind == OwnerKind.TRAIT_IMPL) {
|
if (isInterface(descriptor.getContainingDeclaration()) || kind == OwnerKind.DEFAULT_IMPLS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ public class PropertyCodegen {
|
|||||||
String name = JvmAbi.getSyntheticMethodNameForAnnotatedProperty(descriptor.getName());
|
String name = JvmAbi.getSyntheticMethodNameForAnnotatedProperty(descriptor.getName());
|
||||||
String desc = receiver == null ? "()V" : "(" + typeMapper.mapType(receiver.getType()) + ")V";
|
String desc = receiver == null ? "()V" : "(" + typeMapper.mapType(receiver.getType()) + ")V";
|
||||||
|
|
||||||
if (!isTrait(context.getContextDescriptor()) || kind == OwnerKind.TRAIT_IMPL) {
|
if (!isTrait(context.getContextDescriptor()) || kind == OwnerKind.DEFAULT_IMPLS) {
|
||||||
int flags = ACC_DEPRECATED | ACC_FINAL | ACC_PRIVATE | ACC_STATIC | ACC_SYNTHETIC;
|
int flags = ACC_DEPRECATED | ACC_FINAL | ACC_PRIVATE | ACC_STATIC | ACC_SYNTHETIC;
|
||||||
MethodVisitor mv = v.newMethod(OtherOrigin(descriptor), flags, name, desc, null, null);
|
MethodVisitor mv = v.newMethod(OtherOrigin(descriptor), flags, name, desc, null, null);
|
||||||
AnnotationCodegen.forMethod(mv, typeMapper)
|
AnnotationCodegen.forMethod(mv, typeMapper)
|
||||||
@@ -264,7 +264,7 @@ public class PropertyCodegen {
|
|||||||
v.getSerializationBindings().put(IMPL_CLASS_NAME_FOR_CALLABLE, descriptor, shortNameByAsmType(tImplType));
|
v.getSerializationBindings().put(IMPL_CLASS_NAME_FOR_CALLABLE, descriptor, shortNameByAsmType(tImplType));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind != OwnerKind.TRAIT_IMPL) {
|
if (kind != OwnerKind.DEFAULT_IMPLS) {
|
||||||
v.getSerializationBindings().put(SYNTHETIC_METHOD_FOR_PROPERTY, descriptor, new Method(name, desc));
|
v.getSerializationBindings().put(SYNTHETIC_METHOD_FOR_PROPERTY, descriptor, new Method(name, desc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -595,7 +595,7 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
CodegenContext parent = getContext(descriptor.getContainingDeclaration(), state);
|
CodegenContext parent = getContext(descriptor.getContainingDeclaration(), state);
|
||||||
|
|
||||||
if (descriptor instanceof ClassDescriptor) {
|
if (descriptor instanceof ClassDescriptor) {
|
||||||
OwnerKind kind = DescriptorUtils.isTrait(descriptor) ? OwnerKind.TRAIT_IMPL : OwnerKind.IMPLEMENTATION;
|
OwnerKind kind = DescriptorUtils.isTrait(descriptor) ? OwnerKind.DEFAULT_IMPLS : OwnerKind.IMPLEMENTATION;
|
||||||
return parent.intoClass((ClassDescriptor) descriptor, kind, state);
|
return parent.intoClass((ClassDescriptor) descriptor, kind, state);
|
||||||
}
|
}
|
||||||
else if (descriptor instanceof ScriptDescriptor) {
|
else if (descriptor instanceof ScriptDescriptor) {
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ public class InlineCodegenUtil {
|
|||||||
if (isTrait(containerDescriptor)) {
|
if (isTrait(containerDescriptor)) {
|
||||||
FqName relativeClassName = classId.getRelativeClassName();
|
FqName relativeClassName = classId.getRelativeClassName();
|
||||||
//TODO test nested trait fun inlining
|
//TODO test nested trait fun inlining
|
||||||
classId = new ClassId(classId.getPackageFqName(), Name.identifier(relativeClassName.shortName().asString() + JvmAbi.TRAIT_IMPL_SUFFIX));
|
classId = new ClassId(classId.getPackageFqName(), Name.identifier(relativeClassName.shortName().asString() + JvmAbi.DEFAULT_IMPLS_SUFFIX));
|
||||||
}
|
}
|
||||||
return classId;
|
return classId;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
|||||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider
|
||||||
|
|
||||||
private val EXTERNAL_SOURCES_KINDS = arrayOf(
|
private val EXTERNAL_SOURCES_KINDS = arrayOf(
|
||||||
JvmDeclarationOriginKind.DELEGATION_TO_TRAIT_IMPL,
|
JvmDeclarationOriginKind.DELEGATION_TO_DEFAULT_IMPLS,
|
||||||
JvmDeclarationOriginKind.DELEGATION,
|
JvmDeclarationOriginKind.DELEGATION,
|
||||||
JvmDeclarationOriginKind.BRIDGE)
|
JvmDeclarationOriginKind.BRIDGE)
|
||||||
|
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ public class JetTypeMapper {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Type mapTraitImpl(@NotNull ClassDescriptor descriptor) {
|
public Type mapTraitImpl(@NotNull ClassDescriptor descriptor) {
|
||||||
return Type.getObjectType(mapType(descriptor).getInternalName() + JvmAbi.TRAIT_IMPL_SUFFIX);
|
return Type.getObjectType(mapType(descriptor).getInternalName() + JvmAbi.DEFAULT_IMPLS_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -632,7 +632,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
invokeOpcode = INVOKESTATIC;
|
invokeOpcode = INVOKESTATIC;
|
||||||
signature = mapSignature(descriptor.getOriginal(), OwnerKind.TRAIT_IMPL);
|
signature = mapSignature(descriptor.getOriginal(), OwnerKind.DEFAULT_IMPLS);
|
||||||
owner = mapTraitImpl(currentOwner);
|
owner = mapTraitImpl(currentOwner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -900,7 +900,7 @@ public class JetTypeMapper {
|
|||||||
@NotNull BothSignatureWriter sw
|
@NotNull BothSignatureWriter sw
|
||||||
) {
|
) {
|
||||||
ClassDescriptor thisType;
|
ClassDescriptor thisType;
|
||||||
if (kind == OwnerKind.TRAIT_IMPL) {
|
if (kind == OwnerKind.DEFAULT_IMPLS) {
|
||||||
thisType = getTraitImplThisParameterClass((ClassDescriptor) descriptor.getContainingDeclaration());
|
thisType = getTraitImplThisParameterClass((ClassDescriptor) descriptor.getContainingDeclaration());
|
||||||
}
|
}
|
||||||
else if (isAccessor(descriptor) && descriptor.getDispatchReceiverParameter() != null) {
|
else if (isAccessor(descriptor) && descriptor.getDispatchReceiverParameter() != null) {
|
||||||
|
|||||||
+4
-4
@@ -36,8 +36,8 @@ public enum class JvmDeclarationOriginKind {
|
|||||||
OTHER,
|
OTHER,
|
||||||
PACKAGE_FACADE,
|
PACKAGE_FACADE,
|
||||||
PACKAGE_PART,
|
PACKAGE_PART,
|
||||||
TRAIT_IMPL,
|
INTERFACE_DEFAULT_IMPL,
|
||||||
DELEGATION_TO_TRAIT_IMPL,
|
DELEGATION_TO_DEFAULT_IMPLS,
|
||||||
DELEGATION,
|
DELEGATION,
|
||||||
BRIDGE,
|
BRIDGE,
|
||||||
MULTIFILE_CLASS,
|
MULTIFILE_CLASS,
|
||||||
@@ -78,9 +78,9 @@ public fun MultifileClass(representativeFile: JetFile?, descriptor: PackageFragm
|
|||||||
public fun MultifileClassPart(file: JetFile, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin =
|
public fun MultifileClassPart(file: JetFile, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin =
|
||||||
JvmDeclarationOrigin(MULTIFILE_CLASS_PART, file, descriptor)
|
JvmDeclarationOrigin(MULTIFILE_CLASS_PART, file, descriptor)
|
||||||
|
|
||||||
public fun TraitImpl(element: JetClassOrObject, descriptor: ClassDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(TRAIT_IMPL, element, descriptor)
|
public fun TraitImpl(element: JetClassOrObject, descriptor: ClassDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(INTERFACE_DEFAULT_IMPL, element, descriptor)
|
||||||
public fun DelegationToTraitImpl(element: PsiElement?, descriptor: FunctionDescriptor): JvmDeclarationOrigin =
|
public fun DelegationToTraitImpl(element: PsiElement?, descriptor: FunctionDescriptor): JvmDeclarationOrigin =
|
||||||
JvmDeclarationOrigin(DELEGATION_TO_TRAIT_IMPL, element, descriptor)
|
JvmDeclarationOrigin(DELEGATION_TO_DEFAULT_IMPLS, element, descriptor)
|
||||||
|
|
||||||
public fun Delegation(element: PsiElement?, descriptor: FunctionDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(DELEGATION, element, descriptor)
|
public fun Delegation(element: PsiElement?, descriptor: FunctionDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(DELEGATION, element, descriptor)
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class FilteredJvmDiagnostics(val jvmDiagnostics: Diagnostics, val otherDiagnosti
|
|||||||
private fun ConflictingJvmDeclarationsData.higherThan(other: ConflictingJvmDeclarationsData): Boolean {
|
private fun ConflictingJvmDeclarationsData.higherThan(other: ConflictingJvmDeclarationsData): Boolean {
|
||||||
return when (other.classOrigin.originKind) {
|
return when (other.classOrigin.originKind) {
|
||||||
PACKAGE_PART -> this.classOrigin.originKind == PACKAGE_FACADE
|
PACKAGE_PART -> this.classOrigin.originKind == PACKAGE_FACADE
|
||||||
TRAIT_IMPL -> this.classOrigin.originKind != TRAIT_IMPL
|
INTERFACE_DEFAULT_IMPL -> this.classOrigin.originKind != INTERFACE_DEFAULT_IMPL
|
||||||
MULTIFILE_CLASS_PART -> this.classOrigin.originKind == MULTIFILE_CLASS
|
MULTIFILE_CLASS_PART -> this.classOrigin.originKind == MULTIFILE_CLASS
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public object InlineTestUtil {
|
|||||||
val fromCall = MethodInfo(className, this.name, this.desc)
|
val fromCall = MethodInfo(className, this.name, this.desc)
|
||||||
|
|
||||||
//skip delegation to trait impl from child class
|
//skip delegation to trait impl from child class
|
||||||
if (methodCall.owner.endsWith(JvmAbi.TRAIT_IMPL_SUFFIX) && fromCall.owner != methodCall.owner) {
|
if (methodCall.owner.endsWith(JvmAbi.DEFAULT_IMPLS_SUFFIX) && fromCall.owner != methodCall.owner) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
notInlined.add(NotInlinedCall(fromCall, methodCall))
|
notInlined.add(NotInlinedCall(fromCall, methodCall))
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class KotlinSyntheticClassAnnotationTest extends CodegenTestCase {
|
|||||||
public void testTraitImpl() {
|
public void testTraitImpl() {
|
||||||
doTestKotlinSyntheticClass(
|
doTestKotlinSyntheticClass(
|
||||||
"interface A { fun foo() = 42 }",
|
"interface A { fun foo() = 42 }",
|
||||||
JvmAbi.TRAIT_IMPL_SUFFIX,
|
JvmAbi.DEFAULT_IMPLS_SUFFIX,
|
||||||
TRAIT_IMPL
|
TRAIT_IMPL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ public class SyntheticMethodForAnnotatedPropertyGenTest extends CodegenTestCase
|
|||||||
loadFile();
|
loadFile();
|
||||||
GeneratedClassLoader loader = generateAndCreateClassLoader();
|
GeneratedClassLoader loader = generateAndCreateClassLoader();
|
||||||
assertAnnotatedSyntheticMethodExistence(false, loader.loadClass("T"));
|
assertAnnotatedSyntheticMethodExistence(false, loader.loadClass("T"));
|
||||||
assertAnnotatedSyntheticMethodExistence(true, loader.loadClass("T" + JvmAbi.TRAIT_IMPL_SUFFIX));
|
assertAnnotatedSyntheticMethodExistence(true, loader.loadClass("T" + JvmAbi.DEFAULT_IMPLS_SUFFIX));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertAnnotatedSyntheticMethodExistence(boolean expected, @NotNull Class<?> clazz) {
|
private static void assertAnnotatedSyntheticMethodExistence(boolean expected, @NotNull Class<?> clazz) {
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ public final class JvmAbi {
|
|||||||
*/
|
*/
|
||||||
public static final BinaryVersion VERSION = BinaryVersion.create(0, 27, 0);
|
public static final BinaryVersion VERSION = BinaryVersion.create(0, 27, 0);
|
||||||
|
|
||||||
public static final String TRAIT_IMPL_CLASS_NAME = "$TImpl";
|
public static final String DEFAULT_IMPLS_CLASS_NAME = "$TImpl";
|
||||||
public static final String TRAIT_IMPL_SUFFIX = "$" + TRAIT_IMPL_CLASS_NAME;
|
public static final String DEFAULT_IMPLS_SUFFIX = "$" + DEFAULT_IMPLS_CLASS_NAME;
|
||||||
|
|
||||||
public static final String DEFAULT_PARAMS_IMPL_SUFFIX = "$default";
|
public static final String DEFAULT_PARAMS_IMPL_SUFFIX = "$default";
|
||||||
|
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ public class JvmClassName {
|
|||||||
public FqName getFqNameForClassNameWithoutDollars() {
|
public FqName getFqNameForClassNameWithoutDollars() {
|
||||||
if (fqName == null) {
|
if (fqName == null) {
|
||||||
String fqName = internalName
|
String fqName = internalName
|
||||||
.replace(JvmAbi.TRAIT_IMPL_CLASS_NAME, TRAIT_IMPL_REPLACE_GUARD)
|
.replace(JvmAbi.DEFAULT_IMPLS_CLASS_NAME, TRAIT_IMPL_REPLACE_GUARD)
|
||||||
.replace('$', '.')
|
.replace('$', '.')
|
||||||
.replace('/', '.')
|
.replace('/', '.')
|
||||||
.replace(TRAIT_IMPL_REPLACE_GUARD, JvmAbi.TRAIT_IMPL_CLASS_NAME);
|
.replace(TRAIT_IMPL_REPLACE_GUARD, JvmAbi.DEFAULT_IMPLS_CLASS_NAME);
|
||||||
this.fqName = new FqName(fqName);
|
this.fqName = new FqName(fqName);
|
||||||
}
|
}
|
||||||
return fqName;
|
return fqName;
|
||||||
|
|||||||
+1
-2
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.load.java.JvmAnnotationNames.KotlinSyntheticClass.Ki
|
|||||||
import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache
|
import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache
|
||||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import kotlin.test.assertFalse
|
|
||||||
|
|
||||||
public abstract class AbstractInternalCompiledClassesTest : JetLightCodeInsightFixtureTestCase() {
|
public abstract class AbstractInternalCompiledClassesTest : JetLightCodeInsightFixtureTestCase() {
|
||||||
private fun isFileWithHeader(predicate: (KotlinClassHeader) -> Boolean) : VirtualFile.() -> Boolean = {
|
private fun isFileWithHeader(predicate: (KotlinClassHeader) -> Boolean) : VirtualFile.() -> Boolean = {
|
||||||
@@ -58,7 +57,7 @@ public abstract class AbstractInternalCompiledClassesTest : JetLightCodeInsightF
|
|||||||
decompiledPsiFile is PsiJavaFile)
|
decompiledPsiFile is PsiJavaFile)
|
||||||
val classes = (decompiledPsiFile as PsiJavaFile).getClasses()
|
val classes = (decompiledPsiFile as PsiJavaFile).getClasses()
|
||||||
Assert.assertTrue("Should have some decompiled text",
|
Assert.assertTrue("Should have some decompiled text",
|
||||||
classes.size() == 1 && classes[0].getName()!!.endsWith(JvmAbi.TRAIT_IMPL_SUFFIX))
|
classes.size() == 1 && classes[0].getName()!!.endsWith(JvmAbi.DEFAULT_IMPLS_SUFFIX))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user