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 <leafp@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Leaf Petersen 2017-10-30 19:54:26 +00:00 committed by commit-bot@chromium.org
parent 9283ed238c
commit 4270b99d75
36 changed files with 185 additions and 163 deletions

View file

@ -8,7 +8,4 @@ analyzer:
enableSuperMixins: false
errors:
todo: ignore
# https://github.com/dart-lang/sdk/issues/30589
# TODO(leafp): remove once #30589 is resolved
uses_dynamic_as_bottom: ignore
deprecated_member_use: ignore

View file

@ -43,14 +43,18 @@ String BUILD_ID = null;
* string argument, or the arguments iterator for multiple arguments
* handlers.
*/
typedef void HandleOption(data);
typedef void HandleOption(Null data);
class OptionHandler {
final String pattern;
final HandleOption handle;
final HandleOption _handle;
final bool multipleArguments;
OptionHandler(this.pattern, this.handle, {this.multipleArguments: false});
void handle(argument) {
(_handle as dynamic)(argument);
}
OptionHandler(this.pattern, this._handle, {this.multipleArguments: false});
}
/**

View file

@ -14,7 +14,7 @@
* is printed but only when running in verbose mode.
*/
class TrackMap<K, V> implements Map<K, V> {
final Map _map;
final Map<K, V> _map;
final List _counts;
static final Map<String, List<int>> _countsMap = {};

View file

@ -231,10 +231,10 @@ class NativeBehaviorSerialization {
/// Returns a list of the names of the [SpecialType]s in [types].
static List<String> filterSpecialTypes(List types) {
return types
.where((type) => getTypeKind(type) == SPECIAL_TYPE)
.map((SpecialType type) => type.name)
.toList();
return types.where((type) => getTypeKind(type) == SPECIAL_TYPE).map((t) {
SpecialType type = t;
return type.name;
}).toList();
}
static void serializeNativeBehavior(

View file

@ -43,14 +43,14 @@ class _ConstantOrdering
return a.accept(this, b);
}
static int compareNullable(int compare(a, b), a, b) {
static int compareNullable<T>(int compare(T a, T b), T a, T b) {
if (a == null && b == null) return 0;
if (a == null) return -1;
if (b == null) return 1;
return compare(a, b);
}
static int compareLists(int compare(a, b), List a, List b) {
static int compareLists<S, T>(int compare(S a, T b), List<S> a, List<T> b) {
int r = a.length.compareTo(b.length);
if (r != 0) return r;
for (int i = 0; i < a.length; i++) {

View file

@ -39,8 +39,8 @@ bool equality(a, b) => a == b;
/// Returns `true` if the elements in [a] and [b] are pair-wise equivalent
/// according to [elementEquivalence].
bool areListsEquivalent(List a, List b,
[bool elementEquivalence(a, b) = equality]) {
bool areListsEquivalent<T>(List<T> a, List<T> b,
[bool elementEquivalence(T a, T b) = equality]) {
if (a.length != b.length) return false;
for (int i = 0; i < a.length && i < b.length; i++) {
if (!elementEquivalence(a[i], b[i])) {
@ -52,9 +52,9 @@ bool areListsEquivalent(List a, List b,
/// Returns `true` if the elements in [a] and [b] are equivalent as sets using
/// [elementEquivalence] to determine element equivalence.
bool areSetsEquivalent(Iterable set1, Iterable set2,
[bool elementEquivalence(a, b) = equality]) {
Set remaining = set2.toSet();
bool areSetsEquivalent<E>(Iterable<E> set1, Iterable<E> set2,
[bool elementEquivalence(E a, E b) = equality]) {
Set<E> remaining = set2.toSet();
for (dynamic element1 in set1) {
bool found = false;
for (dynamic element2 in set2) {
@ -73,9 +73,9 @@ bool areSetsEquivalent(Iterable set1, Iterable set2,
/// Returns `true` if the content of [map1] and [map2] is equivalent using
/// [keyEquivalence] and [valueEquivalence] to determine key/value equivalence.
bool areMapsEquivalent(Map map1, Map map2,
[bool keyEquivalence(a, b) = equality,
bool valueEquivalence(a, b) = equality]) {
bool areMapsEquivalent<K, V>(Map<K, V> map1, Map<K, V> map2,
[bool keyEquivalence(K a, K b) = equality,
bool valueEquivalence(V a, V b) = equality]) {
Set remaining = map2.keys.toSet();
for (dynamic key1 in map1.keys) {
bool found = false;
@ -369,9 +369,9 @@ class TestStrategy {
/// An equivalence [TestStrategy] that doesn't throw on inequivalence.
TestStrategy get testOnly => this;
bool test(dynamic object1, dynamic object2, String property, dynamic value1,
dynamic value2,
[bool equivalence(a, b) = equality]) {
bool test<T>(
dynamic object1, dynamic object2, String property, T value1, T value2,
[bool equivalence(T a, T b) = equality]) {
return equivalence(value1, value2);
}
@ -381,16 +381,16 @@ class TestStrategy {
return areListsEquivalent(list1, list2, elementEquivalence);
}
bool testSets(dynamic object1, dynamic object2, String property,
Iterable set1, Iterable set2,
[bool elementEquivalence(a, b) = equality]) {
bool testSets<E>(dynamic object1, dynamic object2, String property,
Iterable<E> set1, Iterable<E> set2,
[bool elementEquivalence(E a, E b) = equality]) {
return areSetsEquivalent(set1, set2, elementEquivalence);
}
bool testMaps(
dynamic object1, dynamic object2, String property, Map map1, Map map2,
[bool keyEquivalence(a, b) = equality,
bool valueEquivalence(a, b) = equality]) {
bool testMaps<K, V>(dynamic object1, dynamic object2, String property,
Map<K, V> map1, Map<K, V> map2,
[bool keyEquivalence(K a, K b) = equality,
bool valueEquivalence(V a, V b) = equality]) {
return areMapsEquivalent(map1, map2, keyEquivalence, valueEquivalence);
}

View file

@ -790,7 +790,7 @@ abstract class ParametersMixin
if (_functionSignature == null) {
List<Element> requiredParameters = [];
List<Element> optionalParameters = [];
List orderedOptionalParameters = [];
List<Element> orderedOptionalParameters = [];
int requiredParameterCount = 0;
int optionalParameterCount = 0;
bool optionalParametersAreNamed = false;

View file

@ -382,7 +382,7 @@ abstract class AbstractDecoder<M, K> {
/// If no value is associated with [key], then if [isOptional] is `true`,
/// and empty [List] is returned, otherwise an exception is thrown.
List<Element> getElements(K key, {bool isOptional: false}) {
List list = _map[_getKeyValue(key)];
List<int> list = _map[_getKeyValue(key)];
if (list == null) {
if (isOptional) {
return const [];
@ -414,7 +414,7 @@ abstract class AbstractDecoder<M, K> {
/// If no value is associated with [key], then if [isOptional] is `true`,
/// and empty [List] is returned, otherwise an exception is thrown.
List<ConstantExpression> getConstants(K key, {bool isOptional: false}) {
List list = _map[_getKeyValue(key)];
List<int> list = _map[_getKeyValue(key)];
if (list == null) {
if (isOptional) {
return const [];
@ -446,7 +446,7 @@ abstract class AbstractDecoder<M, K> {
/// If no value is associated with [key], then if [isOptional] is `true`,
/// and empty [List] is returned, otherwise an exception is thrown.
List<ResolutionDartType> getTypes(K key, {bool isOptional: false}) {
List list = _map[_getKeyValue(key)];
List<int> list = _map[_getKeyValue(key)];
if (list == null) {
if (isOptional) {
return const [];

View file

@ -76,7 +76,7 @@ Future _sendMessage(String method, [Map args = const {}]) {
}
/// Handle all responses
_handleResponse(String s) {
void _handleResponse(Object s) {
var json = JSON.decode(s);
if (json['method'] != 'streamNotify') {
var id = json['id'];

View file

@ -16,10 +16,6 @@ analyzer:
# Allow having TODOs in the code
todo: ignore
# https://github.com/dart-lang/sdk/issues/30590
# TODO(leafp): remove once #30590 is resolved
uses_dynamic_as_bottom: ignore
# Allow deprecated calls (although it would be nice to have a distinction
# between internal and external deprecated calls).
deprecated_member_use: ignore

View file

@ -91,7 +91,8 @@ class EvictingFileByteStore implements ByteStore {
* This function is started in a new isolate, receives cache folder clean up
* requests and evicts older files from the folder.
*/
static void _cacheCleanUpFunction(SendPort initialReplyTo) {
static void _cacheCleanUpFunction(message) {
SendPort initialReplyTo = message;
ReceivePort port = new ReceivePort();
initialReplyTo.send(port.sendPort);
port.listen((request) async {

View file

@ -461,7 +461,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
_typeInferrer.inferMetadata(annotations);
Field field = fields.first.target;
// The first (and often only field) will not get a clone.
annotations.forEach(field.addAnnotation);
annotations.forEach((annotation) => field.addAnnotation(annotation));
for (int i = 1; i < fields.length; i++) {
// We have to clone the annotations on the remaining fields.
field = fields[i].target;

View file

@ -79,5 +79,7 @@ class MultiRootFileSystemEntity implements FileSystemEntity {
Future<String> readAsString() async => (await delegate).readAsString();
}
_normalize(Uri uri) =>
uri.path.endsWith('/') ? uri : uri.replace(path: '${uri.path}/');
_normalize(root) {
Uri uri = root;
return uri.path.endsWith('/') ? uri : uri.replace(path: '${uri.path}/');
}

View file

@ -4,7 +4,7 @@
part of js_ast;
typedef String Renamer(Name);
typedef String Renamer(Name name);
class JavaScriptPrintingOptions {
final bool shouldCompressOutput;

View file

@ -10,9 +10,6 @@ analyzer:
errors:
todo: ignore
# https://github.com/dart-lang/sdk/issues/30589
# TODO(leafp): remove once #30589 is resolved
uses_dynamic_as_bottom: ignore
deprecated_member_use: ignore
exclude:

View file

@ -32,7 +32,7 @@ class TestData {
final String declarations;
/// Tested constants.
final List constants;
final List<ConstantData> constants;
const TestData(this.name, this.declarations, this.constants);
}
@ -446,7 +446,7 @@ main() {
Future testData(TestData data) async {
StringBuffer sb = new StringBuffer();
sb.write('${data.declarations}\n');
Map constants = {};
Map<String, ConstantData> constants = {};
data.constants.forEach((ConstantData constantData) {
String name = 'c${constants.length}';
sb.write('const $name = ${constantData.code};\n');

View file

@ -19,7 +19,7 @@ class TestData {
final String declarations;
/// Tested constants.
final List constants;
final List<ConstantData> constants;
const TestData(this.declarations, this.constants);
}
@ -192,7 +192,7 @@ main() {
Future testData(TestData data) async {
StringBuffer sb = new StringBuffer();
sb.write('${data.declarations}\n');
Map constants = {};
Map<String, ConstantData> constants = {};
data.constants.forEach((ConstantData constantData) {
String name = 'c${constants.length}';
sb.write('const $name = ${constantData.code};\n');

View file

@ -49,7 +49,7 @@ void cleanUp() {
tmpDir.deleteSync(recursive: true);
}
Future launchDart2Js(_) {
Future<Process> launchDart2Js(_) {
String ext = Platform.isWindows ? '.bat' : '';
String command = path.normalize(path.join(
path.fromUri(Platform.script), '../../../../sdk/bin/dart2js${ext}'));

View file

@ -52,7 +52,7 @@ void cleanUp() {
tmpDir.deleteSync(recursive: true);
}
Future launchDart2Js(_) {
Future<Process> launchDart2Js(_) {
return Process.start(
// Use an absolute path because we are changing the cwd below.
path.fromUri(Uri.base.resolve(Platform.executable)),

View file

@ -90,8 +90,8 @@ class CheckStrategy extends TestStrategy {
constantValueEquivalence: constantValueEquivalence);
@override
bool test(var object1, var object2, String property, var value1, var value2,
[bool equivalence(a, b) = equality]) {
bool test<T>(var object1, var object2, String property, T value1, T value2,
[bool equivalence(T a, T b) = equality]) {
return check(object1, object2, property, value1, value2, equivalence);
}
@ -109,17 +109,18 @@ class CheckStrategy extends TestStrategy {
}
@override
bool testSets(
var object1, var object2, String property, Iterable set1, Iterable set2,
[bool elementEquivalence(a, b) = equality]) {
bool testSets<E>(var object1, var object2, String property, Iterable<E> set1,
Iterable<E> set2,
[bool elementEquivalence(E a, E b) = equality]) {
return checkSetEquivalence(
object1, object2, property, set1, set2, elementEquivalence);
}
@override
bool testMaps(var object1, var object2, String property, Map map1, Map map2,
[bool keyEquivalence(a, b) = equality,
bool valueEquivalence(a, b) = equality]) {
bool testMaps<K, V>(
var object1, var object2, String property, Map<K, V> map1, Map<K, V> map2,
[bool keyEquivalence(K a, K b) = equality,
bool valueEquivalence(V a, V b) = equality]) {
return checkMapEquivalence(object1, object2, property, map1, map2,
keyEquivalence, valueEquivalence);
}
@ -127,8 +128,8 @@ class CheckStrategy extends TestStrategy {
/// Check that the values [property] of [object1] and [object2], [value1] and
/// [value2] respectively, are equal and throw otherwise.
bool check(var object1, var object2, String property, var value1, var value2,
[bool equivalence(a, b) = equality, String toString(a)]) {
bool check<T>(var object1, var object2, String property, T value1, T value2,
[bool equivalence(T a, T b) = equality, String toString(T a)]) {
currentCheck = new Check(
currentCheck, object1, object2, property, value1, value2, toString);
if (!equivalence(value1, value2)) {
@ -142,13 +143,13 @@ bool check(var object1, var object2, String property, var value1, var value2,
/// [checkEquivalence] to check the pair-wise equivalence.
///
/// Uses [object1], [object2] and [property] to provide context for failures.
bool checkListEquivalence(
bool checkListEquivalence<T>(
Object object1,
Object object2,
String property,
Iterable list1,
Iterable list2,
void checkEquivalence(o1, o2, property, a, b)) {
Iterable<T> list1,
Iterable<T> list2,
void checkEquivalence(Object o1, Object o2, String property, T a, T b)) {
currentCheck =
new Check(currentCheck, object1, object2, property, list1, list2);
for (int i = 0; i < list1.length && i < list2.length; i++) {
@ -177,9 +178,9 @@ bool checkListEquivalence(
/// Elements both in [set1] and [set2] are added to [common], elements in [set1]
/// but not in [set2] are added to [unfound], and the set of elements in [set2]
/// but not in [set1] are returned.
Set computeSetDifference(
Iterable set1, Iterable set2, List<List> common, List unfound,
{bool sameElement(a, b): equality, void checkElements(a, b)}) {
Set<E> computeSetDifference<E>(
Iterable<E> set1, Iterable<E> set2, List<List<E>> common, List<E> unfound,
{bool sameElement(E a, E b): equality, void checkElements(E a, E b)}) {
// TODO(johnniwinther): Avoid the quadratic cost here. Some ideas:
// - convert each set to a list and sort it first, then compare by walking
// both lists in parallel
@ -214,12 +215,12 @@ Set computeSetDifference(
/// [elementEquivalence] to compute the pair-wise equivalence.
///
/// Uses [object1], [object2] and [property] to provide context for failures.
bool checkSetEquivalence(var object1, var object2, String property,
Iterable set1, Iterable set2, bool sameElement(a, b),
{void onSameElement(a, b)}) {
List<List> common = <List>[];
List unfound = [];
Set remaining = computeSetDifference(set1, set2, common, unfound,
bool checkSetEquivalence<E>(var object1, var object2, String property,
Iterable<E> set1, Iterable<E> set2, bool sameElement(E a, E b),
{void onSameElement(E a, E b)}) {
var common = <List<E>>[];
var unfound = <E>[];
Set<E> remaining = computeSetDifference(set1, set2, common, unfound,
sameElement: sameElement, checkElements: onSameElement);
if (unfound.isNotEmpty || remaining.isNotEmpty) {
String message = "Set mismatch for `$property` on\n"
@ -236,12 +237,18 @@ bool checkSetEquivalence(var object1, var object2, String property,
/// [elementEquivalence] to compute the pair-wise equivalence.
///
/// Uses [object1], [object2] and [property] to provide context for failures.
bool checkMapEquivalence(var object1, var object2, String property, Map map1,
Map map2, bool sameKey(a, b), bool sameValue(a, b),
bool checkMapEquivalence<K, V>(
var object1,
var object2,
String property,
Map<K, V> map1,
Map<K, V> map2,
bool sameKey(K a, K b),
bool sameValue(V a, V b),
{bool allowExtra: false}) {
List<List> common = <List>[];
List unfound = [];
Set extra = computeSetDifference(map1.keys, map2.keys, common, unfound,
var common = <List<K>>[];
var unfound = <K>[];
var extra = computeSetDifference(map1.keys, map2.keys, common, unfound,
sameElement: sameKey);
if (unfound.isNotEmpty || (!allowExtra && extra.isNotEmpty)) {
String message =
@ -266,7 +273,7 @@ bool checkElementIdentities(Object object1, Object object2, String property,
Entity element1, Entity element2) {
if (identical(element1, element2)) return true;
return check(
object1, object2, property, element1, element2, areElementsEquivalent);
object1, object2, property, element1, element2, areEntitiesEquivalent);
}
/// Checks the pair-wise equivalence of the identity (but not properties) of the
@ -279,6 +286,13 @@ bool checkElementListIdentities(Object object1, Object object2, String property,
object1, object2, property, list1, list2, checkElementIdentities);
}
/// Checks the equivalence of [DartType]s [type1] and [type2].
///
/// Uses [object1], [object2] and [property] to provide context for failures.
bool checkDartTypes(Object object1, Object object2, String property,
DartType type1, DartType type2) =>
checkTypes(object1, object2, property, type1, type2);
/// Checks the equivalence of [type1] and [type2].
///
/// Uses [object1], [object2] and [property] to provide context for failures.
@ -299,7 +313,7 @@ bool checkTypes(Object object1, Object object2, String property,
bool checkTypeLists(Object object1, Object object2, String property,
List<DartType> list1, List<DartType> list2) {
return checkListEquivalence(
object1, object2, property, list1, list2, checkTypes);
object1, object2, property, list1, list2, checkDartTypes);
}
/// Checks the equivalence of [exp1] and [exp2].
@ -355,13 +369,13 @@ bool checkConstantValueLists(Object object1, Object object2, String property,
object1, object2, property, list1, list2, checkConstantValues);
}
void checkLists(
List list1, List list2, String messagePrefix, bool sameElement(a, b),
void checkLists<T>(List<T> list1, List<T> list2, String messagePrefix,
bool sameElement(T a, T b),
{bool verbose: false,
void onSameElement(a, b),
void onDifferentElements(a, b),
void onUnfoundElement(a),
void onExtraElement(b),
void onSameElement(T a, T b),
void onDifferentElements(T a, T b),
void onUnfoundElement(T a),
void onExtraElement(T b),
String elementToString(key): defaultToString}) {
List<List> common = <List>[];
List mismatch = [];
@ -429,17 +443,17 @@ void checkLists(
}
}
void checkSets(
Iterable set1, Iterable set2, String messagePrefix, bool sameElement(a, b),
void checkSets<E>(Iterable<E> set1, Iterable<E> set2, String messagePrefix,
bool sameElement(E a, E b),
{bool failOnUnfound: true,
bool failOnExtra: true,
bool verbose: false,
void onSameElement(a, b),
void onUnfoundElement(a),
void onExtraElement(b),
bool elementFilter(element),
elementConverter(element),
String elementToString(key): defaultToString}) {
void onSameElement(E a, E b),
void onUnfoundElement(E a),
void onExtraElement(E b),
bool elementFilter(E element),
elementConverter(E element),
String elementToString(E key): defaultToString}) {
if (elementFilter != null) {
set1 = set1.where(elementFilter);
set2 = set2.where(elementFilter);
@ -448,9 +462,9 @@ void checkSets(
set1 = set1.map(elementConverter);
set2 = set2.map(elementConverter);
}
List<List> common = <List>[];
List unfound = [];
Set remaining = computeSetDifference(set1, set2, common, unfound,
var common = <List<E>>[];
var unfound = <E>[];
var remaining = computeSetDifference(set1, set2, common, unfound,
sameElement: sameElement, checkElements: onSameElement);
if (onUnfoundElement != null) {
unfound.forEach(onUnfoundElement);
@ -490,25 +504,25 @@ void checkSets(
String defaultToString(obj) => '$obj';
void checkMaps(Map map1, Map map2, String messagePrefix, bool sameKey(a, b),
bool sameValue(a, b),
void checkMaps<K, V>(Map<K, V> map1, Map<K, V> map2, String messagePrefix,
bool sameKey(K a, K b), bool sameValue(V a, V b),
{bool failOnUnfound: true,
bool failOnMismatch: true,
bool keyFilter(key),
bool keyFilter(K key),
bool verbose: false,
String keyToString(key): defaultToString,
String valueToString(key): defaultToString}) {
List<List> common = <List>[];
List unfound = [];
List<List> mismatch = <List>[];
String keyToString(K key): defaultToString,
String valueToString(V key): defaultToString}) {
var common = <List<K>>[];
var unfound = <K>[];
var mismatch = <List<K>>[];
Iterable keys1 = map1.keys;
Iterable keys2 = map2.keys;
Iterable<K> keys1 = map1.keys;
Iterable<K> keys2 = map2.keys;
if (keyFilter != null) {
keys1 = keys1.where(keyFilter);
keys2 = keys2.where(keyFilter);
}
Set remaining = computeSetDifference(keys1, keys2, common, unfound,
var remaining = computeSetDifference(keys1, keys2, common, unfound,
sameElement: sameKey, checkElements: (k1, k2) {
var v1 = map1[k1];
var v2 = map2[k2];

View file

@ -160,13 +160,13 @@ main(List<String> args) {
Expect.isNotNull(cls2, 'Missing class ${cls1.name}');
check(cls1.library, cls2.library, 'class ${cls1.name}', cls1, cls2,
equivalence.entityEquivalence);
equivalence.entityEntityEquivalence);
InterfaceType thisType1 = types1.getThisType(cls1);
InterfaceType thisType2 = types2.getThisType(cls2);
check(cls1, cls2, 'thisType', thisType1, thisType2,
equivalence.typeEquivalence);
equivalence.typeTypeEquivalence);
check(cls1, cls2, 'supertype', types1.getSupertype(cls1),
types2.getSupertype(cls2), equivalence.typeEquivalence);
types2.getSupertype(cls2), equivalence.typeTypeEquivalence);
checkClasses(env1.getSuperClass(cls1), env2.getSuperClass(cls2));
List<DartType> mixins1 = <DartType>[];
@ -177,19 +177,19 @@ main(List<String> args) {
env2.forEachMixin(cls2, (ClassEntity mixin) {
mixins2.add(types2.asInstanceOf(thisType2, mixin));
});
checkLists(
mixins1, mixins2, '${cls1.name} mixins', equivalence.typeEquivalence);
checkLists(mixins1, mixins2, '${cls1.name} mixins',
equivalence.typeTypeEquivalence);
checkLists(
types1.getInterfaces(cls1).toList(),
types2.getInterfaces(cls2).toList(),
'${cls1.name} interfaces',
equivalence.typeEquivalence);
equivalence.typeTypeEquivalence);
checkLists(
types1.getSupertypes(cls1).toList(),
types2.getSupertypes(cls2).toList(),
'${cls1.name} supertypes',
equivalence.typeEquivalence);
equivalence.typeTypeEquivalence);
if (cls1 == compiler1.frontendStrategy.commonElements.objectClass) return;

View file

@ -37,6 +37,9 @@ class KernelEquivalence {
constantEquivalence: constantEquivalence,
constantValueEquivalence: constantValueEquivalence);
bool entityEntityEquivalence(Entity a, Entity b, {TestStrategy strategy}) =>
entityEquivalence(a, b, strategy: strategy);
bool entityEquivalence(Element a, Entity b, {TestStrategy strategy}) {
if (identical(a, b)) return true;
if (a == null || b == null) return false;
@ -164,6 +167,9 @@ class KernelEquivalence {
}
}
bool typeTypeEquivalence(DartType a, DartType b, {TestStrategy strategy}) =>
typeEquivalence(a, b, strategy: strategy);
bool typeEquivalence(ResolutionDartType a, DartType b,
{TestStrategy strategy}) {
if (identical(a, b)) return true;

View file

@ -20,7 +20,7 @@ List<String> dart2JsCommand(List<String> args) {
return command;
}
Future launchDart2Js(args, {bool noStdoutEncoding: false}) {
Future<ProcessResult> launchDart2Js(args, {bool noStdoutEncoding: false}) {
if (noStdoutEncoding) {
return Process.run(Platform.executable, dart2JsCommand(args),
stdoutEncoding: null);

View file

@ -238,7 +238,7 @@ class MemoryLoadedLibraries implements LoadedLibraries {
}
@override
void forEachLibrary(f) => copiedLibraries.values.forEach(f);
void forEachLibrary(void f(l)) => copiedLibraries.values.forEach(f);
@override
getLibrary(Uri uri) => copiedLibraries[uri];

View file

@ -6,6 +6,8 @@
/// requested elements are retained for reflection.
library dart2js.test.mirrors_used_test;
import 'package:compiler/src/js/js.dart' as jsAst;
import 'package:expect/expect.dart';
import "package:async_helper/async_helper.dart";
@ -75,17 +77,17 @@ void main() {
'${generatedCode.length} > $expectedMethodCount');
// The following names should be retained:
List expectedNames = [
List<jsAst.Name> expectedNames = [
'Foo', // The name of class Foo.
r'Foo$', // The name of class Foo's constructor.
r'get$field'
]; // The (getter) name of Foo.field.
r'get$field' // The (getter) name of Foo.field.
].map(backend.namer.asName).toList();
// TODO(ahe): Check for the following names, currently they are not being
// recorded correctly, but are being emitted.
[
'Foo_staticMethod', // The name of Foo.staticMethod.
r'instanceMethod$0'
]; // The name of Foo.instanceMethod.
r'instanceMethod$0' // The name of Foo.instanceMethod.
];
// We always include the names of some native classes.
List<ClassElement> nativeClasses = [
@ -97,17 +99,14 @@ void main() {
compiler.resolution.commonElements.nullClass,
compiler.resolution.commonElements.listClass
];
Iterable<String> nativeNames =
// `backend.namer.className` returns a Name, but a String is required.
// ignore: ARGUMENT_TYPE_NOT_ASSIGNABLE
Iterable<jsAst.Name> nativeNames =
nativeClasses.map((c) => backend.namer.className(c));
expectedNames = expectedNames.map(backend.namer.asName).toList();
expectedNames.addAll(nativeNames);
// Mirrors only work in the full emitter. We can thus be certain that the
// emitter is the full emitter.
full.Emitter fullEmitter = backend.emitter.emitter;
Set recordedNames = new Set()
Set<jsAst.Name> recordedNames = new Set()
..addAll(fullEmitter.recordedMangledNames)
..addAll(fullEmitter.mangledFieldNames.keys)
..addAll(fullEmitter.mangledGlobalFieldNames.keys);

View file

@ -280,7 +280,7 @@ class MockCompiler extends Compiler {
}
/// Create a new [MockCompiler] and apply it asynchronously to [f].
static Future create(f(MockCompiler compiler)) {
static Future<T> create<T>(T f(MockCompiler compiler)) {
MockCompiler compiler = new MockCompiler.internal();
return compiler.init().then((_) => f(compiler));
}

View file

@ -337,7 +337,8 @@ void testMissingCloseParen() {
parseMember(source, reporter: new Collector());
}
check(Collector c) {
check(exn) {
Collector c = exn;
Expect.equals(OPEN_CURLY_BRACKET_TOKEN, c.token);
return true;
}
@ -351,7 +352,8 @@ void testMissingCloseBraceInClass() {
fullParseUnit(source, reporter: new Collector());
}
check(Collector c) {
check(exn) {
Collector c = exn;
Expect.equals(BAD_INPUT_TOKEN, c.token);
return true;
}
@ -365,7 +367,8 @@ void testUnmatchedAngleBracket() {
fullParseUnit(source, reporter: new Collector());
}
check(Collector c) {
check(exn) {
Collector c = exn;
Expect.equals(LT_TOKEN, c.token);
return true;
}

View file

@ -54,7 +54,7 @@ void expectHasNoBody(compiler, ElementX element) {
Expect.isFalse(node.hasBody);
}
Element ensure(compiler, String name, Element lookup(name),
Element ensure(compiler, String name, Element lookup(String name),
{bool expectIsPatched: false,
bool expectIsPatch: false,
bool checkHasBody: false,

View file

@ -6,6 +6,7 @@ library reexport_handled_test;
import "package:expect/expect.dart";
import "package:async_helper/async_helper.dart";
import 'package:compiler/src/elements/elements.dart' show LibraryElement;
import 'mock_compiler.dart';
final exportingLibraryUri = Uri.parse('exporting.dart');
@ -30,7 +31,7 @@ void main() {
return compiler.libraryLoader.loadLibrary(exportingLibraryUri);
}).then((loadedLibraries) {
compiler.processLoadedLibraries(loadedLibraries);
var exportingLibrary = loadedLibraries.rootLibrary;
LibraryElement exportingLibrary = loadedLibraries.rootLibrary;
Expect.isTrue(exportingLibrary.exportsHandled);
var foo = exportingLibrary.findExported('foo');
Expect.isNotNull(foo);

View file

@ -44,7 +44,7 @@ createLocals(List variables) {
return new VariableDefinitions(null, Modifiers.EMPTY, definitions);
}
Future testLocals(List variables) {
Future<MockCompiler> testLocals(List variables) {
return MockCompiler.create((MockCompiler compiler) {
ResolverVisitor visitor = compiler.resolverVisitor();
ResolutionResult result = visitor.visit(createLocals(variables));
@ -660,7 +660,7 @@ Future testTwoInterfaces() {
Future testFunctionExpression() {
return MockCompiler.create((MockCompiler compiler) {
Map mapping = compiler.resolveStatement("int f() {}").map;
var mapping = compiler.resolveStatement("int f() {}").map;
Expect.equals(2, mapping.length);
Element element;
Node node;

View file

@ -117,7 +117,7 @@ void checkBackendInfo(Compiler compilerNormal, Compiler compilerDeserialized,
compilerNormal.enqueuer.resolution.processedEntities,
compilerDeserialized.enqueuer.resolution.processedEntities,
"Processed element mismatch",
areElementsEquivalent, onSameElement: (a, b) {
areEntitiesEquivalent, onSameElement: (a, b) {
checkElements(compilerNormal, compilerDeserialized, a, b, verbose: verbose);
}, verbose: verbose);
Expect.equals(
@ -205,7 +205,7 @@ void checkElements(
'$element1.thisFieldEntity',
closureData1.thisFieldEntity,
closureData2.thisFieldEntity,
areLocalsEquivalent);
areCapturedVariablesEquivalent);
if (element1 is MemberElement && element2 is MemberElement) {
MemberElement member1 = element1.implementation;
MemberElement member2 = element2.implementation;
@ -233,7 +233,9 @@ void checkElements(
checkElementOutputUnits(compiler1, compiler2, element1, element2);
}
bool areLocalsEquivalent(LocalVariable a, LocalVariable b) {
bool areLocalsEquivalent(Local a, Local b) => areLocalVariablesEquivalent(a, b);
bool areLocalVariablesEquivalent(LocalVariable a, LocalVariable b) {
if (a == b) return true;
if (a == null || b == null) return false;
@ -250,10 +252,10 @@ bool areCapturedVariablesEquivalent(FieldEntity a, FieldEntity b) {
if (a == null || b == null) return false;
if (a is ClosureFieldElement && b is ClosureFieldElement) {
return areElementsEquivalent(a.closureClass, b.closureClass) &&
areLocalsEquivalent(a.local, b.local);
areLocalVariablesEquivalent(a.local, b.local);
} else if (a is BoxFieldElement && b is BoxFieldElement) {
return areElementsEquivalent(a.variableElement, b.variableElement) &&
areLocalsEquivalent(a.box, b.box);
areLocalVariablesEquivalent(a.box, b.box);
}
return false;
}
@ -261,18 +263,18 @@ bool areCapturedVariablesEquivalent(FieldEntity a, FieldEntity b) {
bool areCapturedScopesEquivalent(CapturedScope a, CapturedScope b) {
if (a == b) return true;
if (a == null || b == null) return false;
if (!areLocalsEquivalent(a.context, b.context)) {
if (!areLocalVariablesEquivalent(a.context, b.context)) {
return false;
}
if (!areLocalsEquivalent(a.thisLocal, b.thisLocal)) {
if (!areLocalVariablesEquivalent(a.thisLocal, b.thisLocal)) {
return false;
}
var aBoxed = {};
var aBoxed = <LocalVariable, Entity>{};
a.forEachBoxedVariable((k, v) => aBoxed[k] = v);
var bBoxed = {};
var bBoxed = <LocalVariable, Entity>{};
b.forEachBoxedVariable((k, v) => bBoxed[k] = v);
checkMaps(aBoxed, bBoxed, 'CapturedScope.boxedVariables', areLocalsEquivalent,
areElementsEquivalent);
checkMaps(aBoxed, bBoxed, 'CapturedScope.boxedVariables',
areLocalVariablesEquivalent, areEntitiesEquivalent);
return true;
}

View file

@ -59,26 +59,26 @@ Future checkNativeData(Uri uri, {bool verbose: false}) async {
NativeDataImpl nativeData2 = closedWorld2.nativeData;
checkMaps(nativeData1.jsInteropLibraries, nativeData2.jsInteropLibraries,
"NativeData.jsInteropLibraryNames", areElementsEquivalent, equality,
"NativeData.jsInteropLibraryNames", areEntitiesEquivalent, equality,
verbose: verbose);
checkMaps(nativeData1.jsInteropClasses, nativeData2.jsInteropClasses,
"NativeData.jsInteropClassNames", areElementsEquivalent, equality,
"NativeData.jsInteropClassNames", areEntitiesEquivalent, equality,
verbose: verbose);
checkMaps(nativeData1.jsInteropMembers, nativeData2.jsInteropMembers,
"NativeData.jsInteropMemberNames", areElementsEquivalent, equality,
"NativeData.jsInteropMemberNames", areEntitiesEquivalent, equality,
verbose: verbose);
checkMaps(nativeData1.nativeMemberName, nativeData2.nativeMemberName,
"NativeData.nativeMemberName", areElementsEquivalent, equality,
"NativeData.nativeMemberName", areEntitiesEquivalent, equality,
verbose: verbose);
checkMaps(
nativeBasicData1.nativeClassTagInfo,
nativeBasicData2.nativeClassTagInfo,
"NativeData.nativeClassTagInfo",
areElementsEquivalent,
areEntitiesEquivalent,
equality,
verbose: verbose);
@ -86,7 +86,7 @@ Future checkNativeData(Uri uri, {bool verbose: false}) async {
nativeData1.nativeMethodBehavior,
nativeData2.nativeMethodBehavior,
"NativeData.nativeMethodBehavior",
areElementsEquivalent,
areEntitiesEquivalent,
testNativeBehavior,
verbose: verbose);
@ -94,7 +94,7 @@ Future checkNativeData(Uri uri, {bool verbose: false}) async {
nativeData1.nativeFieldLoadBehavior,
nativeData2.nativeFieldLoadBehavior,
"NativeData.nativeFieldLoadBehavior",
areElementsEquivalent,
areEntitiesEquivalent,
testNativeBehavior,
verbose: verbose);
@ -102,7 +102,7 @@ Future checkNativeData(Uri uri, {bool verbose: false}) async {
nativeData1.nativeFieldStoreBehavior,
nativeData2.nativeFieldStoreBehavior,
"NativeData.nativeFieldStoreBehavior",
areElementsEquivalent,
areEntitiesEquivalent,
testNativeBehavior,
verbose: verbose);
}

View file

@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:async_helper/async_helper.dart';
@ -17,7 +16,7 @@ void main() {
String file =
'tests/compiler/dart2js/source_map_deferred_validator_test_file.dart';
print("Compiling $file");
Future result = entry.internalMain(
var result = entry.internalMain(
[file, '-o${tmpDir.path}/out.js', '--library-root=sdk']);
return result.then((CompilationResult result) {
CompilerImpl compiler = result.compiler;

View file

@ -906,7 +906,7 @@ CodeSource codeSourceFromElement(Element element) {
/// Create [LineData] that colors line numbers according to the [CodeSource]s
/// origin if available.
LineData getLineData(CodeSource lineAnnotation) {
LineData getLineData(Object lineAnnotation) {
if (lineAnnotation != null) {
return new LineData(
lineClass: ClassNames.line,

View file

@ -46,7 +46,7 @@ SingleMapping convertFromHumanReadableSourceMap(String json) {
Map inputMap = lazon.decode(json);
Map urls = inputMap['sources'];
List<String> sources = new List<String>.filled(urls.length, null);
urls.forEach((String index, String url) {
urls.forEach((Object index, Object url) {
int i = int.parse(index);
assert(sources[i] == null);
sources[i] = url;

View file

@ -136,7 +136,8 @@ check(String typeMaskDescriptor1, String typeMaskDescriptor2,
areDisjoint: areDisjoint);
}
checkUnions(List descriptors1, List descriptors2, {areDisjoint: true}) {
checkUnions(List<String> descriptors1, List<String> descriptors2,
{areDisjoint: true}) {
print('[$descriptors1] & [$descriptors2]');
var m1 = new TypeMask.unionOf(descriptors1.map(maskOf).toList(), world);
var m2 = new TypeMask.unionOf(descriptors2.map(maskOf).toList(), world);