[DAS] Fixes switch_on_type for dynamic

Fixes: https://github.com/dart-lang/sdk/issues/61355
Change-Id: I306e825a20a93910a72c3208596f6d21d82d1ef3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445921
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
FMorschel
2025-08-19 07:47:37 -07:00
committed by Commit Queue
parent 87b2f50c5c
commit 30fbb28714
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ class _Visitor extends SimpleAstVisitor<void> {
/// Returns `true` if the [type] is assignable to [Type].
bool _isAssignableToType(DartType? type) {
if (type == null) return false;
if (type == null || type is DynamicType) return false;
return context.typeSystem.isAssignableTo(type, _typeType);
}
@@ -60,6 +60,14 @@ void f(Type t) {
);
}
Future<void> test_dynamic() async {
await assertNoDiagnostics('''
void foo(dynamic a) {
switch (a) {}
}
''');
}
Future<void> test_functionToString() async {
await assertNoDiagnostics('''
void f() {