From 2141cd268cbe101ad47b77ff8c5c100dd8588213 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 26 Aug 2016 12:42:09 +0200 Subject: [PATCH] don't include properties with declared return type and property accessors in "show expression type" popup --- .../kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt | 4 +++- .../testData/codeInsight/expressionType/PropertyAccessor.kt | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 idea/testData/codeInsight/expressionType/PropertyAccessor.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt index 7d7d2fbc9df..d028c3279f6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt @@ -37,7 +37,9 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider() { private fun KtExpression.shouldShowType() = when(this) { is KtFunction -> !hasBlockBody() && !hasDeclaredReturnType() - is KtProperty, is KtDestructuringDeclarationEntry -> true + is KtProperty -> typeReference == null + is KtPropertyAccessor -> false + is KtDestructuringDeclarationEntry -> true is KtStatementExpression, is KtDestructuringDeclaration -> false is KtIfExpression, is KtLoopExpression, is KtWhenExpression, is KtTryExpression -> parent !is KtBlockExpression else -> true diff --git a/idea/testData/codeInsight/expressionType/PropertyAccessor.kt b/idea/testData/codeInsight/expressionType/PropertyAccessor.kt new file mode 100644 index 00000000000..6626297c35a --- /dev/null +++ b/idea/testData/codeInsight/expressionType/PropertyAccessor.kt @@ -0,0 +1,6 @@ +class A { + val x: String + get() = "abc" +} + +// TYPE: "abc" -> String