Automated g4 rollback of changelist 264686901.
*** Reason for rollback ***
Google Fiber application doesn't build: https://test.corp.google.com/ui#cl=264686901
*** Original change description ***
Make Intl generated code pass most current lint options
Mostly using ignore_for_file, but fixing a few of the most obvious issues
Started out as integrating https://github.com/dart-lang/intl_translation/pull/31 but then expanded.
***
PiperOrigin-RevId: 264727285
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 720558a..0fb2630 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,5 @@
## 0.16.0
* Fix 'k' formatting (1 to 24 hours) which incorrectly showed 0 to 23.
- * Tighten up types in a couple of places.
## 0.15.8
* Add return type to some internal methods to improve dart2js output.
diff --git a/lib/intl.dart b/lib/intl.dart
index 67453c4..5af5d07 100644
--- a/lib/intl.dart
+++ b/lib/intl.dart
@@ -94,7 +94,7 @@
/// [Intl.withLocale] may be preferable if you are using different locales
/// in the same application.
static String get defaultLocale {
- var zoneLocale = Zone.current[#Intl.locale] as String;
+ var zoneLocale = Zone.current[#Intl.locale];
return zoneLocale == null ? _defaultLocale : zoneLocale;
}
@@ -207,9 +207,8 @@
///
/// Note that null is interpreted as meaning the default locale, so if
/// [newLocale] is null the default locale will be returned.
- static String verifiedLocale(
- String newLocale, bool Function(String) localeExists,
- {String Function(String) onFailure: _throwLocaleError}) {
+ static String verifiedLocale(String newLocale, Function localeExists,
+ {Function onFailure: _throwLocaleError}) {
// TODO(alanknight): Previously we kept a single verified locale on the Intl
// object, but with different verification for different uses, that's more
// difficult. As a result, we call this more often. Consider keeping
@@ -341,15 +340,8 @@
/// Internal: Implements the logic for plural selection - use [plural] for
/// normal messages.
- static T pluralLogic<T>(num howMany,
- {T zero,
- T one,
- T two,
- T few,
- T many,
- T other,
- String locale,
- int precision,
+ static pluralLogic(num howMany,
+ {zero, one, two, few, many, other, String locale, int precision,
String meaning}) {
if (other == null) {
throw new ArgumentError("The 'other' named argument must be provided");
@@ -557,10 +549,7 @@
/// desc: 'Say Hello');
/// Intl.withLocale("zh", new Timer(new Duration(milliseconds:10),
/// () => print(hello("World")));
- static dynamic withLocale<T>(String locale, T Function() function) {
- // TODO(alanknight): Make this return T. This requires work because T might
- // be Future and the caller could get an unawaited Future. Which is
- // probably an error in their code, but the change is semi-breaking.
+ static withLocale(String locale, function()) {
var canonical = Intl.canonicalizedLocale(locale);
return runZoned(function, zoneValues: {#Intl.locale: canonical});
}
diff --git a/lib/src/intl/date_format.dart b/lib/src/intl/date_format.dart
index 55901ff..27cc7dc 100644
--- a/lib/src/intl/date_format.dart
+++ b/lib/src/intl/date_format.dart
@@ -277,7 +277,7 @@
/// This will accept dates whose values are not strictly valid, or strings
/// with additional characters (including whitespace) after a valid date. For
/// stricter parsing, use [parseStrict].
- DateTime parse(String inputString, [bool utc = false]) =>
+ DateTime parse(String inputString, [utc = false]) =>
_parse(inputString, utc: utc, strict: false);
/// Given user input, attempt to parse the [inputString] "loosely" into the
@@ -305,7 +305,7 @@
///
/// // "Sept" is not a valid month name.
/// new DateFormat.yMMMd("en_US").parseLoose("Sept 3, 2014");
- DateTime parseLoose(String inputString, [bool utc = false]) {
+ DateTime parseLoose(String inputString, [utc = false]) {
try {
return _parse(inputString, utc: utc, strict: true);
} on FormatException {
@@ -313,7 +313,7 @@
}
}
- DateTime _parseLoose(String inputString, bool utc) {
+ _parseLoose(String inputString, bool utc) {
var dateFields = new _DateBuilder();
if (utc) dateFields.utc = true;
var stream = new _Stream(inputString);
@@ -334,10 +334,10 @@
/// DateTime constructor will accept them. It will also rejct strings with
/// additional characters (including whitespace) after a valid date. For
/// looser parsing, use [parse].
- DateTime parseStrict(String inputString, [bool utc = false]) =>
+ DateTime parseStrict(String inputString, [utc = false]) =>
_parse(inputString, utc: utc, strict: true);
- DateTime _parse(String inputString, {bool utc: false, bool strict: false}) {
+ DateTime _parse(String inputString, {utc: false, strict: false}) {
// TODO(alanknight): The Closure code refers to special parsing of numeric
// values with no delimiters, which we currently don't do. Should we?
var dateFields = new _DateBuilder();
diff --git a/test/fixnum_test.dart b/test/fixnum_test.dart
index 17f5cc2..04e65fc 100644
--- a/test/fixnum_test.dart
+++ b/test/fixnum_test.dart
@@ -80,7 +80,7 @@
test('micro money', () {
microMoneyValues.forEach((number, expected) {
- // ignore: deprecated_member_use_from_same_package
+ // ignore: deprecated_member_use
var currency = new NumberFormat.currencyPattern().format(number);
expect(currency, expected.first);
var percent = new NumberFormat.percentPattern().format(number);
diff --git a/test/number_format_test_core.dart b/test/number_format_test_core.dart
index 9a54071..32f6978 100644
--- a/test/number_format_test_core.dart
+++ b/test/number_format_test_core.dart
@@ -149,7 +149,7 @@
expect(formatted, '€1,000,000.32');
var readBack = usConvention.parse(formatted);
expect(readBack, amount);
- // ignore: deprecated_member_use_from_same_package
+ // ignore: deprecated_member_use
var swissConvention = new NumberFormat.currencyPattern('de_CH', r'$');
formatted = swissConvention.format(amount);
var nbsp = new String.fromCharCode(0xa0);
@@ -159,7 +159,7 @@
readBack = swissConvention.parse(formatted);
expect(readBack, amount);
- // ignore: deprecated_member_use_from_same_package
+ // ignore: deprecated_member_use
var italianSwiss = new NumberFormat.currencyPattern('it_CH', r'$');
formatted = italianSwiss.format(amount);
expect(formatted,
@@ -177,7 +177,7 @@
// Verify that we can pass null in order to specify the currency symbol
// but use the default locale.
- // ignore: deprecated_member_use_from_same_package
+ // ignore: deprecated_member_use
var defaultLocale = new NumberFormat.currencyPattern(null, 'Smurfs');
formatted = defaultLocale.format(amount);
// We don't know what the exact format will be, but it should have Smurfs.