IR: minor, don't store unnecessary fields
This commit is contained in:
+4
-1
@@ -12,10 +12,13 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|||||||
|
|
||||||
abstract class IrFunctionAccessExpression(
|
abstract class IrFunctionAccessExpression(
|
||||||
typeArgumentsCount: Int,
|
typeArgumentsCount: Int,
|
||||||
final override val valueArgumentsCount: Int,
|
valueArgumentsCount: Int,
|
||||||
) : IrMemberAccessExpression<IrFunctionSymbol>(typeArgumentsCount) {
|
) : IrMemberAccessExpression<IrFunctionSymbol>(typeArgumentsCount) {
|
||||||
private val argumentsByParameterIndex: Array<IrExpression?> = arrayOfNulls(valueArgumentsCount)
|
private val argumentsByParameterIndex: Array<IrExpression?> = arrayOfNulls(valueArgumentsCount)
|
||||||
|
|
||||||
|
final override val valueArgumentsCount: Int
|
||||||
|
get() = argumentsByParameterIndex.size
|
||||||
|
|
||||||
override fun getValueArgument(index: Int): IrExpression? {
|
override fun getValueArgument(index: Int): IrExpression? {
|
||||||
if (index >= valueArgumentsCount) {
|
if (index >= valueArgumentsCount) {
|
||||||
throw AssertionError("$this: No such value argument slot: $index")
|
throw AssertionError("$this: No such value argument slot: $index")
|
||||||
|
|||||||
+3
-3
@@ -20,9 +20,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
|||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
abstract class IrMemberAccessExpression<S : IrSymbol>(
|
abstract class IrMemberAccessExpression<S : IrSymbol>(typeArgumentsCount: Int) : IrDeclarationReference() {
|
||||||
val typeArgumentsCount: Int
|
|
||||||
) : IrDeclarationReference() {
|
|
||||||
var dispatchReceiver: IrExpression? = null
|
var dispatchReceiver: IrExpression? = null
|
||||||
var extensionReceiver: IrExpression? = null
|
var extensionReceiver: IrExpression? = null
|
||||||
|
|
||||||
@@ -37,6 +35,8 @@ abstract class IrMemberAccessExpression<S : IrSymbol>(
|
|||||||
|
|
||||||
private val typeArgumentsByIndex = arrayOfNulls<IrType>(typeArgumentsCount)
|
private val typeArgumentsByIndex = arrayOfNulls<IrType>(typeArgumentsCount)
|
||||||
|
|
||||||
|
val typeArgumentsCount: Int get() = typeArgumentsByIndex.size
|
||||||
|
|
||||||
fun getTypeArgument(index: Int): IrType? {
|
fun getTypeArgument(index: Int): IrType? {
|
||||||
if (index >= typeArgumentsCount) {
|
if (index >= typeArgumentsCount) {
|
||||||
throw AssertionError("$this: No such type argument slot: $index")
|
throw AssertionError("$this: No such type argument slot: $index")
|
||||||
|
|||||||
@@ -17,9 +17,11 @@ class IrSimpleTypeImpl(
|
|||||||
override val classifier: IrClassifierSymbol,
|
override val classifier: IrClassifierSymbol,
|
||||||
override val hasQuestionMark: Boolean,
|
override val hasQuestionMark: Boolean,
|
||||||
override val arguments: List<IrTypeArgument>,
|
override val arguments: List<IrTypeArgument>,
|
||||||
annotations: List<IrConstructorCall>,
|
override val annotations: List<IrConstructorCall>,
|
||||||
override val abbreviation: IrTypeAbbreviation? = null
|
override val abbreviation: IrTypeAbbreviation? = null
|
||||||
) : IrTypeBase(kotlinType, annotations, Variance.INVARIANT), IrSimpleType, IrTypeProjection {
|
) : IrTypeBase(kotlinType), IrSimpleType {
|
||||||
|
override val variance: Variance
|
||||||
|
get() = Variance.INVARIANT
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
classifier: IrClassifierSymbol,
|
classifier: IrClassifierSymbol,
|
||||||
|
|||||||
@@ -11,32 +11,28 @@ import org.jetbrains.kotlin.types.KotlinType
|
|||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||||
|
|
||||||
abstract class IrTypeBase(
|
abstract class IrTypeBase(val kotlinType: KotlinType?) : IrType, IrTypeProjection {
|
||||||
val kotlinType: KotlinType?,
|
|
||||||
override val annotations: List<IrConstructorCall>,
|
|
||||||
override val variance: Variance
|
|
||||||
) : IrType, IrTypeProjection {
|
|
||||||
override val type: IrType get() = this
|
override val type: IrType get() = this
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrErrorTypeImpl(
|
class IrErrorTypeImpl(
|
||||||
kotlinType: KotlinType?,
|
kotlinType: KotlinType?,
|
||||||
annotations: List<IrConstructorCall>,
|
override val annotations: List<IrConstructorCall>,
|
||||||
variance: Variance
|
override val variance: Variance,
|
||||||
) : IrTypeBase(kotlinType, annotations, variance), IrErrorType {
|
) : IrTypeBase(kotlinType), IrErrorType {
|
||||||
override fun equals(other: Any?): Boolean = other is IrErrorTypeImpl
|
override fun equals(other: Any?): Boolean = other is IrErrorTypeImpl
|
||||||
|
|
||||||
override fun hashCode(): Int = IrErrorTypeImpl::class.java.name.hashCode()
|
override fun hashCode(): Int = IrErrorTypeImpl::class.java.hashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrDynamicTypeImpl(
|
class IrDynamicTypeImpl(
|
||||||
kotlinType: KotlinType?,
|
kotlinType: KotlinType?,
|
||||||
annotations: List<IrConstructorCall>,
|
override val annotations: List<IrConstructorCall>,
|
||||||
variance: Variance
|
override val variance: Variance,
|
||||||
) : IrTypeBase(kotlinType, annotations, variance), IrDynamicType, IrTypeProjection {
|
) : IrTypeBase(kotlinType), IrDynamicType {
|
||||||
override fun equals(other: Any?): Boolean = other is IrDynamicTypeImpl
|
override fun equals(other: Any?): Boolean = other is IrDynamicTypeImpl
|
||||||
|
|
||||||
override fun hashCode(): Int = IrDynamicTypeImpl::class.java.name.hashCode()
|
override fun hashCode(): Int = IrDynamicTypeImpl::class.java.hashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user