JVM_IR KT-47073 use type parameter upper bound for default value
This commit is contained in:
committed by
TeamCityServer
parent
e4b723fe4a
commit
7fd033adae
+12
@@ -12550,6 +12550,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt46189.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47073.kt")
|
||||
public void testKt47073() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47073_nested.kt")
|
||||
public void testKt47073_nested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073_nested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt6382.kt")
|
||||
public void testKt6382() throws Exception {
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmSymbols
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isInlineOnly
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isJvmInterface
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.representativeUpperBound
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.unboxInlineClass
|
||||
import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX
|
||||
import org.jetbrains.kotlin.config.JvmDefaultMode
|
||||
@@ -123,6 +124,11 @@ val IrType.erasedUpperBound: IrClass
|
||||
* the value is not reboxed and reunboxed by the codegen by using the unsafeCoerceIntrinsic.
|
||||
*/
|
||||
fun IrType.defaultValue(startOffset: Int, endOffset: Int, context: JvmBackendContext): IrExpression {
|
||||
val classifier = this.classifierOrNull
|
||||
if (classifier is IrTypeParameterSymbol) {
|
||||
return classifier.owner.representativeUpperBound.defaultValue(startOffset, endOffset, context)
|
||||
}
|
||||
|
||||
if (this !is IrSimpleType || hasQuestionMark || classOrNull?.owner?.isInline != true)
|
||||
return IrConstImpl.defaultValueForType(startOffset, endOffset, this)
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
class Test<T: Char>(val k: T) {
|
||||
fun test(x: T = k): String {
|
||||
return "O$x"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Test('K').test()
|
||||
@@ -0,0 +1,12 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
class Test<T: Char>(val k: T) {
|
||||
fun test(): String {
|
||||
fun nested(x: T = k): String {
|
||||
return "O$x"
|
||||
}
|
||||
return nested()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Test('K').test()
|
||||
+12
@@ -12550,6 +12550,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt46189.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47073.kt")
|
||||
public void testKt47073() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47073_nested.kt")
|
||||
public void testKt47073_nested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073_nested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt6382.kt")
|
||||
public void testKt6382() throws Exception {
|
||||
|
||||
+12
@@ -12550,6 +12550,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt46189.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47073.kt")
|
||||
public void testKt47073() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47073_nested.kt")
|
||||
public void testKt47073_nested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073_nested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt6382.kt")
|
||||
public void testKt6382() throws Exception {
|
||||
|
||||
+10
@@ -10149,6 +10149,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt46189.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47073.kt")
|
||||
public void testKt47073() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47073_nested.kt")
|
||||
public void testKt47073_nested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073_nested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6382.kt")
|
||||
public void testKt6382() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt6382.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+10
@@ -9028,6 +9028,16 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt46189.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47073.kt")
|
||||
public void testKt47073() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47073_nested.kt")
|
||||
public void testKt47073_nested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073_nested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6382.kt")
|
||||
public void testKt6382() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt6382.kt");
|
||||
|
||||
Generated
+10
@@ -8434,6 +8434,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt46189.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47073.kt")
|
||||
public void testKt47073() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47073_nested.kt")
|
||||
public void testKt47073_nested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073_nested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6382.kt")
|
||||
public void testKt6382() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt6382.kt");
|
||||
|
||||
Generated
+10
@@ -8434,6 +8434,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt46189.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47073.kt")
|
||||
public void testKt47073() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47073_nested.kt")
|
||||
public void testKt47073_nested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073_nested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6382.kt")
|
||||
public void testKt6382() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt6382.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+10
@@ -3989,6 +3989,16 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt46189.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47073.kt")
|
||||
public void testKt47073() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47073_nested.kt")
|
||||
public void testKt47073_nested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt47073_nested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6382.kt")
|
||||
public void testKt6382() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/defaultArguments/kt6382.kt");
|
||||
|
||||
Reference in New Issue
Block a user