Skip to content

Commit 4270b99

Browse files
leafpetersencommit-bot@chromium.org
authored andcommitted
Fix dynamic as bottom uses in front end and dart2js.
Re-enable the dynamic as bottom hint in analysis_options.yaml and fix the code to be hint clean again. Fixes #30589 Fixes #30590 Bug: Change-Id: Idb7910b3ab1c6d931a3ead3eed885d8bd172e621 Reviewed-on: https://dart-review.googlesource.com/17062 Commit-Queue: Leaf Petersen <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent 9283ed2 commit 4270b99

36 files changed

+186
-164
lines changed

pkg/compiler/analysis_options.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,4 @@ analyzer:
88
enableSuperMixins: false
99
errors:
1010
todo: ignore
11-
# https://github.com/dart-lang/sdk/issues/30589
12-
# TODO(leafp): remove once #30589 is resolved
13-
uses_dynamic_as_bottom: ignore
1411
deprecated_member_use: ignore

pkg/compiler/lib/src/dart2js.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ String BUILD_ID = null;
4343
* string argument, or the arguments iterator for multiple arguments
4444
* handlers.
4545
*/
46-
typedef void HandleOption(data);
46+
typedef void HandleOption(Null data);
4747

4848
class OptionHandler {
4949
final String pattern;
50-
final HandleOption handle;
50+
final HandleOption _handle;
5151
final bool multipleArguments;
5252

53-
OptionHandler(this.pattern, this.handle, {this.multipleArguments: false});
53+
void handle(argument) {
54+
(_handle as dynamic)(argument);
55+
}
56+
57+
OptionHandler(this.pattern, this._handle, {this.multipleArguments: false});
5458
}
5559

5660
/**

pkg/compiler/lib/src/helpers/track_map.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* is printed but only when running in verbose mode.
1515
*/
1616
class TrackMap<K, V> implements Map<K, V> {
17-
final Map _map;
17+
final Map<K, V> _map;
1818
final List _counts;
1919
static final Map<String, List<int>> _countsMap = {};
2020

pkg/compiler/lib/src/js_backend/backend_serialization.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ class NativeBehaviorSerialization {
231231

232232
/// Returns a list of the names of the [SpecialType]s in [types].
233233
static List<String> filterSpecialTypes(List types) {
234-
return types
235-
.where((type) => getTypeKind(type) == SPECIAL_TYPE)
236-
.map((SpecialType type) => type.name)
237-
.toList();
234+
return types.where((type) => getTypeKind(type) == SPECIAL_TYPE).map((t) {
235+
SpecialType type = t;
236+
return type.name;
237+
}).toList();
238238
}
239239

240240
static void serializeNativeBehavior(

pkg/compiler/lib/src/js_emitter/constant_ordering.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ class _ConstantOrdering
4343
return a.accept(this, b);
4444
}
4545

46-
static int compareNullable(int compare(a, b), a, b) {
46+
static int compareNullable<T>(int compare(T a, T b), T a, T b) {
4747
if (a == null && b == null) return 0;
4848
if (a == null) return -1;
4949
if (b == null) return 1;
5050
return compare(a, b);
5151
}
5252

53-
static int compareLists(int compare(a, b), List a, List b) {
53+
static int compareLists<S, T>(int compare(S a, T b), List<S> a, List<T> b) {
5454
int r = a.length.compareTo(b.length);
5555
if (r != 0) return r;
5656
for (int i = 0; i < a.length; i++) {

pkg/compiler/lib/src/serialization/equivalence.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ bool equality(a, b) => a == b;
3939

4040
/// Returns `true` if the elements in [a] and [b] are pair-wise equivalent
4141
/// according to [elementEquivalence].
42-
bool areListsEquivalent(List a, List b,
43-
[bool elementEquivalence(a, b) = equality]) {
42+
bool areListsEquivalent<T>(List<T> a, List<T> b,
43+
[bool elementEquivalence(T a, T b) = equality]) {
4444
if (a.length != b.length) return false;
4545
for (int i = 0; i < a.length && i < b.length; i++) {
4646
if (!elementEquivalence(a[i], b[i])) {
@@ -52,9 +52,9 @@ bool areListsEquivalent(List a, List b,
5252

5353
/// Returns `true` if the elements in [a] and [b] are equivalent as sets using
5454
/// [elementEquivalence] to determine element equivalence.
55-
bool areSetsEquivalent(Iterable set1, Iterable set2,
56-
[bool elementEquivalence(a, b) = equality]) {
57-
Set remaining = set2.toSet();
55+
bool areSetsEquivalent<E>(Iterable<E> set1, Iterable<E> set2,
56+
[bool elementEquivalence(E a, E b) = equality]) {
57+
Set<E> remaining = set2.toSet();
5858
for (dynamic element1 in set1) {
5959
bool found = false;
6060
for (dynamic element2 in set2) {
@@ -73,9 +73,9 @@ bool areSetsEquivalent(Iterable set1, Iterable set2,
7373

7474
/// Returns `true` if the content of [map1] and [map2] is equivalent using
7575
/// [keyEquivalence] and [valueEquivalence] to determine key/value equivalence.
76-
bool areMapsEquivalent(Map map1, Map map2,
77-
[bool keyEquivalence(a, b) = equality,
78-
bool valueEquivalence(a, b) = equality]) {
76+
bool areMapsEquivalent<K, V>(Map<K, V> map1, Map<K, V> map2,
77+
[bool keyEquivalence(K a, K b) = equality,
78+
bool valueEquivalence(V a, V b) = equality]) {
7979
Set remaining = map2.keys.toSet();
8080
for (dynamic key1 in map1.keys) {
8181
bool found = false;
@@ -369,9 +369,9 @@ class TestStrategy {
369369
/// An equivalence [TestStrategy] that doesn't throw on inequivalence.
370370
TestStrategy get testOnly => this;
371371

372-
bool test(dynamic object1, dynamic object2, String property, dynamic value1,
373-
dynamic value2,
374-
[bool equivalence(a, b) = equality]) {
372+
bool test<T>(
373+
dynamic object1, dynamic object2, String property, T value1, T value2,
374+
[bool equivalence(T a, T b) = equality]) {
375375
return equivalence(value1, value2);
376376
}
377377

@@ -381,16 +381,16 @@ class TestStrategy {
381381
return areListsEquivalent(list1, list2, elementEquivalence);
382382
}
383383

384-
bool testSets(dynamic object1, dynamic object2, String property,
385-
Iterable set1, Iterable set2,
386-
[bool elementEquivalence(a, b) = equality]) {
384+
bool testSets<E>(dynamic object1, dynamic object2, String property,
385+
Iterable<E> set1, Iterable<E> set2,
386+
[bool elementEquivalence(E a, E b) = equality]) {
387387
return areSetsEquivalent(set1, set2, elementEquivalence);
388388
}
389389

390-
bool testMaps(
391-
dynamic object1, dynamic object2, String property, Map map1, Map map2,
392-
[bool keyEquivalence(a, b) = equality,
393-
bool valueEquivalence(a, b) = equality]) {
390+
bool testMaps<K, V>(dynamic object1, dynamic object2, String property,
391+
Map<K, V> map1, Map<K, V> map2,
392+
[bool keyEquivalence(K a, K b) = equality,
393+
bool valueEquivalence(V a, V b) = equality]) {
394394
return areMapsEquivalent(map1, map2, keyEquivalence, valueEquivalence);
395395
}
396396

pkg/compiler/lib/src/serialization/modelz.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ abstract class ParametersMixin
790790
if (_functionSignature == null) {
791791
List<Element> requiredParameters = [];
792792
List<Element> optionalParameters = [];
793-
List orderedOptionalParameters = [];
793+
List<Element> orderedOptionalParameters = [];
794794
int requiredParameterCount = 0;
795795
int optionalParameterCount = 0;
796796
bool optionalParametersAreNamed = false;

pkg/compiler/lib/src/serialization/serialization.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ abstract class AbstractDecoder<M, K> {
382382
/// If no value is associated with [key], then if [isOptional] is `true`,
383383
/// and empty [List] is returned, otherwise an exception is thrown.
384384
List<Element> getElements(K key, {bool isOptional: false}) {
385-
List list = _map[_getKeyValue(key)];
385+
List<int> list = _map[_getKeyValue(key)];
386386
if (list == null) {
387387
if (isOptional) {
388388
return const [];
@@ -414,7 +414,7 @@ abstract class AbstractDecoder<M, K> {
414414
/// If no value is associated with [key], then if [isOptional] is `true`,
415415
/// and empty [List] is returned, otherwise an exception is thrown.
416416
List<ConstantExpression> getConstants(K key, {bool isOptional: false}) {
417-
List list = _map[_getKeyValue(key)];
417+
List<int> list = _map[_getKeyValue(key)];
418418
if (list == null) {
419419
if (isOptional) {
420420
return const [];
@@ -446,7 +446,7 @@ abstract class AbstractDecoder<M, K> {
446446
/// If no value is associated with [key], then if [isOptional] is `true`,
447447
/// and empty [List] is returned, otherwise an exception is thrown.
448448
List<ResolutionDartType> getTypes(K key, {bool isOptional: false}) {
449-
List list = _map[_getKeyValue(key)];
449+
List<int> list = _map[_getKeyValue(key)];
450450
if (list == null) {
451451
if (isOptional) {
452452
return const [];

pkg/compiler/tool/track_memory.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Future _sendMessage(String method, [Map args = const {}]) {
7676
}
7777

7878
/// Handle all responses
79-
_handleResponse(String s) {
79+
void _handleResponse(Object s) {
8080
var json = JSON.decode(s);
8181
if (json['method'] != 'streamNotify') {
8282
var id = json['id'];

pkg/front_end/analysis_options.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ analyzer:
1616
# Allow having TODOs in the code
1717
todo: ignore
1818

19-
# https://github.com/dart-lang/sdk/issues/30590
20-
# TODO(leafp): remove once #30590 is resolved
21-
uses_dynamic_as_bottom: ignore
22-
2319
# Allow deprecated calls (although it would be nice to have a distinction
2420
# between internal and external deprecated calls).
2521
deprecated_member_use: ignore

pkg/front_end/lib/src/byte_store/file_byte_store.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class EvictingFileByteStore implements ByteStore {
9191
* This function is started in a new isolate, receives cache folder clean up
9292
* requests and evicts older files from the folder.
9393
*/
94-
static void _cacheCleanUpFunction(SendPort initialReplyTo) {
94+
static void _cacheCleanUpFunction(message) {
95+
SendPort initialReplyTo = message;
9596
ReceivePort port = new ReceivePort();
9697
initialReplyTo.send(port.sendPort);
9798
port.listen((request) async {

pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
461461
_typeInferrer.inferMetadata(annotations);
462462
Field field = fields.first.target;
463463
// The first (and often only field) will not get a clone.
464-
annotations.forEach(field.addAnnotation);
464+
annotations.forEach((annotation) => field.addAnnotation(annotation));
465465
for (int i = 1; i < fields.length; i++) {
466466
// We have to clone the annotations on the remaining fields.
467467
field = fields[i].target;

pkg/front_end/lib/src/multi_root_file_system.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,7 @@ class MultiRootFileSystemEntity implements FileSystemEntity {
7979
Future<String> readAsString() async => (await delegate).readAsString();
8080
}
8181

82-
_normalize(Uri uri) =>
83-
uri.path.endsWith('/') ? uri : uri.replace(path: '${uri.path}/');
82+
_normalize(root) {
83+
Uri uri = root;
84+
return uri.path.endsWith('/') ? uri : uri.replace(path: '${uri.path}/');
85+
}

pkg/js_ast/lib/src/printer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
part of js_ast;
66

7-
typedef String Renamer(Name);
7+
typedef String Renamer(Name name);
88

99
class JavaScriptPrintingOptions {
1010
final bool shouldCompressOutput;

tests/compiler/dart2js/analysis_options.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ analyzer:
1010

1111
errors:
1212
todo: ignore
13-
# https://github.com/dart-lang/sdk/issues/30589
14-
# TODO(leafp): remove once #30589 is resolved
15-
uses_dynamic_as_bottom: ignore
1613
deprecated_member_use: ignore
1714

1815
exclude:

tests/compiler/dart2js/constant_expression_evaluate_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TestData {
3232
final String declarations;
3333

3434
/// Tested constants.
35-
final List constants;
35+
final List<ConstantData> constants;
3636

3737
const TestData(this.name, this.declarations, this.constants);
3838
}
@@ -446,7 +446,7 @@ main() {
446446
Future testData(TestData data) async {
447447
StringBuffer sb = new StringBuffer();
448448
sb.write('${data.declarations}\n');
449-
Map constants = {};
449+
Map<String, ConstantData> constants = {};
450450
data.constants.forEach((ConstantData constantData) {
451451
String name = 'c${constants.length}';
452452
sb.write('const $name = ${constantData.code};\n');

tests/compiler/dart2js/constant_expression_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TestData {
1919
final String declarations;
2020

2121
/// Tested constants.
22-
final List constants;
22+
final List<ConstantData> constants;
2323

2424
const TestData(this.declarations, this.constants);
2525
}
@@ -192,7 +192,7 @@ main() {
192192
Future testData(TestData data) async {
193193
StringBuffer sb = new StringBuffer();
194194
sb.write('${data.declarations}\n');
195-
Map constants = {};
195+
Map<String, ConstantData> constants = {};
196196
data.constants.forEach((ConstantData constantData) {
197197
String name = 'c${constants.length}';
198198
sb.write('const $name = ${constantData.code};\n');

tests/compiler/dart2js/dart2js_batch2_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void cleanUp() {
4949
tmpDir.deleteSync(recursive: true);
5050
}
5151

52-
Future launchDart2Js(_) {
52+
Future<Process> launchDart2Js(_) {
5353
String ext = Platform.isWindows ? '.bat' : '';
5454
String command = path.normalize(path.join(
5555
path.fromUri(Platform.script), '../../../../sdk/bin/dart2js${ext}'));

tests/compiler/dart2js/dart2js_batch_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void cleanUp() {
5252
tmpDir.deleteSync(recursive: true);
5353
}
5454

55-
Future launchDart2Js(_) {
55+
Future<Process> launchDart2Js(_) {
5656
return Process.start(
5757
// Use an absolute path because we are changing the cwd below.
5858
path.fromUri(Uri.base.resolve(Platform.executable)),

0 commit comments

Comments
 (0)