IR: Introduce IrClassifierSymbol.defaultType

This commit is contained in:
Steven Schäfer
2019-11-15 18:14:05 +01:00
committed by Alexander Udalov
parent 3d7d1022e4
commit 85b36dcd88
12 changed files with 39 additions and 33 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -10,7 +10,9 @@ import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.impl.*
import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.types.typeUtil.makeNullable
@@ -96,6 +98,13 @@ private fun makeKotlinType(
return classifier.descriptor.defaultType.replace(newArguments = kotlinTypeArguments).makeNullableAsSpecified(hasQuestionMark)
}
val IrClassifierSymbol.defaultType: IrType
get() = when (this) {
is IrClassSymbol -> owner.defaultType
is IrTypeParameterSymbol -> owner.defaultType
else -> error("Unexpected classifier symbol type $this")
}
val IrTypeParameter.defaultType: IrType
get() = IrSimpleTypeImpl(
symbol,