[K2] Avoid type check for Kotlin's property in ConstUtils
When we check Java field for constant initializer, we could be asked to get and check the type of Kotlin's property that is used in this Java field. But there is no guarantee that the type resolve phase was finished and this type is available. So we just check for `const` modifier and skip type check. #KT-63752 Fixed #KT-62558 Obsolete #KT-61786 Declined
This commit is contained in:
+6
@@ -23705,6 +23705,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/kt57802.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noConstKt12248.kt")
|
||||
public void testNoConstKt12248() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/noConstKt12248.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stdlibConstFun.kt")
|
||||
public void testStdlibConstFun() throws Exception {
|
||||
|
||||
+6
@@ -23705,6 +23705,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/kt57802.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noConstKt12248.kt")
|
||||
public void testNoConstKt12248() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/modifiers/const/noConstKt12248.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stdlibConstFun.kt")
|
||||
public void testStdlibConstFun() throws Exception {
|
||||
|
||||
+6
-1
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.light.classes.symbol.classes.SymbolLightClassBase
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.GranularModifiersBox
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.SymbolLightMemberModifierList
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.with
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.NotEvaluatedConstAware
|
||||
import org.jetbrains.kotlin.name.JvmStandardClassIds.TRANSIENT_ANNOTATION_CLASS_ID
|
||||
import org.jetbrains.kotlin.name.JvmStandardClassIds.VOLATILE_ANNOTATION_CLASS_ID
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
@@ -41,7 +42,7 @@ internal class SymbolLightFieldForProperty private constructor(
|
||||
private val isStatic: Boolean,
|
||||
override val kotlinOrigin: KtCallableDeclaration?,
|
||||
private val backingFieldSymbolPointer: KtSymbolPointer<KtBackingFieldSymbol>?,
|
||||
) : SymbolLightField(containingClass, lightMemberOrigin) {
|
||||
) : SymbolLightField(containingClass, lightMemberOrigin), NotEvaluatedConstAware {
|
||||
internal constructor(
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
propertySymbol: KtPropertySymbol,
|
||||
@@ -231,6 +232,10 @@ internal class SymbolLightFieldForProperty private constructor(
|
||||
|
||||
override fun computeConstantValue(): Any? = _constantValue
|
||||
|
||||
override fun isNotYetComputed(): Boolean {
|
||||
return withPropertySymbol { propertySymbol -> (propertySymbol as? KtKotlinPropertySymbol)?.isConst == true }
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is SymbolLightFieldForProperty || other.ktModule != ktModule || other.fieldName != fieldName) return false
|
||||
|
||||
Reference in New Issue
Block a user