[FIR] Cleanup FIR modules. Part 8 (types package)
This commit is contained in:
+1
-1
@@ -740,7 +740,7 @@ class Fir2IrDeclarationStorage(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
valueParameter.name, index, type,
|
||||
if (!valueParameter.isVararg) null
|
||||
else valueParameter.returnTypeRef.coneTypeSafe<ConeKotlinType>()?.arrayElementType(session)?.toIrType(typeContext),
|
||||
else valueParameter.returnTypeRef.coneTypeSafe<ConeKotlinType>()?.arrayElementType()?.toIrType(typeContext),
|
||||
valueParameter.isCrossinline, valueParameter.isNoinline
|
||||
).apply {
|
||||
descriptor.bind(this)
|
||||
|
||||
@@ -6,11 +6,9 @@
|
||||
package org.jetbrains.kotlin.fir.types.jvm
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
|
||||
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.types.FirQualifierPart
|
||||
import org.jetbrains.kotlin.fir.types.FirUserTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.builder.FirUserTypeRefBuilder
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirUserTypeRefImpl
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaType
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ abstract class AbstractConeCallConflictResolver(
|
||||
|
||||
private fun FirValueParameter.argumentType(): ConeKotlinType {
|
||||
val type = returnTypeRef.coneTypeUnsafe<ConeKotlinType>()
|
||||
if (isVararg) return type.arrayElementType(inferenceComponents.session)!!
|
||||
if (isVararg) return type.arrayElementType()!!
|
||||
return type
|
||||
}
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ internal fun FirExpression.getExpectedType(
|
||||
}
|
||||
|
||||
fun ConeKotlinType.varargElementType(session: FirSession): ConeKotlinType {
|
||||
return this.arrayElementType(session) ?: error("Failed to extract! ${this.render()}!")
|
||||
return this.arrayElementType() ?: error("Failed to extract! ${this.render()}!")
|
||||
}
|
||||
|
||||
fun FirTypeRef.isExtensionFunctionType(session: FirSession): Boolean {
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
// Create a FirVarargArgumentExpression for the vararg arguments
|
||||
val varargParameterTypeRef = varargParameter.returnTypeRef
|
||||
val resolvedArrayType = varargParameterTypeRef.substitute(this)
|
||||
val resolvedElementType = resolvedArrayType.arrayElementType(session)
|
||||
val resolvedElementType = resolvedArrayType.arrayElementType()
|
||||
var firstIndex = argumentList.arguments.size
|
||||
val newArgumentMapping = mutableMapOf<FirExpression, FirValueParameter>()
|
||||
val varargArgument = buildVarargArgumentsExpression {
|
||||
|
||||
@@ -9,11 +9,9 @@ import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
|
||||
val FirSymbolProvider.Any: FirClassLikeSymbol<*> get() = this.getClassLikeSymbolByFqName(StandardClassIds.Any)!!
|
||||
val FirSymbolProvider.Nothing: FirClassLikeSymbol<*> get() = this.getClassLikeSymbolByFqName(StandardClassIds.Nothing)!!
|
||||
|
||||
|
||||
operator fun ClassId.invoke(symbolProvider: FirSymbolProvider): FirClassLikeSymbol<*> {
|
||||
return symbolProvider.getClassLikeSymbolByFqName(this)!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.types
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||
|
||||
|
||||
fun ConeTypeProjection.createArrayOf(nullable: Boolean = false): ConeKotlinType {
|
||||
if (this is ConeKotlinTypeProjection) {
|
||||
val type = type.lowerBoundIfFlexible()
|
||||
@@ -25,8 +23,7 @@ fun ConeTypeProjection.createArrayOf(nullable: Boolean = false): ConeKotlinType
|
||||
return StandardClassIds.Array.constructClassLikeType(arrayOf(this), nullable)
|
||||
}
|
||||
|
||||
|
||||
fun ConeKotlinType.arrayElementType(session: FirSession): ConeKotlinType? {
|
||||
fun ConeKotlinType.arrayElementType(): ConeKotlinType? {
|
||||
val type = this.lowerBoundIfFlexible()
|
||||
if (type !is ConeClassLikeType) return null
|
||||
val classId = type.lookupTag.classId
|
||||
|
||||
@@ -58,6 +58,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
||||
isExtensionFunction: Boolean
|
||||
): SimpleTypeMarker {
|
||||
require(constructor is FirClassifierSymbol<*>)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (constructor) {
|
||||
is FirClassLikeSymbol<*> -> ConeClassLikeTypeImpl(
|
||||
constructor.toLookupTag(),
|
||||
|
||||
@@ -335,6 +335,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
||||
}
|
||||
|
||||
require(newArgument is ConeCapturedType)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
newArgument.constructor.supertypes = upperBounds as List<ConeKotlinType>
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSessionComponent
|
||||
import org.jetbrains.kotlin.fir.declarations.FirClassLikeDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
|
||||
|
||||
@@ -92,6 +92,7 @@ fun <T : ConeKotlinType> T.withArguments(arguments: Array<out ConeTypeProjection
|
||||
return this
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> this
|
||||
is ConeClassLikeTypeImpl -> ConeClassLikeTypeImpl(lookupTag, arguments, nullability.isNullable) as T
|
||||
@@ -121,6 +122,7 @@ fun <T : ConeKotlinType> T.withNullability(nullability: ConeNullability, typeCon
|
||||
return this
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (this) {
|
||||
is ConeClassErrorType -> this
|
||||
is ConeClassLikeTypeImpl -> ConeClassLikeTypeImpl(lookupTag, typeArguments, nullability.isNullable)
|
||||
|
||||
+1
-1
@@ -349,7 +349,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
||||
if (valueParameter.isVararg) {
|
||||
data.append("vararg ")
|
||||
}
|
||||
valueParameter.returnTypeRef.coneTypeSafe<ConeClassLikeType>()?.arrayElementType(session)?.let { data.append(it.render()) }
|
||||
valueParameter.returnTypeRef.coneTypeSafe<ConeClassLikeType>()?.arrayElementType()?.let { data.append(it.render()) }
|
||||
?: valueParameter.returnTypeRef.accept(this, data)
|
||||
valueParameter.defaultValue?.let { data.append(" = ...") }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user