Reland [cfe] Migrate front_end libraries from wave 3-4
Change-Id: If7134e417a7820b26c7f96d87d483f0ba1c74919 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195923 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
8156646b0c
commit
38cd5105b5
@@ -927,13 +927,12 @@ class SuperPropertyAccessGenerator extends Generator {
|
||||
|
||||
@override
|
||||
void printOn(StringSink sink) {
|
||||
NameSystem syntheticNames = new NameSystem();
|
||||
sink.write(", name: ");
|
||||
sink.write(name.text);
|
||||
sink.write(", getter: ");
|
||||
printQualifiedNameOn(getter, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(getter, sink);
|
||||
sink.write(", setter: ");
|
||||
printQualifiedNameOn(setter, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(setter, sink);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1303,9 +1302,9 @@ class SuperIndexedAccessGenerator extends Generator {
|
||||
sink.write(", index: ");
|
||||
printNodeOn(index, sink, syntheticNames: syntheticNames);
|
||||
sink.write(", getter: ");
|
||||
printQualifiedNameOn(getter, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(getter, sink);
|
||||
sink.write(", setter: ");
|
||||
printQualifiedNameOn(setter, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(setter, sink);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1503,13 +1502,12 @@ class StaticAccessGenerator extends Generator {
|
||||
|
||||
@override
|
||||
void printOn(StringSink sink) {
|
||||
NameSystem syntheticNames = new NameSystem();
|
||||
sink.write(", targetName: ");
|
||||
sink.write(targetName);
|
||||
sink.write(", readTarget: ");
|
||||
printQualifiedNameOn(readTarget, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(readTarget, sink);
|
||||
sink.write(", writeTarget: ");
|
||||
printQualifiedNameOn(writeTarget, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(writeTarget, sink);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1777,13 +1775,12 @@ class ExtensionInstanceAccessGenerator extends Generator {
|
||||
|
||||
@override
|
||||
void printOn(StringSink sink) {
|
||||
NameSystem syntheticNames = new NameSystem();
|
||||
sink.write(", targetName: ");
|
||||
sink.write(targetName);
|
||||
sink.write(", readTarget: ");
|
||||
printQualifiedNameOn(readTarget, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(readTarget, sink);
|
||||
sink.write(", writeTarget: ");
|
||||
printQualifiedNameOn(writeTarget, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(writeTarget, sink);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2192,13 +2189,12 @@ class ExplicitExtensionInstanceAccessGenerator extends Generator {
|
||||
|
||||
@override
|
||||
void printOn(StringSink sink) {
|
||||
NameSystem syntheticNames = new NameSystem();
|
||||
sink.write(", targetName: ");
|
||||
sink.write(targetName);
|
||||
sink.write(", readTarget: ");
|
||||
printQualifiedNameOn(readTarget, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(readTarget, sink);
|
||||
sink.write(", writeTarget: ");
|
||||
printQualifiedNameOn(writeTarget, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(writeTarget, sink);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2475,9 +2471,9 @@ class ExplicitExtensionIndexedAccessGenerator extends Generator {
|
||||
sink.write(", index: ");
|
||||
printNodeOn(index, sink, syntheticNames: syntheticNames);
|
||||
sink.write(", readTarget: ");
|
||||
printQualifiedNameOn(readTarget, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(readTarget, sink);
|
||||
sink.write(", writeTarget: ");
|
||||
printQualifiedNameOn(writeTarget, sink, syntheticNames: syntheticNames);
|
||||
printQualifiedNameOn(writeTarget, sink);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE.md file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
|
||||
import '../type_inference/type_schema.dart';
|
||||
@@ -81,7 +79,7 @@ class _InvalidTypeFinder implements DartTypeVisitor1<bool, Set<TypedefType>> {
|
||||
bool visitFunctionType(FunctionType node, Set<TypedefType> visitedTypedefs) {
|
||||
if (node.returnType.accept1(this, visitedTypedefs)) return true;
|
||||
for (TypeParameter typeParameter in node.typeParameters) {
|
||||
if (typeParameter.bound.accept1(this, visitedTypedefs)) return true;
|
||||
if (typeParameter.bound!.accept1(this, visitedTypedefs)) return true;
|
||||
// TODO(dmitryas): Check defaultTypes as well if they cause cascading
|
||||
// errors.
|
||||
}
|
||||
@@ -91,8 +89,8 @@ class _InvalidTypeFinder implements DartTypeVisitor1<bool, Set<TypedefType>> {
|
||||
for (NamedType parameter in node.namedParameters) {
|
||||
if (parameter.type.accept1(this, visitedTypedefs)) return true;
|
||||
}
|
||||
if (node.typedefType != null && visitedTypedefs.add(node.typedefType)) {
|
||||
if (node.typedefType.accept1(this, visitedTypedefs)) return true;
|
||||
if (node.typedefType != null && visitedTypedefs.add(node.typedefType!)) {
|
||||
if (node.typedefType!.accept1(this, visitedTypedefs)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -105,7 +103,7 @@ class _InvalidTypeFinder implements DartTypeVisitor1<bool, Set<TypedefType>> {
|
||||
for (DartType typeArgument in node.typeArguments) {
|
||||
if (typeArgument.accept1(this, visitedTypedefs)) return true;
|
||||
}
|
||||
if (node.typedefNode.type.accept1(this, visitedTypedefs)) return true;
|
||||
if (node.typedefNode.type!.accept1(this, visitedTypedefs)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -116,7 +114,7 @@ class _InvalidTypeFinder implements DartTypeVisitor1<bool, Set<TypedefType>> {
|
||||
// automatically means that the potential errors related to the occurrences
|
||||
// of the type-parameter type itself are reported.
|
||||
if (node.promotedBound != null &&
|
||||
node.promotedBound.accept1(this, visitedTypedefs)) {
|
||||
node.promotedBound!.accept1(this, visitedTypedefs)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
/// This library exports all API from Kernel that can be used throughout fasta.
|
||||
library fasta.kernel_api;
|
||||
|
||||
@@ -27,7 +25,7 @@ import 'package:kernel/text/ast_to_text.dart' show NameSystem, Printer;
|
||||
|
||||
import 'package:kernel/ast.dart' show Class, Member, Node;
|
||||
|
||||
void printNodeOn(Node node, StringSink sink, {NameSystem syntheticNames}) {
|
||||
void printNodeOn(Node? node, StringSink sink, {NameSystem? syntheticNames}) {
|
||||
if (node == null) {
|
||||
sink.write("null");
|
||||
} else {
|
||||
@@ -36,19 +34,17 @@ void printNodeOn(Node node, StringSink sink, {NameSystem syntheticNames}) {
|
||||
}
|
||||
}
|
||||
|
||||
void printQualifiedNameOn(Member member, StringSink sink,
|
||||
{NameSystem syntheticNames}) {
|
||||
void printQualifiedNameOn(Member? member, StringSink sink) {
|
||||
if (member == null) {
|
||||
sink.write("null");
|
||||
} else {
|
||||
syntheticNames ??= new NameSystem();
|
||||
sink.write(member.enclosingLibrary.importUri);
|
||||
sink.write("::");
|
||||
Class cls = member.enclosingClass;
|
||||
Class? cls = member.enclosingClass;
|
||||
if (cls != null) {
|
||||
sink.write(cls.name ?? syntheticNames.nameClass(cls));
|
||||
sink.write(cls.name);
|
||||
sink.write("::");
|
||||
}
|
||||
sink.write(member.name?.text ?? syntheticNames.nameMember(member));
|
||||
sink.write(member.name.text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:io' show BytesBuilder, File, IOSink;
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
@@ -29,8 +27,8 @@ import 'package:kernel/text/ast_to_text.dart' show Printer;
|
||||
/// Print the given [component]. Do nothing if it is `null`. If the
|
||||
/// [libraryFilter] is provided, then only libraries that satisfy it are
|
||||
/// printed.
|
||||
void printComponentText(Component component,
|
||||
{bool libraryFilter(Library library)}) {
|
||||
void printComponentText(Component? component,
|
||||
{bool Function(Library library)? libraryFilter}) {
|
||||
if (component == null) return;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Printer printer = new Printer(sb);
|
||||
@@ -45,7 +43,7 @@ void printComponentText(Component component,
|
||||
|
||||
/// Write [component] to file only including libraries that match [filter].
|
||||
Future<Null> writeComponentToFile(Component component, Uri uri,
|
||||
{bool filter(Library library)}) async {
|
||||
{bool Function(Library library)? filter}) async {
|
||||
File output = new File.fromUri(uri);
|
||||
IOSink sink = output.openWrite();
|
||||
try {
|
||||
@@ -58,7 +56,7 @@ Future<Null> writeComponentToFile(Component component, Uri uri,
|
||||
|
||||
/// Serialize the libraries in [component] that match [filter].
|
||||
Uint8List serializeComponent(Component component,
|
||||
{bool filter(Library library),
|
||||
{bool Function(Library library)? filter,
|
||||
bool includeSources: true,
|
||||
bool includeOffsets: true}) {
|
||||
ByteSink byteSink = new ByteSink();
|
||||
@@ -82,7 +80,7 @@ Component createExpressionEvaluationComponent(Procedure procedure) {
|
||||
..nonNullableByDefaultCompiledMode =
|
||||
realLibrary.nonNullableByDefaultCompiledMode;
|
||||
|
||||
TreeNode realClass = procedure.parent;
|
||||
TreeNode? realClass = procedure.parent;
|
||||
if (realClass is Class) {
|
||||
Class fakeClass = new Class(name: kDebugClassName, fileUri: uri)
|
||||
..parent = fakeLibrary;
|
||||
@@ -100,14 +98,15 @@ Component createExpressionEvaluationComponent(Procedure procedure) {
|
||||
typeSubstitution: typeSubstitution, typeParams: typeParams);
|
||||
|
||||
for (TypeParameter typeParam in realClass.typeParameters) {
|
||||
fakeClass.typeParameters.add(typeParam.accept<TreeNode>(cloner));
|
||||
fakeClass.typeParameters
|
||||
.add(typeParam.accept<TreeNode>(cloner) as TypeParameter);
|
||||
}
|
||||
|
||||
if (realClass.supertype != null) {
|
||||
// supertype is null for Object.
|
||||
fakeClass.supertype = new Supertype.byReference(
|
||||
realClass.supertype.className,
|
||||
realClass.supertype.typeArguments.map(cloner.visitType).toList());
|
||||
realClass.supertype!.className,
|
||||
realClass.supertype!.typeArguments.map(cloner.visitType).toList());
|
||||
}
|
||||
|
||||
// Rebind the type parameters in the procedure.
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE.md file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/ast.dart' show DartType, Library, NeverType;
|
||||
|
||||
import 'package:kernel/src/standard_bounds.dart';
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE.md file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/ast.dart'
|
||||
show
|
||||
DartType,
|
||||
@@ -38,10 +36,10 @@ String typeSchemaToString(DartType schema) {
|
||||
/// Extension of [Printer] that represents the unknown type as `?`.
|
||||
class TypeSchemaPrinter extends Printer {
|
||||
TypeSchemaPrinter(StringSink sink,
|
||||
{NameSystem syntheticNames,
|
||||
{NameSystem? syntheticNames,
|
||||
bool showOffsets: false,
|
||||
ImportTable importTable,
|
||||
Annotator annotator})
|
||||
ImportTable? importTable,
|
||||
Annotator? annotator})
|
||||
: super(sink,
|
||||
syntheticNames: syntheticNames,
|
||||
showOffsets: showOffsets,
|
||||
@@ -64,16 +62,16 @@ class UnknownType extends DartType {
|
||||
const UnknownType();
|
||||
|
||||
@override
|
||||
Nullability get declaredNullability => null;
|
||||
Nullability get declaredNullability => Nullability.undetermined;
|
||||
|
||||
@override
|
||||
Nullability get nullability => null;
|
||||
Nullability get nullability => Nullability.undetermined;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => equals(other, null);
|
||||
|
||||
@override
|
||||
bool equals(Object other, Assumptions assumptions) {
|
||||
bool equals(Object other, Assumptions? assumptions) {
|
||||
// This class doesn't have any fields so all instances of `UnknownType` are
|
||||
// equal.
|
||||
return other is UnknownType;
|
||||
@@ -124,7 +122,7 @@ class _IsKnownVisitor extends DartTypeVisitor<bool> {
|
||||
for (NamedType namedParameterType in node.namedParameters) {
|
||||
if (!namedParameterType.type.accept(this)) return false;
|
||||
}
|
||||
if (node.typedefType != null && !node.typedefType.accept(this)) {
|
||||
if (node.typedefType != null && !node.typedefType!.accept(this)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE.md file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
import 'package:kernel/src/replacement_visitor.dart';
|
||||
|
||||
@@ -56,7 +54,7 @@ class _TypeSchemaEliminationVisitor extends ReplacementVisitor {
|
||||
_TypeSchemaEliminationVisitor(this.topType, this.bottomType);
|
||||
|
||||
@override
|
||||
DartType defaultDartType(DartType node, int variance) {
|
||||
DartType? defaultDartType(DartType node, int variance) {
|
||||
bool isLeastClosure = variance == Variance.covariant;
|
||||
if (node is UnknownType) {
|
||||
return isLeastClosure ? bottomType : topType;
|
||||
@@ -79,7 +77,7 @@ class _TypeSchemaEliminationVisitor extends ReplacementVisitor {
|
||||
bottomType == const NeverType.nonNullable() || bottomType is NullType);
|
||||
_TypeSchemaEliminationVisitor visitor =
|
||||
new _TypeSchemaEliminationVisitor(topType, bottomType);
|
||||
DartType result = schema.accept1(
|
||||
DartType? result = schema.accept1(
|
||||
visitor, isLeastClosure ? Variance.covariant : Variance.contravariant);
|
||||
return result ?? schema;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user