Don't save constant value for non-resolved array expression in K1
#KT-55912 Fixed
This commit is contained in:
+6
@@ -17063,6 +17063,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/evaluate/intrinsics.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt55912.kt")
|
||||
public void testKt55912() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/evaluate/kt55912.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt9443.kt")
|
||||
public void testKt9443() throws Exception {
|
||||
|
||||
+1
-13
@@ -19,10 +19,7 @@ import org.jetbrains.kotlin.resolve.calls.util.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.typeUtil.isNothing
|
||||
import org.jetbrains.kotlin.types.typeUtil.isTypeParameter
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections
|
||||
import org.jetbrains.kotlin.types.typeUtil.*
|
||||
|
||||
private val javaLangCloneable = FqNameUnsafe("java.lang.Cloneable")
|
||||
|
||||
@@ -193,15 +190,6 @@ object ValueClassDeclarationChecker : DeclarationChecker {
|
||||
private fun KotlinType.isInapplicableParameterType() =
|
||||
isUnit() || isNothing()
|
||||
|
||||
private fun KotlinType.isGenericArrayOfTypeParameter(): Boolean {
|
||||
if (!KotlinBuiltIns.isArray(this)) return false
|
||||
val argument0 = arguments[0]
|
||||
if (argument0.isStarProjection) return false
|
||||
val argument0type = argument0.type
|
||||
return argument0type.isTypeParameter() ||
|
||||
argument0type.isGenericArrayOfTypeParameter()
|
||||
}
|
||||
|
||||
private fun isParameterAcceptableForInlineClass(parameter: KtParameter): Boolean {
|
||||
val isOpen = parameter.modalityModifier()?.node?.elementType == KtTokens.OPEN_KEYWORD
|
||||
return parameter.hasValOrVar() && !parameter.isMutable && !parameter.isVarArg && !isOpen
|
||||
|
||||
+7
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||
import org.jetbrains.kotlin.types.isError
|
||||
import org.jetbrains.kotlin.types.typeUtil.isBoolean
|
||||
import org.jetbrains.kotlin.types.typeUtil.isGenericArrayOfTypeParameter
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import java.math.BigInteger
|
||||
@@ -408,6 +409,12 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
if (shouldSkipComplexBooleanValue(expression, compileTimeConstant)) {
|
||||
return null
|
||||
}
|
||||
|
||||
// If constant is `Array` and its argument is some generic type, then we must wait for full resolve and only when we can record value
|
||||
if (compileTimeConstant is TypedCompileTimeConstant && compileTimeConstant.type.isGenericArrayOfTypeParameter()) {
|
||||
return compileTimeConstant
|
||||
}
|
||||
|
||||
trace.record(BindingContext.COMPILE_TIME_VALUE, expression, compileTimeConstant)
|
||||
return compileTimeConstant
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
public annotation class Entity(val foreignKeys: Array<String>)
|
||||
|
||||
@Entity(foreignKeys = kotlin.arrayOf("id")) // works without "kotlin."
|
||||
class Record
|
||||
|
||||
fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -16757,6 +16757,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/evaluate/intrinsics.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt55912.kt")
|
||||
public void testKt55912() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/evaluate/kt55912.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt9443.kt")
|
||||
public void testKt9443() throws Exception {
|
||||
|
||||
+6
@@ -17063,6 +17063,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/evaluate/intrinsics.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt55912.kt")
|
||||
public void testKt55912() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/evaluate/kt55912.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt9443.kt")
|
||||
public void testKt9443() throws Exception {
|
||||
|
||||
+5
@@ -13830,6 +13830,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/evaluate/intrinsics.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt55912.kt")
|
||||
public void testKt55912() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/evaluate/kt55912.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt9443.kt")
|
||||
public void testKt9443() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/evaluate/kt9443.kt");
|
||||
|
||||
Reference in New Issue
Block a user