From 4517e15299592c740ad925fa08c4792ef58b2307 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 25 Jun 2015 11:54:40 +0300 Subject: [PATCH] Minor refactoring of resolveDelegationSpecifierList --- .../kotlin/resolve/BodyResolver.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java index 897aee133ff..36ad7f00221 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java @@ -394,6 +394,19 @@ public class BodyResolver { trace.report(SUPERTYPES_FOR_ANNOTATION_CLASS.on(jetClass.getDelegationSpecifierList())); } + if (primaryConstructorDelegationCall[0] != null && primaryConstructor != null) { + recordConstructorDelegationCall(trace, primaryConstructor, primaryConstructorDelegationCall[0]); + } + + checkSupertypeList(descriptor, supertypes, jetClass); + } + + // Returns a set of enum or sealed types of which supertypeOwner is an entry or a member + @NotNull + private static Set getAllowedFinalSupertypes( + @NotNull ClassDescriptor descriptor, + @NotNull JetClassOrObject jetClass + ) { Set parentEnumOrSealed; if (jetClass instanceof JetEnumEntry) { parentEnumOrSealed = Collections.singleton(((ClassDescriptor) descriptor.getContainingDeclaration()).getTypeConstructor()); @@ -411,11 +424,7 @@ public class BodyResolver { } } } - - if (primaryConstructorDelegationCall[0] != null && primaryConstructor != null) { - recordConstructorDelegationCall(trace, primaryConstructor, primaryConstructorDelegationCall[0]); - } - checkSupertypeList(descriptor, supertypes, parentEnumOrSealed); + return parentEnumOrSealed; } private static void recordConstructorDelegationCall( @@ -427,12 +436,12 @@ public class BodyResolver { trace.record(CONSTRUCTOR_RESOLVED_DELEGATION_CALL, constructor, (ResolvedCall) call); } - // allowedFinalSupertypes typically contains a enum type of which supertypeOwner is an entry private void checkSupertypeList( @NotNull ClassDescriptor supertypeOwner, @NotNull Map supertypes, - @NotNull Set allowedFinalSupertypes + @NotNull JetClassOrObject jetClass ) { + Set allowedFinalSupertypes = getAllowedFinalSupertypes(supertypeOwner, jetClass); Set typeConstructors = Sets.newHashSet(); boolean classAppeared = false; for (Map.Entry entry : supertypes.entrySet()) {