[Analysis API decompiler] materialize delegate declarations in stubs

We should materialize delegated declarations to process callables
in scopes correctly. Standalone mode works the same way as it
deserialize directly into FIR.
Another solution is to rework proto and stub serializer/deserializer to
restore FirFields like `$$delegate_0` correctly to work with
`FirDelegatedMemberScope`

^KT-62896 Fixed
^KT-64584 Fixed
This commit is contained in:
Dmitrii Gridin
2023-12-27 19:55:40 +01:00
committed by Space Team
parent 06950f57db
commit d88249bda7
11 changed files with 778 additions and 19 deletions
@@ -1,4 +1 @@
Diagnostics from elements:
for PSI element of type KtClass at (13,1) - (15,96)
ABSTRACT_MEMBER_NOT_IMPLEMENTED text ranges: [(51,71)]
PSI: KtClass at (13,1) - (15,96)
@@ -1,3 +1,15 @@
private val p: A
constructor(p: A)
open var bar: kotlin.Long
open val kotlin.Int.doo: kotlin.String
open fun foo()
open val foo: kotlin.Int
open var kotlin.Int.zoo: kotlin.Unit
open fun kotlin.Int.smth(): kotlin.Short
constructor(p: A)
@@ -89,6 +89,660 @@ KtKotlinPropertySymbol:
javaSetterName: null
setterDeprecationStatus: null
KtKotlinPropertySymbol:
annotationsList: []
backingFieldSymbol: KtBackingFieldSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
isExtension: false
name: field
origin: PROPERTY_BACKING_FIELD
owningProperty: KtKotlinPropertySymbol(/I.bar)
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Long
symbolKind: LOCAL
typeParameters: []
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
callableIdIfNonLocal: /I.bar
contextReceivers: []
getter: KtPropertyGetterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
hasBody: false
hasStableParameterNames: true
isDefault: true
isExtension: false
isInline: false
isOverride: false
modality: FINAL
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Long
symbolKind: ACCESSOR
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
hasBackingField: true
hasGetter: true
hasSetter: true
initializer: null
isActual: false
isConst: false
isDelegatedProperty: false
isExpect: false
isExtension: false
isFromPrimaryConstructor: false
isLateInit: false
isOverride: false
isStatic: false
isVal: false
modality: OPEN
name: bar
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Long
setter: KtPropertySetterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
hasBody: false
hasStableParameterNames: true
isDefault: true
isExtension: false
isInline: false
isOverride: false
modality: FINAL
origin: SOURCE
parameter: KtValueParameterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
generatedPrimaryConstructorProperty: null
hasDefaultValue: false
isCrossinline: false
isExtension: false
isImplicitLambdaParameter: false
isNoinline: false
isVararg: false
name: value
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Long
symbolKind: LOCAL
typeParameters: []
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: null
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: ACCESSOR
typeParameters: []
valueParameters: [
KtValueParameterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
generatedPrimaryConstructorProperty: null
hasDefaultValue: false
isCrossinline: false
isExtension: false
isImplicitLambdaParameter: false
isNoinline: false
isVararg: false
name: value
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Long
symbolKind: LOCAL
typeParameters: []
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: null
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
]
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
symbolKind: CLASS_MEMBER
typeParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
getterDeprecationStatus: null
javaGetterName: getBar
javaSetterName: setBar
setterDeprecationStatus: null
KtKotlinPropertySymbol:
annotationsList: []
backingFieldSymbol: KtBackingFieldSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
isExtension: false
name: field
origin: PROPERTY_BACKING_FIELD
owningProperty: KtKotlinPropertySymbol(/I.doo)
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/String
symbolKind: LOCAL
typeParameters: []
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
callableIdIfNonLocal: /I.doo
contextReceivers: []
getter: KtPropertyGetterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
hasBody: false
hasStableParameterNames: true
isDefault: true
isExtension: false
isInline: false
isOverride: false
modality: FINAL
origin: SOURCE
receiverParameter: KtReceiverParameterSymbol:
annotationsList: []
origin: SOURCE
owningCallableSymbol: KtKotlinPropertySymbol(/I.doo)
type: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/String
symbolKind: ACCESSOR
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
hasBackingField: true
hasGetter: true
hasSetter: false
initializer: null
isActual: false
isConst: false
isDelegatedProperty: false
isExpect: false
isExtension: true
isFromPrimaryConstructor: false
isLateInit: false
isOverride: false
isStatic: false
isVal: true
modality: OPEN
name: doo
origin: SOURCE
receiverParameter: KtReceiverParameterSymbol:
annotationsList: []
origin: SOURCE
owningCallableSymbol: KtKotlinPropertySymbol(/I.doo)
type: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/String
setter: null
symbolKind: CLASS_MEMBER
typeParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
getterDeprecationStatus: null
javaGetterName: getDoo
javaSetterName: null
setterDeprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: /I.foo
contextReceivers: []
contractEffects: []
hasStableParameterNames: true
isActual: false
isBuiltinFunctionInvoke: false
isExpect: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: OPEN
name: foo
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
KtKotlinPropertySymbol:
annotationsList: []
backingFieldSymbol: KtBackingFieldSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
isExtension: false
name: field
origin: PROPERTY_BACKING_FIELD
owningProperty: KtKotlinPropertySymbol(/I.foo)
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
symbolKind: LOCAL
typeParameters: []
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
callableIdIfNonLocal: /I.foo
contextReceivers: []
getter: KtPropertyGetterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
hasBody: false
hasStableParameterNames: true
isDefault: true
isExtension: false
isInline: false
isOverride: false
modality: FINAL
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
symbolKind: ACCESSOR
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
hasBackingField: true
hasGetter: true
hasSetter: false
initializer: null
isActual: false
isConst: false
isDelegatedProperty: false
isExpect: false
isExtension: false
isFromPrimaryConstructor: false
isLateInit: false
isOverride: false
isStatic: false
isVal: true
modality: OPEN
name: foo
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
setter: null
symbolKind: CLASS_MEMBER
typeParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
getterDeprecationStatus: null
javaGetterName: getFoo
javaSetterName: null
setterDeprecationStatus: null
KtKotlinPropertySymbol:
annotationsList: []
backingFieldSymbol: KtBackingFieldSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
isExtension: false
name: field
origin: PROPERTY_BACKING_FIELD
owningProperty: KtKotlinPropertySymbol(/I.zoo)
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: LOCAL
typeParameters: []
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
callableIdIfNonLocal: /I.zoo
contextReceivers: []
getter: KtPropertyGetterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
hasBody: false
hasStableParameterNames: true
isDefault: true
isExtension: false
isInline: false
isOverride: false
modality: FINAL
origin: SOURCE
receiverParameter: KtReceiverParameterSymbol:
annotationsList: []
origin: SOURCE
owningCallableSymbol: KtKotlinPropertySymbol(/I.zoo)
type: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: ACCESSOR
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
hasBackingField: true
hasGetter: true
hasSetter: true
initializer: null
isActual: false
isConst: false
isDelegatedProperty: false
isExpect: false
isExtension: true
isFromPrimaryConstructor: false
isLateInit: false
isOverride: false
isStatic: false
isVal: false
modality: OPEN
name: zoo
origin: SOURCE
receiverParameter: KtReceiverParameterSymbol:
annotationsList: []
origin: SOURCE
owningCallableSymbol: KtKotlinPropertySymbol(/I.zoo)
type: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
setter: KtPropertySetterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
hasBody: false
hasStableParameterNames: true
isDefault: true
isExtension: false
isInline: false
isOverride: false
modality: FINAL
origin: SOURCE
parameter: KtValueParameterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
generatedPrimaryConstructorProperty: null
hasDefaultValue: false
isCrossinline: false
isExtension: false
isImplicitLambdaParameter: false
isNoinline: false
isVararg: false
name: value
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: LOCAL
typeParameters: []
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: null
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
receiverParameter: KtReceiverParameterSymbol:
annotationsList: []
origin: SOURCE
owningCallableSymbol: KtKotlinPropertySymbol(/I.zoo)
type: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: ACCESSOR
typeParameters: []
valueParameters: [
KtValueParameterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
generatedPrimaryConstructorProperty: null
hasDefaultValue: false
isCrossinline: false
isExtension: false
isImplicitLambdaParameter: false
isNoinline: false
isVararg: false
name: value
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: LOCAL
typeParameters: []
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: null
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
]
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
symbolKind: CLASS_MEMBER
typeParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
getterDeprecationStatus: null
javaGetterName: getZoo
javaSetterName: setZoo
setterDeprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: /I.smth
contextReceivers: []
contractEffects: []
hasStableParameterNames: true
isActual: false
isBuiltinFunctionInvoke: false
isExpect: false
isExtension: true
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: OPEN
name: smth
origin: SOURCE
receiverParameter: KtReceiverParameterSymbol:
annotationsList: []
origin: SOURCE
owningCallableSymbol: KtFunctionSymbol(/I.smth)
type: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Short
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: I
getContainingFileSymbol: KtFileSymbol(I.class)
getContainingJvmClassName: I
getContainingModule: KtLibraryModule "Library main"
deprecationStatus: null
KtConstructorSymbol:
annotationsList: []
callableIdIfNonLocal: null
@@ -0,0 +1,55 @@
PsiJetFileStubImpl[package=]
PACKAGE_DIRECTIVE
IMPORT_LIST
CLASS[classId=/Delegation, fqName=Delegation, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=Delegation, superNames=[T]]
MODIFIER_LIST[public final]
PRIMARY_CONSTRUCTOR[fqName=null, hasBody=false, isDelegatedCallToThis=false, isExtension=false, isTopLevel=false, name=Delegation]
MODIFIER_LIST[public]
VALUE_PARAMETER_LIST
VALUE_PARAMETER[fqName=null, hasDefaultValue=true, hasValOrVar=false, isMutable=false, name=c]
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION[referencedName=kotlin]
REFERENCE_EXPRESSION[referencedName=Int]
REFERENCE_EXPRESSION[referencedName=COMPILED_CODE]
VALUE_PARAMETER[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=a]
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION[referencedName=A]
SUPER_TYPE_LIST
SUPER_TYPE_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION[referencedName=T]
CLASS_BODY
PROPERTY[fqName=Delegation.c, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=false, name=c]
MODIFIER_LIST[public final]
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION[referencedName=kotlin]
REFERENCE_EXPRESSION[referencedName=Int]
PROPERTY[fqName=Delegation.g, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=false, name=g]
MODIFIER_LIST[open public]
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION[referencedName=kotlin]
REFERENCE_EXPRESSION[referencedName=Int]
FUN[fqName=Delegation.ff, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, mayHaveContract=false, name=ff]
MODIFIER_LIST[public final]
VALUE_PARAMETER_LIST
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION[referencedName=kotlin]
REFERENCE_EXPRESSION[referencedName=Int]
FUN[fqName=Delegation.f, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, mayHaveContract=false, name=f]
MODIFIER_LIST[open public]
VALUE_PARAMETER_LIST
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION[referencedName=kotlin]
REFERENCE_EXPRESSION[referencedName=Unit]
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
interface T {
fun f()
val g: Int
@@ -30,6 +30,21 @@ PsiJetFileStubImpl[package=]
USER_TYPE
REFERENCE_EXPRESSION[referencedName=kotlin]
REFERENCE_EXPRESSION[referencedName=Int]
PROPERTY[fqName=Delegation.g, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=false, name=g]
MODIFIER_LIST[open public]
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION[referencedName=kotlin]
REFERENCE_EXPRESSION[referencedName=Int]
FUN[fqName=Delegation.f, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, mayHaveContract=false, name=f]
MODIFIER_LIST[open public]
VALUE_PARAMETER_LIST
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION[referencedName=kotlin]
REFERENCE_EXPRESSION[referencedName=Unit]
FUN[fqName=Delegation.ff, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, mayHaveContract=false, name=ff]
MODIFIER_LIST[public final]
VALUE_PARAMETER_LIST
@@ -1,11 +1,10 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.analysis.decompiler.psi.text
import com.intellij.openapi.util.TextRange
import org.jetbrains.kotlin.analysis.decompiler.stub.COMPILED_DEFAULT_INITIALIZER
import org.jetbrains.kotlin.analysis.decompiler.stub.COMPILED_DEFAULT_PARAMETER_VALUE
import org.jetbrains.kotlin.builtins.StandardNames
@@ -20,7 +19,6 @@ import org.jetbrains.kotlin.renderer.DescriptorRendererOptions
import org.jetbrains.kotlin.renderer.render
import org.jetbrains.kotlin.resolve.DataClassDescriptorResolver
import org.jetbrains.kotlin.resolve.DescriptorUtils.isEnumEntry
import org.jetbrains.kotlin.resolve.constants.*
import org.jetbrains.kotlin.resolve.descriptorUtil.secondaryConstructors
import org.jetbrains.kotlin.types.isFlexible
import org.jetbrains.kotlin.util.OperatorNameConventions
@@ -46,11 +44,8 @@ fun DescriptorRendererOptions.defaultDecompilerRendererOptions() {
internal fun CallableMemberDescriptor.mustNotBeWrittenToDecompiledText(): Boolean {
return when (kind) {
CallableMemberDescriptor.Kind.DECLARATION -> false
CallableMemberDescriptor.Kind.FAKE_OVERRIDE,
CallableMemberDescriptor.Kind.DELEGATION -> true
CallableMemberDescriptor.Kind.DECLARATION, CallableMemberDescriptor.Kind.DELEGATION -> false
CallableMemberDescriptor.Kind.FAKE_OVERRIDE -> true
CallableMemberDescriptor.Kind.SYNTHESIZED -> {
// Of all synthesized functions, only `component*` functions are rendered (for historical reasons)
!DataClassDescriptorResolver.isComponentLike(name) && name !in listOf(
@@ -1,4 +1,7 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.analysis.decompiler.stub
@@ -6,8 +9,8 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.stubs.StubElement
import com.intellij.util.io.StringRef
import org.jetbrains.kotlin.analysis.decompiler.stub.flags.*
import org.jetbrains.kotlin.constant.ConstantValue
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.constant.ConstantValue
import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.load.kotlin.*
@@ -28,9 +31,9 @@ import org.jetbrains.kotlin.resolve.constants.ClassLiteralValue
import org.jetbrains.kotlin.serialization.deserialization.AnnotatedCallableKind
import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer
import org.jetbrains.kotlin.serialization.deserialization.getName
import org.jetbrains.kotlin.utils.addToStdlib.runIf
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.kotlin.utils.addIfNotNull
import org.jetbrains.kotlin.utils.addToStdlib.runIf
const val COMPILED_DEFAULT_INITIALIZER = "COMPILED_CODE"
@@ -85,7 +88,7 @@ fun createConstructorStub(
private fun shouldSkip(flags: Int, name: Name): Boolean {
return when (Flags.MEMBER_KIND.get(flags)) {
MemberKind.FAKE_OVERRIDE, MemberKind.DELEGATION -> true
MemberKind.FAKE_OVERRIDE -> true
//TODO: fix decompiler to use sane criteria
MemberKind.SYNTHESIZED -> !DataClassResolver.isComponentLike(name) && name !in listOf(
OperatorNameConventions.EQUALS,
@@ -2,15 +2,45 @@ KT element: KtClass
KT element text:
public final class I public constructor(p: A) : A {
private final val p: A /* compiled code */
public open var bar: kotlin.Long /* compiled code */
public open val kotlin.Int.doo: kotlin.String /* compiled code */
public open val foo: kotlin.Int /* compiled code */
public open var kotlin.Int.zoo: kotlin.Unit /* compiled code */
public open fun foo(): kotlin.Unit { /* compiled code */ }
public open fun kotlin.Int.smth(): kotlin.Short { /* compiled code */ }
}
FIR element: FirRegularClassImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
public final [ResolvedTo(BODY_RESOLVE)] class I : R|A| {
public open [ResolvedTo(BODY_RESOLVE)] fun foo(): R|kotlin/Unit|
public open [ResolvedTo(BODY_RESOLVE)] fun R|kotlin/Int|.smth(): R|kotlin/Short|
public open [ResolvedTo(BODY_RESOLVE)] var bar: R|kotlin/Long|
public open [ResolvedTo(BODY_RESOLVE)] val R|kotlin/Int|.doo: R|kotlin/String|
public open [ResolvedTo(BODY_RESOLVE)] val foo: R|kotlin/Int|
private final [ResolvedTo(BODY_RESOLVE)] val p: R|A|
public open [ResolvedTo(BODY_RESOLVE)] var R|kotlin/Int|.zoo: R|kotlin/Unit|
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=I] constructor([ResolvedTo(BODY_RESOLVE)] p: R|A|): R|I|
}
@@ -17,7 +17,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 = 93
private const val BINARY_STUB_VERSION = 94
// 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.