From af043843b7d09a409297f1ef4ec7b88f3bf1e144 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 16 May 2017 16:22:29 +0200 Subject: [PATCH] Don't show disambiguation for "Show expression type" on "this" #KT-17840 Fixed --- .../kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt | 1 + idea/testData/codeInsight/expressionType/ThisInLambda.kt | 5 +++++ .../idea/codeInsight/ExpressionTypeTestGenerated.java | 6 ++++++ 3 files changed, 12 insertions(+) create mode 100644 idea/testData/codeInsight/expressionType/ThisInLambda.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt index ef97208084f..ff650c34be5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt @@ -74,6 +74,7 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider() { is KtIfExpression, is KtWhenExpression, is KtTryExpression -> shouldShowStatementType() is KtLoopExpression -> false is KtConstantExpression -> false + is KtThisExpression -> false else -> getQualifiedExpressionForSelector() == null && parent !is KtCallableReferenceExpression && !isFunctionCallee() } diff --git a/idea/testData/codeInsight/expressionType/ThisInLambda.kt b/idea/testData/codeInsight/expressionType/ThisInLambda.kt new file mode 100644 index 00000000000..8d38fa9ebba --- /dev/null +++ b/idea/testData/codeInsight/expressionType/ThisInLambda.kt @@ -0,0 +1,5 @@ +val x = 1.apply { + this +} + +// TYPE: this -> Int diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/ExpressionTypeTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/ExpressionTypeTestGenerated.java index a8d7ad40c80..4c623c6d918 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/ExpressionTypeTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/ExpressionTypeTestGenerated.java @@ -126,6 +126,12 @@ public class ExpressionTypeTestGenerated extends AbstractExpressionTypeTest { doTest(fileName); } + @TestMetadata("ThisInLambda.kt") + public void testThisInLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/expressionType/ThisInLambda.kt"); + doTest(fileName); + } + @TestMetadata("VariableDeclaration.kt") public void testVariableDeclaration() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/expressionType/VariableDeclaration.kt");