[FIR] Replace usages of FirExpression.typeRef with coneTypeOrNull
#KT-59855 Fixed
This commit is contained in:
committed by
Space Team
parent
f60d81097c
commit
8d7c5b375e
@@ -123,9 +123,7 @@ private fun <T> List<T>.createArrayLiteral(session: FirSession, kind: ConstantVa
|
||||
arguments += element.createConstantOrError(session)
|
||||
}
|
||||
}
|
||||
typeRef = buildResolvedTypeRef {
|
||||
type = kind.expectedConeType(session).createArrayType()
|
||||
}
|
||||
coneTypeOrNull = kind.expectedConeType(session).createArrayType()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-9
@@ -42,9 +42,7 @@ internal class AnnotationsLoader(private val session: FirSession, private val ko
|
||||
val resolvedClassTypeRef = classId.toLookupTag().toDefaultResolvedTypeRef()
|
||||
return buildClassReferenceExpression {
|
||||
classTypeRef = resolvedClassTypeRef
|
||||
typeRef = buildResolvedTypeRef {
|
||||
type = StandardClassIds.KClass.constructClassLikeType(arrayOf(resolvedClassTypeRef.type), false)
|
||||
}
|
||||
coneTypeOrNull = StandardClassIds.KClass.constructClassLikeType(arrayOf(resolvedClassTypeRef.type), false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +50,7 @@ internal class AnnotationsLoader(private val session: FirSession, private val ko
|
||||
visitExpression(name, buildGetClassCall {
|
||||
val argument = value.toFirClassReferenceExpression()
|
||||
argumentList = buildUnaryArgumentList(argument)
|
||||
typeRef = argument.typeRef
|
||||
coneTypeOrNull = argument.coneTypeOrNull
|
||||
})
|
||||
}
|
||||
|
||||
@@ -78,7 +76,7 @@ internal class AnnotationsLoader(private val session: FirSession, private val ko
|
||||
elements.add(buildGetClassCall {
|
||||
val argument = value.toFirClassReferenceExpression()
|
||||
argumentList = buildUnaryArgumentList(argument)
|
||||
typeRef = argument.typeRef
|
||||
coneTypeOrNull = argument.coneTypeOrNull
|
||||
})
|
||||
}
|
||||
|
||||
@@ -96,11 +94,9 @@ internal class AnnotationsLoader(private val session: FirSession, private val ko
|
||||
override fun visitEnd() {
|
||||
visitExpression(name, buildArrayLiteral {
|
||||
guessArrayTypeIfNeeded(name, elements)?.let {
|
||||
typeRef = it
|
||||
coneTypeOrNull = it.coneTypeOrNull
|
||||
} ?: elements.firstOrNull()?.coneType?.createOutArrayType()?.let {
|
||||
typeRef = buildResolvedTypeRef {
|
||||
type = it
|
||||
}
|
||||
coneTypeOrNull = it
|
||||
}
|
||||
argumentList = buildArgumentList {
|
||||
arguments += elements
|
||||
|
||||
+3
-4
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.expressions.FirConstExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.unexpandedClassId
|
||||
import org.jetbrains.kotlin.fir.java.*
|
||||
import org.jetbrains.kotlin.fir.java.FirJavaTypeConversionMode
|
||||
import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack
|
||||
import org.jetbrains.kotlin.fir.java.declarations.*
|
||||
import org.jetbrains.kotlin.fir.java.resolveIfJavaType
|
||||
import org.jetbrains.kotlin.fir.java.symbols.FirJavaOverriddenSyntheticPropertySymbol
|
||||
@@ -41,7 +41,6 @@ import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef
|
||||
import org.jetbrains.kotlin.fir.utils.exceptions.withConeTypeEntry
|
||||
import org.jetbrains.kotlin.fir.utils.exceptions.withFirEntry
|
||||
import org.jetbrains.kotlin.load.java.AnnotationQualifierApplicabilityType
|
||||
import org.jetbrains.kotlin.load.java.FakePureImplementationsProvider
|
||||
@@ -54,8 +53,8 @@ import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeParameterMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeSystemContext
|
||||
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
||||
import org.jetbrains.kotlin.util.PrivateForInline
|
||||
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
||||
|
||||
class FirSignatureEnhancement(
|
||||
private val owner: FirRegularClass,
|
||||
@@ -363,7 +362,7 @@ class FirSignatureEnhancement(
|
||||
}
|
||||
}.apply {
|
||||
val newValueParameters = firMethod.valueParameters.zip(enhancedValueParameterTypes) { valueParameter, enhancedReturnType ->
|
||||
valueParameter.defaultValue?.replaceTypeRef(enhancedReturnType)
|
||||
valueParameter.defaultValue?.replaceConeTypeOrNull(enhancedReturnType.coneType)
|
||||
|
||||
buildValueParameter {
|
||||
source = valueParameter.source
|
||||
|
||||
@@ -90,9 +90,8 @@ internal fun JavaAnnotationArgument.toFirExpression(
|
||||
)
|
||||
is JavaArrayAnnotationArgument -> buildArrayLiteral {
|
||||
val argumentTypeRef = expectedTypeRef?.let {
|
||||
typeRef = if (it is FirJavaTypeRef) buildResolvedTypeRef {
|
||||
type = it.toConeKotlinTypeProbablyFlexible(session, javaTypeParameterStack)
|
||||
} else it
|
||||
coneTypeOrNull =
|
||||
if (it is FirJavaTypeRef) it.toConeKotlinTypeProbablyFlexible(session, javaTypeParameterStack) else it.coneType
|
||||
buildResolvedTypeRef {
|
||||
type = it.coneTypeSafe<ConeKotlinType>()?.lowerBoundIfFlexible()?.arrayElementType()
|
||||
?: ConeErrorType(ConeSimpleDiagnostic("expected type is not array type"))
|
||||
@@ -111,10 +110,10 @@ internal fun JavaAnnotationArgument.toFirExpression(
|
||||
argumentList = buildUnaryArgumentList(
|
||||
buildClassReferenceExpression {
|
||||
classTypeRef = resolvedClassTypeRef
|
||||
typeRef = resolvedTypeRef
|
||||
coneTypeOrNull = resolvedTypeRef.coneType
|
||||
}
|
||||
)
|
||||
typeRef = resolvedTypeRef
|
||||
coneTypeOrNull = resolvedTypeRef.coneType
|
||||
}
|
||||
is JavaAnnotationAsAnnotationArgument -> getAnnotation().toFirAnnotationCall(session)
|
||||
else -> buildErrorExpression {
|
||||
@@ -168,13 +167,11 @@ private fun buildEnumCall(session: FirSession, classId: ClassId?, entryName: Nam
|
||||
}
|
||||
|
||||
if (classId != null) {
|
||||
this.typeRef = buildResolvedTypeRef {
|
||||
type = ConeClassLikeTypeImpl(
|
||||
classId.toLookupTag(),
|
||||
emptyArray(),
|
||||
isNullable = false
|
||||
)
|
||||
}
|
||||
this.coneTypeOrNull = ConeClassLikeTypeImpl(
|
||||
classId.toLookupTag(),
|
||||
emptyArray(),
|
||||
isNullable = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,9 +191,7 @@ private fun List<JavaAnnotationArgument>.mapJavaTargetArguments(session: FirSess
|
||||
isNullable = false,
|
||||
ConeAttributes.Empty
|
||||
)
|
||||
typeRef = buildResolvedTypeRef {
|
||||
type = elementConeType
|
||||
}
|
||||
coneTypeOrNull = elementConeType
|
||||
varargElementType = buildResolvedTypeRef {
|
||||
type = elementConeType.createOutArrayType()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user