-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor strong mode to use standard Analyzer errors
Also changes implicit casts errors to be determined by the type system isAssignableTo code, and updates our tests to show the user-facing error levels (StaticTypeWarningCode is upgraded to errors as far as users can see, but this wasn't visible in the tests, which showed these as "warnings"). found while looking at #26583 R=brianwilkerson@google.com, leafp@google.com Review URL: https://codereview.chromium.org/2060013002 .
- Loading branch information
John Messerly
committed
Jun 13, 2016
1 parent
678cb04
commit 831c875
Showing
13 changed files
with
666 additions
and
820 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
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
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
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,49 @@ | ||
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// Properties that result from Strong Mode analysis on an AST. | ||
/// | ||
/// These properties are not public, but provided by use of back-ends such as | ||
/// Dart Dev Compiler. | ||
import 'package:analyzer/analyzer.dart'; | ||
import 'package:analyzer/dart/element/type.dart'; | ||
|
||
const String _implicitCast = '_implicitCast'; | ||
const String _hasImplicitCasts = '_hasImplicitCasts'; | ||
const String _isDynamicInvoke = '_isDynamicInvoke'; | ||
|
||
/// True if this compilation unit has any implicit casts, otherwise false. | ||
/// | ||
/// See also [getImplicitCast]. | ||
bool hasImplicitCasts(CompilationUnit node) { | ||
return node.getProperty/*<bool>*/(_hasImplicitCasts) ?? false; | ||
} | ||
|
||
/// Sets [hasImplicitCasts] property for this compilation unit. | ||
void setHasImplicitCasts(CompilationUnit node, bool value) { | ||
node.setProperty(_hasImplicitCasts, value == true ? true : null); | ||
} | ||
|
||
/// If this expression has an implicit cast, returns the type it is coerced to, | ||
/// otherwise returns null. | ||
DartType getImplicitCast(Expression node) { | ||
return node.getProperty/*<DartType>*/(_implicitCast); | ||
} | ||
|
||
/// Sets the result of [getImplicitCast] for this node. | ||
void setImplicitCast(Expression node, DartType type) { | ||
node.setProperty(_implicitCast, type); | ||
} | ||
|
||
/// True if this node is a dynamic operation that requires dispatch and/or | ||
/// checking at runtime. | ||
bool isDynamicInvoke(Expression node) { | ||
return node.getProperty/*<bool>*/(_isDynamicInvoke) ?? false; | ||
} | ||
|
||
/// Sets [isDynamicInvoke] property for this expression | ||
void setIsDynamicInvoke(Expression node, bool value) { | ||
node.setProperty(_isDynamicInvoke, value == true ? true : null); | ||
} |
Oops, something went wrong.