K2: Approximate ILT in vararg expressions properly #KT-57487 Fixed
This commit is contained in:
committed by
Space Team
parent
dead2c8be8
commit
70c5978add
+6
@@ -2863,6 +2863,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI
|
||||
public void testVarInInit() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarInInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("VarargIntegerLiteral.kt")
|
||||
public void testVarargIntegerLiteral() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarargIntegerLiteral.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java
Generated
+6
@@ -2863,6 +2863,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest {
|
||||
public void testVarInInit() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarInInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("VarargIntegerLiteral.kt")
|
||||
public void testVarargIntegerLiteral() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarargIntegerLiteral.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+1
-3
@@ -16,10 +16,8 @@ import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildVarargArgumentsExpression
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.types.ConstantValueKind
|
||||
@@ -39,7 +37,7 @@ internal fun remapArgumentsWithVararg(
|
||||
// The order of arguments in the mapping must be preserved for FIR2IR, hence we have to find where the vararg arguments end.
|
||||
// FIR2IR uses the mapping order to determine if arguments need to be reordered.
|
||||
val varargParameterTypeRef = varargParameter.returnTypeRef
|
||||
val varargElementType = varargArrayType.arrayElementType()
|
||||
val varargElementType = varargArrayType.arrayElementType()?.approximateIntegerLiteralType()
|
||||
val argumentList = argumentMapping.keys.toList()
|
||||
var indexAfterVarargs = argumentList.size
|
||||
val newArgumentMapping = linkedMapOf<FirExpression, FirValueParameter>()
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// KT-57487: Stdlib ArraysTest fails with `Class found but error nodes are not allowed`
|
||||
// IGNORE_BACKEND_K2: NATIVE, JS_IR
|
||||
|
||||
// Minimized from libraries.stdlib.test.collections.ArraysTest.sortedTests()
|
||||
// Exception is: Class found but error nodes are not allowed
|
||||
fun <T: Comparable<T>> arrayData(vararg values: T, toArray: Array<T>.() -> Unit) {}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
FILE fqName:<root> fileName:/VarargIntegerLiteral.kt
|
||||
FUN name:arrayData visibility:public modality:FINAL <T> (values:kotlin.Array<out T of <root>.arrayData>, toArray:@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<T of <root>.arrayData>, kotlin.Unit>) returnType:kotlin.Unit
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Comparable<T of <root>.arrayData>] reified:false
|
||||
VALUE_PARAMETER name:values index:0 type:kotlin.Array<out T of <root>.arrayData> varargElementType:T of <root>.arrayData [vararg]
|
||||
VALUE_PARAMETER name:toArray index:1 type:@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<T of <root>.arrayData>, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
FUN name:arrayLongInheritedData visibility:public modality:FINAL <T> (values:kotlin.Array<out T of <root>.arrayLongInheritedData>, toArray:@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<T of <root>.arrayLongInheritedData>, kotlin.Unit>) returnType:kotlin.Unit
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Long] reified:false
|
||||
VALUE_PARAMETER name:values index:0 type:kotlin.Array<out T of <root>.arrayLongInheritedData> varargElementType:T of <root>.arrayLongInheritedData [vararg]
|
||||
VALUE_PARAMETER name:toArray index:1 type:@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<T of <root>.arrayLongInheritedData>, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
FUN name:longArrayData visibility:public modality:FINAL <> (values:kotlin.LongArray, toArray:@[ExtensionFunctionType] kotlin.Function1<kotlin.LongArray, kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:values index:0 type:kotlin.LongArray varargElementType:kotlin.Long [vararg]
|
||||
VALUE_PARAMETER name:toArray index:1 type:@[ExtensionFunctionType] kotlin.Function1<kotlin.LongArray, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
FUN name:shortArrayData visibility:public modality:FINAL <> (values:kotlin.ShortArray, toArray:@[ExtensionFunctionType] kotlin.Function1<kotlin.ShortArray, kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:values index:0 type:kotlin.ShortArray varargElementType:kotlin.Short [vararg]
|
||||
VALUE_PARAMETER name:toArray index:1 type:@[ExtensionFunctionType] kotlin.Function1<kotlin.ShortArray, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
FUN name:arrayOfLongData visibility:public modality:FINAL <> (values:kotlin.LongArray, toArray:@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<kotlin.Long>, kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:values index:0 type:kotlin.LongArray varargElementType:kotlin.Long [vararg]
|
||||
VALUE_PARAMETER name:toArray index:1 type:@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<kotlin.Long>, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
FUN name:arrayOfShortData visibility:public modality:FINAL <> (values:kotlin.ShortArray, toArray:@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<kotlin.Short>, kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:values index:0 type:kotlin.ShortArray varargElementType:kotlin.Short [vararg]
|
||||
VALUE_PARAMETER name:toArray index:1 type:@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<kotlin.Short>, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun arrayData <T> (vararg values: T of <root>.arrayData, toArray: @[ExtensionFunctionType] kotlin.Function1<kotlin.Array<T of <root>.arrayData>, kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
<T>: kotlin.Int
|
||||
values: VARARG type=kotlin.Array<out kotlin.Int> varargElementType=kotlin.Int
|
||||
CONST Int type=kotlin.Int value=42
|
||||
toArray: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<kotlin.Int>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.Array<kotlin.Int>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:$this$arrayData type:kotlin.Array<kotlin.Int>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.box'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
CALL 'public final fun arrayLongInheritedData <T> (vararg values: T of <root>.arrayLongInheritedData, toArray: @[ExtensionFunctionType] kotlin.Function1<kotlin.Array<T of <root>.arrayLongInheritedData>, kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
<T>: kotlin.Long
|
||||
values: VARARG type=kotlin.Array<out kotlin.Long> varargElementType=kotlin.Long
|
||||
CONST Long type=kotlin.Long value=42
|
||||
toArray: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<kotlin.Long>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.Array<kotlin.Long>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:$this$arrayLongInheritedData type:kotlin.Array<kotlin.Long>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.box'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
CALL 'public final fun longArrayData (vararg values: kotlin.Long, toArray: @[ExtensionFunctionType] kotlin.Function1<kotlin.LongArray, kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
values: VARARG type=kotlin.LongArray varargElementType=kotlin.Long
|
||||
CONST Long type=kotlin.Long value=42
|
||||
toArray: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<kotlin.LongArray, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.LongArray) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:$this$longArrayData type:kotlin.LongArray
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.box'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
CALL 'public final fun shortArrayData (vararg values: kotlin.Short, toArray: @[ExtensionFunctionType] kotlin.Function1<kotlin.ShortArray, kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
values: VARARG type=kotlin.ShortArray varargElementType=kotlin.Short
|
||||
CONST Short type=kotlin.Short value=42
|
||||
toArray: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<kotlin.ShortArray, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.ShortArray) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:$this$shortArrayData type:kotlin.ShortArray
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.box'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
CALL 'public final fun arrayOfLongData (vararg values: kotlin.Long, toArray: @[ExtensionFunctionType] kotlin.Function1<kotlin.Array<kotlin.Long>, kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
values: VARARG type=kotlin.LongArray varargElementType=kotlin.Long
|
||||
CONST Long type=kotlin.Long value=42
|
||||
toArray: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<kotlin.Long>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.Array<kotlin.Long>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:$this$arrayOfLongData type:kotlin.Array<kotlin.Long>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.box'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
CALL 'public final fun arrayOfShortData (vararg values: kotlin.Short, toArray: @[ExtensionFunctionType] kotlin.Function1<kotlin.Array<kotlin.Short>, kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
values: VARARG type=kotlin.ShortArray varargElementType=kotlin.Short
|
||||
CONST Short type=kotlin.Short value=42
|
||||
toArray: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<kotlin.Array<kotlin.Short>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.Array<kotlin.Short>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:$this$arrayOfShortData type:kotlin.Array<kotlin.Short>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.box'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="OK"
|
||||
@@ -0,0 +1,22 @@
|
||||
// FIR_IDENTICAL
|
||||
fun <T: Comparable<T>> arrayData(vararg values: T, toArray: Array<T>.() -> Unit) {}
|
||||
|
||||
fun <T : Long> arrayLongInheritedData(vararg values: T, toArray: Array<T>.() -> Unit) {}
|
||||
|
||||
fun longArrayData(vararg values: Long, toArray: LongArray.() -> Unit) {}
|
||||
|
||||
fun shortArrayData(vararg values: Short, toArray: ShortArray.() -> Unit) {}
|
||||
|
||||
fun arrayOfLongData(vararg values: Long, toArray: Array<Long>.() -> Unit) {}
|
||||
|
||||
fun arrayOfShortData(vararg values: Short, toArray: Array<Short>.() -> Unit) {}
|
||||
|
||||
fun box(): String {
|
||||
arrayData(42) { }
|
||||
arrayLongInheritedData(42) { }
|
||||
longArrayData(42) { }
|
||||
shortArrayData(42) { }
|
||||
arrayOfLongData(42) { }
|
||||
arrayOfShortData(42) { }
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
fun <T : Comparable<T>> arrayData(vararg values: T, toArray: @ExtensionFunctionType Function1<Array<T>, Unit>) {
|
||||
}
|
||||
|
||||
fun <T : Long> arrayLongInheritedData(vararg values: T, toArray: @ExtensionFunctionType Function1<Array<T>, Unit>) {
|
||||
}
|
||||
|
||||
fun longArrayData(vararg values: Long, toArray: @ExtensionFunctionType Function1<LongArray, Unit>) {
|
||||
}
|
||||
|
||||
fun shortArrayData(vararg values: Short, toArray: @ExtensionFunctionType Function1<ShortArray, Unit>) {
|
||||
}
|
||||
|
||||
fun arrayOfLongData(vararg values: Long, toArray: @ExtensionFunctionType Function1<Array<Long>, Unit>) {
|
||||
}
|
||||
|
||||
fun arrayOfShortData(vararg values: Short, toArray: @ExtensionFunctionType Function1<Array<Short>, Unit>) {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
arrayData<Int>(values = [42], toArray = local fun Array<Int>.<anonymous>() {
|
||||
return Unit
|
||||
}
|
||||
)
|
||||
arrayLongInheritedData<Long>(values = [42L], toArray = local fun Array<Long>.<anonymous>() {
|
||||
return Unit
|
||||
}
|
||||
)
|
||||
longArrayData(values = [42L], toArray = local fun LongArray.<anonymous>() {
|
||||
return Unit
|
||||
}
|
||||
)
|
||||
shortArrayData(values = [42S], toArray = local fun ShortArray.<anonymous>() {
|
||||
return Unit
|
||||
}
|
||||
)
|
||||
arrayOfLongData(values = [42L], toArray = local fun Array<Long>.<anonymous>() {
|
||||
return Unit
|
||||
}
|
||||
)
|
||||
arrayOfShortData(values = [42S], toArray = local fun Array<Short>.<anonymous>() {
|
||||
return Unit
|
||||
}
|
||||
)
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -2863,6 +2863,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest
|
||||
public void testVarInInit() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarInInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("VarargIntegerLiteral.kt")
|
||||
public void testVarargIntegerLiteral() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarargIntegerLiteral.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+5
@@ -2024,6 +2024,11 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase {
|
||||
public void testVarInInit() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarInInit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("VarargIntegerLiteral.kt")
|
||||
public void testVarargIntegerLiteral() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarargIntegerLiteral.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/ir/irText/js")
|
||||
|
||||
Generated
+6
@@ -2323,6 +2323,12 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT
|
||||
public void testVarInInit() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarInInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("VarargIntegerLiteral.kt")
|
||||
public void testVarargIntegerLiteral() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarargIntegerLiteral.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -2323,6 +2323,12 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest {
|
||||
public void testVarInInit() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarInInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("VarargIntegerLiteral.kt")
|
||||
public void testVarargIntegerLiteral() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarargIntegerLiteral.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -2323,6 +2323,12 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest {
|
||||
public void testVarInInit() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarInInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("VarargIntegerLiteral.kt")
|
||||
public void testVarargIntegerLiteral() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/VarargIntegerLiteral.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user