FIR2IR: calculate IR parent for Java field ahead

so as to cache type parameters from the parent if the field's return
type is one of type parameters.

#KT-44032 Fixed
This commit is contained in:
Jinseong Jeon
2020-12-22 12:31:17 -08:00
committed by Mikhail Glukhikh
parent 89577543a2
commit 73576c80e4
8 changed files with 92 additions and 2 deletions
@@ -1168,8 +1168,12 @@ class Fir2IrDeclarationStorage(
fun getIrFieldSymbol(firFieldSymbol: FirFieldSymbol): IrSymbol {
val fir = firFieldSymbol.fir
val irProperty = fieldCache[fir] ?: createIrField(fir).apply {
setAndModifyParent(findIrParent(fir))
val irProperty = fieldCache[fir] ?: run {
// In case of type parameters from the parent as the field's return type, find the parent ahead to cache type parameters.
val irParent = findIrParent(fir)
createIrField(fir).apply {
setAndModifyParent(irParent)
}
}
return irProperty.symbol
}
@@ -1873,6 +1873,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/firProblems/throwableStackTrace.kt");
}
@TestMetadata("typeParameterFromJavaClass.kt")
public void testTypeParameterFromJavaClass() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.kt");
}
@TestMetadata("typeVariableAfterBuildMap.kt")
public void testTypeVariableAfterBuildMap() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.kt");