Revert "[vm] Fix some further mirror breaks with frontend NNBD checks enabled."

This reverts commit daf91f56b9.

Reason for revert: Analyzer and CFE disagree

Original change's description:
> [vm] Fix some further mirror breaks with frontend NNBD checks enabled.
> 
> Change-Id: I3c52dac2244c1f7eae59d85bc637cce2cbb3faa9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139302
> Reviewed-by: Régis Crelier <regis@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,asiva@google.com,regis@google.com

Change-Id: I2f13dac7f2d7441f8db61543261ca28f500b8adc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139319
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2020-03-12 22:41:41 +00:00 committed by commit-bot@chromium.org
parent cd3a13e3f6
commit 42e6cf4967
20 changed files with 34 additions and 46 deletions

View file

@ -32,7 +32,7 @@ main() {
'E',
'F'
];
var symbols = <dynamic>[];
var symbols = new List();
for (var high in digits) {
for (var low in digits) {
symbols.add(MirrorSystem.getSymbol("v$high$low"));

View file

@ -49,7 +49,7 @@ void main() {
var a2 = myConst2;
asyncStart();
lib.loadLibrary()!.then((_) {
lib.loadLibrary().then((_) {
var instance = lib.constantInstance;
var c1 = const lib.Const(); //# constructor1: compile-time error
var c2 = const lib.Const.namedConstructor(); //# constructor2: compile-time error

View file

@ -36,7 +36,7 @@ class D {
void main() {
asyncStart();
lib1.loadLibrary()!.then((_) {
lib1.loadLibrary().then((_) {
Expect.equals("ABCD", lib1.foo());
new C();
new D();

View file

@ -11,7 +11,7 @@ import "deferred_mirrors_metatarget_lib.dart" deferred as lib;
void main() {
asyncStart();
lib.loadLibrary()!.then((_) {
lib.loadLibrary().then((_) {
Expect.equals("A", lib.foo());
asyncEnd();
});

View file

@ -10,7 +10,7 @@ class D {}
void main() {
print(reflectClass(D).owner);
l.loadLibrary()!.then((_) {
l.loadLibrary().then((_) {
l.foo();
});
}

View file

@ -10,7 +10,7 @@ import 'package:expect/expect.dart';
class Foo<T> {
List<T> makeList() {
if (new DateTime.now().millisecondsSinceEpoch == 42) return [];
return <T>[];
return new List<T>();
}
}

View file

@ -10,7 +10,7 @@ import 'package:expect/expect.dart';
import 'declarations_model_easier.dart' as declarations_model;
selectKeys<K, V>(Map<K, V> map, bool Function(V) predicate) {
return map.keys.where((K key) => predicate(map[key] as V));
return map.keys.where((K key) => predicate(map[key]));
}
class EasierSuperclass {

View file

@ -10,7 +10,7 @@ import 'package:expect/expect.dart';
import 'declarations_model.dart' as declarations_model;
selectKeys<K, V>(Map<K, V> map, bool Function(V) predicate) {
return map.keys.where((K key) => predicate(map[key] as V));
return map.keys.where((K key) => predicate(map[key]));
}
main() {

View file

@ -29,7 +29,7 @@ abstract class C extends S {
}
selectKeys<K, V>(Map<K, V> map, bool Function(V) predicate) {
return map.keys.where((K key) => predicate(map[key] as V));
return map.keys.where((K key) => predicate(map[key]));
}
main() {

View file

@ -11,7 +11,7 @@ assertInstanitationErrorOnGenerativeConstructors(classMirror) {
classMirror.declarations.values.forEach((decl) {
if (decl is! MethodMirror) return;
if (!decl.isGenerativeConstructor) return;
var args = new List<dynamic>.filled(decl.parameters.length, null);
var args = new List(decl.parameters.length);
Expect.throws(
() => classMirror.newInstance(decl.constructorName, args),
(e) => e is AbstractClassInstantiationError,
@ -23,7 +23,7 @@ runFactoryConstructors(classMirror) {
classMirror.declarations.values.forEach((decl) {
if (decl is! MethodMirror) return;
if (!decl.isFactoryConstructor) return;
var args = new List<dynamic>.filled(decl.parameters.length, null);
var args = new List(decl.parameters.length);
classMirror.newInstance(decl.constructorName, args); // Should not throw.
});
}

View file

@ -55,7 +55,7 @@ class Task {
dynamic action;
}
var queue = <Task>[];
var queue = new List<Task>();
checkMethod(MethodMirror m, ObjectMirror target, [origin]) {
if (isBlacklisted(m.qualifiedName)) return;
@ -152,7 +152,7 @@ main() {
fuzzArgument = 1; // //# smi: ok
fuzzArgument = false; // //# false: ok
fuzzArgument = 'string'; // //# string: ok
fuzzArgument = new List<dynamic>.filled(0, null); // //# emptyarray: ok
fuzzArgument = new List(0); // //# emptyarray: ok
print('Fuzzing with $fuzzArgument');

View file

@ -49,7 +49,7 @@ confuse(x) {
}
main() {
var list = ["foo", <dynamic>[], new A()];
var list = ["foo", new List(), new A()];
getAMirror() => reflect(list[confuse(2)]);
@ -83,14 +83,11 @@ main() {
// Now the same thing through mirrors and mirror-invocation.
f = getAMirror().getField(#codeUnitAt);
Expect.equals(
"codeUnitAt-42", f.invoke(#call, [42], <Symbol, dynamic>{}).reflectee);
Expect.equals("codeUnitAt-42", f.invoke(#call, [42], {}).reflectee);
f = getAMirror().getField(#toUpperCase);
Expect.equals(
"toUpperCase", f.invoke(#call, [], <Symbol, dynamic>{}).reflectee);
Expect.equals("toUpperCase", f.invoke(#call, [], {}).reflectee);
f = getAMirror().getField(#indexOf);
Expect.equals(
"indexOf-499", f.invoke(#call, [499], <Symbol, dynamic>{}).reflectee);
Expect.equals("indexOf-499", f.invoke(#call, [499], {}).reflectee);
f = getAMirror().getField(#lastIndexOf);
Expect.equals(
"lastIndexOf-FOO,BAR", f.invoke(#call, ["FOO", "BAR"]).reflectee);
@ -117,14 +114,11 @@ main() {
Expect.equals("toSet-true", f(named: true));
f = getAMirror().getField(#endsWith);
Expect.equals(
"endsWith-42", f.invoke(#call, [42], <Symbol, dynamic>{}).reflectee);
Expect.equals("endsWith-42", f.invoke(#call, [42], {}).reflectee);
f = getAMirror().getField(#toLowerCase);
Expect.equals(
"toLowerCase", f.invoke(#call, [], <Symbol, dynamic>{}).reflectee);
Expect.equals("toLowerCase", f.invoke(#call, [], {}).reflectee);
f = getAMirror().getField(#indexOf);
Expect.equals(
"indexOf-499", f.invoke(#call, [499], <Symbol, dynamic>{}).reflectee);
Expect.equals("indexOf-499", f.invoke(#call, [499], {}).reflectee);
f = getAMirror().getField(#matchAsPrefix);
Expect.equals(
"matchAsPrefix-FOO,BAR", f.invoke(#call, ["FOO", "BAR"]).reflectee);

View file

@ -17,9 +17,9 @@ main() {
LibraryMirror dartcore = reflectClass(Object).owner as LibraryMirror;
test('List_copyFromObjectArray', () {
var receiver = new List<dynamic>.filled(3, null);
var receiver = new List(3);
var selector = MirrorSystem.getSymbol('_copyFromObjectArray', dartcore);
var src = new List<dynamic>.filled(3, null);
var src = new List(3);
var srcStart = 10;
var dstStart = 10;
var count = 10;

View file

@ -16,7 +16,7 @@ main() {
"should not be loaded yet");
asyncStart();
other.loadLibrary()!.then((_) {
other.loadLibrary().then((_) {
asyncEnd();
LibraryMirror otherMirror = ms.findLibrary(#test.other_library);
Expect.isNotNull(otherMirror);

View file

@ -32,7 +32,7 @@ class M2 {
class C extends S with M1, M2 {}
membersOf(ClassMirror cm) {
var result = new Map<Symbol, dynamic>();
var result = new Map();
cm.declarations.forEach((k, v) {
if (v is MethodMirror && !v.isConstructor) result[k] = v;
if (v is VariableMirror) result[k] = v;

View file

@ -11,7 +11,7 @@ import 'stringify.dart';
import 'declarations_model_easier.dart' as declarations_model;
selectKeys<K, V>(Map<K, V> map, bool Function(V) predicate) {
return map.keys.where((K key) => predicate(map[key] as V));
return map.keys.where((K key) => predicate(map[key]));
}
main() {

View file

@ -11,7 +11,7 @@ import 'stringify.dart';
import 'declarations_model.dart' as declarations_model;
selectKeys<K, V>(Map<K, V> map, bool Function(V) predicate) {
return map.keys.where((K key) => predicate(map[key] as V));
return map.keys.where((K key) => predicate(map[key]));
}
main() {

View file

@ -141,7 +141,7 @@ String stringifyDependencies(LibraryMirror l) {
if (dep.prefix != null) buffer.write(' as ${n(dep.prefix)}');
buffer.write('\n');
var flattenedCombinators = <dynamic>[];
List flattenedCombinators = new List();
dep.combinators.forEach((com) {
com.identifiers.forEach((ident) {
flattenedCombinators.add([n(ident), com.isShow, com.isHide]);

View file

@ -12,7 +12,7 @@ import 'package:expect/expect.dart';
main() {
asyncStart();
def.loadLibrary()!.then((_) {
def.loadLibrary().then((_) {
var barLibrary = currentMirrorSystem().findLibrary(new Symbol("bar"));
var gTypedef = barLibrary.declarations[new Symbol("G")]!;
Expect.equals("G", MirrorSystem.getName(gTypedef.simpleName));

View file

@ -83,14 +83,11 @@ main() {
// Now the same thing through mirrors and mirror-invocation.
f = getAMirror().getField(#codeUnitAt);
Expect.equals(
"codeUnitAt-42", f.invoke(#call, [42], <Symbol, dynamic>{}).reflectee);
Expect.equals("codeUnitAt-42", f.invoke(#call, [42], {}).reflectee);
f = getAMirror().getField(#toUpperCase);
Expect.equals(
"toUpperCase", f.invoke(#call, [], <Symbol, dynamic>{}).reflectee);
Expect.equals("toUpperCase", f.invoke(#call, [], {}).reflectee);
f = getAMirror().getField(#indexOf);
Expect.equals(
"indexOf-499", f.invoke(#call, [499], <Symbol, dynamic>{}).reflectee);
Expect.equals("indexOf-499", f.invoke(#call, [499], {}).reflectee);
f = getAMirror().getField(#lastIndexOf);
Expect.equals(
"lastIndexOf-FOO,BAR", f.invoke(#call, ["FOO", "BAR"]).reflectee);
@ -117,14 +114,11 @@ main() {
Expect.equals("toSet-true", f(named: true));
f = getAMirror().getField(#endsWith);
Expect.equals(
"endsWith-42", f.invoke(#call, [42], <Symbol, dynamic>{}).reflectee);
Expect.equals("endsWith-42", f.invoke(#call, [42], {}).reflectee);
f = getAMirror().getField(#toLowerCase);
Expect.equals(
"toLowerCase", f.invoke(#call, [], <Symbol, dynamic>{}).reflectee);
Expect.equals("toLowerCase", f.invoke(#call, [], {}).reflectee);
f = getAMirror().getField(#indexOf);
Expect.equals(
"indexOf-499", f.invoke(#call, [499], <Symbol, dynamic>{}).reflectee);
Expect.equals("indexOf-499", f.invoke(#call, [499], {}).reflectee);
f = getAMirror().getField(#matchAsPrefix);
Expect.equals(
"matchAsPrefix-FOO,BAR", f.invoke(#call, ["FOO", "BAR"]).reflectee);