IR: remove a KotlinType use from Ir.kt

This commit is contained in:
Georgy Bronnikov
2020-06-30 20:22:32 +03:00
parent aab95f93f2
commit a97d718de8
2 changed files with 15 additions and 7 deletions
@@ -118,22 +118,30 @@ open class BuiltinSymbolsBase(protected val irBuiltIns: IrBuiltIns, protected va
.getContributedFunctions(Name.identifier("getProgressionLastElement"), NoLookupLocation.FROM_BACKEND)
.filter { it.containingDeclaration !is BuiltInsPackageFragment }
.map { d ->
val c = d.returnType?.constructor?.declarationDescriptor?.let { symbolTable.referenceClassifier(it) }
val f = symbolTable.referenceSimpleFunction(d)
c to f
val klass = d.returnType?.constructor?.declarationDescriptor?.let { symbolTable.referenceClassifier(it) }
val function = symbolTable.referenceSimpleFunction(d)
klass to function
}.toMap()
val toUIntByExtensionReceiver = builtInsPackage("kotlin").getContributedFunctions(
Name.identifier("toUInt"),
NoLookupLocation.FROM_BACKEND
).filter { it.containingDeclaration !is BuiltInsPackageFragment && it.extensionReceiverParameter != null }
.map { Pair(it.extensionReceiverParameter!!.type, symbolTable.referenceSimpleFunction(it)) }.toMap()
.map {
val klass = symbolTable.referenceClassifier(it.extensionReceiverParameter!!.type.constructor.declarationDescriptor!!)
val function = symbolTable.referenceSimpleFunction(it)
klass to function
}.toMap()
val toULongByExtensionReceiver = builtInsPackage("kotlin").getContributedFunctions(
Name.identifier("toULong"),
NoLookupLocation.FROM_BACKEND
).filter { it.containingDeclaration !is BuiltInsPackageFragment && it.extensionReceiverParameter != null }
.map { Pair(it.extensionReceiverParameter!!.type, symbolTable.referenceSimpleFunction(it)) }.toMap()
.map {
val klass = symbolTable.referenceClassifier(it.extensionReceiverParameter!!.type.constructor.declarationDescriptor!!)
val function = symbolTable.referenceSimpleFunction(it)
klass to function
}.toMap()
val any = symbolTable.referenceClass(builtIns.any)
val unit = symbolTable.referenceClass(builtIns.unit)
@@ -201,7 +201,7 @@ internal class UIntProgressionType(symbols: Symbols<CommonBackendContext>) :
// Uses `getProgressionLastElement(UInt, UInt, Int): UInt`
getProgressionLastElementFunction = symbols.getProgressionLastElementByReturnType[symbols.uInt!!],
unsignedType = symbols.uInt!!.defaultType,
unsignedConversionFunction = symbols.toUIntByExtensionReceiver.getValue(symbols.int.defaultType.toKotlinType())
unsignedConversionFunction = symbols.toUIntByExtensionReceiver.getValue(symbols.int)
) {
override fun DeclarationIrBuilder.minValueExpression() = irInt(UInt.MIN_VALUE.toInt())
@@ -219,7 +219,7 @@ internal class ULongProgressionType(symbols: Symbols<CommonBackendContext>) :
// Uses `getProgressionLastElement(ULong, ULong, Long): ULong`
getProgressionLastElementFunction = symbols.getProgressionLastElementByReturnType[symbols.uLong!!],
unsignedType = symbols.uLong!!.defaultType,
unsignedConversionFunction = symbols.toULongByExtensionReceiver.getValue(symbols.long.defaultType.toKotlinType())
unsignedConversionFunction = symbols.toULongByExtensionReceiver.getValue(symbols.long)
) {
override fun DeclarationIrBuilder.minValueExpression() = irLong(ULong.MIN_VALUE.toLong())