Enable strong-mode for pkg/kernel and fix some strong-mode warnings.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2523673005 .
This commit is contained in:
Asger Feldthaus 2016-11-23 16:16:37 +01:00
parent 5d310431bd
commit d056236180
5 changed files with 20 additions and 16 deletions

View file

@ -1,4 +1,5 @@
analyzer:
strong-mode: true
language:
enableSuperMixins: true
exclude:

View file

@ -262,7 +262,8 @@ Future<CompilerOutcome> batchMain(
String format = options['format'] ?? defaultFormat();
String outputFile = options['out'] ?? defaultOutput();
var customUriMappings = parseCustomUriMappings(options['url-mapping']);
List<String> urlMapping = options['url-mapping'] as List<String>;
var customUriMappings = parseCustomUriMappings(urlMapping);
var repository = new Repository();
Program program;

View file

@ -153,7 +153,7 @@ class SyncStarFunctionRewriter extends ContinuationRewriterBase {
visitYieldStatement(YieldStatement node) {
var transformedExpression = node.expression.accept(this);
var statements = [];
var statements = <Statement>[];
if (node.isYieldStar) {
var markYieldEach = new ExpressionStatement(new PropertySet(
new VariableGet(iteratorVariable),
@ -498,9 +498,8 @@ abstract class AsyncRewriterBase extends ContinuationRewriterBase {
}
loopBody.add(
new IfStatement(cond, new Block(newBody), new BreakStatement(labeled)));
labeled.body =
new WhileStatement(new BoolLiteral(true), new Block(loopBody))
..parent = labeled;
labeled.body = new WhileStatement(
new BoolLiteral(true), new Block(loopBody))..parent = labeled;
statements.add(new Block(<Statement>[]
..addAll(temps)
..add(labeled)));
@ -831,24 +830,28 @@ class HelperNodes {
}
throw 'Library "$name" not found';
}
Class findClass(Library library, String name) {
for (var klass in library.classes) {
if (klass.name == name) return klass;
}
throw 'Class "$name" not found';
}
Procedure findFactoryConstructor(Class klass, String name) {
for (var procedure in klass.procedures) {
if (procedure.isStatic && procedure.name.name == name) return procedure;
}
throw 'Factory constructor "$klass.$name" not found';
}
Constructor findConstructor(Class klass, String name) {
for (var constructor in klass.constructors) {
if (constructor.name.name == name) return constructor;
}
throw 'Constructor "$klass.$name" not found';
}
Procedure findProcedure(Library library, String name) {
for (var procedure in library.procedures) {
if (procedure.name.name == name ||

View file

@ -35,10 +35,8 @@ main(List<String> args) async {
}
Future<bool> areFilesEqual(String first, String second) async {
List<List<int>> bytes = await Future.wait([
new File(first).readAsBytes(),
new File(second).readAsBytes()
]);
List<List<int>> bytes = await Future
.wait([new File(first).readAsBytes(), new File(second).readAsBytes()]);
if (bytes[0].length != bytes[1].length) return false;
for (int i = 0; i < bytes[0].length; ++i) {
if (bytes[0][i] != bytes[1][i]) return false;
@ -58,7 +56,9 @@ testBatchModeConsistency(List<String> options, List<String> files) {
List results = [null, null];
bool failed = false;
for (int i = 0; i < 2; ++i) {
var args = []..addAll(options)..addAll(['--out', outputFiles[i], file]);
var args = <String>[]
..addAll(options)
..addAll(['--out', outputFiles[i], file]);
var state = (i == 0) ? sharedState : new dartk.BatchModeState();
try {
// We run the two executions in a loop to ensure any stack traces

View file

@ -174,8 +174,7 @@ class DartTypeParser {
}
}
void parseParameterList(
List<DartType> positional, List<NamedType> named) {
void parseParameterList(List<DartType> positional, List<NamedType> named) {
int token = scanToken();
assert(token == Token.LeftParen);
token = peekToken();
@ -215,7 +214,7 @@ class DartTypeParser {
types.add(parseType());
token = scanToken();
if (token != Token.Comma && token != close) {
return fail('Unterminated list');
throw fail('Unterminated list');
}
}
return types;
@ -243,7 +242,7 @@ class DartTypeParser {
typeParameters.add(parseAndPushTypeParameter());
token = scanToken();
if (token != Token.Comma && token != Token.RightAngle) {
return fail('Unterminated type parameter list');
throw fail('Unterminated type parameter list');
}
}
return typeParameters;
@ -275,8 +274,8 @@ class DartTypeParser {
class LazyTypeEnvironment {
final Map<String, Class> classes = <String, Class>{};
final Map<String, TypeParameter> typeParameters = <String, TypeParameter>{};
final Library dummyLibrary = new Library(new Uri(path: 'dummy.dart'),
name: 'lib');
final Library dummyLibrary =
new Library(new Uri(path: 'dummy.dart'), name: 'lib');
TreeNode lookup(String name) {
return name.length == 1