diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt index e11e0af94a3..387e13bdb7c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt @@ -48,7 +48,7 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider() { is KtStatementExpression, is KtDestructuringDeclaration -> false is KtIfExpression, is KtWhenExpression, is KtTryExpression -> shouldShowStatementType() is KtLoopExpression -> false - else -> getQualifiedExpressionForSelector() == null + else -> getQualifiedExpressionForSelector() == null && parent !is KtCallableReferenceExpression } private fun KtExpression.shouldShowStatementType(): Boolean { diff --git a/idea/testData/codeInsight/expressionType/MethodReference.kt b/idea/testData/codeInsight/expressionType/MethodReference.kt new file mode 100644 index 00000000000..a0746270a2c --- /dev/null +++ b/idea/testData/codeInsight/expressionType/MethodReference.kt @@ -0,0 +1,9 @@ +fun foo() { +} + +fun bar() { + run(::foo) +} + +// TYPE: ::foo -> KFunction0<Unit> +// TYPE: run(::foo) -> Unit diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/ExpressionTypeTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/ExpressionTypeTestGenerated.java index bdc7519e630..bebb33fb31a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/ExpressionTypeTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/ExpressionTypeTestGenerated.java @@ -65,6 +65,12 @@ public class ExpressionTypeTestGenerated extends AbstractExpressionTypeTest { doTest(fileName); } + @TestMetadata("MethodReference.kt") + public void testMethodReference() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/expressionType/MethodReference.kt"); + doTest(fileName); + } + @TestMetadata("MultiDeclaration.kt") public void testMultiDeclaration() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/expressionType/MultiDeclaration.kt");