diff --git a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/TypeHints.kt b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/TypeHints.kt index c4a076ddffd..21d6154be9f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/TypeHints.kt +++ b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/TypeHints.kt @@ -19,9 +19,11 @@ package org.jetbrains.kotlin.idea.parameterInfo import com.intellij.codeInsight.hints.InlayInfo import com.intellij.psi.PsiElement import com.intellij.psi.codeStyle.CodeStyleSettingsManager +import org.jetbrains.kotlin.descriptors.ConstructorDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention -import org.jetbrains.kotlin.psi.KtCallableDeclaration +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.renderer.RenderingFormat @@ -46,7 +48,7 @@ fun providePropertyTypeHint(elem: PsiElement): List { fun provideTypeHint(element: KtCallableDeclaration, offset: Int): List { val type = SpecifyTypeExplicitlyIntention.getTypeForDeclaration(element) - return if (!type.isError) { + return if (!type.isError && isUnclearType(type, element)) { val settings = CodeStyleSettingsManager.getInstance(element.project).currentSettings .getCustomSettings(KotlinCodeStyleSettings::class.java) @@ -66,3 +68,18 @@ fun provideTypeHint(element: KtCallableDeclaration, offset: Int): List = listOf("a") }""") + } + + fun testPropertyType() { + HintType.PROPERTY_HINT.option.set(true) + check("""val a = listOf("a")""") + } + + fun testConstInitializerType() { + HintType.PROPERTY_HINT.option.set(true) + check("""val a = 1""") + } + + fun testConstructorWithoutTypeParametersType() { + HintType.PROPERTY_HINT.option.set(true) + check("""val a = Any()""") + } +} \ No newline at end of file