Minor: reformat CapturedTypeConstructor.kt according to code style
This commit is contained in:
+11
-8
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.types.typeUtil.builtIns
|
|||||||
|
|
||||||
class CapturedTypeConstructor(
|
class CapturedTypeConstructor(
|
||||||
val typeProjection: TypeProjection
|
val typeProjection: TypeProjection
|
||||||
): TypeConstructor {
|
) : TypeConstructor {
|
||||||
var newTypeConstructor: NewCapturedTypeConstructor? = null
|
var newTypeConstructor: NewCapturedTypeConstructor? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -64,13 +64,14 @@ class CapturedType(
|
|||||||
override val constructor: CapturedTypeConstructor = CapturedTypeConstructor(typeProjection),
|
override val constructor: CapturedTypeConstructor = CapturedTypeConstructor(typeProjection),
|
||||||
override val isMarkedNullable: Boolean = false,
|
override val isMarkedNullable: Boolean = false,
|
||||||
override val annotations: Annotations = Annotations.EMPTY
|
override val annotations: Annotations = Annotations.EMPTY
|
||||||
): SimpleType(), SubtypingRepresentatives {
|
) : SimpleType(), SubtypingRepresentatives {
|
||||||
override val arguments: List<TypeProjection>
|
override val arguments: List<TypeProjection>
|
||||||
get() = listOf()
|
get() = listOf()
|
||||||
|
|
||||||
override val memberScope: MemberScope
|
override val memberScope: MemberScope
|
||||||
get() = ErrorUtils.createErrorScope(
|
get() = ErrorUtils.createErrorScope(
|
||||||
"No member resolution should be done on captured type, it used only during constraint system resolution", true)
|
"No member resolution should be done on captured type, it used only during constraint system resolution", true
|
||||||
|
)
|
||||||
|
|
||||||
override val subTypeRepresentative: KotlinType
|
override val subTypeRepresentative: KotlinType
|
||||||
get() = representative(OUT_VARIANCE, builtIns.nullableAnyType)
|
get() = representative(OUT_VARIANCE, builtIns.nullableAnyType)
|
||||||
@@ -90,11 +91,11 @@ class CapturedType(
|
|||||||
return CapturedType(typeProjection, constructor, newNullability, annotations)
|
return CapturedType(typeProjection, constructor, newNullability, annotations)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun replaceAnnotations(newAnnotations: Annotations): CapturedType = CapturedType(typeProjection, constructor, isMarkedNullable, newAnnotations)
|
override fun replaceAnnotations(newAnnotations: Annotations): CapturedType =
|
||||||
|
CapturedType(typeProjection, constructor, isMarkedNullable, newAnnotations)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createCapturedType(typeProjection: TypeProjection): KotlinType
|
fun createCapturedType(typeProjection: TypeProjection): KotlinType = CapturedType(typeProjection)
|
||||||
= CapturedType(typeProjection)
|
|
||||||
|
|
||||||
fun KotlinType.isCaptured(): Boolean = constructor is CapturedTypeConstructor
|
fun KotlinType.isCaptured(): Boolean = constructor is CapturedTypeConstructor
|
||||||
|
|
||||||
@@ -105,11 +106,13 @@ fun TypeSubstitution.wrapWithCapturingSubstitution(needApproximation: Boolean =
|
|||||||
this.arguments.zip(this.parameters).map {
|
this.arguments.zip(this.parameters).map {
|
||||||
it.first.createCapturedIfNeeded(it.second)
|
it.first.createCapturedIfNeeded(it.second)
|
||||||
}.toTypedArray(),
|
}.toTypedArray(),
|
||||||
approximateCapturedTypes = needApproximation)
|
approximateCapturedTypes = needApproximation
|
||||||
|
)
|
||||||
else
|
else
|
||||||
object : DelegatedTypeSubstitution(this@wrapWithCapturingSubstitution) {
|
object : DelegatedTypeSubstitution(this@wrapWithCapturingSubstitution) {
|
||||||
override fun approximateContravariantCapturedTypes() = needApproximation
|
override fun approximateContravariantCapturedTypes() = needApproximation
|
||||||
override fun get(key: KotlinType) = super.get(key)?.createCapturedIfNeeded(key.constructor.declarationDescriptor as? TypeParameterDescriptor)
|
override fun get(key: KotlinType) =
|
||||||
|
super.get(key)?.createCapturedIfNeeded(key.constructor.declarationDescriptor as? TypeParameterDescriptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TypeProjection.createCapturedIfNeeded(typeParameterDescriptor: TypeParameterDescriptor?): TypeProjection {
|
private fun TypeProjection.createCapturedIfNeeded(typeParameterDescriptor: TypeParameterDescriptor?): TypeProjection {
|
||||||
|
|||||||
Reference in New Issue
Block a user