Fix "unexpected error type" exception in constructor conversion
So #KT-20218 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
13fc526695
commit
faaddacec6
+5
-1
@@ -72,7 +72,11 @@ class ConvertPrimaryConstructorToSecondaryIntention : SelfTargetingIntention<KtP
|
||||
for (property in klass.getProperties()) {
|
||||
if (property.isIndependent(klass, context)) continue
|
||||
if (property.typeReference == null) {
|
||||
SpecifyTypeExplicitlyIntention().applyTo(property, editor)
|
||||
with (SpecifyTypeExplicitlyIntention()) {
|
||||
if (applicabilityRange(property) != null) {
|
||||
applyTo(property, editor)
|
||||
}
|
||||
}
|
||||
}
|
||||
val initializer = property.initializer!!
|
||||
initializerMap[property] = initializer.text
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// SKIP_ERRORS_BEFORE
|
||||
// SKIP_ERRORS_AFTER
|
||||
|
||||
class Foo(val <caret>arg: Int) {
|
||||
val arg = arg
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// SKIP_ERRORS_BEFORE
|
||||
// SKIP_ERRORS_AFTER
|
||||
|
||||
class Foo {
|
||||
val arg: Int
|
||||
|
||||
constructor(arg: Int) {
|
||||
this.arg = arg
|
||||
this.arg = arg
|
||||
}
|
||||
|
||||
val arg
|
||||
}
|
||||
@@ -5534,6 +5534,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("errorType.kt")
|
||||
public void testErrorType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertPrimaryConstructorToSecondary/errorType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("independentProperty.kt")
|
||||
public void testIndependentProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertPrimaryConstructorToSecondary/independentProperty.kt");
|
||||
|
||||
Reference in New Issue
Block a user