[NI] Add regression tests for builder inference
Actual fix is c02dd720
^KT-33542 Fixed
^KT-33544 Fixed
^KT-36446 Fixed
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
// Issues: KT-33542, KT-33544
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// KJS_WITH_FULL_RUNTIME
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
|
||||||
|
import kotlin.experimental.ExperimentalTypeInference
|
||||||
|
|
||||||
|
interface In<in E> {
|
||||||
|
suspend fun send(element: E)
|
||||||
|
}
|
||||||
|
|
||||||
|
class InImpl<E>(val block: suspend In<E>.() -> Unit) : In<E> {
|
||||||
|
override suspend fun send(element: E) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalTypeInference::class)
|
||||||
|
public fun <T> builder(@BuilderInference block: suspend In<T>.() -> Unit) {
|
||||||
|
InImpl(block)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test33542() {
|
||||||
|
builder {
|
||||||
|
send(run {
|
||||||
|
15
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test33544(){
|
||||||
|
builder {
|
||||||
|
send(run {
|
||||||
|
let { 0 } ?: 1
|
||||||
|
0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = "OK"
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// KJS_WITH_FULL_RUNTIME
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// WITH_REFLECT
|
||||||
|
|
||||||
|
import kotlin.experimental.ExperimentalTypeInference
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
definition<Transaction> {
|
||||||
|
conversion<Unit> {
|
||||||
|
val offset by argument<Int> {
|
||||||
|
// UnsupportedOperationException: no descriptor for type constructor of IntegerLiteralType[Int,Long,Byte,Short]
|
||||||
|
defaultInt(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Transaction
|
||||||
|
fun <Transaction> definition(configure: DefinitionBuilder<Transaction>.() -> Unit): Unit {}
|
||||||
|
class ArgumentBuilder<Value> {
|
||||||
|
fun defaultInt(default: Int): Unit {}
|
||||||
|
}
|
||||||
|
class ConversionBuilder<Value> {
|
||||||
|
fun <ArgumentValue> argument(
|
||||||
|
configure: ArgumentBuilder<ArgumentValue>.() -> Unit
|
||||||
|
): ArgumentDefinition<ArgumentValue> = null as ArgumentDefinition<ArgumentValue>
|
||||||
|
}
|
||||||
|
class DefinitionBuilder<Transaction> {
|
||||||
|
@OptIn(ExperimentalTypeInference::class)
|
||||||
|
fun <Value> conversion(@BuilderInference configure: ConversionBuilder<Value>.() -> Unit): Unit {}
|
||||||
|
}
|
||||||
|
interface ArgumentDefinition<Value> {
|
||||||
|
operator fun provideDelegate(thisRef: Any?, property: KProperty<*>): ArgumentReference<Value>
|
||||||
|
}
|
||||||
|
interface ArgumentReference<out Value> {
|
||||||
|
operator fun getValue(thisRef: Any?, property: KProperty<*>): Value
|
||||||
|
}
|
||||||
+10
@@ -12702,6 +12702,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("builderInferenceLeakingVariable.kt")
|
||||||
|
public void testBuilderInferenceLeakingVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/builderInferenceLeakingVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("capturedStarProjection.kt")
|
@TestMetadata("capturedStarProjection.kt")
|
||||||
public void testCapturedStarProjection() throws Exception {
|
public void testCapturedStarProjection() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
||||||
@@ -12732,6 +12737,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36446.kt")
|
||||||
|
public void testKt36446() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/kt36446.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
||||||
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
||||||
|
|||||||
+10
@@ -12702,6 +12702,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("builderInferenceLeakingVariable.kt")
|
||||||
|
public void testBuilderInferenceLeakingVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/builderInferenceLeakingVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("capturedStarProjection.kt")
|
@TestMetadata("capturedStarProjection.kt")
|
||||||
public void testCapturedStarProjection() throws Exception {
|
public void testCapturedStarProjection() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
||||||
@@ -12732,6 +12737,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36446.kt")
|
||||||
|
public void testKt36446() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/kt36446.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
||||||
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
||||||
|
|||||||
+10
@@ -11577,6 +11577,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("builderInferenceLeakingVariable.kt")
|
||||||
|
public void testBuilderInferenceLeakingVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/builderInferenceLeakingVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("capturedStarProjection.kt")
|
@TestMetadata("capturedStarProjection.kt")
|
||||||
public void testCapturedStarProjection() throws Exception {
|
public void testCapturedStarProjection() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
||||||
@@ -11607,6 +11612,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36446.kt")
|
||||||
|
public void testKt36446() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/kt36446.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
||||||
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
||||||
|
|||||||
+10
@@ -11577,6 +11577,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
runTest("compiler/testData/codegen/box/inference/builderInference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("builderInferenceLeakingVariable.kt")
|
||||||
|
public void testBuilderInferenceLeakingVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/builderInferenceLeakingVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("capturedStarProjection.kt")
|
@TestMetadata("capturedStarProjection.kt")
|
||||||
public void testCapturedStarProjection() throws Exception {
|
public void testCapturedStarProjection() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
||||||
@@ -11607,6 +11612,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36446.kt")
|
||||||
|
public void testKt36446() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/kt36446.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
||||||
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
||||||
|
|||||||
Generated
+10
@@ -9947,6 +9947,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("builderInferenceLeakingVariable.kt")
|
||||||
|
public void testBuilderInferenceLeakingVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/builderInferenceLeakingVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("capturedStarProjection.kt")
|
@TestMetadata("capturedStarProjection.kt")
|
||||||
public void testCapturedStarProjection() throws Exception {
|
public void testCapturedStarProjection() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
||||||
@@ -9972,6 +9977,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36446.kt")
|
||||||
|
public void testKt36446() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/kt36446.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
||||||
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
||||||
|
|||||||
+10
@@ -10012,6 +10012,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("builderInferenceLeakingVariable.kt")
|
||||||
|
public void testBuilderInferenceLeakingVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/builderInferenceLeakingVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("capturedStarProjection.kt")
|
@TestMetadata("capturedStarProjection.kt")
|
||||||
public void testCapturedStarProjection() throws Exception {
|
public void testCapturedStarProjection() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
runTest("compiler/testData/codegen/box/inference/capturedStarProjection.kt");
|
||||||
@@ -10037,6 +10042,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
runTest("compiler/testData/codegen/box/inference/kt35684.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36446.kt")
|
||||||
|
public void testKt36446() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/kt36446.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
@TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt")
|
||||||
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user