K2: Fix deserialization of upper bound of type parameter in nested class
Previously, containingDeclarationSymbol for V was set to the outer class BaseRoot, so its upper bounds was computed to the ones from TNested at org.jetbrains.kotlin.fir.resolve.calls.CreateFreshTypeVariableSubstitutorStageKt.getTypeParameterFromExpandedClass ^KT-56706 Fixed
This commit is contained in:
committed by
Space Team
parent
9f51d3fbeb
commit
0c9fad87c3
+2
-1
@@ -85,11 +85,12 @@ fun deserializeClassToSymbol(
|
|||||||
val context =
|
val context =
|
||||||
parentContext?.childContext(
|
parentContext?.childContext(
|
||||||
classProto.typeParameterList,
|
classProto.typeParameterList,
|
||||||
|
containingDeclarationSymbol = symbol,
|
||||||
nameResolver,
|
nameResolver,
|
||||||
TypeTable(classProto.typeTable),
|
TypeTable(classProto.typeTable),
|
||||||
classId.relativeClassName,
|
classId.relativeClassName,
|
||||||
containerSource,
|
containerSource,
|
||||||
symbol,
|
outerClassSymbol = symbol,
|
||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
if (status.isCompanion) {
|
if (status.isCompanion) {
|
||||||
parentContext.constDeserializer
|
parentContext.constDeserializer
|
||||||
|
|||||||
+1
-1
@@ -60,6 +60,7 @@ class FirDeserializationContext(
|
|||||||
|
|
||||||
fun childContext(
|
fun childContext(
|
||||||
typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
typeParameterProtos: List<ProtoBuf.TypeParameter>,
|
||||||
|
containingDeclarationSymbol: FirBasedSymbol<*>,
|
||||||
nameResolver: NameResolver = this.nameResolver,
|
nameResolver: NameResolver = this.nameResolver,
|
||||||
typeTable: TypeTable = this.typeTable,
|
typeTable: TypeTable = this.typeTable,
|
||||||
relativeClassName: FqName? = this.relativeClassName,
|
relativeClassName: FqName? = this.relativeClassName,
|
||||||
@@ -68,7 +69,6 @@ class FirDeserializationContext(
|
|||||||
annotationDeserializer: AbstractAnnotationDeserializer = this.annotationDeserializer,
|
annotationDeserializer: AbstractAnnotationDeserializer = this.annotationDeserializer,
|
||||||
constDeserializer: FirConstDeserializer = this.constDeserializer,
|
constDeserializer: FirConstDeserializer = this.constDeserializer,
|
||||||
capturesTypeParameters: Boolean = true,
|
capturesTypeParameters: Boolean = true,
|
||||||
containingDeclarationSymbol: FirBasedSymbol<*>? = this.outerClassSymbol
|
|
||||||
): FirDeserializationContext = FirDeserializationContext(
|
): FirDeserializationContext = FirDeserializationContext(
|
||||||
nameResolver,
|
nameResolver,
|
||||||
typeTable,
|
typeTable,
|
||||||
|
|||||||
+6
@@ -18511,6 +18511,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/fir/namedArgumentOnTypeAnnotation.kt");
|
runTest("compiler/testData/codegen/box/fir/namedArgumentOnTypeAnnotation.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noSymbolForIntRangeIterator.kt")
|
@TestMetadata("noSymbolForIntRangeIterator.kt")
|
||||||
public void testNoSymbolForIntRangeIterator() throws Exception {
|
public void testNoSymbolForIntRangeIterator() throws Exception {
|
||||||
|
|||||||
+6
@@ -18511,6 +18511,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
|||||||
runTest("compiler/testData/codegen/box/fir/namedArgumentOnTypeAnnotation.kt");
|
runTest("compiler/testData/codegen/box/fir/namedArgumentOnTypeAnnotation.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noSymbolForIntRangeIterator.kt")
|
@TestMetadata("noSymbolForIntRangeIterator.kt")
|
||||||
public void testNoSymbolForIntRangeIterator() throws Exception {
|
public void testNoSymbolForIntRangeIterator() throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// ISSUE: KT-56706
|
||||||
|
// MODULE: lib
|
||||||
|
// FILE: lib.kt
|
||||||
|
package lib
|
||||||
|
|
||||||
|
abstract class BaseRoot<TNested : BaseRoot.BaseNested<*>> {
|
||||||
|
open class BaseNested<V>(val box: V)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: main(lib)
|
||||||
|
// FILE: main.kt
|
||||||
|
package main
|
||||||
|
import lib.BaseRoot
|
||||||
|
|
||||||
|
class Foo(val v: String)
|
||||||
|
|
||||||
|
class ImplRoot : BaseRoot<ImplRoot.ImplNested>() {
|
||||||
|
|
||||||
|
class ImplNested: BaseNested<Foo>(box = Foo("OK")) {
|
||||||
|
fun bar(): String {
|
||||||
|
return BaseNested(box).box.v // K1 doesn't report it, yet message is really strange
|
||||||
|
// "actual type is main/Foo but lib/BaseRoot.BaseNested<*> was expected" which is also strange, since type of box is main/Foo and V for argument
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String = ImplRoot.ImplNested().bar()
|
||||||
+6
@@ -17581,6 +17581,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt");
|
runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("notFoundClasses.kt")
|
@TestMetadata("notFoundClasses.kt")
|
||||||
public void testNotFoundClasses() throws Exception {
|
public void testNotFoundClasses() throws Exception {
|
||||||
|
|||||||
+6
@@ -18511,6 +18511,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/fir/namedArgumentOnTypeAnnotation.kt");
|
runTest("compiler/testData/codegen/box/fir/namedArgumentOnTypeAnnotation.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noSymbolForIntRangeIterator.kt")
|
@TestMetadata("noSymbolForIntRangeIterator.kt")
|
||||||
public void testNoSymbolForIntRangeIterator() throws Exception {
|
public void testNoSymbolForIntRangeIterator() throws Exception {
|
||||||
|
|||||||
+5
@@ -14568,6 +14568,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt");
|
runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("notFoundClasses.kt")
|
@TestMetadata("notFoundClasses.kt")
|
||||||
public void testNotFoundClasses() throws Exception {
|
public void testNotFoundClasses() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/notFoundClasses.kt");
|
runTest("compiler/testData/codegen/box/fir/notFoundClasses.kt");
|
||||||
|
|||||||
+6
@@ -13544,6 +13544,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+6
@@ -13640,6 +13640,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
|
|||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+6
@@ -13640,6 +13640,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+6
@@ -13640,6 +13640,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
|
|||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+6
@@ -14858,6 +14858,12 @@ public class K2NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTes
|
|||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+6
@@ -14682,6 +14682,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
|||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
Generated
+5
@@ -12107,6 +12107,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
public void testFalsePositiveBoundSmartcast() throws Exception {
|
public void testFalsePositiveBoundSmartcast() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
runTest("compiler/testData/codegen/box/fir/falsePositiveBoundSmartcast.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nestedClassTypeParameterDeserialization.kt")
|
||||||
|
public void testNestedClassTypeParameterDeserialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/nestedClassTypeParameterDeserialization.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
||||||
|
|||||||
Reference in New Issue
Block a user