Replace (implicit and explicit) dynamic with Object in public APIs.
This is to better comply with Effective Dart's recommendation [1], and in particular to reduce noisy implicit dynamic errors from teams working with the `--no-implicit-dynamic` flag.
Fixes https://github.com/dart-lang/intl/issues/197
[1] https://www.dartlang.org/guides/language/effective-dart/design#do-annotate-with-object-instead-of-dynamic-to-indicate-any-object-is-allowed
K2SO=global
Tested=https://test.corp.google.com/OCL:229260260:BASE:229300284:1547522871991:6e440cfa
PiperOrigin-RevId: 229489543
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7cebec1..c84b7d6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
## 0.15.8
* Add return type to some internal methods to improve dart2js output.
+ * Change parameter types in some public methods from dynamic (implicit or
+ explicit) to Object. In particular, the examples and args parameters on
+ Intl.message, Intl.plural, Intl.gender, and Intl.select, as well as the args
+ parameter on MessageLookup.
## 0.15.7
* Upate to require Dart 2.0. Remove deprecated calls,
diff --git a/lib/intl.dart b/lib/intl.dart
index 0b201b5..b8abcfa 100644
--- a/lib/intl.dart
+++ b/lib/intl.dart
@@ -173,17 +173,17 @@
/// the placeholder automatically translated.
static String message(String message_str,
{String desc: '',
- Map<String, dynamic> examples: const {},
+ Map<String, Object> examples: const {},
String locale,
String name,
- List args,
+ List<Object> args,
String meaning,
bool skip}) =>
_message(message_str, locale, name, args, meaning);
/// Omit the compile-time only parameters so dart2js can see to drop them.
static String _message(String message_str, String locale, String name,
- List args, String meaning) {
+ List<Object> args, String meaning) {
return messageLookup.lookupMessage(
message_str, locale, name, args, meaning);
}
@@ -279,10 +279,10 @@
String many,
String other,
String desc,
- Map<String, dynamic> examples,
+ Map<String, Object> examples,
String locale,
String name,
- List args,
+ List<Object> args,
String meaning,
bool skip}) {
// Call our internal method, dropping examples and desc because they're not
@@ -309,7 +309,7 @@
String other,
String locale,
String name,
- List args,
+ List<Object> args,
String meaning}) {
// Look up our translation, but pass in a null message so we don't have to
// eagerly evaluate calls that may not be necessary.
@@ -391,10 +391,10 @@
String male,
String other,
String desc,
- Map<String, dynamic> examples,
+ Map<String, Object> examples,
String locale,
String name,
- List args,
+ List<Object> args,
String meaning,
bool skip}) {
// Call our internal method, dropping args and desc because they're not used
@@ -414,10 +414,10 @@
String male,
String other,
String desc,
- Map<String, dynamic> examples,
+ Map<String, Object> examples,
String locale,
String name,
- List args,
+ List<Object> args,
String meaning}) {
// Look up our translation, but pass in a null message so we don't have to
// eagerly evaluate calls that may not be necessary.
@@ -453,10 +453,10 @@
/// of an Intl.message message that is to be translated.
static String select(Object choice, Map<String, String> cases,
{String desc,
- Map<String, dynamic> examples,
+ Map<String, Object> examples,
String locale,
String name,
- List args,
+ List<Object> args,
String meaning,
bool skip}) {
return _select(choice, cases,
@@ -464,7 +464,7 @@
}
static String _select(Object choice, Map<String, String> cases,
- {String locale, String name, List args, String meaning}) {
+ {String locale, String name, List<Object> args, String meaning}) {
// Look up our translation, but pass in a null message so we don't have to
// eagerly evaluate calls that may not be necessary.
var translated = _message(null, locale, name, args, meaning);
diff --git a/lib/src/intl_helpers.dart b/lib/src/intl_helpers.dart
index a54609a..d284f2e 100644
--- a/lib/src/intl_helpers.dart
+++ b/lib/src/intl_helpers.dart
@@ -11,7 +11,7 @@
import 'package:intl/intl.dart';
/// Type for the callback action when a message translation is not found.
-typedef MessageIfAbsent(String message_str, List args);
+typedef MessageIfAbsent(String message_str, List<Object> args);
/// This is used as a marker for a locale data map that hasn't been initialized,
/// and will throw an exception on any usage that isn't the fallback
@@ -50,8 +50,8 @@
String get _uninitializedMessages =>
(_badMessages.toSet().toList()..sort()).join("\n ");
- String lookupMessage(
- String message_str, String locale, String name, List args, String meaning,
+ String lookupMessage(String message_str, String locale, String name,
+ List<Object> args, String meaning,
{MessageIfAbsent ifAbsent}) {
if (throwOnFallback) {
_badMessages.add(name ?? message_str);
@@ -76,8 +76,8 @@
}
abstract class MessageLookup {
- String lookupMessage(
- String message_str, String locale, String name, List args, String meaning,
+ String lookupMessage(String message_str, String locale, String name,
+ List<Object> args, String meaning,
{MessageIfAbsent ifAbsent});
void addLocale(String localeName, Function findLocale);
}