Skip to content

Commit 9876104

Browse files
committed
Prevent labelling proxies of default getters and setters as themselves default getters and setters
1 parent bf581b9 commit 9876104

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ open class KotlinFileExtractor(
488488
val proxyFunctionId = tw.getLabelFor<DbMethod>(getFunctionLabel(f, classId, listOf()))
489489
// We extract the function prototype with its ID overridden to belong to `c` not the companion object,
490490
// but suppress outputting the body, which we will replace with a delegating call below.
491-
forceExtractFunction(f, classId, extractBody = false, extractMethodAndParameterTypeAccesses = extractFunctionBodies, typeSubstitution = null, classTypeArgsIncludingOuterClasses = listOf(), idOverride = proxyFunctionId, locOverride = null)
491+
forceExtractFunction(f, classId, extractBody = false, extractMethodAndParameterTypeAccesses = extractFunctionBodies, typeSubstitution = null, classTypeArgsIncludingOuterClasses = listOf(), idOverride = proxyFunctionId, locOverride = null, extractOrigin = false)
492492
addModifiers(proxyFunctionId, "static")
493493
tw.writeCompiler_generated(proxyFunctionId, CompilerGeneratedKinds.JVMSTATIC_PROXY_METHOD.kind)
494494
if (extractFunctionBodies) {
@@ -813,7 +813,7 @@ open class KotlinFileExtractor(
813813
else
814814
forceExtractFunction(f, parentId, extractBody, extractMethodAndParameterTypeAccesses, typeSubstitution, classTypeArgsIncludingOuterClasses, null, null)
815815

816-
private fun forceExtractFunction(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean, extractMethodAndParameterTypeAccesses: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?, idOverride: Label<DbMethod>?, locOverride: Label<DbLocation>?): Label<out DbCallable> {
816+
private fun forceExtractFunction(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean, extractMethodAndParameterTypeAccesses: Boolean, typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?, idOverride: Label<DbMethod>?, locOverride: Label<DbLocation>?, extractOrigin: Boolean = true): Label<out DbCallable> {
817817
with("function", f) {
818818
DeclarationStackAdjuster(f).use {
819819

@@ -870,13 +870,15 @@ open class KotlinFileExtractor(
870870
val methodId = id.cast<DbMethod>()
871871
tw.writeMethods(methodId, shortName.nameInDB, "${shortName.nameInDB}$paramsSignature", returnType.javaResult.id, parentId, sourceDeclaration.cast<DbMethod>())
872872
tw.writeMethodsKotlinType(methodId, returnType.kotlinResult.id)
873-
when (f.origin) {
874-
IrDeclarationOrigin.GENERATED_DATA_CLASS_MEMBER ->
875-
tw.writeCompiler_generated(methodId, CompilerGeneratedKinds.GENERATED_DATA_CLASS_MEMBER.kind)
876-
IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR ->
877-
tw.writeCompiler_generated(methodId, CompilerGeneratedKinds.DEFAULT_PROPERTY_ACCESSOR.kind)
878-
IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER ->
879-
tw.writeCompiler_generated(methodId, CompilerGeneratedKinds.ENUM_CLASS_SPECIAL_MEMBER.kind)
873+
if (extractOrigin) {
874+
when (f.origin) {
875+
IrDeclarationOrigin.GENERATED_DATA_CLASS_MEMBER ->
876+
tw.writeCompiler_generated(methodId, CompilerGeneratedKinds.GENERATED_DATA_CLASS_MEMBER.kind)
877+
IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR ->
878+
tw.writeCompiler_generated(methodId, CompilerGeneratedKinds.DEFAULT_PROPERTY_ACCESSOR.kind)
879+
IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER ->
880+
tw.writeCompiler_generated(methodId, CompilerGeneratedKinds.ENUM_CLASS_SPECIAL_MEMBER.kind)
881+
}
880882
}
881883

882884
if (extractMethodAndParameterTypeAccesses) {

0 commit comments

Comments
 (0)