Generate modifier list stub under nullable type for suspend functions (KT-20185)
Otherwise there's a PSI and Stub mismatch error produced. #KT-20185 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
|
// 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).
|
// 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).
|
// 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 = 61
|
private const val BINARY_STUB_VERSION = 62
|
||||||
|
|
||||||
// Classfile stub version should be increased if changes are made to classfile stub building subsystem (org.jetbrains.kotlin.idea.decompiler.classFile)
|
// 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.
|
// Increasing this version will lead to reindexing of all classfiles.
|
||||||
|
|||||||
+13
-3
@@ -95,10 +95,20 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
|||||||
val (extensionAnnotations, notExtensionAnnotations) =
|
val (extensionAnnotations, notExtensionAnnotations) =
|
||||||
annotations.partition { it.classId.asSingleFqName() == KotlinBuiltIns.FQ_NAMES.extensionFunctionType }
|
annotations.partition { it.classId.asSingleFqName() == KotlinBuiltIns.FQ_NAMES.extensionFunctionType }
|
||||||
|
|
||||||
createTypeAnnotationStubs(parent, type, notExtensionAnnotations)
|
|
||||||
|
|
||||||
val isExtension = extensionAnnotations.isNotEmpty()
|
val isExtension = extensionAnnotations.isNotEmpty()
|
||||||
createFunctionTypeStub(nullableTypeParent(parent, type), type, isExtension, Flags.SUSPEND_TYPE.get(type.flags))
|
val isSuspend = Flags.SUSPEND_TYPE.get(type.flags)
|
||||||
|
|
||||||
|
val nullableWrapper = if (isSuspend) {
|
||||||
|
val wrapper = nullableTypeParent(parent, type)
|
||||||
|
createTypeAnnotationStubs(wrapper, type, notExtensionAnnotations)
|
||||||
|
wrapper
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
createTypeAnnotationStubs(parent, type, notExtensionAnnotations)
|
||||||
|
nullableTypeParent(parent, type)
|
||||||
|
}
|
||||||
|
|
||||||
|
createFunctionTypeStub(nullableWrapper, type, isExtension, isSuspend)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,28 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
class SuspendLambda {
|
class SuspendLambda {
|
||||||
fun <T> (suspend () -> T).createCoroutine(completion: Continuation<T>) {}
|
fun <T> (suspend () -> T).createCoroutine1(completion: Continuation<T>) {}
|
||||||
|
|
||||||
fun <R, T> (suspend R.() -> T).createCoroutine(receiver: R, completion: Continuation<T>) {}
|
fun <R, T> (suspend R.() -> T).createCoroutine2(receiver: R, completion: Continuation<T>) {}
|
||||||
|
|
||||||
fun <R, T> (suspend @receiver:A R.() -> T).createCoroutineAnother() {}
|
fun <R, T> (suspend @receiver:A R.() -> T).createCoroutineAnother() {}
|
||||||
|
|
||||||
fun <T> testCoroutine(f: suspend (Int) -> T?) {}
|
fun <T> testCoroutine(f: suspend (Int) -> T?) {}
|
||||||
|
|
||||||
fun <T> testCoroutineWithAnnotation(f: suspend (Int) -> @A T?) {}
|
fun <T> testCoroutineWithAnnotation(f: suspend (Int) -> @A T?) {}
|
||||||
|
|
||||||
|
var nullableSuspend: (suspend (P) -> Unit)? = null
|
||||||
|
var nullableSuspendWithReceiver: (suspend RS.(P) -> Unit)? = null
|
||||||
|
var nullableSuspendWithNullableParameter: (suspend (P?) -> Unit)? = null
|
||||||
|
var nullableSuspendWithNullableReceiver: (suspend RS?.(P) -> Unit)? = null
|
||||||
|
|
||||||
|
var nullableSuspendWithAnnotation: (@A() suspend (P) -> Unit)? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.VALUE_PARAMETER)
|
interface P
|
||||||
|
interface RS
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.TYPE, AnnotationTarget.VALUE_PARAMETER)
|
||||||
annotation class A
|
annotation class A
|
||||||
|
|
||||||
class Continuation<T> {}
|
class Continuation<T> {}
|
||||||
@@ -8,6 +8,117 @@ PsiJetFileStubImpl[package=test]
|
|||||||
MODIFIER_LIST[public]
|
MODIFIER_LIST[public]
|
||||||
VALUE_PARAMETER_LIST
|
VALUE_PARAMETER_LIST
|
||||||
CLASS_BODY
|
CLASS_BODY
|
||||||
|
PROPERTY[fqName=test.SuspendLambda.nullableSuspend, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=true, name=nullableSuspend]
|
||||||
|
MODIFIER_LIST[public final]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
NULLABLE_TYPE
|
||||||
|
MODIFIER_LIST[suspend]
|
||||||
|
FUNCTION_TYPE
|
||||||
|
VALUE_PARAMETER_LIST
|
||||||
|
VALUE_PARAMETER[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=null]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=test]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=P]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=kotlin]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=Unit]
|
||||||
|
PROPERTY[fqName=test.SuspendLambda.nullableSuspendWithAnnotation, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=true, name=nullableSuspendWithAnnotation]
|
||||||
|
MODIFIER_LIST[public final]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
NULLABLE_TYPE
|
||||||
|
MODIFIER_LIST[suspend]
|
||||||
|
ANNOTATION_ENTRY[hasValueArguments=false, shortName=A]
|
||||||
|
CONSTRUCTOR_CALLEE
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=test]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=A]
|
||||||
|
FUNCTION_TYPE
|
||||||
|
VALUE_PARAMETER_LIST
|
||||||
|
VALUE_PARAMETER[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=null]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=test]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=P]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=kotlin]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=Unit]
|
||||||
|
PROPERTY[fqName=test.SuspendLambda.nullableSuspendWithNullableParameter, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=true, name=nullableSuspendWithNullableParameter]
|
||||||
|
MODIFIER_LIST[public final]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
NULLABLE_TYPE
|
||||||
|
MODIFIER_LIST[suspend]
|
||||||
|
FUNCTION_TYPE
|
||||||
|
VALUE_PARAMETER_LIST
|
||||||
|
VALUE_PARAMETER[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=null]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
NULLABLE_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=test]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=P]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=kotlin]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=Unit]
|
||||||
|
PROPERTY[fqName=test.SuspendLambda.nullableSuspendWithNullableReceiver, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=true, name=nullableSuspendWithNullableReceiver]
|
||||||
|
MODIFIER_LIST[public final]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
NULLABLE_TYPE
|
||||||
|
MODIFIER_LIST[suspend]
|
||||||
|
FUNCTION_TYPE
|
||||||
|
FUNCTION_TYPE_RECEIVER
|
||||||
|
TYPE_REFERENCE
|
||||||
|
NULLABLE_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=test]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=RS]
|
||||||
|
VALUE_PARAMETER_LIST
|
||||||
|
VALUE_PARAMETER[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=null]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=test]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=P]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=kotlin]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=Unit]
|
||||||
|
PROPERTY[fqName=test.SuspendLambda.nullableSuspendWithReceiver, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=true, name=nullableSuspendWithReceiver]
|
||||||
|
MODIFIER_LIST[public final]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
NULLABLE_TYPE
|
||||||
|
MODIFIER_LIST[suspend]
|
||||||
|
FUNCTION_TYPE
|
||||||
|
FUNCTION_TYPE_RECEIVER
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=test]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=RS]
|
||||||
|
VALUE_PARAMETER_LIST
|
||||||
|
VALUE_PARAMETER[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=null]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=test]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=P]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=kotlin]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=Unit]
|
||||||
FUN[fqName=test.SuspendLambda.testCoroutine, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=true, isExtension=false, isTopLevel=false, name=testCoroutine]
|
FUN[fqName=test.SuspendLambda.testCoroutine, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=true, isExtension=false, isTopLevel=false, name=testCoroutine]
|
||||||
MODIFIER_LIST[public final]
|
MODIFIER_LIST[public final]
|
||||||
TYPE_PARAMETER_LIST
|
TYPE_PARAMETER_LIST
|
||||||
@@ -66,7 +177,7 @@ PsiJetFileStubImpl[package=test]
|
|||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION[referencedName=kotlin]
|
REFERENCE_EXPRESSION[referencedName=kotlin]
|
||||||
REFERENCE_EXPRESSION[referencedName=Unit]
|
REFERENCE_EXPRESSION[referencedName=Unit]
|
||||||
FUN[fqName=test.SuspendLambda.createCoroutine, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=true, isExtension=true, isTopLevel=false, name=createCoroutine]
|
FUN[fqName=test.SuspendLambda.createCoroutine1, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=true, isExtension=true, isTopLevel=false, name=createCoroutine1]
|
||||||
MODIFIER_LIST[public final]
|
MODIFIER_LIST[public final]
|
||||||
TYPE_PARAMETER_LIST
|
TYPE_PARAMETER_LIST
|
||||||
TYPE_PARAMETER[fqName=null, isInVariance=false, isOutVariance=false, name=T]
|
TYPE_PARAMETER[fqName=null, isInVariance=false, isOutVariance=false, name=T]
|
||||||
@@ -94,7 +205,7 @@ PsiJetFileStubImpl[package=test]
|
|||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION[referencedName=kotlin]
|
REFERENCE_EXPRESSION[referencedName=kotlin]
|
||||||
REFERENCE_EXPRESSION[referencedName=Unit]
|
REFERENCE_EXPRESSION[referencedName=Unit]
|
||||||
FUN[fqName=test.SuspendLambda.createCoroutine, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=true, isExtension=true, isTopLevel=false, name=createCoroutine]
|
FUN[fqName=test.SuspendLambda.createCoroutine2, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=true, isExtension=true, isTopLevel=false, name=createCoroutine2]
|
||||||
MODIFIER_LIST[public final]
|
MODIFIER_LIST[public final]
|
||||||
TYPE_PARAMETER_LIST
|
TYPE_PARAMETER_LIST
|
||||||
TYPE_PARAMETER[fqName=null, isInVariance=false, isOutVariance=false, name=R]
|
TYPE_PARAMETER[fqName=null, isInVariance=false, isOutVariance=false, name=R]
|
||||||
|
|||||||
Reference in New Issue
Block a user