Warning for unused function literal in do..while

This commit is contained in:
Mikhael Bogdanov
2013-03-20 11:33:48 +04:00
parent 8e5f0abb84
commit 79bf174e93
3 changed files with 18 additions and 0 deletions
@@ -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");
@@ -0,0 +1,12 @@
fun unusedLiteral(){
<!UNUSED_FUNCTION_LITERAL!>{() ->
val <!UNUSED_VARIABLE!>i<!> = 1
}<!>
}
fun unusedLiteralInDoWhile(){
do<!UNUSED_FUNCTION_LITERAL!>{() ->
val <!UNUSED_VARIABLE!>i<!> = 1
}<!> while(false)
}
@@ -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")