Skip to content

Commit

Permalink
Fix ISE when caret is on parameter of function type
Browse files Browse the repository at this point in the history
EA-68570
  • Loading branch information
udalov committed May 28, 2015
1 parent dff3e17 commit bf09906
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt
Expand Up @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.references.JetReference
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.idea.util.ShortenReferences
Expand Down Expand Up @@ -74,10 +73,11 @@ fun isAutoCreatedItUsage(expression: JetSimpleNameExpression): Boolean {
}

fun JetCallableDeclaration.canRemoveTypeSpecificationByVisibility(): Boolean {
val descriptor = resolveToDescriptor()
val isOverride = getModifierList()?.hasModifier(JetTokens.OVERRIDE_KEYWORD) ?: false
if (!isOverride && (descriptor as? DeclarationDescriptorWithVisibility)?.getVisibility()?.isPublicAPI() ?: false) return false
return true
if (isOverride) return true

val descriptor = analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this]
return descriptor !is DeclarationDescriptorWithVisibility || !descriptor.getVisibility().isPublicAPI()
}

// returns assignment which replaces initializer
Expand Down
@@ -0,0 +1,2 @@
// IS_APPLICABLE: false
fun foo(x: (<caret>String) -> Unit) {}
Expand Up @@ -5671,6 +5671,12 @@ public void testAllFilesPresentInRemoveExplicitType() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/removeExplicitType"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}

@TestMetadata("notOnParameterOfFunctionType.kt")
public void testNotOnParameterOfFunctionType() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/removeExplicitType/notOnParameterOfFunctionType.kt");
doTest(fileName);
}

@TestMetadata("notOnPublic.kt")
public void testNotOnPublic() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/removeExplicitType/notOnPublic.kt");
Expand Down

0 comments on commit bf09906

Please sign in to comment.