[kernel] Migrate tests
Change-Id: If426fc15f7bce54b51eaac3354061684cd5b0e17 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207129 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
c49560cd37
commit
286702df6b
@@ -0,0 +1,3 @@
|
||||
// @dart = 2.9
|
||||
Iterable<int> getElements() sync* {}
|
||||
main() => print(getElements());
|
||||
@@ -0,0 +1,3 @@
|
||||
// @dart = 2.9
|
||||
Iterable<int> getElements() sync* {}
|
||||
main() => print(getElements());
|
||||
@@ -0,0 +1,13 @@
|
||||
library;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
static method getElements() → core::Iterable<core::int*>* sync* {
|
||||
core::Iterable<core::int*>* elements;
|
||||
elements = (() → core::Iterable<core::int*>* sync* {
|
||||
yield 7;
|
||||
})(){() →* core::Iterable<core::int*>*};
|
||||
yield* elements;
|
||||
}
|
||||
static method main() → dynamic
|
||||
return core::print(self::getElements());
|
||||
@@ -0,0 +1,8 @@
|
||||
library;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
static method getElements() → core::Iterable<core::int*>* sync*
|
||||
;
|
||||
static method main() → dynamic
|
||||
;
|
||||
@@ -0,0 +1,41 @@
|
||||
library;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
static method getElements() → core::Iterable<core::int*>* /* originally sync* */ {
|
||||
function :sync_op_gen() → (core::_SyncIterator<dynamic>*, dynamic, dynamic) →* core::bool* {
|
||||
core::int* :await_jump_var = 0;
|
||||
dynamic :await_ctx_var;
|
||||
function :sync_op(core::_SyncIterator<dynamic>* :iterator, dynamic :exception, dynamic :stack_trace) → core::bool* yielding {
|
||||
{
|
||||
core::Iterable<core::int*>* elements;
|
||||
elements = (() → core::Iterable<core::int*>* /* originally sync* */ {
|
||||
function :sync_op_gen() → (core::_SyncIterator<dynamic>*, dynamic, dynamic) →* core::bool* {
|
||||
core::int* :await_jump_var = 0;
|
||||
dynamic :await_ctx_var;
|
||||
function :sync_op(core::_SyncIterator<dynamic>* :iterator, dynamic :exception, dynamic :stack_trace) → core::bool* yielding {
|
||||
{
|
||||
{
|
||||
:iterator.{core::_SyncIterator::_current} = 7;
|
||||
[yield] true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return :sync_op;
|
||||
}
|
||||
return new core::_SyncIterable::•<core::int*>(:sync_op_gen);
|
||||
})(){() →* core::Iterable<core::int*>*};
|
||||
{
|
||||
:iterator.{core::_SyncIterator::_yieldEachIterable} = elements;
|
||||
[yield] true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return :sync_op;
|
||||
}
|
||||
return new core::_SyncIterable::•<core::int*>(:sync_op_gen);
|
||||
}
|
||||
static method main() → dynamic
|
||||
return core::print(self::getElements());
|
||||
@@ -3,7 +3,9 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
//
|
||||
// Regression test for https://github.com/dart-lang/sdk/issues/40662.
|
||||
|
||||
// @dart=2.9
|
||||
|
||||
bar(int a, List<int> b) {
|
||||
expect(-1, a);
|
||||
expect(-1, (b[0] - 2));
|
||||
|
||||
@@ -86,6 +86,6 @@ static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
|
||||
|
||||
Extra constant evaluation status:
|
||||
Evaluated: InstanceInvocation @ org-dartlang-testcase:///issue40662.dart:8:10 -> IntConstant(-1)
|
||||
Evaluated: InstanceInvocation @ org-dartlang-testcase:///issue40662.dart:9:10 -> IntConstant(-1)
|
||||
Evaluated: InstanceInvocation @ org-dartlang-testcase:///issue40662.dart:10:10 -> IntConstant(-1)
|
||||
Evaluated: InstanceInvocation @ org-dartlang-testcase:///issue40662.dart:11:10 -> IntConstant(-1)
|
||||
Extra constant evaluation: evaluated: 94, effectively constant: 2
|
||||
|
||||
@@ -1722,8 +1722,6 @@ class ClassSet extends IterableBase<Class> {
|
||||
/// are removed first; in the case of ties, classes with lower topological sort
|
||||
/// index are removed first.
|
||||
class _LubHeap extends Heap<_ClassInfo> {
|
||||
_LubHeap() : super(_dummyClassInfo);
|
||||
|
||||
@override
|
||||
bool sortsBefore(_ClassInfo a, _ClassInfo b) => sortsBeforeStatic(a, b);
|
||||
|
||||
@@ -1733,5 +1731,3 @@ class _LubHeap extends Heap<_ClassInfo> {
|
||||
return a.topologicalIndex < b.topologicalIndex;
|
||||
}
|
||||
}
|
||||
|
||||
final _ClassInfo _dummyClassInfo = new _ClassInfo(dummyClass);
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
/// Basic implementation of a heap, with O(log n) insertion and removal.
|
||||
abstract class Heap<T> {
|
||||
final _items = <T>[];
|
||||
final T _dummyValue;
|
||||
|
||||
Heap(this._dummyValue);
|
||||
|
||||
bool get isEmpty => _items.isEmpty;
|
||||
|
||||
@@ -15,7 +12,7 @@ abstract class Heap<T> {
|
||||
|
||||
void add(T item) {
|
||||
int index = _items.length;
|
||||
_items.add(_dummyValue);
|
||||
_items.add(item);
|
||||
while (index > 0) {
|
||||
T parent = _items[_parentIndex(index)];
|
||||
if (sortsBefore(parent, item)) break;
|
||||
|
||||
@@ -714,7 +714,7 @@ class Optional<T> extends TextSerializer<T?> {
|
||||
/// Serializes an object and uses it as a binder for the name that is retrieved
|
||||
/// from the object using [nameGetter] and (temporarily) modified using
|
||||
/// [nameSetter]. The binder is added to the enclosing environment.
|
||||
class Binder<T extends Node> extends TextSerializer<Tuple2<String, T>> {
|
||||
class Binder<T extends Node> extends TextSerializer<Tuple2<String?, T>> {
|
||||
final Tuple2Serializer<String, T> namedContents;
|
||||
|
||||
Binder(TextSerializer<T> contents)
|
||||
@@ -733,13 +733,13 @@ class Binder<T extends Node> extends TextSerializer<Tuple2<String, T>> {
|
||||
return new Tuple2(name, object);
|
||||
}
|
||||
|
||||
void writeTo(StringBuffer buffer, Tuple2<String, T> namedObject,
|
||||
void writeTo(StringBuffer buffer, Tuple2<String?, T> namedObject,
|
||||
SerializationState? state) {
|
||||
if (state == null) {
|
||||
throw StateError(
|
||||
"No serialization state provided for ${runtimeType}.writeTo.");
|
||||
}
|
||||
String nameClue = namedObject.first;
|
||||
String? nameClue = namedObject.first;
|
||||
T object = namedObject.second;
|
||||
String distinctName =
|
||||
state.environment.addBinder(object, nameClue: nameClue);
|
||||
|
||||
@@ -1706,7 +1706,7 @@ TextSerializer<LabeledStatement> labeledStatementSerializer =
|
||||
(ls) => Tuple2(ls, ls.body),
|
||||
(t) => t.first..body = t.second,
|
||||
Bind(
|
||||
Wrapped<Tuple2<String, LabeledStatement>, LabeledStatement>(
|
||||
Wrapped<Tuple2<String?, LabeledStatement>, LabeledStatement>(
|
||||
(ls) => Tuple2("L", ls),
|
||||
(t) => t.second,
|
||||
Binder(Wrapped(
|
||||
@@ -1775,7 +1775,7 @@ class SwitchCaseTagger implements Tagger<SwitchCase> {
|
||||
}
|
||||
|
||||
TextSerializer<SwitchCase> switchCaseCaseSerializer =
|
||||
Wrapped<Tuple2<String, SwitchCase>, SwitchCase>(
|
||||
Wrapped<Tuple2<String?, SwitchCase>, SwitchCase>(
|
||||
(w) => Tuple2("L", w),
|
||||
(u) => u.second,
|
||||
Binder(Wrapped<List<Expression>, SwitchCase>(
|
||||
@@ -1784,7 +1784,7 @@ TextSerializer<SwitchCase> switchCaseCaseSerializer =
|
||||
ListSerializer(expressionSerializer))));
|
||||
|
||||
TextSerializer<SwitchCase> switchCaseDefaultSerializer = Wrapped<
|
||||
Tuple2<String, SwitchCase>, SwitchCase>(
|
||||
Tuple2<String?, SwitchCase>, SwitchCase>(
|
||||
(w) => Tuple2("L", w),
|
||||
(u) => u.second,
|
||||
Binder(
|
||||
|
||||
@@ -3,8 +3,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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'dart:io';
|
||||
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:kernel/binary/ast_from_binary.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/binary/ast_from_binary.dart';
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/binary/ast_from_binary.dart' show ParseError;
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/binary/ast_from_binary.dart';
|
||||
import 'package:kernel/src/tool/find_referenced_libraries.dart';
|
||||
import 'utils.dart';
|
||||
@@ -47,9 +45,9 @@ main() {
|
||||
final Library loadedLib = loadedComponent.libraries.single;
|
||||
final Class loadedClassA = loadedLib.classes.first;
|
||||
final ExpressionStatement loadedConstructorA =
|
||||
loadedClassA.constructors.single.function.body;
|
||||
loadedClassA.constructors.single.function.body as ExpressionStatement;
|
||||
final ConstructorInvocation loadedConstructorInvocation =
|
||||
loadedConstructorA.expression;
|
||||
loadedConstructorA.expression as ConstructorInvocation;
|
||||
final Class pointedToClass =
|
||||
loadedConstructorInvocation.target.enclosingClass;
|
||||
final Library pointedToLib =
|
||||
@@ -81,9 +79,9 @@ main() {
|
||||
final Library loadedLib = loadedComponent2.libraries.single;
|
||||
final Class loadedClassA = loadedLib.classes.first;
|
||||
final ExpressionStatement loadedConstructorA =
|
||||
loadedClassA.constructors.single.function.body;
|
||||
loadedClassA.constructors.single.function.body as ExpressionStatement;
|
||||
final ConstructorInvocation loadedConstructorInvocation =
|
||||
loadedConstructorA.expression;
|
||||
loadedConstructorA.expression as ConstructorInvocation;
|
||||
final Class pointedToClass =
|
||||
loadedConstructorInvocation.target.enclosingClass;
|
||||
final Library pointedToLib =
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
/// Test that library flags are serialized and read correctly.
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:io' show BytesBuilder;
|
||||
|
||||
import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// This files contains methods for benchmarking Kernel binary serialization
|
||||
// and deserialization routines.
|
||||
|
||||
@@ -35,8 +33,8 @@ final benchmarks = <String, Benchmark>{
|
||||
},
|
||||
};
|
||||
|
||||
Benchmark benchmark;
|
||||
File sourceDill;
|
||||
Benchmark? benchmark;
|
||||
late File sourceDill;
|
||||
bool forGolem = false;
|
||||
bool forRaw = false;
|
||||
|
||||
@@ -47,7 +45,7 @@ main(List<String> args) async {
|
||||
}
|
||||
|
||||
final bytes = sourceDill.readAsBytesSync();
|
||||
benchmark(bytes);
|
||||
benchmark!(bytes);
|
||||
}
|
||||
|
||||
const warmupIterations = 100;
|
||||
@@ -64,7 +62,8 @@ void _benchmarkAstFromBinary(Uint8List bytes, {bool eager: true}) {
|
||||
}
|
||||
final warmupUs = sw.elapsedMicroseconds / warmupIterations;
|
||||
|
||||
final runsUs = new List<int>.filled(benchmarkIterations, null);
|
||||
final runsUs =
|
||||
new List<int>.filled(benchmarkIterations, /* dummy value = */ 0);
|
||||
for (var i = 0; i < benchmarkIterations; i++) {
|
||||
sw.reset();
|
||||
_fromBinary(bytes, eager: eager);
|
||||
@@ -88,7 +87,8 @@ void _benchmarkAstToBinary(Uint8List bytes) {
|
||||
}
|
||||
final warmupUs = sw.elapsedMicroseconds / warmupIterations;
|
||||
|
||||
final runsUs = new List<int>.filled(benchmarkIterations, null);
|
||||
final runsUs =
|
||||
new List<int>.filled(benchmarkIterations, /* dummy value = */ 0);
|
||||
for (var i = 0; i < benchmarkIterations; i++) {
|
||||
sw.reset();
|
||||
_toBinary(p);
|
||||
@@ -106,7 +106,7 @@ class BenchmarkResult {
|
||||
|
||||
BenchmarkResult(this.name, this.coldRunUs, this.warmupUs, this.runsUs);
|
||||
|
||||
static T add<T extends num>(T x, T y) => x + y;
|
||||
static T add<T extends num>(T x, T y) => x + y as T;
|
||||
|
||||
void report() {
|
||||
runsUs.sort();
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library kernel.class_hierarchy_basic;
|
||||
|
||||
import 'package:kernel/class_hierarchy.dart';
|
||||
@@ -97,19 +95,19 @@ class BasicClassHierarchy implements ClassHierarchy {
|
||||
superMixtures[node] = new Set<Class>()..add(node);
|
||||
supertypes[node] = new Set<Class>()..add(node);
|
||||
if (node.supertype != null) {
|
||||
buildSuperTypeSets(node.supertype.classNode);
|
||||
superclasses[node].addAll(superclasses[node.supertype.classNode]);
|
||||
superMixtures[node].addAll(superMixtures[node.supertype.classNode]);
|
||||
supertypes[node].addAll(supertypes[node.supertype.classNode]);
|
||||
buildSuperTypeSets(node.supertype!.classNode);
|
||||
superclasses[node]!.addAll(superclasses[node.supertype!.classNode]!);
|
||||
superMixtures[node]!.addAll(superMixtures[node.supertype!.classNode]!);
|
||||
supertypes[node]!.addAll(supertypes[node.supertype!.classNode]!);
|
||||
}
|
||||
if (node.mixedInType != null) {
|
||||
buildSuperTypeSets(node.mixedInType.classNode);
|
||||
superMixtures[node].addAll(superMixtures[node.mixedInType.classNode]);
|
||||
supertypes[node].addAll(supertypes[node.mixedInType.classNode]);
|
||||
buildSuperTypeSets(node.mixedInType!.classNode);
|
||||
superMixtures[node]!.addAll(superMixtures[node.mixedInType!.classNode]!);
|
||||
supertypes[node]!.addAll(supertypes[node.mixedInType!.classNode]!);
|
||||
}
|
||||
for (var supertype in node.implementedTypes) {
|
||||
buildSuperTypeSets(supertype.classNode);
|
||||
supertypes[node].addAll(supertypes[supertype.classNode]);
|
||||
supertypes[node]!.addAll(supertypes[supertype.classNode]!);
|
||||
}
|
||||
classes.add(node);
|
||||
classIndex[node] = classes.length - 1;
|
||||
@@ -125,8 +123,8 @@ class BasicClassHierarchy implements ClassHierarchy {
|
||||
buildSuperTypeInstantiations(superclass);
|
||||
var substitution = Substitution.fromPairs(
|
||||
superclass.typeParameters, supertype.typeArguments);
|
||||
supertypeInstantiations[superclass].forEach((key, type) {
|
||||
supertypeInstantiations[node][key] =
|
||||
supertypeInstantiations[superclass]!.forEach((key, type) {
|
||||
supertypeInstantiations[node]![key] =
|
||||
substitution.substituteSupertype(type);
|
||||
});
|
||||
}
|
||||
@@ -137,25 +135,26 @@ class BasicClassHierarchy implements ClassHierarchy {
|
||||
gettersAndCalls[node] = <Name, Member>{};
|
||||
setters[node] = <Name, Member>{};
|
||||
if (node.supertype != null) {
|
||||
buildDispatchTable(node.supertype.classNode);
|
||||
gettersAndCalls[node].addAll(gettersAndCalls[node.supertype.classNode]);
|
||||
setters[node].addAll(setters[node.supertype.classNode]);
|
||||
buildDispatchTable(node.supertype!.classNode);
|
||||
gettersAndCalls[node]!
|
||||
.addAll(gettersAndCalls[node.supertype!.classNode]!);
|
||||
setters[node]!.addAll(setters[node.supertype!.classNode]!);
|
||||
}
|
||||
// Overwrite map entries with declared members.
|
||||
Class mixin = node.mixedInType?.classNode ?? node;
|
||||
for (Procedure procedure in mixin.procedures) {
|
||||
if (procedure.isStatic || procedure.isAbstract) continue;
|
||||
if (procedure.kind == ProcedureKind.Setter) {
|
||||
setters[node][procedure.name] = procedure;
|
||||
setters[node]![procedure.name] = procedure;
|
||||
} else {
|
||||
gettersAndCalls[node][procedure.name] = procedure;
|
||||
gettersAndCalls[node]![procedure.name] = procedure;
|
||||
}
|
||||
}
|
||||
for (Field field in mixin.fields) {
|
||||
if (field.isStatic) continue;
|
||||
gettersAndCalls[node][field.name] = field;
|
||||
gettersAndCalls[node]![field.name] = field;
|
||||
if (!field.isFinal) {
|
||||
setters[node][field.name] = field;
|
||||
setters[node]![field.name] = field;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,7 +162,7 @@ class BasicClassHierarchy implements ClassHierarchy {
|
||||
void mergeMaps(
|
||||
Map<Name, List<Member>> source, Map<Name, List<Member>> destination) {
|
||||
for (var name in source.keys) {
|
||||
destination.putIfAbsent(name, () => <Member>[]).addAll(source[name]);
|
||||
destination.putIfAbsent(name, () => <Member>[]).addAll(source[name]!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,12 +170,12 @@ class BasicClassHierarchy implements ClassHierarchy {
|
||||
if (interfaceGettersAndCalls.containsKey(node)) return;
|
||||
interfaceGettersAndCalls[node] = <Name, List<Member>>{};
|
||||
interfaceSetters[node] = <Name, List<Member>>{};
|
||||
void inheritFrom(Supertype type) {
|
||||
void inheritFrom(Supertype? type) {
|
||||
if (type == null) return;
|
||||
buildInterfaceTable(type.classNode);
|
||||
mergeMaps(interfaceGettersAndCalls[type.classNode],
|
||||
interfaceGettersAndCalls[node]);
|
||||
mergeMaps(interfaceSetters[type.classNode], interfaceSetters[node]);
|
||||
mergeMaps(interfaceGettersAndCalls[type.classNode]!,
|
||||
interfaceGettersAndCalls[node]!);
|
||||
mergeMaps(interfaceSetters[type.classNode]!, interfaceSetters[node]!);
|
||||
}
|
||||
|
||||
inheritFrom(node.supertype);
|
||||
@@ -186,70 +185,70 @@ class BasicClassHierarchy implements ClassHierarchy {
|
||||
for (Procedure procedure in node.mixin.procedures) {
|
||||
if (procedure.isStatic) continue;
|
||||
if (procedure.kind == ProcedureKind.Setter) {
|
||||
interfaceSetters[node][procedure.name] = <Member>[procedure];
|
||||
interfaceSetters[node]![procedure.name] = <Member>[procedure];
|
||||
} else {
|
||||
interfaceGettersAndCalls[node][procedure.name] = <Member>[procedure];
|
||||
interfaceGettersAndCalls[node]![procedure.name] = <Member>[procedure];
|
||||
}
|
||||
}
|
||||
for (Field field in node.mixin.fields) {
|
||||
if (field.isStatic) continue;
|
||||
interfaceGettersAndCalls[node][field.name] = <Member>[field];
|
||||
interfaceGettersAndCalls[node]![field.name] = <Member>[field];
|
||||
if (!field.isFinal) {
|
||||
interfaceSetters[node][field.name] = <Member>[field];
|
||||
interfaceSetters[node]![field.name] = <Member>[field];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isSubclassOf(Class subtype, Class supertype) {
|
||||
return superclasses[subtype].contains(supertype);
|
||||
return superclasses[subtype]!.contains(supertype);
|
||||
}
|
||||
|
||||
bool isSubmixtureOf(Class subtype, Class supertype) {
|
||||
return superMixtures[subtype].contains(supertype);
|
||||
return superMixtures[subtype]!.contains(supertype);
|
||||
}
|
||||
|
||||
bool isSubtypeOf(Class subtype, Class supertype) {
|
||||
return supertypes[subtype].contains(supertype);
|
||||
return supertypes[subtype]!.contains(supertype);
|
||||
}
|
||||
|
||||
Supertype getClassAsInstanceOf(Class type, Class supertype) {
|
||||
return supertypeInstantiations[type][supertype];
|
||||
Supertype? getClassAsInstanceOf(Class type, Class supertype) {
|
||||
return supertypeInstantiations[type]![supertype];
|
||||
}
|
||||
|
||||
Member getDispatchTarget(Class class_, Name name, {bool setter: false}) {
|
||||
return setter ? setters[class_][name] : gettersAndCalls[class_][name];
|
||||
Member? getDispatchTarget(Class class_, Name name, {bool setter: false}) {
|
||||
return setter ? setters[class_]![name] : gettersAndCalls[class_]![name];
|
||||
}
|
||||
|
||||
List<Member> getDispatchTargets(Class class_, {bool setters: false}) {
|
||||
return setters
|
||||
? this.setters[class_].values
|
||||
: gettersAndCalls[class_].values;
|
||||
? this.setters[class_]!.values.toList()
|
||||
: gettersAndCalls[class_]!.values.toList();
|
||||
}
|
||||
|
||||
Member tryFirst(List<Member> members) {
|
||||
return (members == null || members.isEmpty) ? null : members[0];
|
||||
Member? tryFirst(Iterable<Member>? members) {
|
||||
return (members == null || members.isEmpty) ? null : members.first;
|
||||
}
|
||||
|
||||
Member getInterfaceMember(Class class_, Name name, {bool setter: false}) {
|
||||
Member? getInterfaceMember(Class class_, Name name, {bool setter: false}) {
|
||||
return tryFirst(getInterfaceMembersByName(class_, name, setter: setter));
|
||||
}
|
||||
|
||||
Iterable<Member> getInterfaceMembersByName(Class class_, Name name,
|
||||
{bool setter: false}) {
|
||||
var iterable = setter
|
||||
? interfaceSetters[class_][name]
|
||||
: interfaceGettersAndCalls[class_][name];
|
||||
? interfaceSetters[class_]![name]
|
||||
: interfaceGettersAndCalls[class_]![name];
|
||||
return iterable == null ? const <Member>[] : iterable;
|
||||
}
|
||||
|
||||
List<Member> getInterfaceMembers(Class class_, {bool setters: false}) {
|
||||
return setters
|
||||
? interfaceSetters[class_].values.expand((x) => x)
|
||||
: interfaceGettersAndCalls[class_].values.expand((x) => x);
|
||||
? interfaceSetters[class_]!.values.expand((x) => x).toList()
|
||||
: interfaceGettersAndCalls[class_]!.values.expand((x) => x).toList();
|
||||
}
|
||||
|
||||
int getClassIndex(Class node) {
|
||||
return classIndex[node];
|
||||
return classIndex[node]!;
|
||||
}
|
||||
|
||||
List<int> getExpenseHistogram() => <int>[];
|
||||
|
||||
@@ -3,8 +3,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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'package:kernel/class_hierarchy.dart';
|
||||
import 'package:kernel/core_types.dart';
|
||||
@@ -61,7 +59,8 @@ main(List<String> args) {
|
||||
int hierarchyCount = int.parse(options['cycle']);
|
||||
var hierarchies = <ClosedWorldClassHierarchy>[];
|
||||
for (int i = 0; i < hierarchyCount; i++) {
|
||||
hierarchies.add(buildHierarchy());
|
||||
// TODO(johnniwinther): This doesn't work for the [BasicClassHierarchy].
|
||||
hierarchies.add(buildHierarchy() as ClosedWorldClassHierarchy);
|
||||
}
|
||||
|
||||
List<Class> classes = hierarchies.first.classes.toList();
|
||||
@@ -246,13 +245,13 @@ main(List<String> args) {
|
||||
classIds[class_] = classIds.length;
|
||||
}
|
||||
|
||||
List<int> depth = new List.filled(classes.length, null);
|
||||
List<int> depth = new List.filled(classes.length, /* dummy value = */ 0);
|
||||
for (int i = 0; i < depth.length; ++i) {
|
||||
int parentDepth = 0;
|
||||
var classNode = classes[i];
|
||||
for (var supertype in classNode.supers) {
|
||||
var superclass = supertype.classNode;
|
||||
int index = classIds[superclass];
|
||||
int index = classIds[superclass]!;
|
||||
if (!(index < i)) {
|
||||
throw '${classNode.name}($i) extends ${superclass.name}($index)';
|
||||
}
|
||||
@@ -264,7 +263,7 @@ main(List<String> args) {
|
||||
List<int> depthHistogram = getHistogramOf(depth);
|
||||
double averageDepth = average(depth);
|
||||
double medianDepth = median(depth);
|
||||
int totalDepth = sum(depth);
|
||||
int totalDepth = sum(depth) as int;
|
||||
|
||||
int numberOfClasses = classes.length;
|
||||
String expenseHistogram =
|
||||
|
||||
@@ -3,8 +3,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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'package:kernel/class_hierarchy.dart';
|
||||
import 'package:kernel/core_types.dart';
|
||||
@@ -53,7 +51,8 @@ main(List<String> args) {
|
||||
|
||||
List<ClosedWorldClassHierarchy> keepAlive = <ClosedWorldClassHierarchy>[];
|
||||
for (int i = 0; i < copyCount; ++i) {
|
||||
keepAlive.add(buildHierarchy());
|
||||
// TODO(johnniwinther): This doesn't work for the [BasicClassHierarchy].
|
||||
keepAlive.add(buildHierarchy() as ClosedWorldClassHierarchy);
|
||||
}
|
||||
|
||||
print('$copyCount copies built');
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'package:kernel/class_hierarchy.dart';
|
||||
import 'package:kernel/core_types.dart';
|
||||
@@ -23,7 +21,7 @@ void testClassHierarchyOnComponent(Component component, {bool verbose: false}) {
|
||||
BasicClassHierarchy basic = new BasicClassHierarchy(component);
|
||||
CoreTypes coreTypes = new CoreTypes(component);
|
||||
ClosedWorldClassHierarchy classHierarchy =
|
||||
new ClassHierarchy(component, coreTypes);
|
||||
new ClassHierarchy(component, coreTypes) as ClosedWorldClassHierarchy;
|
||||
int total = classHierarchy.numberOfClasses;
|
||||
int progress = 0;
|
||||
for (var class1 in classHierarchy.classes) {
|
||||
@@ -60,18 +58,18 @@ void testClassHierarchyOnComponent(Component component, {bool verbose: false}) {
|
||||
progress = 0;
|
||||
for (var classNode in classHierarchy.classes) {
|
||||
Iterable<Name> candidateNames = <Iterable<Name>>[
|
||||
basic.gettersAndCalls[classNode].keys,
|
||||
basic.setters[classNode].keys,
|
||||
basic.gettersAndCalls[classNode]!.keys,
|
||||
basic.setters[classNode]!.keys,
|
||||
pickRandom(nameList, 100)
|
||||
].expand((x) => x);
|
||||
for (Name name in candidateNames) {
|
||||
Member expectedGetter =
|
||||
Member? expectedGetter =
|
||||
basic.getDispatchTarget(classNode, name, setter: false);
|
||||
Member expectedSetter =
|
||||
Member? expectedSetter =
|
||||
basic.getDispatchTarget(classNode, name, setter: true);
|
||||
Member actualGetter =
|
||||
Member? actualGetter =
|
||||
classHierarchy.getDispatchTarget(classNode, name, setter: false);
|
||||
Member actualSetter =
|
||||
Member? actualSetter =
|
||||
classHierarchy.getDispatchTarget(classNode, name, setter: true);
|
||||
if (actualGetter != expectedGetter) {
|
||||
fail('lookupGetter($classNode, $name) returned '
|
||||
@@ -90,18 +88,18 @@ void testClassHierarchyOnComponent(Component component, {bool verbose: false}) {
|
||||
progress = 0;
|
||||
for (var classNode in classHierarchy.classes) {
|
||||
Iterable<Name> candidateNames = [
|
||||
basic.interfaceGettersAndCalls[classNode].keys,
|
||||
basic.interfaceSetters[classNode].keys,
|
||||
basic.interfaceGettersAndCalls[classNode]!.keys,
|
||||
basic.interfaceSetters[classNode]!.keys,
|
||||
pickRandom(nameList, 100)
|
||||
].expand((x) => x);
|
||||
for (Name name in candidateNames) {
|
||||
Member expectedGetter =
|
||||
Member? expectedGetter =
|
||||
basic.getInterfaceMember(classNode, name, setter: false);
|
||||
Member expectedSetter =
|
||||
Member? expectedSetter =
|
||||
basic.getInterfaceMember(classNode, name, setter: true);
|
||||
Member actualGetter =
|
||||
Member? actualGetter =
|
||||
classHierarchy.getInterfaceMember(classNode, name, setter: false);
|
||||
Member actualSetter =
|
||||
Member? actualSetter =
|
||||
classHierarchy.getInterfaceMember(classNode, name, setter: true);
|
||||
if (actualGetter != expectedGetter) {
|
||||
fail('getInterfaceMember($classNode, $name) returned '
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/minitest.dart";
|
||||
|
||||
import "package:kernel/ast.dart";
|
||||
@@ -82,11 +80,11 @@ main() {
|
||||
|
||||
class ClosedWorldClassHierarchyTest {
|
||||
final Component component = createMockSdkComponent();
|
||||
CoreTypes coreTypes;
|
||||
late CoreTypes coreTypes;
|
||||
|
||||
Library library;
|
||||
late Library library;
|
||||
|
||||
ClassHierarchy _hierarchy;
|
||||
ClassHierarchy? _hierarchy;
|
||||
|
||||
ClosedWorldClassHierarchyTest() {
|
||||
coreTypes = new CoreTypes(component);
|
||||
@@ -335,8 +333,9 @@ class H extends self::G implements self::C, self::A {}
|
||||
/// The [TypeParameterType]s corresponding to [typeParameterNames] are
|
||||
/// passed to optional [extends_] and [implements_] callbacks.
|
||||
Class addGenericClass(String name, List<String> typeParameterNames,
|
||||
{Supertype extends_(List<DartType> typeParameterTypes),
|
||||
List<Supertype> implements_(List<DartType> typeParameterTypes)}) {
|
||||
{Supertype Function(List<DartType> typeParameterTypes)? extends_,
|
||||
List<Supertype> Function(List<DartType> typeParameterTypes)?
|
||||
implements_}) {
|
||||
var typeParameters = typeParameterNames
|
||||
.map((name) => new TypeParameter(
|
||||
name, coreTypes.objectLegacyRawType, coreTypes.objectLegacyRawType))
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'class_hierarchy_self_check.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/binary/ast_from_binary.dart';
|
||||
import 'package:kernel/binary/ast_to_binary.dart';
|
||||
import 'binary/utils.dart';
|
||||
@@ -42,14 +40,14 @@ main() {
|
||||
// Canonical names are now set: Verify that the field is marked as such,
|
||||
// canonical-name-wise.
|
||||
String getterCanonicalName = '${field.getterReference.canonicalName}';
|
||||
if (field.getterReference.canonicalName.parent.name != "@getters") {
|
||||
if (field.getterReference.canonicalName!.parent!.name != "@getters") {
|
||||
throw "Expected @getters parent, but had "
|
||||
"${field.getterReference.canonicalName.parent.name}";
|
||||
"${field.getterReference.canonicalName!.parent!.name}";
|
||||
}
|
||||
String setterCanonicalName = '${field.setterReference.canonicalName}';
|
||||
if (field.setterReference.canonicalName.parent.name != "@setters") {
|
||||
String setterCanonicalName = '${field.setterReference!.canonicalName}';
|
||||
if (field.setterReference!.canonicalName!.parent!.name != "@setters") {
|
||||
throw "Expected @setters parent, but had "
|
||||
"${field.setterReference.canonicalName.parent.name}";
|
||||
"${field.setterReference!.canonicalName!.parent!.name}";
|
||||
}
|
||||
|
||||
// Replace the field with a setter/getter pair.
|
||||
@@ -65,7 +63,7 @@ main() {
|
||||
// a setter/getter), the reference wouldn't (because of the way `bindTo` is
|
||||
// implemented) actually have it's canonical name set, and serialization
|
||||
// wouldn't work.)
|
||||
field.getterReference?.canonicalName?.unbind();
|
||||
field.getterReference.canonicalName?.unbind();
|
||||
lib1.addProcedure(getter);
|
||||
|
||||
FunctionNode setterFunction = new FunctionNode(new Block([]),
|
||||
@@ -82,18 +80,18 @@ main() {
|
||||
List<int> writtenBytesGetterSetter = serialize(lib1, lib2);
|
||||
// Canonical names are now set: Verify that the getter/setter is marked as
|
||||
// such, canonical-name-wise.
|
||||
if (getter.reference.canonicalName.parent.name != "@getters") {
|
||||
if (getter.reference.canonicalName!.parent!.name != "@getters") {
|
||||
throw "Expected @getters parent, but had "
|
||||
"${getter.reference.canonicalName.parent.name}";
|
||||
"${getter.reference.canonicalName!.parent!.name}";
|
||||
}
|
||||
if ('${getter.reference.canonicalName}' != getterCanonicalName) {
|
||||
throw "Unexpected getter canonical name. "
|
||||
"Expected $getterCanonicalName, "
|
||||
"actual ${getter.reference.canonicalName}.";
|
||||
}
|
||||
if (setter.reference.canonicalName.parent.name != "@setters") {
|
||||
if (setter.reference.canonicalName!.parent!.name != "@setters") {
|
||||
throw "Expected @setters parent, but had "
|
||||
"${setter.reference.canonicalName.parent.name}";
|
||||
"${setter.reference.canonicalName!.parent!.name}";
|
||||
}
|
||||
if ('${setter.reference.canonicalName}' != setterCanonicalName) {
|
||||
throw "Unexpected setter canonical name. "
|
||||
@@ -110,7 +108,7 @@ main() {
|
||||
fileUri: lib1Uri);
|
||||
// Important: Unbind any old canonical name
|
||||
// (nulling out the canonical name is not enough, see above).
|
||||
fieldReplacement.getterReference?.canonicalName?.unbind();
|
||||
fieldReplacement.getterReference.canonicalName?.unbind();
|
||||
fieldReplacement.setterReference?.canonicalName?.unbind();
|
||||
lib1.addField(fieldReplacement);
|
||||
|
||||
@@ -119,15 +117,15 @@ main() {
|
||||
List<int> writtenBytesFieldNew = serialize(lib1, lib2);
|
||||
// Canonical names are now set: Verify that the field is marked as such,
|
||||
// canonical-name-wise.
|
||||
if (fieldReplacement.getterReference.canonicalName.parent.name !=
|
||||
if (fieldReplacement.getterReference.canonicalName!.parent!.name !=
|
||||
"@getters") {
|
||||
throw "Expected @getters parent, but had "
|
||||
"${fieldReplacement.getterReference.canonicalName.parent.name}";
|
||||
"${fieldReplacement.getterReference.canonicalName!.parent!.name}";
|
||||
}
|
||||
if (fieldReplacement.setterReference.canonicalName.parent.name !=
|
||||
if (fieldReplacement.setterReference!.canonicalName!.parent!.name !=
|
||||
"@setters") {
|
||||
throw "Expected @setters parent, but had "
|
||||
"${fieldReplacement.setterReference.canonicalName.parent.name}";
|
||||
"${fieldReplacement.setterReference!.canonicalName!.parent!.name}";
|
||||
}
|
||||
|
||||
// Load the written stuff and ensure it is as expected.
|
||||
@@ -188,15 +186,16 @@ List<int> serialize(Library lib1, Library lib2) {
|
||||
}
|
||||
|
||||
Member getSetTarget(Procedure p) {
|
||||
Block block = p.function.body;
|
||||
ExpressionStatement getterStatement = block.statements[0];
|
||||
StaticSet staticSet = getterStatement.expression;
|
||||
Block block = p.function.body as Block;
|
||||
ExpressionStatement getterStatement =
|
||||
block.statements[0] as ExpressionStatement;
|
||||
StaticSet staticSet = getterStatement.expression as StaticSet;
|
||||
return staticSet.target;
|
||||
}
|
||||
|
||||
Member getGetTarget(Procedure p) {
|
||||
Block block = p.function.body;
|
||||
ReturnStatement setterStatement = block.statements[1];
|
||||
StaticGet staticGet = setterStatement.expression;
|
||||
Block block = p.function.body as Block;
|
||||
ReturnStatement setterStatement = block.statements[1] as ReturnStatement;
|
||||
StaticGet staticGet = setterStatement.expression as StaticGet;
|
||||
return staticGet.target;
|
||||
}
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart" show Expect;
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart" show Expect;
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
@@ -62,7 +60,7 @@ const Set<Test> data = {
|
||||
class Test {
|
||||
final String input;
|
||||
final String output;
|
||||
final String typeParameters;
|
||||
final String? typeParameters;
|
||||
|
||||
const Test(this.input, this.output, [this.typeParameters]);
|
||||
}
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart" show Expect;
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
|
||||
@@ -2,8 +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.md file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library kernel.test.graph_test;
|
||||
|
||||
import 'package:expect/expect.dart' show Expect;
|
||||
@@ -17,7 +15,7 @@ class TestGraph implements Graph<String> {
|
||||
|
||||
Iterable<String> get vertices => graph.keys;
|
||||
|
||||
Iterable<String> neighborsOf(String vertex) => graph[vertex];
|
||||
Iterable<String> neighborsOf(String vertex) => graph[vertex]!;
|
||||
}
|
||||
|
||||
void test(String expected, Map<String, List<String>> graph) {
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/src/heap.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -36,7 +34,5 @@ main() {
|
||||
}
|
||||
|
||||
class _intHeap extends Heap<int> {
|
||||
_intHeap() : super(0);
|
||||
|
||||
bool sortsBefore(int a, int b) => a < b;
|
||||
}
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/import_table.dart';
|
||||
|
||||
main() {
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart" show Expect;
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Test that 79cc54e51924cd5a6bdc2bd1771f2d0ee7af8899 works as intended.
|
||||
|
||||
import 'dart:convert';
|
||||
@@ -67,16 +65,16 @@ void expectSource(List<int> data, bool expect1, bool expect2) {
|
||||
builder.readComponent(tmp);
|
||||
if (tmp.uriToSource[uri1] == null) throw "No data for $uri1";
|
||||
if (tmp.uriToSource[uri2] == null) throw "No data for $uri2";
|
||||
if (expect1 && tmp.uriToSource[uri1].source.isEmpty) {
|
||||
if (expect1 && tmp.uriToSource[uri1]!.source.isEmpty) {
|
||||
throw "No data for $uri1";
|
||||
}
|
||||
if (!expect1 && tmp.uriToSource[uri1].source.isNotEmpty) {
|
||||
if (!expect1 && tmp.uriToSource[uri1]!.source.isNotEmpty) {
|
||||
throw "Unexpected data for $uri1";
|
||||
}
|
||||
if (expect2 && tmp.uriToSource[uri2].source.isEmpty) {
|
||||
if (expect2 && tmp.uriToSource[uri2]!.source.isEmpty) {
|
||||
throw "No data data for $uri2";
|
||||
}
|
||||
if (!expect2 && tmp.uriToSource[uri2].source.isNotEmpty) {
|
||||
if (!expect2 && tmp.uriToSource[uri2]!.source.isNotEmpty) {
|
||||
throw "Unexpected data for $uri2";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
@@ -21,10 +19,10 @@ import 'package:front_end/src/compute_platform_binaries_location.dart'
|
||||
/// * type representing the first type parameter of its enclosing function
|
||||
class Metadata {
|
||||
final String string;
|
||||
final Reference _memberRef;
|
||||
final Reference? _memberRef;
|
||||
final DartType type;
|
||||
|
||||
Member get member => _memberRef?.asMember;
|
||||
Member? get member => _memberRef?.asMember;
|
||||
|
||||
Metadata.forNode(TreeNode n)
|
||||
: this(
|
||||
@@ -36,7 +34,7 @@ class Metadata {
|
||||
Metadata(this.string, this._memberRef, this.type);
|
||||
}
|
||||
|
||||
Member getMemberForMetadata(TreeNode node) {
|
||||
Member? getMemberForMetadata(TreeNode node) {
|
||||
final parent = node.parent;
|
||||
if (parent == null) return null;
|
||||
if (parent is Member) return parent;
|
||||
@@ -67,7 +65,7 @@ class TestMetadataRepository extends MetadataRepository<Metadata> {
|
||||
sink.writeByteList(utf8.encode(metadata.string));
|
||||
sink.writeStringReference(metadata.string);
|
||||
sink.writeNullAllowedCanonicalNameReference(
|
||||
metadata.member?.reference?.canonicalName);
|
||||
metadata.member?.reference.canonicalName);
|
||||
sink.writeDartType(metadata.type);
|
||||
}
|
||||
|
||||
@@ -116,7 +114,7 @@ class Visitor extends RecursiveVisitor {
|
||||
/// [shouldAnnotate] predicate.
|
||||
void annotate(Component p, NodePredicate shouldAnnotate) {
|
||||
globalDebuggingNames = new NameSystem();
|
||||
final repository = p.metadata[TestMetadataRepository.kTag];
|
||||
final repository = p.metadata[TestMetadataRepository.kTag]!;
|
||||
p.accept(new Visitor(shouldAnnotate, (node) {
|
||||
repository.mapping[node] = new Metadata.forNode(node);
|
||||
}));
|
||||
@@ -126,7 +124,7 @@ void annotate(Component p, NodePredicate shouldAnnotate) {
|
||||
/// component matching [shouldAnnotate] predicate has correct metadata.
|
||||
void validate(Component p, NodePredicate shouldAnnotate) {
|
||||
globalDebuggingNames = new NameSystem();
|
||||
final repository = p.metadata[TestMetadataRepository.kTag];
|
||||
final repository = p.metadata[TestMetadataRepository.kTag]!;
|
||||
p.accept(new Visitor(shouldAnnotate, (node) {
|
||||
final m = repository.mapping[node];
|
||||
final expected = new Metadata.forNode(node);
|
||||
@@ -168,7 +166,7 @@ main() async {
|
||||
final component = fromBinary(platformBinary);
|
||||
annotate(component, shouldAnnotate);
|
||||
validate(component, shouldAnnotate);
|
||||
expect(component.metadata[TestMetadataRepository.kTag].mapping.length,
|
||||
expect(component.metadata[TestMetadataRepository.kTag]!.mapping.length,
|
||||
greaterThan(0));
|
||||
|
||||
final annotatedComponentBinary = binaryTransformer(toBinary(component));
|
||||
@@ -176,7 +174,7 @@ main() async {
|
||||
validate(annotatedComponentFromBinary, shouldAnnotate);
|
||||
expect(
|
||||
annotatedComponentFromBinary
|
||||
.metadata[TestMetadataRepository.kTag].mapping.length,
|
||||
.metadata[TestMetadataRepository.kTag]!.mapping.length,
|
||||
greaterThan(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart" show Expect;
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
@@ -129,8 +127,8 @@ main() {
|
||||
List<String> parts = input.split(' vs ');
|
||||
DartType aType = env.parseType(parts[0]);
|
||||
DartType bType = env.parseType(parts[1]);
|
||||
DartType expectedOutputType1;
|
||||
DartType expectedOutputType2;
|
||||
DartType? expectedOutputType1;
|
||||
DartType? expectedOutputType2;
|
||||
if (output is List) {
|
||||
expectedOutputType1 = env.parseType(output[0]);
|
||||
expectedOutputType2 = env.parseType(output[1]);
|
||||
@@ -138,8 +136,8 @@ main() {
|
||||
expectedOutputType1 = expectedOutputType2 = env.parseType(output);
|
||||
}
|
||||
|
||||
void test(DartType a, DartType b, DartType expectedOutputType) {
|
||||
DartType actualOutputType = nnbdTopMerge(env.coreTypes, a, b);
|
||||
void test(DartType a, DartType b, DartType? expectedOutputType) {
|
||||
DartType? actualOutputType = nnbdTopMerge(env.coreTypes, a, b);
|
||||
print('nnbdTopMerge($a,$b) = '
|
||||
'$actualOutputType (expected=$expectedOutputType)');
|
||||
Expect.equals(
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart" show Expect;
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart" show Expect;
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
||||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Regression test for https://github.com/dart-lang/sdk/issues/40662.
|
||||
|
||||
import "package:expect/expect.dart" show Expect;
|
||||
|
||||
bar(int a, List<int> b) {
|
||||
Expect.equals(-1, a);
|
||||
Expect.equals(-1, (b[0] - 2));
|
||||
}
|
||||
|
||||
foo(int x) async => bar(x - 1, x != null ? [x + 1, x + 2, await null] : null);
|
||||
|
||||
void main() async => await foo(0);
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/binary/ast_from_binary.dart';
|
||||
import 'package:kernel/binary/ast_to_binary.dart';
|
||||
import 'package:kernel/src/tool/find_referenced_libraries.dart';
|
||||
@@ -141,9 +139,11 @@ Procedure getMainTarget(Component component1Prime) {
|
||||
Uri.parse('org-dartlang:///main.dart')) {
|
||||
throw "Expected main first, got ${component1Prime.libraries[0].importUri}";
|
||||
}
|
||||
Block block = component1Prime.libraries[0].procedures[0].function.body;
|
||||
ReturnStatement returnStatement = block.statements[0];
|
||||
StaticInvocation staticInvocation = returnStatement.expression;
|
||||
Block block =
|
||||
component1Prime.libraries[0].procedures[0].function.body as Block;
|
||||
ReturnStatement returnStatement = block.statements[0] as ReturnStatement;
|
||||
StaticInvocation staticInvocation =
|
||||
returnStatement.expression as StaticInvocation;
|
||||
Procedure target = staticInvocation.target;
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library kernel.round_trip;
|
||||
|
||||
import 'dart:io';
|
||||
@@ -30,7 +28,7 @@ void main(List<String> args) async {
|
||||
}
|
||||
}
|
||||
|
||||
void testRoundTrip(List<int> bytes, List<int> sdkBytes) async {
|
||||
Future<void> testRoundTrip(List<int> bytes, List<int>? sdkBytes) async {
|
||||
var component = new Component();
|
||||
if (sdkBytes != null) {
|
||||
var sdk = new Component(nameRoot: component.root);
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library kernel.round_trip_test;
|
||||
|
||||
import 'self_check_util.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:kernel/src/tool/batch_util.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'dart:io';
|
||||
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library kernel.text_serializer_from_kernel_nodes_test;
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
@@ -25,14 +23,17 @@ class TestCase<T extends Node> {
|
||||
final TextSerializer<T> serializer;
|
||||
|
||||
TestCase(
|
||||
{this.name,
|
||||
this.node,
|
||||
this.expectation,
|
||||
this.serializer,
|
||||
SerializationState Function() makeSerializationState,
|
||||
DeserializationState Function() makeDeserializationState})
|
||||
{required this.name,
|
||||
required this.node,
|
||||
required this.expectation,
|
||||
required this.serializer,
|
||||
SerializationState Function()? makeSerializationState,
|
||||
DeserializationState Function()? makeDeserializationState})
|
||||
// ignore: unnecessary_null_comparison
|
||||
: assert(node != null),
|
||||
// ignore: unnecessary_null_comparison
|
||||
assert(expectation != null),
|
||||
// ignore: unnecessary_null_comparison
|
||||
assert(serializer != null),
|
||||
this.makeSerializationState = makeSerializationState ??
|
||||
(() => new SerializationState(new SerializationEnvironment(null))),
|
||||
@@ -75,12 +76,12 @@ void test() {
|
||||
new TestCase<Statement>(
|
||||
name: 'let dynamic x = 42 in let Null x^0 = null in x;',
|
||||
node: () {
|
||||
VariableDeclaration outterLetVar = new VariableDeclaration('x',
|
||||
VariableDeclaration outerLetVar = new VariableDeclaration('x',
|
||||
type: const DynamicType(), initializer: new IntLiteral(42));
|
||||
VariableDeclaration innerLetVar = new VariableDeclaration('x',
|
||||
type: const NullType(), initializer: new NullLiteral());
|
||||
return new ExpressionStatement(new Let(outterLetVar,
|
||||
new Let(innerLetVar, new VariableGet(outterLetVar))));
|
||||
return new ExpressionStatement(new Let(outerLetVar,
|
||||
new Let(innerLetVar, new VariableGet(outerLetVar))));
|
||||
}(),
|
||||
expectation: ''
|
||||
'(expr (let "x^0" () (dynamic) (int 42) ()'
|
||||
@@ -90,11 +91,11 @@ void test() {
|
||||
new TestCase<Statement>(
|
||||
name: 'let dynamic x = 42 in let Null x^0 = null in x^0;',
|
||||
node: () {
|
||||
VariableDeclaration outterLetVar = new VariableDeclaration('x',
|
||||
VariableDeclaration outerLetVar = new VariableDeclaration('x',
|
||||
type: const DynamicType(), initializer: new IntLiteral(42));
|
||||
VariableDeclaration innerLetVar = new VariableDeclaration('x',
|
||||
type: const NullType(), initializer: new NullLiteral());
|
||||
return new ExpressionStatement(new Let(outterLetVar,
|
||||
return new ExpressionStatement(new Let(outerLetVar,
|
||||
new Let(innerLetVar, new VariableGet(innerLetVar))));
|
||||
}(),
|
||||
expectation: ''
|
||||
@@ -133,9 +134,10 @@ void test() {
|
||||
node: new ExpressionStatement(new StaticGet(field)),
|
||||
expectation: ''
|
||||
'(expr (get-static "package:foo/bar.dart::@getters::field"))',
|
||||
makeSerializationState: () => new SerializationState(null),
|
||||
makeDeserializationState: () =>
|
||||
new DeserializationState(null, component.root),
|
||||
makeSerializationState: () =>
|
||||
new SerializationState(new SerializationEnvironment(null)),
|
||||
makeDeserializationState: () => new DeserializationState(
|
||||
new DeserializationEnvironment(null), component.root),
|
||||
serializer: statementSerializer);
|
||||
}(),
|
||||
() {
|
||||
@@ -150,9 +152,10 @@ void test() {
|
||||
node: new ExpressionStatement(new StaticGet(field)),
|
||||
expectation: ''
|
||||
'(expr (get-static "package:foo/bar.dart::@getters::field"))',
|
||||
makeSerializationState: () => new SerializationState(null),
|
||||
makeDeserializationState: () =>
|
||||
new DeserializationState(null, component.root),
|
||||
makeSerializationState: () =>
|
||||
new SerializationState(new SerializationEnvironment(null)),
|
||||
makeDeserializationState: () => new DeserializationState(
|
||||
new DeserializationEnvironment(null), component.root),
|
||||
serializer: statementSerializer);
|
||||
}(),
|
||||
() {
|
||||
@@ -169,9 +172,10 @@ void test() {
|
||||
expectation: ''
|
||||
'(expr'
|
||||
' (set-static "package:foo/bar.dart::@setters::field" (int 1)))',
|
||||
makeSerializationState: () => new SerializationState(null),
|
||||
makeDeserializationState: () =>
|
||||
new DeserializationState(null, component.root),
|
||||
makeSerializationState: () =>
|
||||
new SerializationState(new SerializationEnvironment(null)),
|
||||
makeDeserializationState: () => new DeserializationState(
|
||||
new DeserializationEnvironment(null), component.root),
|
||||
serializer: statementSerializer);
|
||||
}(),
|
||||
() {
|
||||
@@ -197,9 +201,10 @@ void test() {
|
||||
expectation: ''
|
||||
'(expr (invoke-static "package:foo/bar.dart::@methods::foo"'
|
||||
' () ((int 42)) ()))',
|
||||
makeSerializationState: () => new SerializationState(null),
|
||||
makeDeserializationState: () =>
|
||||
new DeserializationState(null, component.root),
|
||||
makeSerializationState: () =>
|
||||
new SerializationState(new SerializationEnvironment(null)),
|
||||
makeDeserializationState: () => new DeserializationState(
|
||||
new DeserializationEnvironment(null), component.root),
|
||||
serializer: statementSerializer);
|
||||
}(),
|
||||
() {
|
||||
@@ -222,9 +227,10 @@ void test() {
|
||||
'(expr (invoke-const-static'
|
||||
' "package:foo/bar.dart::A::@factories::foo"'
|
||||
' () () ()))',
|
||||
makeSerializationState: () => new SerializationState(null),
|
||||
makeDeserializationState: () =>
|
||||
new DeserializationState(null, component.root),
|
||||
makeSerializationState: () =>
|
||||
new SerializationState(new SerializationEnvironment(null)),
|
||||
makeDeserializationState: () => new DeserializationState(
|
||||
new DeserializationEnvironment(null), component.root),
|
||||
serializer: statementSerializer);
|
||||
}(),
|
||||
() {
|
||||
@@ -365,9 +371,10 @@ void test() {
|
||||
'(expr (invoke-constructor'
|
||||
' "package:foo/bar.dart::A::@constructors::foo"'
|
||||
' () () ()))',
|
||||
makeSerializationState: () => new SerializationState(null),
|
||||
makeDeserializationState: () =>
|
||||
new DeserializationState(null, component.root),
|
||||
makeSerializationState: () =>
|
||||
new SerializationState(new SerializationEnvironment(null)),
|
||||
makeDeserializationState: () => new DeserializationState(
|
||||
new DeserializationEnvironment(null), component.root),
|
||||
serializer: statementSerializer);
|
||||
}(),
|
||||
() {
|
||||
@@ -387,13 +394,14 @@ void test() {
|
||||
'(expr (invoke-const-constructor'
|
||||
' "package:foo/bar.dart::A::@constructors::foo"'
|
||||
' () () ()))',
|
||||
makeSerializationState: () => new SerializationState(null),
|
||||
makeDeserializationState: () =>
|
||||
new DeserializationState(null, component.root),
|
||||
makeSerializationState: () =>
|
||||
new SerializationState(new SerializationEnvironment(null)),
|
||||
makeDeserializationState: () => new DeserializationState(
|
||||
new DeserializationEnvironment(null), component.root),
|
||||
serializer: statementSerializer);
|
||||
}(),
|
||||
() {
|
||||
TypeParameter outterParam =
|
||||
TypeParameter outerParam =
|
||||
new TypeParameter('T', const DynamicType(), const DynamicType());
|
||||
TypeParameter innerParam =
|
||||
new TypeParameter('T', const DynamicType(), const DynamicType());
|
||||
@@ -407,9 +415,9 @@ void test() {
|
||||
Nullability.legacy,
|
||||
typeParameters: [innerParam])
|
||||
],
|
||||
new TypeParameterType(outterParam, Nullability.legacy),
|
||||
new TypeParameterType(outerParam, Nullability.legacy),
|
||||
Nullability.legacy,
|
||||
typeParameters: [outterParam]))),
|
||||
typeParameters: [outerParam]))),
|
||||
expectation: ''
|
||||
'(expr (type (-> ("T^0") ((dynamic)) ((dynamic)) '
|
||||
'((-> ("T^1") ((dynamic)) ((dynamic)) () () () '
|
||||
@@ -417,7 +425,7 @@ void test() {
|
||||
makeSerializationState: () =>
|
||||
new SerializationState(new SerializationEnvironment(null)),
|
||||
makeDeserializationState: () => new DeserializationState(
|
||||
new DeserializationEnvironment(null), null),
|
||||
new DeserializationEnvironment(null), new CanonicalName.root()),
|
||||
serializer: statementSerializer);
|
||||
}(),
|
||||
() {
|
||||
@@ -444,7 +452,7 @@ void test() {
|
||||
makeSerializationState: () =>
|
||||
new SerializationState(new SerializationEnvironment(null)),
|
||||
makeDeserializationState: () => new DeserializationState(
|
||||
new DeserializationEnvironment(null), null),
|
||||
new DeserializationEnvironment(null), new CanonicalName.root()),
|
||||
serializer: statementSerializer);
|
||||
}(),
|
||||
() {
|
||||
@@ -471,7 +479,7 @@ void test() {
|
||||
makeSerializationState: () =>
|
||||
new SerializationState(new SerializationEnvironment(null)),
|
||||
makeDeserializationState: () => new DeserializationState(
|
||||
new DeserializationEnvironment(null), null),
|
||||
new DeserializationEnvironment(null), component.root),
|
||||
serializer: memberSerializer);
|
||||
}(),
|
||||
() {
|
||||
@@ -588,7 +596,7 @@ void test() {
|
||||
" but expected:\n ${testCase.expectation}");
|
||||
}
|
||||
|
||||
TreeNode deserialized =
|
||||
Node deserialized =
|
||||
testCase.readNode(roundTripInput, testCase.makeDeserializationState());
|
||||
String roundTripOutput =
|
||||
testCase.writeNode(deserialized, testCase.makeSerializationState());
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library kernel.text_serializer_test;
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
@@ -27,7 +25,9 @@ Expression readExpression(String input) {
|
||||
TextIterator stream = new TextIterator(input, 0);
|
||||
stream.moveNext();
|
||||
Expression result = expressionSerializer.readFrom(
|
||||
stream, new DeserializationState(null, new CanonicalName.root()));
|
||||
stream,
|
||||
new DeserializationState(
|
||||
new DeserializationEnvironment(null), new CanonicalName.root()));
|
||||
if (stream.moveNext()) {
|
||||
throw StateError("extra cruft in basic literal");
|
||||
}
|
||||
@@ -36,8 +36,8 @@ Expression readExpression(String input) {
|
||||
|
||||
String writeExpression(Expression expression) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
expressionSerializer.writeTo(
|
||||
buffer, expression, new SerializationState(null));
|
||||
expressionSerializer.writeTo(buffer, expression,
|
||||
new SerializationState(new SerializationEnvironment(null)));
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'dart:io';
|
||||
|
||||
@@ -40,7 +38,7 @@ class DartTypeCollector extends RecursiveVisitor {
|
||||
if (hash == 0) {
|
||||
print('Type has a hash code of zero: $node');
|
||||
}
|
||||
DartType existing = table[hash];
|
||||
DartType? existing = table[hash];
|
||||
if (existing == null) {
|
||||
table[hash] = node;
|
||||
} else if (existing != node) {
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'type_parser.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -55,11 +53,13 @@ class TestCase {
|
||||
String type1;
|
||||
String type2;
|
||||
Iterable<String> quantifiedVariables;
|
||||
Map<String, String> expectedSubstitution; // Null if unification should fail.
|
||||
Map<String, String?>?
|
||||
expectedSubstitution; // Null if unification should fail.
|
||||
|
||||
TestCase.success(this.type1, this.type2, this.expectedSubstitution) {
|
||||
quantifiedVariables = expectedSubstitution.keys;
|
||||
}
|
||||
TestCase.success(
|
||||
this.type1, this.type2, Map<String, String?> expectedSubstitution)
|
||||
: this.expectedSubstitution = expectedSubstitution,
|
||||
this.quantifiedVariables = expectedSubstitution.keys;
|
||||
|
||||
TestCase.fail(this.type1, this.type2, this.quantifiedVariables);
|
||||
|
||||
@@ -68,7 +68,7 @@ class TestCase {
|
||||
String toString() => '∃ ${quantifiedVariables.join(',')}. $type1 = $type2';
|
||||
}
|
||||
|
||||
TestCase successCase(String type1, String type2, Map<String, String> expected,
|
||||
TestCase successCase(String type1, String type2, Map<String, String?> expected,
|
||||
{bool debug: false}) {
|
||||
return new TestCase.success(type1, type2, expected);
|
||||
}
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// A very simple parser for a subset of DartTypes for use in testing type
|
||||
// algebra.
|
||||
library kernel.test.type_parser;
|
||||
@@ -41,14 +39,14 @@ class Token {
|
||||
class DartTypeParser {
|
||||
final String string;
|
||||
int index = 0;
|
||||
String tokenText;
|
||||
String? tokenText;
|
||||
final TypeEnvironment environment;
|
||||
final Map<String, TypeParameter> localTypeParameters =
|
||||
<String, TypeParameter>{};
|
||||
|
||||
DartTypeParser(this.string, this.environment);
|
||||
|
||||
TreeNode lookupType(String name) {
|
||||
TreeNode? lookupType(String name) {
|
||||
return localTypeParameters[name] ?? environment(name);
|
||||
}
|
||||
|
||||
@@ -139,8 +137,8 @@ class DartTypeParser {
|
||||
}
|
||||
}
|
||||
|
||||
Nullability parseOptionalNullability(
|
||||
[Nullability defaultNullability = Nullability.nonNullable]) {
|
||||
Nullability? parseOptionalNullability(
|
||||
[Nullability? defaultNullability = Nullability.nonNullable]) {
|
||||
int token = peekToken();
|
||||
switch (token) {
|
||||
case Token.QuestionMark:
|
||||
@@ -159,23 +157,23 @@ class DartTypeParser {
|
||||
switch (token) {
|
||||
case Token.Name:
|
||||
scanToken();
|
||||
String name = this.tokenText;
|
||||
String name = this.tokenText!;
|
||||
if (name == 'void') return const VoidType();
|
||||
if (name == 'dynamic') return const DynamicType();
|
||||
var target = lookupType(name);
|
||||
if (target == null) {
|
||||
return fail('Unresolved type $name');
|
||||
} else if (target is Class) {
|
||||
List<DartType> typeArguments = parseOptionalTypeArgumentList();
|
||||
Nullability nullability = parseOptionalNullability();
|
||||
List<DartType>? typeArguments = parseOptionalTypeArgumentList();
|
||||
Nullability nullability = parseOptionalNullability()!;
|
||||
return new InterfaceType(target, nullability, typeArguments);
|
||||
} else if (target is Typedef) {
|
||||
List<DartType> typeArguments = parseOptionalTypeArgumentList();
|
||||
Nullability nullability = parseOptionalNullability();
|
||||
List<DartType>? typeArguments = parseOptionalTypeArgumentList();
|
||||
Nullability nullability = parseOptionalNullability()!;
|
||||
return new TypedefType(target, nullability, typeArguments);
|
||||
} else if (target is TypeParameter) {
|
||||
Nullability nullability = parseOptionalNullability(null);
|
||||
DartType promotedBound;
|
||||
Nullability? nullability = parseOptionalNullability(null);
|
||||
DartType? promotedBound;
|
||||
switch (peekToken()) {
|
||||
case Token.LeftAngle:
|
||||
return fail('Attempt to apply type arguments to a type variable');
|
||||
@@ -199,7 +197,7 @@ class DartTypeParser {
|
||||
List<NamedType> namedParameters = <NamedType>[];
|
||||
parseParameterList(parameters, namedParameters);
|
||||
consumeString('=>');
|
||||
Nullability nullability = parseOptionalNullability();
|
||||
Nullability nullability = parseOptionalNullability()!;
|
||||
var returnType = parseType();
|
||||
return new FunctionType(parameters, returnType, nullability,
|
||||
namedParameters: namedParameters);
|
||||
@@ -210,7 +208,7 @@ class DartTypeParser {
|
||||
List<NamedType> namedParameters = <NamedType>[];
|
||||
parseParameterList(parameters, namedParameters);
|
||||
consumeString('=>');
|
||||
Nullability nullability = parseOptionalNullability();
|
||||
Nullability nullability = parseOptionalNullability()!;
|
||||
var returnType = parseType();
|
||||
popTypeParameters(typeParameters);
|
||||
return new FunctionType(parameters, returnType, nullability,
|
||||
@@ -246,7 +244,7 @@ class DartTypeParser {
|
||||
if (type is InterfaceType && type.typeArguments.isEmpty) {
|
||||
return type.classNode.name;
|
||||
} else if (type is TypeParameterType) {
|
||||
return type.parameter.name;
|
||||
return type.parameter.name!;
|
||||
} else {
|
||||
return fail('Unexpected colon after $type');
|
||||
}
|
||||
@@ -267,12 +265,12 @@ class DartTypeParser {
|
||||
return types;
|
||||
}
|
||||
|
||||
List<DartType> parseOptionalList(int open, int close) {
|
||||
List<DartType>? parseOptionalList(int open, int close) {
|
||||
if (peekToken() != open) return null;
|
||||
return parseTypeList(open, close);
|
||||
}
|
||||
|
||||
List<DartType> parseOptionalTypeArgumentList() {
|
||||
List<DartType>? parseOptionalTypeArgumentList() {
|
||||
return parseOptionalList(Token.LeftAngle, Token.RightAngle);
|
||||
}
|
||||
|
||||
@@ -302,14 +300,14 @@ class DartTypeParser {
|
||||
if (localTypeParameters.containsKey(typeParameter.name)) {
|
||||
return fail('Shadowing a type parameter is not allowed');
|
||||
}
|
||||
localTypeParameters[typeParameter.name] = typeParameter;
|
||||
localTypeParameters[typeParameter.name!] = typeParameter;
|
||||
var next = peekToken();
|
||||
if (next == Token.Colon) {
|
||||
scanToken();
|
||||
typeParameter.bound = parseType();
|
||||
} else {
|
||||
typeParameter.bound =
|
||||
new InterfaceType(lookupType('Object'), Nullability.nullable);
|
||||
typeParameter.bound = new InterfaceType(
|
||||
lookupType('Object') as Class, Nullability.nullable);
|
||||
}
|
||||
return typeParameter;
|
||||
}
|
||||
@@ -322,7 +320,7 @@ class DartTypeParser {
|
||||
class LazyTypeEnvironment {
|
||||
final Map<String, Class> classes = <String, Class>{};
|
||||
final Map<String, TypeParameter> typeParameters = <String, TypeParameter>{};
|
||||
Library dummyLibrary;
|
||||
late final Library dummyLibrary;
|
||||
final Component component = new Component();
|
||||
|
||||
LazyTypeEnvironment() {
|
||||
@@ -360,14 +358,14 @@ class LazyTypeEnvironment {
|
||||
for (var typeParameter
|
||||
in new DartTypeParser('<$typeParametersList>', lookup)
|
||||
.parseAndPushTypeParameterList()) {
|
||||
typeParameters[typeParameter.name] = typeParameter;
|
||||
typeParameters[typeParameter.name!] = typeParameter;
|
||||
}
|
||||
}
|
||||
|
||||
DartType parse(String type) => parseDartType(type, lookup);
|
||||
|
||||
Supertype parseSuper(String type) {
|
||||
InterfaceType interfaceType = parse(type);
|
||||
InterfaceType interfaceType = parse(type) as InterfaceType;
|
||||
return new Supertype(interfaceType.classNode, interfaceType.typeArguments);
|
||||
}
|
||||
|
||||
@@ -376,9 +374,9 @@ class LazyTypeEnvironment {
|
||||
return parse(type);
|
||||
}
|
||||
|
||||
TypeParameter getTypeParameter(String name) {
|
||||
TypeParameter? getTypeParameter(String name) {
|
||||
if (name.length != 1) throw 'Type parameter names must have length 1';
|
||||
return lookup(name);
|
||||
return lookup(name) as TypeParameter?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:expect/expect.dart' show Expect;
|
||||
|
||||
import 'package:kernel/testing/type_parser.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library kernel.type_substitute_bounds_test;
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
@@ -45,7 +43,7 @@ class TestCase {
|
||||
|
||||
String toString() {
|
||||
var substitution = bounds.keys.map((key) {
|
||||
var bound = bounds[key];
|
||||
var bound = bounds[key]!;
|
||||
return '${bound.lower} <: $key <: ${bound.upper}';
|
||||
}).join(',');
|
||||
return '$type [$substitution] <: $expected';
|
||||
@@ -72,7 +70,7 @@ main() {
|
||||
var upperBounds = <TypeParameter, DartType>{};
|
||||
var lowerBounds = <TypeParameter, DartType>{};
|
||||
testCase.bounds.forEach((String name, TypeBound bounds) {
|
||||
var parameter = environment.getTypeParameter(name);
|
||||
var parameter = environment.getTypeParameter(name)!;
|
||||
upperBounds[parameter] = environment.parse(bounds.upper);
|
||||
lowerBounds[parameter] = environment.parse(bounds.lower);
|
||||
});
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'package:kernel/type_algebra.dart';
|
||||
import 'type_parser.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library kernel.typedef_unalias_test;
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/kernel.dart';
|
||||
import 'package:kernel/verifier.dart';
|
||||
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
import 'package:kernel/text/ast_to_text.dart';
|
||||
import 'package:kernel/verifier.dart';
|
||||
@@ -30,7 +28,7 @@ main() {
|
||||
test.addNode(VariableGet(node));
|
||||
return node;
|
||||
},
|
||||
(Node node) => "Variable '$node' used out of scope.",
|
||||
(Node? node) => "Variable '$node' used out of scope.",
|
||||
);
|
||||
negative1Test(
|
||||
'VariableSet out of scope',
|
||||
@@ -39,7 +37,7 @@ main() {
|
||||
test.addNode(VariableSet(variable, new NullLiteral()));
|
||||
return variable;
|
||||
},
|
||||
(Node node) => "Variable '$node' used out of scope.",
|
||||
(Node? node) => "Variable '$node' used out of scope.",
|
||||
);
|
||||
negative1Test(
|
||||
'Variable block scope',
|
||||
@@ -51,7 +49,7 @@ main() {
|
||||
]));
|
||||
return variable;
|
||||
},
|
||||
(Node node) => "Variable '$node' used out of scope.",
|
||||
(Node? node) => "Variable '$node' used out of scope.",
|
||||
);
|
||||
negative1Test(
|
||||
'Variable let scope',
|
||||
@@ -63,7 +61,7 @@ main() {
|
||||
new VariableGet(variable)));
|
||||
return variable;
|
||||
},
|
||||
(Node node) => "Variable '$node' used out of scope.",
|
||||
(Node? node) => "Variable '$node' used out of scope.",
|
||||
);
|
||||
negative1Test(
|
||||
'Variable redeclared',
|
||||
@@ -72,7 +70,7 @@ main() {
|
||||
test.addNode(Block([variable, variable]));
|
||||
return variable;
|
||||
},
|
||||
(Node node) => "Variable '$node' declared more than once.",
|
||||
(Node? node) => "Variable '$node' declared more than once.",
|
||||
);
|
||||
negative1Test(
|
||||
'Member redeclared',
|
||||
@@ -86,7 +84,7 @@ main() {
|
||||
fileUri: dummyUri));
|
||||
return field;
|
||||
},
|
||||
(Node node) => "Member '$node' has been declared more than once.",
|
||||
(Node? node) => "Member '$node' has been declared more than once.",
|
||||
);
|
||||
negative1Test(
|
||||
'Class redeclared',
|
||||
@@ -96,7 +94,7 @@ main() {
|
||||
otherClass); // Test harness also adds otherClass to component.
|
||||
return test.otherClass;
|
||||
},
|
||||
(Node node) => "Class '$node' declared more than once.",
|
||||
(Node? node) => "Class '$node' declared more than once.",
|
||||
);
|
||||
negative1Test(
|
||||
'Class type parameter redeclared',
|
||||
@@ -109,7 +107,7 @@ main() {
|
||||
fileUri: dummyUri));
|
||||
return parameter;
|
||||
},
|
||||
(Node node) => "Type parameter '$node' redeclared.",
|
||||
(Node? node) => "Type parameter '$node' redeclared.",
|
||||
);
|
||||
negative1Test(
|
||||
'Member type parameter redeclared',
|
||||
@@ -124,7 +122,7 @@ main() {
|
||||
|
||||
return parameter;
|
||||
},
|
||||
(Node node) => "Type parameter '$node' redeclared.",
|
||||
(Node? node) => "Type parameter '$node' redeclared.",
|
||||
);
|
||||
negative2Test(
|
||||
'Type parameter out of scope',
|
||||
@@ -134,7 +132,7 @@ main() {
|
||||
typeArgument: new TypeParameterType(parameter, Nullability.legacy)));
|
||||
return [parameter, null];
|
||||
},
|
||||
(Node node, Node parent) =>
|
||||
(Node? node, Node? parent) =>
|
||||
"Type parameter '$node' referenced out of scope,"
|
||||
" owner is: '$parent'.",
|
||||
);
|
||||
@@ -146,7 +144,7 @@ main() {
|
||||
TypeLiteral(new TypeParameterType(node, Nullability.legacy)));
|
||||
return [node, test.otherClass];
|
||||
},
|
||||
(Node node, Node parent) =>
|
||||
(Node? node, Node? parent) =>
|
||||
"Type parameter '$node' referenced out of scope,"
|
||||
" owner is: '$parent'.",
|
||||
);
|
||||
@@ -164,7 +162,7 @@ main() {
|
||||
|
||||
return [node, test.enclosingClass];
|
||||
},
|
||||
(Node node, Node parent) =>
|
||||
(Node? node, Node? parent) =>
|
||||
"Type parameter '$node' referenced from static context,"
|
||||
" parent is: '$parent'.",
|
||||
);
|
||||
@@ -179,7 +177,7 @@ main() {
|
||||
fileUri: dummyUri));
|
||||
return [node, test.enclosingClass];
|
||||
},
|
||||
(Node node, Node parent) =>
|
||||
(Node? node, Node? parent) =>
|
||||
"Type parameter '$node' referenced from static context,"
|
||||
" parent is: '$parent'.",
|
||||
);
|
||||
@@ -206,7 +204,7 @@ main() {
|
||||
|
||||
return [parameter, parent];
|
||||
},
|
||||
(Node node, Node parent) =>
|
||||
(Node? node, Node? parent) =>
|
||||
"Type parameter '$node' referenced out of scope,"
|
||||
" owner is: '${(parent as TreeNode).parent}'.",
|
||||
);
|
||||
@@ -218,7 +216,7 @@ main() {
|
||||
test.addNode(TypeLiteral(node));
|
||||
return node;
|
||||
},
|
||||
(Node node) => "Type $node provides 0 type arguments,"
|
||||
(Node? node) => "Type $node provides 0 type arguments,"
|
||||
" but the class declares 1 parameters.",
|
||||
);
|
||||
negative1Test(
|
||||
@@ -229,7 +227,7 @@ main() {
|
||||
test.addNode(TypeLiteral(node));
|
||||
return node;
|
||||
},
|
||||
(Node node) => "Type $node provides 2 type arguments,"
|
||||
(Node? node) => "Type $node provides 2 type arguments,"
|
||||
" but the class declares 1 parameters.",
|
||||
);
|
||||
negative1Test(
|
||||
@@ -240,7 +238,7 @@ main() {
|
||||
new TypeLiteral(new InterfaceType(orphan, Nullability.legacy)));
|
||||
return orphan;
|
||||
},
|
||||
(Node node) => "Dangling reference to '$node', parent is: 'null'.",
|
||||
(Node? node) => "Dangling reference to '$node', parent is: 'null'.",
|
||||
);
|
||||
negative1Test(
|
||||
'Dangling field get',
|
||||
@@ -249,7 +247,7 @@ main() {
|
||||
test.addNode(new PropertyGet(new NullLiteral(), orphan.name, orphan));
|
||||
return orphan;
|
||||
},
|
||||
(Node node) => "Dangling reference to '$node', parent is: 'null'.",
|
||||
(Node? node) => "Dangling reference to '$node', parent is: 'null'.",
|
||||
);
|
||||
simpleNegativeTest(
|
||||
'Missing block parent pointer',
|
||||
@@ -299,7 +297,7 @@ main() {
|
||||
StaticInvocation(method, new Arguments([new NullLiteral()])));
|
||||
return method;
|
||||
},
|
||||
(Node node) => "StaticInvocation with incompatible arguments for"
|
||||
(Node? node) => "StaticInvocation with incompatible arguments for"
|
||||
" '$node'.",
|
||||
);
|
||||
negative1Test(
|
||||
@@ -316,7 +314,7 @@ main() {
|
||||
test.addNode(StaticInvocation(method, new Arguments.empty()));
|
||||
return method;
|
||||
},
|
||||
(Node node) => "StaticInvocation with incompatible arguments for '$node'.",
|
||||
(Node? node) => "StaticInvocation with incompatible arguments for '$node'.",
|
||||
);
|
||||
negative1Test(
|
||||
'StaticInvocation with unmatched named parameter',
|
||||
@@ -331,7 +329,7 @@ main() {
|
||||
named: [new NamedExpression('p', new NullLiteral())])));
|
||||
return method;
|
||||
},
|
||||
(Node node) => "StaticInvocation with incompatible arguments for"
|
||||
(Node? node) => "StaticInvocation with incompatible arguments for"
|
||||
" '$node'.",
|
||||
);
|
||||
negative1Test(
|
||||
@@ -348,7 +346,7 @@ main() {
|
||||
test.addNode(StaticInvocation(method, new Arguments.empty()));
|
||||
return method;
|
||||
},
|
||||
(Node node) => "StaticInvocation with wrong number of type arguments for"
|
||||
(Node? node) => "StaticInvocation with wrong number of type arguments for"
|
||||
" '$node'.",
|
||||
);
|
||||
negative1Test(
|
||||
@@ -360,7 +358,7 @@ main() {
|
||||
test.addNode(ConstructorInvocation(constructor, new Arguments.empty()));
|
||||
return constructor;
|
||||
},
|
||||
(Node node) =>
|
||||
(Node? node) =>
|
||||
"ConstructorInvocation with wrong number of type arguments for"
|
||||
" '$node'.",
|
||||
);
|
||||
@@ -433,7 +431,7 @@ main() {
|
||||
test.addNode(typedef_);
|
||||
return typedef_;
|
||||
},
|
||||
(Node node) => "The typedef '$node' refers to itself",
|
||||
(Node? node) => "The typedef '$node' refers to itself",
|
||||
);
|
||||
negative1Test(
|
||||
'Invalid typedef Foo = `(Foo) => void`',
|
||||
@@ -446,7 +444,7 @@ main() {
|
||||
test.addNode(typedef_);
|
||||
return typedef_;
|
||||
},
|
||||
(Node node) => "The typedef '$node' refers to itself",
|
||||
(Node? node) => "The typedef '$node' refers to itself",
|
||||
);
|
||||
negative1Test(
|
||||
'Invalid typedef Foo = `() => Foo`',
|
||||
@@ -457,7 +455,7 @@ main() {
|
||||
test.addNode(typedef_);
|
||||
return typedef_;
|
||||
},
|
||||
(Node node) => "The typedef '$node' refers to itself",
|
||||
(Node? node) => "The typedef '$node' refers to itself",
|
||||
);
|
||||
negative1Test(
|
||||
'Invalid typedef Foo = C<Foo>',
|
||||
@@ -468,7 +466,7 @@ main() {
|
||||
test.addNode(typedef_);
|
||||
return typedef_;
|
||||
},
|
||||
(Node node) => "The typedef '$node' refers to itself",
|
||||
(Node? node) => "The typedef '$node' refers to itself",
|
||||
);
|
||||
negative1Test(
|
||||
'Invalid typedefs Foo = Bar, Bar = Foo',
|
||||
@@ -481,7 +479,7 @@ main() {
|
||||
test.enclosingLibrary.addTypedef(bar);
|
||||
return foo;
|
||||
},
|
||||
(Node foo) => "The typedef '$foo' refers to itself",
|
||||
(Node? foo) => "The typedef '$foo' refers to itself",
|
||||
);
|
||||
negative1Test(
|
||||
'Invalid typedefs Foo = Bar, Bar = C<Foo>',
|
||||
@@ -495,7 +493,7 @@ main() {
|
||||
test.enclosingLibrary.addTypedef(bar);
|
||||
return foo;
|
||||
},
|
||||
(Node foo) => "The typedef '$foo' refers to itself",
|
||||
(Node? foo) => "The typedef '$foo' refers to itself",
|
||||
);
|
||||
negative1Test(
|
||||
'Invalid typedefs Foo = C<Bar>, Bar = C<Foo>',
|
||||
@@ -510,7 +508,7 @@ main() {
|
||||
test.enclosingLibrary.addTypedef(bar);
|
||||
return foo;
|
||||
},
|
||||
(Node foo) => "The typedef '$foo' refers to itself",
|
||||
(Node? foo) => "The typedef '$foo' refers to itself",
|
||||
);
|
||||
positiveTest(
|
||||
'Valid long typedefs C20 = C19 = ... = C1 = C0 = dynamic',
|
||||
@@ -541,7 +539,7 @@ main() {
|
||||
first.type = new TypedefType(typedef_, Nullability.legacy);
|
||||
return firstTypedef;
|
||||
},
|
||||
(Node node) => "The typedef '$node' refers to itself",
|
||||
(Node? node) => "The typedef '$node' refers to itself",
|
||||
);
|
||||
positiveTest(
|
||||
'Valid typedef Foo<T extends C> = C<T>',
|
||||
@@ -611,7 +609,7 @@ main() {
|
||||
test.enclosingLibrary.addTypedef(bar);
|
||||
return foo;
|
||||
},
|
||||
(Node foo) => "The typedef '$foo' refers to itself",
|
||||
(Node? foo) => "The typedef '$foo' refers to itself",
|
||||
);
|
||||
negative1Test(
|
||||
'Invalid typedef Foo<T extends Foo<dynamic> = C<T>',
|
||||
@@ -628,7 +626,7 @@ main() {
|
||||
test.addNode(foo);
|
||||
return foo;
|
||||
},
|
||||
(Node foo) => "The typedef '$foo' refers to itself",
|
||||
(Node? foo) => "The typedef '$foo' refers to itself",
|
||||
);
|
||||
negative1Test(
|
||||
'Typedef arity error',
|
||||
@@ -643,7 +641,7 @@ main() {
|
||||
test.enclosingLibrary.addField(field);
|
||||
return typedefType;
|
||||
},
|
||||
(Node typedefType) =>
|
||||
(Node? typedefType) =>
|
||||
"The typedef type $typedefType provides 0 type arguments,"
|
||||
" but the typedef declares 1 parameters.",
|
||||
);
|
||||
@@ -659,7 +657,7 @@ main() {
|
||||
test.enclosingLibrary.addField(field);
|
||||
return foo;
|
||||
},
|
||||
(Node foo) => "Dangling reference to '$foo', parent is: 'null'",
|
||||
(Node? foo) => "Dangling reference to '$foo', parent is: 'null'",
|
||||
);
|
||||
negative1Test(
|
||||
'Non-static top-level field',
|
||||
@@ -668,7 +666,7 @@ main() {
|
||||
test.enclosingLibrary.addField(field);
|
||||
return null;
|
||||
},
|
||||
(Node node) => "The top-level field 'field' should be static",
|
||||
(Node? node) => "The top-level field 'field' should be static",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -683,21 +681,21 @@ checkHasError(Component component, Matcher matcher) {
|
||||
}
|
||||
|
||||
class TestHarness {
|
||||
Component component;
|
||||
Class objectClass;
|
||||
Library stubLibrary;
|
||||
late Component component;
|
||||
late Class objectClass;
|
||||
late Library stubLibrary;
|
||||
|
||||
TypeParameter classTypeParameter;
|
||||
late TypeParameter classTypeParameter;
|
||||
|
||||
Library enclosingLibrary;
|
||||
Class enclosingClass;
|
||||
Procedure enclosingMember;
|
||||
late Library enclosingLibrary;
|
||||
late Class enclosingClass;
|
||||
late Procedure enclosingMember;
|
||||
|
||||
Class otherClass;
|
||||
late Class otherClass;
|
||||
|
||||
InterfaceType objectLegacyRawType;
|
||||
InterfaceType enclosingLegacyRawType;
|
||||
InterfaceType otherLegacyRawType;
|
||||
late InterfaceType objectLegacyRawType;
|
||||
late InterfaceType enclosingLegacyRawType;
|
||||
late InterfaceType otherLegacyRawType;
|
||||
|
||||
void addNode(TreeNode node) {
|
||||
if (node is Expression) {
|
||||
@@ -756,7 +754,7 @@ class TestHarness {
|
||||
|
||||
VariableDeclaration makeVariable() => new VariableDeclaration(null);
|
||||
|
||||
TypeParameter makeTypeParameter([String name]) {
|
||||
TypeParameter makeTypeParameter([String? name]) {
|
||||
return new TypeParameter(name, objectLegacyRawType, const DynamicType());
|
||||
}
|
||||
|
||||
@@ -802,10 +800,10 @@ class TestHarness {
|
||||
}
|
||||
}
|
||||
|
||||
negative1Test(String name, Node Function(TestHarness test) nodeProvider,
|
||||
dynamic Function(Node node) matcher) {
|
||||
negative1Test(String name, Node? Function(TestHarness test) nodeProvider,
|
||||
dynamic Function(Node? node) matcher) {
|
||||
TestHarness testHarness = new TestHarness();
|
||||
Node node = nodeProvider(testHarness);
|
||||
Node? node = nodeProvider(testHarness);
|
||||
test(
|
||||
name,
|
||||
() {
|
||||
@@ -818,10 +816,10 @@ negative1Test(String name, Node Function(TestHarness test) nodeProvider,
|
||||
);
|
||||
}
|
||||
|
||||
negative2Test(String name, List<Node> Function(TestHarness test) nodeProvider,
|
||||
dynamic Function(Node node, Node other) matcher) {
|
||||
negative2Test(String name, List<Node?> Function(TestHarness test) nodeProvider,
|
||||
dynamic Function(Node? node, Node? other) matcher) {
|
||||
TestHarness testHarness = new TestHarness();
|
||||
List<Node> nodes = nodeProvider(testHarness);
|
||||
List<Node?> nodes = nodeProvider(testHarness);
|
||||
if (nodes.length != 2) throw "Needs exactly 2 nodes: Node and other!";
|
||||
test(
|
||||
name,
|
||||
|
||||
@@ -2,8 +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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
final String repoDir = _computeRepoDir();
|
||||
|
||||
Reference in New Issue
Block a user