default -> companion: replace all mentions of default and default object
This commit is contained in:
+2
-2
@@ -20,9 +20,9 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
|
|
||||||
public abstract class DefaultObjectMapping {
|
public abstract class CompanionObjectMapping {
|
||||||
public fun hasMappingToObject(classDescriptor: ClassDescriptor): Boolean {
|
public fun hasMappingToObject(classDescriptor: ClassDescriptor): Boolean {
|
||||||
if (!DescriptorUtils.isDefaultObject(classDescriptor)) return false
|
if (!DescriptorUtils.isCompanionObject(classDescriptor)) return false
|
||||||
|
|
||||||
val containingDeclaration = classDescriptor.getContainingDeclaration()
|
val containingDeclaration = classDescriptor.getContainingDeclaration()
|
||||||
if (containingDeclaration !is ClassDescriptor) return false
|
if (containingDeclaration !is ClassDescriptor) return false
|
||||||
|
|||||||
@@ -195,8 +195,8 @@ public class AsmUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AnnotationsPackage.isPlatformStaticInDefaultObject(functionDescriptor)) {
|
if (AnnotationsPackage.isPlatformStaticInCompanionObject(functionDescriptor)) {
|
||||||
// Native method will be a member of the class, the default object method will be delegated to it
|
// Native method will be a member of the class, the companion object method will be delegated to it
|
||||||
flags &= ~Opcodes.ACC_NATIVE;
|
flags &= ~Opcodes.ACC_NATIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,7 +344,7 @@ public class AsmUtil {
|
|||||||
}
|
}
|
||||||
// the following code is only for PRIVATE visibility of member
|
// the following code is only for PRIVATE visibility of member
|
||||||
if (memberDescriptor instanceof ConstructorDescriptor) {
|
if (memberDescriptor instanceof ConstructorDescriptor) {
|
||||||
if (isNonDefaultObject(containingDeclaration) || isEnumEntry(containingDeclaration)) {
|
if (isNonCompanionObject(containingDeclaration) || isEnumEntry(containingDeclaration)) {
|
||||||
return NO_FLAG_PACKAGE_PRIVATE;
|
return NO_FLAG_PACKAGE_PRIVATE;
|
||||||
}
|
}
|
||||||
if (isEnumClass(containingDeclaration)) {
|
if (isEnumClass(containingDeclaration)) {
|
||||||
@@ -727,12 +727,12 @@ public class AsmUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isNonDefaultObject(propertyDescriptor.getContainingDeclaration()) || isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
return isNonCompanionObject(propertyDescriptor.getContainingDeclaration()) || isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPropertyWithBackingFieldInOuterClass(@NotNull PropertyDescriptor propertyDescriptor) {
|
public static boolean isPropertyWithBackingFieldInOuterClass(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||||
return propertyDescriptor.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE &&
|
return propertyDescriptor.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE &&
|
||||||
isDefaultObjectWithBackingFieldsInOuter(propertyDescriptor.getContainingDeclaration());
|
isCompanionObjectWithBackingFieldsInOuter(propertyDescriptor.getContainingDeclaration());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getVisibilityForSpecialPropertyBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate) {
|
public static int getVisibilityForSpecialPropertyBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate) {
|
||||||
@@ -761,14 +761,14 @@ public class AsmUtil {
|
|||||||
DeclarationDescriptor propertyContainer = propertyDescriptor.getContainingDeclaration();
|
DeclarationDescriptor propertyContainer = propertyDescriptor.getContainingDeclaration();
|
||||||
return !propertyDescriptor.isVar()
|
return !propertyDescriptor.isVar()
|
||||||
&& !isExtensionProperty
|
&& !isExtensionProperty
|
||||||
&& isDefaultObject(propertyContainer) && isTrait(propertyContainer.getContainingDeclaration())
|
&& isCompanionObject(propertyContainer) && isTrait(propertyContainer.getContainingDeclaration())
|
||||||
&& areBothAccessorDefault(propertyDescriptor)
|
&& areBothAccessorDefault(propertyDescriptor)
|
||||||
&& getVisibilityForSpecialPropertyBackingField(propertyDescriptor, false) == ACC_PUBLIC;
|
&& getVisibilityForSpecialPropertyBackingField(propertyDescriptor, false) == ACC_PUBLIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDefaultObjectWithBackingFieldsInOuter(@NotNull DeclarationDescriptor defaultObject) {
|
public static boolean isCompanionObjectWithBackingFieldsInOuter(@NotNull DeclarationDescriptor companionObject) {
|
||||||
DeclarationDescriptor containingClass = defaultObject.getContainingDeclaration();
|
DeclarationDescriptor containingClass = companionObject.getContainingDeclaration();
|
||||||
return isDefaultObject(defaultObject) && (isClass(containingClass) || isEnumClass(containingClass));
|
return isCompanionObject(companionObject) && (isClass(containingClass) || isEnumClass(containingClass));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean areBothAccessorDefault(@NotNull PropertyDescriptor propertyDescriptor) {
|
private static boolean areBothAccessorDefault(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||||
|
|||||||
@@ -1946,9 +1946,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
Type type = typeMapper.mapType((ClassDescriptor) enumClass);
|
Type type = typeMapper.mapType((ClassDescriptor) enumClass);
|
||||||
return StackValue.field(type, type, descriptor.getName().asString(), true, StackValue.none());
|
return StackValue.field(type, type, descriptor.getName().asString(), true, StackValue.none());
|
||||||
}
|
}
|
||||||
ClassDescriptor defaultObjectDescriptor = classDescriptor.getDefaultObjectDescriptor();
|
ClassDescriptor companionObjectDescriptor = classDescriptor.getCompanionObjectDescriptor();
|
||||||
if (defaultObjectDescriptor != null) {
|
if (companionObjectDescriptor != null) {
|
||||||
return StackValue.singleton(defaultObjectDescriptor, typeMapper);
|
return StackValue.singleton(companionObjectDescriptor, typeMapper);
|
||||||
}
|
}
|
||||||
return StackValue.none();
|
return StackValue.none();
|
||||||
}
|
}
|
||||||
@@ -2439,7 +2439,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
public StackValue generateReceiverValue(@NotNull ReceiverValue receiverValue) {
|
public StackValue generateReceiverValue(@NotNull ReceiverValue receiverValue) {
|
||||||
if (receiverValue instanceof ClassReceiver) {
|
if (receiverValue instanceof ClassReceiver) {
|
||||||
ClassDescriptor receiverDescriptor = ((ClassReceiver) receiverValue).getDeclarationDescriptor();
|
ClassDescriptor receiverDescriptor = ((ClassReceiver) receiverValue).getDeclarationDescriptor();
|
||||||
if (DescriptorUtils.isDefaultObject(receiverDescriptor)) {
|
if (DescriptorUtils.isCompanionObject(receiverDescriptor)) {
|
||||||
CallableMemberDescriptor contextDescriptor = context.getContextDescriptor();
|
CallableMemberDescriptor contextDescriptor = context.getContextDescriptor();
|
||||||
if (contextDescriptor instanceof FunctionDescriptor && receiverDescriptor == contextDescriptor.getContainingDeclaration()) {
|
if (contextDescriptor instanceof FunctionDescriptor && receiverDescriptor == contextDescriptor.getContainingDeclaration()) {
|
||||||
return StackValue.LOCAL_0;
|
return StackValue.LOCAL_0;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi;
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isNonDefaultObject;
|
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isNonCompanionObject;
|
||||||
|
|
||||||
public class FieldInfo {
|
public class FieldInfo {
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -34,7 +34,7 @@ public class FieldInfo {
|
|||||||
throw new UnsupportedOperationException("Can't create singleton field for class: " + classDescriptor);
|
throw new UnsupportedOperationException("Can't create singleton field for class: " + classDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNonDefaultObject(classDescriptor) || IntrinsicObjects.INSTANCE$.hasMappingToObject(classDescriptor)) {
|
if (isNonCompanionObject(classDescriptor) || IntrinsicObjects.INSTANCE$.hasMappingToObject(classDescriptor)) {
|
||||||
Type type = typeMapper.mapType(classDescriptor);
|
Type type = typeMapper.mapType(classDescriptor);
|
||||||
return new FieldInfo(type, type, JvmAbi.INSTANCE_FIELD, true);
|
return new FieldInfo(type, type, JvmAbi.INSTANCE_FIELD, true);
|
||||||
}
|
}
|
||||||
@@ -48,12 +48,12 @@ public class FieldInfo {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@NotNull
|
@NotNull
|
||||||
public static FieldInfo deprecatedFieldForDefaultObject(@NotNull ClassDescriptor defaultObject, @NotNull JetTypeMapper typeMapper) {
|
public static FieldInfo deprecatedFieldForCompanionObject(@NotNull ClassDescriptor companionObject, @NotNull JetTypeMapper typeMapper) {
|
||||||
assert DescriptorUtils.isDefaultObject(defaultObject) : "Not a default object: " + defaultObject;
|
assert DescriptorUtils.isCompanionObject(companionObject) : "Not a companion object: " + companionObject;
|
||||||
return new FieldInfo(
|
return new FieldInfo(
|
||||||
typeMapper.mapType((ClassifierDescriptor) defaultObject.getContainingDeclaration()),
|
typeMapper.mapType((ClassifierDescriptor) companionObject.getContainingDeclaration()),
|
||||||
typeMapper.mapType(defaultObject),
|
typeMapper.mapType(companionObject),
|
||||||
JvmAbi.DEPRECATED_DEFAULT_OBJECT_FIELD,
|
JvmAbi.DEPRECATED_COMPANION_OBJECT_FIELD,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,8 +166,8 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
generateBridges(functionDescriptor);
|
generateBridges(functionDescriptor);
|
||||||
|
|
||||||
boolean staticInDefaultObject = AnnotationsPackage.isPlatformStaticInDefaultObject(functionDescriptor);
|
boolean staticInCompanionObject = AnnotationsPackage.isPlatformStaticInCompanionObject(functionDescriptor);
|
||||||
if (staticInDefaultObject) {
|
if (staticInCompanionObject) {
|
||||||
ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
|
ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
|
||||||
parentBodyCodegen.addAdditionalTask(new PlatformStaticGenerator(functionDescriptor, origin, state));
|
parentBodyCodegen.addAdditionalTask(new PlatformStaticGenerator(functionDescriptor, origin, state));
|
||||||
}
|
}
|
||||||
@@ -190,8 +190,8 @@ public class FunctionCodegen {
|
|||||||
if (!isNative) {
|
if (!isNative) {
|
||||||
generateMethodBody(mv, functionDescriptor, methodContext, jvmSignature, strategy, memberCodegen);
|
generateMethodBody(mv, functionDescriptor, methodContext, jvmSignature, strategy, memberCodegen);
|
||||||
}
|
}
|
||||||
else if (staticInDefaultObject) {
|
else if (staticInCompanionObject) {
|
||||||
// native platformStatic foo() in default object should delegate to the static native function moved to the outer class
|
// native platformStatic foo() in companion object should delegate to the static native function moved to the outer class
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
FunctionDescriptor staticFunctionDescriptor = PlatformStaticGenerator.createStaticFunctionDescriptor(functionDescriptor);
|
FunctionDescriptor staticFunctionDescriptor = PlatformStaticGenerator.createStaticFunctionDescriptor(functionDescriptor);
|
||||||
JvmMethodSignature jvmMethodSignature =
|
JvmMethodSignature jvmMethodSignature =
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
private JetType superClassType;
|
private JetType superClassType;
|
||||||
private final Type classAsmType;
|
private final Type classAsmType;
|
||||||
|
|
||||||
private List<PropertyAndDefaultValue> defaultObjectPropertiesToCopy;
|
private List<PropertyAndDefaultValue> companionObjectPropertiesToCopy;
|
||||||
|
|
||||||
private final List<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>> additionalTasks =
|
private final List<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>> additionalTasks =
|
||||||
new ArrayList<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>>();
|
new ArrayList<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>>();
|
||||||
@@ -152,7 +152,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
isStatic = !jetClass.isInner();
|
isStatic = !jetClass.isInner();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
isStatic = myClass instanceof JetObjectDeclaration && ((JetObjectDeclaration) myClass).isDefault() ;
|
isStatic = myClass instanceof JetObjectDeclaration && ((JetObjectDeclaration) myClass).isCompanion() ;
|
||||||
isFinal = true;
|
isFinal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
generateFieldForSingleton();
|
generateFieldForSingleton();
|
||||||
|
|
||||||
generateDefaultObjectBackingFieldCopies();
|
generateCompanionObjectBackingFieldCopies();
|
||||||
|
|
||||||
DelegationFieldsInfo delegationFieldsInfo = getDelegationFieldsInfo(myClass.getDelegationSpecifiers());
|
DelegationFieldsInfo delegationFieldsInfo = getDelegationFieldsInfo(myClass.getDelegationSpecifiers());
|
||||||
try {
|
try {
|
||||||
@@ -872,7 +872,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
@Override
|
@Override
|
||||||
public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
|
public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
|
||||||
boolean forceField = AsmUtil.isPropertyWithBackingFieldInOuterClass(original) &&
|
boolean forceField = AsmUtil.isPropertyWithBackingFieldInOuterClass(original) &&
|
||||||
!isDefaultObject(bridge.getContainingDeclaration());
|
!isCompanionObject(bridge.getContainingDeclaration());
|
||||||
StackValue property =
|
StackValue property =
|
||||||
codegen.intermediateValueForProperty(original, forceField, null, MethodKind.SYNTHETIC_ACCESSOR,
|
codegen.intermediateValueForProperty(original, forceField, null, MethodKind.SYNTHETIC_ACCESSOR,
|
||||||
StackValue.none());
|
StackValue.none());
|
||||||
@@ -962,9 +962,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateFieldForSingleton() {
|
private void generateFieldForSingleton() {
|
||||||
if (isEnumEntry(descriptor) || isDefaultObject(descriptor)) return;
|
if (isEnumEntry(descriptor) || isCompanionObject(descriptor)) return;
|
||||||
|
|
||||||
if (isNonDefaultObject(descriptor)) {
|
if (isNonCompanionObject(descriptor)) {
|
||||||
StackValue.Field field = StackValue.singleton(descriptor, typeMapper);
|
StackValue.Field field = StackValue.singleton(descriptor, typeMapper);
|
||||||
v.newField(OtherOrigin(myClass), ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null);
|
v.newField(OtherOrigin(myClass), ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null);
|
||||||
|
|
||||||
@@ -977,34 +977,34 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassDescriptor defaultObjectDescriptor = descriptor.getDefaultObjectDescriptor();
|
ClassDescriptor companionObjectDescriptor = descriptor.getCompanionObjectDescriptor();
|
||||||
if (defaultObjectDescriptor == null) {
|
if (companionObjectDescriptor == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JetObjectDeclaration defaultObject = firstOrNull(((JetClass) myClass).getDefaultObjects());
|
JetObjectDeclaration companionObject = firstOrNull(((JetClass) myClass).getCompanionObjects());
|
||||||
assert defaultObject != null : "Default object not found: " + myClass.getText();
|
assert companionObject != null : "Companion object not found: " + myClass.getText();
|
||||||
|
|
||||||
StackValue.Field field = StackValue.singleton(defaultObjectDescriptor, typeMapper);
|
StackValue.Field field = StackValue.singleton(companionObjectDescriptor, typeMapper);
|
||||||
v.newField(OtherOrigin(defaultObject), ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null);
|
v.newField(OtherOrigin(companionObject), ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null);
|
||||||
|
|
||||||
StackValue.Field deprecatedField = StackValue.deprecatedDefaultObjectAccessor(defaultObjectDescriptor, typeMapper);
|
StackValue.Field deprecatedField = StackValue.deprecatedCompanionObjectAccessor(companionObjectDescriptor, typeMapper);
|
||||||
FieldVisitor fv = v.newField(OtherOrigin(defaultObject), ACC_PUBLIC | ACC_STATIC | ACC_FINAL | ACC_DEPRECATED,
|
FieldVisitor fv = v.newField(OtherOrigin(companionObject), ACC_PUBLIC | ACC_STATIC | ACC_FINAL | ACC_DEPRECATED,
|
||||||
deprecatedField.name, deprecatedField.type.getDescriptor(), null, null);
|
deprecatedField.name, deprecatedField.type.getDescriptor(), null, null);
|
||||||
|
|
||||||
fv.visitAnnotation(asmDescByFqNameWithoutInnerClasses(new FqName("java.lang.Deprecated")), true).visitEnd();
|
fv.visitAnnotation(asmDescByFqNameWithoutInnerClasses(new FqName("java.lang.Deprecated")), true).visitEnd();
|
||||||
|
|
||||||
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
|
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
|
||||||
|
|
||||||
if (!isDefaultObjectWithBackingFieldsInOuter(defaultObjectDescriptor)) {
|
if (!isCompanionObjectWithBackingFieldsInOuter(companionObjectDescriptor)) {
|
||||||
generateDefaultObjectInitializer(defaultObjectDescriptor);
|
generateCompanionObjectInitializer(companionObjectDescriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateDefaultObjectBackingFieldCopies() {
|
private void generateCompanionObjectBackingFieldCopies() {
|
||||||
if (defaultObjectPropertiesToCopy == null) return;
|
if (companionObjectPropertiesToCopy == null) return;
|
||||||
|
|
||||||
for (PropertyAndDefaultValue info : defaultObjectPropertiesToCopy) {
|
for (PropertyAndDefaultValue info : companionObjectPropertiesToCopy) {
|
||||||
PropertyDescriptor property = info.descriptor;
|
PropertyDescriptor property = info.descriptor;
|
||||||
|
|
||||||
Type type = typeMapper.mapType(property);
|
Type type = typeMapper.mapType(property);
|
||||||
@@ -1020,40 +1020,40 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
// TODO: test this code
|
// TODO: test this code
|
||||||
if (state.getClassBuilderMode() == ClassBuilderMode.FULL && info.defaultValue == null) {
|
if (state.getClassBuilderMode() == ClassBuilderMode.FULL && info.defaultValue == null) {
|
||||||
ExpressionCodegen codegen = createOrGetClInitCodegen();
|
ExpressionCodegen codegen = createOrGetClInitCodegen();
|
||||||
int defaultObjectIndex = putDefaultObjectInLocalVar(codegen);
|
int companionObjectIndex = putCompanionObjectInLocalVar(codegen);
|
||||||
StackValue.local(defaultObjectIndex, OBJECT_TYPE).put(OBJECT_TYPE, codegen.v);
|
StackValue.local(companionObjectIndex, OBJECT_TYPE).put(OBJECT_TYPE, codegen.v);
|
||||||
copyFieldFromDefaultObject(property);
|
copyFieldFromCompanionObject(property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int putDefaultObjectInLocalVar(ExpressionCodegen codegen) {
|
private int putCompanionObjectInLocalVar(ExpressionCodegen codegen) {
|
||||||
FrameMap frameMap = codegen.myFrameMap;
|
FrameMap frameMap = codegen.myFrameMap;
|
||||||
ClassDescriptor defaultObjectDescriptor = descriptor.getDefaultObjectDescriptor();
|
ClassDescriptor companionObjectDescriptor = descriptor.getCompanionObjectDescriptor();
|
||||||
int defaultObjectIndex = frameMap.getIndex(defaultObjectDescriptor);
|
int companionObjectIndex = frameMap.getIndex(companionObjectDescriptor);
|
||||||
if (defaultObjectIndex == -1) {
|
if (companionObjectIndex == -1) {
|
||||||
defaultObjectIndex = frameMap.enter(defaultObjectDescriptor, OBJECT_TYPE);
|
companionObjectIndex = frameMap.enter(companionObjectDescriptor, OBJECT_TYPE);
|
||||||
StackValue defaultObject = StackValue.singleton(defaultObjectDescriptor, typeMapper);
|
StackValue companionObject = StackValue.singleton(companionObjectDescriptor, typeMapper);
|
||||||
StackValue.local(defaultObjectIndex, defaultObject.type).store(defaultObject, codegen.v);
|
StackValue.local(companionObjectIndex, companionObject.type).store(companionObject, codegen.v);
|
||||||
}
|
}
|
||||||
return defaultObjectIndex;
|
return companionObjectIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyFieldFromDefaultObject(PropertyDescriptor propertyDescriptor) {
|
private void copyFieldFromCompanionObject(PropertyDescriptor propertyDescriptor) {
|
||||||
ExpressionCodegen codegen = createOrGetClInitCodegen();
|
ExpressionCodegen codegen = createOrGetClInitCodegen();
|
||||||
StackValue property = codegen.intermediateValueForProperty(propertyDescriptor, false, null, StackValue.none());
|
StackValue property = codegen.intermediateValueForProperty(propertyDescriptor, false, null, StackValue.none());
|
||||||
StackValue.Field field = StackValue.field(property.type, classAsmType, propertyDescriptor.getName().asString(), true, StackValue.none());
|
StackValue.Field field = StackValue.field(property.type, classAsmType, propertyDescriptor.getName().asString(), true, StackValue.none());
|
||||||
field.store(property, codegen.v);
|
field.store(property, codegen.v);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateDefaultObjectInitializer(@NotNull ClassDescriptor defaultObject) {
|
private void generateCompanionObjectInitializer(@NotNull ClassDescriptor companionObject) {
|
||||||
ExpressionCodegen codegen = createOrGetClInitCodegen();
|
ExpressionCodegen codegen = createOrGetClInitCodegen();
|
||||||
FunctionDescriptor constructor = codegen.accessibleFunctionDescriptor(KotlinPackage.single(defaultObject.getConstructors()));
|
FunctionDescriptor constructor = codegen.accessibleFunctionDescriptor(KotlinPackage.single(companionObject.getConstructors()));
|
||||||
generateMethodCallTo(constructor, codegen.v);
|
generateMethodCallTo(constructor, codegen.v);
|
||||||
codegen.v.dup();
|
codegen.v.dup();
|
||||||
StackValue instance = StackValue.onStack(typeMapper.mapClass(defaultObject));
|
StackValue instance = StackValue.onStack(typeMapper.mapClass(companionObject));
|
||||||
StackValue.singleton(defaultObject, typeMapper).store(instance, codegen.v, true);
|
StackValue.singleton(companionObject, typeMapper).store(instance, codegen.v, true);
|
||||||
StackValue.deprecatedDefaultObjectAccessor(defaultObject, typeMapper).store(instance, codegen.v, true);
|
StackValue.deprecatedCompanionObjectAccessor(companionObject, typeMapper).store(instance, codegen.v, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generatePrimaryConstructor(final DelegationFieldsInfo delegationFieldsInfo) {
|
private void generatePrimaryConstructor(final DelegationFieldsInfo delegationFieldsInfo) {
|
||||||
@@ -1079,7 +1079,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
CallableMethod callableMethod = typeMapper.mapToCallableMethod(constructorDescriptor);
|
CallableMethod callableMethod = typeMapper.mapToCallableMethod(constructorDescriptor);
|
||||||
FunctionCodegen.generateConstructorWithoutParametersIfNeeded(state, callableMethod, constructorDescriptor, v, myClass);
|
FunctionCodegen.generateConstructorWithoutParametersIfNeeded(state, callableMethod, constructorDescriptor, v, myClass);
|
||||||
|
|
||||||
if (isDefaultObject(descriptor)) {
|
if (isCompanionObject(descriptor)) {
|
||||||
context.recordSyntheticAccessorIfNeeded(constructorDescriptor, bindingContext);
|
context.recordSyntheticAccessorIfNeeded(constructorDescriptor, bindingContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1112,7 +1112,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
generateDelegatorToConstructorCall(iv, codegen, constructorDescriptor,
|
generateDelegatorToConstructorCall(iv, codegen, constructorDescriptor,
|
||||||
getDelegationConstructorCall(bindingContext, constructorDescriptor));
|
getDelegationConstructorCall(bindingContext, constructorDescriptor));
|
||||||
|
|
||||||
if (isNonDefaultObject(descriptor)) {
|
if (isNonCompanionObject(descriptor)) {
|
||||||
StackValue.singleton(descriptor, typeMapper).store(StackValue.LOCAL_0, iv);
|
StackValue.singleton(descriptor, typeMapper).store(StackValue.LOCAL_0, iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1137,9 +1137,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
curParam++;
|
curParam++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDefaultObjectWithBackingFieldsInOuter(descriptor)) {
|
if (isCompanionObjectWithBackingFieldsInOuter(descriptor)) {
|
||||||
final ImplementationBodyCodegen parentCodegen = (ImplementationBodyCodegen) getParentCodegen();
|
final ImplementationBodyCodegen parentCodegen = (ImplementationBodyCodegen) getParentCodegen();
|
||||||
parentCodegen.generateDefaultObjectInitializer(descriptor);
|
parentCodegen.generateCompanionObjectInitializer(descriptor);
|
||||||
generateInitializers(new Function0<ExpressionCodegen>() {
|
generateInitializers(new Function0<ExpressionCodegen>() {
|
||||||
@Override
|
@Override
|
||||||
public ExpressionCodegen invoke() {
|
public ExpressionCodegen invoke() {
|
||||||
@@ -1740,11 +1740,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDefaultObjectPropertyToCopy(@NotNull PropertyDescriptor descriptor, Object defaultValue) {
|
public void addCompanionObjectPropertyToCopy(@NotNull PropertyDescriptor descriptor, Object defaultValue) {
|
||||||
if (defaultObjectPropertiesToCopy == null) {
|
if (companionObjectPropertiesToCopy == null) {
|
||||||
defaultObjectPropertiesToCopy = new ArrayList<PropertyAndDefaultValue>();
|
companionObjectPropertiesToCopy = new ArrayList<PropertyAndDefaultValue>();
|
||||||
}
|
}
|
||||||
defaultObjectPropertiesToCopy.add(new PropertyAndDefaultValue(descriptor, defaultValue));
|
companionObjectPropertiesToCopy.add(new PropertyAndDefaultValue(descriptor, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -180,8 +180,8 @@ public class JvmCodegenUtil {
|
|||||||
// Delegated and extension properties have no backing fields
|
// Delegated and extension properties have no backing fields
|
||||||
if (isDelegated || property.getExtensionReceiverParameter() != null) return false;
|
if (isDelegated || property.getExtensionReceiverParameter() != null) return false;
|
||||||
|
|
||||||
// Default object properties cannot be accessed directly because their backing fields are stored in the containing class
|
// Companion object properties cannot be accessed directly because their backing fields are stored in the containing class
|
||||||
if (DescriptorUtils.isDefaultObject(property.getContainingDeclaration())) return false;
|
if (DescriptorUtils.isCompanionObject(property.getContainingDeclaration())) return false;
|
||||||
|
|
||||||
PropertyAccessorDescriptor accessor = forGetter ? property.getGetter() : property.getSetter();
|
PropertyAccessorDescriptor accessor = forGetter ? property.getGetter() : property.getSetter();
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ import java.util.List;
|
|||||||
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
|
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
|
||||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isInterface;
|
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isInterface;
|
||||||
import static org.jetbrains.kotlin.codegen.JvmSerializationBindings.*;
|
import static org.jetbrains.kotlin.codegen.JvmSerializationBindings.*;
|
||||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isDefaultObject;
|
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject;
|
||||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isTrait;
|
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isTrait;
|
||||||
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.PROPERTY_METADATA_TYPE;
|
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.PROPERTY_METADATA_TYPE;
|
||||||
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.OtherOrigin;
|
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.OtherOrigin;
|
||||||
@@ -144,8 +144,8 @@ public class PropertyCodegen {
|
|||||||
// Delegated or extension properties can only be referenced via accessors
|
// Delegated or extension properties can only be referenced via accessors
|
||||||
if (declaration.hasDelegate() || declaration.getReceiverTypeReference() != null) return true;
|
if (declaration.hasDelegate() || declaration.getReceiverTypeReference() != null) return true;
|
||||||
|
|
||||||
// Default object properties always should have accessors, because their backing fields are moved/copied to the outer class
|
// Companion object properties always should have accessors, because their backing fields are moved/copied to the outer class
|
||||||
if (isDefaultObject(descriptor.getContainingDeclaration())) return true;
|
if (isCompanionObject(descriptor.getContainingDeclaration())) return true;
|
||||||
|
|
||||||
// Private class properties have accessors only in cases when those accessors are non-trivial
|
// Private class properties have accessors only in cases when those accessors are non-trivial
|
||||||
if (kind == OwnerKind.IMPLEMENTATION && Visibilities.isPrivate(descriptor.getVisibility())) {
|
if (kind == OwnerKind.IMPLEMENTATION && Visibilities.isPrivate(descriptor.getVisibility())) {
|
||||||
@@ -265,7 +265,7 @@ public class PropertyCodegen {
|
|||||||
|
|
||||||
if (AsmUtil.isPropertyWithBackingFieldCopyInOuterClass(propertyDescriptor)) {
|
if (AsmUtil.isPropertyWithBackingFieldCopyInOuterClass(propertyDescriptor)) {
|
||||||
ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
|
ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
|
||||||
parentBodyCodegen.addDefaultObjectPropertyToCopy(propertyDescriptor, defaultValue);
|
parentBodyCodegen.addCompanionObjectPropertyToCopy(propertyDescriptor, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = backingFieldContext.getFieldName(propertyDescriptor, isDelegate);
|
String name = backingFieldContext.getFieldName(propertyDescriptor, isDelegate);
|
||||||
|
|||||||
@@ -513,8 +513,8 @@ public abstract class StackValue {
|
|||||||
return field(FieldInfo.createForSingleton(classDescriptor, typeMapper));
|
return field(FieldInfo.createForSingleton(classDescriptor, typeMapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Field deprecatedDefaultObjectAccessor(ClassDescriptor classDescriptor, JetTypeMapper typeMapper) {
|
public static Field deprecatedCompanionObjectAccessor(ClassDescriptor classDescriptor, JetTypeMapper typeMapper) {
|
||||||
return field(FieldInfo.deprecatedFieldForDefaultObject(classDescriptor, typeMapper));
|
return field(FieldInfo.deprecatedFieldForCompanionObject(classDescriptor, typeMapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StackValue operation(Type type, Function1<InstructionAdapter, Unit> lambda) {
|
public static StackValue operation(Type type, Function1<InstructionAdapter, Unit> lambda) {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public final class PsiCodegenPredictor {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String getPredefinedJvmInternalName(@NotNull JetDeclaration declaration) {
|
public static String getPredefinedJvmInternalName(@NotNull JetDeclaration declaration) {
|
||||||
// TODO: Method won't work for declarations inside default objects
|
// TODO: Method won't work for declarations inside companion objects
|
||||||
// TODO: Method won't give correct class name for traits implementations
|
// TODO: Method won't give correct class name for traits implementations
|
||||||
|
|
||||||
JetDeclaration parentDeclaration = JetStubbedPsiUtil.getContainingDeclaration(declaration);
|
JetDeclaration parentDeclaration = JetStubbedPsiUtil.getContainingDeclaration(declaration);
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ public class ClassContext extends FieldOwnerContext<ClassDescriptor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public CodegenContext getDefaultObjectContext() {
|
public CodegenContext getCompanionObjectContext() {
|
||||||
if (getContextDescriptor().getDefaultObjectDescriptor() != null) {
|
if (getContextDescriptor().getCompanionObjectDescriptor() != null) {
|
||||||
return findChildContext(getContextDescriptor().getDefaultObjectDescriptor());
|
return findChildContext(getContextDescriptor().getCompanionObjectDescriptor());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
|||||||
CodegenContext descriptorContext = null;
|
CodegenContext descriptorContext = null;
|
||||||
if (!fromOutsideContext || getClassOrPackageParentContext().getContextDescriptor() != descriptor.getContainingDeclaration()) {
|
if (!fromOutsideContext || getClassOrPackageParentContext().getContextDescriptor() != descriptor.getContainingDeclaration()) {
|
||||||
DeclarationDescriptor enclosed = descriptor.getContainingDeclaration();
|
DeclarationDescriptor enclosed = descriptor.getContainingDeclaration();
|
||||||
boolean isDefaultObjectMember = DescriptorUtils.isDefaultObject(enclosed);
|
boolean isCompanionObjectMember = DescriptorUtils.isCompanionObject(enclosed);
|
||||||
//go upper
|
//go upper
|
||||||
if (hasThisDescriptor() && (enclosed != getThisDescriptor() || !fromOutsideContext)) {
|
if (hasThisDescriptor() && (enclosed != getThisDescriptor() || !fromOutsideContext)) {
|
||||||
CodegenContext currentContext = this;
|
CodegenContext currentContext = this;
|
||||||
@@ -371,12 +371,12 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//accessors for private members in default object for call from class
|
//accessors for private members in companion object for call from class
|
||||||
if (isDefaultObjectMember && currentContext instanceof ClassContext) {
|
if (isCompanionObjectMember && currentContext instanceof ClassContext) {
|
||||||
ClassContext classContext = (ClassContext) currentContext;
|
ClassContext classContext = (ClassContext) currentContext;
|
||||||
CodegenContext defaultObjectContext = classContext.getDefaultObjectContext();
|
CodegenContext companionObjectContext = classContext.getCompanionObjectContext();
|
||||||
if (defaultObjectContext != null && defaultObjectContext.getContextDescriptor() == enclosed) {
|
if (companionObjectContext != null && companionObjectContext.getContextDescriptor() == enclosed) {
|
||||||
descriptorContext = defaultObjectContext;
|
descriptorContext = companionObjectContext;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -417,7 +417,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldAddChild(@NotNull CodegenContext child) {
|
protected boolean shouldAddChild(@NotNull CodegenContext child) {
|
||||||
return DescriptorUtils.isDefaultObject(child.contextDescriptor);
|
return DescriptorUtils.isCompanionObject(child.contextDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -16,17 +16,17 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.codegen.intrinsics
|
package org.jetbrains.kotlin.codegen.intrinsics
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.builtins.DefaultObjectMapping
|
import org.jetbrains.kotlin.backend.common.builtins.CompanionObjectMapping
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
public object IntrinsicObjects : DefaultObjectMapping() {
|
public object IntrinsicObjects : CompanionObjectMapping() {
|
||||||
public fun mapType(classDescriptor: ClassDescriptor): FqName? {
|
public fun mapType(classDescriptor: ClassDescriptor): FqName? {
|
||||||
if (!hasMappingToObject(classDescriptor)) return null
|
if (!hasMappingToObject(classDescriptor)) return null
|
||||||
|
|
||||||
val containingDeclaration = classDescriptor.getContainingDeclaration()
|
val containingDeclaration = classDescriptor.getContainingDeclaration()
|
||||||
val name = Name.identifier(containingDeclaration.getName().asString() + "DefaultObject")
|
val name = Name.identifier(containingDeclaration.getName().asString() + "CompanionObject")
|
||||||
return FqName("kotlin.jvm.internal").child(name)
|
return FqName("kotlin.jvm.internal").child(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,9 +300,9 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor instanceof ClassDescriptor) {
|
if (descriptor instanceof ClassDescriptor) {
|
||||||
FqName defaultObjectMappedFqName = IntrinsicObjects.INSTANCE$.mapType((ClassDescriptor) descriptor);
|
FqName companionObjectMappedFqName = IntrinsicObjects.INSTANCE$.mapType((ClassDescriptor) descriptor);
|
||||||
if (defaultObjectMappedFqName != null) {
|
if (companionObjectMappedFqName != null) {
|
||||||
Type asmType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(defaultObjectMappedFqName);
|
Type asmType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(companionObjectMappedFqName);
|
||||||
if (signatureVisitor != null) {
|
if (signatureVisitor != null) {
|
||||||
signatureVisitor.writeAsmType(asmType);
|
signatureVisitor.writeAsmType(asmType);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -81,7 +81,7 @@ public abstract class FileBasedKotlinClass implements KotlinJvmBinaryClass {
|
|||||||
@NotNull
|
@NotNull
|
||||||
protected abstract byte[] getFileContents();
|
protected abstract byte[] getFileContents();
|
||||||
|
|
||||||
// TODO public to be accessible in default object of subclass, workaround for KT-3974
|
// TODO public to be accessible in companion object of subclass, workaround for KT-3974
|
||||||
@Nullable
|
@Nullable
|
||||||
public static <T extends FileBasedKotlinClass> T create(
|
public static <T extends FileBasedKotlinClass> T create(
|
||||||
@NotNull byte[] fileContents,
|
@NotNull byte[] fileContents,
|
||||||
|
|||||||
+5
-5
@@ -96,12 +96,12 @@ public class PlatformStaticAnnotationChecker : AnnotationChecker {
|
|||||||
diagnosticHolder: DiagnosticSink
|
diagnosticHolder: DiagnosticSink
|
||||||
) {
|
) {
|
||||||
val container = descriptor.getContainingDeclaration()
|
val container = descriptor.getContainingDeclaration()
|
||||||
val insideObject = container != null && DescriptorUtils.isNonDefaultObject(container)
|
val insideObject = container != null && DescriptorUtils.isNonCompanionObject(container)
|
||||||
val insideDefaultObjectInClass =
|
val insideCompanionObjectInClass =
|
||||||
container != null && DescriptorUtils.isDefaultObject(container) && DescriptorUtils.isClass(container.getContainingDeclaration())
|
container != null && DescriptorUtils.isCompanionObject(container) && DescriptorUtils.isClass(container.getContainingDeclaration())
|
||||||
container != null && DescriptorUtils.isDefaultObject(container) && DescriptorUtils.isClass(container.getContainingDeclaration())
|
container != null && DescriptorUtils.isCompanionObject(container) && DescriptorUtils.isClass(container.getContainingDeclaration())
|
||||||
|
|
||||||
if (!insideObject && !insideDefaultObjectInClass) {
|
if (!insideObject && !insideCompanionObjectInClass) {
|
||||||
diagnosticHolder.report(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT.on(declaration));
|
diagnosticHolder.report(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT.on(declaration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ public class NeedSyntheticChecker implements CallChecker {
|
|||||||
|
|
||||||
//Necessary synthetic accessors in outer classes generated via old logic: CodegenContext.getAccessor
|
//Necessary synthetic accessors in outer classes generated via old logic: CodegenContext.getAccessor
|
||||||
//Generation of accessors in nested classes (to invoke from outer,
|
//Generation of accessors in nested classes (to invoke from outer,
|
||||||
// e.g.: from class to default object) controlled via NEED_SYNTHETIC_ACCESSOR slice
|
// e.g.: from class to companion object) controlled via NEED_SYNTHETIC_ACCESSOR slice
|
||||||
private boolean needSyntheticAccessor(JetScope invokationScope, CallableDescriptor targetDescriptor) {
|
private boolean needSyntheticAccessor(JetScope invokationScope, CallableDescriptor targetDescriptor) {
|
||||||
return targetDescriptor instanceof CallableMemberDescriptor &&
|
return targetDescriptor instanceof CallableMemberDescriptor &&
|
||||||
Visibilities.isPrivate(targetDescriptor.getVisibility()) &&
|
Visibilities.isPrivate(targetDescriptor.getVisibility()) &&
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
|||||||
static {
|
static {
|
||||||
MAP.put(ErrorsJvm.CONFLICTING_JVM_DECLARATIONS, "Platform declaration clash: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
|
MAP.put(ErrorsJvm.CONFLICTING_JVM_DECLARATIONS, "Platform declaration clash: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
|
||||||
MAP.put(ErrorsJvm.ACCIDENTAL_OVERRIDE, "Accidental override: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
|
MAP.put(ErrorsJvm.ACCIDENTAL_OVERRIDE, "Accidental override: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
|
||||||
MAP.put(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and default objects of classes can be annotated with 'platformStatic'");
|
MAP.put(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and companion objects of classes can be annotated with 'platformStatic'");
|
||||||
MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be 'platformStatic' in object");
|
MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be 'platformStatic' in object");
|
||||||
MAP.put(ErrorsJvm.PLATFORM_STATIC_ILLEGAL_USAGE, "This declaration does not support ''platformStatic''", DescriptorRenderer.SHORT_NAMES_IN_TYPES);
|
MAP.put(ErrorsJvm.PLATFORM_STATIC_ILLEGAL_USAGE, "This declaration does not support ''platformStatic''", DescriptorRenderer.SHORT_NAMES_IN_TYPES);
|
||||||
MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_ABSTRACT, "Native declaration can not be abstract");
|
MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_ABSTRACT, "Native declaration can not be abstract");
|
||||||
|
|||||||
@@ -1379,7 +1379,7 @@ public class JetControlFlowProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitTypeProjection(@NotNull JetTypeProjection typeProjection) {
|
public void visitTypeProjection(@NotNull JetTypeProjection typeProjection) {
|
||||||
// TODO : Support Type Arguments. Default object may be initialized at this point");
|
// TODO : Support Type Arguments. Companion object may be initialized at this point");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ public interface ClassDescriptorWithResolutionScopes extends ClassDescriptor {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
ClassDescriptorWithResolutionScopes getDefaultObjectDescriptor();
|
ClassDescriptorWithResolutionScopes getCompanionObjectDescriptor();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ReadOnly
|
@ReadOnly
|
||||||
|
|||||||
+10
-10
@@ -44,7 +44,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
|||||||
private List<TypeParameterDescriptor> typeParameters;
|
private List<TypeParameterDescriptor> typeParameters;
|
||||||
private Collection<JetType> supertypes = new ArrayList<JetType>();
|
private Collection<JetType> supertypes = new ArrayList<JetType>();
|
||||||
|
|
||||||
private MutableClassDescriptor defaultObjectDescriptor;
|
private MutableClassDescriptor companionObjectDescriptor;
|
||||||
|
|
||||||
private final Set<ConstructorDescriptor> constructors = Sets.newLinkedHashSet();
|
private final Set<ConstructorDescriptor> constructors = Sets.newLinkedHashSet();
|
||||||
private ConstructorDescriptor primaryConstructor;
|
private ConstructorDescriptor primaryConstructor;
|
||||||
@@ -71,7 +71,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
|||||||
@NotNull SourceElement source
|
@NotNull SourceElement source
|
||||||
) {
|
) {
|
||||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source);
|
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source);
|
||||||
assert kind != ClassKind.OBJECT : "Fix isDefaultObject()";
|
assert kind != ClassKind.OBJECT : "Fix isCompanionObject()";
|
||||||
|
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.isInner = isInner;
|
this.isInner = isInner;
|
||||||
@@ -98,13 +98,13 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public MutableClassDescriptor getDefaultObjectDescriptor() {
|
public MutableClassDescriptor getCompanionObjectDescriptor() {
|
||||||
return defaultObjectDescriptor;
|
return companionObjectDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) {
|
public void setCompanionObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) {
|
||||||
assert this.defaultObjectDescriptor == null : "classObjectDescriptor already assigned in " + this;
|
assert this.companionObjectDescriptor == null : "classObjectDescriptor already assigned in " + this;
|
||||||
this.defaultObjectDescriptor = classObjectDescriptor;
|
this.companionObjectDescriptor = classObjectDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -155,7 +155,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDefaultObject() {
|
public boolean isCompanionObject() {
|
||||||
//TODO:
|
//TODO:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -329,8 +329,8 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
|||||||
|
|
||||||
public void lockScopes() {
|
public void lockScopes() {
|
||||||
getScopeForMemberLookupAsWritableScope().changeLockLevel(WritableScope.LockLevel.READING);
|
getScopeForMemberLookupAsWritableScope().changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
if (defaultObjectDescriptor != null) {
|
if (companionObjectDescriptor != null) {
|
||||||
defaultObjectDescriptor.lockScopes();
|
companionObjectDescriptor.lockScopes();
|
||||||
}
|
}
|
||||||
scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
|
|||||||
@@ -203,10 +203,10 @@ public interface Errors {
|
|||||||
DiagnosticFactory1<JetTypeReference, ClassDescriptor> ENUM_ENTRY_ILLEGAL_TYPE = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetTypeReference, ClassDescriptor> ENUM_ENTRY_ILLEGAL_TYPE = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<JetClass, ClassDescriptor> LOCAL_ENUM_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
DiagnosticFactory1<JetClass, ClassDescriptor> LOCAL_ENUM_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||||
|
|
||||||
// Default objects
|
// Companion objects
|
||||||
|
|
||||||
DiagnosticFactory0<JetObjectDeclaration> MANY_DEFAULT_OBJECTS = DiagnosticFactory0.create(ERROR, DEFAULT_OBJECT);
|
DiagnosticFactory0<JetObjectDeclaration> MANY_COMPANION_OBJECTS = DiagnosticFactory0.create(ERROR, COMPANION_OBJECT);
|
||||||
DiagnosticFactory0<JetObjectDeclaration> DEFAULT_OBJECT_NOT_ALLOWED = DiagnosticFactory0.create(ERROR, DEFAULT_OBJECT);
|
DiagnosticFactory0<JetObjectDeclaration> COMPANION_OBJECT_NOT_ALLOWED = DiagnosticFactory0.create(ERROR, COMPANION_OBJECT);
|
||||||
|
|
||||||
DiagnosticFactory0<JetObjectDeclaration> DEPRECATED_CLASS_OBJECT_SYNTAX = DiagnosticFactory0.create(WARNING);
|
DiagnosticFactory0<JetObjectDeclaration> DEPRECATED_CLASS_OBJECT_SYNTAX = DiagnosticFactory0.create(WARNING);
|
||||||
|
|
||||||
@@ -217,12 +217,12 @@ public interface Errors {
|
|||||||
// Type parameter declarations
|
// Type parameter declarations
|
||||||
|
|
||||||
DiagnosticFactory1<JetTypeReference, JetType> FINAL_UPPER_BOUND = DiagnosticFactory1.create(WARNING);
|
DiagnosticFactory1<JetTypeReference, JetType> FINAL_UPPER_BOUND = DiagnosticFactory1.create(WARNING);
|
||||||
DiagnosticFactory1<JetTypeReference, JetType> FINAL_DEFAULT_OBJECT_UPPER_BOUND = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetTypeReference, JetType> FINAL_COMPANION_OBJECT_UPPER_BOUND = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory0<JetTypeReference> DYNAMIC_UPPER_BOUND = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<JetTypeReference> DYNAMIC_UPPER_BOUND = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory1<JetNamedDeclaration, TypeParameterDescriptor> CONFLICTING_UPPER_BOUNDS =
|
DiagnosticFactory1<JetNamedDeclaration, TypeParameterDescriptor> CONFLICTING_UPPER_BOUNDS =
|
||||||
DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||||
DiagnosticFactory1<JetNamedDeclaration, TypeParameterDescriptor> CONFLICTING_DEFAULT_OBJECT_UPPER_BOUNDS
|
DiagnosticFactory1<JetNamedDeclaration, TypeParameterDescriptor> CONFLICTING_COMPANION_OBJECT_UPPER_BOUNDS
|
||||||
= DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
= DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||||
|
|
||||||
DiagnosticFactory2<JetSimpleNameExpression, JetTypeConstraint, JetTypeParameterListOwner> NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER =
|
DiagnosticFactory2<JetSimpleNameExpression, JetTypeConstraint, JetTypeParameterListOwner> NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER =
|
||||||
@@ -636,7 +636,7 @@ public interface Errors {
|
|||||||
|
|
||||||
DiagnosticFactory0<JetThisExpression> NO_THIS = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<JetThisExpression> NO_THIS = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<JetRootPackageExpression> PACKAGE_IS_NOT_AN_EXPRESSION = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<JetRootPackageExpression> PACKAGE_IS_NOT_AN_EXPRESSION = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory1<JetSimpleNameExpression, ClassifierDescriptor> NO_DEFAULT_OBJECT = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetSimpleNameExpression, ClassifierDescriptor> NO_COMPANION_OBJECT = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<JetSimpleNameExpression, TypeParameterDescriptor> TYPE_PARAMETER_IS_NOT_AN_EXPRESSION = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetSimpleNameExpression, TypeParameterDescriptor> TYPE_PARAMETER_IS_NOT_AN_EXPRESSION = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<JetSimpleNameExpression, TypeParameterDescriptor> TYPE_PARAMETER_ON_LHS_OF_DOT = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetSimpleNameExpression, TypeParameterDescriptor> TYPE_PARAMETER_ON_LHS_OF_DOT = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<JetExpression, ClassDescriptor> NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetExpression, ClassDescriptor> NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE = DiagnosticFactory1.create(ERROR);
|
||||||
|
|||||||
@@ -391,10 +391,10 @@ public object PositioningStrategies {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public val DEFAULT_OBJECT: PositioningStrategy<JetObjectDeclaration> = object : PositioningStrategy<JetObjectDeclaration>() {
|
public val COMPANION_OBJECT: PositioningStrategy<JetObjectDeclaration> = object : PositioningStrategy<JetObjectDeclaration>() {
|
||||||
override fun mark(element: JetObjectDeclaration): List<TextRange> {
|
override fun mark(element: JetObjectDeclaration): List<TextRange> {
|
||||||
if (element.hasModifier(JetTokens.DEFAULT_KEYWORD)) {
|
if (element.hasModifier(JetTokens.COMPANION_KEYWORD)) {
|
||||||
return modifierSetPosition(JetTokens.DEFAULT_KEYWORD).mark(element)
|
return modifierSetPosition(JetTokens.COMPANION_KEYWORD).mark(element)
|
||||||
}
|
}
|
||||||
return DEFAULT.mark(element)
|
return DEFAULT.mark(element)
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -273,10 +273,10 @@ public class DefaultErrorMessages {
|
|||||||
|
|
||||||
MAP.put(UNREACHABLE_CODE, "Unreachable code", TO_STRING);
|
MAP.put(UNREACHABLE_CODE, "Unreachable code", TO_STRING);
|
||||||
|
|
||||||
MAP.put(MANY_DEFAULT_OBJECTS, "Only one default object is allowed per class");
|
MAP.put(MANY_COMPANION_OBJECTS, "Only one companion object is allowed per class");
|
||||||
MAP.put(DEFAULT_OBJECT_NOT_ALLOWED, "A default object is not allowed here");
|
MAP.put(COMPANION_OBJECT_NOT_ALLOWED, "A companion object is not allowed here");
|
||||||
|
|
||||||
MAP.put(DEPRECATED_CLASS_OBJECT_SYNTAX, "'class object' syntax for default objects was deprecated. Use 'default' modifier instead");
|
MAP.put(DEPRECATED_CLASS_OBJECT_SYNTAX, "'class object' syntax for companion objects was deprecated. Use 'default' modifier instead");
|
||||||
|
|
||||||
MAP.put(LOCAL_OBJECT_NOT_ALLOWED, "Named object ''{0}'' is a singleton and cannot be local. Try to use anonymous object instead", NAME);
|
MAP.put(LOCAL_OBJECT_NOT_ALLOWED, "Named object ''{0}'' is a singleton and cannot be local. Try to use anonymous object instead", NAME);
|
||||||
MAP.put(LOCAL_ENUM_NOT_ALLOWED, "Enum class ''{0}'' cannot be local", NAME);
|
MAP.put(LOCAL_ENUM_NOT_ALLOWED, "Enum class ''{0}'' cannot be local", NAME);
|
||||||
@@ -321,9 +321,9 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(USELESS_NULLABLE_CHECK, "Non-null type is checked for instance of nullable type");
|
MAP.put(USELESS_NULLABLE_CHECK, "Non-null type is checked for instance of nullable type");
|
||||||
MAP.put(WRONG_SETTER_PARAMETER_TYPE, "Setter parameter type must be equal to the type of the property, i.e. ''{0}''", RENDER_TYPE, RENDER_TYPE);
|
MAP.put(WRONG_SETTER_PARAMETER_TYPE, "Setter parameter type must be equal to the type of the property, i.e. ''{0}''", RENDER_TYPE, RENDER_TYPE);
|
||||||
MAP.put(WRONG_GETTER_RETURN_TYPE, "Getter return type must be equal to the type of the property, i.e. ''{0}''", RENDER_TYPE, RENDER_TYPE);
|
MAP.put(WRONG_GETTER_RETURN_TYPE, "Getter return type must be equal to the type of the property, i.e. ''{0}''", RENDER_TYPE, RENDER_TYPE);
|
||||||
MAP.put(NO_DEFAULT_OBJECT, "Please specify constructor invocation; classifier ''{0}'' does not have a default object", NAME);
|
MAP.put(NO_COMPANION_OBJECT, "Please specify constructor invocation; classifier ''{0}'' does not have a companion object", NAME);
|
||||||
MAP.put(TYPE_PARAMETER_IS_NOT_AN_EXPRESSION, "Type parameter ''{0}'' is not an expression", NAME);
|
MAP.put(TYPE_PARAMETER_IS_NOT_AN_EXPRESSION, "Type parameter ''{0}'' is not an expression", NAME);
|
||||||
MAP.put(TYPE_PARAMETER_ON_LHS_OF_DOT, "Type parameter ''{0}'' cannot have or inherit a default object, so it cannot be on the left hand side of dot", NAME);
|
MAP.put(TYPE_PARAMETER_ON_LHS_OF_DOT, "Type parameter ''{0}'' cannot have or inherit a companion object, so it cannot be on the left hand side of dot", NAME);
|
||||||
MAP.put(NO_GENERICS_IN_SUPERTYPE_SPECIFIER, "Generic arguments of the base type must be specified");
|
MAP.put(NO_GENERICS_IN_SUPERTYPE_SPECIFIER, "Generic arguments of the base type must be specified");
|
||||||
MAP.put(NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE, "Nested {0} accessed via instance reference", RENDER_CLASS_OR_OBJECT_NAME);
|
MAP.put(NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE, "Nested {0} accessed via instance reference", RENDER_CLASS_OR_OBJECT_NAME);
|
||||||
MAP.put(NESTED_CLASS_SHOULD_BE_QUALIFIED, "Nested {0} should be qualified as ''{1}''", RENDER_CLASS_OR_OBJECT_NAME, TO_STRING);
|
MAP.put(NESTED_CLASS_SHOULD_BE_QUALIFIED, "Nested {0} should be qualified as ''{1}''", RENDER_CLASS_OR_OBJECT_NAME, TO_STRING);
|
||||||
@@ -381,12 +381,12 @@ public class DefaultErrorMessages {
|
|||||||
});
|
});
|
||||||
|
|
||||||
MAP.put(UPPER_BOUND_VIOLATED, "Type argument is not within its bounds: should be subtype of ''{0}''", RENDER_TYPE, RENDER_TYPE);
|
MAP.put(UPPER_BOUND_VIOLATED, "Type argument is not within its bounds: should be subtype of ''{0}''", RENDER_TYPE, RENDER_TYPE);
|
||||||
MAP.put(FINAL_DEFAULT_OBJECT_UPPER_BOUND, "''{0}'' is a final type, and thus a default object cannot extend it", RENDER_TYPE);
|
MAP.put(FINAL_COMPANION_OBJECT_UPPER_BOUND, "''{0}'' is a final type, and thus a companion object cannot extend it", RENDER_TYPE);
|
||||||
MAP.put(FINAL_UPPER_BOUND, "''{0}'' is a final type, and thus a value of the type parameter is predetermined", RENDER_TYPE);
|
MAP.put(FINAL_UPPER_BOUND, "''{0}'' is a final type, and thus a value of the type parameter is predetermined", RENDER_TYPE);
|
||||||
MAP.put(DYNAMIC_UPPER_BOUND, "Dynamic type can not be used as an upper bound");
|
MAP.put(DYNAMIC_UPPER_BOUND, "Dynamic type can not be used as an upper bound");
|
||||||
MAP.put(USELESS_ELVIS, "Elvis operator (?:) always returns the left operand of non-nullable type {0}", RENDER_TYPE);
|
MAP.put(USELESS_ELVIS, "Elvis operator (?:) always returns the left operand of non-nullable type {0}", RENDER_TYPE);
|
||||||
MAP.put(CONFLICTING_UPPER_BOUNDS, "Upper bounds of {0} have empty intersection", NAME);
|
MAP.put(CONFLICTING_UPPER_BOUNDS, "Upper bounds of {0} have empty intersection", NAME);
|
||||||
MAP.put(CONFLICTING_DEFAULT_OBJECT_UPPER_BOUNDS, "Default object upper bounds of {0} have empty intersection", NAME);
|
MAP.put(CONFLICTING_COMPANION_OBJECT_UPPER_BOUNDS, "Companion object upper bounds of {0} have empty intersection", NAME);
|
||||||
|
|
||||||
MAP.put(TOO_MANY_ARGUMENTS, "Too many arguments for {0}", FQ_NAMES_IN_TYPES);
|
MAP.put(TOO_MANY_ARGUMENTS, "Too many arguments for {0}", FQ_NAMES_IN_TYPES);
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public interface JetTokens {
|
|||||||
JetModifierKeywordToken VARARG_KEYWORD = JetModifierKeywordToken.softKeywordModifier("vararg");
|
JetModifierKeywordToken VARARG_KEYWORD = JetModifierKeywordToken.softKeywordModifier("vararg");
|
||||||
JetModifierKeywordToken REIFIED_KEYWORD = JetModifierKeywordToken.softKeywordModifier("reified");
|
JetModifierKeywordToken REIFIED_KEYWORD = JetModifierKeywordToken.softKeywordModifier("reified");
|
||||||
JetModifierKeywordToken DYNAMIC_KEYWORD = JetModifierKeywordToken.softKeywordModifier("dynamic");
|
JetModifierKeywordToken DYNAMIC_KEYWORD = JetModifierKeywordToken.softKeywordModifier("dynamic");
|
||||||
JetModifierKeywordToken DEFAULT_KEYWORD = JetModifierKeywordToken.softKeywordModifier("default");
|
JetModifierKeywordToken COMPANION_KEYWORD = JetModifierKeywordToken.softKeywordModifier("companion");
|
||||||
|
|
||||||
JetKeywordToken FINALLY_KEYWORD = JetKeywordToken.softKeyword("finally");
|
JetKeywordToken FINALLY_KEYWORD = JetKeywordToken.softKeyword("finally");
|
||||||
JetModifierKeywordToken FINAL_KEYWORD = JetModifierKeywordToken.softKeywordModifier("final");
|
JetModifierKeywordToken FINAL_KEYWORD = JetModifierKeywordToken.softKeywordModifier("final");
|
||||||
@@ -173,7 +173,7 @@ public interface JetTokens {
|
|||||||
SET_KEYWORD, ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD, ANNOTATION_KEYWORD,
|
SET_KEYWORD, ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD, ANNOTATION_KEYWORD,
|
||||||
OVERRIDE_KEYWORD, PRIVATE_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD,
|
OVERRIDE_KEYWORD, PRIVATE_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD,
|
||||||
CATCH_KEYWORD, FINALLY_KEYWORD, OUT_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD, REIFIED_KEYWORD,
|
CATCH_KEYWORD, FINALLY_KEYWORD, OUT_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD, REIFIED_KEYWORD,
|
||||||
DYNAMIC_KEYWORD, DEFAULT_KEYWORD, CONSTRUCTOR_KEYWORD, INIT_KEYWORD
|
DYNAMIC_KEYWORD, COMPANION_KEYWORD, CONSTRUCTOR_KEYWORD, INIT_KEYWORD
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -185,7 +185,7 @@ public interface JetTokens {
|
|||||||
new JetModifierKeywordToken[] {
|
new JetModifierKeywordToken[] {
|
||||||
ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD, ANNOTATION_KEYWORD, OVERRIDE_KEYWORD, PRIVATE_KEYWORD,
|
ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD, ANNOTATION_KEYWORD, OVERRIDE_KEYWORD, PRIVATE_KEYWORD,
|
||||||
PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD, OUT_KEYWORD, IN_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD,
|
PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD, OUT_KEYWORD, IN_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD,
|
||||||
REIFIED_KEYWORD, DEFAULT_KEYWORD
|
REIFIED_KEYWORD, COMPANION_KEYWORD
|
||||||
};
|
};
|
||||||
|
|
||||||
TokenSet MODIFIER_KEYWORDS = TokenSet.create(MODIFIER_KEYWORDS_ARRAY);
|
TokenSet MODIFIER_KEYWORDS = TokenSet.create(MODIFIER_KEYWORDS_ARRAY);
|
||||||
|
|||||||
@@ -785,7 +785,7 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
* ;
|
* ;
|
||||||
*
|
*
|
||||||
* memberDeclaration'
|
* memberDeclaration'
|
||||||
* : defaultObject
|
* : companionObject
|
||||||
* : secondaryConstructor
|
* : secondaryConstructor
|
||||||
* : function
|
* : function
|
||||||
* : property
|
* : property
|
||||||
@@ -957,7 +957,7 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* defaultObject
|
* companionObject
|
||||||
* : modifiers "class" object
|
* : modifiers "class" object
|
||||||
* ;
|
* ;
|
||||||
*/
|
*/
|
||||||
@@ -2083,7 +2083,7 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
if (item == JetTokens.ENUM_KEYWORD) {
|
if (item == JetTokens.ENUM_KEYWORD) {
|
||||||
enumDetected = true;
|
enumDetected = true;
|
||||||
}
|
}
|
||||||
else if (item == JetTokens.DEFAULT_KEYWORD) {
|
else if (item == JetTokens.COMPANION_KEYWORD) {
|
||||||
defaultDetected = true;
|
defaultDetected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,12 +220,12 @@ public class JetClass extends JetTypeParameterListOwnerStub<KotlinClassStub> imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JetObjectDeclaration> getDefaultObjects() {
|
public List<JetObjectDeclaration> getCompanionObjects() {
|
||||||
JetClassBody body = getBody();
|
JetClassBody body = getBody();
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return body.getAllDefaultObjects();
|
return body.getAllCompanionObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrimaryConstructor() {
|
public boolean hasPrimaryConstructor() {
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ public class JetClassBody extends JetElementImplStub<KotlinPlaceHolderStub<JetCl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JetObjectDeclaration> getAllDefaultObjects() {
|
public List<JetObjectDeclaration> getAllCompanionObjects() {
|
||||||
List<JetObjectDeclaration> result = Lists.newArrayList();
|
List<JetObjectDeclaration> result = Lists.newArrayList();
|
||||||
for (JetObjectDeclaration declaration : getStubOrPsiChildrenAsList(JetStubElementTypes.OBJECT_DECLARATION)) {
|
for (JetObjectDeclaration declaration : getStubOrPsiChildrenAsList(JetStubElementTypes.OBJECT_DECLARATION)) {
|
||||||
if (declaration.isDefault()) {
|
if (declaration.isCompanion()) {
|
||||||
result.add(declaration);
|
result.add(declaration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,10 +95,10 @@ abstract class JetNamedDeclarationStub<T extends KotlinStubWithFqName> extends J
|
|||||||
|
|
||||||
if (hasModifier(JetTokens.PRIVATE_KEYWORD)) {
|
if (hasModifier(JetTokens.PRIVATE_KEYWORD)) {
|
||||||
JetElement containingClass = PsiTreeUtil.getParentOfType(this, JetClassOrObject.class);
|
JetElement containingClass = PsiTreeUtil.getParentOfType(this, JetClassOrObject.class);
|
||||||
if (containingClass instanceof JetObjectDeclaration && ((JetObjectDeclaration) containingClass).isDefault()) {
|
if (containingClass instanceof JetObjectDeclaration && ((JetObjectDeclaration) containingClass).isCompanion()) {
|
||||||
JetElement defaultObjectClass = PsiTreeUtil.getParentOfType(containingClass, JetClassOrObject.class);
|
JetElement companionObjectClass = PsiTreeUtil.getParentOfType(containingClass, JetClassOrObject.class);
|
||||||
if (defaultObjectClass != null) {
|
if (companionObjectClass != null) {
|
||||||
containingClass = defaultObjectClass;
|
containingClass = companionObjectClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (containingClass != null) {
|
if (containingClass != null) {
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ public class JetObjectDeclaration extends JetNamedDeclarationStub<KotlinObjectSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
JetObjectDeclarationName nameAsDeclaration = getNameAsDeclaration();
|
JetObjectDeclarationName nameAsDeclaration = getNameAsDeclaration();
|
||||||
if (nameAsDeclaration == null && isDefault()) {
|
if (nameAsDeclaration == null && isCompanion()) {
|
||||||
//NOTE: a hack in PSI that simplifies writing frontend code
|
//NOTE: a hack in PSI that simplifies writing frontend code
|
||||||
return SpecialNames.DEFAULT_NAME_FOR_DEFAULT_OBJECT.toString();
|
return SpecialNames.DEFAULT_NAME_FOR_COMPANION_OBJECT.toString();
|
||||||
}
|
}
|
||||||
return nameAsDeclaration == null ? null : nameAsDeclaration.getName();
|
return nameAsDeclaration == null ? null : nameAsDeclaration.getName();
|
||||||
}
|
}
|
||||||
@@ -94,12 +94,12 @@ public class JetObjectDeclaration extends JetNamedDeclarationStub<KotlinObjectSt
|
|||||||
return (JetObjectDeclarationName) findChildByType(JetNodeTypes.OBJECT_DECLARATION_NAME);
|
return (JetObjectDeclarationName) findChildByType(JetNodeTypes.OBJECT_DECLARATION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDefault() {
|
public boolean isCompanion() {
|
||||||
KotlinObjectStub stub = getStub();
|
KotlinObjectStub stub = getStub();
|
||||||
if (stub != null) {
|
if (stub != null) {
|
||||||
return stub.isDefault();
|
return stub.isDefault();
|
||||||
}
|
}
|
||||||
return getClassKeyword() != null || hasModifier(JetTokens.DEFAULT_KEYWORD);
|
return getClassKeyword() != null || hasModifier(JetTokens.COMPANION_KEYWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ public class JetTypeConstraint extends JetElementImplStub<KotlinTypeConstraintSt
|
|||||||
return visitor.visitTypeConstraint(this, data);
|
return visitor.visitTypeConstraint(this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDefaultObjectConstraint() {
|
public boolean isCompanionObjectConstraint() {
|
||||||
KotlinTypeConstraintStub stub = getStub();
|
KotlinTypeConstraintStub stub = getStub();
|
||||||
if (stub != null) {
|
if (stub != null) {
|
||||||
return stub.isDefaultObjectConstraint();
|
return stub.isCompanionObjectConstraint();
|
||||||
}
|
}
|
||||||
return findChildByType(JetTokens.CLASS_KEYWORD) != null &&
|
return findChildByType(JetTokens.CLASS_KEYWORD) != null &&
|
||||||
findChildByType(JetTokens.OBJECT_KEYWORD) != null;
|
findChildByType(JetTokens.OBJECT_KEYWORD) != null;
|
||||||
|
|||||||
@@ -95,4 +95,4 @@ private val MODIFIERS_ORDER = listOf(PUBLIC_KEYWORD, PROTECTED_KEYWORD, PRIVATE_
|
|||||||
FINAL_KEYWORD, OPEN_KEYWORD, ABSTRACT_KEYWORD,
|
FINAL_KEYWORD, OPEN_KEYWORD, ABSTRACT_KEYWORD,
|
||||||
OVERRIDE_KEYWORD,
|
OVERRIDE_KEYWORD,
|
||||||
INNER_KEYWORD,
|
INNER_KEYWORD,
|
||||||
ANNOTATION_KEYWORD, ENUM_KEYWORD, DEFAULT_KEYWORD)
|
ANNOTATION_KEYWORD, ENUM_KEYWORD, COMPANION_KEYWORD)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public trait KotlinPropertyStub : KotlinStubWithFqName<JetProperty> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public trait KotlinTypeConstraintStub : StubElement<JetTypeConstraint> {
|
public trait KotlinTypeConstraintStub : StubElement<JetTypeConstraint> {
|
||||||
public fun isDefaultObjectConstraint(): Boolean
|
public fun isCompanionObjectConstraint(): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
public trait KotlinTypeParameterStub : KotlinStubWithFqName<JetTypeParameter> {
|
public trait KotlinTypeParameterStub : KotlinStubWithFqName<JetTypeParameter> {
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ public class JetObjectElementType extends JetStubElementType<KotlinObjectStub, J
|
|||||||
FqName fqName = ResolveSessionUtils.safeFqNameForLazyResolve(psi);
|
FqName fqName = ResolveSessionUtils.safeFqNameForLazyResolve(psi);
|
||||||
List<String> superNames = PsiUtilPackage.getSuperNames(psi);
|
List<String> superNames = PsiUtilPackage.getSuperNames(psi);
|
||||||
return new KotlinObjectStubImpl(parentStub, StringRef.fromString(name), fqName, Utils.INSTANCE$.wrapStrings(superNames),
|
return new KotlinObjectStubImpl(parentStub, StringRef.fromString(name), fqName, Utils.INSTANCE$.wrapStrings(superNames),
|
||||||
psi.isTopLevel(), psi.isDefault(), psi.isLocal(), psi.isObjectLiteral());
|
psi.isTopLevel(), psi.isCompanion(), psi.isLocal(), psi.isObjectLiteral());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+4
-4
@@ -34,18 +34,18 @@ public class JetTypeConstraintElementType extends JetStubElementType<KotlinTypeC
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KotlinTypeConstraintStub createStub(@NotNull JetTypeConstraint psi, StubElement parentStub) {
|
public KotlinTypeConstraintStub createStub(@NotNull JetTypeConstraint psi, StubElement parentStub) {
|
||||||
return new KotlinTypeConstraintStubImpl(parentStub, psi.isDefaultObjectConstraint());
|
return new KotlinTypeConstraintStubImpl(parentStub, psi.isCompanionObjectConstraint());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(@NotNull KotlinTypeConstraintStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
public void serialize(@NotNull KotlinTypeConstraintStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
||||||
dataStream.writeBoolean(stub.isDefaultObjectConstraint());
|
dataStream.writeBoolean(stub.isCompanionObjectConstraint());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public KotlinTypeConstraintStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
public KotlinTypeConstraintStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||||
boolean isDefaultObjectConstraint = dataStream.readBoolean();
|
boolean isCompanionObjectConstraint = dataStream.readBoolean();
|
||||||
return new KotlinTypeConstraintStubImpl(parentStub, isDefaultObjectConstraint);
|
return new KotlinTypeConstraintStubImpl(parentStub, isCompanionObjectConstraint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -24,8 +24,8 @@ import com.intellij.psi.PsiElement
|
|||||||
|
|
||||||
public class KotlinTypeConstraintStubImpl(
|
public class KotlinTypeConstraintStubImpl(
|
||||||
parent: StubElement<out PsiElement>?,
|
parent: StubElement<out PsiElement>?,
|
||||||
private val isDefaultObjectConstraint: Boolean
|
private val isCompanionObjectConstraint: Boolean
|
||||||
) : KotlinStubBaseImpl<JetTypeConstraint>(parent, JetStubElementTypes.TYPE_CONSTRAINT), KotlinTypeConstraintStub {
|
) : KotlinStubBaseImpl<JetTypeConstraint>(parent, JetStubElementTypes.TYPE_CONSTRAINT), KotlinTypeConstraintStub {
|
||||||
|
|
||||||
override fun isDefaultObjectConstraint() = isDefaultObjectConstraint
|
override fun isCompanionObjectConstraint() = isCompanionObjectConstraint
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ public fun DeclarationDescriptor.hasIntrinsicAnnotation(): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public fun CallableDescriptor.isPlatformStaticInObjectOrClass(): Boolean =
|
public fun CallableDescriptor.isPlatformStaticInObjectOrClass(): Boolean =
|
||||||
isPlatformStaticIn { DescriptorUtils.isNonDefaultObject(it) || DescriptorUtils.isClass(it) }
|
isPlatformStaticIn { DescriptorUtils.isNonCompanionObject(it) || DescriptorUtils.isClass(it) }
|
||||||
|
|
||||||
public fun CallableDescriptor.isPlatformStaticInDefaultObject(): Boolean =
|
public fun CallableDescriptor.isPlatformStaticInCompanionObject(): Boolean =
|
||||||
isPlatformStaticIn { DescriptorUtils.isDefaultObject(it) }
|
isPlatformStaticIn { DescriptorUtils.isCompanionObject(it) }
|
||||||
|
|
||||||
private fun CallableDescriptor.isPlatformStaticIn(predicate: (DeclarationDescriptor) -> Boolean): Boolean =
|
private fun CallableDescriptor.isPlatformStaticIn(predicate: (DeclarationDescriptor) -> Boolean): Boolean =
|
||||||
when (this) {
|
when (this) {
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ public interface BindingContext {
|
|||||||
|
|
||||||
WritableSlice<JetReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET =
|
WritableSlice<JetReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET =
|
||||||
new BasicWritableSlice<JetReferenceExpression, DeclarationDescriptor>(DO_NOTHING);
|
new BasicWritableSlice<JetReferenceExpression, DeclarationDescriptor>(DO_NOTHING);
|
||||||
// if 'A' really means 'A.Default' then this slice stores class descriptor for A, REFERENCE_TARGET stores descriptor Default in this case
|
// if 'A' really means 'A.Companion' then this slice stores class descriptor for A, REFERENCE_TARGET stores descriptor Companion in this case
|
||||||
WritableSlice<JetReferenceExpression, ClassDescriptor> SHORT_REFERENCE_TO_DEFAULT_OBJECT =
|
WritableSlice<JetReferenceExpression, ClassDescriptor> SHORT_REFERENCE_TO_COMPANION_OBJECT =
|
||||||
new BasicWritableSlice<JetReferenceExpression, ClassDescriptor>(DO_NOTHING);
|
new BasicWritableSlice<JetReferenceExpression, ClassDescriptor>(DO_NOTHING);
|
||||||
|
|
||||||
@KotlinSignature("val RESOLVED_CALL: WritableSlice<Call, ResolvedCall<out CallableDescriptor>>")
|
@KotlinSignature("val RESOLVED_CALL: WritableSlice<Call, ResolvedCall<out CallableDescriptor>>")
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ public class DeclarationsChecker {
|
|||||||
|
|
||||||
for (JetTypeConstraint constraint : jetClass.getTypeConstraints()) {
|
for (JetTypeConstraint constraint : jetClass.getTypeConstraints()) {
|
||||||
checkBoundsForTypeInClassHeader(constraint.getBoundTypeReference());
|
checkBoundsForTypeInClassHeader(constraint.getBoundTypeReference());
|
||||||
checkFinalUpperBounds(constraint.getBoundTypeReference(), constraint.isDefaultObjectConstraint());
|
checkFinalUpperBounds(constraint.getBoundTypeReference(), constraint.isCompanionObjectConstraint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,11 +164,11 @@ public class DeclarationsChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkFinalUpperBounds(@Nullable JetTypeReference typeReference, boolean isDefaultObjectConstraint) {
|
private void checkFinalUpperBounds(@Nullable JetTypeReference typeReference, boolean isCompanionObjectConstraint) {
|
||||||
if (typeReference != null) {
|
if (typeReference != null) {
|
||||||
JetType type = trace.getBindingContext().get(TYPE, typeReference);
|
JetType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
DescriptorResolver.checkUpperBoundType(typeReference, type, isDefaultObjectConstraint, trace);
|
DescriptorResolver.checkUpperBoundType(typeReference, type, isCompanionObjectConstraint, trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,7 @@ public class DeclarationsChecker {
|
|||||||
private void checkObject(JetObjectDeclaration declaration, ClassDescriptor classDescriptor) {
|
private void checkObject(JetObjectDeclaration declaration, ClassDescriptor classDescriptor) {
|
||||||
checkDeprecatedClassObjectSyntax(declaration);
|
checkDeprecatedClassObjectSyntax(declaration);
|
||||||
reportErrorIfHasIllegalModifier(declaration);
|
reportErrorIfHasIllegalModifier(declaration);
|
||||||
if (declaration.isLocal() && !declaration.isDefault() && !declaration.isObjectLiteral()) {
|
if (declaration.isLocal() && !declaration.isCompanion() && !declaration.isObjectLiteral()) {
|
||||||
trace.report(LOCAL_OBJECT_NOT_ALLOWED.on(declaration, classDescriptor));
|
trace.report(LOCAL_OBJECT_NOT_ALLOWED.on(declaration, classDescriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -455,12 +455,12 @@ public class DescriptorResolver {
|
|||||||
static final class UpperBoundCheckerTask {
|
static final class UpperBoundCheckerTask {
|
||||||
JetTypeReference upperBound;
|
JetTypeReference upperBound;
|
||||||
JetType upperBoundType;
|
JetType upperBoundType;
|
||||||
boolean isDefaultObjectConstraint;
|
boolean isCompanionObjectConstraint;
|
||||||
|
|
||||||
private UpperBoundCheckerTask(JetTypeReference upperBound, JetType upperBoundType, boolean defaultObjectConstraint) {
|
private UpperBoundCheckerTask(JetTypeReference upperBound, JetType upperBoundType, boolean companionObjectConstraint) {
|
||||||
this.upperBound = upperBound;
|
this.upperBound = upperBound;
|
||||||
this.upperBoundType = upperBoundType;
|
this.upperBoundType = upperBoundType;
|
||||||
isDefaultObjectConstraint = defaultObjectConstraint;
|
isCompanionObjectConstraint = companionObjectConstraint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,7 +489,7 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (JetTypeConstraint constraint : declaration.getTypeConstraints()) {
|
for (JetTypeConstraint constraint : declaration.getTypeConstraints()) {
|
||||||
reportUnsupportedDefaultObjectConstraint(trace, constraint);
|
reportUnsupportedCompanionObjectConstraint(trace, constraint);
|
||||||
|
|
||||||
JetSimpleNameExpression subjectTypeParameterName = constraint.getSubjectTypeParameterName();
|
JetSimpleNameExpression subjectTypeParameterName = constraint.getSubjectTypeParameterName();
|
||||||
if (subjectTypeParameterName == null) {
|
if (subjectTypeParameterName == null) {
|
||||||
@@ -502,14 +502,14 @@ public class DescriptorResolver {
|
|||||||
if (boundTypeReference != null) {
|
if (boundTypeReference != null) {
|
||||||
bound = typeResolver.resolveType(scope, boundTypeReference, trace, false);
|
bound = typeResolver.resolveType(scope, boundTypeReference, trace, false);
|
||||||
deferredUpperBoundCheckerTasks
|
deferredUpperBoundCheckerTasks
|
||||||
.add(new UpperBoundCheckerTask(boundTypeReference, bound, constraint.isDefaultObjectConstraint()));
|
.add(new UpperBoundCheckerTask(boundTypeReference, bound, constraint.isCompanionObjectConstraint()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeParameterDescriptor != null) {
|
if (typeParameterDescriptor != null) {
|
||||||
trace.record(BindingContext.REFERENCE_TARGET, subjectTypeParameterName, typeParameterDescriptor);
|
trace.record(BindingContext.REFERENCE_TARGET, subjectTypeParameterName, typeParameterDescriptor);
|
||||||
if (bound != null) {
|
if (bound != null) {
|
||||||
if (constraint.isDefaultObjectConstraint()) {
|
if (constraint.isCompanionObjectConstraint()) {
|
||||||
// Default object bounds are not supported
|
// Companion object bounds are not supported
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
typeParameterDescriptor.addUpperBound(bound);
|
typeParameterDescriptor.addUpperBound(bound);
|
||||||
@@ -528,7 +528,7 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
if (!(declaration instanceof JetClass)) {
|
if (!(declaration instanceof JetClass)) {
|
||||||
for (UpperBoundCheckerTask checkerTask : deferredUpperBoundCheckerTasks) {
|
for (UpperBoundCheckerTask checkerTask : deferredUpperBoundCheckerTasks) {
|
||||||
checkUpperBoundType(checkerTask.upperBound, checkerTask.upperBoundType, checkerTask.isDefaultObjectConstraint, trace);
|
checkUpperBoundType(checkerTask.upperBound, checkerTask.upperBoundType, checkerTask.isCompanionObjectConstraint, trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkNamesInConstraints(declaration, descriptor, scope, trace);
|
checkNamesInConstraints(declaration, descriptor, scope, trace);
|
||||||
@@ -546,7 +546,7 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
JetType classObjectType = parameter.getClassObjectType();
|
JetType classObjectType = parameter.getClassObjectType();
|
||||||
if (classObjectType != null && KotlinBuiltIns.isNothing(classObjectType)) {
|
if (classObjectType != null && KotlinBuiltIns.isNothing(classObjectType)) {
|
||||||
trace.report(CONFLICTING_DEFAULT_OBJECT_UPPER_BOUNDS.on(typeParameter, parameter));
|
trace.report(CONFLICTING_COMPANION_OBJECT_UPPER_BOUNDS.on(typeParameter, parameter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -581,21 +581,21 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reportUnsupportedDefaultObjectConstraint(BindingTrace trace, JetTypeConstraint constraint) {
|
public static void reportUnsupportedCompanionObjectConstraint(BindingTrace trace, JetTypeConstraint constraint) {
|
||||||
if (constraint.isDefaultObjectConstraint()) {
|
if (constraint.isCompanionObjectConstraint()) {
|
||||||
trace.report(UNSUPPORTED.on(constraint, "Default objects constraints are not supported yet"));
|
trace.report(UNSUPPORTED.on(constraint, "Companion objects constraints are not supported yet"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkUpperBoundType(
|
public static void checkUpperBoundType(
|
||||||
JetTypeReference upperBound,
|
JetTypeReference upperBound,
|
||||||
@NotNull JetType upperBoundType,
|
@NotNull JetType upperBoundType,
|
||||||
boolean isDefaultObjectConstraint,
|
boolean isCompanionObjectConstraint,
|
||||||
BindingTrace trace
|
BindingTrace trace
|
||||||
) {
|
) {
|
||||||
if (!TypeUtils.canHaveSubtypes(JetTypeChecker.DEFAULT, upperBoundType)) {
|
if (!TypeUtils.canHaveSubtypes(JetTypeChecker.DEFAULT, upperBoundType)) {
|
||||||
if (isDefaultObjectConstraint) {
|
if (isCompanionObjectConstraint) {
|
||||||
trace.report(FINAL_DEFAULT_OBJECT_UPPER_BOUND.on(upperBound, upperBoundType));
|
trace.report(FINAL_COMPANION_OBJECT_UPPER_BOUND.on(upperBound, upperBoundType));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trace.report(FINAL_UPPER_BOUND.on(upperBound, upperBoundType));
|
trace.report(FINAL_UPPER_BOUND.on(upperBound, upperBoundType));
|
||||||
|
|||||||
@@ -192,13 +192,13 @@ public class LazyTopDownAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkClassOrObjectDeclarations(JetClassOrObject classOrObject, ClassDescriptor classDescriptor) {
|
private void checkClassOrObjectDeclarations(JetClassOrObject classOrObject, ClassDescriptor classDescriptor) {
|
||||||
boolean defaultObjectAlreadyFound = false;
|
boolean companionObjectAlreadyFound = false;
|
||||||
for (JetDeclaration jetDeclaration : classOrObject.getDeclarations()) {
|
for (JetDeclaration jetDeclaration : classOrObject.getDeclarations()) {
|
||||||
if (jetDeclaration instanceof JetObjectDeclaration && ((JetObjectDeclaration) jetDeclaration).isDefault()) {
|
if (jetDeclaration instanceof JetObjectDeclaration && ((JetObjectDeclaration) jetDeclaration).isCompanion()) {
|
||||||
if (defaultObjectAlreadyFound) {
|
if (companionObjectAlreadyFound) {
|
||||||
trace.report(MANY_DEFAULT_OBJECTS.on((JetObjectDeclaration) jetDeclaration));
|
trace.report(MANY_COMPANION_OBJECTS.on((JetObjectDeclaration) jetDeclaration));
|
||||||
}
|
}
|
||||||
defaultObjectAlreadyFound = true;
|
companionObjectAlreadyFound = true;
|
||||||
}
|
}
|
||||||
else if (jetDeclaration instanceof JetSecondaryConstructor) {
|
else if (jetDeclaration instanceof JetSecondaryConstructor) {
|
||||||
if (DescriptorUtils.isSingletonOrAnonymousObject(classDescriptor)) {
|
if (DescriptorUtils.isSingletonOrAnonymousObject(classDescriptor)) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import java.util.*;
|
|||||||
import static org.jetbrains.kotlin.diagnostics.Errors.*;
|
import static org.jetbrains.kotlin.diagnostics.Errors.*;
|
||||||
import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||||
import static org.jetbrains.kotlin.psi.JetStubbedPsiUtil.getContainingDeclaration;
|
import static org.jetbrains.kotlin.psi.JetStubbedPsiUtil.getContainingDeclaration;
|
||||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isDefaultObject;
|
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject;
|
||||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isEnumEntry;
|
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isEnumEntry;
|
||||||
|
|
||||||
public class ModifiersChecker {
|
public class ModifiersChecker {
|
||||||
@@ -235,13 +235,13 @@ public class ModifiersChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkDefaultModifier(@NotNull JetDeclaration declaration) {
|
private void checkDefaultModifier(@NotNull JetDeclaration declaration) {
|
||||||
if (declaration.hasModifier(DEFAULT_KEYWORD) && !isDefaultModifierAllowed(declaration)) {
|
if (declaration.hasModifier(COMPANION_KEYWORD) && !isDefaultModifierAllowed(declaration)) {
|
||||||
reportIllegalModifiers(declaration, Collections.singletonList(DEFAULT_KEYWORD));
|
reportIllegalModifiers(declaration, Collections.singletonList(COMPANION_KEYWORD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: just checks if this is legal context for default modifier (Default object descriptor can be created)
|
// NOTE: just checks if this is legal context for companion modifier (Companion object descriptor can be created)
|
||||||
// DEFAULT_OBJECT_NOT_ALLOWED can be reported later
|
// COMPANION_OBJECT_NOT_ALLOWED can be reported later
|
||||||
public static boolean isDefaultModifierAllowed(@NotNull JetDeclaration declaration) {
|
public static boolean isDefaultModifierAllowed(@NotNull JetDeclaration declaration) {
|
||||||
if (declaration instanceof JetObjectDeclaration) {
|
if (declaration instanceof JetObjectDeclaration) {
|
||||||
JetDeclaration containingDeclaration = getContainingDeclaration(declaration);
|
JetDeclaration containingDeclaration = getContainingDeclaration(declaration);
|
||||||
@@ -388,7 +388,7 @@ public class ModifiersChecker {
|
|||||||
if (isEnumEntry(descriptor)) {
|
if (isEnumEntry(descriptor)) {
|
||||||
return Visibilities.PUBLIC;
|
return Visibilities.PUBLIC;
|
||||||
}
|
}
|
||||||
if (isDefaultObject(descriptor)) {
|
if (isCompanionObject(descriptor)) {
|
||||||
return ((ClassDescriptor) descriptor.getContainingDeclaration()).getVisibility();
|
return ((ClassDescriptor) descriptor.getContainingDeclaration()).getVisibility();
|
||||||
}
|
}
|
||||||
return Visibilities.INTERNAL;
|
return Visibilities.INTERNAL;
|
||||||
|
|||||||
@@ -121,9 +121,9 @@ public class OverloadResolver {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
if (jetClass instanceof JetObjectDeclaration) {
|
if (jetClass instanceof JetObjectDeclaration) {
|
||||||
// must be default object
|
// must be companion object
|
||||||
name = classDescriptor.getContainingDeclaration().getName().asString();
|
name = classDescriptor.getContainingDeclaration().getName().asString();
|
||||||
return "default object " + name;
|
return "companion object " + name;
|
||||||
}
|
}
|
||||||
// safe
|
// safe
|
||||||
return "<unknown>";
|
return "<unknown>";
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ public class TaskPrioritizer(private val storageManager: StorageManager) {
|
|||||||
val classifierDescriptor = qualifierReceiver.classifier
|
val classifierDescriptor = qualifierReceiver.classifier
|
||||||
doComputeTasks(classObjectReceiver, taskPrioritizerContext.filterCollectors {
|
doComputeTasks(classObjectReceiver, taskPrioritizerContext.filterCollectors {
|
||||||
when {
|
when {
|
||||||
classifierDescriptor is ClassDescriptor && classifierDescriptor.getDefaultObjectDescriptor() != null -> {
|
classifierDescriptor is ClassDescriptor && classifierDescriptor.getCompanionObjectDescriptor() != null -> {
|
||||||
// nested classes and objects should not be accessible via short reference to default object
|
// nested classes and objects should not be accessible via short reference to companion object
|
||||||
it !is ConstructorDescriptor && it !is FakeCallableDescriptorForObject
|
it !is ConstructorDescriptor && it !is FakeCallableDescriptorForObject
|
||||||
}
|
}
|
||||||
classifierDescriptor != null && DescriptorUtils.isEnumEntry(classifierDescriptor) -> {
|
classifierDescriptor != null && DescriptorUtils.isEnumEntry(classifierDescriptor) -> {
|
||||||
|
|||||||
+2
-2
@@ -60,8 +60,8 @@ public class TracingStrategyImpl extends AbstractTracingStrategy {
|
|||||||
if (descriptor instanceof FakeCallableDescriptorForObject) {
|
if (descriptor instanceof FakeCallableDescriptorForObject) {
|
||||||
FakeCallableDescriptorForObject fakeCallableDescriptorForObject = (FakeCallableDescriptorForObject) descriptor;
|
FakeCallableDescriptorForObject fakeCallableDescriptorForObject = (FakeCallableDescriptorForObject) descriptor;
|
||||||
descriptor = fakeCallableDescriptorForObject.getReferencedDescriptor();
|
descriptor = fakeCallableDescriptorForObject.getReferencedDescriptor();
|
||||||
if (fakeCallableDescriptorForObject.getClassDescriptor().getDefaultObjectDescriptor() != null) {
|
if (fakeCallableDescriptorForObject.getClassDescriptor().getCompanionObjectDescriptor() != null) {
|
||||||
trace.record(SHORT_REFERENCE_TO_DEFAULT_OBJECT, reference, fakeCallableDescriptorForObject.getClassDescriptor());
|
trace.record(SHORT_REFERENCE_TO_COMPANION_OBJECT, reference, fakeCallableDescriptorForObject.getClassDescriptor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeclarationDescriptor storedReference = trace.get(REFERENCE_TARGET, reference);
|
DeclarationDescriptor storedReference = trace.get(REFERENCE_TARGET, reference);
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ public class FakeCallableDescriptorForObject(
|
|||||||
|
|
||||||
{
|
{
|
||||||
assert(classDescriptor.getClassObjectType() != null) {
|
assert(classDescriptor.getClassObjectType() != null) {
|
||||||
"FakeCallableDescriptorForObject can be created only for objects, classes with default object or enum entries: $classDescriptor"
|
"FakeCallableDescriptorForObject can be created only for objects, classes with companion object or enum entries: $classDescriptor"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public interface JetClassLikeInfo extends JetDeclarationContainer {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ReadOnly
|
@ReadOnly
|
||||||
List<JetObjectDeclaration> getDefaultObjects();
|
List<JetObjectDeclaration> getCompanionObjects();
|
||||||
|
|
||||||
// This element is used to identify resolution scope for the class
|
// This element is used to identify resolution scope for the class
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+2
-2
@@ -58,12 +58,12 @@ public abstract class JetClassOrObjectInfo<E extends JetClassOrObject> implement
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<JetObjectDeclaration> getDefaultObjects() {
|
public List<JetObjectDeclaration> getCompanionObjects() {
|
||||||
JetClassBody body = element.getBody();
|
JetClassBody body = element.getBody();
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return body.getAllDefaultObjects();
|
return body.getAllCompanionObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class JetObjectInfo extends JetClassOrObjectInfo<JetObjectDeclaration> {
|
|||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDefaultObject() {
|
public boolean isCompanionObject() {
|
||||||
return element.isDefault() && ModifiersChecker.isDefaultModifierAllowed(element);
|
return element.isCompanion() && ModifiersChecker.isDefaultModifierAllowed(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class JetScriptInfo(
|
|||||||
public val fqName: FqName = ScriptNameUtil.classNameForScript(script)
|
public val fqName: FqName = ScriptNameUtil.classNameForScript(script)
|
||||||
override fun getContainingPackageFqName() = fqName.parent()
|
override fun getContainingPackageFqName() = fqName.parent()
|
||||||
override fun getModifierList() = null
|
override fun getModifierList() = null
|
||||||
override fun getDefaultObjects() = listOf<JetObjectDeclaration>()
|
override fun getCompanionObjects() = listOf<JetObjectDeclaration>()
|
||||||
override fun getScopeAnchor() = script
|
override fun getScopeAnchor() = script
|
||||||
override fun getCorrespondingClassOrObject() = null
|
override fun getCorrespondingClassOrObject() = null
|
||||||
override fun getTypeParameterList() = null
|
override fun getTypeParameterList() = null
|
||||||
|
|||||||
+46
-46
@@ -83,8 +83,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
|
|
||||||
private final Annotations annotations;
|
private final Annotations annotations;
|
||||||
private final Annotations danglingAnnotations;
|
private final Annotations danglingAnnotations;
|
||||||
private final NullableLazyValue<LazyClassDescriptor> defaultObjectDescriptor;
|
private final NullableLazyValue<LazyClassDescriptor> companionObjectDescriptor;
|
||||||
private final MemoizedFunctionToNotNull<JetObjectDeclaration, ClassDescriptor> extraDefaultObjectDescriptors;
|
private final MemoizedFunctionToNotNull<JetObjectDeclaration, ClassDescriptor> extraCompanionObjectDescriptors;
|
||||||
|
|
||||||
private final LazyClassMemberScope unsubstitutedMemberScope;
|
private final LazyClassMemberScope unsubstitutedMemberScope;
|
||||||
private final JetScope staticScope = new StaticScopeForKotlinClass(this);
|
private final JetScope staticScope = new StaticScopeForKotlinClass(this);
|
||||||
@@ -95,7 +95,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
private final NotNullLazyValue<JetScope> scopeForSecondaryConstructorHeaderResolution;
|
private final NotNullLazyValue<JetScope> scopeForSecondaryConstructorHeaderResolution;
|
||||||
|
|
||||||
private final NullableLazyValue<Void> forceResolveAllContents;
|
private final NullableLazyValue<Void> forceResolveAllContents;
|
||||||
private final boolean isDefaultObject;
|
private final boolean isCompanionObject;
|
||||||
|
|
||||||
public LazyClassDescriptor(
|
public LazyClassDescriptor(
|
||||||
@NotNull LazyClassContext c,
|
@NotNull LazyClassContext c,
|
||||||
@@ -122,7 +122,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
this.typeConstructor = new LazyClassTypeConstructor();
|
this.typeConstructor = new LazyClassTypeConstructor();
|
||||||
|
|
||||||
this.kind = classLikeInfo.getClassKind();
|
this.kind = classLikeInfo.getClassKind();
|
||||||
this.isDefaultObject = classLikeInfo instanceof JetObjectInfo && ((JetObjectInfo) classLikeInfo).isDefaultObject();
|
this.isCompanionObject = classLikeInfo instanceof JetObjectInfo && ((JetObjectInfo) classLikeInfo).isCompanionObject();
|
||||||
|
|
||||||
JetModifierList modifierList = classLikeInfo.getModifierList();
|
JetModifierList modifierList = classLikeInfo.getModifierList();
|
||||||
if (kind.isSingleton()) {
|
if (kind.isSingleton()) {
|
||||||
@@ -182,16 +182,16 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.defaultObjectDescriptor = storageManager.createNullableLazyValue(new Function0<LazyClassDescriptor>() {
|
this.companionObjectDescriptor = storageManager.createNullableLazyValue(new Function0<LazyClassDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public LazyClassDescriptor invoke() {
|
public LazyClassDescriptor invoke() {
|
||||||
return computeDefaultObjectDescriptor(getDefaultObjectIfAllowed());
|
return computeCompanionObjectDescriptor(getCompanionObjectIfAllowed());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.extraDefaultObjectDescriptors = storageManager.createMemoizedFunction(new Function1<JetObjectDeclaration, ClassDescriptor>() {
|
this.extraCompanionObjectDescriptors = storageManager.createMemoizedFunction(new Function1<JetObjectDeclaration, ClassDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public ClassDescriptor invoke(JetObjectDeclaration defaultObject) {
|
public ClassDescriptor invoke(JetObjectDeclaration companionObject) {
|
||||||
return computeDefaultObjectDescriptor(defaultObject);
|
return computeCompanionObjectDescriptor(companionObject);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.scopeForClassHeaderResolution = storageManager.createLazyValue(new Function0<JetScope>() {
|
this.scopeForClassHeaderResolution = storageManager.createLazyValue(new Function0<JetScope>() {
|
||||||
@@ -277,8 +277,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
thisScope.setImplicitReceiver(this.getThisAsReceiverParameter());
|
thisScope.setImplicitReceiver(this.getThisAsReceiverParameter());
|
||||||
thisScope.changeLockLevel(WritableScope.LockLevel.READING);
|
thisScope.changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
|
|
||||||
ClassDescriptor defaultObjectDescriptor = getDefaultObjectDescriptor();
|
ClassDescriptor companionObjectDescriptor = getCompanionObjectDescriptor();
|
||||||
JetScope defaultObjectAdapterScope = (defaultObjectDescriptor != null) ? new DefaultObjectMixinScope(defaultObjectDescriptor) : JetScope.Empty.INSTANCE$;
|
JetScope companionObjectAdapterScope = (companionObjectDescriptor != null) ? new CompanionObjectMixinScope(companionObjectDescriptor) : JetScope.Empty.INSTANCE$;
|
||||||
|
|
||||||
return new ChainedScope(
|
return new ChainedScope(
|
||||||
this,
|
this,
|
||||||
@@ -286,7 +286,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
thisScope,
|
thisScope,
|
||||||
getScopeForMemberLookup(),
|
getScopeForMemberLookup(),
|
||||||
getScopeForClassHeaderResolution(),
|
getScopeForClassHeaderResolution(),
|
||||||
defaultObjectAdapterScope,
|
companionObjectAdapterScope,
|
||||||
getStaticScope()
|
getStaticScope()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -374,47 +374,47 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LazyClassDescriptor getDefaultObjectDescriptor() {
|
public LazyClassDescriptor getCompanionObjectDescriptor() {
|
||||||
return defaultObjectDescriptor.invoke();
|
return companionObjectDescriptor.invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ReadOnly
|
@ReadOnly
|
||||||
public List<ClassDescriptor> getDescriptorsForExtraDefaultObjects() {
|
public List<ClassDescriptor> getDescriptorsForExtraCompanionObjects() {
|
||||||
final JetObjectDeclaration allowedDefaultObject = getDefaultObjectIfAllowed();
|
final JetObjectDeclaration allowedCompanionObject = getCompanionObjectIfAllowed();
|
||||||
|
|
||||||
return KotlinPackage.map(
|
return KotlinPackage.map(
|
||||||
KotlinPackage.filter(
|
KotlinPackage.filter(
|
||||||
declarationProvider.getOwnerInfo().getDefaultObjects(),
|
declarationProvider.getOwnerInfo().getCompanionObjects(),
|
||||||
new Function1<JetObjectDeclaration, Boolean>() {
|
new Function1<JetObjectDeclaration, Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean invoke(JetObjectDeclaration defaultObject) {
|
public Boolean invoke(JetObjectDeclaration companionObject) {
|
||||||
return defaultObject != allowedDefaultObject;
|
return companionObject != allowedCompanionObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
new Function1<JetObjectDeclaration, ClassDescriptor>() {
|
new Function1<JetObjectDeclaration, ClassDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public ClassDescriptor invoke(JetObjectDeclaration defaultObject) {
|
public ClassDescriptor invoke(JetObjectDeclaration companionObject) {
|
||||||
return extraDefaultObjectDescriptors.invoke(defaultObject);
|
return extraCompanionObjectDescriptors.invoke(companionObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private LazyClassDescriptor computeDefaultObjectDescriptor(@Nullable JetObjectDeclaration defaultObject) {
|
private LazyClassDescriptor computeCompanionObjectDescriptor(@Nullable JetObjectDeclaration companionObject) {
|
||||||
JetClassLikeInfo defaultObjectInfo = getDefaultObjectInfo(defaultObject);
|
JetClassLikeInfo companionObjectInfo = getCompanionObjectInfo(companionObject);
|
||||||
if (!(defaultObjectInfo instanceof JetClassOrObjectInfo)) {
|
if (!(companionObjectInfo instanceof JetClassOrObjectInfo)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Name name = ((JetClassOrObjectInfo) defaultObjectInfo).getName();
|
Name name = ((JetClassOrObjectInfo) companionObjectInfo).getName();
|
||||||
assert name != null;
|
assert name != null;
|
||||||
getScopeForMemberLookup().getClassifier(name);
|
getScopeForMemberLookup().getClassifier(name);
|
||||||
ClassDescriptor defaultObjectDescriptor = c.getTrace().get(BindingContext.CLASS, defaultObject);
|
ClassDescriptor companionObjectDescriptor = c.getTrace().get(BindingContext.CLASS, companionObject);
|
||||||
if (defaultObjectDescriptor instanceof LazyClassDescriptor) {
|
if (companionObjectDescriptor instanceof LazyClassDescriptor) {
|
||||||
assert DescriptorUtils.isDefaultObject(defaultObjectDescriptor) : "Not a default object: " + defaultObjectDescriptor;
|
assert DescriptorUtils.isCompanionObject(companionObjectDescriptor) : "Not a companion object: " + companionObjectDescriptor;
|
||||||
return (LazyClassDescriptor) defaultObjectDescriptor;
|
return (LazyClassDescriptor) companionObjectDescriptor;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
return null;
|
||||||
@@ -422,25 +422,25 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private JetClassLikeInfo getDefaultObjectInfo(@Nullable JetObjectDeclaration defaultObject) {
|
private JetClassLikeInfo getCompanionObjectInfo(@Nullable JetObjectDeclaration companionObject) {
|
||||||
if (defaultObject != null) {
|
if (companionObject != null) {
|
||||||
if (!isDefaultObjectAllowed()) {
|
if (!isCompanionObjectAllowed()) {
|
||||||
c.getTrace().report(DEFAULT_OBJECT_NOT_ALLOWED.on(defaultObject));
|
c.getTrace().report(COMPANION_OBJECT_NOT_ALLOWED.on(companionObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
return JetClassInfoUtil.createClassLikeInfo(defaultObject);
|
return JetClassInfoUtil.createClassLikeInfo(companionObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private JetObjectDeclaration getDefaultObjectIfAllowed() {
|
private JetObjectDeclaration getCompanionObjectIfAllowed() {
|
||||||
JetObjectDeclaration defaultObject = firstOrNull(declarationProvider.getOwnerInfo().getDefaultObjects());
|
JetObjectDeclaration companionObject = firstOrNull(declarationProvider.getOwnerInfo().getCompanionObjects());
|
||||||
return (defaultObject != null && isDefaultObjectAllowed()) ? defaultObject : null;
|
return (companionObject != null && isCompanionObjectAllowed()) ? companionObject : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDefaultObjectAllowed() {
|
private boolean isCompanionObjectAllowed() {
|
||||||
return !(getKind().isSingleton() || isInner() || DescriptorUtils.isLocal(this));
|
return !(getKind().isSingleton() || isInner() || DescriptorUtils.isLocal(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,8 +468,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDefaultObject() {
|
public boolean isCompanionObject() {
|
||||||
return isDefaultObject;
|
return isCompanionObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -496,13 +496,13 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
|
|
||||||
private void doForceResolveAllContents() {
|
private void doForceResolveAllContents() {
|
||||||
resolveMemberHeaders();
|
resolveMemberHeaders();
|
||||||
ClassDescriptor defaultObjectDescriptor = getDefaultObjectDescriptor();
|
ClassDescriptor companionObjectDescriptor = getCompanionObjectDescriptor();
|
||||||
if (defaultObjectDescriptor != null) {
|
if (companionObjectDescriptor != null) {
|
||||||
ForceResolveUtil.forceResolveAllContents(defaultObjectDescriptor);
|
ForceResolveUtil.forceResolveAllContents(companionObjectDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
ForceResolveUtil.forceResolveAllContents(getConstructors());
|
ForceResolveUtil.forceResolveAllContents(getConstructors());
|
||||||
ForceResolveUtil.forceResolveAllContents(getDescriptorsForExtraDefaultObjects());
|
ForceResolveUtil.forceResolveAllContents(getDescriptorsForExtraCompanionObjects());
|
||||||
ForceResolveUtil.forceResolveAllContents(getScopeForMemberLookup());
|
ForceResolveUtil.forceResolveAllContents(getScopeForMemberLookup());
|
||||||
ForceResolveUtil.forceResolveAllContents(getTypeConstructor());
|
ForceResolveUtil.forceResolveAllContents(getTypeConstructor());
|
||||||
}
|
}
|
||||||
@@ -512,9 +512,9 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
ForceResolveUtil.forceResolveAllContents(getAnnotations());
|
ForceResolveUtil.forceResolveAllContents(getAnnotations());
|
||||||
ForceResolveUtil.forceResolveAllContents(getDanglingAnnotations());
|
ForceResolveUtil.forceResolveAllContents(getDanglingAnnotations());
|
||||||
|
|
||||||
getDefaultObjectDescriptor();
|
getCompanionObjectDescriptor();
|
||||||
|
|
||||||
getDescriptorsForExtraDefaultObjects();
|
getDescriptorsForExtraCompanionObjects();
|
||||||
|
|
||||||
getClassObjectType();
|
getClassObjectType();
|
||||||
getConstructors();
|
getConstructors();
|
||||||
|
|||||||
+1
-1
@@ -230,7 +230,7 @@ public open class LazyClassMemberScope(
|
|||||||
|
|
||||||
private fun <T : CallableMemberDescriptor> generateDelegatingDescriptors(name: Name, extractor: MemberExtractor<T>, existingDescriptors: Collection<CallableDescriptor>): Collection<T> {
|
private fun <T : CallableMemberDescriptor> generateDelegatingDescriptors(name: Name, extractor: MemberExtractor<T>, existingDescriptors: Collection<CallableDescriptor>): Collection<T> {
|
||||||
val classOrObject = declarationProvider.getOwnerInfo().getCorrespondingClassOrObject()
|
val classOrObject = declarationProvider.getOwnerInfo().getCorrespondingClassOrObject()
|
||||||
?: return setOf() // Enum default objects do not have delegated members
|
?: return setOf()
|
||||||
|
|
||||||
val lazyTypeResolver = DelegationResolver.TypeResolver { reference ->
|
val lazyTypeResolver = DelegationResolver.TypeResolver { reference ->
|
||||||
c.typeResolver.resolveType(thisDescriptor.getScopeForClassHeaderResolution(), reference, trace, false)
|
c.typeResolver.resolveType(thisDescriptor.getScopeForClassHeaderResolution(), reference, trace, false)
|
||||||
|
|||||||
+2
-2
@@ -83,7 +83,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
|||||||
if (classOrObject instanceof JetClass) {
|
if (classOrObject instanceof JetClass) {
|
||||||
JetClass jetClass = (JetClass) classOrObject;
|
JetClass jetClass = (JetClass) classOrObject;
|
||||||
for (JetTypeConstraint jetTypeConstraint : jetClass.getTypeConstraints()) {
|
for (JetTypeConstraint jetTypeConstraint : jetClass.getTypeConstraints()) {
|
||||||
DescriptorResolver.reportUnsupportedDefaultObjectConstraint(c.getTrace(), jetTypeConstraint);
|
DescriptorResolver.reportUnsupportedCompanionObjectConstraint(c.getTrace(), jetTypeConstraint);
|
||||||
|
|
||||||
JetSimpleNameExpression constrainedParameterName = jetTypeConstraint.getSubjectTypeParameterName();
|
JetSimpleNameExpression constrainedParameterName = jetTypeConstraint.getSubjectTypeParameterName();
|
||||||
if (constrainedParameterName != null) {
|
if (constrainedParameterName != null) {
|
||||||
@@ -93,7 +93,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
|||||||
JetTypeReference boundTypeReference = jetTypeConstraint.getBoundTypeReference();
|
JetTypeReference boundTypeReference = jetTypeConstraint.getBoundTypeReference();
|
||||||
if (boundTypeReference != null) {
|
if (boundTypeReference != null) {
|
||||||
JetType boundType = resolveBoundType(boundTypeReference);
|
JetType boundType = resolveBoundType(boundTypeReference);
|
||||||
if (!jetTypeConstraint.isDefaultObjectConstraint()) {
|
if (!jetTypeConstraint.isCompanionObjectConstraint()) {
|
||||||
upperBounds.add(boundType);
|
upperBounds.add(boundType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -19,12 +19,12 @@ package org.jetbrains.kotlin.resolve.scopes
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Members of the default object are accessible from the class.
|
* Members of the companion object are accessible from the class.
|
||||||
* Scope lazily delegates requests to default object scope.
|
* Scope lazily delegates requests to companion object scope.
|
||||||
*/
|
*/
|
||||||
public class DefaultObjectMixinScope(private val defaultObjectDescriptor: ClassDescriptor) : AbstractScopeAdapter() {
|
public class CompanionObjectMixinScope(private val companionObjectDescriptor: ClassDescriptor) : AbstractScopeAdapter() {
|
||||||
override val workerScope: JetScope
|
override val workerScope: JetScope
|
||||||
get() = defaultObjectDescriptor.getDefaultType().getMemberScope()
|
get() = companionObjectDescriptor.getDefaultType().getMemberScope()
|
||||||
|
|
||||||
override fun getImplicitReceiversHierarchy() = listOf(defaultObjectDescriptor.getThisAsReceiverParameter())
|
override fun getImplicitReceiversHierarchy() = listOf(companionObjectDescriptor.getThisAsReceiverParameter())
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -91,8 +91,8 @@ public abstract class WritableScopeWithImports(override val workerScope: JetScop
|
|||||||
protected open fun computeImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> {
|
protected open fun computeImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> {
|
||||||
val implicitReceiverHierarchy = Lists.newArrayList<ReceiverParameterDescriptor>()
|
val implicitReceiverHierarchy = Lists.newArrayList<ReceiverParameterDescriptor>()
|
||||||
// Imported scopes come with their receivers
|
// Imported scopes come with their receivers
|
||||||
// Example: class member resolution scope imports a scope of it's default object
|
// Example: class member resolution scope imports a scope of it's companion object
|
||||||
// members of the default object must be able to find it as an implicit receiver
|
// members of the companion object must be able to find it as an implicit receiver
|
||||||
for (scope in getImports()) {
|
for (scope in getImports()) {
|
||||||
implicitReceiverHierarchy.addAll(scope.getImplicitReceiversHierarchy())
|
implicitReceiverHierarchy.addAll(scope.getImplicitReceiversHierarchy())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ private fun QualifierReceiver.resolveAsStandaloneExpression(context: ExpressionT
|
|||||||
context.trace.report(TYPE_PARAMETER_IS_NOT_AN_EXPRESSION.on(referenceExpression, classifier))
|
context.trace.report(TYPE_PARAMETER_IS_NOT_AN_EXPRESSION.on(referenceExpression, classifier))
|
||||||
}
|
}
|
||||||
else if (classifier is ClassDescriptor && classifier.getClassObjectType() == null) {
|
else if (classifier is ClassDescriptor && classifier.getClassObjectType() == null) {
|
||||||
context.trace.report(NO_DEFAULT_OBJECT.on(referenceExpression, classifier))
|
context.trace.report(NO_COMPANION_OBJECT.on(referenceExpression, classifier))
|
||||||
}
|
}
|
||||||
else if (packageView != null) {
|
else if (packageView != null) {
|
||||||
context.trace.report(EXPRESSION_EXPECTED_PACKAGE_FOUND.on(referenceExpression))
|
context.trace.report(EXPRESSION_EXPECTED_PACKAGE_FOUND.on(referenceExpression))
|
||||||
@@ -174,8 +174,8 @@ private fun QualifierReceiver.resolveReferenceTarget(
|
|||||||
(selector.getDispatchReceiverParameter() != null || selector.getExtensionReceiverParameter() != null)
|
(selector.getDispatchReceiverParameter() != null || selector.getExtensionReceiverParameter() != null)
|
||||||
|
|
||||||
if (classifier is ClassDescriptor && classifier.classObjectDescriptor != null && isCallableWithReceiver) {
|
if (classifier is ClassDescriptor && classifier.classObjectDescriptor != null && isCallableWithReceiver) {
|
||||||
if (classifier.getDefaultObjectDescriptor() != null) {
|
if (classifier.getCompanionObjectDescriptor() != null) {
|
||||||
context.trace.record(SHORT_REFERENCE_TO_DEFAULT_OBJECT, referenceExpression, classifier)
|
context.trace.record(SHORT_REFERENCE_TO_COMPANION_OBJECT, referenceExpression, classifier)
|
||||||
}
|
}
|
||||||
return classifier.getClassObjectReferenceTarget()
|
return classifier.getClassObjectReferenceTarget()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -180,7 +180,7 @@ class DeclarationScopeProviderForLocalClassifierAnalyzer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getOuterDataFlowInfoForDeclaration(elementOfDeclaration: PsiElement): DataFlowInfo {
|
override fun getOuterDataFlowInfoForDeclaration(elementOfDeclaration: PsiElement): DataFlowInfo {
|
||||||
// nested (non-inner) classes and default objects are forbidden in local classes, so it's enough to be simply inside the class
|
// nested (non-inner) classes and companion objects are forbidden in local classes, so it's enough to be simply inside the class
|
||||||
if (localClassDescriptorManager.insideMyClass(elementOfDeclaration)) {
|
if (localClassDescriptorManager.insideMyClass(elementOfDeclaration)) {
|
||||||
return localClassDescriptorManager.expressionTypingContext.dataFlowInfo
|
return localClassDescriptorManager.expressionTypingContext.dataFlowInfo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,12 +150,12 @@ public class LightClassUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static PsiField getLightFieldForDefaultObject(@NotNull JetClassOrObject defaultObject) {
|
public static PsiField getLightFieldForCompanionObject(@NotNull JetClassOrObject companionObject) {
|
||||||
PsiClass outerPsiClass = getWrappingClass(defaultObject);
|
PsiClass outerPsiClass = getWrappingClass(companionObject);
|
||||||
if (outerPsiClass != null) {
|
if (outerPsiClass != null) {
|
||||||
for (PsiField fieldOfParent : outerPsiClass.getFields()) {
|
for (PsiField fieldOfParent : outerPsiClass.getFields()) {
|
||||||
if (((KotlinLightElement<?, ?>) fieldOfParent).getOrigin() == defaultObject &&
|
if (((KotlinLightElement<?, ?>) fieldOfParent).getOrigin() == companionObject &&
|
||||||
fieldOfParent.getName().equals(defaultObject.getName())) { // TODO this check is relevant while light class has deprecated OBJECT$ field
|
fieldOfParent.getName().equals(companionObject.getName())) { // TODO this check is relevant while light class has deprecated OBJECT$ field
|
||||||
return fieldOfParent;
|
return fieldOfParent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
class WithClassObject {
|
class WithClassObject {
|
||||||
default object {
|
companion object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ package test
|
|||||||
import kotlin.platform.platformStatic
|
import kotlin.platform.platformStatic
|
||||||
|
|
||||||
class PlatformStaticClass {
|
class PlatformStaticClass {
|
||||||
default object {
|
companion object {
|
||||||
platformStatic
|
platformStatic
|
||||||
fun inClassObject<T>() {}
|
fun inClassObject<T>() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,21 @@ public final class ClassObjectField {
|
|||||||
@org.jetbrains.annotations.Nullable
|
@org.jetbrains.annotations.Nullable
|
||||||
public static final java.lang.String x = "";
|
public static final java.lang.String x = "";
|
||||||
private static final java.lang.String y = "";
|
private static final java.lang.String y = "";
|
||||||
public static final ClassObjectField.Default Default;
|
public static final ClassObjectField.Companion Companion;
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@java.lang.Deprecated
|
@java.lang.Deprecated
|
||||||
public static final ClassObjectField.Default OBJECT$;
|
public static final ClassObjectField.Companion OBJECT$;
|
||||||
|
|
||||||
public ClassObjectField() { /* compiled code */ }
|
public ClassObjectField() { /* compiled code */ }
|
||||||
|
|
||||||
public static final class Default {
|
public static final class Companion {
|
||||||
@org.jetbrains.annotations.Nullable
|
@org.jetbrains.annotations.Nullable
|
||||||
public final java.lang.String getX() { /* compiled code */ }
|
public final java.lang.String getX() { /* compiled code */ }
|
||||||
|
|
||||||
private final java.lang.String getY() { /* compiled code */ }
|
private final java.lang.String getY() { /* compiled code */ }
|
||||||
|
|
||||||
private Default() { /* compiled code */ }
|
private Companion() { /* compiled code */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// ClassObjectField
|
// ClassObjectField
|
||||||
|
|
||||||
class ClassObjectField {
|
class ClassObjectField {
|
||||||
default object {
|
companion object {
|
||||||
val x: String? = ""
|
val x: String? = ""
|
||||||
private val y: String? = ""
|
private val y: String? = ""
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,14 +1,14 @@
|
|||||||
public interface TraitClassObjectField {
|
public interface TraitClassObjectField {
|
||||||
TraitClassObjectField.Default Default;
|
TraitClassObjectField.Companion Companion;
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@java.lang.Deprecated
|
@java.lang.Deprecated
|
||||||
TraitClassObjectField.Default OBJECT$;
|
TraitClassObjectField.Companion OBJECT$;
|
||||||
@org.jetbrains.annotations.Nullable
|
@org.jetbrains.annotations.Nullable
|
||||||
java.lang.String x = "";
|
java.lang.String x = "";
|
||||||
|
|
||||||
static final class Default {
|
static final class Companion {
|
||||||
@org.jetbrains.annotations.Nullable
|
@org.jetbrains.annotations.Nullable
|
||||||
private final java.lang.String x = "";
|
private final java.lang.String x = "";
|
||||||
private final java.lang.String y = "";
|
private final java.lang.String y = "";
|
||||||
@@ -18,6 +18,6 @@ public interface TraitClassObjectField {
|
|||||||
|
|
||||||
private final java.lang.String getY() { /* compiled code */ }
|
private final java.lang.String getY() { /* compiled code */ }
|
||||||
|
|
||||||
private Default() { /* compiled code */ }
|
private Companion() { /* compiled code */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
// TraitClassObjectField
|
// TraitClassObjectField
|
||||||
|
|
||||||
trait TraitClassObjectField {
|
trait TraitClassObjectField {
|
||||||
default object {
|
companion object {
|
||||||
val x: String? = ""
|
val x: String? = ""
|
||||||
private val y: String? = ""
|
private val y: String? = ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ public final class Byte : kotlin.Number, kotlin.Comparable<kotlin.Byte> {
|
|||||||
public open override /*1*/ fun toLong(): kotlin.Long
|
public open override /*1*/ fun toLong(): kotlin.Long
|
||||||
public open override /*1*/ fun toShort(): kotlin.Short
|
public open override /*1*/ fun toShort(): kotlin.Short
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,8 +171,8 @@ public final class ByteRange : kotlin.Range<kotlin.Byte>, kotlin.Progression<kot
|
|||||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||||
public open override /*1*/ fun iterator(): kotlin.ByteIterator
|
public open override /*1*/ fun iterator(): kotlin.ByteIterator
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
public final val EMPTY: kotlin.ByteRange
|
public final val EMPTY: kotlin.ByteRange
|
||||||
public final fun <get-EMPTY>(): kotlin.ByteRange
|
public final fun <get-EMPTY>(): kotlin.ByteRange
|
||||||
}
|
}
|
||||||
@@ -231,8 +231,8 @@ public final class Char : kotlin.Comparable<kotlin.Char> {
|
|||||||
public open fun toLong(): kotlin.Long
|
public open fun toLong(): kotlin.Long
|
||||||
public open fun toShort(): kotlin.Short
|
public open fun toShort(): kotlin.Short
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,8 +293,8 @@ public final class CharRange : kotlin.Range<kotlin.Char>, kotlin.Progression<kot
|
|||||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||||
public open override /*1*/ fun iterator(): kotlin.CharIterator
|
public open override /*1*/ fun iterator(): kotlin.CharIterator
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
public final val EMPTY: kotlin.CharRange
|
public final val EMPTY: kotlin.CharRange
|
||||||
public final fun <get-EMPTY>(): kotlin.CharRange
|
public final fun <get-EMPTY>(): kotlin.CharRange
|
||||||
}
|
}
|
||||||
@@ -385,8 +385,8 @@ public final class Double : kotlin.Number, kotlin.Comparable<kotlin.Double> {
|
|||||||
public open override /*1*/ fun toLong(): kotlin.Long
|
public open override /*1*/ fun toLong(): kotlin.Long
|
||||||
public open override /*1*/ fun toShort(): kotlin.Short
|
public open override /*1*/ fun toShort(): kotlin.Short
|
||||||
|
|
||||||
public default object Default : kotlin.FloatingPointConstants<kotlin.Double> {
|
public companion object Companion : kotlin.FloatingPointConstants<kotlin.Double> {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
public abstract override /*1*/ /*fake_override*/ val NEGATIVE_INFINITY: kotlin.Double
|
public abstract override /*1*/ /*fake_override*/ val NEGATIVE_INFINITY: kotlin.Double
|
||||||
public abstract override /*1*/ /*fake_override*/ fun <get-NEGATIVE_INFINITY>(): kotlin.Double
|
public abstract override /*1*/ /*fake_override*/ fun <get-NEGATIVE_INFINITY>(): kotlin.Double
|
||||||
public abstract override /*1*/ /*fake_override*/ val NaN: kotlin.Double
|
public abstract override /*1*/ /*fake_override*/ val NaN: kotlin.Double
|
||||||
@@ -450,8 +450,8 @@ public final class DoubleRange : kotlin.Range<kotlin.Double>, kotlin.Progression
|
|||||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||||
public open override /*1*/ fun iterator(): kotlin.DoubleIterator
|
public open override /*1*/ fun iterator(): kotlin.DoubleIterator
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
public final val EMPTY: kotlin.DoubleRange
|
public final val EMPTY: kotlin.DoubleRange
|
||||||
public final fun <get-EMPTY>(): kotlin.DoubleRange
|
public final fun <get-EMPTY>(): kotlin.DoubleRange
|
||||||
}
|
}
|
||||||
@@ -463,8 +463,8 @@ public abstract class Enum</*0*/ E : kotlin.Enum<E>> : kotlin.Comparable<E> {
|
|||||||
public final fun name(): kotlin.String
|
public final fun name(): kotlin.String
|
||||||
public final fun ordinal(): kotlin.Int
|
public final fun ordinal(): kotlin.Int
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,8 +623,8 @@ public final class Float : kotlin.Number, kotlin.Comparable<kotlin.Float> {
|
|||||||
public open override /*1*/ fun toLong(): kotlin.Long
|
public open override /*1*/ fun toLong(): kotlin.Long
|
||||||
public open override /*1*/ fun toShort(): kotlin.Short
|
public open override /*1*/ fun toShort(): kotlin.Short
|
||||||
|
|
||||||
public default object Default : kotlin.FloatingPointConstants<kotlin.Float> {
|
public companion object Companion : kotlin.FloatingPointConstants<kotlin.Float> {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
public abstract override /*1*/ /*fake_override*/ val NEGATIVE_INFINITY: kotlin.Float
|
public abstract override /*1*/ /*fake_override*/ val NEGATIVE_INFINITY: kotlin.Float
|
||||||
public abstract override /*1*/ /*fake_override*/ fun <get-NEGATIVE_INFINITY>(): kotlin.Float
|
public abstract override /*1*/ /*fake_override*/ fun <get-NEGATIVE_INFINITY>(): kotlin.Float
|
||||||
public abstract override /*1*/ /*fake_override*/ val NaN: kotlin.Float
|
public abstract override /*1*/ /*fake_override*/ val NaN: kotlin.Float
|
||||||
@@ -688,8 +688,8 @@ public final class FloatRange : kotlin.Range<kotlin.Float>, kotlin.Progression<k
|
|||||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||||
public open override /*1*/ fun iterator(): kotlin.FloatIterator
|
public open override /*1*/ fun iterator(): kotlin.FloatIterator
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
public final val EMPTY: kotlin.FloatRange
|
public final val EMPTY: kotlin.FloatRange
|
||||||
public final fun <get-EMPTY>(): kotlin.FloatRange
|
public final fun <get-EMPTY>(): kotlin.FloatRange
|
||||||
}
|
}
|
||||||
@@ -916,8 +916,8 @@ public final class Int : kotlin.Number, kotlin.Comparable<kotlin.Int> {
|
|||||||
public final fun ushr(/*0*/ bits: kotlin.Int): kotlin.Int
|
public final fun ushr(/*0*/ bits: kotlin.Int): kotlin.Int
|
||||||
public final fun xor(/*0*/ other: kotlin.Int): kotlin.Int
|
public final fun xor(/*0*/ other: kotlin.Int): kotlin.Int
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -978,8 +978,8 @@ public final class IntRange : kotlin.Range<kotlin.Int>, kotlin.Progression<kotli
|
|||||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||||
public open override /*1*/ fun iterator(): kotlin.IntIterator
|
public open override /*1*/ fun iterator(): kotlin.IntIterator
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
public final val EMPTY: kotlin.IntRange
|
public final val EMPTY: kotlin.IntRange
|
||||||
public final fun <get-EMPTY>(): kotlin.IntRange
|
public final fun <get-EMPTY>(): kotlin.IntRange
|
||||||
}
|
}
|
||||||
@@ -1087,8 +1087,8 @@ public final class Long : kotlin.Number, kotlin.Comparable<kotlin.Long> {
|
|||||||
public final fun ushr(/*0*/ bits: kotlin.Int): kotlin.Long
|
public final fun ushr(/*0*/ bits: kotlin.Int): kotlin.Long
|
||||||
public final fun xor(/*0*/ other: kotlin.Long): kotlin.Long
|
public final fun xor(/*0*/ other: kotlin.Long): kotlin.Long
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1149,8 +1149,8 @@ public final class LongRange : kotlin.Range<kotlin.Long>, kotlin.Progression<kot
|
|||||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||||
public open override /*1*/ fun iterator(): kotlin.LongIterator
|
public open override /*1*/ fun iterator(): kotlin.LongIterator
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
public final val EMPTY: kotlin.LongRange
|
public final val EMPTY: kotlin.LongRange
|
||||||
public final fun <get-EMPTY>(): kotlin.LongRange
|
public final fun <get-EMPTY>(): kotlin.LongRange
|
||||||
}
|
}
|
||||||
@@ -1383,8 +1383,8 @@ public final class Short : kotlin.Number, kotlin.Comparable<kotlin.Short> {
|
|||||||
public open override /*1*/ fun toLong(): kotlin.Long
|
public open override /*1*/ fun toLong(): kotlin.Long
|
||||||
public open override /*1*/ fun toShort(): kotlin.Short
|
public open override /*1*/ fun toShort(): kotlin.Short
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1445,8 +1445,8 @@ public final class ShortRange : kotlin.Range<kotlin.Short>, kotlin.Progression<k
|
|||||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||||
public open override /*1*/ fun iterator(): kotlin.ShortIterator
|
public open override /*1*/ fun iterator(): kotlin.ShortIterator
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
public final val EMPTY: kotlin.ShortRange
|
public final val EMPTY: kotlin.ShortRange
|
||||||
public final fun <get-EMPTY>(): kotlin.ShortRange
|
public final fun <get-EMPTY>(): kotlin.ShortRange
|
||||||
}
|
}
|
||||||
@@ -1461,8 +1461,8 @@ public final class String : kotlin.Comparable<kotlin.String>, kotlin.CharSequenc
|
|||||||
public final fun plus(/*0*/ other: kotlin.Any?): kotlin.String
|
public final fun plus(/*0*/ other: kotlin.Any?): kotlin.String
|
||||||
public open override /*1*/ fun subSequence(/*0*/ start: kotlin.Int, /*1*/ end: kotlin.Int): kotlin.CharSequence
|
public open override /*1*/ fun subSequence(/*0*/ start: kotlin.Int, /*1*/ end: kotlin.Int): kotlin.CharSequence
|
||||||
|
|
||||||
public default object Default {
|
public companion object Companion {
|
||||||
/*primary*/ private constructor Default()
|
/*primary*/ private constructor Companion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
class C() {
|
class C() {
|
||||||
val a: Int = 1
|
val a: Int = 1
|
||||||
|
|
||||||
default object {
|
companion object {
|
||||||
val x : Int
|
val x : Int
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class C() {
|
class C() {
|
||||||
val a: Int = 1
|
val a: Int = 1
|
||||||
|
|
||||||
default object {
|
companion object {
|
||||||
val x : Int
|
val x : Int
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
class C() {
|
class C() {
|
||||||
val a: Int = 1
|
val a: Int = 1
|
||||||
|
|
||||||
default object {
|
companion object {
|
||||||
val x : Int
|
val x : Int
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class A {
|
class A {
|
||||||
default object {
|
companion object {
|
||||||
var xi = 0
|
var xi = 0
|
||||||
var xin : Int? = 0
|
var xin : Int? = 0
|
||||||
var xinn : Int? = null
|
var xinn : Int? = null
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class C() {
|
class C() {
|
||||||
default object {
|
companion object {
|
||||||
fun create() = C()
|
fun create() = C()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
fun Any.foo() = 1
|
fun Any.foo() = 1
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
default object
|
companion object
|
||||||
}
|
}
|
||||||
|
|
||||||
fun box() = if (A.foo() == 1) "OK" else "fail"
|
fun box() = if (A.foo() == 1) "OK" else "fail"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var global = 0;
|
var global = 0;
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
default object {
|
companion object {
|
||||||
{
|
{
|
||||||
global = 1;
|
global = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class A() {
|
class A() {
|
||||||
default object {
|
companion object {
|
||||||
val value = 10
|
val value = 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// EA-38323 - Illegal field modifiers in class: classObject field in C must be static and final
|
// EA-38323 - Illegal field modifiers in class: classObject field in C must be static and final
|
||||||
|
|
||||||
trait C {
|
trait C {
|
||||||
default object {
|
companion object {
|
||||||
public val FOO: String = "OK"
|
public val FOO: String = "OK"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class A {
|
class A {
|
||||||
default object {
|
companion object {
|
||||||
fun values() = "O"
|
fun values() = "O"
|
||||||
fun valueOf() = "K"
|
fun valueOf() = "K"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class SomeClass { default object }
|
class SomeClass { companion object }
|
||||||
|
|
||||||
fun box() =
|
fun box() =
|
||||||
if ((SomeClass.toString() as java.lang.String).matches("SomeClass\\\$Default@[0-9a-fA-F]+"))
|
if ((SomeClass.toString() as java.lang.String).matches("SomeClass\\\$Companion@[0-9a-fA-F]+"))
|
||||||
"OK"
|
"OK"
|
||||||
else
|
else
|
||||||
"Fail: $SomeClass"
|
"Fail: $SomeClass"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class C() {
|
class C() {
|
||||||
default object {
|
companion object {
|
||||||
private fun <T> create() = C()
|
private fun <T> create() = C()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
open class Test {
|
open class Test {
|
||||||
default object {
|
companion object {
|
||||||
fun testStatic(ic: InnerClass): NotInnerClass = NotInnerClass(ic.value)
|
fun testStatic(ic: InnerClass): NotInnerClass = NotInnerClass(ic.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class A {
|
|||||||
private val p: Int
|
private val p: Int
|
||||||
get() = 4
|
get() = 4
|
||||||
|
|
||||||
default object B {
|
companion object B {
|
||||||
val p: Int
|
val p: Int
|
||||||
get() = 6
|
get() = 6
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class C() {
|
class C() {
|
||||||
default object Foo
|
companion object Foo
|
||||||
}
|
}
|
||||||
|
|
||||||
fun C.Foo.create() = 3
|
fun C.Foo.create() = 3
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ public class StockMarketTableModel() {
|
|||||||
return COLUMN_TITLES?.size()!!
|
return COLUMN_TITLES?.size()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
default object {
|
companion object {
|
||||||
private val COLUMN_TITLES : Array<Int?> = arrayOfNulls<Int>(10)
|
private val COLUMN_TITLES : Array<Int?> = arrayOfNulls<Int>(10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class A {
|
class A {
|
||||||
default object {
|
companion object {
|
||||||
val b = 0
|
val b = 0
|
||||||
val c = b
|
val c = b
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package x
|
package x
|
||||||
|
|
||||||
class Outer() {
|
class Outer() {
|
||||||
default object {
|
companion object {
|
||||||
class Inner() {
|
class Inner() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun box (): String {
|
fun box (): String {
|
||||||
val inner = Outer.Default.Inner()
|
val inner = Outer.Companion.Inner()
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
open class Factory(p: Int)
|
open class Factory(p: Int)
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
default object : Factory(1)
|
companion object : Factory(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun box() : String {
|
fun box() : String {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package mult_constructors_3_bug
|
|||||||
|
|
||||||
public open class Identifier() {
|
public open class Identifier() {
|
||||||
private var myNullable : Boolean = true
|
private var myNullable : Boolean = true
|
||||||
default object {
|
companion object {
|
||||||
open public fun init(isNullable : Boolean) : Identifier {
|
open public fun init(isNullable : Boolean) : Identifier {
|
||||||
val __ = Identifier()
|
val __ = Identifier()
|
||||||
__.myNullable = isNullable
|
__.myNullable = isNullable
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class C() {
|
class C() {
|
||||||
default object Foo {
|
companion object Foo {
|
||||||
fun create() = 3
|
fun create() = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class Foo private(val param: String = "OK") {
|
class Foo private(val param: String = "OK") {
|
||||||
default object {
|
companion object {
|
||||||
val s = Foo()
|
val s = Foo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
class A {
|
class A {
|
||||||
default object {
|
companion object {
|
||||||
fun Int.foo(a: Int = 1): Int {
|
fun Int.foo(a: Int = 1): Int {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
fun foo(a: String = "Default", b: Int = 1, c: Long = 2): String {
|
fun foo(a: String = "Companion", b: Int = 1, c: Long = 2): String {
|
||||||
return "$a $b $c"
|
return "$a $b $c"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ class Delegate<T>(var inner: T) {
|
|||||||
|
|
||||||
|
|
||||||
class Foo (val f: Int) {
|
class Foo (val f: Int) {
|
||||||
default object {
|
companion object {
|
||||||
val A: Foo by Delegate(Foo(11))
|
val A: Foo by Delegate(Foo(11))
|
||||||
var B: Foo by Delegate(Foo(11))
|
var B: Foo by Delegate(Foo(11))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait FooTrait {
|
trait FooTrait {
|
||||||
default object {
|
companion object {
|
||||||
val A: Foo by Delegate(Foo(11))
|
val A: Foo by Delegate(Foo(11))
|
||||||
var B: Foo by Delegate(Foo(11))
|
var B: Foo by Delegate(Foo(11))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import java.util.IdentityHashMap
|
|||||||
class A {
|
class A {
|
||||||
var foo: Int by IntHandler
|
var foo: Int by IntHandler
|
||||||
|
|
||||||
default object {
|
companion object {
|
||||||
var bar: Any? by AnyHandler
|
var bar: Any? by AnyHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
class A {
|
class A {
|
||||||
default object {
|
companion object {
|
||||||
fun invoke(i: Int) = i
|
fun invoke(i: Int) = i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -8,8 +8,8 @@ internal final class A {
|
|||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
internal default object Default {
|
internal companion object Companion {
|
||||||
private constructor Default()
|
private constructor Companion()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
internal final fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
internal final fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ trait B
|
|||||||
fun B.invoke(i: Int) = i
|
fun B.invoke(i: Int) = i
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
default object: B {
|
companion object: B {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -9,8 +9,8 @@ internal final class A {
|
|||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
internal default object Default : B {
|
internal companion object Companion : B {
|
||||||
private constructor Default()
|
private constructor Companion()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
class A {
|
class A {
|
||||||
class Nested {
|
class Nested {
|
||||||
default object {
|
companion object {
|
||||||
fun invoke(i: Int) = i
|
fun invoke(i: Int) = i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -14,8 +14,8 @@ internal final class A {
|
|||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
internal default object Default {
|
internal companion object Companion {
|
||||||
private constructor Default()
|
private constructor Companion()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
internal final fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
internal final fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ import A.Nested
|
|||||||
|
|
||||||
class A {
|
class A {
|
||||||
class Nested {
|
class Nested {
|
||||||
default object {
|
companion object {
|
||||||
fun invoke(i: Int) = i
|
fun invoke(i: Int) = i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -14,8 +14,8 @@ internal final class A {
|
|||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
internal default object Default {
|
internal companion object Companion {
|
||||||
private constructor Default()
|
private constructor Companion()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
internal final fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
internal final fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ enum class Game {
|
|||||||
PAPER
|
PAPER
|
||||||
SCISSORS
|
SCISSORS
|
||||||
|
|
||||||
default object {
|
companion object {
|
||||||
fun foo() = ROCK
|
fun foo() = ROCK
|
||||||
val bar = PAPER
|
val bar = PAPER
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user