Make the Intl package strong-mode compatible
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=113758046
diff --git a/bin/generate_from_arb.dart b/bin/generate_from_arb.dart
index 06d0809..c5556de 100644
--- a/bin/generate_from_arb.dart
+++ b/bin/generate_from_arb.dart
@@ -110,7 +110,7 @@
}
allLocales.add(locale);
- var translations = [];
+ List<TranslatedMessage> translations = [];
data.forEach((key, value) {
if (value != null) {
translations.add(value);
diff --git a/bin/rewrite_intl_messages.dart b/bin/rewrite_intl_messages.dart
index f983c72..8fc0dd6 100644
--- a/bin/rewrite_intl_messages.dart
+++ b/bin/rewrite_intl_messages.dart
@@ -19,7 +19,7 @@
String outputFile = 'transformed_output.dart';
-main(args) {
+main(List<String> args) {
var parser = new ArgParser();
parser.addOption('output',
defaultsTo: 'transformed_output.dart',
diff --git a/example/basic/basic_example.dart b/example/basic/basic_example.dart
index a58f614..6a22807 100644
--- a/example/basic/basic_example.dart
+++ b/example/basic/basic_example.dart
@@ -25,10 +25,11 @@
/// example we just pass in [print] and for tests we pass in a function that
/// adds it a list to be verified.
Function doThisWithTheOutput;
+typedef ThenList(List l);
-void setup(Function program, Function output) {
+void setup(ThenList program, Function output) {
// Before we use any messages or use date formatting for a locale we must
- // call their initializtion messages, which are asynchronous, since they
+ // call their initialization messages, which are asynchronous, since they
// might be reading information from files or over the web. Since we are
// running here in local mode they will all complete immediately.
doThisWithTheOutput = output;
@@ -50,7 +51,7 @@
// part of our program into a separate function that runs once all the
// futures have completed. We are passed the collection of futures, but we
// don't need to use them, so ignore the parameter.
-runProgram(List<Future> _) {
+runProgram(List _) {
var aDate = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
var de = new Intl('de_DE');
var th = new Intl('th_TH');
diff --git a/lib/date_symbols.dart b/lib/date_symbols.dart
index 66b2fe7..80a0c4d 100644
--- a/lib/date_symbols.dart
+++ b/lib/date_symbols.dart
@@ -54,31 +54,32 @@
// TODO(alanknight): Replace this with use of a more general serialization
// facility once one is available. Issue 4926.
DateSymbols.deserializeFromMap(Map map) {
+ List<String> _getStringList(String name) => new List<String>.from(map[name]);
NAME = map["NAME"];
- ERAS = map["ERAS"];
- ERANAMES = map["ERANAMES"];
- NARROWMONTHS = map["NARROWMONTHS"];
- STANDALONENARROWMONTHS = map["STANDALONENARROWMONTHS"];
- MONTHS = map["MONTHS"];
- STANDALONEMONTHS = map["STANDALONEMONTHS"];
- SHORTMONTHS = map["SHORTMONTHS"];
- STANDALONESHORTMONTHS = map["STANDALONESHORTMONTHS"];
- WEEKDAYS = map["WEEKDAYS"];
- STANDALONEWEEKDAYS = map["STANDALONEWEEKDAYS"];
- SHORTWEEKDAYS = map["SHORTWEEKDAYS"];
- STANDALONESHORTWEEKDAYS = map["STANDALONESHORTWEEKDAYS"];
- NARROWWEEKDAYS = map["NARROWWEEKDAYS"];
- STANDALONENARROWWEEKDAYS = map["STANDALONENARROWWEEKDAYS"];
- SHORTQUARTERS = map["SHORTQUARTERS"];
- QUARTERS = map["QUARTERS"];
- AMPMS = map["AMPMS"];
- DATEFORMATS = map["DATEFORMATS"];
- TIMEFORMATS = map["TIMEFORMATS"];
- AVAILABLEFORMATS = map["AVAILABLEFORMATS"];
+ ERAS = _getStringList("ERAS");
+ ERANAMES = _getStringList("ERANAMES");
+ NARROWMONTHS = _getStringList("NARROWMONTHS");
+ STANDALONENARROWMONTHS = _getStringList("STANDALONENARROWMONTHS");
+ MONTHS = _getStringList("MONTHS");
+ STANDALONEMONTHS = _getStringList("STANDALONEMONTHS");
+ SHORTMONTHS = _getStringList("SHORTMONTHS");
+ STANDALONESHORTMONTHS = _getStringList("STANDALONESHORTMONTHS");
+ WEEKDAYS = _getStringList("WEEKDAYS");
+ STANDALONEWEEKDAYS = _getStringList("STANDALONEWEEKDAYS");
+ SHORTWEEKDAYS = _getStringList("SHORTWEEKDAYS");
+ STANDALONESHORTWEEKDAYS = _getStringList("STANDALONESHORTWEEKDAYS");
+ NARROWWEEKDAYS = _getStringList("NARROWWEEKDAYS");
+ STANDALONENARROWWEEKDAYS = _getStringList("STANDALONENARROWWEEKDAYS");
+ SHORTQUARTERS = _getStringList("SHORTQUARTERS");
+ QUARTERS = _getStringList("QUARTERS");
+ AMPMS = _getStringList("AMPMS");
+ DATEFORMATS = _getStringList("DATEFORMATS");
+ TIMEFORMATS = _getStringList("TIMEFORMATS");
+ AVAILABLEFORMATS = new Map<String, String>.from(map["AVAILABLEFORMATS"] ?? {});
FIRSTDAYOFWEEK = map["FIRSTDAYOFWEEK"];
- WEEKENDRANGE = map["WEEKENDRANGE"];
+ WEEKENDRANGE = new List<int>.from(map["WEEKENDRANGE"]);
FIRSTWEEKCUTOFFDAY = map["FIRSTWEEKCUTOFFDAY"];
- DATETIMEFORMATS = map["DATETIMEFORAMTS"];
+ DATETIMEFORMATS = _getStringList("DATETIMEFORMATS");
}
Map serializeToMap() => {
diff --git a/lib/extract_messages.dart b/lib/extract_messages.dart
index 1b5928c..ff65642 100644
--- a/lib/extract_messages.dart
+++ b/lib/extract_messages.dart
@@ -229,7 +229,8 @@
var extractionResult = extract(message, arguments);
if (extractionResult == null) return null;
- for (var namedArgument in arguments.where((x) => x is NamedExpression)) {
+ for (NamedExpression namedArgument
+ in arguments.where((x) => x is NamedExpression)) {
var name = namedArgument.name.label.name;
var exp = namedArgument.expression;
var evaluator = new ConstantEvaluator();
@@ -259,7 +260,7 @@
"Error at $node");
}
}
- message.messagePieces.addAll(interpolation.pieces);
+ message.messagePieces.addAll(interpolation.pieces as List<Message>);
} on IntlMessageExtractionException catch (e) {
message = null;
var err = new StringBuffer()
diff --git a/lib/generate_localized.dart b/lib/generate_localized.dart
index 1824cdb..75f16e5 100644
--- a/lib/generate_localized.dart
+++ b/lib/generate_localized.dart
@@ -61,11 +61,14 @@
/// The original messages that we are a translation of. There can
/// be more than one original message for the same translation.
- List<MainMessage> originalMessages;
+ List<MainMessage> _originalMessages;
+
+ List<MainMessage> get originalMessages => _originalMessages;
+ set originalMessages(List<MainMessage> x) {_originalMessages = x;}
/// For backward compatibility, we still have the originalMessage API.
MainMessage get originalMessage => originalMessages.first;
- set originalMessage(MainMessage m) => originalMessages = [m];
+ set originalMessage(MainMessage m) {originalMessages = [m];}
TranslatedMessage(this.id, this.translated);
diff --git a/lib/intl.dart b/lib/intl.dart
index 459b4f8..d91b6ba 100644
--- a/lib/intl.dart
+++ b/lib/intl.dart
@@ -94,7 +94,7 @@
var zoneLocale = Zone.current[#Intl.locale];
return zoneLocale == null ? _defaultLocale : zoneLocale;
}
- static set defaultLocale(String newLocale) => _defaultLocale = newLocale;
+ static set defaultLocale(String newLocale) {_defaultLocale = newLocale;}
static String _defaultLocale;
/// The system's locale, as obtained from the window.navigator.language
@@ -158,8 +158,8 @@
/// We may in the future modify the code during compilation to make manually
/// passing those arguments unnecessary.
static String message(String message_str, {String desc: '',
- Map<String, String> examples: const {}, String locale, String name,
- List<String> args, String meaning}) =>
+ Map<String, dynamic> examples: const {}, String locale, String name,
+ List args, String meaning}) =>
_message(message_str, locale, name, args);
/// Omit the compile-time only parameters so dart2js can see to drop them.
diff --git a/lib/intl_standalone.dart b/lib/intl_standalone.dart
index 03bff78..081ff4c 100644
--- a/lib/intl_standalone.dart
+++ b/lib/intl_standalone.dart
@@ -61,7 +61,7 @@
/// Run the "defaults read -g AppleLocale" command and return the output in
/// a future.
-Future _getAppleDefaults() {
+Future<String> _getAppleDefaults() {
var p = Process.run('defaults', ['read', '-g', 'AppleLocale']);
var myResult = p.then((result) => _checkResult(result, _appleDefaultsRegex));
return myResult;
@@ -70,13 +70,13 @@
/// Given [result], find its text and extract the locale from it using [regex],
/// and set it as the system locale. If the process didn't run correctly then
/// don't set the variable and return a future that completes with null.
-Future<String> _checkResult(ProcessResult result, RegExp regex) {
- if (result.exitCode != 0) return new Future.value();
+String _checkResult(ProcessResult result, RegExp regex) {
+ if (result.exitCode != 0) return null;
var match = regex.firstMatch(result.stdout);
- if (match == null) return new Future.value();
+ if (match == null) return null;
var locale = match.group(1);
_setLocale(locale);
- return new Future.value(locale);
+ return locale;
}
/// Set [Intl.systemLocale] to be the canonicalizedLocale of [aLocale].
diff --git a/lib/src/intl/date_format.dart b/lib/src/intl/date_format.dart
index f50bead..bf36a3f 100644
--- a/lib/src/intl/date_format.dart
+++ b/lib/src/intl/date_format.dart
@@ -604,13 +604,13 @@
];
/// Parse the template pattern and return a list of field objects.
- List parsePattern(String pattern) {
+ List<_DateFormatField> parsePattern(String pattern) {
if (pattern == null) return null;
return _parsePatternHelper(pattern).reversed.toList();
}
/// Recursive helper for parsing the template pattern.
- List _parsePatternHelper(String pattern) {
+ List<_DateFormatField> _parsePatternHelper(String pattern) {
if (pattern.isEmpty) return [];
var matched = _match(pattern);
diff --git a/lib/src/intl/number_format.dart b/lib/src/intl/number_format.dart
index adceb19..b31fa91 100644
--- a/lib/src/intl/number_format.dart
+++ b/lib/src/intl/number_format.dart
@@ -619,13 +619,12 @@
/// in the context. Note that the ordering is important here. For example,
/// [symbols.PERCENT] might be " %", and we must handle that before we
/// look at an individual space.
- Map<String, Function> get replacements => _replacements == null
- ? _replacements = _initializeReplacements()
- : _replacements;
+ Map<String, Function> get replacements =>
+ _replacements ??= _initializeReplacements();
- var _replacements;
+ Map<String, Function> _replacements;
- Map _initializeReplacements() => {
+ Map<String, Function> _initializeReplacements() => {
symbols.DECIMAL_SEP: () => '.',
symbols.EXP_SYMBOL: () => 'E',
symbols.GROUP_SEP: handleSpace,
@@ -1068,7 +1067,7 @@
Iterable _iterable(String s) => new _StringIterable(s);
/// Return an iterator on the string as a list of substrings.
-Iterator _iterator(String s) => new _StringIterator(s);
+Iterator<String> _iterator(String s) => new _StringIterator(s);
// TODO(nweiz): remove this when issue 3780 is fixed.
/// Provides an Iterable that wraps [_iterator] so it can be used in a `for`
@@ -1137,12 +1136,12 @@
// overflow on JS when multiplying out the [other] parameter, which may be
// an Int64. In formatting we only ever subtract out our own integer part.
_MicroMoney operator -(other) {
- if (other is MicroMoney) return new _MicroMoney(_micros - other._micros);
+ if (other is _MicroMoney) return new _MicroMoney(_micros - other._micros);
return new _MicroMoney(_micros - (other * _multiplier));
}
_MicroMoney operator +(other) {
- if (other is MicroMoney) return new _MicroMoney(_micros + other._micros);
+ if (other is _MicroMoney) return new _MicroMoney(_micros + other._micros);
return new _MicroMoney(_micros + (other * _multiplier));
}
diff --git a/lib/src/intl_helpers.dart b/lib/src/intl_helpers.dart
index a5b138f..ef5dc92 100644
--- a/lib/src/intl_helpers.dart
+++ b/lib/src/intl_helpers.dart
@@ -23,7 +23,7 @@
String lookupMessage(String message_str, String locale,
String name, List args) => message_str;
- List get keys => _throwException();
+ List<String> get keys => _throwException() as List<String>;
bool containsKey(String key) => (key == 'en_US') ? true : _throwException();
@@ -47,7 +47,7 @@
/// The internal mechanism for looking up messages. We expect this to be set
/// by the implementing package so that we're not dependent on its
/// implementation.
-var messageLookup =
+dynamic messageLookup =
const UninitializedLocaleData('initializeMessages(<locale>)', null);
/// Initialize the message lookup mechanism. This is for internal use only.
diff --git a/lib/src/intl_message.dart b/lib/src/intl_message.dart
index 69afe54..7ff41f2 100644
--- a/lib/src/intl_message.dart
+++ b/lib/src/intl_message.dart
@@ -139,10 +139,10 @@
/// subclass. We expect to get literal Strings, variable substitutions
/// represented by integers, things that are already MessageChunks and
/// lists of the same.
- static Message from(value, Message parent) {
+ static Message from(Object value, Message parent) {
if (value is String) return new LiteralString(value, parent);
if (value is int) return new VariableSubstitution(value, parent);
- if (value is Iterable) {
+ if (value is List) {
if (value.length == 1) return Message.from(value[0], parent);
var result = new CompositeMessage([], parent);
var items = value.map((x) => from(x, result)).toList();
@@ -150,8 +150,9 @@
return result;
}
// We assume this is already a Message.
- value.parent = parent;
- return value;
+ Message mustBeAMessage = value;
+ mustBeAMessage.parent = parent;
+ return mustBeAMessage;
}
/// Return a string representation of this message for use in generated Dart
@@ -164,7 +165,7 @@
/// simple variables ("$foo", but not "${foo}") and Intl.gender/plural
/// calls.
String escapeAndValidateString(String value) {
- const escapes = const {
+ const Map<String, String> escapes = const {
r"\": r"\\",
'"': r'\"',
"\b": r"\b",
@@ -176,7 +177,7 @@
"'": r"\'",
};
- _escape(String s) => (escapes[s] == null) ? s : escapes[s];
+ String _escape(String s) => (escapes[s] == null) ? s : escapes[s];
var escaped = value.splitMapJoin("", onNonMatch: _escape);
return disallowInvalidInterpolations(escaped);
@@ -189,7 +190,7 @@
String disallowInvalidInterpolations(String input) {
var validInterpolations = new RegExp(r"(\$\w+)|(\${\w+})");
var validMatches = validInterpolations.allMatches(input);
- escapeInvalidMatches(Match m) {
+ String escapeInvalidMatches(Match m) {
var valid = validMatches.any((x) => x.start == m.start);
if (valid) {
return m.group(0);
@@ -436,7 +437,7 @@
description = value;
return;
case "examples":
- examples = value;
+ examples = value as Map<String, dynamic>;
return;
case "name":
name = value;
@@ -525,7 +526,7 @@
List<String> get codeAttributeNames;
String expanded([Function transform = _nullTransform]) {
- fullMessageForClause(key) =>
+ fullMessageForClause(String key) =>
key + '{' + transform(parent, this[key]).toString() + '}';
var clauses = attributeNames
.where((key) => this[key] != null)
@@ -720,7 +721,7 @@
/// case they will all be passed in as a Map rather than as the named
/// arguments used in Plural/Gender.
Map argumentsOfInterestFor(MethodInvocation node) {
- var casesArgument = node.argumentList.arguments[1];
+ MapLiteral casesArgument = node.argumentList.arguments[1];
return new Map.fromIterable(casesArgument.entries,
key: (node) => node.key.value, value: (node) => node.value);
}
diff --git a/lib/src/message_rewriter.dart b/lib/src/message_rewriter.dart
index 711c05a..c8ee750 100644
--- a/lib/src/message_rewriter.dart
+++ b/lib/src/message_rewriter.dart
@@ -33,13 +33,13 @@
/// Find all the messages in the [source] text.
///
/// Report errors as coming from [sourceName]
-List<MainMessage> findMessages(String source, String sourceName) {
+List findMessages(String source, String sourceName) {
try {
root = parseCompilationUnit(source, name: sourceName);
} on AnalyzerErrorGroup catch (e) {
print("Error in parsing $sourceName, no messages extracted.");
print(" $e");
- return '';
+ return [];
}
origin = sourceName;
var visitor = new MessageFindingVisitor();
diff --git a/lib/transformer.dart b/lib/transformer.dart
index aa0d303..38dc8d0 100644
--- a/lib/transformer.dart
+++ b/lib/transformer.dart
@@ -8,7 +8,6 @@
import 'package:barback/barback.dart';
-import 'extract_messages.dart';
import 'src/message_rewriter.dart';
/// Rewrites Intl.message calls to automatically insert the name and args
@@ -18,7 +17,7 @@
String get allowedExtensions => ".dart";
- Future apply(Transform transform) async {
+ apply(Transform transform) async {
var content = await transform.primaryInput.readAsString();
var id = transform.primaryInput.id;
var newContent = rewriteMessages(content, '$id');
diff --git a/test/date_time_format_test_core.dart b/test/date_time_format_test_core.dart
index 63ffaab..068ceeb 100644
--- a/test/date_time_format_test_core.dart
+++ b/test/date_time_format_test_core.dart
@@ -168,7 +168,8 @@
/// A shortcut for returning all the locales we have available.
List<String> allLocales() => DateFormat.allLocalesWithSymbols();
-Function _subsetFunc;
+typedef List<String> SubsetFuncType();
+SubsetFuncType _subsetFunc;
List<String> _subsetValue;
@@ -182,7 +183,7 @@
// TODO(alanknight): Run specific tests for the en_ISO locale which isn't
// included in CLDR, and check that our patterns for it are correct (they
// very likely aren't).
-void runDateTests(Function subsetFunc) {
+void runDateTests(SubsetFuncType subsetFunc) {
assert(subsetFunc != null);
_subsetFunc = subsetFunc;
@@ -364,7 +365,8 @@
/// to a Date object. If [year] is a leap year, then pass 1 for
/// [leapDay], otherwise pass 0.
Map<int, DateTime> generateDates(int year, int leapDay) =>
- new Iterable.generate(365 + leapDay, (n) => n + 1).map((day) {
+ new Iterable.generate(365 + leapDay, (n) => n + 1)
+ .map /*<DateTime>*/ ((day) {
var result = new DateTime(year, 1, day);
// TODO(alanknight): This is a workaround for dartbug.com/15560.
if (result.toUtc() == result) result = new DateTime(year, 1, day);
diff --git a/test/date_time_format_test_stub.dart b/test/date_time_format_test_stub.dart
index 9bc355f..52a83a5 100644
--- a/test/date_time_format_test_stub.dart
+++ b/test/date_time_format_test_stub.dart
@@ -24,7 +24,7 @@
}
/// Return a set of a few locales to run just the tests on a small sample.
-List smallSetOfLocales() {
+List<String> smallSetOfLocales() {
return allLocales().sublist(0, 10);
}
diff --git a/test/find_default_locale_browser_test.dart b/test/find_default_locale_browser_test.dart
index 865f86f..f25f7ea 100644
--- a/test/find_default_locale_browser_test.dart
+++ b/test/find_default_locale_browser_test.dart
@@ -17,11 +17,13 @@
// should find a way to force the system locale before the test is run
// and then verify that it's actually the correct value.
Intl.systemLocale = 'xx_YY';
- var callback = expectAsync(verifyLocale);
+ ThenArgument callback = expectAsync(verifyLocale) as ThenArgument;
findSystemLocale().then(callback);
});
}
+typedef ThenArgument(String _);
+
verifyLocale(_) {
expect(Intl.systemLocale, isNot(equals("xx_YY")));
// Allow either en_US or just en type locales. Windows in particular may
diff --git a/test/find_default_locale_standalone_test.dart b/test/find_default_locale_standalone_test.dart
index a89f8ad..14b80b0 100644
--- a/test/find_default_locale_standalone_test.dart
+++ b/test/find_default_locale_standalone_test.dart
@@ -15,11 +15,12 @@
// and then verify that it's actually the correct value.
// We have no way of getting this reliably for Windows, so it will fail.
Intl.systemLocale = "xx_YY";
- var callback = expectAsync(verifyLocale);
+ var callback = expectAsync(verifyLocale) as ThenArgument;
findSystemLocale().then(callback);
});
}
+typedef ThenArgument(String _);
verifyLocale(_) {
expect(Intl.systemLocale, isNot(equals("xx_YY")));
var pattern = new RegExp(r"\w\w_[A-Z0-9]+");
diff --git a/test/intl_message_basic_example_test.dart b/test/intl_message_basic_example_test.dart
index b8265b7..a873b23 100644
--- a/test/intl_message_basic_example_test.dart
+++ b/test/intl_message_basic_example_test.dart
@@ -23,9 +23,9 @@
test('Verify basic example printing localized messages', () {
runAllTests(_) {
- setup(expectAsync(runProgram), addToList);
+ setup(expectAsync(runProgram) as ThenList, addToList);
}
- setup(expectAsync(runAllTests), addToList);
+ setup(expectAsync(runAllTests) as ThenList, addToList);
waitForIt.future.then(expectAsync((_) {
expect(list[0], "Ran at 00:00:00 on Thursday, January 1, 1970");
expect(list[1], "Ausgedruckt am 00:00:00 am Donnerstag, 1. Januar 1970.");
diff --git a/test/message_extraction/embedded_plural_text_after_test.dart b/test/message_extraction/embedded_plural_text_after_test.dart
index 3a53dba..ed9c16f 100644
--- a/test/message_extraction/embedded_plural_text_after_test.dart
+++ b/test/message_extraction/embedded_plural_text_after_test.dart
@@ -9,7 +9,7 @@
main() {
test("Expect failure because of embedded plural with text after it", () {
- var specialFiles = ['embedded_plural_text_after.dart'];
+ List<String> specialFiles = ['embedded_plural_text_after.dart'];
runTestWithWarnings(
warningsAreErrors: true,
expectedExitCode: 1,
diff --git a/test/message_extraction/embedded_plural_text_before_test.dart b/test/message_extraction/embedded_plural_text_before_test.dart
index ebfa1bf..75b411c 100644
--- a/test/message_extraction/embedded_plural_text_before_test.dart
+++ b/test/message_extraction/embedded_plural_text_before_test.dart
@@ -9,7 +9,7 @@
main() {
test("Expect failure because of embedded plural with text before it", () {
- var files = ['embedded_plural_text_before.dart'];
+ List<String> files = ['embedded_plural_text_before.dart'];
runTestWithWarnings(
warningsAreErrors: true,
expectedExitCode: 1,
diff --git a/test/message_extraction/failed_extraction_test.dart b/test/message_extraction/failed_extraction_test.dart
index 51b2c4b..b2758a7 100644
--- a/test/message_extraction/failed_extraction_test.dart
+++ b/test/message_extraction/failed_extraction_test.dart
@@ -13,14 +13,14 @@
});
}
-const defaultFiles = const [
+const List<String> defaultFiles = const [
"sample_with_messages.dart",
"part_of_sample_with_messages.dart"
];
void runTestWithWarnings({bool warningsAreErrors, int expectedExitCode,
bool embeddedPlurals: true, List<String> sourceFiles: defaultFiles}) {
- void verify(ProcessResult result) {
+ verify(ProcessResult result) {
try {
expect(result.exitCode, expectedExitCode);
} finally {
@@ -30,7 +30,7 @@
copyFilesToTempDirectory();
var program = asTestDirPath("../../bin/extract_to_arb.dart");
- var args = ["--output-dir=$tempDir"];
+ List<String> args = ["--output-dir=$tempDir"];
if (warningsAreErrors) {
args.add('--warnings-are-errors');
}
@@ -38,9 +38,12 @@
args.add('--no-embedded-plurals');
}
var files = sourceFiles.map(asTempDirPath).toList();
- var allArgs = [program]
+ List<String> allArgs = [program]
..addAll(args)
..addAll(files);
- var callback = expectAsync(verify);
+ var callback = expectAsync(verify) as ThenArgument;
+
run(null, allArgs).then(callback);
}
+
+typedef dynamic ThenArgument(ProcessResult _);
diff --git a/test/message_extraction/message_extraction_test.dart b/test/message_extraction/message_extraction_test.dart
index 79afb74..d22e1e3 100644
--- a/test/message_extraction/message_extraction_test.dart
+++ b/test/message_extraction/message_extraction_test.dart
@@ -53,6 +53,7 @@
return path.join(tempDir, s);
}
+typedef ProcessResult ThenResult(ProcessResult _);
main(arguments) {
// If debugging, use --local to avoid copying everything to temporary
// directories to make it even harder to debug. Note that this will also
@@ -65,7 +66,7 @@
tearDown(deleteGeneratedFiles);
test("Test round trip message extraction, translation, code generation, "
"and printing", () {
- var makeSureWeVerify = expectAsync(runAndVerify);
+ var makeSureWeVerify = expectAsync(runAndVerify) as ThenResult;
return extractMessages(null).then((result) {
return generateTranslationFiles(result);
}).then((result) {
@@ -114,7 +115,7 @@
.toList();
// Inject the script argument --output-dir in between the script and its
// arguments.
- var args = []
+ List<String> args = []
..addAll(vmArgs)
..add(filesInTheRightDirectory.first)
..addAll(["--output-dir=$tempDir"])
@@ -124,7 +125,7 @@
return result;
}
-void checkResult(ProcessResult previousResult) {
+checkResult(ProcessResult previousResult) {
if (previousResult != null) {
if (previousResult.exitCode != 0) {
print("Error running sub-program:");
diff --git a/test/number_closure_test.dart b/test/number_closure_test.dart
index b7c422a..5f31d2a 100644
--- a/test/number_closure_test.dart
+++ b/test/number_closure_test.dart
@@ -379,9 +379,11 @@
Intl.withLocale("fr", verifyFrenchLocale);
}
+typedef void TimerArgument();
testLocaleSwitchAsync() {
Intl.withLocale("fr", () {
- new Timer(new Duration(milliseconds: 10), expectAsync(verifyFrenchLocale));
+ new Timer(new Duration(milliseconds: 10),
+ expectAsync(verifyFrenchLocale) as TimerArgument);
});
// Verify that things running outside the zone still get en_US.
testStandardFormat();