From 2228cb6a9ab71dca3a8fd562a35e8b438bd0c767 Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Wed, 13 Jan 2016 12:47:34 +0300 Subject: [PATCH] Rollback parameter descriptor propagation to CapturedTypeConstructor --- .../inference/ConstraintSystemBuilderImpl.kt | 2 +- .../calls/inference/constraintIncorporation.kt | 4 ++-- .../CapturedTypeApproximationTest.kt | 2 +- .../calls/inference/CapturedTypeConstructor.kt | 16 +++++++--------- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt index 3fa6ecf1dc5..c8295ad38e1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt @@ -320,7 +320,7 @@ class ConstraintSystemBuilderImpl : ConstraintSystem.Builder { else { constrainingTypeProjection } - val capturedType = createCapturedType(typeProjection, typeVariable.originalTypeParameter) + val capturedType = createCapturedType(typeProjection) addBound(typeVariable, capturedType, EXACT_BOUND, constraintContext) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index 5fcf63b46ed..07b1b8385c7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -87,8 +87,8 @@ private fun ConstraintSystemBuilderImpl.generateNewBound(bound: Bound, substitut val substitutedType = when (substitution.kind) { EXACT_BOUND -> substitution.constrainingType - UPPER_BOUND -> CapturedType(TypeProjectionImpl(Variance.OUT_VARIANCE, substitution.constrainingType), substitution.typeVariable.originalTypeParameter) - LOWER_BOUND -> CapturedType(TypeProjectionImpl(Variance.IN_VARIANCE, substitution.constrainingType), substitution.typeVariable.originalTypeParameter) + UPPER_BOUND -> CapturedType(TypeProjectionImpl(Variance.OUT_VARIANCE, substitution.constrainingType)) + LOWER_BOUND -> CapturedType(TypeProjectionImpl(Variance.IN_VARIANCE, substitution.constrainingType)) } val newTypeProjection = TypeProjectionImpl(substitutedType) diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt index 60705758825..e7d709f2827 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt @@ -84,7 +84,7 @@ class CapturedTypeApproximationTest() : KotlinLiteFixture() { fun createTestSubstitutor(testSubstitution: Map): TypeSubstitutor { val substitutionContext = testSubstitution.map { val (typeParameter, typeProjection) = it - typeParameter.typeConstructor to TypeProjectionImpl(createCapturedType(typeProjection, typeParameter)) + typeParameter.typeConstructor to TypeProjectionImpl(createCapturedType(typeProjection)) }.toMap() return TypeSubstitutor.create(substitutionContext) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt index fec8fc34428..cdc6da5bd6e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt @@ -25,8 +25,7 @@ import org.jetbrains.kotlin.types.Variance.OUT_VARIANCE import org.jetbrains.kotlin.types.typeUtil.builtIns class CapturedTypeConstructor( - val typeProjection: TypeProjection, - val typeParameterDescriptor: TypeParameterDescriptor + val typeProjection: TypeProjection ): TypeConstructor { init { assert(typeProjection.projectionKind != Variance.INVARIANT) { @@ -48,7 +47,7 @@ class CapturedTypeConstructor( override fun isDenotable() = false - override fun getDeclarationDescriptor() = typeParameterDescriptor + override fun getDeclarationDescriptor() = null override fun getAnnotations() = Annotations.EMPTY @@ -58,14 +57,13 @@ class CapturedTypeConstructor( } class CapturedType( - private val typeProjection: TypeProjection, - private val typeParameterDescriptor: TypeParameterDescriptor + private val typeProjection: TypeProjection ): DelegatingType(), SubtypingRepresentatives { private val delegateType = run { val scope = ErrorUtils.createErrorScope( "No member resolution should be done on captured type, it used only during constraint system resolution", true) - KotlinTypeImpl.create(Annotations.EMPTY, CapturedTypeConstructor(typeProjection, typeParameterDescriptor), false, listOf(), scope) + KotlinTypeImpl.create(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), false, listOf(), scope) } override fun getDelegate(): KotlinType = delegateType @@ -95,8 +93,8 @@ class CapturedType( override fun toString() = "Captured($typeProjection)" } -fun createCapturedType(typeProjection: TypeProjection, typeParameterDescriptor: TypeParameterDescriptor): KotlinType - = CapturedType(typeProjection, typeParameterDescriptor) +fun createCapturedType(typeProjection: TypeProjection): KotlinType + = CapturedType(typeProjection) fun KotlinType.isCaptured(): Boolean = constructor is CapturedTypeConstructor @@ -128,5 +126,5 @@ private fun TypeProjection.createCapturedIfNeeded(typeParameterDescriptor: TypeP TypeProjectionImpl(this@createCapturedIfNeeded.type) } - return TypeProjectionImpl(createCapturedType(this, typeParameterDescriptor)) + return TypeProjectionImpl(createCapturedType(this)) }