diff --git a/lib/src/lints/proper_super_calls/visitors/proper_super_calls_visitor.dart b/lib/src/lints/proper_super_calls/visitors/proper_super_calls_visitor.dart index 6cbe4759..871938ad 100644 --- a/lib/src/lints/proper_super_calls/visitors/proper_super_calls_visitor.dart +++ b/lib/src/lints/proper_super_calls/visitors/proper_super_calls_visitor.dart @@ -103,7 +103,10 @@ class ProperSuperCallsVisitor extends SimpleAstVisitor { return false; } - final expression = statement.expression; + var expression = statement.expression.unParenthesized; + if (expression is AwaitExpression) { + expression = expression.expression.unParenthesized; + } return expression is MethodInvocation && expression.target is SuperExpression && diff --git a/test/lints/proper_super_calls/proper_super_calls_rule_test.dart b/test/lints/proper_super_calls/proper_super_calls_rule_test.dart index 8969e73c..c043945c 100644 --- a/test/lints/proper_super_calls/proper_super_calls_rule_test.dart +++ b/test/lints/proper_super_calls/proper_super_calls_rule_test.dart @@ -164,6 +164,54 @@ class MyWidgetState extends State { super.initState(); } } +''', + ); + } + + void test_no_report_for_async_correct_usage() async { + await assertNoDiagnostics( + r''' +import 'package:flutter/src/widgets/framework.dart'; + +class MyWidgetState extends State { + @override + Future initState() async { + // ignore: use_of_void_result + await super.initState(); + print(''); + } + + @override + Future dispose() async { + print(''); + // ignore: use_of_void_result + await super.dispose(); + } +} +''', + ); + } + + void test_no_report_for_parenthesized_and_async_correct_usage() async { + await assertNoDiagnostics( + r''' +import 'package:flutter/src/widgets/framework.dart'; + +class MyWidgetState extends State { + @override + Future initState() async { + // ignore: use_of_void_result + await (super.initState()); + print(''); + } + + @override + Future dispose() async { + print(''); + // ignore: use_of_void_result + (await super.dispose()); + } +} ''', ); }