Don't show hint for parameter with explicitly specified type

This commit is contained in:
Dmitry Jemerov
2017-04-26 11:10:36 +02:00
parent 7973e033a9
commit 75a1e8f0a2
2 changed files with 11 additions and 1 deletions
@@ -55,7 +55,7 @@ enum class HintType(desc: String, enabled: Boolean) {
}
override fun isApplicable(elem: PsiElement): Boolean = (elem is KtProperty && elem.getReturnTypeReference() == null && elem.isLocal) ||
(elem is KtParameter && elem.isLoopParameter)
(elem is KtParameter && elem.isLoopParameter && elem.typeReference == null)
},
FUNCTION_HINT("Show function return type hints", false) {
@@ -46,4 +46,14 @@ class InlayTypeHintsTest : KotlinLightCodeInsightFixtureTestCase() {
HintType.PROPERTY_HINT.option.set(true)
check("""val a = Any()""")
}
fun testLoopParameter() {
HintType.LOCAL_VARIABLE_HINT.option.set(true)
check("""fun foo() { for (x<hint text=": String" /> in listOf("a")) { } }""")
}
fun testLoopParameterWithExplicitType() {
HintType.LOCAL_VARIABLE_HINT.option.set(true)
check("""fun foo() { for (x: String in listOf("a")) { } }""")
}
}