Skip to content

Commit e0c776b

Browse files
authored
Disable implicit casts (flutter#61)
1 parent 13e7010 commit e0c776b

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

analysis_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
analyzer:
2+
strong-mode:
3+
implicit-casts: false
14
linter:
25
rules:
36
- prefer_equal_for_default_values

lib/src/chain.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class Chain implements StackTrace {
4747
final List<Trace> traces;
4848

4949
/// The [StackZoneSpecification] for the current zone.
50-
static StackZoneSpecification get _currentSpec => Zone.current[_specKey];
50+
static StackZoneSpecification get _currentSpec =>
51+
Zone.current[_specKey] as StackZoneSpecification;
5152

5253
/// If [when] is `true`, runs [callback] in a [Zone] in which the current
5354
/// stack chain is tracked and automatically associated with (most) errors.
@@ -81,7 +82,7 @@ class Chain implements StackTrace {
8182
}
8283

8384
if (!when) {
84-
var newOnError;
85+
void Function(Object, StackTrace) newOnError;
8586
if (onError != null) {
8687
newOnError = (error, stackTrace) {
8788
onError(

lib/src/frame.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class Frame {
165165

166166
// v8 location strings can be arbitrarily-nested, since it adds a layer
167167
// of nesting for each eval performed on that line.
168-
parseLocation(location, member) {
168+
Frame parseLocation(String location, String member) {
169169
var evalMatch = _v8EvalLocation.firstMatch(location);
170170
while (evalMatch != null) {
171171
location = evalMatch[1];
@@ -240,7 +240,7 @@ class Frame {
240240
// Normally this is a URI, but in a jsshell trace it can be a path.
241241
var uri = _uriOrPathToUri(match[3]);
242242

243-
var member;
243+
String member;
244244
if (match[1] != null) {
245245
member = match[1];
246246
member +=

lib/src/stack_zone_specification.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class StackZoneSpecification {
133133
/// Tracks the current stack chain so it can be set to [_currentChain] when
134134
/// [f] is run.
135135
ZoneBinaryCallback<R, T1, T2> _registerBinaryCallback<R, T1, T2>(
136-
Zone self, ZoneDelegate parent, Zone zone, Function f) {
136+
Zone self, ZoneDelegate parent, Zone zone, R Function(T1, T2) f) {
137137
if (f == null || _disabled) return parent.registerBinaryCallback(zone, f);
138138

139139
var node = _createNode(1);

test/chain/dart2js_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ void main() {
305305
test(
306306
'called for an unregistered stack trace returns a chain wrapping that '
307307
'trace', () {
308-
var trace;
308+
StackTrace trace;
309309
var chain = Chain.capture(() {
310310
try {
311311
throw 'error';
@@ -324,7 +324,7 @@ void main() {
324324
test(
325325
'forTrace() outside of capture() returns a chain wrapping the given '
326326
'trace', () {
327-
var trace;
327+
StackTrace trace;
328328
var chain = Chain.capture(() {
329329
try {
330330
throw 'error';

test/chain/utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Future<Chain> chainForTrace(asyncFn(callback()), callback()) {
7474
});
7575

7676
return completer.future
77-
.catchError((_, stackTrace) => Chain.forTrace(stackTrace));
77+
.catchError((_, StackTrace stackTrace) => Chain.forTrace(stackTrace));
7878
}
7979

8080
/// Runs [callback] in a [Chain.capture] zone and returns a Future that

test/chain/vm_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ void main() {
481481
'chain', () {
482482
// Disable the test package's chain-tracking.
483483
return Chain.disable(() async {
484-
var trace;
484+
StackTrace trace;
485485
await Chain.capture(() async {
486486
try {
487487
throw 'error';

0 commit comments

Comments
 (0)