From d63a2462ef80e6aff1e30ed39dffee6b77069e3e Mon Sep 17 00:00:00 2001 From: Jim S Date: Sat, 7 Apr 2018 01:49:20 -0700 Subject: [PATCH] Eliminate duplicate call to genSyntheticClassOrObject As far as I can tell (and admittedly I'm not an expert in the Kotlin compiler code), it looks like the new logic iterates over all contributed descriptors, which renders the old logic (which explicitly invokes getCompanionObjectDescriptor) obsolete. We ran into this last year when rebasing on top of https://github.com/JetBrains/kotlin/commit/527ccaff16ecebbfbcecabd5fbc8af808a296915 and - after a quick conversation with @sandwwraith (email chain dated December 12, 2017) - we unblocked ourselves by deleting the old code from our local repository. Now we're looking to upstream our changes, thus this PR. Old code: ``` // Generate synthetic (non-declared) companion if needed ClassDescriptor companionObjectDescriptor = descriptor.getCompanionObjectDescriptor(); if (companionObjectDescriptor instanceof SyntheticClassOrObjectDescriptor) { genSyntheticClassOrObject((SyntheticClassOrObjectDescriptor) companionObjectDescriptor); } ``` New code: ``` // Generate synthetic nested classes Collection classifiers = descriptor .getUnsubstitutedMemberScope() .getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS, MemberScope.Companion.getALL_NAME_FILTER()); for (DeclarationDescriptor memberDescriptor : classifiers) { if (memberDescriptor instanceof SyntheticClassOrObjectDescriptor) { genSyntheticClassOrObject((SyntheticClassOrObjectDescriptor) memberDescriptor); } } ``` Change-Id: Icb51ee6e56b9928108cc121c78fa50c6354a4b31 --- .../src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java index fa7006fb790..60596fa41f3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java @@ -91,12 +91,6 @@ public abstract class ClassBodyCodegen extends MemberCodegen classifiers = descriptor .getUnsubstitutedMemberScope()