Drop some usages of KotlinBuiltIns.getInstance() in ide-common module

This commit is contained in:
Pavel V. Talanov
2015-09-21 18:57:15 +03:00
parent 0610dd36fa
commit e42057c71c
2 changed files with 6 additions and 11 deletions
@@ -16,13 +16,13 @@
package org.jetbrains.kotlin.idea.util
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.renderer.DescriptorRendererModifier
import org.jetbrains.kotlin.renderer.NameShortness
import org.jetbrains.kotlin.renderer.OverrideRenderingPolicy
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.isDynamic
import org.jetbrains.kotlin.types.typeUtil.builtIns
public object IdeDescriptorRenderers {
public val APPROXIMATE_FLEXIBLE_TYPES: (JetType) -> JetType = { approximateFlexibleTypes(it, true) }
@@ -37,7 +37,7 @@ public object IdeDescriptorRenderers {
type.constructor.supertypes.singleOrNull()?.let { return it }
val builtIns = KotlinBuiltIns.getInstance()
val builtIns = type.builtIns
return if (type.isMarkedNullable)
builtIns.nullableAnyType
else
@@ -18,7 +18,6 @@
package org.jetbrains.kotlin.idea.util
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.idea.imports.canBeReferencedViaImport
@@ -28,16 +27,12 @@ import org.jetbrains.kotlin.load.java.JvmAnnotationNames.JETBRAINS_NULLABLE_ANNO
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.JETBRAINS_READONLY_ANNOTATION
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
import org.jetbrains.kotlin.psi.JetCallableDeclaration
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.utils.getClassifier
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.immediateSupertypes
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.types.typeUtil.substitute
import org.jetbrains.kotlin.types.typeUtil.supertypes
import org.jetbrains.kotlin.types.typeUtil.*
public fun approximateFlexibleTypes(jetType: JetType, outermost: Boolean = true): JetType {
if (jetType.isDynamic()) return jetType
@@ -95,13 +90,13 @@ fun JetType.isResolvableInScope(scope: LexicalScope?, checkTypeParameters: Boole
public fun JetType.approximateWithResolvableType(scope: LexicalScope?, checkTypeParameters: Boolean): JetType {
if (isError() || isResolvableInScope(scope, checkTypeParameters)) return this
return supertypes().firstOrNull { it.isResolvableInScope(scope, checkTypeParameters) }
?: KotlinBuiltIns.getInstance().getAnyType()
?: builtIns.anyType
}
public fun JetType.anonymousObjectSuperTypeOrNull(): JetType? {
val classDescriptor = constructor.declarationDescriptor
if (classDescriptor != null && DescriptorUtils.isAnonymousObject(classDescriptor)) {
return immediateSupertypes().firstOrNull() ?: KotlinBuiltIns.getInstance().anyType
return immediateSupertypes().firstOrNull() ?: classDescriptor.builtIns.anyType
}
return null
}