[FIR2IR] Don't access symbol.owner in DataClassMembersGenerator
This commit is contained in:
committed by
Space Team
parent
50f1ea79c5
commit
da531bc261
+8
-5
@@ -109,7 +109,10 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
|||||||
}
|
}
|
||||||
} ?: error("Property for parameter $irValueParameter")
|
} ?: error("Property for parameter $irValueParameter")
|
||||||
|
|
||||||
inner class Fir2IrHashCodeFunctionInfo(override val symbol: IrSimpleFunctionSymbol) : HashCodeFunctionInfo {
|
inner class Fir2IrHashCodeFunctionInfo(
|
||||||
|
override val symbol: IrSimpleFunctionSymbol,
|
||||||
|
override val hasDispatchReceiver: Boolean,
|
||||||
|
) : HashCodeFunctionInfo {
|
||||||
override fun commitSubstituted(irMemberAccessExpression: IrMemberAccessExpression<*>) {
|
override fun commitSubstituted(irMemberAccessExpression: IrMemberAccessExpression<*>) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@@ -158,8 +161,8 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
|||||||
.first { (it as FirPropertySymbol).fromPrimaryConstructor } as FirPropertySymbol
|
.first { (it as FirPropertySymbol).fromPrimaryConstructor } as FirPropertySymbol
|
||||||
|
|
||||||
val type = firProperty.resolvedReturnType.fullyExpandedType(session)
|
val type = firProperty.resolvedReturnType.fullyExpandedType(session)
|
||||||
val symbol = when {
|
val (symbol, hasDispatchReceiver) = when {
|
||||||
type.isArrayOrPrimitiveArray(checkUnsignedArrays = false) -> context.irBuiltIns.dataClassArrayMemberHashCodeSymbol
|
type.isArrayOrPrimitiveArray(checkUnsignedArrays = false) -> context.irBuiltIns.dataClassArrayMemberHashCodeSymbol to false
|
||||||
else -> {
|
else -> {
|
||||||
val classForType = when (val classifier = type.coerceToAny().toSymbol(session)?.fir) {
|
val classForType = when (val classifier = type.coerceToAny().toSymbol(session)?.fir) {
|
||||||
is FirRegularClass -> classifier
|
is FirRegularClass -> classifier
|
||||||
@@ -168,10 +171,10 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
|||||||
}
|
}
|
||||||
val firHashCode = getHashCodeFunction(classForType)
|
val firHashCode = getHashCodeFunction(classForType)
|
||||||
val lookupTag = classForType.symbol.toLookupTag()
|
val lookupTag = classForType.symbol.toLookupTag()
|
||||||
declarationStorage.getIrFunctionSymbol(firHashCode, lookupTag) as IrSimpleFunctionSymbol
|
declarationStorage.getIrFunctionSymbol(firHashCode, lookupTag) as IrSimpleFunctionSymbol to (firHashCode.dispatchReceiverType != null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Fir2IrHashCodeFunctionInfo(symbol)
|
return Fir2IrHashCodeFunctionInfo(symbol, hasDispatchReceiver)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ abstract class DataClassMembersGenerator(
|
|||||||
|
|
||||||
protected fun IrBuilderWithScope.getHashCodeOf(hashCodeFunctionInfo: HashCodeFunctionInfo, irValue: IrExpression): IrExpression {
|
protected fun IrBuilderWithScope.getHashCodeOf(hashCodeFunctionInfo: HashCodeFunctionInfo, irValue: IrExpression): IrExpression {
|
||||||
val hashCodeFunctionSymbol = hashCodeFunctionInfo.symbol
|
val hashCodeFunctionSymbol = hashCodeFunctionInfo.symbol
|
||||||
val hasDispatchReceiver = hashCodeFunctionSymbol.hasDispatchReceiver()
|
val hasDispatchReceiver = hashCodeFunctionInfo.hasDispatchReceiver ?: hashCodeFunctionSymbol.hasDispatchReceiver()
|
||||||
return irCall(
|
return irCall(
|
||||||
hashCodeFunctionSymbol,
|
hashCodeFunctionSymbol,
|
||||||
context.irBuiltIns.intType,
|
context.irBuiltIns.intType,
|
||||||
@@ -263,6 +263,13 @@ abstract class DataClassMembersGenerator(
|
|||||||
|
|
||||||
interface HashCodeFunctionInfo {
|
interface HashCodeFunctionInfo {
|
||||||
val symbol: IrSimpleFunctionSymbol
|
val symbol: IrSimpleFunctionSymbol
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement it if [symbol] may be unbound
|
||||||
|
*/
|
||||||
|
val hasDispatchReceiver: Boolean?
|
||||||
|
get() = null
|
||||||
|
|
||||||
fun commitSubstituted(irMemberAccessExpression: IrMemberAccessExpression<*>)
|
fun commitSubstituted(irMemberAccessExpression: IrMemberAccessExpression<*>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user