Abstract FlatSignature from kotlin types
This commit is contained in:
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.annotations.CompositeAnnotations;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.CapturedTypeConstructorKt;
|
||||
import org.jetbrains.kotlin.types.model.TypeSubstitutorMarker;
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||
import org.jetbrains.kotlin.types.typesApproximation.CapturedTypeApproximationKt;
|
||||
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
||||
@@ -34,7 +35,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TypeSubstitutor {
|
||||
public class TypeSubstitutor implements TypeSubstitutorMarker {
|
||||
|
||||
private static final int MAX_RECURSION_DEPTH = 100;
|
||||
|
||||
|
||||
@@ -444,7 +444,9 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
}
|
||||
|
||||
override fun TypeSubstitutorMarker.safeSubstitute(type: KotlinTypeMarker): KotlinTypeMarker {
|
||||
errorSupportedOnlyInTypeInference()
|
||||
require(type is UnwrappedType, type::errorMessage)
|
||||
require(this is TypeSubstitutor, this::errorMessage)
|
||||
return safeSubstitute(type, Variance.INVARIANT)
|
||||
}
|
||||
|
||||
override fun TypeVariableMarker.defaultType(): SimpleTypeMarker {
|
||||
@@ -470,8 +472,14 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
require(this is KotlinType, this::errorMessage)
|
||||
return KotlinBuiltIns.isPrimitiveType(this)
|
||||
}
|
||||
|
||||
override fun captureFromExpression(type: KotlinTypeMarker): KotlinTypeMarker? {
|
||||
return captureFromExpressionInternal(type as UnwrappedType)
|
||||
}
|
||||
}
|
||||
|
||||
private fun captureFromExpressionInternal(type: UnwrappedType) = captureFromExpression(type)
|
||||
|
||||
private fun hasNoInferInternal(type: UnwrappedType): Boolean {
|
||||
return type.hasNoInferAnnotation()
|
||||
}
|
||||
|
||||
@@ -11,4 +11,15 @@ fun TypeSubstitutorMarker.safeSubstitute(
|
||||
type: KotlinTypeMarker
|
||||
) = with(c) { safeSubstitute(type) }
|
||||
|
||||
fun TypeVariableMarker.defaultType(c: TypeSystemInferenceExtensionContext) = with(c) { defaultType() }
|
||||
fun TypeVariableMarker.defaultType(c: TypeSystemInferenceExtensionContext) = with(c) { defaultType() }
|
||||
|
||||
fun KotlinTypeMarker.dependsOnTypeConstructor(c: TypeSystemInferenceExtensionContext, typeConstructors: Set<TypeConstructorMarker>) =
|
||||
with(c) {
|
||||
contains { it.typeConstructor() in typeConstructors }
|
||||
}
|
||||
|
||||
fun KotlinTypeMarker.dependsOnTypeParameters(c: TypeSystemInferenceExtensionContext, typeParameters: Collection<TypeParameterMarker>) =
|
||||
with(c) {
|
||||
val typeConstructors = typeParameters.mapTo(mutableSetOf()) { it.getTypeConstructor() }
|
||||
dependsOnTypeConstructor(c, typeConstructors)
|
||||
}
|
||||
@@ -223,6 +223,8 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
|
||||
status: CaptureStatus
|
||||
): SimpleTypeMarker?
|
||||
|
||||
fun captureFromExpression(type: KotlinTypeMarker): KotlinTypeMarker?
|
||||
|
||||
fun SimpleTypeMarker.asArgumentList(): TypeArgumentListMarker
|
||||
|
||||
operator fun TypeArgumentListMarker.get(index: Int): TypeArgumentMarker {
|
||||
|
||||
Reference in New Issue
Block a user