Minor. Pull computeMemberScope to AbstractLazyType

This commit is contained in:
Denis Zharkov
2015-08-03 10:39:20 +03:00
parent b7c042510d
commit 4563f4b1f9
3 changed files with 11 additions and 31 deletions
@@ -16,14 +16,12 @@
package org.jetbrains.kotlin.serialization.deserialization
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedAnnotations
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.AbstractLazyType
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.LazyType
import org.jetbrains.kotlin.utils.toReadOnlyList
class DeserializedType(
@@ -40,29 +38,12 @@ class DeserializedType(
typeDeserializer.typeArgument(getConstructor().getParameters().getOrNull(index), proto)
}.toReadOnlyList()
override fun computeMemberScope() =
if (isError()) {
ErrorUtils.createErrorScope(getConstructor().toString())
}
else {
getTypeMemberScope(getConstructor(), getArguments())
}
private val annotations = DeserializedAnnotations(c.storageManager) {
c.components.annotationAndConstantLoader.loadTypeAnnotations(typeProto, c.nameResolver)
}
override fun isMarkedNullable(): Boolean = typeProto.getNullable()
private fun getTypeMemberScope(constructor: TypeConstructor, typeArguments: List<TypeProjection>): JetScope {
val descriptor = constructor.getDeclarationDescriptor()
return when (descriptor) {
is TypeParameterDescriptor -> descriptor.getDefaultType().getMemberScope()
is ClassDescriptor -> descriptor.getMemberScope(typeArguments)
else -> throw IllegalStateException("Unsupported classifier: $descriptor")
}
}
override fun isError(): Boolean {
val descriptor = getConstructor().getDeclarationDescriptor()
return descriptor != null && ErrorUtils.isError(descriptor)