-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce documentation for new strict modes
- Loading branch information
Showing
8 changed files
with
117 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
Analyzing analysis... | ||
|
||
error - lib/assignment.dart:11:14 - A value of type 'dynamic' can't be assigned to a variable of type 'String'. Try changing the type of the variable, or casting the right-hand type to 'String'. - invalid_assignment | ||
error - lib/strict_modes.dart:9:14 - A value of type 'dynamic' can't be assigned to a variable of type 'String'. Try changing the type of the variable, or casting the right-hand type to 'String'. - invalid_assignment | ||
info - lib/lint.dart:9:19 - Avoid empty statements. - empty_statements | ||
info - lib/lint.dart:17:7 - Close instances of `dart.core.Sink`. - close_sinks | ||
info - lib/strict_modes.dart:18:7 - The type of dynamicValue can't be inferred without either a type or initializer. Try specifying the type of the variable. - inference_failure_on_uninitialized_variable | ||
info - lib/strict_modes.dart:27:3 - The generic type 'List<dynamic>' should have explicit type arguments but doesn't. Use explicit type arguments for 'List<dynamic>'. - strict_raw_type | ||
|
||
3 issues found. | ||
5 issues found. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
Analyzing analysis... | ||
|
||
error - lib/assignment.dart:11:14 - A value of type 'dynamic' can't be assigned to a variable of type 'String'. Try changing the type of the variable, or casting the right-hand type to 'String'. - invalid_assignment | ||
error - lib/strict_modes.dart:9:14 - A value of type 'dynamic' can't be assigned to a variable of type 'String'. Try changing the type of the variable, or casting the right-hand type to 'String'. - invalid_assignment | ||
info - lib/lint.dart:9:19 - Avoid empty statements. - empty_statements | ||
info - lib/lint.dart:17:7 - Close instances of `dart.core.Sink`. - close_sinks | ||
info - lib/strict_modes.dart:18:7 - The type of dynamicValue can't be inferred without either a type or initializer. Try specifying the type of the variable. - inference_failure_on_uninitialized_variable | ||
info - lib/strict_modes.dart:27:3 - The generic type 'List<dynamic>' should have explicit type arguments but doesn't. Use explicit type arguments for 'List<dynamic>'. - strict_raw_type | ||
|
||
3 issues found. | ||
5 issues found. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
Analyzing analysis... | ||
|
||
error - lib/assignment.dart:11:14 - A value of type 'dynamic' can't be assigned to a variable of type 'String'. Try changing the type of the variable, or casting the right-hand type to 'String'. - invalid_assignment | ||
error - lib/strict_modes.dart:9:14 - A value of type 'dynamic' can't be assigned to a variable of type 'String'. Try changing the type of the variable, or casting the right-hand type to 'String'. - invalid_assignment | ||
info - lib/lint.dart:9:19 - Avoid empty statements. - empty_statements | ||
info - lib/lint.dart:17:7 - Close instances of `dart.core.Sink`. - close_sinks | ||
info - lib/strict_modes.dart:18:7 - The type of dynamicValue can't be inferred without either a type or initializer. Try specifying the type of the variable. - inference_failure_on_uninitialized_variable | ||
info - lib/strict_modes.dart:27:3 - The generic type 'List<dynamic>' should have explicit type arguments but doesn't. Use explicit type arguments for 'List<dynamic>'. - strict_raw_type | ||
|
||
3 issues found. | ||
5 issues found. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// ignore_for_file: dead_code, prefer_typing_uninitialized_variables | ||
|
||
import 'package:examples_util/ellipsis.dart'; | ||
|
||
String strictCasts() { | ||
// #docregion strict-casts | ||
dynamic o = ellipsis<String>(); | ||
// ignore: stable, beta, dev, invalid_assignment | ||
String s = o; // Implicit downcast | ||
String s2 = s.substring(1); | ||
// #enddocregion strict-casts | ||
return s2; | ||
} | ||
|
||
void strictInference() { | ||
// #docregion strict-inference | ||
// ignore: stable, beta, dev, inference_failure_on_uninitialized_variable | ||
var dynamicValue; | ||
dynamicValue.add(1); | ||
dynamicValue.add(2); | ||
// #enddocregion strict-inference | ||
} | ||
|
||
void strictRawTypes() { | ||
// #docregion strict-raw-types | ||
// ignore: stable, beta, dev, strict_raw_type | ||
List numbers = [1, 2, 3]; // List with raw type | ||
for (final n in numbers) { | ||
print(n.length); // Runtime error | ||
} | ||
// #enddocregion strict-raw-types | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters