mirror of
https://github.com/dart-lang/sdk
synced 2024-09-06 00:59:09 +00:00
Issue 52060. Fix reporting CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE for Null vs. nullable FunctionType.
Bug: https://github.com/dart-lang/sdk/issues/52060 Change-Id: I5373a9a73396fbf49562131f5f801d1bceeb65f2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298280 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
b81fd66ed5
commit
00d841ee99
|
@ -478,6 +478,9 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
|
|||
return _canBeEqual(constantType, bound);
|
||||
}
|
||||
} else if (valueType is FunctionType) {
|
||||
if (constantType.isDartCoreNull) {
|
||||
return _typeSystem.isNullable(valueType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -356,6 +356,24 @@ void f(String x) {
|
|||
]);
|
||||
}
|
||||
|
||||
test_Null_functionType() async {
|
||||
await assertErrorsInCode('''
|
||||
void f(void Function() x) {
|
||||
if (x case (null)) {}
|
||||
}
|
||||
''', [
|
||||
error(WarningCode.CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE, 42, 4),
|
||||
]);
|
||||
}
|
||||
|
||||
test_Null_functionTypeQuestion() async {
|
||||
await assertNoErrorsInCode('''
|
||||
void f(void Function()? x) {
|
||||
if (x case (null)) {}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_Null_int() async {
|
||||
await assertErrorsInCode('''
|
||||
void f(int x) {
|
||||
|
|
Loading…
Reference in a new issue