[kernel] Make FileUriNode.fileUri non-nullable

TEST=existing

Change-Id: I72583e500cb0b69d9352b040c3e2885f9e0450c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195681
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
Johnni Winther
2021-04-19 08:03:30 +00:00
committed by commit-bot@chromium.org
parent 5168b3eb96
commit 3e44898e08
86 changed files with 1027 additions and 680 deletions
@@ -126,6 +126,9 @@ class EnumBuilder extends SourceClassBuilder {
Class referencesFrom,
IndexedClass referencesFromIndexed) {
assert(enumConstantInfos == null || enumConstantInfos.isNotEmpty);
Uri fileUri = parent.fileUri;
// TODO(ahe): These types shouldn't be looked up in scope, they come
// directly from dart:core.
TypeBuilder intType = new NamedTypeBuilder(
@@ -146,7 +149,8 @@ class EnumBuilder extends SourceClassBuilder {
/* arguments = */ null,
/* fileUri = */ null,
/* charOffset = */ null);
Class cls = new Class(name: name, reference: referencesFrom?.reference);
Class cls = new Class(
name: name, reference: referencesFrom?.reference, fileUri: fileUri);
Map<String, MemberBuilder> members = <String, MemberBuilder>{};
Map<String, MemberBuilder> constructors = <String, MemberBuilder>{};
NamedTypeBuilder selfType = new NamedTypeBuilder(
@@ -271,7 +271,8 @@ class SourceProcedureBuilder extends ProcedureBuilderImpl {
new FunctionNode(null),
isStatic: true,
isExtensionMember: true,
reference: _tearOffReference)
reference: _tearOffReference,
fileUri: fileUri)
..isNonNullableByDefault = library.isNonNullableByDefault;
}
}
@@ -1948,7 +1948,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
Procedure procedure = new Procedure(
new Name(syntheticProcedureName), ProcedureKind.Method, parameters,
isStatic: isStatic)
isStatic: isStatic, fileUri: debugLibrary.fileUri)
..isNonNullableByDefault = debugLibrary.isNonNullableByDefault;
parameters.body = new ReturnStatement(compiledExpression)
@@ -772,9 +772,10 @@ class KernelTarget extends TargetImplementation {
initializers: <Initializer>[initializer],
isSynthetic: true,
isConst: isConst,
reference: referenceFrom?.reference)
..isNonNullableByDefault = cls.enclosingLibrary.isNonNullableByDefault
..fileUri = cls.fileUri,
reference: referenceFrom?.reference,
fileUri: cls.fileUri)
..isNonNullableByDefault =
cls.enclosingLibrary.isNonNullableByDefault,
// If the constructor is constant, the default values must be part of
// the outline expressions. We pass on the original constructor and
// cloned function nodes to ensure that the default values are computed
@@ -801,7 +802,8 @@ class KernelTarget extends TargetImplementation {
returnType: makeConstructorReturnType(enclosingClass)),
name: new Name(""),
isSynthetic: true,
reference: referenceFrom?.reference)
reference: referenceFrom?.reference,
fileUri: enclosingClass.fileUri)
..isNonNullableByDefault =
enclosingClass.enclosingLibrary.isNonNullableByDefault);
}
@@ -75,16 +75,17 @@ const String kDebugClassName = "#DebugClass";
Component createExpressionEvaluationComponent(Procedure procedure) {
Library realLibrary = procedure.enclosingLibrary;
Library fakeLibrary = new Library(new Uri(scheme: 'evaluate', path: 'source'))
Uri uri = new Uri(scheme: 'evaluate', path: 'source');
Library fakeLibrary = new Library(uri, fileUri: uri)
..setLanguageVersion(realLibrary.languageVersion)
..isNonNullableByDefault = realLibrary.isNonNullableByDefault
..nonNullableByDefaultCompiledMode =
realLibrary.nonNullableByDefaultCompiledMode;
if (procedure.parent is Class) {
Class realClass = procedure.parent;
Class fakeClass = new Class(name: kDebugClassName)..parent = fakeLibrary;
TreeNode realClass = procedure.parent;
if (realClass is Class) {
Class fakeClass = new Class(name: kDebugClassName, fileUri: uri)
..parent = fakeLibrary;
Map<TypeParameter, TypeParameter> typeParams =
<TypeParameter, TypeParameter>{};
Map<TypeParameter, DartType> typeSubstitution = <TypeParameter, DartType>{};
@@ -68,7 +68,8 @@ Class initializeClass(
name: name,
typeParameters:
TypeVariableBuilder.typeParametersFromBuilders(typeVariables),
reference: referencesFrom?.reference);
reference: referencesFrom?.reference,
fileUri: parent.fileUri);
cls.fileUri ??= parent.fileUri;
if (cls.startFileOffset == TreeNode.noOffset) {
cls.startFileOffset = startCharOffset;
@@ -1030,7 +1030,8 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
initializer: new StringLiteral(jsonEncode(unserializableExports)),
isStatic: true,
isConst: true,
getterReference: getterReference));
getterReference: getterReference,
fileUri: library.fileUri));
}
return library;
@@ -22,9 +22,11 @@ import 'package:kernel/ast.dart'
main() async {
await asyncTest(() async {
Library library = new Library(Uri.parse("org.dartlang.fasta:library"));
Uri uri = Uri.parse("org.dartlang.fasta:library");
Library library = new Library(uri, fileUri: uri);
Field field = new Field.immutable(new Name("_exports#", library),
initializer: new StringLiteral('{"main":"Problem with main"}'));
initializer: new StringLiteral('{"main":"Problem with main"}'),
fileUri: library.fileUri);
library.addField(field);
Component component = new Component(libraries: <Library>[library]);
await CompilerContext.runWithDefaultOptions((CompilerContext c) async {
@@ -87,11 +87,14 @@ main() async {
LoadLibraryBuilder loadLibraryBuilder =
new LoadLibraryBuilder(libraryBuilder, null, -1);
Procedure getter = new Procedure(
new Name("myGetter"), ProcedureKind.Getter, new FunctionNode(null));
new Name("myGetter"), ProcedureKind.Getter, new FunctionNode(null),
fileUri: uri);
Procedure interfaceTarget = new Procedure(new Name("myInterfaceTarget"),
ProcedureKind.Method, new FunctionNode(null));
ProcedureKind.Method, new FunctionNode(null),
fileUri: uri);
Procedure setter = new Procedure(
new Name("mySetter"), ProcedureKind.Setter, new FunctionNode(null));
new Name("mySetter"), ProcedureKind.Setter, new FunctionNode(null),
fileUri: uri);
Message message = templateUnspecified.withArguments("My Message.");
Name binaryOperator = new Name("+");
Name name = new Name("bar");
@@ -110,8 +113,8 @@ main() async {
Generator generator =
new ThisAccessGenerator(helper, token, false, false, false);
Library library = new Library(uri);
Class cls = new Class(name: 'foo');
Library library = new Library(uri, fileUri: uri);
Class cls = new Class(name: 'foo', fileUri: uri);
library.addClass(cls);
library.addProcedure(getter);
library.addProcedure(setter);
@@ -121,7 +121,7 @@ class IncludesTypeParametersCovariantlyTest {
}
void test_interface_type() {
Class cls = new Class(name: 'C', typeParameters: [T, U]);
Class cls = new Class(name: 'C', typeParameters: [T, U], fileUri: dummyUri);
expect(
check(
new InterfaceType(cls, Nullability.legacy, [tpt(T), tpt(U)]), [T]),
@@ -187,7 +187,7 @@ class IncludesTypeParametersCovariantlyTest {
// typedef U F<T, U>(T x);
var typedefNode = new Typedef(
'F', new FunctionType([tpt(T)], tpt(U), Nullability.legacy),
typeParameters: [T, U]);
typeParameters: [T, U], fileUri: dummyUri);
expect(
check(
new TypedefType(typedefNode, Nullability.legacy,
@@ -31,9 +31,9 @@ class UnknownTypeTest {
void test_isKnown() {
expect(isKnown(unknownType), isFalse);
expect(isKnown(const DynamicType()), isTrue);
var classA = new Class(name: 'A');
var classA = new Class(name: 'A', fileUri: dummyUri);
var A = new InterfaceType(classA, Nullability.legacy);
var typedefF = new Typedef('F', A);
var typedefF = new Typedef('F', A, fileUri: dummyUri);
expect(isKnown(A), isTrue);
expect(isKnown(new InterfaceType(classA, Nullability.legacy, [A])), isTrue);
expect(
+4 -2
View File
@@ -1923,7 +1923,8 @@ void doSimulateTransformer(Component c) {
isFinal: true,
getterReference: lib.reference.canonicalName
?.getChildFromFieldWithName(fieldName)
?.reference);
?.reference,
fileUri: lib.fileUri);
lib.addField(field);
for (Class c in lib.classes) {
if (c.fields
@@ -1935,7 +1936,8 @@ void doSimulateTransformer(Component c) {
isFinal: true,
getterReference: c.reference.canonicalName
?.getChildFromFieldWithName(fieldName)
?.reference);
?.reference,
fileUri: c.fileUri);
c.addField(field);
}
}
+11 -6
View File
@@ -5,7 +5,7 @@
// @dart = 2.9
import 'package:expect/expect.dart';
import 'package:front_end/src/fasta/kernel/kernel_ast_api.dart';
import 'package:kernel/ast.dart';
import 'package:front_end/src/fasta/kernel/member_covariance.dart';
main() {
@@ -92,7 +92,8 @@ main() {
covariance.toString());
Procedure noParameterProcedure = new Procedure(
new Name('foo'), ProcedureKind.Method, new FunctionNode(null));
new Name('foo'), ProcedureKind.Method, new FunctionNode(null),
fileUri: dummyUri);
Covariance noParameterProcedureCovariance =
new Covariance.fromMember(noParameterProcedure, forSetter: false);
Expect.isTrue(noParameterProcedureCovariance.isEmpty);
@@ -106,7 +107,8 @@ main() {
new Name('foo'),
ProcedureKind.Method,
new FunctionNode(null,
positionalParameters: [new VariableDeclaration(null)]));
positionalParameters: [new VariableDeclaration(null)]),
fileUri: dummyUri);
Covariance oneParameterProcedureCovariance =
new Covariance.fromMember(oneParameterProcedure, forSetter: false);
Expect.isTrue(oneParameterProcedureCovariance.isEmpty);
@@ -127,7 +129,8 @@ main() {
new VariableDeclaration(null),
new VariableDeclaration(null),
new VariableDeclaration(null)
]));
]),
fileUri: dummyUri);
Covariance positionalParametersProcedureCovariance =
new Covariance.fromMember(positionalParametersProcedure,
forSetter: false);
@@ -156,7 +159,8 @@ main() {
new VariableDeclaration('c'),
new VariableDeclaration('d'),
new VariableDeclaration('e')
]));
]),
fileUri: dummyUri);
Covariance namedParametersProcedureCovariance =
new Covariance.fromMember(namedParametersProcedure, forSetter: false);
Expect.isTrue(namedParametersProcedureCovariance.isEmpty);
@@ -183,7 +187,8 @@ main() {
new TypeParameter(null),
new TypeParameter(null),
new TypeParameter(null),
]));
]),
fileUri: dummyUri);
Covariance typeParametersProcedureCovariance =
new Covariance.fromMember(typeParametersProcedure, forSetter: false);
Expect.isTrue(typeParametersProcedureCovariance.isEmpty);
@@ -365,6 +365,7 @@ ef
effects
efficient
efficiently
eighth
elem
eliminating
elt
@@ -1254,6 +1255,7 @@ tuple4
tuple5
tuple6
tuple7
tuple8
type1
type2
typeref
@@ -38,9 +38,12 @@ class ProcessedOptionsTest {
Component _mockOutline;
Component get mockSummary => _mockOutline ??= new Component(
libraries: [new Library(Uri.parse('org-dartlang-test:///a/b.dart'))])
..setMainMethodAndMode(null, false, NonNullableByDefaultCompiledMode.Weak);
Component get mockSummary => _mockOutline ??= new Component(libraries: [
new Library(Uri.parse('org-dartlang-test:///a/b.dart'),
fileUri: Uri.parse('org-dartlang-test:///a/b.dart'))
])
..setMainMethodAndMode(
null, false, NonNullableByDefaultCompiledMode.Weak);
test_compileSdk_false() {
for (var value in [false, true]) {
@@ -303,7 +303,7 @@ let final dynamic #0 = 0 in cascade { #0.foo = 1; #0.bar = 2; } => #0''');
}
void _testDeferredCheck() {
Library library = new Library(dummyUri);
Library library = new Library(dummyUri, fileUri: dummyUri);
LibraryDependency dependency =
LibraryDependency.deferredImport(library, 'pre');
VariableDeclaration check =
@@ -313,11 +313,12 @@ let final dynamic #0 = pre.checkLibraryIsLoaded() in 0''');
}
void _testFactoryConstructorInvocationJudgment() {
Library library = new Library(dummyUri);
Class cls = new Class(name: 'Class');
Library library = new Library(dummyUri, fileUri: dummyUri);
Class cls = new Class(name: 'Class', fileUri: dummyUri);
library.addClass(cls);
Procedure factoryConstructor = new Procedure(
new Name(''), ProcedureKind.Factory, new FunctionNode(null));
new Name(''), ProcedureKind.Factory, new FunctionNode(null),
fileUri: dummyUri);
cls.addProcedure(factoryConstructor);
testExpression(
@@ -525,7 +526,7 @@ foo{void}''');
}
void _testLoadLibraryImpl() {
Library library = new Library(dummyUri);
Library library = new Library(dummyUri, fileUri: dummyUri);
LibraryDependency dependency =
LibraryDependency.deferredImport(library, 'pre');
testExpression(new LoadLibraryImpl(dependency, new ArgumentsImpl([])), '''
@@ -537,7 +538,7 @@ pre.loadLibrary(0)''');
}
void _testLoadLibraryTearOff() {
Library library = new Library(dummyUri);
Library library = new Library(dummyUri, fileUri: dummyUri);
LibraryDependency dependency =
LibraryDependency.deferredImport(library, 'pre');
@@ -545,7 +546,8 @@ void _testLoadLibraryTearOff() {
pre.loadLibrary''');
Procedure procedure = new Procedure(new Name('get#loadLibrary'),
ProcedureKind.Getter, new FunctionNode(new Block([])));
ProcedureKind.Getter, new FunctionNode(new Block([])),
fileUri: dummyUri);
testExpression(new LoadLibraryTearOff(dependency, procedure), '''
pre.loadLibrary''');
}
@@ -610,12 +612,15 @@ void _testIndexSet() {}
void _testSuperIndexSet() {}
void _testExtensionIndexSet() {
Library library = new Library(dummyUri);
Library library = new Library(dummyUri, fileUri: dummyUri);
Extension extension = new Extension(
name: 'Extension', typeParameters: [new TypeParameter('T')]);
name: 'Extension',
typeParameters: [new TypeParameter('T')],
fileUri: dummyUri);
library.addExtension(extension);
Procedure setter =
new Procedure(new Name(''), ProcedureKind.Method, new FunctionNode(null));
Procedure setter = new Procedure(
new Name(''), ProcedureKind.Method, new FunctionNode(null),
fileUri: dummyUri);
library.addProcedure(setter);
testExpression(
+38 -23
View File
@@ -31,32 +31,42 @@ main() {
}
// Library mocks
Library dartCoreLib = new Library(new Uri(scheme: 'dart', path: 'core'));
Library myLib = new Library(Uri.parse("org-dartlang-testcase:///mylib.dart"));
Uri dartCoreUri = new Uri(scheme: 'dart', path: 'core');
Library dartCoreLib = new Library(dartCoreUri, fileUri: dartCoreUri);
Uri myUri = Uri.parse("org-dartlang-testcase:///mylib.dart");
Library myLib = new Library(myUri, fileUri: myUri);
// Set up some classes
Class objectClass = new Class(name: "Object")..parent = dartCoreLib;
Class objectClass = new Class(name: "Object", fileUri: dartCoreUri)
..parent = dartCoreLib;
Supertype objectSuper = new Supertype(objectClass, []);
Class boolClass = new Class(name: "bool", supertype: objectSuper)
..parent = dartCoreLib;
Class numClass = new Class(name: "num", supertype: objectSuper)
..parent = dartCoreLib;
Class boolClass =
new Class(name: "bool", supertype: objectSuper, fileUri: dartCoreUri)
..parent = dartCoreLib;
Class numClass =
new Class(name: "num", supertype: objectSuper, fileUri: dartCoreUri)
..parent = dartCoreLib;
Supertype numSuper = new Supertype(numClass, []);
Class intClass = new Class(name: "int", supertype: numSuper)
..parent = dartCoreLib;
Class fooClass = new Class(name: "Foo", supertype: objectSuper)
..parent = myLib;
Class foo2Class = new Class(name: "Foo", supertype: objectSuper)
..parent = myLib;
Class intClass =
new Class(name: "int", supertype: numSuper, fileUri: dartCoreUri)
..parent = dartCoreLib;
Class fooClass =
new Class(name: "Foo", supertype: objectSuper, fileUri: myUri)
..parent = myLib;
Class foo2Class =
new Class(name: "Foo", supertype: objectSuper, fileUri: myUri)
..parent = myLib;
Class barClass = new Class(
name: "Bar",
supertype: objectSuper,
typeParameters: [new TypeParameter("X")])
typeParameters: [new TypeParameter("X")],
fileUri: myUri)
..parent = myLib;
Class bazClass = new Class(
name: "Baz",
supertype: objectSuper,
typeParameters: [new TypeParameter("X"), new TypeParameter("Y")])
typeParameters: [new TypeParameter("X"), new TypeParameter("Y")],
fileUri: myUri)
..parent = myLib;
// Test types
@@ -184,25 +194,30 @@ main() {
check({funGenericBar: "T Function<T extends Bar<T>>(T)"}, 1);
// Add some members for testing instance constants
Field booField = new Field.immutable(new Name("boo"), type: boolType);
Field booField = new Field.immutable(new Name("boo"),
type: boolType, fileUri: fooClass.fileUri);
fooClass.fields.add(booField);
Field valueField = new Field.immutable(new Name("value"), type: intType);
Field valueField = new Field.immutable(new Name("value"),
type: intType, fileUri: foo2Class.fileUri);
foo2Class.fields.add(valueField);
Field nextField = new Field.immutable(new Name("next"), type: foo2);
Field nextField = new Field.immutable(new Name("next"),
type: foo2, fileUri: foo2Class.fileUri);
foo2Class.fields.add(nextField);
Field xField = new Field.immutable(new Name("x"),
type: new TypeParameterType(
bazClass.typeParameters[0], Nullability.legacy));
type:
new TypeParameterType(bazClass.typeParameters[0], Nullability.legacy),
fileUri: bazClass.fileUri);
bazClass.fields.add(xField);
Field yField = new Field.immutable(new Name("y"),
type: new TypeParameterType(
bazClass.typeParameters[1], Nullability.legacy));
type:
new TypeParameterType(bazClass.typeParameters[1], Nullability.legacy),
fileUri: bazClass.fileUri);
bazClass.fields.add(yField);
FunctionNode gooFunction = new FunctionNode(new EmptyStatement(),
typeParameters: [new TypeParameter("V")]);
Procedure gooMethod = new Procedure(
new Name("goo"), ProcedureKind.Method, gooFunction,
isStatic: true)
isStatic: true, fileUri: fooClass.fileUri)
..parent = fooClass;
// Test constants
@@ -12,7 +12,7 @@ import "dart:core" as core;
export "org-dartlang-testcase:///hello.dart" show main;
export "org-dartlang-testcase:///map.dart" show main;
static const field dynamic _exports# = #C1 /* from null */;
static const field dynamic _exports# = #C1;
library;
import self as self2;
@@ -11,7 +11,7 @@ import self as self;
export "org-dartlang-testcase:///hello.dart" show main;
export "org-dartlang-testcase:///map.dart" show main;
static const field dynamic _exports# = "{\"main\":\"'main' is exported from both 'pkg/front_end/testcases/general/hello.dart' and 'pkg/front_end/testcases/general/map.dart'.\"}" /* from null */;
static const field dynamic _exports# = "{\"main\":\"'main' is exported from both 'pkg/front_end/testcases/general/hello.dart' and 'pkg/front_end/testcases/general/map.dart'.\"}";
library;
import self as self2;
@@ -12,7 +12,7 @@ import "dart:core" as core;
export "org-dartlang-testcase:///hello.dart" show main;
export "org-dartlang-testcase:///map.dart" show main;
static const field dynamic _exports# = #C1 /* from null */;
static const field dynamic _exports# = #C1;
library;
import self as self2;
@@ -2,13 +2,13 @@ main = main::main;
library from "package:foo/foo.dart" as foo {
static field dart.core::bool* foo = true;
final field dynamic unique_SimulateTransformer /* from null */;
final field dynamic unique_SimulateTransformer;
}
library from "org-dartlang-test:///main.dart" as main {
import "package:foo/foo.dart";
final field dynamic unique_SimulateTransformer /* from null */;
final field dynamic unique_SimulateTransformer;
static method main() → dynamic {
dart.core::print(foo::foo);
}
@@ -2,13 +2,13 @@ main = main::main;
library from "package:foo/foo.dart" as foo {
static field dart.core::bool* foo2 = true;
final field dynamic unique_SimulateTransformer /* from null */;
final field dynamic unique_SimulateTransformer;
}
library from "org-dartlang-test:///main.dart" as main {
import "package:foo/foo.dart";
final field dynamic unique_SimulateTransformer /* from null */;
final field dynamic unique_SimulateTransformer;
static method main() → dynamic {
dart.core::print(foo::foo2);
}
@@ -23,7 +23,7 @@ library from "org-dartlang-test:///main.dart" as main {
export "org-dartlang-test:///lib1.dart" show x;
export "org-dartlang-test:///lib2.dart" show x;
static const field dynamic _exports# = #C1 /* from null */;
static const field dynamic _exports# = #C1;
static method main() → dynamic {
dart.core::print("exports");
}
@@ -23,7 +23,7 @@ library from "org-dartlang-test:///main.dart" as main {
export "org-dartlang-test:///lib1.dart" show x;
export "org-dartlang-test:///lib2.dart" show x;
static const field dynamic _exports# = #C1 /* from null */;
static const field dynamic _exports# = #C1;
static method main() → dynamic {
dart.core::print("exports!");
}
@@ -12,7 +12,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation {
final field wid::_Location* _location /* from null */;
final field wid::_Location* _location;
synthetic constructor •({wid::_Location* $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget*
: super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -12,7 +12,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation {
final field wid::_Location* _location /* from null */;
final field wid::_Location* _location;
synthetic constructor •({wid::_Location* $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget*
: super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -7,7 +7,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
;
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation /*hasConstConstructor*/ {
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
const constructor •({wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -7,7 +7,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
;
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation /*hasConstConstructor*/ {
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
const constructor •({wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -7,7 +7,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
;
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation /*hasConstConstructor*/ {
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
const constructor •({wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -7,7 +7,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
;
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation /*hasConstConstructor*/ {
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
const constructor •({wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -7,7 +7,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
;
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation /*hasConstConstructor*/ {
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
const constructor •({wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -8,7 +8,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation /*hasConstConstructor*/ {
final field dart.core::Object? key;
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
const constructor •({dart.core::Object? key = #C1, wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: fra::Widget::key = key, super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -8,7 +8,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation /*hasConstConstructor*/ {
final field dart.core::Object? key;
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
const constructor •({dart.core::Object? key = #C1, wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: fra::Widget::key = key, super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -7,7 +7,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
;
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation /*hasConstConstructor*/ {
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
const constructor •({wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -7,7 +7,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
;
}
abstract class Widget extends fra::Bar implements wid::_HasCreationLocation /*hasConstConstructor*/ {
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
const constructor •({wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: super fra::Bar::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -27,7 +27,7 @@ library from "org-dartlang-test:///main.dart" as main {
export "org-dartlang-test:///lib1.dart" show x;
export "org-dartlang-test:///lib2.dart" show x;
static const field dynamic _exports# = #C1 /* from null */;
static const field dynamic _exports# = #C1;
static method main() → dynamic {
dart.core::print("exports");
}
@@ -27,7 +27,7 @@ library from "org-dartlang-test:///main.dart" as main {
export "org-dartlang-test:///lib1.dart" show x;
export "org-dartlang-test:///lib2.dart" show x;
static const field dynamic _exports# = #C1 /* from null */;
static const field dynamic _exports# = #C1;
static method main() → dynamic {
dart.core::print("exports!");
}
@@ -4,7 +4,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
import "package:flutter/src/widgets/widget_inspector.dart";
abstract class Widget extends dart.core::Object implements wid::_HasCreationLocation {
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
synthetic constructor •({wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: super dart.core::Object::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -4,7 +4,7 @@ library from "package:flutter/src/widgets/framework.dart" as fra {
import "package:flutter/src/widgets/widget_inspector.dart";
abstract class Widget extends dart.core::Object implements wid::_HasCreationLocation {
final field wid::_Location? _location /*isLegacy, from null */;
final field wid::_Location? _location /*isLegacy*/;
synthetic constructor •({wid::_Location? $creationLocationd_0dea112b090073317d4 = #C1}) → fra::Widget
: super dart.core::Object::•(), fra::Widget::_location = $creationLocationd_0dea112b090073317d4
;
@@ -19,7 +19,7 @@ import "dart:core" as core;
export "org-dartlang-testcase:///ambiguous_main_export_lib1.dart";
export "org-dartlang-testcase:///ambiguous_main_export_lib2.dart";
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
library /*isNonNullableByDefault*/;
import self as self3;
@@ -19,7 +19,7 @@ import "dart:core" as core;
export "org-dartlang-testcase:///ambiguous_main_export_lib1.dart";
export "org-dartlang-testcase:///ambiguous_main_export_lib2.dart";
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
library /*isNonNullableByDefault*/;
import self as self3;
@@ -19,7 +19,7 @@ import "dart:core" as core;
export "org-dartlang-testcase:///ambiguous_main_export_lib1.dart";
export "org-dartlang-testcase:///ambiguous_main_export_lib2.dart";
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
library /*isNonNullableByDefault*/;
import self as self3;
@@ -19,7 +19,7 @@ import self as self2;
export "org-dartlang-testcase:///ambiguous_main_export_lib1.dart";
export "org-dartlang-testcase:///ambiguous_main_export_lib2.dart";
static const field dynamic _exports# = "{\"main\":\"'main' is exported from both 'pkg/front_end/testcases/nnbd/ambiguous_main_export_lib1.dart' and 'pkg/front_end/testcases/nnbd/ambiguous_main_export_lib2.dart'.\"}" /*isLegacy, from null */;
static const field dynamic _exports# = "{\"main\":\"'main' is exported from both 'pkg/front_end/testcases/nnbd/ambiguous_main_export_lib1.dart' and 'pkg/front_end/testcases/nnbd/ambiguous_main_export_lib2.dart'.\"}" /*isLegacy*/;
library /*isNonNullableByDefault*/;
import self as self3;
@@ -19,7 +19,7 @@ import "dart:core" as core;
export "org-dartlang-testcase:///ambiguous_main_export_lib1.dart";
export "org-dartlang-testcase:///ambiguous_main_export_lib2.dart";
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
library /*isNonNullableByDefault*/;
import self as self3;
@@ -176,7 +176,7 @@ late static final [setter] field core::int topLevelLateFinalFieldAndSetter2;
static final field core::int topLevelDuplicateFieldAndSetter;
static final field core::int topLevelFieldAndDuplicateSetter = 1;
static final field core::int topLevelDuplicateFieldAndDuplicateSetter;
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method topLevelMethod() → core::int
return 1;
static get topLevelGetter() → core::int
@@ -176,7 +176,7 @@ late static final [setter] field core::int topLevelLateFinalFieldAndSetter2;
static final field core::int topLevelDuplicateFieldAndSetter;
static final field core::int topLevelFieldAndDuplicateSetter = 1;
static final field core::int topLevelDuplicateFieldAndDuplicateSetter;
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method topLevelMethod() → core::int
return 1;
static get topLevelGetter() → core::int
@@ -176,7 +176,7 @@ late static final [setter] field core::int topLevelLateFinalFieldAndSetter2;
static final field core::int topLevelDuplicateFieldAndSetter;
static final field core::int topLevelFieldAndDuplicateSetter = 1;
static final field core::int topLevelDuplicateFieldAndDuplicateSetter;
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method topLevelMethod() → core::int
return 1;
static get topLevelGetter() → core::int
@@ -124,7 +124,7 @@ late static final [setter] field core::int topLevelLateFinalFieldAndSetter2;
static final field core::int topLevelDuplicateFieldAndSetter;
static final field core::int topLevelFieldAndDuplicateSetter;
static final field core::int topLevelDuplicateFieldAndDuplicateSetter;
static const field dynamic _exports# = "{\"topLevelSetter\":\"'topLevelSetter' is exported from both 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart' and 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart'.\",\"topLevelFieldAndDuplicateSetter\":\"'topLevelFieldAndDuplicateSetter' is exported from both 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart' and 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart'.\",\"topLevelDuplicateFieldAndDuplicateSetter\":\"'topLevelDuplicateFieldAndDuplicateSetter' is exported from both 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart' and 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart'.\"}" /*isLegacy, from null */;
static const field dynamic _exports# = "{\"topLevelSetter\":\"'topLevelSetter' is exported from both 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart' and 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart'.\",\"topLevelFieldAndDuplicateSetter\":\"'topLevelFieldAndDuplicateSetter' is exported from both 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart' and 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart'.\",\"topLevelDuplicateFieldAndDuplicateSetter\":\"'topLevelDuplicateFieldAndDuplicateSetter' is exported from both 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart' and 'pkg/front_end/testcases/nnbd/duplicates_toplevel.dart'.\"}" /*isLegacy*/;
static method topLevelMethod() → core::int
;
static get topLevelGetter() → core::int
@@ -176,7 +176,7 @@ late static final [setter] field core::int topLevelLateFinalFieldAndSetter2;
static final field core::int topLevelDuplicateFieldAndSetter;
static final field core::int topLevelFieldAndDuplicateSetter = 1;
static final field core::int topLevelDuplicateFieldAndDuplicateSetter;
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method topLevelMethod() → core::int
return 1;
static get topLevelGetter() → core::int
@@ -1143,7 +1143,7 @@ static field core::int? Extension|duplicateExtensionInstanceFieldAndStaticSetter
static final field core::int? Extension|duplicateExtensionInstanceFieldAndStaticSetter2;
static field core::int? Extension|duplicateExtensionStaticFieldAndInstanceSetter1;
static final field core::int? Extension|duplicateExtensionStaticFieldAndInstanceSetter2;
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method test() → dynamic {
self::topLevelFieldAndSetter = self::topLevelFieldAndSetter;
self::topLevelFieldAndDuplicateSetter = self::topLevelFieldAndDuplicateSetter;
@@ -1143,7 +1143,7 @@ static field core::int? Extension|duplicateExtensionInstanceFieldAndStaticSetter
static final field core::int? Extension|duplicateExtensionInstanceFieldAndStaticSetter2;
static field core::int? Extension|duplicateExtensionStaticFieldAndInstanceSetter1;
static final field core::int? Extension|duplicateExtensionStaticFieldAndInstanceSetter2;
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method test() → dynamic {
self::topLevelFieldAndSetter = self::topLevelFieldAndSetter;
self::topLevelFieldAndDuplicateSetter = self::topLevelFieldAndDuplicateSetter;
@@ -1143,7 +1143,7 @@ static field core::int? Extension|duplicateExtensionInstanceFieldAndStaticSetter
static final field core::int? Extension|duplicateExtensionInstanceFieldAndStaticSetter2;
static field core::int? Extension|duplicateExtensionStaticFieldAndInstanceSetter1;
static final field core::int? Extension|duplicateExtensionStaticFieldAndInstanceSetter2;
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method test() → dynamic {
self::topLevelFieldAndSetter = self::topLevelFieldAndSetter;
self::topLevelFieldAndDuplicateSetter = self::topLevelFieldAndDuplicateSetter;
@@ -774,7 +774,7 @@ static field core::int? Extension|duplicateExtensionInstanceFieldAndStaticSetter
static final field core::int? Extension|duplicateExtensionInstanceFieldAndStaticSetter2;
static field core::int? Extension|duplicateExtensionStaticFieldAndInstanceSetter1;
static final field core::int? Extension|duplicateExtensionStaticFieldAndInstanceSetter2;
static const field dynamic _exports# = "{\"topLevelFieldAndDuplicateSetter\":\"'topLevelFieldAndDuplicateSetter' is exported from both 'pkg/front_end/testcases/nnbd/field_vs_setter.dart' and 'pkg/front_end/testcases/nnbd/field_vs_setter.dart'.\",\"topLevelLateFinalFieldAndDuplicateSetter\":\"'topLevelLateFinalFieldAndDuplicateSetter' is exported from both 'pkg/front_end/testcases/nnbd/field_vs_setter.dart' and 'pkg/front_end/testcases/nnbd/field_vs_setter.dart'.\"}" /*isLegacy, from null */;
static const field dynamic _exports# = "{\"topLevelFieldAndDuplicateSetter\":\"'topLevelFieldAndDuplicateSetter' is exported from both 'pkg/front_end/testcases/nnbd/field_vs_setter.dart' and 'pkg/front_end/testcases/nnbd/field_vs_setter.dart'.\",\"topLevelLateFinalFieldAndDuplicateSetter\":\"'topLevelLateFinalFieldAndDuplicateSetter' is exported from both 'pkg/front_end/testcases/nnbd/field_vs_setter.dart' and 'pkg/front_end/testcases/nnbd/field_vs_setter.dart'.\"}" /*isLegacy*/;
static method test() → dynamic
;
static method main() → dynamic
@@ -1143,7 +1143,7 @@ static field core::int? Extension|duplicateExtensionInstanceFieldAndStaticSetter
static final field core::int? Extension|duplicateExtensionInstanceFieldAndStaticSetter2;
static field core::int? Extension|duplicateExtensionStaticFieldAndInstanceSetter1;
static final field core::int? Extension|duplicateExtensionStaticFieldAndInstanceSetter2;
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method test() → dynamic {
self::topLevelFieldAndSetter = self::topLevelFieldAndSetter;
self::topLevelFieldAndDuplicateSetter = self::topLevelFieldAndDuplicateSetter;
@@ -165,7 +165,7 @@ extension Extension on core::int? {
static set extensionInstanceMethodAndStaticSetter = set self::Extension|extensionInstanceMethodAndStaticSetter;
set extensionStaticMethodAndInstanceSetter = self::Extension|set#extensionStaticMethodAndInstanceSetter;
}
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method topLevelMethodAndSetter() → dynamic {}
static set topLevelMethodAndSetter(dynamic value) → void {}
static set classAndSetter(dynamic value) → void {}
@@ -165,7 +165,7 @@ extension Extension on core::int? {
static set extensionInstanceMethodAndStaticSetter = set self::Extension|extensionInstanceMethodAndStaticSetter;
set extensionStaticMethodAndInstanceSetter = self::Extension|set#extensionStaticMethodAndInstanceSetter;
}
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method topLevelMethodAndSetter() → dynamic {}
static set topLevelMethodAndSetter(dynamic value) → void {}
static set classAndSetter(dynamic value) → void {}
@@ -165,7 +165,7 @@ extension Extension on core::int? {
static set extensionInstanceMethodAndStaticSetter = set self::Extension|extensionInstanceMethodAndStaticSetter;
set extensionStaticMethodAndInstanceSetter = self::Extension|set#extensionStaticMethodAndInstanceSetter;
}
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method topLevelMethodAndSetter() → dynamic {}
static set topLevelMethodAndSetter(dynamic value) → void {}
static set classAndSetter(dynamic value) → void {}
@@ -138,7 +138,7 @@ extension Extension on core::int? {
static set extensionInstanceMethodAndStaticSetter = set self::Extension|extensionInstanceMethodAndStaticSetter;
set extensionStaticMethodAndInstanceSetter = self::Extension|set#extensionStaticMethodAndInstanceSetter;
}
static const field dynamic _exports# = "{\"topLevelMethodAndSetter\":\"'topLevelMethodAndSetter' is exported from both 'pkg/front_end/testcases/nnbd/nonfield_vs_setter.dart' and 'pkg/front_end/testcases/nnbd/nonfield_vs_setter.dart'.\"}" /*isLegacy, from null */;
static const field dynamic _exports# = "{\"topLevelMethodAndSetter\":\"'topLevelMethodAndSetter' is exported from both 'pkg/front_end/testcases/nnbd/nonfield_vs_setter.dart' and 'pkg/front_end/testcases/nnbd/nonfield_vs_setter.dart'.\"}" /*isLegacy*/;
static method topLevelMethodAndSetter() → dynamic
;
static set topLevelMethodAndSetter(dynamic value) → void
@@ -165,7 +165,7 @@ extension Extension on core::int? {
static set extensionInstanceMethodAndStaticSetter = set self::Extension|extensionInstanceMethodAndStaticSetter;
set extensionStaticMethodAndInstanceSetter = self::Extension|set#extensionStaticMethodAndInstanceSetter;
}
static const field dynamic _exports# = #C1 /*isLegacy, from null */;
static const field dynamic _exports# = #C1 /*isLegacy*/;
static method topLevelMethodAndSetter() → dynamic {}
static set topLevelMethodAndSetter(dynamic value) → void {}
static set classAndSetter(dynamic value) → void {}
@@ -63,14 +63,19 @@ void main() {
};
final testCoreLibraries = [
for (String requiredLibrary in allRequiredLibraries)
Library(Uri.parse(requiredLibrary), classes: [
for (String requiredClass in allRequiredTypes[requiredLibrary] ?? [])
Class(name: requiredClass),
], procedures: [
for (var requiredMethod in requiredMethods[requiredLibrary] ?? [])
Procedure(Name(requiredMethod), ProcedureKind.Method,
FunctionNode(EmptyStatement())),
]),
Library(Uri.parse(requiredLibrary),
fileUri: Uri.parse(requiredLibrary),
classes: [
for (String requiredClass
in allRequiredTypes[requiredLibrary] ?? [])
Class(name: requiredClass, fileUri: Uri.parse(requiredLibrary)),
],
procedures: [
for (var requiredMethod in requiredMethods[requiredLibrary] ?? [])
Procedure(Name(requiredMethod), ProcedureKind.Method,
FunctionNode(EmptyStatement()),
fileUri: Uri.parse(requiredLibrary)),
]),
];
final packageConfig = PackageConfig.parseJson({
@@ -86,12 +91,14 @@ void main() {
final multiRootScheme = 'org-dartlang-app';
test('compiles JavaScript code', () async {
final uri = Uri.file('/c.dart');
final library = Library(
Uri.file('/c.dart'),
fileUri: Uri.file('/c.dart'),
uri,
fileUri: uri,
procedures: [
Procedure(Name('ArbitrarilyChosen'), ProcedureKind.Method,
FunctionNode(Block([])))
FunctionNode(Block([])),
fileUri: uri)
],
);
final testComponent = Component(libraries: [library, ...testCoreLibraries]);
@@ -141,7 +148,8 @@ void main() {
fileUri: fileUri,
procedures: [
Procedure(Name('ArbitrarilyChosen'), ProcedureKind.Method,
FunctionNode(Block([])))
FunctionNode(Block([])),
fileUri: fileUri)
],
);
@@ -182,7 +190,8 @@ void main() {
fileUri: fileUri,
procedures: [
Procedure(Name('ArbitrarilyChosen'), ProcedureKind.Method,
FunctionNode(Block([])))
FunctionNode(Block([])),
fileUri: fileUri)
],
);
@@ -222,15 +231,17 @@ void main() {
final libraryB = Library(Uri.file('/b.dart'), fileUri: Uri.file('/b.dart'));
libraryC.dependencies.add(LibraryDependency.import(libraryB));
libraryB.dependencies.add(LibraryDependency.import(libraryC));
final uriA = Uri.file('/a.dart');
final libraryA = Library(
Uri.file('/a.dart'),
fileUri: Uri.file('/a.dart'),
uriA,
fileUri: uriA,
dependencies: [
LibraryDependency.import(libraryB),
],
procedures: [
Procedure(Name('ArbitrarilyChosen'), ProcedureKind.Method,
FunctionNode(Block([])))
FunctionNode(Block([])),
fileUri: uriA)
],
);
final testComponent = Component(
+1 -1
View File
@@ -147,7 +147,7 @@ type CanonicalName {
type ComponentFile {
UInt32 magic = 0x90ABCDEF;
UInt32 formatVersion = 61;
UInt32 formatVersion = 62;
Byte[10] shortSdkHash;
List<String> problemsAsJson; // Described in problems.md.
Library[] libraries;
+46 -35
View File
@@ -231,7 +231,7 @@ abstract class NamedNode extends TreeNode {
abstract class FileUriNode extends TreeNode {
/// The URI of the source file this node was loaded from.
// TODO(johnniwinther): Make this non-nullable.
Uri? get fileUri;
Uri get fileUri;
}
abstract class Annotatable extends TreeNode {
@@ -256,7 +256,7 @@ class Library extends NamedNode
/// The URI of the source file this library was loaded from.
@override
Uri? fileUri;
Uri fileUri;
Version? _languageVersion;
Version get languageVersion => _languageVersion ?? defaultLanguageVersion;
@@ -359,9 +359,11 @@ class Library extends NamedNode
List<Extension>? extensions,
List<Procedure>? procedures,
List<Field>? fields,
this.fileUri,
required this.fileUri,
Reference? reference})
: this.annotations = annotations ?? <Expression>[],
// ignore: unnecessary_null_comparison
: assert(fileUri != null),
this.annotations = annotations ?? <Expression>[],
this.dependencies = dependencies ?? <LibraryDependency>[],
this.parts = parts ?? <LibraryPart>[],
this.typedefs = typedefs ?? <Typedef>[],
@@ -769,7 +771,7 @@ class Combinator extends TreeNode {
class Typedef extends NamedNode implements FileUriNode, Annotatable {
/// The URI of the source file that contains the declaration of this typedef.
@override
Uri? fileUri;
Uri fileUri;
@override
List<Expression> annotations = const <Expression>[];
@@ -789,12 +791,14 @@ class Typedef extends NamedNode implements FileUriNode, Annotatable {
Typedef(this.name, this.type,
{Reference? reference,
this.fileUri,
required this.fileUri,
List<TypeParameter>? typeParameters,
List<TypeParameter>? typeParametersOfFunctionType,
List<VariableDeclaration>? positionalParameters,
List<VariableDeclaration>? namedParameters})
: this.typeParameters = typeParameters ?? <TypeParameter>[],
// ignore: unnecessary_null_comparison
: assert(fileUri != null),
this.typeParameters = typeParameters ?? <TypeParameter>[],
this.typeParametersOfFunctionType =
typeParametersOfFunctionType ?? <TypeParameter>[],
this.positionalParameters =
@@ -853,7 +857,7 @@ class Typedef extends NamedNode implements FileUriNode, Annotatable {
@override
Location? _getLocationInEnclosingFile(int offset) {
return _getLocationInComponent(enclosingComponent, fileUri!, offset);
return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
@override
@@ -1037,7 +1041,7 @@ class Class extends NamedNode implements Annotatable, FileUriNode {
/// The URI of the source file this class was loaded from.
@override
Uri? fileUri;
Uri fileUri;
final List<TypeParameter> typeParameters;
@@ -1146,10 +1150,12 @@ class Class extends NamedNode implements Annotatable, FileUriNode {
List<Procedure>? procedures,
List<Field>? fields,
List<RedirectingFactoryConstructor>? redirectingFactoryConstructors,
this.fileUri,
required this.fileUri,
Reference? reference})
// ignore: unnecessary_null_comparison
: assert(name != null),
// ignore: unnecessary_null_comparison
assert(fileUri != null),
this.typeParameters = typeParameters ?? <TypeParameter>[],
this.implementedTypes = implementedTypes ?? <Supertype>[],
this.fieldsInternal = fields ?? <Field>[],
@@ -1413,7 +1419,7 @@ class Class extends NamedNode implements Annotatable, FileUriNode {
@override
Location? _getLocationInEnclosingFile(int offset) {
return _getLocationInComponent(enclosingComponent, fileUri!, offset);
return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
}
@@ -1429,7 +1435,7 @@ class Extension extends NamedNode implements Annotatable, FileUriNode {
String name;
/// The URI of the source file this class was loaded from.
Uri? fileUri;
Uri fileUri;
/// Type parameters declared on the extension.
final List<TypeParameter> typeParameters;
@@ -1466,10 +1472,12 @@ class Extension extends NamedNode implements Annotatable, FileUriNode {
List<TypeParameter>? typeParameters,
DartType? onType,
List<ExtensionMemberDescriptor>? members,
this.fileUri,
required this.fileUri,
Reference? reference})
// ignore: unnecessary_null_comparison
: assert(name != null),
// ignore: unnecessary_null_comparison
assert(fileUri != null),
this.typeParameters = typeParameters ?? <TypeParameter>[],
this.members = members ?? <ExtensionMemberDescriptor>[],
super(reference) {
@@ -1515,7 +1523,7 @@ class Extension extends NamedNode implements Annotatable, FileUriNode {
@override
Location? _getLocationInEnclosingFile(int offset) {
return _getLocationInComponent(enclosingComponent, fileUri!, offset);
return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
@override
@@ -1621,7 +1629,7 @@ abstract class Member extends NamedNode implements Annotatable, FileUriNode {
/// The URI of the source file this member was loaded from.
@override
Uri? fileUri;
Uri fileUri;
/// Flags summarizing the kinds of AST nodes contained in this member, for
/// speeding up transformations that only affect certain types of nodes.
@@ -1643,6 +1651,8 @@ abstract class Member extends NamedNode implements Annotatable, FileUriNode {
Member(this.name, this.fileUri, Reference? reference)
// ignore: unnecessary_null_comparison
: assert(name != null),
// ignore: unnecessary_null_comparison
assert(fileUri != null),
super(reference);
Class? get enclosingClass => parent is Class ? parent as Class : null;
@@ -1761,7 +1771,7 @@ class Field extends Member {
bool isStatic: false,
bool isLate: false,
int transformerFlags: 0,
Uri? fileUri,
required Uri fileUri,
Reference? getterReference,
Reference? setterReference})
: this.setterReference = setterReference ?? new Reference(),
@@ -1786,7 +1796,7 @@ class Field extends Member {
bool isStatic: false,
bool isLate: false,
int transformerFlags: 0,
Uri? fileUri,
required Uri fileUri,
Reference? getterReference})
: this.setterReference = null,
super(name, fileUri, getterReference) {
@@ -1959,7 +1969,7 @@ class Field extends Member {
@override
Location? _getLocationInEnclosingFile(int offset) {
return _getLocationInComponent(enclosingComponent, fileUri!, offset);
return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
@override
@@ -2000,7 +2010,7 @@ class Constructor extends Member {
bool isSynthetic: false,
List<Initializer>? initializers,
int transformerFlags: 0,
Uri? fileUri,
required Uri fileUri,
Reference? reference})
: this.initializers = initializers ?? <Initializer>[],
// ignore: unnecessary_null_comparison
@@ -2116,7 +2126,7 @@ class Constructor extends Member {
@override
Location? _getLocationInEnclosingFile(int offset) {
return _getLocationInComponent(enclosingComponent, fileUri!, offset);
return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
}
@@ -2180,7 +2190,7 @@ class RedirectingFactoryConstructor extends Member {
List<VariableDeclaration>? positionalParameters,
List<VariableDeclaration>? namedParameters,
int? requiredParameterCount,
Uri? fileUri,
required Uri fileUri,
Reference? reference})
: this.typeArguments = typeArguments ?? <DartType>[],
this.typeParameters = typeParameters ?? <TypeParameter>[],
@@ -2291,7 +2301,7 @@ class RedirectingFactoryConstructor extends Member {
@override
Location? _getLocationInEnclosingFile(int offset) {
return _getLocationInComponent(enclosingComponent, fileUri!, offset);
return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
}
@@ -2546,7 +2556,7 @@ class Procedure extends Member {
bool isExtensionMember: false,
bool isSynthetic: false,
int transformerFlags: 0,
Uri? fileUri,
required Uri fileUri,
Reference? reference,
ProcedureStubKind stubKind: ProcedureStubKind.Regular,
Member? stubTarget})
@@ -2572,7 +2582,7 @@ class Procedure extends Member {
bool isExtensionMember: false,
bool isSynthetic: false,
int transformerFlags: 0,
Uri? fileUri,
required Uri fileUri,
Reference? reference,
this.stubKind: ProcedureStubKind.Regular,
this.stubTargetReference})
@@ -2796,7 +2806,7 @@ class Procedure extends Member {
@override
Location? _getLocationInEnclosingFile(int offset) {
return _getLocationInComponent(enclosingComponent, fileUri!, offset);
return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
}
@@ -13589,7 +13599,7 @@ final Name dummyName = new _PublicName('');
/// This is used as the removal sentinel in [RemovingTransformer] and can be
/// used for instance as a dummy initial value for the `List.filled`
/// constructor.
final Library dummyLibrary = new Library(dummyUri);
final Library dummyLibrary = new Library(dummyUri, fileUri: dummyUri);
/// Non-nullable [LibraryDependency] dummy value.
///
@@ -13618,7 +13628,7 @@ final LibraryPart dummyLibraryPart = new LibraryPart(const [], '');
/// This is used as the removal sentinel in [RemovingTransformer] and can be
/// used for instance as a dummy initial value for the `List.filled`
/// constructor.
final Class dummyClass = new Class(name: '');
final Class dummyClass = new Class(name: '', fileUri: dummyUri);
/// Non-nullable [Constructor] dummy value.
///
@@ -13626,35 +13636,36 @@ final Class dummyClass = new Class(name: '');
/// used for instance as a dummy initial value for the `List.filled`
/// constructor.
final Constructor dummyConstructor =
new Constructor(dummyFunctionNode, name: dummyName);
new Constructor(dummyFunctionNode, name: dummyName, fileUri: dummyUri);
/// Non-nullable [Extension] dummy value.
///
/// This is used as the removal sentinel in [RemovingTransformer] and can be
/// used for instance as a dummy initial value for the `List.filled`
/// constructor.
final Extension dummyExtension = new Extension(name: '');
final Extension dummyExtension = new Extension(name: '', fileUri: dummyUri);
/// Non-nullable [Member] dummy value.
///
/// This can be used for instance as a dummy initial value for the
/// `List.filled` constructor.
final Member dummyMember = new Field.mutable(new _PublicName(''));
final Member dummyMember = new Field.mutable(dummyName, fileUri: dummyUri);
/// Non-nullable [Procedure] dummy value.
///
/// This is used as the removal sentinel in [RemovingTransformer] and can be
/// used for instance as a dummy initial value for the `List.filled`
/// constructor.
final Procedure dummyProcedure =
new Procedure(dummyName, ProcedureKind.Method, dummyFunctionNode);
final Procedure dummyProcedure = new Procedure(
dummyName, ProcedureKind.Method, dummyFunctionNode,
fileUri: dummyUri);
/// Non-nullable [Field] dummy value.
///
/// This is used as the removal sentinel in [RemovingTransformer] and can be
/// used for instance as a dummy initial value for the `List.filled`
/// constructor.
final Field dummyField = new Field.mutable(dummyName);
final Field dummyField = new Field.mutable(dummyName, fileUri: dummyUri);
/// Non-nullable [RedirectingFactoryConstructor] dummy value.
///
@@ -13662,14 +13673,14 @@ final Field dummyField = new Field.mutable(dummyName);
/// used for instance as a dummy initial value for the `List.filled`
/// constructor.
final RedirectingFactoryConstructor dummyRedirectingFactoryConstructor =
new RedirectingFactoryConstructor(null, name: dummyName);
new RedirectingFactoryConstructor(null, name: dummyName, fileUri: dummyUri);
/// Non-nullable [Typedef] dummy value.
///
/// This is used as the removal sentinel in [RemovingTransformer] and can be
/// used for instance as a dummy initial value for the `List.filled`
/// constructor.
final Typedef dummyTypedef = new Typedef('', null);
final Typedef dummyTypedef = new Typedef('', null, fileUri: dummyUri);
/// Non-nullable [Initializer] dummy value.
///
+38 -27
View File
@@ -469,8 +469,8 @@ class BinaryBuilder {
growable: useGrowableLists);
}
Uri? readUriReference() {
return _sourceUriTable[readUInt30()];
Uri readUriReference() {
return _sourceUriTable[readUInt30()]!;
}
String readStringReference() {
@@ -1110,19 +1110,20 @@ class BinaryBuilder {
CanonicalName canonicalName = readNonNullCanonicalNameReference();
Reference reference = canonicalName.reference;
Library? library = reference.node as Library?;
String? name = readStringOrNullIfEmpty();
// TODO(jensj): We currently save (almost the same) uri twice.
Uri fileUri = readUriReference();
if (alwaysCreateNewNamedNodes) {
library = null;
}
if (library == null) {
library =
new Library(Uri.parse(canonicalName.name), reference: reference);
library = new Library(Uri.parse(canonicalName.name),
reference: reference, fileUri: fileUri);
component.libraries.add(library..parent = component);
}
_currentLibrary = library;
String? name = readStringOrNullIfEmpty();
// TODO(jensj): We currently save (almost the same) uri twice.
Uri? fileUri = readUriReference();
List<String>? problemsAsJson = readListOfStrings();
@@ -1245,11 +1246,11 @@ class BinaryBuilder {
if (alwaysCreateNewNamedNodes) {
node = null;
}
Uri? fileUri = readUriReference();
Uri fileUri = readUriReference();
int fileOffset = readOffset();
String name = readStringReference();
if (node == null) {
node = new Typedef(name, null, reference: reference);
node = new Typedef(name, null, reference: reference, fileUri: fileUri);
}
node.annotations = readAnnotationList(node);
readAndPushTypeParameterList(node.typeParameters, node);
@@ -1293,14 +1294,15 @@ class BinaryBuilder {
if (alwaysCreateNewNamedNodes) {
node = null;
}
Uri? fileUri = readUriReference();
Uri fileUri = readUriReference();
int startFileOffset = readOffset();
int fileOffset = readOffset();
int fileEndOffset = readOffset();
int flags = readByte();
String name = readStringReference();
if (node == null) {
node = new Class(name: name, reference: reference)..dirty = false;
node = new Class(name: name, reference: reference, fileUri: fileUri)
..dirty = false;
}
node.startFileOffset = startFileOffset;
@@ -1351,17 +1353,21 @@ class BinaryBuilder {
}
String name = readStringReference();
if (node == null) {
node = new Extension(name: name, reference: reference);
}
assert(() {
debugPath.add(name);
return true;
}());
node.annotations = readAnnotationList(node);
List<Expression> annotations = readAnnotationList();
Uri fileUri = readUriReference();
if (node == null) {
node = new Extension(name: name, reference: reference, fileUri: fileUri);
}
node.annotations = annotations;
setParents(annotations, node);
Uri? fileUri = readUriReference();
node.fileOffset = readOffset();
readAndPushTypeParameterList(node.typeParameters, node);
@@ -1443,7 +1449,7 @@ class BinaryBuilder {
if (alwaysCreateNewNamedNodes) {
node = null;
}
Uri? fileUri = readUriReference();
Uri fileUri = readUriReference();
int fileOffset = readOffset();
int fileEndOffset = readOffset();
int flags = readUInt30();
@@ -1451,9 +1457,12 @@ class BinaryBuilder {
if (node == null) {
if (setterReference != null) {
node = new Field.mutable(name,
getterReference: getterReference, setterReference: setterReference);
getterReference: getterReference,
setterReference: setterReference,
fileUri: fileUri);
} else {
node = new Field.immutable(name, getterReference: getterReference);
node = new Field.immutable(name,
getterReference: getterReference, fileUri: fileUri);
}
}
List<Expression> annotations = readAnnotationList(node);
@@ -1487,7 +1496,7 @@ class BinaryBuilder {
if (alwaysCreateNewNamedNodes) {
node = null;
}
Uri? fileUri = readUriReference();
Uri fileUri = readUriReference();
int startFileOffset = readOffset();
int fileOffset = readOffset();
int fileEndOffset = readOffset();
@@ -1500,7 +1509,8 @@ class BinaryBuilder {
}());
FunctionNode function = readFunctionNode();
if (node == null) {
node = new Constructor(function, reference: reference, name: name);
node = new Constructor(function,
reference: reference, name: name, fileUri: fileUri);
}
pushVariableDeclarations(function.positionalParameters);
pushVariableDeclarations(function.namedParameters);
@@ -1530,7 +1540,7 @@ class BinaryBuilder {
if (alwaysCreateNewNamedNodes) {
node = null;
}
Uri? fileUri = readUriReference();
Uri fileUri = readUriReference();
int startFileOffset = readOffset();
int fileOffset = readOffset();
int fileEndOffset = readOffset();
@@ -1553,7 +1563,8 @@ class BinaryBuilder {
FunctionNode function = readFunctionNode(
lazyLoadBody: !readFunctionNodeNow, outerEndOffset: endOffset);
if (node == null) {
node = new Procedure(name, kind, function, reference: reference);
node = new Procedure(name, kind, function,
reference: reference, fileUri: fileUri);
} else {
assert(node.kind == kind);
}
@@ -1590,14 +1601,14 @@ class BinaryBuilder {
if (alwaysCreateNewNamedNodes) {
node = null;
}
Uri? fileUri = readUriReference();
Uri fileUri = readUriReference();
int fileOffset = readOffset();
int fileEndOffset = readOffset();
int flags = readByte();
Name name = readName();
if (node == null) {
node = new RedirectingFactoryConstructor(null,
reference: reference, name: name);
reference: reference, name: name, fileUri: fileUri);
}
List<Expression> annotations = readAnnotationList(node);
assert(() {
@@ -2315,7 +2326,7 @@ class BinaryBuilder {
}
Expression _readFileUriExpression() {
Uri fileUri = readUriReference()!;
Uri fileUri = readUriReference();
int offset = readOffset();
return new FileUriExpression(readExpression(), fileUri)
..fileOffset = offset;
+6 -8
View File
@@ -274,7 +274,7 @@ class BinaryPrinter implements Visitor<void>, BinarySink {
}
// Returns the new active file uri.
void writeUriReference(Uri? uri) {
void writeUriReference(Uri uri) {
final int index = _sourceUriIndexer.put(uri);
writeUInt30(index);
if (!_currentlyInNonimplementation) {
@@ -784,7 +784,7 @@ class BinaryPrinter implements Visitor<void>, BinarySink {
// Write data.
int i = 0;
Uint8List buffer = new Uint8List(1 << 16);
for (Uri? uri in _sourceUriIndexer.index.keys) {
for (Uri uri in _sourceUriIndexer.index.keys) {
index[i] = getBufferOffset();
Source? source = uriToSource[uri];
if (source == null ||
@@ -795,7 +795,7 @@ class BinaryPrinter implements Visitor<void>, BinarySink {
<int>[], const <int>[], source?.importUri, source?.fileUri);
}
String uriAsString = uri == null ? "" : "$uri";
String uriAsString = "$uri";
outputStringViaBuffer(uriAsString, buffer);
writeByteList(source.source);
@@ -2863,13 +2863,11 @@ class StringIndexer {
class UriIndexer {
// Note that the iteration order is important.
final Map<Uri?, int> index = new Map<Uri?, int>();
final Map<Uri, int> index = new Map<Uri, int>();
UriIndexer() {
put(null);
}
UriIndexer();
int put(Uri? uri) {
int put(Uri uri) {
int? result = index[uri];
if (result == null) {
result = index.length;
+1 -1
View File
@@ -174,7 +174,7 @@ class Tag {
/// Internal version of kernel binary format.
/// Bump it when making incompatible changes in kernel binaries.
/// Keep in sync with runtime/vm/kernel_binary.h, pkg/kernel/binary.md.
static const int BinaryFormatVersion = 61;
static const int BinaryFormatVersion = 62;
}
abstract class ConstantTag {
+17 -13
View File
@@ -99,7 +99,9 @@ class CloneVisitorNotMembers implements TreeVisitor<TreeNode> {
T clone<T extends TreeNode>(T node) {
final Uri? activeFileUriSaved = _activeFileUri;
if (node is FileUriNode) _activeFileUri = node.fileUri ?? _activeFileUri;
if (node is FileUriNode) {
_activeFileUri = node.fileUri;
}
final TreeNode result = node.accept(this)
..fileOffset = _cloneFileOffset(node.fileOffset);
_activeFileUri = activeFileUriSaved;
@@ -109,7 +111,9 @@ class CloneVisitorNotMembers implements TreeVisitor<TreeNode> {
T? cloneOptional<T extends TreeNode>(T? node) {
if (node == null) return null;
final Uri? activeFileUriSaved = _activeFileUri;
if (node is FileUriNode) _activeFileUri = node.fileUri ?? _activeFileUri;
if (node is FileUriNode) {
_activeFileUri = node.fileUri;
}
TreeNode? result = node.accept(this);
if (result != null) result.fileOffset = _cloneFileOffset(node.fileOffset);
_activeFileUri = activeFileUriSaved;
@@ -128,8 +132,8 @@ class CloneVisitorNotMembers implements TreeVisitor<TreeNode> {
Uri? _activeFileUriFromContext(TreeNode? node) {
while (node != null) {
if (node is FileUriNode && node.fileUri != null) {
return node.fileUri!;
if (node is FileUriNode) {
return node.fileUri;
}
node = node.parent;
}
@@ -754,7 +758,7 @@ class CloneVisitorWithMembers extends CloneVisitorNotMembers {
Constructor cloneConstructor(Constructor node, Reference? reference) {
final Uri? activeFileUriSaved = _activeFileUri;
_activeFileUri = node.fileUri ?? _activeFileUri;
_activeFileUri = node.fileUri;
Constructor result = new Constructor(
super.clone(node.function),
@@ -764,7 +768,7 @@ class CloneVisitorWithMembers extends CloneVisitorNotMembers {
isSynthetic: node.isSynthetic,
initializers: node.initializers.map(super.clone).toList(),
transformerFlags: node.transformerFlags,
fileUri: _activeFileUri,
fileUri: node.fileUri,
reference: reference,
)
..annotations = cloneAnnotations && !node.annotations.isEmpty
@@ -779,12 +783,12 @@ class CloneVisitorWithMembers extends CloneVisitorNotMembers {
Procedure cloneProcedure(Procedure node, Reference? reference) {
final Uri? activeFileUriSaved = _activeFileUri;
_activeFileUri = node.fileUri ?? _activeFileUri;
_activeFileUri = node.fileUri;
Procedure result = new Procedure(
node.name, node.kind, super.clone(node.function),
reference: reference,
transformerFlags: node.transformerFlags,
fileUri: _activeFileUri,
fileUri: node.fileUri,
stubKind: node.stubKind,
stubTarget: node.stubTarget)
..annotations = cloneAnnotations && !node.annotations.isEmpty
@@ -802,7 +806,7 @@ class CloneVisitorWithMembers extends CloneVisitorNotMembers {
Field cloneField(
Field node, Reference? getterReference, Reference? setterReference) {
final Uri? activeFileUriSaved = _activeFileUri;
_activeFileUri = node.fileUri ?? _activeFileUri;
_activeFileUri = node.fileUri;
Field result;
if (node.hasSetter) {
@@ -810,7 +814,7 @@ class CloneVisitorWithMembers extends CloneVisitorNotMembers {
type: visitType(node.type),
initializer: cloneOptional(node.initializer),
transformerFlags: node.transformerFlags,
fileUri: _activeFileUri,
fileUri: node.fileUri,
getterReference: getterReference,
setterReference: setterReference);
} else {
@@ -822,7 +826,7 @@ class CloneVisitorWithMembers extends CloneVisitorNotMembers {
type: visitType(node.type),
initializer: cloneOptional(node.initializer),
transformerFlags: node.transformerFlags,
fileUri: _activeFileUri,
fileUri: node.fileUri,
getterReference: getterReference);
}
result
@@ -840,7 +844,7 @@ class CloneVisitorWithMembers extends CloneVisitorNotMembers {
RedirectingFactoryConstructor cloneRedirectingFactoryConstructor(
RedirectingFactoryConstructor node, Reference? reference) {
final Uri? activeFileUriSaved = _activeFileUri;
_activeFileUri = node.fileUri ?? _activeFileUri;
_activeFileUri = node.fileUri;
prepareTypeParameters(node.typeParameters);
RedirectingFactoryConstructor result = new RedirectingFactoryConstructor(
@@ -855,7 +859,7 @@ class CloneVisitorWithMembers extends CloneVisitorNotMembers {
node.positionalParameters.map(super.clone).toList(),
namedParameters: node.namedParameters.map(super.clone).toList(),
requiredParameterCount: node.requiredParameterCount,
fileUri: _activeFileUri,
fileUri: node.fileUri,
reference: reference)
..annotations = cloneAnnotations && !node.annotations.isEmpty
? node.annotations.map(super.clone).toList()
+42 -44
View File
@@ -9,17 +9,30 @@ import 'package:kernel/ast.dart';
/// Returns a [Component] object containing empty definitions of core SDK
/// classes.
Component createMockSdkComponent() {
Library coreLib = new Library(Uri.parse('dart:core'), name: 'dart.core');
Library asyncLib = new Library(Uri.parse('dart:async'), name: 'dart.async');
Library internalLib =
new Library(Uri.parse('dart:_internal'), name: 'dart._internal');
Library coreLib = new Library(Uri.parse('dart:core'),
name: 'dart.core', fileUri: Uri.parse('dart:core'));
Library asyncLib = new Library(Uri.parse('dart:async'),
name: 'dart.async', fileUri: Uri.parse('dart:async'));
Library internalLib = new Library(Uri.parse('dart:_internal'),
name: 'dart._internal', fileUri: Uri.parse('dart:_internal'));
Class addClass(Library lib, Class c) {
Class objectClass = new Class(name: 'Object', fileUri: coreLib.fileUri);
coreLib.addClass(objectClass);
Class addClass(Library lib, String name,
{Supertype supertype,
List<TypeParameter> typeParameters,
List<Supertype> implementedTypes}) {
Class c = new Class(
name: name,
supertype: supertype ?? objectClass.asThisSupertype,
typeParameters: typeParameters,
implementedTypes: implementedTypes,
fileUri: lib.fileUri);
lib.addClass(c);
return c;
}
Class objectClass = addClass(coreLib, new Class(name: 'Object'));
InterfaceType objectType =
new InterfaceType(objectClass, coreLib.nonNullable);
@@ -27,48 +40,33 @@ Component createMockSdkComponent() {
return new TypeParameter(name, bound ?? objectType);
}
Class class_(String name,
{Supertype supertype,
List<TypeParameter> typeParameters,
List<Supertype> implementedTypes}) {
return new Class(
name: name,
supertype: supertype ?? objectClass.asThisSupertype,
typeParameters: typeParameters,
implementedTypes: implementedTypes);
}
addClass(coreLib, class_('Null'));
addClass(coreLib, class_('bool'));
Class num = addClass(coreLib, class_('num'));
addClass(coreLib, class_('String'));
addClass(coreLib, 'Null');
addClass(coreLib, 'bool');
Class num = addClass(coreLib, 'num');
addClass(coreLib, 'String');
Class iterable =
addClass(coreLib, class_('Iterable', typeParameters: [typeParam('T')]));
addClass(coreLib, 'Iterable', typeParameters: [typeParam('T')]);
{
TypeParameter T = typeParam('T');
addClass(
coreLib,
class_('List', typeParameters: [
T
], implementedTypes: [
new Supertype(iterable, [
new TypeParameterType.withDefaultNullabilityForLibrary(T, coreLib)
])
]));
addClass(coreLib, 'List', typeParameters: [
T
], implementedTypes: [
new Supertype(iterable,
[new TypeParameterType.withDefaultNullabilityForLibrary(T, coreLib)])
]);
}
addClass(
coreLib, class_('Map', typeParameters: [typeParam('K'), typeParam('V')]));
addClass(coreLib, class_('int', supertype: num.asThisSupertype));
addClass(coreLib, class_('double', supertype: num.asThisSupertype));
addClass(coreLib, class_('Iterator', typeParameters: [typeParam('T')]));
addClass(coreLib, class_('Symbol'));
addClass(coreLib, class_('Type'));
addClass(coreLib, class_('Function'));
addClass(coreLib, class_('Invocation'));
addClass(coreLib, class_('Future', typeParameters: [typeParam('T')]));
addClass(asyncLib, class_('FutureOr', typeParameters: [typeParam('T')]));
addClass(asyncLib, class_('Stream', typeParameters: [typeParam('T')]));
addClass(internalLib, class_('Symbol'));
addClass(coreLib, 'Map', typeParameters: [typeParam('K'), typeParam('V')]);
addClass(coreLib, 'int', supertype: num.asThisSupertype);
addClass(coreLib, 'double', supertype: num.asThisSupertype);
addClass(coreLib, 'Iterator', typeParameters: [typeParam('T')]);
addClass(coreLib, 'Symbol');
addClass(coreLib, 'Type');
addClass(coreLib, 'Function');
addClass(coreLib, 'Invocation');
addClass(coreLib, 'Future', typeParameters: [typeParam('T')]);
addClass(asyncLib, 'FutureOr', typeParameters: [typeParam('T')]);
addClass(asyncLib, 'Stream', typeParameters: [typeParam('T')]);
addClass(internalLib, 'Symbol');
return new Component(libraries: [coreLib, asyncLib, internalLib]);
}
@@ -501,8 +501,9 @@ class _KernelFromParsedType implements Visitor<Node, TypeParserEnvironment> {
..defaultType = type;
}
}
Uri uri = new Uri.file("test.lib");
List<DartType> defaultTypes = calculateBounds(typeParameters, objectClass,
new Library(new Uri.file("test.lib"))..isNonNullableByDefault = true);
new Library(uri, fileUri: uri)..isNonNullableByDefault = true);
for (int i = 0; i < typeParameters.length; i++) {
typeParameters[i].defaultType = defaultTypes[i];
}
@@ -594,6 +594,69 @@ class Tuple7<T1, T2, T3, T4, T5, T6, T7> {
this.sixth, this.seventh);
}
class Tuple8Serializer<T1, T2, T3, T4, T5, T6, T7, T8>
extends TextSerializer<Tuple8<T1, T2, T3, T4, T5, T6, T7, T8>> {
final TextSerializer<T1> first;
final TextSerializer<T2> second;
final TextSerializer<T3> third;
final TextSerializer<T4> fourth;
final TextSerializer<T5> fifth;
final TextSerializer<T6> sixth;
final TextSerializer<T7> seventh;
final TextSerializer<T8> eighth;
const Tuple8Serializer(this.first, this.second, this.third, this.fourth,
this.fifth, this.sixth, this.seventh, this.eighth);
Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> readFrom(
Iterator<Object?> stream, DeserializationState? state) {
return new Tuple8(
first.readFrom(stream, state),
second.readFrom(stream, state),
third.readFrom(stream, state),
fourth.readFrom(stream, state),
fifth.readFrom(stream, state),
sixth.readFrom(stream, state),
seventh.readFrom(stream, state),
eighth.readFrom(stream, state));
}
void writeTo(
StringBuffer buffer,
Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> object,
SerializationState? state) {
first.writeTo(buffer, object.first, state);
if (!second.isEmpty) buffer.write(' ');
second.writeTo(buffer, object.second, state);
if (!third.isEmpty) buffer.write(' ');
third.writeTo(buffer, object.third, state);
if (!fourth.isEmpty) buffer.write(' ');
fourth.writeTo(buffer, object.fourth, state);
if (!fifth.isEmpty) buffer.write(' ');
fifth.writeTo(buffer, object.fifth, state);
if (!sixth.isEmpty) buffer.write(' ');
sixth.writeTo(buffer, object.sixth, state);
if (!seventh.isEmpty) buffer.write(' ');
seventh.writeTo(buffer, object.seventh, state);
if (!eighth.isEmpty) buffer.write(' ');
eighth.writeTo(buffer, object.eighth, state);
}
}
class Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> {
final T1 first;
final T2 second;
final T3 third;
final T4 fourth;
final T5 fifth;
final T6 sixth;
final T7 seventh;
final T8 eighth;
const Tuple8(this.first, this.second, this.third, this.fourth, this.fifth,
this.sixth, this.seventh, this.eighth);
}
// A serializer/deserializer for lists.
class ListSerializer<T> extends TextSerializer<List<T>> {
final TextSerializer<T> elements;
+105 -83
View File
@@ -1966,83 +1966,93 @@ class MemberTagger implements Tagger<Member> {
}
TextSerializer<Field> mutableFieldSerializer =
Wrapped<Tuple4<Name, int, DartType, Expression?>, Field>(
(w) => Tuple4(w.name, w.flags, w.type, w.initializer),
(u) => Field.mutable(u.first, type: u.third, initializer: u.fourth)
Wrapped<Tuple5<Name, int, DartType, Expression?, Uri>, Field>(
(w) => Tuple5(w.name, w.flags, w.type, w.initializer, w.fileUri),
(u) => Field.mutable(u.first,
type: u.third, initializer: u.fourth, fileUri: u.fifth)
..flags = u.second,
Tuple4Serializer(nameSerializer, fieldFlagsSerializer,
dartTypeSerializer, nullableExpressionSerializer));
Tuple5Serializer(nameSerializer, fieldFlagsSerializer,
dartTypeSerializer, nullableExpressionSerializer, UriSerializer()));
TextSerializer<Field> immutableFieldSerializer =
Wrapped<Tuple4<Name, int, DartType, Expression?>, Field>(
(w) => Tuple4(w.name, w.flags, w.type, w.initializer),
(u) => Field.immutable(u.first, type: u.third, initializer: u.fourth)
Wrapped<Tuple5<Name, int, DartType, Expression?, Uri>, Field>(
(w) => Tuple5(w.name, w.flags, w.type, w.initializer, w.fileUri),
(u) => Field.immutable(u.first,
type: u.third, initializer: u.fourth, fileUri: u.fifth)
..flags = u.second,
Tuple4Serializer(nameSerializer, fieldFlagsSerializer,
dartTypeSerializer, nullableExpressionSerializer));
Tuple5Serializer(nameSerializer, fieldFlagsSerializer,
dartTypeSerializer, nullableExpressionSerializer, UriSerializer()));
TextSerializer<Procedure> methodSerializer =
Wrapped<Tuple3<Name, int, FunctionNode>, Procedure>(
(w) => Tuple3(w.name, w.flags, w.function),
Wrapped<Tuple4<Name, int, FunctionNode, Uri>, Procedure>(
(w) => Tuple4(w.name, w.flags, w.function, w.fileUri),
(u) =>
Procedure(u.first, ProcedureKind.Method, u.third)..flags = u.second,
Tuple3Serializer(
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
Procedure(u.first, ProcedureKind.Method, u.third, fileUri: u.fourth)
..flags = u.second,
Tuple4Serializer(nameSerializer, procedureFlagsSerializer,
functionNodeSerializer, UriSerializer()));
TextSerializer<Procedure> getterSerializer =
Wrapped<Tuple3<Name, int, FunctionNode>, Procedure>(
(w) => Tuple3(w.name, w.flags, w.function),
Wrapped<Tuple4<Name, int, FunctionNode, Uri>, Procedure>(
(w) => Tuple4(w.name, w.flags, w.function, w.fileUri),
(u) =>
Procedure(u.first, ProcedureKind.Getter, u.third)..flags = u.second,
Tuple3Serializer(
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
Procedure(u.first, ProcedureKind.Getter, u.third, fileUri: u.fourth)
..flags = u.second,
Tuple4Serializer(nameSerializer, procedureFlagsSerializer,
functionNodeSerializer, UriSerializer()));
TextSerializer<Procedure> setterSerializer =
Wrapped<Tuple3<Name, int, FunctionNode>, Procedure>(
(w) => Tuple3(w.name, w.flags, w.function),
Wrapped<Tuple4<Name, int, FunctionNode, Uri>, Procedure>(
(w) => Tuple4(w.name, w.flags, w.function, w.fileUri),
(u) =>
Procedure(u.first, ProcedureKind.Setter, u.third)..flags = u.second,
Tuple3Serializer(
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
Procedure(u.first, ProcedureKind.Setter, u.third, fileUri: u.fourth)
..flags = u.second,
Tuple4Serializer(nameSerializer, procedureFlagsSerializer,
functionNodeSerializer, UriSerializer()));
TextSerializer<Procedure> operatorSerializer =
Wrapped<Tuple3<Name, int, FunctionNode>, Procedure>(
(w) => Tuple3(w.name, w.flags, w.function),
(u) => Procedure(u.first, ProcedureKind.Operator, u.third)
Wrapped<Tuple4<Name, int, FunctionNode, Uri>, Procedure>(
(w) => Tuple4(w.name, w.flags, w.function, w.fileUri),
(u) => Procedure(u.first, ProcedureKind.Operator, u.third,
fileUri: u.fourth)
..flags = u.second,
Tuple3Serializer(
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
Tuple4Serializer(nameSerializer, procedureFlagsSerializer,
functionNodeSerializer, UriSerializer()));
TextSerializer<Procedure> factorySerializer =
Wrapped<Tuple3<Name, int, FunctionNode>, Procedure>(
(w) => Tuple3(w.name, w.flags, w.function),
(u) => Procedure(u.first, ProcedureKind.Factory, u.third)
..flags = u.second,
Tuple3Serializer(
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
TextSerializer<Procedure> factorySerializer = Wrapped<
Tuple4<Name, int, FunctionNode, Uri>, Procedure>(
(w) => Tuple4(w.name, w.flags, w.function, w.fileUri),
(u) => Procedure(u.first, ProcedureKind.Factory, u.third, fileUri: u.fourth)
..flags = u.second,
Tuple4Serializer(nameSerializer, procedureFlagsSerializer,
functionNodeSerializer, UriSerializer()));
TextSerializer<Constructor> constructorSerializer = Wrapped<
Tuple3<Name, int, Tuple2<FunctionNode, List<Initializer>?>>,
Tuple4<Name, int, Tuple2<FunctionNode, List<Initializer>?>, Uri>,
Constructor>(
(w) => Tuple3(w.name, w.flags, Tuple2(w.function, w.initializers)),
(u) =>
Constructor(u.third.first, name: u.first, initializers: u.third.second)
..flags = u.second,
Tuple3Serializer(nameSerializer, constructorFlagsSerializer,
functionNodeWithInitializersSerializer));
(w) =>
Tuple4(w.name, w.flags, Tuple2(w.function, w.initializers), w.fileUri),
(u) => Constructor(u.third.first,
name: u.first, initializers: u.third.second, fileUri: u.fourth)
..flags = u.second,
Tuple4Serializer(nameSerializer, constructorFlagsSerializer,
functionNodeWithInitializersSerializer, UriSerializer()));
TextSerializer<RedirectingFactoryConstructor>
redirectingFactoryConstructorSerializer = Wrapped<
Tuple4<
redirectingFactoryConstructorSerializer
// Comment added to direct formatter.
= Wrapped<
Tuple5<
Name,
int,
CanonicalName,
Tuple2<
List<TypeParameter>,
Tuple4<List<VariableDeclaration>, List<VariableDeclaration>,
List<VariableDeclaration>, List<DartType>>>>,
List<VariableDeclaration>, List<DartType>>>,
Uri>,
RedirectingFactoryConstructor>(
(w) => Tuple4(
(w) => Tuple5(
w.name,
w.flags,
w.targetReference!.canonicalName!,
@@ -2056,7 +2066,8 @@ TextSerializer<RedirectingFactoryConstructor>
.skip(w.requiredParameterCount)
.toList(),
w.namedParameters,
w.typeArguments))),
w.typeArguments)),
w.fileUri),
(u) => RedirectingFactoryConstructor(u.third.reference,
name: u.first,
typeParameters: u.fourth.first,
@@ -2064,9 +2075,10 @@ TextSerializer<RedirectingFactoryConstructor>
u.fourth.second.first + u.fourth.second.second,
requiredParameterCount: u.fourth.second.first.length,
namedParameters: u.fourth.second.third,
typeArguments: u.fourth.second.fourth)
typeArguments: u.fourth.second.fourth,
fileUri: u.fifth)
..flags = u.second,
Tuple4Serializer(
Tuple5Serializer(
nameSerializer,
redirectingFactoryConstructorFlagsSerializer,
CanonicalNameSerializer(),
@@ -2076,7 +2088,8 @@ TextSerializer<RedirectingFactoryConstructor>
ListSerializer(variableDeclarationSerializer),
ListSerializer(variableDeclarationSerializer),
ListSerializer(variableDeclarationSerializer),
ListSerializer(dartTypeSerializer)))));
ListSerializer(dartTypeSerializer))),
UriSerializer()));
Case<Member> memberSerializer = new Case.uninitialized(const MemberTagger());
@@ -2117,11 +2130,11 @@ TextSerializer<int> libraryFlagsSerializer = Wrapped<List<int>, int>(
Case(LibraryFlagTagger(), convertFlagsMap(libraryFlagToName))));
TextSerializer<Library> librarySerializer = new Wrapped<
Tuple7<Uri, int, List<LibraryPart>, List<Member>, List<Class>,
List<Typedef>, List<Extension>>,
Tuple8<Uri, int, List<LibraryPart>, List<Member>, List<Class>,
List<Typedef>, List<Extension>, Uri>,
Library>(
(w) => Tuple7(w.importUri, w.flags, w.parts, [...w.fields, ...w.procedures],
w.classes, w.typedefs, w.extensions),
(w) => Tuple8(w.importUri, w.flags, w.parts, [...w.fields, ...w.procedures],
w.classes, w.typedefs, w.extensions, w.fileUri),
(u) => Library(u.first,
parts: u.third,
fields: u.fourth.where((m) => m is Field).cast<Field>().toList(),
@@ -2129,16 +2142,18 @@ TextSerializer<Library> librarySerializer = new Wrapped<
u.fourth.where((m) => m is Procedure).cast<Procedure>().toList(),
classes: u.fifth,
typedefs: u.sixth,
extensions: u.seventh)
extensions: u.seventh,
fileUri: u.eighth)
..flags = u.second,
Tuple7Serializer(
Tuple8Serializer(
UriSerializer(),
libraryFlagsSerializer,
ListSerializer(libraryPartSerializer),
ListSerializer(memberSerializer),
ListSerializer(classSerializer),
ListSerializer(typedefSerializer),
ListSerializer(extensionSerializer)),
ListSerializer(extensionSerializer),
UriSerializer()),
);
TextSerializer<Component> componentSerializer =
@@ -2387,43 +2402,47 @@ TextSerializer<int> classFlagsSerializer = Wrapped<List<int>, int>(
ListSerializer(Case(ClassFlagTagger(), convertFlagsMap(classFlagToName))));
TextSerializer<Class> classSerializer = Wrapped<
Tuple3<
Tuple4<
String,
int,
Uri,
Tuple2<
List<TypeParameter>,
/* Comment added to guide formatting. */
Tuple4<Supertype?, Supertype?, List<Supertype>, List<Member>>>>,
Class>(
(w) => Tuple3(
(w) => Tuple4(
w.name,
w.flags,
w.fileUri,
Tuple2(
w.typeParameters,
Tuple4(w.supertype, w.mixedInType, w.implementedTypes,
<Member>[...w.fields, ...w.constructors, ...w.procedures]))),
(u) => Class(
name: u.first,
typeParameters: u.third.first,
supertype: u.third.second.first,
mixedInType: u.third.second.second,
implementedTypes: u.third.second.third,
fields: u.third.second.fourth
typeParameters: u.fourth.first,
supertype: u.fourth.second.first,
mixedInType: u.fourth.second.second,
implementedTypes: u.fourth.second.third,
fields: u.fourth.second.fourth
.where((m) => m is Field)
.cast<Field>()
.toList(),
constructors: u.third.second.fourth
constructors: u.fourth.second.fourth
.where((m) => m is Constructor)
.cast<Constructor>()
.toList(),
procedures: u.third.second.fourth
procedures: u.fourth.second.fourth
.where((m) => m is Procedure)
.cast<Procedure>()
.toList())
.toList(),
fileUri: u.third)
..flags = u.second,
Tuple3Serializer(
Tuple4Serializer(
DartString(),
classFlagsSerializer,
UriSerializer(),
Bind(
typeParametersSerializer,
Tuple4Serializer(
@@ -2432,13 +2451,13 @@ TextSerializer<Class> classSerializer = Wrapped<
ListSerializer(supertypeSerializer),
ListSerializer(memberSerializer)))));
TextSerializer<Typedef> typedefSerializer =
Wrapped<Tuple2<String, Tuple2<List<TypeParameter>, DartType>>, Typedef>(
(w) => Tuple2(w.name, Tuple2(w.typeParameters, w.type!)),
(u) =>
Typedef(u.first, u.second.second, typeParameters: u.second.first),
Tuple2Serializer(
DartString(), Bind(typeParametersSerializer, dartTypeSerializer)));
TextSerializer<Typedef> typedefSerializer = Wrapped<
Tuple3<String, Tuple2<List<TypeParameter>, DartType>, Uri>, Typedef>(
(w) => Tuple3(w.name, Tuple2(w.typeParameters, w.type!), w.fileUri),
(u) => Typedef(u.first, u.second.second,
typeParameters: u.second.first, fileUri: u.third),
Tuple3Serializer(DartString(),
Bind(typeParametersSerializer, dartTypeSerializer), UriSerializer()));
const Map<int, String> extensionMemberDescriptorFlagToName = const {
ExtensionMemberDescriptor.FlagStatic: "static",
@@ -2498,19 +2517,22 @@ TextSerializer<ExtensionMemberDescriptor> extensionMemberDescriptorSerializer =
CanonicalNameSerializer()));
TextSerializer<Extension> extensionSerializer = Wrapped<
Tuple3<String, Tuple2<List<TypeParameter>, DartType>,
List<ExtensionMemberDescriptor>>,
Tuple4<String, Tuple2<List<TypeParameter>, DartType>,
List<ExtensionMemberDescriptor>, Uri>,
Extension>(
(w) => Tuple3(w.name, Tuple2(w.typeParameters, w.onType), w.members),
(w) => Tuple4(
w.name, Tuple2(w.typeParameters, w.onType), w.members, w.fileUri),
(u) => Extension(
name: u.first,
typeParameters: u.second.first,
onType: u.second.second,
members: u.third),
Tuple3Serializer(
members: u.third,
fileUri: u.fourth),
Tuple4Serializer(
DartString(),
Bind(typeParametersSerializer, dartTypeSerializer),
ListSerializer(extensionMemberDescriptorSerializer)));
ListSerializer(extensionMemberDescriptorSerializer),
UriSerializer()));
void initializeSerializers() {
expressionSerializer.registerTags({
@@ -390,7 +390,8 @@ class WidgetCreatorTracker {
isFinal: true,
getterReference: clazz.reference.canonicalName
?.getChildFromFieldWithName(fieldName)
.reference);
.reference,
fileUri: clazz.fileUri);
clazz.addField(locationField);
final Set<Constructor> _handledConstructors =
@@ -38,7 +38,8 @@ main() {
// Try individually.
List<int> c1Serialized;
{
Library lib1 = new Library(Uri.parse("foo://bar.dart"))
Uri uri = Uri.parse("foo://bar.dart");
Library lib1 = new Library(uri, fileUri: uri)
..nonNullableByDefaultCompiledMode = c1Mode;
Component c1 = new Component(libraries: [lib1]);
setCompileMode(c1, c1Mode);
@@ -49,7 +50,8 @@ main() {
List<int> c2Serialized;
{
Library lib2 = new Library(Uri.parse("foo://baz.dart"))
Uri uri = Uri.parse("foo://baz.dart");
Library lib2 = new Library(uri, fileUri: uri)
..nonNullableByDefaultCompiledMode = c2Mode;
Component c2 = new Component(libraries: [lib2]);
setCompileMode(c2, c2Mode);
@@ -9,7 +9,8 @@ import 'package:kernel/binary/ast_from_binary.dart' show ParseError;
import 'utils.dart';
main() {
Library lib1 = new Library(Uri.parse("foo://bar.dart"));
Uri uri = Uri.parse("foo://bar.dart");
Library lib1 = new Library(uri, fileUri: uri);
Component c1 = new Component(libraries: [lib1]);
List<int> serialized = serializeComponent(c1);
// The last 4 bytes is the size entry in the index. Overwrite that with 0's.
@@ -13,21 +13,24 @@ main() {
{
/// Create a library with two classes (A and B) where class A - in its
/// constructor - invokes the constructor for B.
lib = new Library(Uri.parse('org-dartlang:///lib.dart'));
final Class classA = new Class(name: "A");
final Uri uri = Uri.parse('org-dartlang:///lib.dart');
lib = new Library(uri, fileUri: uri);
final Class classA = new Class(name: "A", fileUri: uri);
lib.addClass(classA);
final Class classB = new Class(name: "B");
final Class classB = new Class(name: "B", fileUri: uri);
lib.addClass(classB);
final Constructor classBConstructor = new Constructor(
new FunctionNode(new EmptyStatement()),
name: new Name(""));
name: new Name(""),
fileUri: uri);
classB.addConstructor(classBConstructor);
final Constructor classAConstructor = new Constructor(
new FunctionNode(new ExpressionStatement(new ConstructorInvocation(
classBConstructor, new Arguments.empty()))),
name: new Name(""));
name: new Name(""),
fileUri: uri);
classA.addConstructor(classAConstructor);
}
Component c = new Component(libraries: [lib]);
@@ -58,7 +58,8 @@ main() {
"isNonNullableByDefault: $isNonNullableByDefault; "
"nonNullableByDefaultCompiledMode:"
" $nonNullableByDefaultCompiledMode");
Library lib = new Library(Uri.parse("foo://bar.dart"));
Uri uri = Uri.parse("foo://bar.dart");
Library lib = new Library(uri, fileUri: uri);
setSynthetic(lib, isSynthetic);
setNonNullableByDefault(lib, isNonNullableByDefault);
setNonNullableByDefaultCompiledMode(
+262 -144
View File
@@ -84,13 +84,14 @@ class ClosedWorldClassHierarchyTest {
final Component component = createMockSdkComponent();
CoreTypes coreTypes;
final Library library =
new Library(Uri.parse('org-dartlang:///test.dart'), name: 'test');
Library library;
ClassHierarchy _hierarchy;
ClosedWorldClassHierarchyTest() {
coreTypes = new CoreTypes(component);
Uri uri = Uri.parse('org-dartlang:///test.dart');
library = new Library(uri, fileUri: uri, name: 'test');
library.parent = component;
component.libraries.add(library);
}
@@ -100,14 +101,16 @@ class ClosedWorldClassHierarchyTest {
}
void test_applyTreeChanges() {
Class a = addClass(new Class(name: 'A', supertype: objectSuper));
Class a = addClass(
new Class(name: 'A', supertype: objectSuper, fileUri: library.fileUri));
_assertLibraryText(library, '''
class A {}
''');
Class b = new Class(name: 'B', supertype: a.asThisSupertype);
Library libWithB =
new Library(Uri.parse('org-dartlang:///test_b.dart'), name: 'test_b');
Uri uriB = Uri.parse('org-dartlang:///test_b.dart');
Class b = new Class(
name: 'B', supertype: a.asThisSupertype, fileUri: library.fileUri);
Library libWithB = new Library(uriB, fileUri: uriB, name: 'test_b');
libWithB.parent = component;
component.libraries.add(libWithB);
libWithB.addClass(b);
@@ -116,7 +119,8 @@ library test_b;
import self as self;
import "test.dart" as test;
class B extends test::A {}
class B extends test::A { // from org-dartlang:///test.dart
}
''');
// No updated classes, the same hierarchy.
@@ -124,9 +128,10 @@ class B extends test::A {}
// Has updated classes, still the same hierarchy (instance). Can answer
// queries about the new classes.
var c = new Class(name: 'C', supertype: a.asThisSupertype);
Library libWithC =
new Library(Uri.parse('org-dartlang:///test2.dart'), name: 'test2');
var c = new Class(
name: 'C', supertype: a.asThisSupertype, fileUri: library.fileUri);
Uri uriC = Uri.parse('org-dartlang:///test2.dart');
Library libWithC = new Library(uriC, fileUri: uriC, name: 'test2');
libWithC.parent = component;
component.libraries.add(libWithC);
libWithC.addClass(c);
@@ -147,9 +152,15 @@ class B extends test::A {}
var methodB1 = newEmptyMethod('memberB1');
var a = addClass(new Class(
name: 'A', supertype: objectSuper, procedures: [methodA1, methodA2]));
name: 'A',
supertype: objectSuper,
procedures: [methodA1, methodA2],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B', supertype: a.asThisSupertype, procedures: [methodB1]));
name: 'B',
supertype: a.asThisSupertype,
procedures: [methodB1],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -191,25 +202,34 @@ class B extends self::A {
var methodInD = newEmptyMethod('foo');
var methodInE = newEmptyMethod('foo');
var a = addClass(
new Class(name: 'A', supertype: objectSuper, procedures: [methodInA]));
var a = addClass(new Class(
name: 'A',
supertype: objectSuper,
procedures: [methodInA],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
isAbstract: true,
supertype: objectSuper,
procedures: [methodInB]));
procedures: [methodInB],
fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C',
supertype: b.asThisSupertype,
implementedTypes: [a.asThisSupertype]));
implementedTypes: [a.asThisSupertype],
fileUri: library.fileUri));
addClass(new Class(
name: 'D', supertype: b.asThisSupertype, procedures: [methodInD]));
name: 'D',
supertype: b.asThisSupertype,
procedures: [methodInD],
fileUri: library.fileUri));
addClass(new Class(
name: 'E',
isAbstract: true,
supertype: objectSuper,
implementedTypes: [c.asThisSupertype],
procedures: [methodInE]));
procedures: [methodInE],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -239,28 +259,36 @@ abstract class E implements self::C {
}
void test_getSubtypesOf() {
var a = addClass(new Class(name: 'A', supertype: objectSuper));
var b = addClass(new Class(name: 'B', supertype: objectSuper));
var c = addClass(new Class(name: 'C', supertype: objectSuper));
var a = addClass(
new Class(name: 'A', supertype: objectSuper, fileUri: library.fileUri));
var b = addClass(
new Class(name: 'B', supertype: objectSuper, fileUri: library.fileUri));
var c = addClass(
new Class(name: 'C', supertype: objectSuper, fileUri: library.fileUri));
var d = addClass(new Class(name: 'D', supertype: a.asThisSupertype));
var d = addClass(new Class(
name: 'D', supertype: a.asThisSupertype, fileUri: library.fileUri));
var e = addClass(new Class(
name: 'E',
supertype: b.asThisSupertype,
implementedTypes: [c.asThisSupertype]));
implementedTypes: [c.asThisSupertype],
fileUri: library.fileUri));
var f = addClass(new Class(
name: 'F',
supertype: e.asThisSupertype,
implementedTypes: [a.asThisSupertype]));
implementedTypes: [a.asThisSupertype],
fileUri: library.fileUri));
var g = addClass(new Class(name: 'G', supertype: objectSuper));
var g = addClass(
new Class(name: 'G', supertype: objectSuper, fileUri: library.fileUri));
var h = addClass(new Class(
name: 'H',
supertype: g.asThisSupertype,
implementedTypes: [c.asThisSupertype, a.asThisSupertype]));
implementedTypes: [c.asThisSupertype, a.asThisSupertype],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {}
@@ -324,7 +352,8 @@ class H extends self::G implements self::C, self::A {}
name: name,
typeParameters: typeParameters,
supertype: supertype,
implementedTypes: implementedTypes));
implementedTypes: implementedTypes,
fileUri: library.fileUri));
}
Procedure newEmptyGetter(String name,
@@ -332,14 +361,15 @@ class H extends self::G implements self::C, self::A {}
var body =
isAbstract ? null : new Block([new ReturnStatement(new NullLiteral())]);
return new Procedure(new Name(name), ProcedureKind.Getter,
new FunctionNode(body, returnType: returnType));
new FunctionNode(body, returnType: returnType),
fileUri: library.fileUri);
}
Procedure newEmptyMethod(String name, {bool isAbstract: false}) {
var body = isAbstract ? null : new Block([]);
return new Procedure(new Name(name), ProcedureKind.Method,
new FunctionNode(body, returnType: const VoidType()),
isAbstract: isAbstract);
isAbstract: isAbstract, fileUri: library.fileUri);
}
Procedure newEmptySetter(String name,
@@ -350,7 +380,8 @@ class H extends self::G implements self::C, self::A {}
ProcedureKind.Setter,
new FunctionNode(body,
returnType: const VoidType(),
positionalParameters: [new VariableDeclaration('_', type: type)]));
positionalParameters: [new VariableDeclaration('_', type: type)]),
fileUri: library.fileUri);
}
/// 2. A non-abstract member is inherited from a superclass, and in the
@@ -360,21 +391,26 @@ class H extends self::G implements self::C, self::A {}
var a = addClass(new Class(
name: 'A',
supertype: objectSuper,
procedures: [newEmptyMethod('foo'), newEmptyMethod('bar')]));
procedures: [newEmptyMethod('foo'), newEmptyMethod('bar')],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
supertype: a.asThisSupertype,
procedures: [newEmptyMethod('foo', isAbstract: true)]));
procedures: [newEmptyMethod('foo', isAbstract: true)],
fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C',
supertype: a.asThisSupertype,
implementedTypes: [b.asThisSupertype]));
var d = addClass(new Class(name: 'D', supertype: objectSuper));
implementedTypes: [b.asThisSupertype],
fileUri: library.fileUri));
var d = addClass(
new Class(name: 'D', supertype: objectSuper, fileUri: library.fileUri));
var e = addClass(new Class(
name: 'E',
supertype: d.asThisSupertype,
mixedInType: a.asThisSupertype,
implementedTypes: [b.asThisSupertype]));
implementedTypes: [b.asThisSupertype],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -399,18 +435,23 @@ class E = self::D with self::A implements self::B {}
var a = addClass(new Class(
name: 'A',
supertype: objectSuper,
procedures: [newEmptyMethod('foo')]));
procedures: [newEmptyMethod('foo')],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
supertype: a.asThisSupertype,
procedures: [newEmptyMethod('foo', isAbstract: true)]));
procedures: [newEmptyMethod('foo', isAbstract: true)],
fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C',
supertype: a.asThisSupertype,
procedures: [newEmptyMethod('foo', isAbstract: true)],
isAbstract: true));
var d = addClass(new Class(name: 'D', supertype: b.asThisSupertype));
var e = addClass(new Class(name: 'E', supertype: c.asThisSupertype));
isAbstract: true,
fileUri: library.fileUri));
var d = addClass(new Class(
name: 'D', supertype: b.asThisSupertype, fileUri: library.fileUri));
var e = addClass(new Class(
name: 'E', supertype: c.asThisSupertype, fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -438,11 +479,13 @@ class E extends self::C {}
var a = addClass(new Class(
name: 'A',
supertype: objectSuper,
procedures: [newEmptyMethod('foo'), newEmptyMethod('bar')]));
procedures: [newEmptyMethod('foo'), newEmptyMethod('bar')],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
supertype: a.asThisSupertype,
procedures: [newEmptyMethod('foo', isAbstract: true)]));
procedures: [newEmptyMethod('foo', isAbstract: true)],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -466,15 +509,18 @@ class B extends self::A {
var a = addClass(new Class(
name: 'A',
supertype: objectSuper,
procedures: [newEmptyMethod('foo'), newEmptyMethod('bar')]));
procedures: [newEmptyMethod('foo'), newEmptyMethod('bar')],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
supertype: a.asThisSupertype,
procedures: [newEmptyMethod('foo')]));
procedures: [newEmptyMethod('foo')],
fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C',
supertype: b.asThisSupertype,
procedures: [newEmptyMethod('bar')]));
procedures: [newEmptyMethod('bar')],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -499,15 +545,18 @@ class C extends self::B {
var a = addClass(new Class(
name: 'A',
supertype: objectSuper,
procedures: [newEmptySetter('foo'), newEmptySetter('bar')]));
procedures: [newEmptySetter('foo'), newEmptySetter('bar')],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
supertype: a.asThisSupertype,
procedures: [newEmptySetter('foo')]));
procedures: [newEmptySetter('foo')],
fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C',
supertype: b.asThisSupertype,
procedures: [newEmptySetter('bar')]));
procedures: [newEmptySetter('bar')],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -537,9 +586,13 @@ class C extends self::B {
var b = addClass(new Class(
name: 'B',
typeParameters: [bT],
supertype: new Supertype(a, [bTT, bool])));
supertype: new Supertype(a, [bTT, bool]),
fileUri: library.fileUri));
var c = addClass(new Class(name: 'C', supertype: new Supertype(b, [int])));
var c = addClass(new Class(
name: 'C',
supertype: new Supertype(b, [int]),
fileUri: library.fileUri));
_assertTestLibraryText('''
class A<T*, U*> {}
@@ -568,12 +621,16 @@ class C extends self::B<core::int*> {}
supertype: objectSuper,
implementedTypes: [
new Supertype(a, [bTT, bool])
]));
],
fileUri: library.fileUri));
var c = addClass(
new Class(name: 'C', supertype: objectSuper, implementedTypes: [
new Supertype(b, [int])
]));
var c = addClass(new Class(
name: 'C',
supertype: objectSuper,
implementedTypes: [
new Supertype(b, [int])
],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A<T*, U*> {}
@@ -600,12 +657,14 @@ class C implements self::B<core::int*> {}
name: 'B',
typeParameters: [bT],
supertype: objectSuper,
mixedInType: new Supertype(a, [bTT, bool])));
mixedInType: new Supertype(a, [bTT, bool]),
fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C',
supertype: objectSuper,
mixedInType: new Supertype(b, [int])));
mixedInType: new Supertype(b, [int]),
fileUri: library.fileUri));
_assertTestLibraryText('''
class A<T*, U*> {}
@@ -621,10 +680,14 @@ class C = core::Object with self::B<core::int*> {}
}
void test_getClassAsInstanceOf_notGeneric_extends() {
var a = addClass(new Class(name: 'A', supertype: objectSuper));
var b = addClass(new Class(name: 'B', supertype: a.asThisSupertype));
var c = addClass(new Class(name: 'C', supertype: b.asThisSupertype));
var z = addClass(new Class(name: 'Z', supertype: objectSuper));
var a = addClass(
new Class(name: 'A', supertype: objectSuper, fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B', supertype: a.asThisSupertype, fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C', supertype: b.asThisSupertype, fileUri: library.fileUri));
var z = addClass(
new Class(name: 'Z', supertype: objectSuper, fileUri: library.fileUri));
_assertTestLibraryText('''
class A {}
@@ -643,21 +706,27 @@ class Z {}
}
void test_getClassAsInstanceOf_notGeneric_implements() {
var a = addClass(new Class(name: 'A', supertype: objectSuper));
var b = addClass(new Class(name: 'B', supertype: objectSuper));
var a = addClass(
new Class(name: 'A', supertype: objectSuper, fileUri: library.fileUri));
var b = addClass(
new Class(name: 'B', supertype: objectSuper, fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C',
supertype: objectSuper,
implementedTypes: [a.asThisSupertype]));
implementedTypes: [a.asThisSupertype],
fileUri: library.fileUri));
var d = addClass(new Class(
name: 'D',
supertype: objectSuper,
implementedTypes: [c.asThisSupertype]));
implementedTypes: [c.asThisSupertype],
fileUri: library.fileUri));
var e = addClass(new Class(
name: 'D',
supertype: a.asThisSupertype,
implementedTypes: [b.asThisSupertype]));
var z = addClass(new Class(name: 'Z', supertype: objectSuper));
implementedTypes: [b.asThisSupertype],
fileUri: library.fileUri));
var z = addClass(
new Class(name: 'Z', supertype: objectSuper, fileUri: library.fileUri));
_assertTestLibraryText('''
class A {}
@@ -677,10 +746,15 @@ class Z {}
}
void test_getClassAsInstanceOf_notGeneric_with() {
var a = addClass(new Class(name: 'A', supertype: objectSuper));
var a = addClass(
new Class(name: 'A', supertype: objectSuper, fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B', supertype: objectSuper, mixedInType: a.asThisSupertype));
var z = addClass(new Class(name: 'Z', supertype: objectSuper));
name: 'B',
supertype: objectSuper,
mixedInType: a.asThisSupertype,
fileUri: library.fileUri));
var z = addClass(
new Class(name: 'Z', supertype: objectSuper, fileUri: library.fileUri));
_assertTestLibraryText('''
class A {}
@@ -700,16 +774,15 @@ class Z {}
var abstractMethod = newEmptyMethod('abstractMethod', isAbstract: true);
var abstractGetter = newEmptyGetter('abstractGetter', isAbstract: true);
var abstractSetter = newEmptySetter('abstractSetter', isAbstract: true);
var nonFinalField = new Field.mutable(new Name('nonFinalField'));
var finalField = new Field.immutable(new Name('finalField'), isFinal: true);
var nonFinalField =
new Field.mutable(new Name('nonFinalField'), fileUri: library.fileUri);
var finalField = new Field.immutable(new Name('finalField'),
isFinal: true, fileUri: library.fileUri);
var a = addClass(new Class(
isAbstract: true,
name: 'A',
supertype: objectSuper,
fields: [
nonFinalField,
finalField
],
fields: [nonFinalField, finalField],
procedures: [
method,
getter,
@@ -717,9 +790,13 @@ class Z {}
abstractMethod,
abstractGetter,
abstractSetter
]));
var b = addClass(
new Class(isAbstract: true, name: 'B', supertype: a.asThisSupertype));
],
fileUri: library.fileUri));
var b = addClass(new Class(
isAbstract: true,
name: 'B',
supertype: a.asThisSupertype,
fileUri: library.fileUri));
_assertTestLibraryText('''
abstract class A {
@@ -759,12 +836,17 @@ abstract class B extends self::A {}
var bMethod = newEmptyMethod('bMethod');
var bSetter = newEmptySetter('bSetter');
var a = addClass(new Class(
name: 'A', supertype: objectSuper, procedures: [aMethod, aSetter]));
name: 'A',
supertype: objectSuper,
procedures: [aMethod, aSetter],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
supertype: a.asThisSupertype,
procedures: [bMethod, bSetter]));
var c = addClass(new Class(name: 'C', supertype: b.asThisSupertype));
procedures: [bMethod, bSetter],
fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C', supertype: b.asThisSupertype, fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -805,13 +887,16 @@ class C extends self::B {}
isAbstract: true,
name: 'A',
supertype: objectSuper,
procedures: [aFoo, aBar]));
procedures: [aFoo, aBar],
fileUri: library.fileUri));
var b = addClass(new Class(
isAbstract: true,
name: 'B',
supertype: a.asThisSupertype,
procedures: [bFoo, bBar]));
var c = addClass(new Class(name: 'C', supertype: b.asThisSupertype));
procedures: [bFoo, bBar],
fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C', supertype: b.asThisSupertype, fileUri: library.fileUri));
_assertTestLibraryText('''
abstract class A {
@@ -840,12 +925,17 @@ class C extends self::B {}
var bMethod = newEmptyMethod('bMethod');
var bSetter = newEmptySetter('bSetter');
var a = addClass(new Class(
name: 'A', supertype: objectSuper, procedures: [aMethod, aSetter]));
name: 'A',
supertype: objectSuper,
procedures: [aMethod, aSetter],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
supertype: a.asThisSupertype,
procedures: [bMethod, bSetter]));
var c = addClass(new Class(name: 'C', supertype: b.asThisSupertype));
procedures: [bMethod, bSetter],
fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C', supertype: b.asThisSupertype, fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -883,16 +973,21 @@ class C extends self::B {}
var bMethod = newEmptyMethod('bMethod');
var bSetter = newEmptySetter('bSetter');
var a = addClass(new Class(
name: 'A', supertype: objectSuper, procedures: [aMethod, aSetter]));
name: 'A',
supertype: objectSuper,
procedures: [aMethod, aSetter],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
supertype: objectSuper,
implementedTypes: [a.asThisSupertype],
procedures: [bMethod, bSetter]));
procedures: [bMethod, bSetter],
fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C',
supertype: objectSuper,
implementedTypes: [b.asThisSupertype]));
implementedTypes: [b.asThisSupertype],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -931,16 +1026,15 @@ class C implements self::B {}
var abstractMethod = newEmptyMethod('abstractMethod', isAbstract: true);
var abstractGetter = newEmptyGetter('abstractGetter', isAbstract: true);
var abstractSetter = newEmptySetter('abstractSetter', isAbstract: true);
var nonFinalField = new Field.mutable(new Name('nonFinalField'));
var finalField = new Field.immutable(new Name('finalField'), isFinal: true);
var nonFinalField =
new Field.mutable(new Name('nonFinalField'), fileUri: library.fileUri);
var finalField = new Field.immutable(new Name('finalField'),
isFinal: true, fileUri: library.fileUri);
var a = addClass(new Class(
isAbstract: true,
name: 'A',
supertype: objectSuper,
fields: [
nonFinalField,
finalField
],
fields: [nonFinalField, finalField],
procedures: [
method,
getter,
@@ -948,7 +1042,8 @@ class C implements self::B {}
abstractMethod,
abstractGetter,
abstractSetter
]));
],
fileUri: library.fileUri));
_assertTestLibraryText('''
abstract class A {
@@ -986,28 +1081,37 @@ abstract class A {
var abstractMethod = newEmptyMethod('abstractMethod', isAbstract: true);
var abstractGetter = newEmptyGetter('abstractGetter', isAbstract: true);
var abstractSetter = newEmptySetter('abstractSetter', isAbstract: true);
var nonFinalField = new Field.mutable(new Name('nonFinalField'));
var finalField = new Field.immutable(new Name('finalField'), isFinal: true);
var nonFinalField =
new Field.mutable(new Name('nonFinalField'), fileUri: library.fileUri);
var finalField = new Field.immutable(new Name('finalField'),
isFinal: true, fileUri: library.fileUri);
var a = addClass(new Class(name: 'A', supertype: objectSuper, fields: [
nonFinalField,
finalField
], procedures: [
method,
getter,
setter,
abstractMethod,
abstractGetter,
abstractSetter
]));
var b = addClass(new Class(name: 'B', supertype: a.asThisSupertype));
var a = addClass(new Class(
name: 'A',
supertype: objectSuper,
fields: [nonFinalField, finalField],
procedures: [
method,
getter,
setter,
abstractMethod,
abstractGetter,
abstractSetter
],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B', supertype: a.asThisSupertype, fileUri: library.fileUri));
var c = addClass(new Class(
isAbstract: true,
name: 'C',
supertype: objectSuper,
implementedTypes: [a.asThisSupertype]));
implementedTypes: [a.asThisSupertype],
fileUri: library.fileUri));
var d = addClass(new Class(
name: 'D', supertype: objectSuper, mixedInType: a.asThisSupertype));
name: 'D',
supertype: objectSuper,
mixedInType: a.asThisSupertype,
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -1051,31 +1155,36 @@ class D = core::Object with self::A {}
var method_a = newEmptyMethod('method');
var getter_a = newEmptyGetter('getter');
var setter_a = newEmptySetter('setter');
var nonFinalField_a = new Field.mutable(new Name('nonFinalField'));
var finalField_a =
new Field.immutable(new Name('finalField'), isFinal: true);
var nonFinalField_a =
new Field.mutable(new Name('nonFinalField'), fileUri: library.fileUri);
var finalField_a = new Field.immutable(new Name('finalField'),
isFinal: true, fileUri: library.fileUri);
var method_b = newEmptyMethod('method');
var getter_b = newEmptyGetter('getter');
var setter_b = newEmptySetter('setter');
var nonFinalField_b = new Field.mutable(new Name('nonFinalField'));
var finalField_b =
new Field.immutable(new Name('finalField'), isFinal: true);
var nonFinalField_b =
new Field.mutable(new Name('nonFinalField'), fileUri: library.fileUri);
var finalField_b = new Field.immutable(new Name('finalField'),
isFinal: true, fileUri: library.fileUri);
var a = addClass(new Class(
name: 'A',
supertype: objectSuper,
fields: [nonFinalField_a, finalField_a],
procedures: [method_a, getter_a, setter_a]));
procedures: [method_a, getter_a, setter_a],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
supertype: objectSuper,
fields: [nonFinalField_b, finalField_b],
procedures: [method_b, getter_b, setter_b]));
procedures: [method_b, getter_b, setter_b],
fileUri: library.fileUri));
var c = addClass(new Class(
isAbstract: true,
name: 'C',
supertype: objectSuper,
implementedTypes: [a.asThisSupertype, b.asThisSupertype]));
implementedTypes: [a.asThisSupertype, b.asThisSupertype],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -1123,31 +1232,36 @@ abstract class C implements self::A, self::B {}
var getter_a = newEmptyGetter('getter');
var setter_a = newEmptySetter('setter');
var nonShadowedSetter_a = newEmptySetter('nonShadowedSetter');
var nonFinalField_a = new Field.mutable(new Name('nonFinalField'));
var finalField_a =
new Field.immutable(new Name('finalField'), isFinal: true);
var nonFinalField_a =
new Field.mutable(new Name('nonFinalField'), fileUri: library.fileUri);
var finalField_a = new Field.immutable(new Name('finalField'),
isFinal: true, fileUri: library.fileUri);
var method_b = newEmptyMethod('method');
var getter_b = newEmptyGetter('getter');
var setter_b = newEmptySetter('setter');
var nonFinalField_b = new Field.mutable(new Name('nonFinalField'));
var finalField_b =
new Field.immutable(new Name('finalField'), isFinal: true);
var nonFinalField_b =
new Field.mutable(new Name('nonFinalField'), fileUri: library.fileUri);
var finalField_b = new Field.immutable(new Name('finalField'),
isFinal: true, fileUri: library.fileUri);
var a = addClass(new Class(name: 'A', supertype: objectSuper, fields: [
nonFinalField_a,
finalField_a
], procedures: [
method_a,
nonShadowedMethod_a,
getter_a,
setter_a,
nonShadowedSetter_a
]));
var a = addClass(new Class(
name: 'A',
supertype: objectSuper,
fields: [nonFinalField_a, finalField_a],
procedures: [
method_a,
nonShadowedMethod_a,
getter_a,
setter_a,
nonShadowedSetter_a
],
fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B',
supertype: a.asThisSupertype,
fields: [nonFinalField_b, finalField_b],
procedures: [method_b, getter_b, setter_b]));
procedures: [method_b, getter_b, setter_b],
fileUri: library.fileUri));
_assertTestLibraryText('''
class A {
@@ -1186,9 +1300,12 @@ class B extends self::A {
}
void test_getOrderedClasses() {
var a = addClass(new Class(name: 'A', supertype: objectSuper));
var b = addClass(new Class(name: 'B', supertype: a.asThisSupertype));
var c = addClass(new Class(name: 'C', supertype: b.asThisSupertype));
var a = addClass(
new Class(name: 'A', supertype: objectSuper, fileUri: library.fileUri));
var b = addClass(new Class(
name: 'B', supertype: a.asThisSupertype, fileUri: library.fileUri));
var c = addClass(new Class(
name: 'C', supertype: b.asThisSupertype, fileUri: library.fileUri));
void assertOrderOfClasses(List<Class> unordered, List<Class> expected) {
var ordered = hierarchy.getOrderedClasses(unordered);
@@ -1215,7 +1332,8 @@ class B extends self::A {
var b = addClass(new Class(
name: 'B',
typeParameters: [bT],
supertype: new Supertype(a, [bTT, bool])));
supertype: new Supertype(a, [bTT, bool]),
fileUri: library.fileUri));
_assertTestLibraryText('''
class A<T*, U*> {}
@@ -9,8 +9,9 @@ import 'package:kernel/binary/ast_to_binary.dart';
import 'binary/utils.dart';
main() {
final Library lib1 = new Library(Uri.parse('org-dartlang:///lib.dart'));
final Field field = new Field.mutable(new Name("f"));
final Uri lib1Uri = Uri.parse('org-dartlang:///lib.dart');
final Library lib1 = new Library(lib1Uri, fileUri: lib1Uri);
final Field field = new Field.mutable(new Name("f"), fileUri: lib1Uri);
lib1.addField(field);
final Block libProcedureBody = new Block([
new ExpressionStatement(new StaticSet(field, new IntLiteral(42))),
@@ -19,10 +20,12 @@ main() {
final Procedure libProcedure = new Procedure(
new Name("method"),
ProcedureKind.Method,
new FunctionNode(libProcedureBody, returnType: new DynamicType()));
new FunctionNode(libProcedureBody, returnType: new DynamicType()),
fileUri: lib1Uri);
lib1.addProcedure(libProcedure);
final Library lib2 = new Library(Uri.parse('org-dartlang:///lib2.dart'));
final Uri lib2Uri = Uri.parse('org-dartlang:///lib2.dart');
final Library lib2 = new Library(lib2Uri, fileUri: lib2Uri);
final Block lib2ProcedureBody = new Block([
new ExpressionStatement(new StaticSet(field, new IntLiteral(43))),
new ReturnStatement(new StaticGet(field)),
@@ -30,7 +33,8 @@ main() {
final Procedure lib2Procedure = new Procedure(
new Name("method"),
ProcedureKind.Method,
new FunctionNode(lib2ProcedureBody, returnType: new DynamicType()));
new FunctionNode(lib2ProcedureBody, returnType: new DynamicType()),
fileUri: lib2Uri);
lib2.addProcedure(lib2Procedure);
verifyTargets(libProcedure, lib2Procedure, field, field);
@@ -53,7 +57,7 @@ main() {
FunctionNode getterFunction = new FunctionNode(new Block([]));
Procedure getter = new Procedure(
new Name("f"), ProcedureKind.Getter, getterFunction,
reference: field.getterReference);
reference: field.getterReference, fileUri: lib1Uri);
// Important: Unbind any old canonical name
// (nulling out the canonical name is not enough because it leaves the old
// canonical name (which always stays alive) with a pointer to the reference,
@@ -68,7 +72,7 @@ main() {
positionalParameters: [new VariableDeclaration("foo")]);
Procedure setter = new Procedure(
new Name("f"), ProcedureKind.Setter, setterFunction,
reference: field.setterReference);
reference: field.setterReference, fileUri: lib1Uri);
// Important: Unbind any old canonical name
// (nulling out the canonical name is not enough, see above).
field.setterReference?.canonicalName?.unbind();
@@ -101,7 +105,9 @@ main() {
lib1.procedures.remove(getter);
lib1.procedures.remove(setter);
final Field fieldReplacement = new Field.mutable(new Name("f"),
getterReference: getter.reference, setterReference: setter.reference);
getterReference: getter.reference,
setterReference: setter.reference,
fileUri: lib1Uri);
// Important: Unbind any old canonical name
// (nulling out the canonical name is not enough, see above).
fieldReplacement.getterReference?.canonicalName?.unbind();
@@ -16,14 +16,14 @@ Uri uri1 = Uri.parse("foo://lib1.dart");
Uri uri2 = Uri.parse("foo://lib2.dart");
main() {
Library library1 = new Library(uri1)..fileUri = uri1;
Library library2 = new Library(uri2)..fileUri = uri2;
Library library1 = new Library(uri1, fileUri: uri1);
Library library2 = new Library(uri2, fileUri: uri2);
Procedure p1 = new Procedure(new Name("p1"), ProcedureKind.Method,
new FunctionNode(new ReturnStatement()))
..fileUri = uri2;
new FunctionNode(new ReturnStatement()),
fileUri: uri2);
Procedure p2 = new Procedure(new Name("p2"), ProcedureKind.Method,
new FunctionNode(new ReturnStatement()))
..fileUri = uri1;
new FunctionNode(new ReturnStatement()),
fileUri: uri1);
library1.addProcedure(p1);
library2.addProcedure(p2);
+8 -4
View File
@@ -149,16 +149,19 @@ Procedure getMainTarget(Component component1Prime) {
}
Component createComponent(int literal) {
final Library lib = new Library(Uri.parse('org-dartlang:///lib.dart'));
final Uri libUri = Uri.parse('org-dartlang:///lib.dart');
final Library lib = new Library(libUri, fileUri: libUri);
final Block libProcedureBody =
new Block([new ReturnStatement(new IntLiteral(literal))]);
final Procedure libProcedure = new Procedure(
new Name("method"),
ProcedureKind.Method,
new FunctionNode(libProcedureBody, returnType: new DynamicType()));
new FunctionNode(libProcedureBody, returnType: new DynamicType()),
fileUri: libUri);
lib.addProcedure(libProcedure);
final Library main = new Library(Uri.parse('org-dartlang:///main.dart'));
final Uri mainUri = Uri.parse('org-dartlang:///main.dart');
final Library main = new Library(mainUri, fileUri: mainUri);
final Block mainProcedureBody = new Block([
new ReturnStatement(
new StaticInvocation(libProcedure, new Arguments.empty()))
@@ -166,7 +169,8 @@ Component createComponent(int literal) {
final Procedure mainProcedure = new Procedure(
new Name("method"),
ProcedureKind.Method,
new FunctionNode(mainProcedureBody, returnType: new DynamicType()));
new FunctionNode(mainProcedureBody, returnType: new DynamicType()),
fileUri: mainUri);
main.addProcedure(mainProcedure);
return new Component(libraries: [main, lib])
..setMainMethodAndMode(null, false, NonNullableByDefaultCompiledMode.Weak);
@@ -122,11 +122,10 @@ void test() {
serializer: statementSerializer);
}(),
() {
Field field =
new Field.immutable(new Name('field'), type: const DynamicType());
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
fields: <Field>[field]);
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Field field = new Field.immutable(new Name('field'),
type: const DynamicType(), fileUri: uri);
Library library = new Library(uri, fileUri: uri, fields: <Field>[field]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
return new TestCase<Statement>(
@@ -140,11 +139,10 @@ void test() {
serializer: statementSerializer);
}(),
() {
Field field =
new Field.mutable(new Name('field'), type: const DynamicType());
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
fields: <Field>[field]);
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Field field = new Field.mutable(new Name('field'),
type: const DynamicType(), fileUri: uri);
Library library = new Library(uri, fileUri: uri, fields: <Field>[field]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
return new TestCase<Statement>(
@@ -158,11 +156,10 @@ void test() {
serializer: statementSerializer);
}(),
() {
Field field =
new Field.mutable(new Name('field'), type: const DynamicType());
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
fields: <Field>[field]);
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Field field = new Field.mutable(new Name('field'),
type: const DynamicType(), fileUri: uri);
Library library = new Library(uri, fileUri: uri, fields: <Field>[field]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
return new TestCase<Statement>(
@@ -178,16 +175,17 @@ void test() {
serializer: statementSerializer);
}(),
() {
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Procedure topLevelProcedure = new Procedure(
new Name('foo'),
ProcedureKind.Method,
new FunctionNode(null, positionalParameters: <VariableDeclaration>[
new VariableDeclaration('x', type: const DynamicType())
]),
isStatic: true);
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
procedures: <Procedure>[topLevelProcedure]);
isStatic: true,
fileUri: uri);
Library library = new Library(uri,
fileUri: uri, procedures: <Procedure>[topLevelProcedure]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
return new TestCase<Statement>(
@@ -205,14 +203,13 @@ void test() {
serializer: statementSerializer);
}(),
() {
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Procedure factoryConstructor = new Procedure(
new Name('foo'), ProcedureKind.Factory, new FunctionNode(null),
isStatic: true, isConst: true);
Class klass =
new Class(name: 'A', procedures: <Procedure>[factoryConstructor]);
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
classes: <Class>[klass]);
isStatic: true, isConst: true, fileUri: uri);
Class klass = new Class(
name: 'A', procedures: <Procedure>[factoryConstructor], fileUri: uri);
Library library = new Library(uri, fileUri: uri, classes: <Class>[klass]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
return new TestCase<Statement>(
@@ -231,12 +228,11 @@ void test() {
serializer: statementSerializer);
}(),
() {
Field field =
new Field.immutable(new Name('field'), type: const DynamicType());
Class klass = new Class(name: 'A', fields: <Field>[field]);
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
classes: <Class>[klass]);
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Field field = new Field.immutable(new Name('field'),
type: const DynamicType(), fileUri: uri);
Class klass = new Class(name: 'A', fields: <Field>[field], fileUri: uri);
Library library = new Library(uri, fileUri: uri, classes: <Class>[klass]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
@@ -260,12 +256,11 @@ void test() {
serializer: statementSerializer);
}(),
() {
Field field =
new Field.mutable(new Name('field'), type: const DynamicType());
Class klass = new Class(name: 'A', fields: <Field>[field]);
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
classes: <Class>[klass]);
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Field field = new Field.mutable(new Name('field'),
type: const DynamicType(), fileUri: uri);
Class klass = new Class(name: 'A', fields: <Field>[field], fileUri: uri);
Library library = new Library(uri, fileUri: uri, classes: <Class>[klass]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
@@ -289,12 +284,11 @@ void test() {
serializer: statementSerializer);
}(),
() {
Field field =
new Field.mutable(new Name('field'), type: const DynamicType());
Class klass = new Class(name: 'A', fields: <Field>[field]);
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
classes: <Class>[klass]);
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Field field = new Field.mutable(new Name('field'),
type: const DynamicType(), fileUri: uri);
Class klass = new Class(name: 'A', fields: <Field>[field], fileUri: uri);
Library library = new Library(uri, fileUri: uri, classes: <Class>[klass]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
@@ -321,13 +315,13 @@ void test() {
serializer: statementSerializer);
}(),
() {
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Procedure method = new Procedure(
new Name('foo'), ProcedureKind.Method, new FunctionNode(null),
isStatic: true, isConst: true);
Class klass = new Class(name: 'A', procedures: <Procedure>[method]);
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
classes: <Class>[klass]);
isStatic: true, isConst: true, fileUri: uri);
Class klass =
new Class(name: 'A', procedures: <Procedure>[method], fileUri: uri);
Library library = new Library(uri, fileUri: uri, classes: <Class>[klass]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
@@ -355,13 +349,12 @@ void test() {
serializer: statementSerializer);
}(),
() {
Constructor constructor =
new Constructor(new FunctionNode(null), name: new Name('foo'));
Class klass =
new Class(name: 'A', constructors: <Constructor>[constructor]);
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
classes: <Class>[klass]);
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Constructor constructor = new Constructor(new FunctionNode(null),
name: new Name('foo'), fileUri: uri);
Class klass = new Class(
name: 'A', constructors: <Constructor>[constructor], fileUri: uri);
Library library = new Library(uri, fileUri: uri, classes: <Class>[klass]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
return new TestCase<Statement>(
@@ -378,13 +371,12 @@ void test() {
serializer: statementSerializer);
}(),
() {
Uri uri = new Uri(scheme: 'package', path: 'foo/bar.dart');
Constructor constructor = new Constructor(new FunctionNode(null),
name: new Name('foo'), isConst: true);
Class klass =
new Class(name: 'A', constructors: <Constructor>[constructor]);
Library library = new Library(
new Uri(scheme: 'package', path: 'foo/bar.dart'),
classes: <Class>[klass]);
name: new Name('foo'), isConst: true, fileUri: uri);
Class klass = new Class(
name: 'A', constructors: <Constructor>[constructor], fileUri: uri);
Library library = new Library(uri, fileUri: uri, classes: <Class>[klass]);
Component component = new Component(libraries: <Library>[library]);
component.computeCanonicalNames();
return new TestCase<Statement>(
@@ -456,15 +448,16 @@ void test() {
serializer: statementSerializer);
}(),
() {
Uri uri = Uri(scheme: 'package', path: 'foo/bar.dart');
VariableDeclaration x = VariableDeclaration('x', type: DynamicType());
Procedure foo = Procedure(
Name('foo'),
ProcedureKind.Method,
FunctionNode(ReturnStatement(VariableGet(x)),
positionalParameters: [x]),
isStatic: true);
Library library = Library(Uri(scheme: 'package', path: 'foo/bar.dart'),
procedures: [foo]);
isStatic: true,
fileUri: uri);
Library library = Library(uri, fileUri: uri, procedures: [foo]);
Component component = Component(libraries: [library]);
component.computeCanonicalNames();
return new TestCase<Member>(
@@ -473,7 +466,8 @@ void test() {
expectation: ''
'(method (public "foo") ((static))'
' (sync) () () () ("x^0" () (dynamic) _ ()) () ()'
' (dynamic) _ (ret (get-var "x^0" _)))',
' (dynamic) _ (ret (get-var "x^0" _))'
' "package:foo/bar.dart")',
makeSerializationState: () =>
new SerializationState(new SerializationEnvironment(null)),
makeDeserializationState: () => new DeserializationState(
@@ -481,6 +475,7 @@ void test() {
serializer: memberSerializer);
}(),
() {
Uri uri = Uri(scheme: 'package', path: 'foo/bar.dart');
VariableDeclaration x1 = VariableDeclaration('x', type: DynamicType());
VariableDeclaration x2 = VariableDeclaration('x', type: DynamicType());
Procedure foo = Procedure(
@@ -488,7 +483,8 @@ void test() {
ProcedureKind.Method,
FunctionNode(ReturnStatement(VariableGet(x1)),
positionalParameters: [x1]),
isStatic: true);
isStatic: true,
fileUri: uri);
Procedure bar = Procedure(
Name('bar'),
ProcedureKind.Method,
@@ -496,9 +492,9 @@ void test() {
ReturnStatement(
StaticInvocation(foo, Arguments([VariableGet(x2)]))),
positionalParameters: [x2]),
isStatic: true);
Library library = Library(Uri(scheme: 'package', path: 'foo/bar.dart'),
procedures: [foo, bar]);
isStatic: true,
fileUri: uri);
Library library = Library(uri, fileUri: uri, procedures: [foo, bar]);
Component component = Component(libraries: [library]);
component.computeCanonicalNames();
return new TestCase<Library>(
@@ -509,19 +505,23 @@ void test() {
''
' ((method (public "foo") ((static))'
' (sync) () () () ("x^0" () (dynamic) _ ()) () () (dynamic)'
' _ (ret (get-var "x^0" _)))'
' _ (ret (get-var "x^0" _))'
' "package:foo/bar.dart")'
''
' (method (public "bar") ((static))'
' (sync) () () () ("x^0" () (dynamic) _ ()) () () (dynamic)'
' _ (ret'
' (invoke-static "package:foo/bar.dart::@methods::foo"'
' () ((get-var "x^0" _)) ()))))'
' () ((get-var "x^0" _)) ()))'
' "package:foo/bar.dart"))'
''
' ()'
''
' ()'
''
' ()',
' ()'
''
' "package:foo/bar.dart"',
makeSerializationState: () =>
new SerializationState(new SerializationEnvironment(null)),
makeDeserializationState: () => new DeserializationState(
@@ -529,15 +529,17 @@ void test() {
serializer: librarySerializer);
}(),
() {
Class a = Class(name: "A");
Uri uri = Uri(scheme: "package", path: "foo/bar.dart");
Class a = Class(name: "A", fileUri: uri);
Procedure foo = Procedure(
Name("foo"),
ProcedureKind.Method,
FunctionNode(ReturnStatement(NullLiteral()),
returnType: InterfaceType(a, Nullability.legacy)),
isStatic: true);
Library library = Library(Uri(scheme: "package", path: "foo/bar.dart"),
classes: [a], procedures: [foo]);
isStatic: true,
fileUri: uri);
Library library =
Library(uri, fileUri: uri, classes: [a], procedures: [foo]);
Component component = Component(libraries: [library]);
component.computeCanonicalNames();
return new TestCase<Library>(
@@ -548,13 +550,16 @@ void test() {
''
' ((method (public "foo") ((static))'
' (sync) () () () () () () (interface "package:foo/bar.dart::A" ())'
' _ (ret (null))))'
' _ (ret (null))'
' "package:foo/bar.dart"))'
''
' ("A" () () () () _ _ () ())'
' ("A" () "package:foo/bar.dart" () () () _ _ () ())'
''
' ()'
''
' ()',
' ()'
''
' "package:foo/bar.dart"',
makeSerializationState: () =>
new SerializationState(new SerializationEnvironment(null)),
makeDeserializationState: () => new DeserializationState(
@@ -579,8 +584,8 @@ void test() {
if (roundTripInput != testCase.expectation) {
failures.add(''
"* initial serialization for test '${testCase.name}'"
" gave output '${roundTripInput}'"
" but expected '${testCase.expectation}'");
" gave output:\n ${roundTripInput}\n"
" but expected:\n ${testCase.expectation}");
}
TreeNode deserialized =
+3 -2
View File
@@ -326,7 +326,8 @@ class LazyTypeEnvironment {
final Component component = new Component();
LazyTypeEnvironment() {
dummyLibrary = new Library(Uri.parse('file://dummy.dart'))
Uri uri = Uri.parse('file://dummy.dart');
dummyLibrary = new Library(uri, fileUri: uri)
..isNonNullableByDefault = true;
component.libraries.add(dummyLibrary..parent = component);
dummyLibrary.name = 'lib';
@@ -346,7 +347,7 @@ class LazyTypeEnvironment {
}
Class makeClass(String name) {
var class_ = new Class(name: name);
var class_ = new Class(name: name, fileUri: dummyLibrary.fileUri);
dummyLibrary.addClass(class_);
return class_;
}
+9 -5
View File
@@ -18,7 +18,7 @@ void harnessTest(String name, void doTest(TestHarness harness)) {
main() {
harnessTest('`Foo` where typedef Foo = C', (TestHarness harness) {
var foo = new Typedef('Foo', harness.otherLegacyRawType);
var foo = new Typedef('Foo', harness.otherLegacyRawType, fileUri: dummyUri);
harness.enclosingLibrary.addTypedef(foo);
var type = new TypedefType(foo, Nullability.legacy);
expect(type.unalias, equals(harness.otherLegacyRawType));
@@ -29,7 +29,8 @@ main() {
'Foo',
new InterfaceType(harness.otherClass, Nullability.legacy,
[new TypeParameterType(param, Nullability.legacy)]),
typeParameters: [param]);
typeParameters: [param],
fileUri: dummyUri);
harness.enclosingLibrary.addTypedef(foo);
var input =
new TypedefType(foo, Nullability.legacy, [harness.objectLegacyRawType]);
@@ -44,13 +45,15 @@ main() {
'Foo',
new InterfaceType(harness.otherClass, Nullability.legacy,
[new TypeParameterType(fooParam, Nullability.legacy)]),
typeParameters: [fooParam]);
typeParameters: [fooParam],
fileUri: dummyUri);
var barParam = harness.makeTypeParameter('T');
var bar = new Typedef(
'Bar',
new TypedefType(foo, Nullability.legacy,
[new TypeParameterType(barParam, Nullability.legacy)]),
typeParameters: [barParam]);
typeParameters: [barParam],
fileUri: dummyUri);
harness.enclosingLibrary.addTypedef(foo);
harness.enclosingLibrary.addTypedef(bar);
var input =
@@ -66,7 +69,8 @@ main() {
'Foo',
new InterfaceType(harness.otherClass, Nullability.legacy,
[new TypeParameterType(param, Nullability.legacy)]),
typeParameters: [param]);
typeParameters: [param],
fileUri: dummyUri);
harness.enclosingLibrary.addTypedef(foo);
var input = new TypedefType(foo, Nullability.legacy, [
new TypedefType(foo, Nullability.legacy, [harness.objectLegacyRawType])
+96 -64
View File
@@ -77,12 +77,13 @@ main() {
negative1Test(
'Member redeclared',
(TestHarness test) {
Field field =
new Field.mutable(new Name('field'), initializer: new NullLiteral());
Field field = new Field.mutable(new Name('field'),
initializer: new NullLiteral(), fileUri: dummyUri);
test.addNode(Class(
name: 'Test',
supertype: test.objectClass.asRawSupertype,
fields: [field, field]));
fields: [field, field],
fileUri: dummyUri));
return field;
},
(Node node) => "Member '$node' has been declared more than once.",
@@ -104,7 +105,8 @@ main() {
test.addNode(Class(
name: 'Test',
supertype: test.objectClass.asRawSupertype,
typeParameters: [parameter, parameter]));
typeParameters: [parameter, parameter],
fileUri: dummyUri));
return parameter;
},
(Node node) => "Type parameter '$node' redeclared.",
@@ -117,7 +119,8 @@ main() {
new Name('bar'),
ProcedureKind.Method,
new FunctionNode(new ReturnStatement(new NullLiteral()),
typeParameters: [parameter, parameter])));
typeParameters: [parameter, parameter]),
fileUri: dummyUri));
return parameter;
},
@@ -156,7 +159,8 @@ main() {
ProcedureKind.Method,
new FunctionNode(new ReturnStatement(new TypeLiteral(
new TypeParameterType(node, Nullability.legacy)))),
isStatic: true));
isStatic: true,
fileUri: dummyUri));
return [node, test.enclosingClass];
},
@@ -171,7 +175,8 @@ main() {
test.addNode(Field.mutable(new Name('field'),
initializer:
new TypeLiteral(new TypeParameterType(node, Nullability.legacy)),
isStatic: true));
isStatic: true,
fileUri: dummyUri));
return [node, test.enclosingClass];
},
(Node node, Node parent) =>
@@ -188,13 +193,16 @@ main() {
name: 'Test',
supertype: test.objectClass.asRawSupertype,
procedures: [
new Procedure(new Name('generic'), ProcedureKind.Method, parent),
new Procedure(new Name('generic'), ProcedureKind.Method, parent,
fileUri: dummyUri),
new Procedure(
new Name('use'),
ProcedureKind.Method,
new FunctionNode(new ReturnStatement(new TypeLiteral(
new TypeParameterType(parameter, Nullability.legacy)))))
]));
new TypeParameterType(parameter, Nullability.legacy)))),
fileUri: dummyUri)
],
fileUri: dummyUri));
return [parameter, parent];
},
@@ -227,7 +235,7 @@ main() {
negative1Test(
'Dangling interface type',
(TestHarness test) {
Class orphan = new Class(name: 'Class');
Class orphan = new Class(name: 'Class', fileUri: dummyUri);
test.addNode(
new TypeLiteral(new InterfaceType(orphan, Nullability.legacy)));
return orphan;
@@ -237,7 +245,7 @@ main() {
negative1Test(
'Dangling field get',
(TestHarness test) {
Field orphan = new Field.mutable(new Name('foo'));
Field orphan = new Field.mutable(new Name('foo'), fileUri: dummyUri);
test.addNode(new PropertyGet(new NullLiteral(), orphan.name, orphan));
return orphan;
},
@@ -259,7 +267,8 @@ main() {
" expected 'Procedure', but found: 'Null'.",
(TestHarness test) {
var procedure = new Procedure(
new Name('bar'), ProcedureKind.Method, dummyFunctionNode);
new Name('bar'), ProcedureKind.Method, dummyFunctionNode,
fileUri: dummyUri);
procedure.function = new FunctionNode(new EmptyStatement());
test.addNode(procedure);
},
@@ -272,7 +281,8 @@ main() {
ProcedureKind.Method,
new FunctionNode(new EmptyStatement(),
positionalParameters: [new VariableDeclaration('p')]),
isStatic: true);
isStatic: true,
fileUri: dummyUri);
test.enclosingClass.addProcedure(method);
test.addNode(
StaticInvocation(method, new Arguments([new NullLiteral()])));
@@ -283,7 +293,7 @@ main() {
(TestHarness test) {
var method = new Procedure(new Name('bar'), ProcedureKind.Method,
new FunctionNode(new EmptyStatement()),
isStatic: true);
isStatic: true, fileUri: dummyUri);
test.enclosingClass.addProcedure(method);
test.addNode(
StaticInvocation(method, new Arguments([new NullLiteral()])));
@@ -300,7 +310,8 @@ main() {
ProcedureKind.Method,
new FunctionNode(new EmptyStatement(),
positionalParameters: [new VariableDeclaration('p')]),
isStatic: true);
isStatic: true,
fileUri: dummyUri);
test.enclosingClass.addProcedure(method);
test.addNode(StaticInvocation(method, new Arguments.empty()));
return method;
@@ -312,7 +323,7 @@ main() {
(TestHarness test) {
var method = new Procedure(new Name('bar'), ProcedureKind.Method,
new FunctionNode(new EmptyStatement()),
isStatic: true);
isStatic: true, fileUri: dummyUri);
test.enclosingClass.addProcedure(method);
test.addNode(StaticInvocation(
method,
@@ -331,7 +342,8 @@ main() {
ProcedureKind.Method,
new FunctionNode(new EmptyStatement(),
typeParameters: [test.makeTypeParameter()]),
isStatic: true);
isStatic: true,
fileUri: dummyUri);
test.enclosingClass.addProcedure(method);
test.addNode(StaticInvocation(method, new Arguments.empty()));
return method;
@@ -343,7 +355,7 @@ main() {
'ConstructorInvocation with missing type argument',
(TestHarness test) {
var constructor = new Constructor(new FunctionNode(new EmptyStatement()),
name: new Name('foo'));
name: new Name('foo'), fileUri: dummyUri);
test.enclosingClass.addConstructor(constructor);
test.addNode(ConstructorInvocation(constructor, new Arguments.empty()));
return constructor;
@@ -358,7 +370,8 @@ main() {
var typedef_ = new Typedef(
'Foo',
new FunctionType(
[test.otherLegacyRawType], const VoidType(), Nullability.legacy));
[test.otherLegacyRawType], const VoidType(), Nullability.legacy),
fileUri: dummyUri);
test.addNode(typedef_);
},
);
@@ -368,15 +381,16 @@ main() {
var typedef_ = new Typedef(
'Foo',
new InterfaceType(
test.otherClass, Nullability.legacy, [const DynamicType()]));
test.otherClass, Nullability.legacy, [const DynamicType()]),
fileUri: dummyUri);
test.addNode(typedef_);
},
);
positiveTest(
'Valid typedefs Foo = Bar, Bar = C',
(TestHarness test) {
var foo = new Typedef('Foo', null);
var bar = new Typedef('Bar', null);
var foo = new Typedef('Foo', null, fileUri: dummyUri);
var bar = new Typedef('Bar', null, fileUri: dummyUri);
foo.type = new TypedefType(bar, Nullability.legacy);
bar.type = test.otherLegacyRawType;
test.enclosingLibrary.addTypedef(foo);
@@ -386,8 +400,8 @@ main() {
positiveTest(
'Valid typedefs Foo = C<Bar>, Bar = C',
(TestHarness test) {
var foo = new Typedef('Foo', null);
var bar = new Typedef('Bar', null);
var foo = new Typedef('Foo', null, fileUri: dummyUri);
var bar = new Typedef('Bar', null, fileUri: dummyUri);
foo.type = new InterfaceType(test.otherClass, Nullability.legacy,
[new TypedefType(bar, Nullability.legacy)]);
bar.type = test.otherLegacyRawType;
@@ -401,9 +415,12 @@ main() {
var typedef_ = new Typedef(
'Foo',
new FunctionType(
[test.otherLegacyRawType], const VoidType(), Nullability.legacy));
[test.otherLegacyRawType], const VoidType(), Nullability.legacy),
fileUri: dummyUri);
var field = new Field.mutable(new Name('field'),
type: new TypedefType(typedef_, Nullability.legacy), isStatic: true);
type: new TypedefType(typedef_, Nullability.legacy),
isStatic: true,
fileUri: dummyUri);
test.enclosingLibrary.addTypedef(typedef_);
test.enclosingLibrary.addField(field);
},
@@ -411,7 +428,7 @@ main() {
negative1Test(
'Invalid typedef Foo = Foo',
(TestHarness test) {
var typedef_ = new Typedef('Foo', null);
var typedef_ = new Typedef('Foo', null, fileUri: dummyUri);
typedef_.type = new TypedefType(typedef_, Nullability.legacy);
test.addNode(typedef_);
return typedef_;
@@ -421,7 +438,7 @@ main() {
negative1Test(
'Invalid typedef Foo = `(Foo) => void`',
(TestHarness test) {
var typedef_ = new Typedef('Foo', null);
var typedef_ = new Typedef('Foo', null, fileUri: dummyUri);
typedef_.type = new FunctionType(
[new TypedefType(typedef_, Nullability.legacy)],
const VoidType(),
@@ -434,7 +451,7 @@ main() {
negative1Test(
'Invalid typedef Foo = `() => Foo`',
(TestHarness test) {
var typedef_ = new Typedef('Foo', null);
var typedef_ = new Typedef('Foo', null, fileUri: dummyUri);
typedef_.type = new FunctionType([],
new TypedefType(typedef_, Nullability.legacy), Nullability.legacy);
test.addNode(typedef_);
@@ -445,7 +462,7 @@ main() {
negative1Test(
'Invalid typedef Foo = C<Foo>',
(TestHarness test) {
var typedef_ = new Typedef('Foo', null);
var typedef_ = new Typedef('Foo', null, fileUri: dummyUri);
typedef_.type = new InterfaceType(test.otherClass, Nullability.legacy,
[new TypedefType(typedef_, Nullability.legacy)]);
test.addNode(typedef_);
@@ -456,8 +473,8 @@ main() {
negative1Test(
'Invalid typedefs Foo = Bar, Bar = Foo',
(TestHarness test) {
var foo = new Typedef('Foo', null);
var bar = new Typedef('Bar', null);
var foo = new Typedef('Foo', null, fileUri: dummyUri);
var bar = new Typedef('Bar', null, fileUri: dummyUri);
foo.type = new TypedefType(bar, Nullability.legacy);
bar.type = new TypedefType(foo, Nullability.legacy);
test.enclosingLibrary.addTypedef(foo);
@@ -469,8 +486,8 @@ main() {
negative1Test(
'Invalid typedefs Foo = Bar, Bar = C<Foo>',
(TestHarness test) {
var foo = new Typedef('Foo', null);
var bar = new Typedef('Bar', null);
var foo = new Typedef('Foo', null, fileUri: dummyUri);
var bar = new Typedef('Bar', null, fileUri: dummyUri);
foo.type = new TypedefType(bar, Nullability.legacy);
bar.type = new InterfaceType(test.otherClass, Nullability.legacy,
[new TypedefType(foo, Nullability.legacy)]);
@@ -483,8 +500,8 @@ main() {
negative1Test(
'Invalid typedefs Foo = C<Bar>, Bar = C<Foo>',
(TestHarness test) {
var foo = new Typedef('Foo', null);
var bar = new Typedef('Bar', null);
var foo = new Typedef('Foo', null, fileUri: dummyUri);
var bar = new Typedef('Bar', null, fileUri: dummyUri);
foo.type = new InterfaceType(test.otherClass, Nullability.legacy,
[new TypedefType(bar, Nullability.legacy)]);
bar.type = new InterfaceType(test.otherClass, Nullability.legacy,
@@ -498,11 +515,12 @@ main() {
positiveTest(
'Valid long typedefs C20 = C19 = ... = C1 = C0 = dynamic',
(TestHarness test) {
var typedef_ = new Typedef('C0', const DynamicType());
var typedef_ = new Typedef('C0', const DynamicType(), fileUri: dummyUri);
test.enclosingLibrary.addTypedef(typedef_);
for (int i = 1; i < 20; ++i) {
typedef_ =
new Typedef('C$i', new TypedefType(typedef_, Nullability.legacy));
typedef_ = new Typedef(
'C$i', new TypedefType(typedef_, Nullability.legacy),
fileUri: dummyUri);
test.enclosingLibrary.addTypedef(typedef_);
}
},
@@ -510,13 +528,14 @@ main() {
negative1Test(
'Invalid long typedefs C20 = C19 = ... = C1 = C0 = C20',
(TestHarness test) {
Typedef firstTypedef = new Typedef('C0', null);
Typedef firstTypedef = new Typedef('C0', null, fileUri: dummyUri);
Typedef typedef_ = firstTypedef;
test.enclosingLibrary.addTypedef(typedef_);
var first = typedef_;
for (int i = 1; i < 20; ++i) {
typedef_ =
new Typedef('C$i', new TypedefType(typedef_, Nullability.legacy));
typedef_ = new Typedef(
'C$i', new TypedefType(typedef_, Nullability.legacy),
fileUri: dummyUri);
test.enclosingLibrary.addTypedef(typedef_);
}
first.type = new TypedefType(typedef_, Nullability.legacy);
@@ -532,7 +551,8 @@ main() {
'Foo',
new InterfaceType(test.otherClass, Nullability.legacy,
[new TypeParameterType(param, Nullability.legacy)]),
typeParameters: [param]);
typeParameters: [param],
fileUri: dummyUri);
test.addNode(foo);
},
);
@@ -546,7 +566,8 @@ main() {
'Foo',
new InterfaceType(test.otherClass, Nullability.legacy,
[new TypeParameterType(param, Nullability.legacy)]),
typeParameters: [param]);
typeParameters: [param],
fileUri: dummyUri);
test.addNode(foo);
},
);
@@ -554,8 +575,8 @@ main() {
'Valid typedef Foo<T> = dynamic, Bar<T extends Foo<T>> = C<T>',
(TestHarness test) {
var fooParam = test.makeTypeParameter('T');
var foo =
new Typedef('Foo', const DynamicType(), typeParameters: [fooParam]);
var foo = new Typedef('Foo', const DynamicType(),
typeParameters: [fooParam], fileUri: dummyUri);
var barParam = new TypeParameter('T', null);
barParam.bound = new TypedefType(foo, Nullability.legacy,
[new TypeParameterType(barParam, Nullability.legacy)]);
@@ -563,7 +584,8 @@ main() {
'Bar',
new InterfaceType(test.otherClass, Nullability.legacy,
[new TypeParameterType(barParam, Nullability.legacy)]),
typeParameters: [barParam]);
typeParameters: [barParam],
fileUri: dummyUri);
test.enclosingLibrary.addTypedef(foo);
test.enclosingLibrary.addTypedef(bar);
},
@@ -572,8 +594,8 @@ main() {
'Invalid typedefs Foo<T extends Bar<T>>, Bar<T extends Foo<T>>',
(TestHarness test) {
var fooParam = test.makeTypeParameter('T');
var foo =
new Typedef('Foo', const DynamicType(), typeParameters: [fooParam]);
var foo = new Typedef('Foo', const DynamicType(),
typeParameters: [fooParam], fileUri: dummyUri);
var barParam = new TypeParameter('T', null);
barParam.bound = new TypedefType(foo, Nullability.legacy,
[new TypeParameterType(barParam, Nullability.legacy)]);
@@ -581,7 +603,8 @@ main() {
'Bar',
new InterfaceType(test.otherClass, Nullability.legacy,
[new TypeParameterType(barParam, Nullability.legacy)]),
typeParameters: [barParam]);
typeParameters: [barParam],
fileUri: dummyUri);
fooParam.bound = new TypedefType(bar, Nullability.legacy,
[new TypeParameterType(fooParam, Nullability.legacy)]);
test.enclosingLibrary.addTypedef(foo);
@@ -598,7 +621,8 @@ main() {
'Foo',
new InterfaceType(test.otherClass, Nullability.legacy,
[new TypeParameterType(param, Nullability.legacy)]),
typeParameters: [param]);
typeParameters: [param],
fileUri: dummyUri);
param.bound =
new TypedefType(foo, Nullability.legacy, [const DynamicType()]);
test.addNode(foo);
@@ -610,11 +634,11 @@ main() {
'Typedef arity error',
(TestHarness test) {
var param = test.makeTypeParameter('T');
var foo =
new Typedef('Foo', test.otherLegacyRawType, typeParameters: [param]);
var foo = new Typedef('Foo', test.otherLegacyRawType,
typeParameters: [param], fileUri: dummyUri);
var typedefType = new TypedefType(foo, Nullability.legacy, []);
var field = new Field.mutable(new Name('field'),
type: typedefType, isStatic: true);
type: typedefType, isStatic: true, fileUri: dummyUri);
test.enclosingLibrary.addTypedef(foo);
test.enclosingLibrary.addField(field);
return typedefType;
@@ -626,9 +650,12 @@ main() {
negative1Test(
'Dangling typedef reference',
(TestHarness test) {
var foo = new Typedef('Foo', test.otherLegacyRawType, typeParameters: []);
var foo = new Typedef('Foo', test.otherLegacyRawType,
typeParameters: [], fileUri: dummyUri);
var field = new Field.mutable(new Name('field'),
type: new TypedefType(foo, Nullability.legacy, []), isStatic: true);
type: new TypedefType(foo, Nullability.legacy, []),
isStatic: true,
fileUri: dummyUri);
test.enclosingLibrary.addField(field);
return foo;
},
@@ -637,7 +664,7 @@ main() {
negative1Test(
'Non-static top-level field',
(TestHarness test) {
var field = new Field.mutable(new Name('field'));
var field = new Field.mutable(new Name('field'), fileUri: dummyUri);
test.enclosingLibrary.addField(field);
return null;
},
@@ -739,31 +766,36 @@ class TestHarness {
void setupComponent() {
component = new Component();
stubLibrary = new Library(Uri.parse('dart:core'));
Uri dartCoreUri = Uri.parse('dart:core');
stubLibrary = new Library(dartCoreUri, fileUri: dartCoreUri);
component.libraries.add(stubLibrary..parent = component);
stubLibrary.name = 'dart.core';
objectClass = new Class(name: 'Object');
objectClass = new Class(name: 'Object', fileUri: dartCoreUri);
objectLegacyRawType =
new InterfaceType(objectClass, Nullability.legacy, const <DartType>[]);
stubLibrary.addClass(objectClass);
enclosingLibrary = new Library(Uri.parse('file://test.dart'));
Uri testUri = Uri.parse('file://test.dart');
enclosingLibrary = new Library(testUri, fileUri: testUri);
component.libraries.add(enclosingLibrary..parent = component);
enclosingLibrary.name = 'test_lib';
classTypeParameter = makeTypeParameter('T');
enclosingClass = new Class(
name: 'TestClass',
typeParameters: [classTypeParameter],
supertype: objectClass.asRawSupertype);
supertype: objectClass.asRawSupertype,
fileUri: testUri);
enclosingLegacyRawType = new InterfaceType(enclosingClass,
Nullability.legacy, const <DartType>[const DynamicType()]);
enclosingLibrary.addClass(enclosingClass);
enclosingMember = new Procedure(new Name('test'), ProcedureKind.Method,
new FunctionNode(new EmptyStatement()));
new FunctionNode(new EmptyStatement()),
fileUri: dummyUri);
enclosingClass.addProcedure(enclosingMember);
otherClass = new Class(
name: 'OtherClass',
typeParameters: [makeTypeParameter('OtherT')],
supertype: objectClass.asRawSupertype);
supertype: objectClass.asRawSupertype,
fileUri: testUri);
otherLegacyRawType = new InterfaceType(
otherClass, Nullability.legacy, const <DartType>[const DynamicType()]);
enclosingLibrary.addClass(otherClass);
@@ -374,7 +374,8 @@ class _DispatchableInvocation extends _Invocation {
/// Marker for noSuchMethod() invocation in the map of invocation targets.
static final Member kNoSuchMethodMarker = new Procedure(
new Name('noSuchMethod&&'), ProcedureKind.Method, new FunctionNode(null));
new Name('noSuchMethod&&'), ProcedureKind.Method, new FunctionNode(null),
fileUri: dummyUri);
_DispatchableInvocation(Selector selector, Args<Type> args)
: super(selector, args) {
@@ -54,9 +54,11 @@ main() {
final CoreTypes coreTypes = new CoreTypes(component);
test('types-builder', () {
final Class c1 = new Class(name: 'C1');
final Class c2 =
new Class(name: 'C2', typeParameters: [new TypeParameter('E')]);
final Class c1 = new Class(name: 'C1', fileUri: dummyUri);
final Class c2 = new Class(
name: 'C2',
typeParameters: [new TypeParameter('E')],
fileUri: dummyUri);
final TypesBuilder tb = new TestTypeHierarchy(coreTypes, {}, {});
final tfc1 = tb.getTFClass(c1);
@@ -100,10 +102,10 @@ main() {
test('union-intersection', () {
// T1 <: T3, T2 <: T3
final c1 = new Class(name: 'T1');
final c2 = new Class(name: 'T2');
final c3 = new Class(name: 'T3');
final c4 = new Class(name: 'T4');
final c1 = new Class(name: 'T1', fileUri: dummyUri);
final c2 = new Class(name: 'T2', fileUri: dummyUri);
final c3 = new Class(name: 'T3', fileUri: dummyUri);
final c4 = new Class(name: 'T4', fileUri: dummyUri);
final tfc1 = new TFClass(1, c1);
final tfc2 = new TFClass(2, c2);
@@ -291,9 +293,9 @@ main() {
});
test('hashcode-equals', () {
final c1 = new Class(name: 'C1');
final c2 = new Class(name: 'C2');
final c3 = new Class(name: 'C3');
final c1 = new Class(name: 'C1', fileUri: dummyUri);
final c2 = new Class(name: 'C2', fileUri: dummyUri);
final c3 = new Class(name: 'C3', fileUri: dummyUri);
final tfc1 = new TFClass(1, c1);
final tfc2 = new TFClass(2, c2);
+2 -2
View File
@@ -20,8 +20,8 @@ namespace kernel {
static const uint32_t kMagicProgramFile = 0x90ABCDEFu;
// Both version numbers are inclusive.
static const uint32_t kMinSupportedKernelFormatVersion = 61;
static const uint32_t kMaxSupportedKernelFormatVersion = 61;
static const uint32_t kMinSupportedKernelFormatVersion = 62;
static const uint32_t kMaxSupportedKernelFormatVersion = 62;
// Keep in sync with package:kernel/lib/binary/tag.dart
#define KERNEL_TAG_LIST(V) \