From 60d1736b974a47140f3b689836073a1fb50bdd03 Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Thu, 8 Oct 2015 12:22:45 +0300 Subject: [PATCH] Instance field generation in objects --- .../jetbrains/kotlin/codegen/FieldInfo.java | 31 +++++++++---------- .../codegen/ImplementationBodyCodegen.java | 25 ++++++++------- .../kotlin/codegen/PackageCodegen.java | 2 +- .../jetbrains/kotlin/codegen/StackValue.java | 8 +++++ .../kotlin/resolve/lazy/ResolveSession.java | 2 +- .../ClassObjectField.java | 2 ++ .../TraitClassObjectField.java | 5 +-- .../publicField/CompanionObject.java | 2 ++ .../deprecatedFieldForObject/B.java | 4 +++ .../deprecatedInstanceFieldForObject.kt | 10 ++++++ .../bytecodeText/constClosureOptimization.kt | 6 ++-- .../bytecodeText/constValsGetterDeprecated.kt | 2 +- .../bytecodeText/staticFields/classObject.kt | 2 +- .../classObjectSyntheticAccessor.kt | 2 +- .../bytecodeText/staticFields/object.kt | 4 +-- .../BlackBoxWithJavaCodegenTestGenerated.java | 6 ++++ .../jetbrains/kotlin/load/java/JvmAbi.java | 3 +- .../{SourceFile.kt => SourceFile.java} | 6 ++-- .../annotations/AnnotationDescriptorImpl.java | 2 +- .../impl/DeclarationDescriptorImpl.java | 2 +- .../kotlin/resolve/DescriptorUtils.java | 2 +- .../kotlin/types/AbstractJetType.java | 2 +- .../macro/BaseJetVariableMacro.java | 4 +-- .../ToObject/external/JavaFile.java.expected | 6 ++-- .../js/translate/utils/ManglingUtils.java | 2 +- 25 files changed, 87 insertions(+), 55 deletions(-) create mode 100644 compiler/testData/codegen/boxWithJava/deprecatedFieldForObject/B.java create mode 100644 compiler/testData/codegen/boxWithJava/deprecatedFieldForObject/deprecatedInstanceFieldForObject.kt rename core/descriptors/src/org/jetbrains/kotlin/descriptors/{SourceFile.kt => SourceFile.java} (83%) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FieldInfo.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FieldInfo.java index a2dbd1b44fe..3294922b0cf 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FieldInfo.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FieldInfo.java @@ -17,37 +17,34 @@ package org.jetbrains.kotlin.codegen; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.CompanionObjectMapping; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.codegen.state.JetTypeMapper; import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.load.java.JvmAbi; import org.jetbrains.kotlin.resolve.DescriptorUtils; -import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform; import org.jetbrains.org.objectweb.asm.Type; -import static org.jetbrains.kotlin.resolve.DescriptorUtils.isNonCompanionObject; - public class FieldInfo { - private static final CompanionObjectMapping COMPANION_OBJECT_MAPPING = new CompanionObjectMapping(JvmPlatform.INSTANCE$.getBuiltIns()); + @NotNull + public static FieldInfo createForCompanionSingleton(@NotNull ClassDescriptor companionObject, @NotNull JetTypeMapper typeMapper) { + ClassDescriptor ownerDescriptor = DescriptorUtils.getParentOfType(companionObject, ClassDescriptor.class); + assert ownerDescriptor != null : "Owner not found for class: " + companionObject; + Type ownerType = typeMapper.mapType(ownerDescriptor); + return new FieldInfo(ownerType, typeMapper.mapType(companionObject), companionObject.getName().asString(), true); + } @NotNull public static FieldInfo createForSingleton(@NotNull ClassDescriptor classDescriptor, @NotNull JetTypeMapper typeMapper) { + return createForSingleton(classDescriptor, typeMapper, false); + } + + @NotNull + public static FieldInfo createForSingleton(@NotNull ClassDescriptor classDescriptor, @NotNull JetTypeMapper typeMapper, boolean oldSingleton) { if (!classDescriptor.getKind().isSingleton()) { throw new UnsupportedOperationException("Can't create singleton field for class: " + classDescriptor); } - - if (isNonCompanionObject(classDescriptor) || COMPANION_OBJECT_MAPPING.hasMappingToObject(classDescriptor)) { - Type type = typeMapper.mapType(classDescriptor); - return new FieldInfo(type, type, JvmAbi.INSTANCE_FIELD, true); - } - else { - ClassDescriptor ownerDescriptor = DescriptorUtils.getParentOfType(classDescriptor, ClassDescriptor.class); - assert ownerDescriptor != null : "Owner not found for class: " + classDescriptor; - Type ownerType = typeMapper.mapType(ownerDescriptor); - return new FieldInfo(ownerType, typeMapper.mapType(classDescriptor), classDescriptor.getName().asString(), true); - } + Type type = typeMapper.mapType(classDescriptor); + return new FieldInfo(type, type, oldSingleton ? JvmAbi.DEPRECATED_INSTANCE_FIELD : JvmAbi.INSTANCE_FIELD, true); } @NotNull diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index d3d110753cd..2ad0d381810 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -984,12 +984,17 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { } private void generateFieldForSingleton() { - if (isEnumEntry(descriptor) || isCompanionObject(descriptor)) return; + if (isEnumEntry(descriptor)) return; - if (isNonCompanionObject(descriptor)) { + if (isObject(descriptor)) { StackValue.Field field = StackValue.singleton(descriptor, typeMapper); v.newField(OtherOrigin(myClass), ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null); + if (isNonCompanionObject(descriptor)) { + StackValue.Field oldField = StackValue.oldSingleton(descriptor, typeMapper); + v.newField(OtherOrigin(myClass), ACC_PUBLIC | ACC_STATIC | ACC_FINAL | ACC_DEPRECATED, oldField.name, oldField.type.getDescriptor(), null, null); + } + if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return; // Invoke the object constructor but ignore the result because INSTANCE$ will be initialized in the first line of @@ -1007,7 +1012,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { JetObjectDeclaration companionObject = CollectionsKt.firstOrNull(((JetClass) myClass).getCompanionObjects()); assert companionObject != null : "Companion object not found: " + myClass.getText(); - StackValue.Field field = StackValue.singleton(companionObjectDescriptor, typeMapper); + StackValue.Field field = StackValue.singletonForCompanion(companionObjectDescriptor, typeMapper); v.newField(OtherOrigin(companionObject), ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null); if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return; @@ -1065,13 +1070,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { private void generateCompanionObjectInitializer(@NotNull ClassDescriptor companionObject) { ExpressionCodegen codegen = createOrGetClInitCodegen(); - FunctionDescriptor constructor = (FunctionDescriptor) context.accessibleDescriptor( - CollectionsKt.single(companionObject.getConstructors()), /* superCallExpression = */ null - ); - generateMethodCallTo(constructor, null, codegen.v); - codegen.v.dup(); - StackValue instance = StackValue.onStack(typeMapper.mapClass(companionObject)); - StackValue.singleton(companionObject, typeMapper).store(instance, codegen.v, true); + StackValue.singletonForCompanion(companionObject, typeMapper) + .store(StackValue.singleton(companionObject, typeMapper), codegen.v, true); } private void generatePrimaryConstructor(final DelegationFieldsInfo delegationFieldsInfo) { @@ -1138,8 +1138,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { generateDelegatorToConstructorCall(iv, codegen, constructorDescriptor, getDelegationConstructorCall(bindingContext, constructorDescriptor)); - if (isNonCompanionObject(descriptor)) { + if (isObject(descriptor)) { StackValue.singleton(descriptor, typeMapper).store(StackValue.LOCAL_0, iv); + if (isNonCompanionObject(descriptor)) { + StackValue.oldSingleton(descriptor, typeMapper).store(StackValue.LOCAL_0, iv); + } } for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PackageCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/PackageCodegen.java index 708781e77c3..b327b6367b7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PackageCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PackageCodegen.java @@ -163,7 +163,7 @@ public class PackageCodegen { return Collections.emptyList(); } List callables = Lists.newArrayList(); - for (DeclarationDescriptor member : packageFragment.getMemberScope().getDescriptors(DescriptorKindFilter.CALLABLES, JetScope.ALL_NAME_FILTER)) { + for (DeclarationDescriptor member : packageFragment.getMemberScope().getDescriptors(DescriptorKindFilter.CALLABLES, JetScope.Companion.getALL_NAME_FILTER())) { if (member instanceof DeserializedCallableMemberDescriptor) { callables.add((DeserializedCallableMemberDescriptor) member); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java index c44343d0a85..203ee57c88e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java @@ -576,6 +576,14 @@ public abstract class StackValue { return field(FieldInfo.createForSingleton(classDescriptor, typeMapper)); } + public static Field singletonForCompanion(ClassDescriptor companionObject, JetTypeMapper typeMapper) { + return field(FieldInfo.createForCompanionSingleton(companionObject, typeMapper)); + } + + public static Field oldSingleton(ClassDescriptor classDescriptor, JetTypeMapper typeMapper) { + return field(FieldInfo.createForSingleton(classDescriptor, typeMapper, true)); + } + public static StackValue operation(Type type, Function1 lambda) { return new OperationStackValue(type, lambda); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java index 5a1bc0ae186..ddf276ac893 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java @@ -348,7 +348,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext { @NotNull LazyPackageDescriptor current ) { result.add(current); - for (FqName subPackage : packageFragmentProvider.getSubPackagesOf(current.getFqName(), JetScope.ALL_NAME_FILTER)) { + for (FqName subPackage : packageFragmentProvider.getSubPackagesOf(current.getFqName(), JetScope.Companion.getALL_NAME_FILTER())) { LazyPackageDescriptor fragment = getPackageFragment(subPackage); assert fragment != null : "Couldn't find fragment for " + subPackage; collectAllPackages(result, fragment); diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java index 74373b189c7..0a059e798ce 100644 --- a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java @@ -7,6 +7,8 @@ public final class ClassObjectField { public ClassObjectField() { /* compiled code */ } public static final class Companion { + public static final ClassObjectField.Companion INSTANCE; + @org.jetbrains.annotations.Nullable public final java.lang.String getX() { /* compiled code */ } diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/TraitClassObjectField.java b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/TraitClassObjectField.java index b8986f8bd2d..704461ddcdd 100644 --- a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/TraitClassObjectField.java +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/TraitClassObjectField.java @@ -5,8 +5,9 @@ public interface TraitClassObjectField { static final class Companion { @org.jetbrains.annotations.Nullable - private final java.lang.String x = ""; - private final java.lang.String y = ""; + private static final java.lang.String x = ""; + private static final java.lang.String y = ""; + public static final TraitClassObjectField.Companion INSTANCE; /** * @deprecated diff --git a/compiler/testData/asJava/lightClasses/publicField/CompanionObject.java b/compiler/testData/asJava/lightClasses/publicField/CompanionObject.java index dcd3d456f9c..693221e4667 100644 --- a/compiler/testData/asJava/lightClasses/publicField/CompanionObject.java +++ b/compiler/testData/asJava/lightClasses/publicField/CompanionObject.java @@ -6,6 +6,8 @@ public final class C { public C() { /* compiled code */ } public static final class Companion { + public static final C.Companion INSTANCE; + private final java.lang.String getFoo() { /* compiled code */ } private Companion() { /* compiled code */ } diff --git a/compiler/testData/codegen/boxWithJava/deprecatedFieldForObject/B.java b/compiler/testData/codegen/boxWithJava/deprecatedFieldForObject/B.java new file mode 100644 index 00000000000..8709504a80d --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/deprecatedFieldForObject/B.java @@ -0,0 +1,4 @@ +public class B { + public static int a = A.INSTANCE$.getC(); + public static int b = A.INSTANCE$.foo(); +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithJava/deprecatedFieldForObject/deprecatedInstanceFieldForObject.kt b/compiler/testData/codegen/boxWithJava/deprecatedFieldForObject/deprecatedInstanceFieldForObject.kt new file mode 100644 index 00000000000..8831ecce551 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/deprecatedFieldForObject/deprecatedInstanceFieldForObject.kt @@ -0,0 +1,10 @@ +import B + +object A { + val c = 1 + fun foo() = 4 +} + +fun box(): String { + return if (B.a == 1 && B.b == 4) "OK" else "${B.a} ${B.b}" +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/constClosureOptimization.kt b/compiler/testData/codegen/bytecodeText/constClosureOptimization.kt index dfb525ce937..89228af152f 100644 --- a/compiler/testData/codegen/bytecodeText/constClosureOptimization.kt +++ b/compiler/testData/codegen/bytecodeText/constClosureOptimization.kt @@ -17,6 +17,6 @@ fun test() { (::local)() } -// 3 GETSTATIC ConstClosureOptimizationKt\$test\$1\.INSTANCE\$ -// 1 GETSTATIC ConstClosureOptimizationKt\$test\$2\.INSTANCE\$ -// 1 GETSTATIC ConstClosureOptimizationKt\$test\$3\.INSTANCE\$ +// 3 GETSTATIC ConstClosureOptimizationKt\$test\$1\.INSTANCE +// 1 GETSTATIC ConstClosureOptimizationKt\$test\$2\.INSTANCE +// 1 GETSTATIC ConstClosureOptimizationKt\$test\$3\.INSTANCE diff --git a/compiler/testData/codegen/bytecodeText/constValsGetterDeprecated.kt b/compiler/testData/codegen/bytecodeText/constValsGetterDeprecated.kt index b8a8e8e62ca..6cec9c25f90 100644 --- a/compiler/testData/codegen/bytecodeText/constValsGetterDeprecated.kt +++ b/compiler/testData/codegen/bytecodeText/constValsGetterDeprecated.kt @@ -16,4 +16,4 @@ class B { 3 others are for getCONST_VAL */ -// 5 DEPRECATED \ No newline at end of file +// 6 DEPRECATED \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/staticFields/classObject.kt b/compiler/testData/codegen/bytecodeText/staticFields/classObject.kt index 069eefa79f0..2bcf84150fa 100644 --- a/compiler/testData/codegen/bytecodeText/staticFields/classObject.kt +++ b/compiler/testData/codegen/bytecodeText/staticFields/classObject.kt @@ -4,4 +4,4 @@ class A { } } // A and companion object constructor call -// 3 ALOAD 0 \ No newline at end of file +// 4 ALOAD 0 \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/staticFields/classObjectSyntheticAccessor.kt b/compiler/testData/codegen/bytecodeText/staticFields/classObjectSyntheticAccessor.kt index 8ef75cec9be..369ed0472e2 100644 --- a/compiler/testData/codegen/bytecodeText/staticFields/classObjectSyntheticAccessor.kt +++ b/compiler/testData/codegen/bytecodeText/staticFields/classObjectSyntheticAccessor.kt @@ -4,5 +4,5 @@ class A { } } // A and companion object constructor call -// 3 ALOAD 0 +// 4 ALOAD 0 // 1 synthetic access\$getR diff --git a/compiler/testData/codegen/bytecodeText/staticFields/object.kt b/compiler/testData/codegen/bytecodeText/staticFields/object.kt index 07a30b494b2..5c538220d21 100644 --- a/compiler/testData/codegen/bytecodeText/staticFields/object.kt +++ b/compiler/testData/codegen/bytecodeText/staticFields/object.kt @@ -2,5 +2,5 @@ object A { val r: Int = 1 } // Field initialized in constant pool -// A super constructor call and INSTANCE$ put -// 2 ALOAD 0 \ No newline at end of file +// A super constructor call, INSTANCE and INSTANCE$ put +// 3 ALOAD 0 \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java index 22d60410167..e1830d27b5e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java @@ -53,6 +53,12 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege doTestWithJava(fileName); } + @TestMetadata("deprecatedFieldForObject") + public void testDeprecatedFieldForObject() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/deprecatedFieldForObject/"); + doTestWithJava(fileName); + } + @TestMetadata("inline") public void testInline() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/inline/"); diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java index 690963dff1d..4dc970fcc31 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java @@ -49,7 +49,8 @@ public final class JvmAbi { public static final String PROPERTY_METADATA_ARRAY_NAME = "$propertyMetadata"; public static final String ANNOTATED_PROPERTY_METHOD_NAME_SUFFIX = "$annotations"; - public static final String INSTANCE_FIELD = "INSTANCE$"; + public static final String INSTANCE_FIELD = "INSTANCE"; + public static final String DEPRECATED_INSTANCE_FIELD = "INSTANCE$"; public static final String KOTLIN_CLASS_FIELD_NAME = "$kotlinClass"; public static final String KOTLIN_PACKAGE_FIELD_NAME = "$kotlinPackage"; diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/SourceFile.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/SourceFile.java similarity index 83% rename from core/descriptors/src/org/jetbrains/kotlin/descriptors/SourceFile.kt rename to core/descriptors/src/org/jetbrains/kotlin/descriptors/SourceFile.java index ff696ca8fa2..7baa91d94b3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/SourceFile.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/SourceFile.java @@ -14,10 +14,8 @@ * limitations under the License. */ -package org.jetbrains.kotlin.descriptors +package org.jetbrains.kotlin.descriptors; public interface SourceFile { - companion object { - val NO_SOURCE_FILE = object : SourceFile {} - } + SourceFile NO_SOURCE_FILE = new SourceFile() {}; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java index 3e444db785b..99b5f350915 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java @@ -61,6 +61,6 @@ public class AnnotationDescriptorImpl implements AnnotationDescriptor { @Override public String toString() { - return DescriptorRenderer.FQ_NAMES_IN_TYPES.renderAnnotation(this, null); + return DescriptorRenderer.Companion.getFQ_NAMES_IN_TYPES().renderAnnotation(this, null); } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/DeclarationDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/DeclarationDescriptorImpl.java index 3398cf0513b..32113f43855 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/DeclarationDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/DeclarationDescriptorImpl.java @@ -59,7 +59,7 @@ public abstract class DeclarationDescriptorImpl extends AnnotatedImpl implements @NotNull public static String toString(@NotNull DeclarationDescriptor descriptor) { try { - return DescriptorRenderer.DEBUG_TEXT.render(descriptor) + + return DescriptorRenderer.Companion.getDEBUG_TEXT().render(descriptor) + "[" + descriptor.getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(descriptor)) + "]"; } catch (Throwable e) { // DescriptionRenderer may throw if this is not yet completely initialized diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java index 6d4037bd760..b2df0ce5698 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java @@ -624,7 +624,7 @@ public class DescriptorUtils { result.add(fqName); } - for (DeclarationDescriptor descriptor : packageView.getMemberScope().getDescriptors(DescriptorKindFilter.PACKAGES, JetScope.ALL_NAME_FILTER)) { + for (DeclarationDescriptor descriptor : packageView.getMemberScope().getDescriptors(DescriptorKindFilter.PACKAGES, JetScope.Companion.getALL_NAME_FILTER())) { if (descriptor instanceof PackageViewDescriptor) { getSubPackagesFqNames((PackageViewDescriptor) descriptor, result); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractJetType.java b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractJetType.java index ea1a80cd2f1..579330efb70 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractJetType.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractJetType.java @@ -63,7 +63,7 @@ public abstract class AbstractJetType implements JetType { for (AnnotationWithTarget annotationWithTarget : getAnnotations().getAllAnnotations()) { sb.append("["); - sb.append(DescriptorRenderer.DEBUG_TEXT.renderAnnotation( + sb.append(DescriptorRenderer.Companion.getDEBUG_TEXT().renderAnnotation( annotationWithTarget.getAnnotation(), annotationWithTarget.getTarget())); sb.append("] "); } diff --git a/idea/src/org/jetbrains/kotlin/idea/liveTemplates/macro/BaseJetVariableMacro.java b/idea/src/org/jetbrains/kotlin/idea/liveTemplates/macro/BaseJetVariableMacro.java index f98d20b72d4..0a15205b476 100644 --- a/idea/src/org/jetbrains/kotlin/idea/liveTemplates/macro/BaseJetVariableMacro.java +++ b/idea/src/org/jetbrains/kotlin/idea/liveTemplates/macro/BaseJetVariableMacro.java @@ -109,9 +109,9 @@ public abstract class BaseJetVariableMacro extends Macro { private static Collection getAllVariables(JetScope scope) { Collection result = ContainerUtil.newArrayList(); - result.addAll(scope.getDescriptors(DescriptorKindFilter.VARIABLES, JetScope.ALL_NAME_FILTER)); + result.addAll(scope.getDescriptors(DescriptorKindFilter.VARIABLES, JetScope.Companion.getALL_NAME_FILTER())); for (ReceiverParameterDescriptor implicitReceiver : scope.getImplicitReceiversHierarchy()) { - result.addAll(implicitReceiver.getType().getMemberScope().getDescriptors(DescriptorKindFilter.VARIABLES, JetScope.ALL_NAME_FILTER)); + result.addAll(implicitReceiver.getType().getMemberScope().getDescriptors(DescriptorKindFilter.VARIABLES, JetScope.Companion.getALL_NAME_FILTER())); } return result; } diff --git a/j2k/testData/multiFile/ToObject/external/JavaFile.java.expected b/j2k/testData/multiFile/ToObject/external/JavaFile.java.expected index 3c79314c7f2..59a81219f26 100644 --- a/j2k/testData/multiFile/ToObject/external/JavaFile.java.expected +++ b/j2k/testData/multiFile/ToObject/external/JavaFile.java.expected @@ -2,8 +2,8 @@ package test; class C { void foo() { - Utils.INSTANCE$.foo1(Utils.staticField); - Utils.staticField += Utils.INSTANCE$.foo2(); - PureUtils.INSTANCE$.foo1(PureUtils.INSTANCE$.foo2()) + Utils.INSTANCE.foo1(Utils.staticField); + Utils.staticField += Utils.INSTANCE.foo2(); + PureUtils.INSTANCE.foo1(PureUtils.INSTANCE.foo2()) } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/ManglingUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/ManglingUtils.java index d5aa0c98f36..39050c6c0f2 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/ManglingUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/ManglingUtils.java @@ -176,7 +176,7 @@ public class ManglingUtils { if (jetScope != null) { final String finalNameToCompare = nameToCompare; - Collection declarations = jetScope.getDescriptors(DescriptorKindFilter.CALLABLES, JetScope.ALL_NAME_FILTER); + Collection declarations = jetScope.getDescriptors(DescriptorKindFilter.CALLABLES, JetScope.Companion.getALL_NAME_FILTER()); List overloadedFunctions = CollectionsKt.flatMap(declarations, new Function1>() { @Override