the source for a parameter of the generated copy() function is the corresponding constructor parameter

#KT-8698 Fixed
This commit is contained in:
Dmitry Jemerov
2015-08-21 20:09:47 +02:00
parent 351e1863fc
commit b45af1d47a
4 changed files with 17 additions and 1 deletions
@@ -268,7 +268,7 @@ public class DescriptorResolver {
new ValueParameterDescriptorImpl(functionDescriptor, null, parameter.getIndex(), parameter.getAnnotations(),
parameter.getName(), parameter.getType(),
declaresDefaultValue,
parameter.getVarargElementType(), SourceElement.NO_SOURCE);
parameter.getVarargElementType(), parameter.getSource());
parameterDescriptors.add(parameterDescriptor);
if (declaresDefaultValue) {
trace.record(BindingContext.VALUE_PARAMETER_AS_PROPERTY, parameterDescriptor, propertyDescriptor);
@@ -0,0 +1,6 @@
data class A(val <caret>x: Int)
fun main(args: Array<String>) {
val a = A(x = 1)
val b = a.copy(x = 2)
}
@@ -0,0 +1,6 @@
data class A(val y: Int)
fun main(args: Array<String>) {
val a = A(y = 1)
val b = a.copy(y = 2)
}
@@ -51,6 +51,10 @@ public class SimpleNameReferenceRenameTest extends LightCodeInsightTestCase {
doTest("xyzzy");
}
public void testParameterOfCopyMethod() throws Exception {
doTest("y");
}
private void doTest(String newName) throws Exception {
configureByFile(getTestName(true) + ".kt");
PsiElement element = TargetElementUtilBase