[FE] Allow to infer generic property type from a context receiver type
This commit is contained in:
committed by
TeamCityServer
parent
dcb3fc5508
commit
837f3b98fa
+6
@@ -16157,6 +16157,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/dp.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inferGenericPropertyType.kt")
|
||||
public void testInferGenericPropertyType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/inferGenericPropertyType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusMatrix.kt")
|
||||
public void testPlusMatrix() throws Exception {
|
||||
|
||||
@@ -636,6 +636,9 @@ class DeclarationsChecker(
|
||||
}
|
||||
}
|
||||
addAccessibleTypeParametersFromType(descriptor.extensionReceiverParameter?.type)
|
||||
for (contextReceiverParameter in descriptor.contextReceiverParameters) {
|
||||
addAccessibleTypeParametersFromType(contextReceiverParameter.type)
|
||||
}
|
||||
|
||||
val typeParametersInaccessibleFromReceiver = allTypeParameters - allAccessibleTypeParameters
|
||||
for (typeParameter in typeParametersInaccessibleFromReceiver) {
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
class Result<T>(val x: T)
|
||||
|
||||
context(Result<T>)
|
||||
val <T> result: Result<T> get() = this@Result
|
||||
|
||||
fun <T> Result<T>.x(): T {
|
||||
with(result) {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
with(Result<String>("OK")) {
|
||||
return x()
|
||||
}
|
||||
}
|
||||
+6
@@ -16157,6 +16157,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/dp.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inferGenericPropertyType.kt")
|
||||
public void testInferGenericPropertyType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/extensionFunctions/contextReceivers/inferGenericPropertyType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("plusMatrix.kt")
|
||||
public void testPlusMatrix() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user