-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed as not planned
Labels
area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.model-flowImplementation of flow analysis in analyzer/cfeImplementation of flow analysis in analyzer/cfe
Description
Promotion via type test is specified as:
- We say that a variable
xis promotable via type test with typeTgiven variable modelVMif
VM = VariableModel(declared, promoted, tested, assigned, unassigned, captured)- and captured is
false- and
Sis the current type ofxinVM- and not
S <: T- and
T <: Sor (SisX extends RandT <: R) or (SisX & RandT <: R)
According to the above we should be able to promote any type to type Never. But we cannot.
main() {
String s = "a";
if (s is Never) {
s.expectStaticType<Exactly<Never>>(); // Error: 'Exactly<Never>' doesn't conform to the bound 'Exactly<String>' of the type parameter 'R'.
}
}
extension StaticType<T> on T {
T expectStaticType<R extends Exactly<T>>() {
return this;
}
}
typedef Exactly<T> = T Function(T);Yes, s.expectStaticType<...>(...) is dead code, but according to the spec it should work.
Dart SDK version: 3.9.0-74.0.dev (dev) (Tue Apr 29 21:02:55 2025 -0700) on "windows_x64"
Metadata
Metadata
Assignees
Labels
area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.model-flowImplementation of flow analysis in analyzer/cfeImplementation of flow analysis in analyzer/cfe