diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/Ir.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/Ir.kt index fddf2a8cfb8..96f85e0e283 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/Ir.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/Ir.kt @@ -1,4 +1,4 @@ - /* +/* * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * that can be found in the license/LICENSE.txt file. */ @@ -12,14 +12,13 @@ import org.jetbrains.kotlin.builtins.UnsignedType import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies import org.jetbrains.kotlin.incremental.components.NoLookupLocation -import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.declarations.IrPackageFragment import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.types.classifierOrNull +import org.jetbrains.kotlin.ir.types.classOrNull import org.jetbrains.kotlin.ir.util.ReferenceSymbolTable import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable import org.jetbrains.kotlin.ir.util.getPackageFragment @@ -30,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.components.isVararg import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.util.OperatorNameConventions - // This is what Context collects about IR. +// This is what Context collects about IR. abstract class Ir(val context: T, val irModule: IrModuleFragment) { abstract val symbols: Symbols @@ -192,7 +191,7 @@ abstract class Symbols(val context: T, private val function.parent is IrPackageFragment && function.getPackageFragment()!!.fqName.asString() == "kotlin" && function.valueParameters.isEmpty() && - (symbol.owner.extensionReceiverParameter?.type?.classifierOrNull?.owner as? IrClass).let { receiverClass -> + symbol.owner.extensionReceiverParameter?.type?.classOrNull?.owner.let { receiverClass -> receiverClass?.fqNameWhenAvailable?.toUnsafe() == KotlinBuiltIns.FQ_NAMES.kProperty0 } } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt index f7728090912..afb8ba6dfb6 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol import org.jetbrains.kotlin.ir.symbols.IrValueSymbol -import org.jetbrains.kotlin.ir.types.classifierOrNull +import org.jetbrains.kotlin.ir.types.classOrNull import org.jetbrains.kotlin.ir.util.dump import org.jetbrains.kotlin.ir.util.parentAsClass import org.jetbrains.kotlin.ir.util.patchDeclarationParents @@ -39,7 +39,7 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass { // TODO: is this the correct way to get the class? // -1 means value is either IMPLICIT or EXTENSION receiver get() = if (this is IrValueParameterSymbol && owner.index == -1 && owner.name.isSpecial /* */) - owner.type.classifierOrNull?.owner as IrClass + owner.type.classOrNull?.owner else null diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt index f0f3dae7a16..c473198f060 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt @@ -54,7 +54,7 @@ fun IrType.isFunctionTypeOrSubtype(): Boolean = DFS.ifAny(listOf(this), { it.sup fun IrType.isTypeParameter() = classifierOrNull is IrTypeParameterSymbol -fun IrType.isInterface() = (classifierOrNull?.owner as? IrClass)?.kind == ClassKind.INTERFACE +fun IrType.isInterface() = classOrNull?.owner?.kind == ClassKind.INTERFACE fun IrType.isFunctionOrKFunction() = isFunction() || isKFunction() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt index 863b34b7f5d..2875cc30062 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt @@ -44,6 +44,9 @@ val IrType.classifierOrFail: IrClassifierSymbol val IrType.classifierOrNull: IrClassifierSymbol? get() = safeAs()?.classifier +val IrType.classOrNull: IrClassSymbol? + get() = classifierOrNull as? IrClassSymbol + fun IrType.makeNotNull() = if (this is IrSimpleType && this.hasQuestionMark) { IrSimpleTypeImpl( @@ -82,7 +85,7 @@ fun IrType.toKotlinType(): KotlinType { } fun IrType.getClass(): IrClass? = - (this.classifierOrNull as? IrClassSymbol)?.owner + classOrNull?.owner fun IrClassSymbol.createType(hasQuestionMark: Boolean, arguments: List): IrSimpleType = IrSimpleTypeImpl(