Drop MutableClassDescriptorLite
Inline it into MutableClassDescriptor
This commit is contained in:
-61
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.resolve.java.descriptor;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassKind;
|
||||
import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptorLite;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.name.SpecialNames.getClassObjectName;
|
||||
|
||||
public class JavaEnumClassObjectDescriptor extends MutableClassDescriptorLite {
|
||||
private ConstructorDescriptor constructor;
|
||||
|
||||
public JavaEnumClassObjectDescriptor(@NotNull DeclarationDescriptor enumClass) {
|
||||
super(enumClass, getClassObjectName(enumClass.getName()), ClassKind.CLASS_OBJECT, false);
|
||||
}
|
||||
|
||||
private void initConstructor() {
|
||||
if (constructor == null) {
|
||||
ConstructorDescriptorImpl constructor = DescriptorFactory.createPrimaryConstructorForObject(this);
|
||||
constructor.setReturnType(getDefaultType());
|
||||
this.constructor = constructor;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ConstructorDescriptor> getConstructors() {
|
||||
initConstructor();
|
||||
return Collections.singleton(constructor);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
initConstructor();
|
||||
return constructor;
|
||||
}
|
||||
}
|
||||
+8
-6
@@ -10,7 +10,6 @@ import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.lang.types.TypeConstructor
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor
|
||||
import java.util.Collections
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaResolverContextWithTypes
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.child
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage
|
||||
@@ -24,7 +23,6 @@ import org.jetbrains.jet.lang.resolve.java.structure.JavaMethod
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.jet.lang.types.TypeUtils
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaClassDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaEnumClassObjectDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.Modality
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler
|
||||
@@ -36,6 +34,8 @@ import java.util.ArrayList
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaClassStaticsPackageFragmentDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.name.SpecialNames
|
||||
|
||||
class LazyJavaClassDescriptor(
|
||||
private val outerC: LazyJavaResolverContextWithTypes,
|
||||
@@ -82,12 +82,14 @@ class LazyJavaClassDescriptor(
|
||||
|
||||
private val _classObjectDescriptor = c.storageManager.createNullableLazyValue {
|
||||
if (jClass.isEnum()) {
|
||||
val classObject = JavaEnumClassObjectDescriptor(this)
|
||||
classObject.setSupertypes(Collections.singleton(KotlinBuiltIns.getInstance().getAnyType()))
|
||||
val classObject = MutableClassDescriptor(this, this.getUnsubstitutedInnerClassesScope(), ClassKind.CLASS_OBJECT, false,
|
||||
SpecialNames.getClassObjectName(this.getName()))
|
||||
classObject.setSupertypes(listOf(KotlinBuiltIns.getInstance().getAnyType()))
|
||||
classObject.setModality(Modality.FINAL)
|
||||
classObject.setVisibility(jClass.getVisibility())
|
||||
classObject.setTypeParameterDescriptors(Collections.emptyList<TypeParameterDescriptor>())
|
||||
classObject.setTypeParameterDescriptors(listOf())
|
||||
classObject.createTypeConstructor()
|
||||
classObject.setPrimaryConstructor(DescriptorFactory.createPrimaryConstructorForObject(classObject))
|
||||
|
||||
val scope = LazyJavaClassMemberScope(c, classObject, jClass, enumClassObject = true)
|
||||
val writableScope = WritableScopeImpl(scope, classObject, RedeclarationHandler.THROW_EXCEPTION, "Enum class object scope")
|
||||
@@ -102,7 +104,7 @@ class LazyJavaClassDescriptor(
|
||||
else null
|
||||
}
|
||||
|
||||
private fun createEnumSyntheticMethods(classObject: JavaEnumClassObjectDescriptor, enumType: JetType) {
|
||||
private fun createEnumSyntheticMethods(classObject: MutableClassDescriptor, enumType: JetType) {
|
||||
val valuesReturnType = KotlinBuiltIns.getInstance().getArrayType(enumType)
|
||||
val valuesMethod = DescriptorFactory.createEnumClassObjectValuesMethod(classObject, valuesReturnType)
|
||||
classObject.getBuilder().addFunctionDescriptor(valuesMethod)
|
||||
|
||||
Reference in New Issue
Block a user