[FIR2IR] Get rid of all usages of IrSymbol.owner from DataClassMembersGenerator

This change uncovered the following problem in pipeline: we have a contract,
  that all bodies will be generated after all fake overrides will be preprocessed.
  But DataClassMembersGenerator generates bodies before f/o creation,
  which leads to the problem, if data class has forward reference to some
  class which was not processed before (because in this case generator
  of `hashCode` function will try to reference f/o, which is not created yet,
  which leads to `SymbolAlreadyBound` problem)

```
data class Some(val a: A) {
    generated fun hashCode(): Int {
        return a.hashCode() // (1) is not generated yet
    }
}

class A {
    fake-override fun hashCode(): Int // (1)
}
```

This problem will be fixed in the next commit

(related test is compiler/testData/codegen/box/ir/kt52677.kt)

^KT-60924
This commit is contained in:
Dmitriy Novozhilov
2023-08-18 15:30:49 +03:00
committed by Space Team
parent b38de13696
commit 76d3c0e804
6 changed files with 111 additions and 56 deletions
@@ -272,6 +272,10 @@ class AnnotationImplementationMemberGenerator(
return irCallOp(context.irBuiltIns.intXorSymbol, context.irBuiltIns.intType, multiplied, propertyValueHashCode)
}
private fun IrBuilderWithScope.getHashCodeOf(type: IrType, irValue: IrExpression): IrExpression {
return getHashCodeOf(getHashCodeFunctionInfo(type), irValue)
}
// Manual implementation of equals is required for following reasons:
// 1. `other` should be casted to interface instead of implementation
// 2. Properties should be retrieved using getters without accessing backing fields