diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index f0aa0307ec0..451f7fa1be9 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -529,7 +529,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { closure.superCall = (JetDelegatorToSuperCall) superCall; DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, ((JetDelegatorToSuperCall) superCall).getCalleeExpression().getConstructorReferenceExpression()); if (declarationDescriptor instanceof ClassDescriptor) { - declarationDescriptor = ((ClassDescriptor)declarationDescriptor).getUnsubstitutedPrimaryConstructor(); + declarationDescriptor = ((ClassDescriptorFromSource) declarationDescriptor).getUnsubstitutedPrimaryConstructor(); } ConstructorDescriptor superConstructor = (ConstructorDescriptor) declarationDescriptor; CallableMethod superCallable = typeMapper.mapToCallableMethod(superConstructor, OwnerKind.IMPLEMENTATION, typeMapper.hasThis0(superConstructor.getContainingDeclaration())); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptor.java index d352202a0a0..ec031a07273 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptor.java @@ -41,9 +41,6 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor, @NotNull Set getConstructors(); - @Nullable - ConstructorDescriptor getUnsubstitutedPrimaryConstructor(); - @Override @NotNull DeclarationDescriptor getContainingDeclaration(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorFromSource.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorFromSource.java new file mode 100644 index 00000000000..3513956a3f8 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorFromSource.java @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.lang.descriptors; + +import org.jetbrains.annotations.Nullable; + +/** + * @author Stepan Koltsov + */ +public interface ClassDescriptorFromSource extends ClassDescriptor { + @Nullable + ConstructorDescriptor getUnsubstitutedPrimaryConstructor(); + +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java index 0dde08e8498..e36d672400e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java @@ -32,7 +32,7 @@ import java.util.*; /** * @author abreslav */ -public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements ClassDescriptor { +public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements ClassDescriptorFromSource { private TypeConstructor typeConstructor; private JetScope memberDeclarations; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java index c59f3cebe01..338301d8cae 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java @@ -121,11 +121,6 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { return r; } - @Override - public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() { - return original.getUnsubstitutedPrimaryConstructor(); - } - @Override public List getAnnotations() { return original.getAnnotations(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java index f5dbf5d9e42..00c6dfc712c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors; import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.psi.JetParameter; import org.jetbrains.jet.lang.resolve.AbstractScopeAdapter; import org.jetbrains.jet.lang.resolve.BindingContextUtils; @@ -36,7 +37,9 @@ import java.util.Set; /** * @author abreslav */ -public class MutableClassDescriptor extends MutableClassDescriptorLite { +public class MutableClassDescriptor extends MutableClassDescriptorLite implements ClassDescriptorFromSource { + private ConstructorDescriptor primaryConstructor; + private final Set declaredCallableMembers = Sets.newHashSet(); private final Set allCallableMembers = Sets.newHashSet(); // includes fake overrides private final Set properties = Sets.newHashSet(); @@ -84,6 +87,20 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite { } } + public void setPrimaryConstructor(@NotNull ConstructorDescriptor constructorDescriptor, BindingTrace trace) { + assert this.primaryConstructor == null : "Primary constructor assigned twice " + this; + this.primaryConstructor = constructorDescriptor; + addConstructor(constructorDescriptor, trace); + } + + @Override + @Nullable + public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() { + return primaryConstructor; + } + + + @NotNull public Set getFunctions() { return functions; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.java index 9e9ab59d7ea..bb6cb468e3e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.java @@ -38,7 +38,6 @@ import java.util.*; */ public class MutableClassDescriptorLite extends ClassDescriptorBase implements WithDeferredResolve { - private ConstructorDescriptor primaryConstructor; private final Set constructors = Sets.newLinkedHashSet(); private List annotations = Lists.newArrayList(); @@ -206,18 +205,6 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase } - public void setPrimaryConstructor(@NotNull ConstructorDescriptor constructorDescriptor, BindingTrace trace) { - assert this.primaryConstructor == null : "Primary constructor assigned twice " + this; - this.primaryConstructor = constructorDescriptor; - addConstructor(constructorDescriptor, trace); - } - - @Override - @Nullable - public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() { - return primaryConstructor; - } - public void addConstructor(@NotNull ConstructorDescriptor constructorDescriptor, @Nullable BindingTrace trace) { assert constructorDescriptor.getContainingDeclaration() == this; constructors.add(constructorDescriptor); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java index c2eb0b35d8f..87653d27d09 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java @@ -377,7 +377,7 @@ public class DeclarationsChecker { DeclarationDescriptor declaration = classDescriptor.getContainingDeclaration().getContainingDeclaration(); assert declaration instanceof ClassDescriptor; - ClassDescriptor enumClass = (ClassDescriptor) declaration; + ClassDescriptorFromSource enumClass = (ClassDescriptorFromSource) declaration; assert enumClass.getKind() == ClassKind.ENUM_CLASS; List delegationSpecifiers = aClass.getDelegationSpecifiers(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/LazyClassDescriptor.java index 9912cbc2fd0..f796d97ff76 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/LazyClassDescriptor.java @@ -35,7 +35,7 @@ import java.util.*; /** * @author abreslav */ -public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDescriptor { +public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDescriptorFromSource { private final ResolveSession resolveSession; private final ClassMemberDeclarationProvider declarationProvider; diff --git a/js/js.translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java b/js/js.translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java index 45dbe8970b5..063b8724b0c 100644 --- a/js/js.translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java +++ b/js/js.translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java @@ -354,7 +354,7 @@ public final class BindingUtils { public static ConstructorDescriptor getConstructor(@NotNull BindingContext bindingContext, @NotNull JetClassOrObject declaration) { ConstructorDescriptor primaryConstructor = - getClassDescriptor(bindingContext, declaration).getUnsubstitutedPrimaryConstructor(); + ((ClassDescriptorFromSource) getClassDescriptor(bindingContext, declaration)).getUnsubstitutedPrimaryConstructor(); assert primaryConstructor != null : "Traits do not have initialize methods."; return primaryConstructor; }