diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java index 8460ae12c8a..f3c71c4b93d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java @@ -237,6 +237,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { else { facade.getTypeInfo(body, context.replaceScope(context.scope)); } + context.trace.report(UNUSED_FUNCTION_LITERAL.on(function)); } else if (body != null) { WritableScope writableScope = newWritableScopeImpl(context, "do..while body scope"); diff --git a/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt b/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt new file mode 100644 index 00000000000..10edbc1d7ee --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt @@ -0,0 +1,12 @@ +fun unusedLiteral(){ + {() -> + val i = 1 + } +} + + +fun unusedLiteralInDoWhile(){ + do{() -> + val i = 1 + } while(false) +} diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 958c16c1446..7cedb124fa7 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -1849,6 +1849,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/functionLiterals/kt2906.kt"); } + @TestMetadata("unusedLiteral.kt") + public void testUnusedLiteral() throws Exception { + doTest("compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt"); + } + } @TestMetadata("compiler/testData/diagnostics/tests/generics")