[Stubs] Fix stub inconsistency on unnamed setter parameters
If an unused setter parameter was replaced with an underscore ('_'),
it had a special name in the stub ('<anonymous parameter 0>'). The text
version of the stub inserted it as is, leading to an extra
'PsiErrorElement'.
^KTIJ-28194 Fixed
This commit is contained in:
+4
-5
@@ -7,10 +7,12 @@ package org.jetbrains.kotlin.analysis.decompiler.psi.text
|
||||
|
||||
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.analysis.decompiler.stub.computeParameterName
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.contracts.description.ContractProviderKey
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.psi.psiUtil.quoteIfNeeded
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
@@ -128,11 +130,8 @@ fun buildDecompiledText(
|
||||
builder.append(descriptorRenderer.renderAnnotation(annotation))
|
||||
builder.append(" ")
|
||||
}
|
||||
val paramName = when (val name = parameterDescriptor.name) {
|
||||
SpecialNames.IMPLICIT_SET_PARAMETER -> StandardNames.DEFAULT_VALUE_PARAMETER
|
||||
else -> name
|
||||
}
|
||||
builder.append(paramName.asString()).append(": ")
|
||||
val parameterName = computeParameterName(parameterDescriptor.name)
|
||||
builder.append(parameterName.asString()).append(": ")
|
||||
.append(descriptorRenderer.renderType(parameterDescriptor.type))
|
||||
builder.append(")")
|
||||
builder.append(" {").append(DECOMPILED_CODE_COMMENT).append(" }")
|
||||
|
||||
+6
@@ -311,4 +311,10 @@ public class ByDecompiledPsiStubBuilderK2CompilerTestGenerated extends AbstractB
|
||||
public void testTypes() throws Exception {
|
||||
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Types/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("UnderscoreParameterName")
|
||||
public void testUnderscoreParameterName() throws Exception {
|
||||
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/UnderscoreParameterName/");
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -311,4 +311,10 @@ public class ByDecompiledPsiStubBuilderTestGenerated extends AbstractByDecompile
|
||||
public void testTypes() throws Exception {
|
||||
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Types/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("UnderscoreParameterName")
|
||||
public void testUnderscoreParameterName() throws Exception {
|
||||
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/UnderscoreParameterName/");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user