[ddc] Migrate compiler to null safety

Issue: https://github.com/dart-lang/sdk/issues/46617
Change-Id: Id6a5e2e435b22fad4afcb5d06d0a50dc617f4bf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248705
Reviewed-by: Anna Gringauze <annagrin@google.com>
This commit is contained in:
Nicholas Shahan 2022-06-22 21:30:16 +00:00 committed by Commit Bot
parent c52dd252f8
commit de90931be4
3 changed files with 333 additions and 344 deletions

View file

@ -144,10 +144,6 @@ abstract class SharedCompiler<Library extends Object, Class extends Object,
@protected
Library get coreLibrary;
/// The import URI of current library.
@protected
Uri get currentLibraryUri;
/// The current function being compiled, if any.
@protected
FunctionNode? get currentFunction;

File diff suppressed because it is too large Load diff

View file

@ -11,11 +11,11 @@ Constructor? unnamedConstructor(Class c) =>
c.constructors.firstWhereOrNull((c) => c.name.text == '');
/// Returns the enclosing library for reference [node].
Library? getLibrary(NamedNode node) {
Library getLibrary(NamedNode node) {
for (TreeNode? n = node; n != null; n = n.parent) {
if (n is Library) return n;
}
return null;
throw UnsupportedError('Could not find a containing library for $node');
}
final Pattern _syntheticTypeCharacters = RegExp('[&^#.|]');
@ -44,14 +44,14 @@ String getLocalClassName(Class node) => escapeIdentifier(node.name)!;
///
/// In the current encoding, generic classes are generated in a function scope
/// which avoids name clashes of the escaped parameter name.
String? getTypeParameterName(TypeParameter node) => escapeIdentifier(node.name);
String getTypeParameterName(TypeParameter node) => escapeIdentifier(node.name)!;
String? getTopLevelName(NamedNode n) {
String getTopLevelName(NamedNode n) {
if (n is Procedure) return n.name.text;
if (n is Class) return n.name;
if (n is Typedef) return n.name;
if (n is Field) return n.name.text;
return n.reference.canonicalName?.name;
return n.reference.canonicalName!.name;
}
/// Given an annotated [node] and a [test] function, returns the first matching