From a86ec25ffb90cbbe389ea6c4a22f33248deb70d0 Mon Sep 17 00:00:00 2001 From: pq Date: Mon, 3 Jun 2024 21:45:12 +0000 Subject: [PATCH] wildcard variable test for `unused_result` validation We talked about migrating these tests to using language version overrides but I lost the plot over the weekend :). Can you suggest how I'd modify this? How would I opt into this feature with a language version override if there is not version in which we have it enabled? Change-Id: Ie0411d8f24e7468692a99cc2bc645bdbd3d5a500 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369420 Auto-Submit: Phil Quitslund Commit-Queue: Brian Wilkerson Reviewed-by: Brian Wilkerson --- .../src/diagnostics/unused_result_test.dart | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pkg/analyzer/test/src/diagnostics/unused_result_test.dart b/pkg/analyzer/test/src/diagnostics/unused_result_test.dart index a1ee5538b2c..7b6a01bc617 100644 --- a/pkg/analyzer/test/src/diagnostics/unused_result_test.dart +++ b/pkg/analyzer/test/src/diagnostics/unused_result_test.dart @@ -746,6 +746,39 @@ void main() { '''); } + test_method_result_assigned_wildcard_unused() async { + await assertNoErrorsInCode(r''' +import 'package:meta/meta.dart'; + +class A { + @useResult + int foo() => 0; +} + +void main() { + var _ = A().foo(); +} +'''); + } + + test_method_result_assigned_wildcard_unused_preWildcards() async { + await assertNoErrorsInCode(r''' +// @dart = 3.4 +// (pre wildcard-variables) + +import 'package:meta/meta.dart'; + +class A { + @useResult + int foo() => 0; +} + +void main() { + var _ = A().foo(); +} +'''); + } + test_method_result_binaryExpression() async { await assertNoErrorsInCode(''' import 'package:meta/meta.dart';