You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pkg/dev_compiler/doc/STATIC_SAFETY.md
+101Lines changed: 101 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -416,6 +416,107 @@ code where a field definition in a subclass shadows the field
416
416
allocated. Users should prefer explicit getters and setters in such
417
417
cases. See [issue 52](https://github.com/dart-lang/dev_compiler/issues/52).
418
418
419
+
## Optional Features
420
+
421
+
### Disable implicit casts (experimental)
422
+
423
+
This is an optional feature of strong mode. It disables implicit down casts. For example:
424
+
425
+
```dart
426
+
main() {
427
+
num n = 0.5;
428
+
int x = n; // error: invalid assignment
429
+
int y = n as int; // ok at compile time, might fail when run
430
+
}
431
+
```
432
+
433
+
Casts from `dynamic` must be explicit as well:
434
+
435
+
```dart
436
+
main() {
437
+
dynamic d = 'hi';
438
+
int x = d; // error: invalid assignment
439
+
int y = d as int; // ok at compile time, might fail when run
440
+
}
441
+
```
442
+
443
+
This option is experimental and may be changed or removed in the future. Feedback is appreciated! Contact us at our [mailing list](https://groups.google.com/a/dartlang.org/forum/#!forum/dev-compiler).
444
+
Try it out in your project by editing .analysis_options:
int x = genericFn(); // okay, inferred genericFn<int>
495
+
}
496
+
497
+
// error: implicit supertype Iterable<dynamic>
498
+
class C extends Iterable { /* ... */ }
499
+
// okay
500
+
class C extends Iterable<dynamic> { /* ... */ }
501
+
```
502
+
503
+
This feature is to prevent accidental use of `dynamic` in code that does not intend to use it.
504
+
505
+
This option is experimental and may be changed or removed in the future. Feedback is appreciated! Contact us at our [mailing list](https://groups.google.com/a/dartlang.org/forum/#!forum/dev-compiler).
506
+
Try it out in your project by editing .analysis_options:
0 commit comments