[Tests] Add a test with type parameter as a context receiver
This commit is contained in:
committed by
TeamCityServer
parent
752bc299f1
commit
a70036c945
+6
@@ -10726,6 +10726,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterAsContextReceiver.kt")
|
||||
public void testTypeParameterAsContextReceiver() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterAsContextReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterized.kt")
|
||||
public void testTypeParameterized() throws Exception {
|
||||
|
||||
+6
@@ -10726,6 +10726,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterAsContextReceiver.kt")
|
||||
public void testTypeParameterAsContextReceiver() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterAsContextReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterized.kt")
|
||||
public void testTypeParameterized() throws Exception {
|
||||
|
||||
+6
@@ -10726,6 +10726,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterAsContextReceiver.kt")
|
||||
public void testTypeParameterAsContextReceiver() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterAsContextReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterized.kt")
|
||||
public void testTypeParameterized() throws Exception {
|
||||
|
||||
Generated
+6
@@ -865,6 +865,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
runTest("compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterAsContextReceiver.kt")
|
||||
public void testTypeParameterAsContextReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unaryOperators.kt")
|
||||
public void testUnaryOperators() throws Exception {
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
context(T)
|
||||
fun <T> useContext(block: (T) -> Unit) { }
|
||||
|
||||
fun test() {
|
||||
with(42) {
|
||||
useContext { i: Int -> i.toDouble() }
|
||||
}
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
context(T)
|
||||
fun <T> useContext(block: (T) -> Unit) { }
|
||||
|
||||
fun test() {
|
||||
with(42) {
|
||||
useContext { i: Int -> i.toDouble() }
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
public fun </*0*/ T> useContext(/*0*/ block: (T) -> kotlin.Unit): kotlin.Unit
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
FILE fqName:<root> fileName:/typeParameterAsContextReceiver.kt
|
||||
FUN name:useContext visibility:public modality:FINAL <T> (<this>:T of <root>.useContext, block:kotlin.Function1<T of <root>.useContext, kotlin.Unit>) returnType:kotlin.Unit
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
contextReceiverParametersCount: 1
|
||||
VALUE_PARAMETER name:<this> index:0 type:T of <root>.useContext
|
||||
VALUE_PARAMETER name:block index:1 type:kotlin.Function1<T of <root>.useContext, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun with <T, R> (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.StandardKt.with, R of kotlin.StandardKt.with>): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null
|
||||
<T>: kotlin.Int
|
||||
<R>: kotlin.Unit
|
||||
receiver: CONST Int type=kotlin.Int value=42
|
||||
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<kotlin.Int, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun useContext <T> (<this>: T of <root>.useContext, block: kotlin.Function1<T of <root>.useContext, kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
<T>: kotlin.Int
|
||||
<this>: GET_VAR '$this$with: kotlin.Int declared in <root>.test.<anonymous>' type=kotlin.Int origin=null
|
||||
block: FUN_EXPR type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (i:kotlin.Int) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:i index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public open fun toDouble (): kotlin.Double declared in kotlin.Int' type=kotlin.Double origin=null
|
||||
$this: GET_VAR 'i: kotlin.Int declared in <root>.test.<anonymous>.<anonymous>' type=kotlin.Int origin=null
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
context(T)
|
||||
fun <T> useContext(block: (T) -> Unit) { }
|
||||
|
||||
fun test() {
|
||||
with(42) {
|
||||
useContext { i: Int -> i.toDouble() }
|
||||
}
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
fun <T : Any?> useContext(<this>: T, block: Function1<T, Unit>) {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
with<Int, Unit>(receiver = 42, block = local fun Int.<anonymous>() {
|
||||
useContext<Int>(<this> = $this$with, block = local fun <anonymous>(i: Int) {
|
||||
i.toDouble() /*~> Unit */
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
Generated
+6
@@ -10732,6 +10732,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterAsContextReceiver.kt")
|
||||
public void testTypeParameterAsContextReceiver() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterAsContextReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterized.kt")
|
||||
public void testTypeParameterized() throws Exception {
|
||||
|
||||
Generated
+6
@@ -865,6 +865,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest {
|
||||
runTest("compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterAsContextReceiver.kt")
|
||||
public void testTypeParameterAsContextReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unaryOperators.kt")
|
||||
public void testUnaryOperators() throws Exception {
|
||||
|
||||
@@ -663,6 +663,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase {
|
||||
runTest("compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameterAsContextReceiver.kt")
|
||||
public void testTypeParameterAsContextReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user