diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt index ea35f4c3886..c0e8c6a8544 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt @@ -468,8 +468,8 @@ internal class KtSymbolByFirBuilder( } is ConeTypeVariableType -> { - val diagnostic = when ( val typeParameter = coneType.lookupTag.originalTypeParameter) { - null -> ConeSimpleDiagnostic("Cannot infer parameter type for ${coneType.lookupTag.debugName}") + val diagnostic = when ( val typeParameter = coneType.typeConstructor.originalTypeParameter) { + null -> ConeSimpleDiagnostic("Cannot infer parameter type for ${coneType.typeConstructor.debugName}") else -> ConeCannotInferTypeParameterType((typeParameter as ConeTypeParameterLookupTag).typeParameterSymbol) } buildKtType(ConeErrorType(diagnostic, isUninferredParameter = true, attributes = coneType.attributes)) diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/types/KtFirTypeErrorType.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/types/KtFirTypeErrorType.kt index 464533bbb79..be19743d46b 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/types/KtFirTypeErrorType.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/types/KtFirTypeErrorType.kt @@ -30,7 +30,7 @@ internal class KtFirTypeErrorType( override fun tryRenderAsNonErrorType(): String? = withValidityAssertion { when (val diagnostic = coneType.diagnostic) { is ConeCannotInferTypeParameterType -> diagnostic.typeParameter.name.asString() - is ConeTypeVariableTypeIsNotInferred -> diagnostic.typeVariableType.lookupTag.debugName + is ConeTypeVariableTypeIsNotInferred -> diagnostic.typeVariableType.typeConstructor.debugName else -> null } } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt index b96d02144a4..be6e7cb7dac 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt @@ -839,7 +839,7 @@ fun ConeKotlinType?.collectUpperBounds(): Set { else -> error("missing branch for ${javaClass.name}") } is ConeTypeVariableType -> { - val symbol = (type.lookupTag.originalTypeParameter as? ConeTypeParameterLookupTag)?.typeParameterSymbol ?: return + val symbol = (type.typeConstructor.originalTypeParameter as? ConeTypeParameterLookupTag)?.typeParameterSymbol ?: return symbol.resolvedBounds.forEach { collect(it.coneType) } } is ConeDefinitelyNotNullType -> collect(type.original) diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/renderer/ConeTypeRenderer.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/renderer/ConeTypeRenderer.kt index 1a71d324df4..4cb50199e92 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/renderer/ConeTypeRenderer.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/renderer/ConeTypeRenderer.kt @@ -74,7 +74,7 @@ open class ConeTypeRenderer( when (type) { is ConeTypeVariableType -> { builder.append("TypeVariable(") - builder.append(type.lookupTag.name) + builder.append(type.typeConstructor.name) builder.append(")") } diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypeVariableAndStubTypes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypeVariableAndStubTypes.kt index c18c2210e5c..3444ca88723 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypeVariableAndStubTypes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypeVariableAndStubTypes.kt @@ -12,7 +12,7 @@ import org.jetbrains.kotlin.types.model.* class ConeTypeVariableType( override val nullability: ConeNullability, - val lookupTag: ConeTypeVariableTypeConstructor, + val typeConstructor: ConeTypeVariableTypeConstructor, override val attributes: ConeAttributes = ConeAttributes.Empty, ) : ConeSimpleKotlinType() { override val typeArguments: Array get() = EMPTY_ARRAY @@ -21,7 +21,7 @@ class ConeTypeVariableType( if (other !is ConeTypeVariableType) return false if (nullability != other.nullability) return false - if (lookupTag != other.lookupTag) return false + if (typeConstructor != other.typeConstructor) return false return true } @@ -29,7 +29,7 @@ class ConeTypeVariableType( override fun hashCode(): Int { var result = 0 result = 31 * result + nullability.hashCode() - result = 31 * result + lookupTag.hashCode() + result = 31 * result + typeConstructor.hashCode() return result } } diff --git a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt index a523dbb463e..1c82b9a7684 100644 --- a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt +++ b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt @@ -849,7 +849,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver simpleName(type.lookupTag.name) } } - is ConeTypeVariableType -> resolved { +type.lookupTag.name.asString() } + is ConeTypeVariableType -> resolved { +type.typeConstructor.name.asString() } is ConeFlexibleType -> resolved { generate(type) } is ConeCapturedType -> inlineUnsupported(type) is ConeDefinitelyNotNullType -> resolved { diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/LookupTagUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/LookupTagUtils.kt index ebcc35e42c3..a1efb0651e3 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/LookupTagUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/LookupTagUtils.kt @@ -131,7 +131,7 @@ fun ConeKotlinType.findClassRepresentation( is ConeIntegerLiteralType -> possibleTypes.findClassRepresentationThatIsSubtypeOf(dispatchReceiverParameterType, session) is ConeIntersectionType -> intersectedTypes.findClassRepresentationThatIsSubtypeOf(dispatchReceiverParameterType, session) is ConeTypeParameterType -> lookupTag.findClassRepresentationThatIsSubtypeOf(dispatchReceiverParameterType, session) - is ConeTypeVariableType -> (this.lookupTag.originalTypeParameter as? ConeTypeParameterLookupTag) + is ConeTypeVariableType -> (this.typeConstructor.originalTypeParameter as? ConeTypeParameterLookupTag) ?.findClassRepresentationThatIsSubtypeOf(dispatchReceiverParameterType, session) is ConeStubType -> (this.constructor.variable.typeConstructor.originalTypeParameter as? ConeTypeParameterLookupTag) ?.findClassRepresentationThatIsSubtypeOf(dispatchReceiverParameterType, session) diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt index 94c4f752604..b4d3d703a7c 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt @@ -34,7 +34,6 @@ import org.jetbrains.kotlin.types.TypeCheckerState.SupertypesPolicy.LowerIfFlexi import org.jetbrains.kotlin.types.TypeSystemCommonBackendContext import org.jetbrains.kotlin.types.model.* import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment -import org.jetbrains.kotlin.utils.exceptions.withPsiEntry class ErrorTypeConstructor(val reason: String) : TypeConstructorMarker { override fun toString(): String = reason @@ -156,7 +155,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty is ConeClassLikeType -> lookupTag is ConeTypeParameterType -> lookupTag is ConeCapturedType -> constructor - is ConeTypeVariableType -> lookupTag + is ConeTypeVariableType -> typeConstructor is ConeIntersectionType -> this is ConeStubType -> constructor is ConeDefinitelyNotNullType -> original.typeConstructor() @@ -492,7 +491,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty // And while it seems reasonable to have similar semantics as for stub types, it would make some diagnostic test failing // Thus, we leave the same semantics only for stubs (similar to TypeUtils.isNullableType) is ConeStubType -> { - val symbol = (this.constructor.variable.defaultType.lookupTag.originalTypeParameter as? ConeTypeParameterLookupTag)?.symbol + val symbol = (this.constructor.variable.defaultType.typeConstructor.originalTypeParameter as? ConeTypeParameterLookupTag)?.symbol symbol == null || symbol.allBoundsAreNullableOrUnresolved() } is ConeIntersectionType -> intersectedTypes.all { it.isNullableType() } diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt index 5b2460b7596..7a3e7e6ecde 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt @@ -236,7 +236,7 @@ fun T.withAttributes(attributes: ConeAttributes): T { is ConeRawType -> ConeRawType.create(lowerBound.withAttributes(attributes), upperBound.withAttributes(attributes)) is ConeDynamicType -> ConeDynamicType(lowerBound.withAttributes(attributes), upperBound.withAttributes(attributes)) is ConeFlexibleType -> ConeFlexibleType(lowerBound.withAttributes(attributes), upperBound.withAttributes(attributes)) - is ConeTypeVariableType -> ConeTypeVariableType(nullability, lookupTag, attributes) + is ConeTypeVariableType -> ConeTypeVariableType(nullability, typeConstructor, attributes) is ConeCapturedType -> ConeCapturedType( captureStatus, lowerType, nullability, constructor, attributes, isProjectionNotNull, ) @@ -285,7 +285,7 @@ fun T.withNullability( ) } - is ConeTypeVariableType -> ConeTypeVariableType(nullability, lookupTag, theAttributes) + is ConeTypeVariableType -> ConeTypeVariableType(nullability, typeConstructor, theAttributes) is ConeCapturedType -> ConeCapturedType(captureStatus, lowerType, nullability, constructor, theAttributes) is ConeIntersectionType -> when (nullability) { ConeNullability.NULLABLE -> this.mapTypes { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt index 7c370d0183d..53f7d1c7fae 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt @@ -353,7 +353,7 @@ private fun checkApplicabilityForArgumentType( fun tryGetConeTypeThatCompatibleWithKtType(type: ConeKotlinType): ConeKotlinType { if (type is ConeTypeVariableType) { - val lookupTag = type.lookupTag + val lookupTag = type.typeConstructor val constraints = csBuilder.currentStorage().notFixedTypeVariables[lookupTag]?.constraints val constraintTypes = constraints?.mapNotNull { it.type as? ConeKotlinType } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt index 6c15157193d..f8bd4d09381 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt @@ -84,7 +84,7 @@ internal object CheckCallableReferenceExpectedType : CheckerStage() { val position = ConeArgumentConstraintPosition(callInfo.callSite) if (expectedType != null && !resultingType.contains { - it is ConeTypeVariableType && it.lookupTag !in outerCsBuilder.currentStorage().allTypeVariables + it is ConeTypeVariableType && it.typeConstructor !in outerCsBuilder.currentStorage().allTypeVariables } ) { addSubtypeConstraint(resultingType, expectedType, position) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 7f5fd8d78da..ad96b3ea3d3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -449,7 +449,7 @@ open class FirDeclarationsResolveTransformer( // Substitut type parameter to type variable .let(candidate.substitutor::substituteOrSelf) .unwrapTopLevelVariableType() ?: return null - val typeVariable = returnTypeBasedOnVariable.lookupTag + val typeVariable = returnTypeBasedOnVariable.typeConstructor val candidateSystem = candidate.system val candidateStorage = candidateSystem.currentStorage() diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/TypeVariableTypeRemovingSubstitutor.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/TypeVariableTypeRemovingSubstitutor.kt index 6190dd9a011..b8a9256298d 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/TypeVariableTypeRemovingSubstitutor.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/TypeVariableTypeRemovingSubstitutor.kt @@ -23,7 +23,7 @@ private class TypeVariableTypeRemovingSubstitutor(typeContext: ConeTypeContext) } private fun convertTypeVariableType(type: ConeTypeVariableType): ConeKotlinType { - val originalTypeParameter = type.lookupTag.originalTypeParameter + val originalTypeParameter = type.typeConstructor.originalTypeParameter if (originalTypeParameter != null) { check(originalTypeParameter is ConeTypeParameterLookupTag) return ConeTypeParameterTypeImpl(originalTypeParameter, type.isNullable, type.attributes) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt index 23c6d71dc24..7c4d22b8d1b 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt @@ -43,7 +43,7 @@ class ConeCannotInferReceiverParameterType( class ConeTypeVariableTypeIsNotInferred( val typeVariableType: ConeTypeVariableType, - override val reason: String = "Type for ${typeVariableType.lookupTag.debugName} is not inferred" + override val reason: String = "Type for ${typeVariableType.typeConstructor.debugName} is not inferred" ) : ConeDiagnostic class ConeUnderscoreUsageWithoutBackticks(source: KtSourceElement) : ConeDiagnosticWithSource(source) { diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/fir/RenderingForDebugInfo.kt b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/fir/RenderingForDebugInfo.kt index 6867da43254..3f86ef17a62 100644 --- a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/fir/RenderingForDebugInfo.kt +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/fir/RenderingForDebugInfo.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.types.* fun ConeKotlinType.renderForDebugInfo(): String { val nullabilitySuffix = if (this !is ConeErrorType && this !is ConeErrorType) nullability.suffix else "" return when (this) { - is ConeTypeVariableType -> "TypeVariable(${this.lookupTag.name})" + is ConeTypeVariableType -> "TypeVariable(${this.typeConstructor.name})" is ConeDefinitelyNotNullType -> "${original.renderForDebugInfo()}!!" is ConeErrorType -> "ERROR CLASS: ${diagnostic.reason}" is ConeCapturedType -> "CapturedType(${constructor.projection.renderForDebugInfo()})"