Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3057. Add instance check tests #3078

Merged
merged 3 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions TypeSystem/flow-analysis/reachability_A12_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
/// the case `T` is `R?` and `Null <: S`.
/// @author [email protected]

import '../../Utils/static_type_helper.dart';

main() {
int? i = 2 > 1 ? null : 42;
if (i is Null) {
Null n = i; // Ok
int j = i;
// ^
// [analyzer] unspecified
// [cfe] unspecified
Null n = i;
} else {
i.expectStaticType<Exactly<int>>();
}
}
10 changes: 5 additions & 5 deletions TypeSystem/flow-analysis/reachability_A12_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
/// @description Checks that for expression of the form `E1 is S`
/// `true(N) = promote(E1, S, after(E1))` and
/// `false(N) = promote(E1, factor(T, S), after(E1))`. Test `factor(T, S)` for
/// the case `T` is `R?` and `Null <: S`.
/// the case `T` is `R?` and `S` is not subtype of `Null`.
/// @author [email protected]

import '../../Utils/static_type_helper.dart';

main() {
int? i = 2 > 1 ? null : 42;
if (i is int) {
int j = i;
Null n = i;
// ^
// [analyzer] unspecified
// [cfe] unspecified
} else {
i.expectStaticType<Exactly<Null>>();
}
}
7 changes: 3 additions & 4 deletions TypeSystem/flow-analysis/reachability_A12_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ class C {

test(FutureOr<C> foc) async {
if (foc is Future<C>) {
} else {
foc.foo();
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

main() {
print(test);
test(C());
test(Future<C>.value(C()));
}
4 changes: 3 additions & 1 deletion TypeSystem/flow-analysis/reachability_A12_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
/// @author [email protected]

import 'dart:async';
import '../../Utils/static_type_helper.dart';

class C {
void foo() {}
}

test(FutureOr<C> foc) async {
if (foc is C) {
foc.foo(); // Ok
} else {
foc.expectStaticType<Exactly<Future<C>>>();
}
}

Expand Down