Don't assign type parameters from original proto if type is substituted with Any (KT-15128)
#KT-15128 Fixed
This commit is contained in:
@@ -28,7 +28,7 @@ object KotlinStubVersions {
|
||||
// Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed
|
||||
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
|
||||
// Increasing this version will lead to reindexing of all binary files that are potentially kotlin binaries (including all class files).
|
||||
private const val BINARY_STUB_VERSION = 56
|
||||
private const val BINARY_STUB_VERSION = 57
|
||||
|
||||
// Classfile stub version should be increased if changes are made to classfile stub building subsystem (org.jetbrains.kotlin.idea.decompiler.classFile)
|
||||
// Increasing this version will lead to reindexing of all classfiles.
|
||||
|
||||
+7
-3
@@ -141,10 +141,12 @@ fun createStubForPackageName(packageDirectiveStub: KotlinPlaceHolderStubImpl<KtP
|
||||
fun createStubForTypeName(
|
||||
typeClassId: ClassId,
|
||||
parent: StubElement<out PsiElement>,
|
||||
onUserTypeLevel: (KotlinUserTypeStub, Int) -> Unit = { x, y -> }
|
||||
bindTypeArguments: (KotlinUserTypeStub, Int) -> Unit = { x, y -> }
|
||||
): KotlinUserTypeStub {
|
||||
val substituteWithAny = typeClassId.isLocal
|
||||
|
||||
val fqName =
|
||||
if (typeClassId.isLocal) KotlinBuiltIns.FQ_NAMES.any
|
||||
if (substituteWithAny) KotlinBuiltIns.FQ_NAMES.any
|
||||
else typeClassId.asSingleFqName().toUnsafe()
|
||||
val segments = fqName.pathSegments().asReversed()
|
||||
assert(segments.isNotEmpty())
|
||||
@@ -156,7 +158,9 @@ fun createStubForTypeName(
|
||||
recCreateStubForType(userTypeStub, level + 1)
|
||||
}
|
||||
KotlinNameReferenceExpressionStubImpl(userTypeStub, lastSegment.ref())
|
||||
onUserTypeLevel(userTypeStub, level)
|
||||
if (!substituteWithAny) {
|
||||
bindTypeArguments(userTypeStub, level)
|
||||
}
|
||||
return userTypeStub
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
interface Foo<T>
|
||||
|
||||
class AnonymousReturnWithGenericType<T> {
|
||||
val v1 = object : Foo<T> {}
|
||||
fun f1() = object : Foo<T> {}
|
||||
|
||||
private val v2 = object : Foo<T> {}
|
||||
private fun f2() = object : Foo<T> {}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
PsiJetFileStubImpl[package=]
|
||||
PACKAGE_DIRECTIVE
|
||||
IMPORT_LIST
|
||||
CLASS[fqName=AnonymousReturnWithGenericType, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=AnonymousReturnWithGenericType, superNames=[]]
|
||||
MODIFIER_LIST[public final]
|
||||
TYPE_PARAMETER_LIST
|
||||
TYPE_PARAMETER[fqName=null, isInVariance=false, isOutVariance=false, name=T]
|
||||
PRIMARY_CONSTRUCTOR
|
||||
MODIFIER_LIST[public]
|
||||
VALUE_PARAMETER_LIST
|
||||
CLASS_BODY
|
||||
PROPERTY[fqName=AnonymousReturnWithGenericType.v1, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=false, name=v1]
|
||||
MODIFIER_LIST[public final]
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION[referencedName=Foo]
|
||||
TYPE_ARGUMENT_LIST
|
||||
TYPE_PROJECTION[projectionKind=NONE]
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION[referencedName=T]
|
||||
PROPERTY[fqName=AnonymousReturnWithGenericType.v2, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=false, name=v2]
|
||||
MODIFIER_LIST[private final]
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION[referencedName=Any]
|
||||
FUN[fqName=AnonymousReturnWithGenericType.f1, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=f1]
|
||||
MODIFIER_LIST[public final]
|
||||
VALUE_PARAMETER_LIST
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION[referencedName=Foo]
|
||||
TYPE_ARGUMENT_LIST
|
||||
TYPE_PROJECTION[projectionKind=NONE]
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION[referencedName=T]
|
||||
FUN[fqName=AnonymousReturnWithGenericType.f2, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=f2]
|
||||
MODIFIER_LIST[private final]
|
||||
VALUE_PARAMETER_LIST
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION[referencedName=Any]
|
||||
+6
@@ -60,6 +60,12 @@ public class ClsStubBuilderTestGenerated extends AbstractClsStubBuilderTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AnonymousReturnWithGenericType")
|
||||
public void testAnonymousReturnWithGenericType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/stubBuilder/AnonymousReturnWithGenericType/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ClassMembers")
|
||||
public void testClassMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/stubBuilder/ClassMembers/");
|
||||
|
||||
Reference in New Issue
Block a user