FIR2IR: inline some conversion one-liners
This commit is contained in:
@@ -69,7 +69,7 @@ fun FirClassifierSymbol<*>.toIrSymbol(
|
|||||||
): IrClassifierSymbol {
|
): IrClassifierSymbol {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is FirTypeParameterSymbol -> {
|
is FirTypeParameterSymbol -> {
|
||||||
toTypeParameterSymbol(declarationStorage, typeContext)
|
declarationStorage.getIrTypeParameterSymbol(this, typeContext)
|
||||||
}
|
}
|
||||||
is FirTypeAliasSymbol -> {
|
is FirTypeAliasSymbol -> {
|
||||||
val typeAlias = fir
|
val typeAlias = fir
|
||||||
@@ -77,7 +77,7 @@ fun FirClassifierSymbol<*>.toIrSymbol(
|
|||||||
coneClassLikeType.lookupTag.toSymbol(session)!!.toIrSymbol(session, declarationStorage)
|
coneClassLikeType.lookupTag.toSymbol(session)!!.toIrSymbol(session, declarationStorage)
|
||||||
}
|
}
|
||||||
is FirClassSymbol -> {
|
is FirClassSymbol -> {
|
||||||
toClassSymbol(declarationStorage)
|
declarationStorage.getIrClassSymbol(this)
|
||||||
}
|
}
|
||||||
else -> throw AssertionError("Should not be here: $this")
|
else -> throw AssertionError("Should not be here: $this")
|
||||||
}
|
}
|
||||||
@@ -109,43 +109,16 @@ fun FirReference.toSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbo
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun AbstractFirBasedSymbol<*>.toSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol? = when (this) {
|
private fun AbstractFirBasedSymbol<*>.toSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol? = when (this) {
|
||||||
is FirClassSymbol -> toClassSymbol(declarationStorage)
|
is FirClassSymbol -> declarationStorage.getIrClassSymbol(this)
|
||||||
is FirFunctionSymbol<*> -> toFunctionSymbol(declarationStorage)
|
is FirFunctionSymbol<*> -> declarationStorage.getIrFunctionSymbol(this)
|
||||||
is FirPropertySymbol -> if (fir.isLocal) toValueSymbol(declarationStorage) else toPropertyOrFieldSymbol(declarationStorage)
|
is FirPropertySymbol -> if (fir.isLocal) declarationStorage.getIrValueSymbol(this) else declarationStorage.getIrPropertyOrFieldSymbol(this)
|
||||||
is FirFieldSymbol -> toPropertyOrFieldSymbol(declarationStorage)
|
is FirFieldSymbol -> declarationStorage.getIrPropertyOrFieldSymbol(this)
|
||||||
is FirBackingFieldSymbol -> toBackingFieldSymbol(declarationStorage)
|
is FirBackingFieldSymbol -> declarationStorage.getIrBackingFieldSymbol(this)
|
||||||
is FirDelegateFieldSymbol<*> -> toBackingFieldSymbol(declarationStorage)
|
is FirDelegateFieldSymbol<*> -> declarationStorage.getIrBackingFieldSymbol(this)
|
||||||
is FirVariableSymbol<*> -> toValueSymbol(declarationStorage)
|
is FirVariableSymbol<*> -> declarationStorage.getIrValueSymbol(this)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FirClassSymbol<*>.toClassSymbol(declarationStorage: Fir2IrDeclarationStorage): IrClassSymbol {
|
|
||||||
return declarationStorage.getIrClassSymbol(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FirTypeParameterSymbol.toTypeParameterSymbol(
|
|
||||||
declarationStorage: Fir2IrDeclarationStorage,
|
|
||||||
typeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT
|
|
||||||
): IrTypeParameterSymbol {
|
|
||||||
return declarationStorage.getIrTypeParameterSymbol(this, typeContext)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FirFunctionSymbol<*>.toFunctionSymbol(declarationStorage: Fir2IrDeclarationStorage): IrFunctionSymbol {
|
|
||||||
return declarationStorage.getIrFunctionSymbol(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FirVariableSymbol<*>.toPropertyOrFieldSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol {
|
|
||||||
return declarationStorage.getIrPropertyOrFieldSymbol(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FirVariableSymbol<*>.toBackingFieldSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol {
|
|
||||||
return declarationStorage.getIrBackingFieldSymbol(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FirVariableSymbol<*>.toValueSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol {
|
|
||||||
return declarationStorage.getIrValueSymbol(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FirConstExpression<*>.getIrConstKind(): IrConstKind<*> = when (kind) {
|
fun FirConstExpression<*>.getIrConstKind(): IrConstKind<*> = when (kind) {
|
||||||
FirConstKind.IntegerLiteral -> {
|
FirConstKind.IntegerLiteral -> {
|
||||||
val type = typeRef.coneTypeUnsafe<ConeIntegerLiteralType>()
|
val type = typeRef.coneTypeUnsafe<ConeIntegerLiteralType>()
|
||||||
|
|||||||
+1
-1
@@ -568,7 +568,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
val created = create()
|
val created = create()
|
||||||
if (function.symbol.callableId.isKFunctionInvoke()) {
|
if (function.symbol.callableId.isKFunctionInvoke()) {
|
||||||
(function.symbol.overriddenSymbol as? FirNamedFunctionSymbol)?.let {
|
(function.symbol.overriddenSymbol as? FirNamedFunctionSymbol)?.let {
|
||||||
created.overriddenSymbols += (it.toFunctionSymbol(this) as IrSimpleFunctionSymbol)
|
created.overriddenSymbols += getIrFunctionSymbol(it) as IrSimpleFunctionSymbol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
functionCache[function] = created
|
functionCache[function] = created
|
||||||
|
|||||||
@@ -1452,7 +1452,7 @@ class Fir2IrVisitor(
|
|||||||
if (argument is FirResolvedReifiedParameterReference) {
|
if (argument is FirResolvedReifiedParameterReference) {
|
||||||
IrClassReferenceImpl(
|
IrClassReferenceImpl(
|
||||||
startOffset, endOffset, irType,
|
startOffset, endOffset, irType,
|
||||||
argument.symbol.toTypeParameterSymbol(declarationStorage),
|
declarationStorage.getIrTypeParameterSymbol(argument.symbol, ConversionTypeContext.DEFAULT),
|
||||||
argument.typeRef.toIrType()
|
argument.typeRef.toIrType()
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user