Control Flow: Fix CFG usage info for double-colon expressions
#KT-12551 Fixed #KT-17092 Fixed
This commit is contained in:
@@ -1450,9 +1450,8 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
|||||||
val receiverExpression = expression.receiverExpression
|
val receiverExpression = expression.receiverExpression
|
||||||
if (receiverExpression != null &&
|
if (receiverExpression != null &&
|
||||||
trace.bindingContext.get(BindingContext.DOUBLE_COLON_LHS, receiverExpression) is DoubleColonLHS.Expression) {
|
trace.bindingContext.get(BindingContext.DOUBLE_COLON_LHS, receiverExpression) is DoubleColonLHS.Expression) {
|
||||||
// TODO: UNUSED_EXPRESSION is not reported on the whole expression, see KT-12551
|
|
||||||
generateInstructions(receiverExpression)
|
generateInstructions(receiverExpression)
|
||||||
createSyntheticValue(expression, MagicKind.BOUND_CALLABLE_REFERENCE, receiverExpression)
|
createNonSyntheticValue(expression, MagicKind.BOUND_CALLABLE_REFERENCE, receiverExpression)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
createNonSyntheticValue(expression, MagicKind.UNBOUND_CALLABLE_REFERENCE)
|
createNonSyntheticValue(expression, MagicKind.UNBOUND_CALLABLE_REFERENCE)
|
||||||
|
|||||||
+1
-1
@@ -134,7 +134,7 @@ enum class MagicKind(val sideEffectFree: Boolean = false) {
|
|||||||
IS(),
|
IS(),
|
||||||
CAST(),
|
CAST(),
|
||||||
UNBOUND_CALLABLE_REFERENCE(true),
|
UNBOUND_CALLABLE_REFERENCE(true),
|
||||||
BOUND_CALLABLE_REFERENCE(),
|
BOUND_CALLABLE_REFERENCE(true),
|
||||||
// implicit operations
|
// implicit operations
|
||||||
LOOP_RANGE_ITERATION(),
|
LOOP_RANGE_ITERATION(),
|
||||||
IMPLICIT_RECEIVER(),
|
IMPLICIT_RECEIVER(),
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
fun unusedExpression(s: String) {
|
fun unusedExpression(s: String) {
|
||||||
// TODO: report UNUSED_EXPRESSION (KT-12551)
|
<!UNUSED_EXPRESSION!>s::hashCode<!>
|
||||||
s::hashCode
|
<!UNUSED_EXPRESSION!>s::class<!>
|
||||||
s::class
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun noUnusedParameter(s: String): Int {
|
fun noUnusedParameter(s: String): Int {
|
||||||
@@ -10,13 +9,13 @@ fun noUnusedParameter(s: String): Int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun unreachableCode(): Int {
|
fun unreachableCode(): Int {
|
||||||
(if (true) return 1 else return 0)::toString
|
(if (true) return 1 else return 0)<!UNREACHABLE_CODE!>::toString<!>
|
||||||
<!UNREACHABLE_CODE!>return 0<!>
|
<!UNREACHABLE_CODE!>return 0<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unreachableCodeInLoop(): Int {
|
fun unreachableCodeInLoop(): Int {
|
||||||
while (true) {
|
while (true) {
|
||||||
(break)::toString
|
(break)<!UNREACHABLE_CODE!>::toString<!>
|
||||||
<!UNREACHABLE_CODE!>return 1<!>
|
<!UNREACHABLE_CODE!>return 1<!>
|
||||||
}
|
}
|
||||||
return 2
|
return 2
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ fun f(<!UNUSED_PARAMETER!>x<!>: KClass<out Int>) {}
|
|||||||
fun test() {
|
fun test() {
|
||||||
f(42::class)
|
f(42::class)
|
||||||
f((40 + 2)::class)
|
f((40 + 2)::class)
|
||||||
42::toInt
|
<!UNUSED_EXPRESSION!>42::toInt<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// "Create function 'checkProperty'" "true"
|
||||||
|
internal object model {
|
||||||
|
val layer = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
<caret>checkProperty(model.layer::class)
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
// "Create function 'checkProperty'" "true"
|
||||||
|
internal object model {
|
||||||
|
val layer = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
checkProperty(model.layer::class)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkProperty(kClass: KClass<out String>) {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
@@ -2433,6 +2433,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("callWithClassLiteral.kt")
|
||||||
|
public void testCallWithClassLiteral() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createFunction/call/callWithClassLiteral.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("callWithLambdaArg.kt")
|
@TestMetadata("callWithLambdaArg.kt")
|
||||||
public void testCallWithLambdaArg() throws Exception {
|
public void testCallWithLambdaArg() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createFunction/call/callWithLambdaArg.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createFunction/call/callWithLambdaArg.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user