From 5c1e42aa512fd8711ced17b52d5d26bc2d91feb8 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Sun, 28 Aug 2016 23:53:38 +0300 Subject: [PATCH] Class literal access supported --- .../search/usagesSearch/destructuringDeclarationUsages.kt | 7 +++++++ .../kotlin/conventions/components/callableReferences.0.kt | 2 ++ .../kotlin/conventions/components/callableReferences.log | 1 + .../conventions/components/callableReferences.results.txt | 1 + 4 files changed, 11 insertions(+) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/destructuringDeclarationUsages.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/destructuringDeclarationUsages.kt index bae61788438..c622830e45f 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/destructuringDeclarationUsages.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/destructuringDeclarationUsages.kt @@ -327,6 +327,13 @@ private class Processor( } } } + + is KtClassLiteralExpression -> { + if (element == parent.receiverExpression) { // ClassName::class + processSuspiciousExpression(element) + return true + } + } } if (element.getStrictParentOfType() != null) return true // ignore usage in import diff --git a/idea/testData/findUsages/kotlin/conventions/components/callableReferences.0.kt b/idea/testData/findUsages/kotlin/conventions/components/callableReferences.0.kt index e431e787dc3..7611fb861dc 100644 --- a/idea/testData/findUsages/kotlin/conventions/components/callableReferences.0.kt +++ b/idea/testData/findUsages/kotlin/conventions/components/callableReferences.0.kt @@ -21,4 +21,6 @@ fun foo(x: X) { val constructor = ::A val (a3, b3) = constructor(1, 2) + + val (a4, b4) = A::class.java.newInstance() } \ No newline at end of file diff --git a/idea/testData/findUsages/kotlin/conventions/components/callableReferences.log b/idea/testData/findUsages/kotlin/conventions/components/callableReferences.log index 7bcdaff658f..5b642852376 100644 --- a/idea/testData/findUsages/kotlin/conventions/components/callableReferences.log +++ b/idea/testData/findUsages/kotlin/conventions/components/callableReferences.log @@ -1,6 +1,7 @@ Checked type of (a1, b1) Checked type of (a2, b2) Checked type of (a3, b3) +Checked type of (a4, b4) Checked type of X.f2() Checked type of constructor Checked type of fun2 diff --git a/idea/testData/findUsages/kotlin/conventions/components/callableReferences.results.txt b/idea/testData/findUsages/kotlin/conventions/components/callableReferences.results.txt index c0ca32a393d..a8748d1b0c6 100644 --- a/idea/testData/findUsages/kotlin/conventions/components/callableReferences.results.txt +++ b/idea/testData/findUsages/kotlin/conventions/components/callableReferences.results.txt @@ -1,3 +1,4 @@ Value read 19 val (a1, b1) = fun2() Value read 20 val (a2, b2) = fun3() Value read 23 val (a3, b3) = constructor(1, 2) +Value read 25 val (a4, b4) = A::class.java.newInstance() \ No newline at end of file