Warning for unused function literal in do..while
This commit is contained in:
+1
@@ -237,6 +237,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
else {
|
else {
|
||||||
facade.getTypeInfo(body, context.replaceScope(context.scope));
|
facade.getTypeInfo(body, context.replaceScope(context.scope));
|
||||||
}
|
}
|
||||||
|
context.trace.report(UNUSED_FUNCTION_LITERAL.on(function));
|
||||||
}
|
}
|
||||||
else if (body != null) {
|
else if (body != null) {
|
||||||
WritableScope writableScope = newWritableScopeImpl(context, "do..while body scope");
|
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");
|
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")
|
@TestMetadata("compiler/testData/diagnostics/tests/generics")
|
||||||
|
|||||||
Reference in New Issue
Block a user