diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt index c3343a1673e..ca2c1924cc0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt @@ -1450,9 +1450,8 @@ class ControlFlowProcessor(private val trace: BindingTrace) { val receiverExpression = expression.receiverExpression if (receiverExpression != null && 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) - createSyntheticValue(expression, MagicKind.BOUND_CALLABLE_REFERENCE, receiverExpression) + createNonSyntheticValue(expression, MagicKind.BOUND_CALLABLE_REFERENCE, receiverExpression) } else { createNonSyntheticValue(expression, MagicKind.UNBOUND_CALLABLE_REFERENCE) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt index 4e909d9d555..792e65653de 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt @@ -134,7 +134,7 @@ enum class MagicKind(val sideEffectFree: Boolean = false) { IS(), CAST(), UNBOUND_CALLABLE_REFERENCE(true), - BOUND_CALLABLE_REFERENCE(), + BOUND_CALLABLE_REFERENCE(true), // implicit operations LOOP_RANGE_ITERATION(), IMPLICIT_RECEIVER(), diff --git a/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.kt b/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.kt index 03620a34f60..6771eeb1573 100644 --- a/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.kt +++ b/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.kt @@ -1,7 +1,6 @@ fun unusedExpression(s: String) { - // TODO: report UNUSED_EXPRESSION (KT-12551) - s::hashCode - s::class + s::hashCode + s::class } fun noUnusedParameter(s: String): Int { @@ -10,13 +9,13 @@ fun noUnusedParameter(s: String): Int { } fun unreachableCode(): Int { - (if (true) return 1 else return 0)::toString + (if (true) return 1 else return 0)::toString return 0 } fun unreachableCodeInLoop(): Int { while (true) { - (break)::toString + (break)::toString return 1 } return 2 diff --git a/compiler/testData/diagnostics/tests/classLiteral/integerValueType.kt b/compiler/testData/diagnostics/tests/classLiteral/integerValueType.kt index 056cd23e846..90d7c450ce7 100644 --- a/compiler/testData/diagnostics/tests/classLiteral/integerValueType.kt +++ b/compiler/testData/diagnostics/tests/classLiteral/integerValueType.kt @@ -7,5 +7,5 @@ fun f(x: KClass) {} fun test() { f(42::class) f((40 + 2)::class) - 42::toInt + 42::toInt } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/call/callWithClassLiteral.kt b/idea/testData/quickfix/createFromUsage/createFunction/call/callWithClassLiteral.kt new file mode 100644 index 00000000000..3cdf1e81aea --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createFunction/call/callWithClassLiteral.kt @@ -0,0 +1,8 @@ +// "Create function 'checkProperty'" "true" +internal object model { + val layer = "" +} + +fun main(args: Array) { + checkProperty(model.layer::class) +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createFunction/call/callWithClassLiteral.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/call/callWithClassLiteral.kt.after new file mode 100644 index 00000000000..62f63d019df --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createFunction/call/callWithClassLiteral.kt.after @@ -0,0 +1,14 @@ +import kotlin.reflect.KClass + +// "Create function 'checkProperty'" "true" +internal object model { + val layer = "" +} + +fun main(args: Array) { + checkProperty(model.layer::class) +} + +fun checkProperty(kClass: KClass) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 75eb3bbba4e..b8f802d986c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -2433,6 +2433,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { 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") public void testCallWithLambdaArg() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createFunction/call/callWithLambdaArg.kt");