Data class copy method invocation gives errors in IDE when some optional parameters specified (KT-5975)
#KT-5975 Fixed
This commit is contained in:
+7
-3
@@ -190,9 +190,13 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
|
||||
}
|
||||
|
||||
if (name.equals(DescriptorResolver.COPY_METHOD_NAME)) {
|
||||
SimpleFunctionDescriptor copyFunctionDescriptor = DescriptorResolver.createCopyFunctionDescriptor(
|
||||
constructor.getValueParameters(),
|
||||
thisDescriptor, trace);
|
||||
for (ValueParameterDescriptor parameter : constructor.getValueParameters()) {
|
||||
// force properties resolution to fill BindingContext.VALUE_PARAMETER_AS_PROPERTY slice
|
||||
getProperties(parameter.getName());
|
||||
}
|
||||
|
||||
SimpleFunctionDescriptor copyFunctionDescriptor =
|
||||
DescriptorResolver.createCopyFunctionDescriptor(constructor.getValueParameters(), thisDescriptor, trace);
|
||||
result.add(copyFunctionDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package copytest
|
||||
|
||||
import dataclass.Settings
|
||||
|
||||
fun foo(s: Settings) {
|
||||
s.copy(1, 32)
|
||||
s.copy(1)
|
||||
}
|
||||
|
||||
// KT-5975 data class copy method invocation gives errors in IDE when some optional parameters specified
|
||||
/* Resolution of copy was called before parameters resolve */
|
||||
@@ -0,0 +1,3 @@
|
||||
package dataclass
|
||||
|
||||
data class Settings(b: Int = 1, val a: Int)
|
||||
@@ -38,6 +38,12 @@ public class MultiFileHighlightingTestGenerated extends AbstractMultiFileHighlig
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/multiFileHighlighting"), Pattern.compile("^(.+)\\.kt$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("copyResolveBeforeParams.kt")
|
||||
public void testCopyResolveBeforeParams() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/multiFileHighlighting/copyResolveBeforeParams.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("delegatesReference.kt")
|
||||
public void testDelegatesReference() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/multiFileHighlighting/delegatesReference.kt");
|
||||
|
||||
Reference in New Issue
Block a user