Type Approximation: add separate flag to control approx. anonymous type

This extra flexibility is useful for IDE where we always want to
approximate anonymous types but may not want to approximate other local
 types
This commit is contained in:
Tianyu Geng
2021-12-07 10:31:29 -08:00
committed by teamcity
parent c5c606924c
commit a5844b754e
7 changed files with 28 additions and 2 deletions
@@ -377,6 +377,7 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
fun TypeConstructorMarker.isInterface(): Boolean
fun TypeConstructorMarker.isIntegerLiteralTypeConstructor(): Boolean
fun TypeConstructorMarker.isLocalType(): Boolean
fun TypeConstructorMarker.isAnonymous(): Boolean
fun TypeConstructorMarker.getTypeParameterClassifier(): TypeParameterMarker?
val TypeVariableTypeConstructorMarker.typeParameter: TypeParameterMarker?
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.descriptors.impl.AbstractTypeParameterDescriptor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.inference.CapturedType
import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor
@@ -44,6 +45,11 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
return declarationDescriptor?.classId?.isLocal == true
}
override fun TypeConstructorMarker.isAnonymous(): Boolean {
require(this is TypeConstructor, this::errorMessage)
return declarationDescriptor?.classId?.shortClassName == SpecialNames.ANONYMOUS
}
override val TypeVariableTypeConstructorMarker.typeParameter: TypeParameterMarker?
get() {
require(this is NewTypeVariableConstructor, this::errorMessage)