From a6d80b78de012dfe569b55557c4d56383da44673 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 13 Jun 2017 13:03:08 +0200 Subject: [PATCH] Fix tests --- .../idea/intentions/MovePropertyToConstructorIntention.kt | 7 +++---- .../cantChangeMultipleOverriddenPropertiesTypes.kt | 1 - .../dontChangeOverriddenPropertyTypeToErrorType.kt | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToConstructorIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToConstructorIntention.kt index def81e70cd4..7165ee189a2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToConstructorIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToConstructorIntention.kt @@ -28,13 +28,12 @@ import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import org.jetbrains.kotlin.idea.core.ShortenReferences -import org.jetbrains.kotlin.idea.refactoring.isInterfaceClass import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor import org.jetbrains.kotlin.idea.util.CommentSaver import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.lexer.KtModifierKeywordToken -import org.jetbrains.kotlin.lexer.KtTokens.VARARG_KEYWORD import org.jetbrains.kotlin.lexer.KtTokens.LATEINIT_KEYWORD +import org.jetbrains.kotlin.lexer.KtTokens.VARARG_KEYWORD import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.resolve.AnnotationChecker @@ -56,8 +55,8 @@ class MovePropertyToConstructorIntention : override fun isApplicableTo(element: KtProperty, caretOffset: Int): Boolean { fun KtProperty.isDeclaredInClass() : Boolean { - val parent = element.getStrictParentOfType() - return parent != null && !parent.isInterfaceClass() + val parent = getStrictParentOfType() + return parent is KtClass && !parent.isInterface() } return !element.isLocal diff --git a/idea/testData/quickfix/override/typeMismatchOnOverride/cantChangeMultipleOverriddenPropertiesTypes.kt b/idea/testData/quickfix/override/typeMismatchOnOverride/cantChangeMultipleOverriddenPropertiesTypes.kt index f0045a4bc90..98163105562 100644 --- a/idea/testData/quickfix/override/typeMismatchOnOverride/cantChangeMultipleOverriddenPropertiesTypes.kt +++ b/idea/testData/quickfix/override/typeMismatchOnOverride/cantChangeMultipleOverriddenPropertiesTypes.kt @@ -1,6 +1,5 @@ // "Change type of overriden property 'A.x' to '(Int) -> Int'" "false" // ACTION: Change type to '(String) -> Int' -// ACTION: Move to constructor // ERROR: Type of 'x' is not a subtype of the overridden property 'public abstract val x: (String) -> Int defined in A' interface A { val x: (String) -> Int diff --git a/idea/testData/quickfix/typeMismatch/dontChangeOverriddenPropertyTypeToErrorType.kt b/idea/testData/quickfix/typeMismatch/dontChangeOverriddenPropertyTypeToErrorType.kt index 88b675e3591..e157c9d7639 100644 --- a/idea/testData/quickfix/typeMismatch/dontChangeOverriddenPropertyTypeToErrorType.kt +++ b/idea/testData/quickfix/typeMismatch/dontChangeOverriddenPropertyTypeToErrorType.kt @@ -1,6 +1,5 @@ // "Change type to '(String) -> [ERROR : Ay]'" "false" // ACTION: Change type of base property 'A.x' to '(Int) -> Int' -// ACTION: Move to constructor // ERROR: Type of 'x' is not a subtype of the overridden property 'public abstract val x: (String) -> [ERROR : Ay] defined in A' // ERROR: Unresolved reference: Ay interface A {