[FIR] Fix deserialization of generic context receivers
We need to pass the local deserialization context so that generic type parameters can be referenced. #KT-62607 Fixed
This commit is contained in:
committed by
Space Team
parent
45a1cc1a4a
commit
ef78d4b95a
+5
-5
@@ -468,7 +468,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
proto.contextReceiverTypes(c.typeTable).mapTo(contextReceivers, ::loadContextReceiver)
|
proto.contextReceiverTypes(c.typeTable).mapTo(contextReceivers) { loadContextReceiver(it, local) }
|
||||||
}.apply {
|
}.apply {
|
||||||
initializer?.replaceConeTypeOrNull(returnTypeRef.type)
|
initializer?.replaceConeTypeOrNull(returnTypeRef.type)
|
||||||
this.versionRequirements = versionRequirements
|
this.versionRequirements = versionRequirements
|
||||||
@@ -479,8 +479,8 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadContextReceiver(proto: ProtoBuf.Type): FirContextReceiver {
|
private fun loadContextReceiver(proto: ProtoBuf.Type, context: FirDeserializationContext): FirContextReceiver {
|
||||||
val typeRef = proto.toTypeRef(c)
|
val typeRef = proto.toTypeRef(context)
|
||||||
return buildContextReceiver {
|
return buildContextReceiver {
|
||||||
val type = typeRef.coneType
|
val type = typeRef.coneType
|
||||||
this.labelNameFromTypeRef = (type as? ConeLookupTagBasedType)?.lookupTag?.name
|
this.labelNameFromTypeRef = (type as? ConeLookupTagBasedType)?.lookupTag?.name
|
||||||
@@ -489,7 +489,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun createContextReceiversForClass(classProto: ProtoBuf.Class): List<FirContextReceiver> =
|
internal fun createContextReceiversForClass(classProto: ProtoBuf.Class): List<FirContextReceiver> =
|
||||||
classProto.contextReceiverTypes(c.typeTable).map(::loadContextReceiver)
|
classProto.contextReceiverTypes(c.typeTable).map { loadContextReceiver(it, c) }
|
||||||
|
|
||||||
fun loadFunction(
|
fun loadFunction(
|
||||||
proto: ProtoBuf.Function,
|
proto: ProtoBuf.Function,
|
||||||
@@ -559,7 +559,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
deprecationsProvider = annotations.getDeprecationsProviderFromAnnotations(c.session, fromJava = false, versionRequirements)
|
deprecationsProvider = annotations.getDeprecationsProviderFromAnnotations(c.session, fromJava = false, versionRequirements)
|
||||||
this.containerSource = c.containerSource
|
this.containerSource = c.containerSource
|
||||||
|
|
||||||
proto.contextReceiverTypes(c.typeTable).mapTo(contextReceivers, ::loadContextReceiver)
|
proto.contextReceiverTypes(c.typeTable).mapTo(contextReceivers) { loadContextReceiver(it, local) }
|
||||||
}.apply {
|
}.apply {
|
||||||
this.versionRequirements = versionRequirements
|
this.versionRequirements = versionRequirements
|
||||||
setLazyPublishedVisibility(c.session)
|
setLazyPublishedVisibility(c.session)
|
||||||
|
|||||||
+5
@@ -247,6 +247,11 @@ public class IncrementalFirICLightTreeJvmCompilerRunnerTestGenerated extends Abs
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+5
@@ -247,6 +247,11 @@ public class IncrementalFirLightTreeJvmCompilerRunnerTestGenerated extends Abstr
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+5
@@ -256,6 +256,11 @@ public class IncrementalK1JsKlibCompilerRunnerTestGenerated extends AbstractIncr
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+5
@@ -256,6 +256,11 @@ public class IncrementalK1JsKlibCompilerWithScopeExpansionRunnerTestGenerated ex
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+5
@@ -257,6 +257,11 @@ public class IncrementalK1JvmCompilerRunnerTestGenerated extends AbstractIncreme
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+5
@@ -241,6 +241,11 @@ public class IncrementalK2JsKlibCompilerWithScopeExpansionRunnerTestGenerated ex
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+5
@@ -247,6 +247,11 @@ public class IncrementalK2JvmCompilerRunnerTestGenerated extends AbstractIncreme
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
Generated
+5
@@ -926,6 +926,11 @@ public class IncrementalK1JvmJpsTestGenerated extends AbstractIncrementalK1JvmJp
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+5
@@ -252,6 +252,11 @@ public class IncrementalK2FirICLightTreeJvmJpsTestGenerated extends AbstractIncr
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
Generated
+5
@@ -252,6 +252,11 @@ public class IncrementalK2JvmJpsTestGenerated extends AbstractIncrementalK2JvmJp
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+5
@@ -252,6 +252,11 @@ public class IncrementalK2LightTreeJvmJpsTestGenerated extends AbstractIncrement
|
|||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericContextReceiver")
|
||||||
|
public void testGenericContextReceiver() throws Exception {
|
||||||
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/genericContextReceiver/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
runTest("jps/jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
-XXLanguage:+ContextReceivers
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
with("") {
|
||||||
|
foo()
|
||||||
|
foo
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
================ Step #1 =================
|
||||||
|
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/META-INF/module.kotlin_module
|
||||||
|
out/production/module/test/BarKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/bar.kt
|
||||||
|
End of files
|
||||||
|
Exit code: OK
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
context(T)
|
||||||
|
fun <T> foo() {}
|
||||||
|
|
||||||
|
context(T)
|
||||||
|
val <T> T.foo get() = 1
|
||||||
Reference in New Issue
Block a user