Ignore unnecessary casts from utf8.encode (dart-lang/package_config#114)
An upcoming SDK change will change the return type to `Uint8List` which
makes the casts unnecessary and introduces analyzer diagnostics.
Preemptively ignore these to make it easier to roll the SDK.
https://dart-review.googlesource.com/c/sdk/+/208190
diff --git a/pkgs/package_config/CHANGELOG.md b/pkgs/package_config/CHANGELOG.md
index 9949b51..898ebc4 100644
--- a/pkgs/package_config/CHANGELOG.md
+++ b/pkgs/package_config/CHANGELOG.md
@@ -1,3 +1,5 @@
+## 2.0.2-dev
+
## 2.0.1
- Use unique library names to correct docs issue.
diff --git a/pkgs/package_config/pubspec.yaml b/pkgs/package_config/pubspec.yaml
index 687c3d3..5cc9cc0 100644
--- a/pkgs/package_config/pubspec.yaml
+++ b/pkgs/package_config/pubspec.yaml
@@ -1,5 +1,5 @@
name: package_config
-version: 2.0.1
+version: 2.0.2-dev
description: Support for working with Package Configuration files.
homepage: https://github.com/dart-lang/package_config
diff --git a/pkgs/package_config/test/parse_test.dart b/pkgs/package_config/test/parse_test.dart
index a163e12..d5c2e72 100644
--- a/pkgs/package_config/test/parse_test.dart
+++ b/pkgs/package_config/test/parse_test.dart
@@ -113,6 +113,7 @@
}
''';
var config = parsePackageConfigBytes(
+ // ignore: unnecessary_cast
utf8.encode(packageConfigFile) as Uint8List,
Uri.parse('file:///tmp/.dart_tool/file.dart'),
throwError);
@@ -193,6 +194,7 @@
}
''';
var config = parsePackageConfigBytes(
+ // ignore: unnecessary_cast
utf8.encode(packageConfigFile) as Uint8List,
Uri.parse('file:///tmp/.dart_tool/file.dart'),
throwError);
@@ -219,6 +221,7 @@
var root = '"rootUri":"/foo/"';
test('minimal', () {
var config = parsePackageConfigBytes(
+ // ignore: unnecessary_cast
utf8.encode('{$cfg,$pkgs}') as Uint8List,
Uri.parse('file:///tmp/.dart_tool/file.dart'),
throwError);
@@ -229,6 +232,7 @@
// A package must have a name and a rootUri, the remaining properties
// are optional.
var config = parsePackageConfigBytes(
+ // ignore: unnecessary_cast
utf8.encode('{$cfg,"packages":[{$name,$root}]}') as Uint8List,
Uri.parse('file:///tmp/.dart_tool/file.dart'),
throwError);
@@ -246,6 +250,7 @@
{'name': 'qux', 'rootUri': '/foo/qux/', 'packageUri': 'lib/'},
]
}));
+ // ignore: unnecessary_cast
var config = parsePackageConfigBytes(configBytes as Uint8List,
Uri.parse('file:///tmp/.dart_tool/file.dart'), throwError);
expect(config.version, 2);
@@ -271,6 +276,7 @@
void testThrows(String name, String source) {
test(name, () {
expect(
+ // ignore: unnecessary_cast
() => parsePackageConfigBytes(utf8.encode(source) as Uint8List,
Uri.parse('file:///tmp/.dart_tool/file.dart'), throwError),
throwsA(TypeMatcher<FormatException>()));
diff --git a/pkgs/package_config/test/src/util.dart b/pkgs/package_config/test/src/util.dart
index 32e9217..246e129 100644
--- a/pkgs/package_config/test/src/util.dart
+++ b/pkgs/package_config/test/src/util.dart
@@ -48,6 +48,7 @@
if (value is! Map<String, Object?>) return null;
value = value[parts[i]];
}
+ // ignore: unnecessary_cast
if (value is String) return utf8.encode(value) as Uint8List;
return null;
}