mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:20:36 +00:00
[analyzer] Test UNNECESSARY_QUESTION_MARK in patterns
Bug: https://github.com/dart-lang/sdk/issues/51750 Change-Id: I8d27aeb7b8c4ca4ea900e7c9017333f239f59210 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290906 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
5cca9584b2
commit
bf97d18c87
|
@ -29,6 +29,16 @@ dynamic? a;
|
|||
]);
|
||||
}
|
||||
|
||||
test_dynamicQuestionMark_inVariableDeclarationPattern() async {
|
||||
await assertErrorsInCode('''
|
||||
void f(List<Object> a) {
|
||||
var [dynamic? _] = a;
|
||||
}
|
||||
''', [
|
||||
error(WarningCode.UNNECESSARY_QUESTION_MARK, 39, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_Null() async {
|
||||
await assertNoErrorsInCode('''
|
||||
Null a;
|
||||
|
@ -43,6 +53,18 @@ Null? a;
|
|||
]);
|
||||
}
|
||||
|
||||
test_NullQuestionMark_inCastPattern() async {
|
||||
await assertErrorsInCode('''
|
||||
void f(Object a) {
|
||||
switch (a) {
|
||||
case var _ as Null?:
|
||||
}
|
||||
}
|
||||
''', [
|
||||
error(WarningCode.UNNECESSARY_QUESTION_MARK, 56, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_typeAliasQuestionMark() async {
|
||||
await assertNoErrorsInCode('''
|
||||
typedef n = Null;
|
||||
|
|
Loading…
Reference in a new issue