Version 2.15.0-242.0.dev
Merge commit 'd0e56020f347204e02c0eaa7012b2eb3fa820934' into 'dev'
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_loader.dart b/pkg/front_end/lib/src/fasta/dill/dill_loader.dart
index 86a4c3b..9524f5b 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_loader.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_loader.dart
@@ -47,6 +47,9 @@
class DillLoader extends Loader {
SourceLoader? currentSourceLoader;
+ final Map<Uri, DillLibraryBuilder> _knownLibraryBuilders =
+ <Uri, DillLibraryBuilder>{};
+
final Map<Uri, DillLibraryBuilder> _builders = <Uri, DillLibraryBuilder>{};
final Queue<DillLibraryBuilder> _unparsedLibraries =
@@ -88,6 +91,16 @@
Ticker get ticker => target.ticker;
+ void registerKnownLibrary(Library library) {
+ _knownLibraryBuilders[library.importUri] =
+ new DillLibraryBuilder(library, this);
+ }
+
+ // TODO(johnniwinther): This is never called!?!
+ void releaseAncillaryResources() {
+ _knownLibraryBuilders.clear();
+ }
+
/// Look up a library builder by the [uri], or if such doesn't exist, create
/// one. The canonical URI of the library is [uri], and its actual location is
/// [fileUri].
@@ -100,12 +113,16 @@
/// directive. If [accessor] isn't allowed to access [uri], it's a
/// compile-time error.
DillLibraryBuilder read(Uri uri, int charOffset, {LibraryBuilder? accessor}) {
- DillLibraryBuilder builder = _builders.putIfAbsent(uri, () {
- DillLibraryBuilder library = target.createLibraryBuilder(uri);
- assert(library.loader == this);
+ DillLibraryBuilder? libraryBuilder = _builders[uri];
+ if (libraryBuilder == null) {
+ libraryBuilder = _knownLibraryBuilders.remove(uri);
+ // ignore: unnecessary_null_comparison
+ assert(libraryBuilder != null, "No library found for $uri.");
+ _builders[uri] = libraryBuilder!;
+ assert(libraryBuilder.loader == this);
if (uri.scheme == "dart") {
if (uri.path == "core") {
- _coreLibrary = library;
+ _coreLibrary = libraryBuilder;
}
}
{
@@ -113,19 +130,18 @@
// firstSourceUri and first library should be done as early as
// possible.
firstSourceUri ??= uri;
- first ??= library;
+ first ??= libraryBuilder;
}
- if (_coreLibrary == library) {
+ if (_coreLibrary == libraryBuilder) {
target.loadExtraRequiredLibraries(this);
}
if (target.backendTarget.mayDefineRestrictedType(uri)) {
- library.mayImplementRestrictedTypes = true;
+ libraryBuilder.mayImplementRestrictedTypes = true;
}
- _unparsedLibraries.addLast(library);
- return library;
- });
+ _unparsedLibraries.addLast(libraryBuilder);
+ }
if (accessor != null) {
- builder.recordAccess(charOffset, noLength, accessor.fileUri);
+ libraryBuilder.recordAccess(charOffset, noLength, accessor.fileUri);
if (!accessor.isPatch &&
!accessor.isPart &&
!target.backendTarget
@@ -134,7 +150,7 @@
noLength, accessor.fileUri);
}
}
- return builder;
+ return libraryBuilder;
}
void _ensureCoreLibrary() {
@@ -259,7 +275,7 @@
Uri uri = library.importUri;
if (filter == null || filter(library.importUri)) {
libraries.add(library);
- target.registerLibrary(library);
+ registerKnownLibrary(library);
requestedLibraries.add(uri);
requestedLibrariesFileUri.add(library.fileUri);
}
@@ -285,7 +301,7 @@
//
// Create dill library builder (adds it to a map where it's fetched
// again momentarily).
- target.registerLibrary(library);
+ registerKnownLibrary(library);
// Set up the dill library builder (fetch it from the map again, add it to
// another map and setup some auxiliary things).
return read(library.importUri, -1);
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_target.dart b/pkg/front_end/lib/src/fasta/dill/dill_target.dart
index 459831a..b5b737e 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_target.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_target.dart
@@ -4,7 +4,7 @@
import 'package:_fe_analyzer_shared/src/messages/severity.dart' show Severity;
-import 'package:kernel/ast.dart' show Library, Source;
+import 'package:kernel/ast.dart' show Source;
import 'package:kernel/target/targets.dart' show Target;
@@ -20,16 +20,11 @@
import '../target_implementation.dart' show TargetImplementation;
-import 'dill_library_builder.dart' show DillLibraryBuilder;
-
import 'dill_loader.dart' show DillLoader;
class DillTarget extends TargetImplementation {
final Ticker ticker;
- final Map<Uri, DillLibraryBuilder> _knownLibraryBuilders =
- <Uri, DillLibraryBuilder>{};
-
bool isLoaded = false;
late final DillLoader loader;
@@ -92,23 +87,4 @@
}
isLoaded = true;
}
-
- /// Returns the [DillLibraryBuilder] corresponding to [uri].
- ///
- /// The [DillLibraryBuilder] is pulled from [_knownLibraryBuilders].
- DillLibraryBuilder createLibraryBuilder(Uri uri) {
- DillLibraryBuilder libraryBuilder = _knownLibraryBuilders.remove(uri)!;
- // ignore: unnecessary_null_comparison
- assert(libraryBuilder != null, "No library found for $uri.");
- return libraryBuilder;
- }
-
- void registerLibrary(Library library) {
- _knownLibraryBuilders[library.importUri] =
- new DillLibraryBuilder(library, loader);
- }
-
- void releaseAncillaryResources() {
- _knownLibraryBuilders.clear();
- }
}
diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
index febaaf8..61bdb2e 100644
--- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart
+++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
@@ -1426,7 +1426,7 @@
for (Library lib in module.libraries) {
if (!dillLoadedData!.loader.containsLibraryBuilder(lib.importUri)) {
dillLoadedData!.loader.libraries.add(lib);
- dillLoadedData!.registerLibrary(lib);
+ dillLoadedData!.loader.registerKnownLibrary(lib);
reusedLibraries.add(dillLoadedData!.loader.read(lib.importUri, -1));
usedComponent = true;
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index 58475d8..9e0e011 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -40,7 +40,6 @@
import '../builder/void_type_declaration_builder.dart';
import '../compiler_context.dart' show CompilerContext;
import '../crash.dart' show withCrashReporting;
-import '../dill/dill_library_builder.dart' show DillLibraryBuilder;
import '../dill/dill_member_builder.dart' show DillMemberBuilder;
import '../dill/dill_target.dart' show DillTarget;
import '../kernel/constructor_tearoff_lowering.dart';
@@ -50,16 +49,11 @@
FormattedMessage,
LocatedMessage,
Message,
- messageAgnosticWithStrongDillLibrary,
- messageAgnosticWithWeakDillLibrary,
messageConstConstructorLateFinalFieldCause,
messageConstConstructorLateFinalFieldError,
messageConstConstructorNonFinalField,
messageConstConstructorNonFinalFieldCause,
messageConstConstructorRedirectionToNonConst,
- messageInvalidNnbdDillLibrary,
- messageStrongWithWeakDillLibrary,
- messageWeakWithStrongDillLibrary,
noLength,
templateFieldNonNullableNotInitializedByConstructorError,
templateFieldNonNullableWithoutInitializerError,
@@ -72,8 +66,7 @@
import '../scope.dart' show AmbiguousBuilder;
import '../source/name_scheme.dart';
import '../source/source_class_builder.dart' show SourceClassBuilder;
-import '../source/source_library_builder.dart'
- show LanguageVersion, SourceLibraryBuilder;
+import '../source/source_library_builder.dart' show SourceLibraryBuilder;
import '../source/source_loader.dart' show SourceLoader;
import '../target_implementation.dart' show TargetImplementation;
import '../ticker.dart' show Ticker;
@@ -368,90 +361,6 @@
return entryPoint;
}
- /// Creates a [LibraryBuilder] corresponding to [uri], if one doesn't exist
- /// already.
- ///
- /// [fileUri] must not be null and is a URI that can be passed to FileSystem
- /// to locate the corresponding file.
- ///
- /// [origin] is non-null if the created library is a patch to [origin].
- ///
- /// [packageUri] is the base uri for the package which the library belongs to.
- /// For instance 'package:foo'.
- ///
- /// This is used to associate libraries in for instance the 'bin' and 'test'
- /// folders of a package source with the package uri of the 'lib' folder.
- ///
- /// If the [packageUri] is `null` the package association of this library is
- /// based on its [importUri].
- ///
- /// For libraries with a 'package:' [importUri], the package path must match
- /// the path in the [importUri]. For libraries with a 'dart:' [importUri] the
- /// [packageUri] must be `null`.
- ///
- /// [packageLanguageVersion] is the language version defined by the package
- /// which the library belongs to, or the current sdk version if the library
- /// doesn't belong to a package.
- LibraryBuilder createLibraryBuilder(
- Uri uri,
- Uri fileUri,
- Uri? packageUri,
- LanguageVersion packageLanguageVersion,
- SourceLibraryBuilder? origin,
- Library? referencesFrom,
- bool? referenceIsPartOwner) {
- if (dillTarget.isLoaded) {
- DillLibraryBuilder? builder = dillTarget.loader.lookupLibraryBuilder(uri);
- if (builder != null) {
- if (!builder.isNonNullableByDefault &&
- (loader.nnbdMode == NnbdMode.Strong ||
- loader.nnbdMode == NnbdMode.Agnostic)) {
- loader.registerStrongOptOutLibrary(builder);
- } else {
- NonNullableByDefaultCompiledMode libraryMode =
- builder.library.nonNullableByDefaultCompiledMode;
- if (libraryMode == NonNullableByDefaultCompiledMode.Invalid) {
- loader.registerNnbdMismatchLibrary(
- builder, messageInvalidNnbdDillLibrary);
- } else {
- switch (loader.nnbdMode) {
- case NnbdMode.Weak:
- if (libraryMode != NonNullableByDefaultCompiledMode.Agnostic &&
- libraryMode != NonNullableByDefaultCompiledMode.Weak) {
- loader.registerNnbdMismatchLibrary(
- builder, messageWeakWithStrongDillLibrary);
- }
- break;
- case NnbdMode.Strong:
- if (libraryMode != NonNullableByDefaultCompiledMode.Agnostic &&
- libraryMode != NonNullableByDefaultCompiledMode.Strong) {
- loader.registerNnbdMismatchLibrary(
- builder, messageStrongWithWeakDillLibrary);
- }
- break;
- case NnbdMode.Agnostic:
- if (libraryMode != NonNullableByDefaultCompiledMode.Agnostic) {
- if (libraryMode == NonNullableByDefaultCompiledMode.Strong) {
- loader.registerNnbdMismatchLibrary(
- builder, messageAgnosticWithStrongDillLibrary);
- } else {
- loader.registerNnbdMismatchLibrary(
- builder, messageAgnosticWithWeakDillLibrary);
- }
- }
- break;
- }
- }
- }
- return builder;
- }
- }
- return new SourceLibraryBuilder(
- uri, fileUri, packageUri, packageLanguageVersion, loader, origin,
- referencesFrom: referencesFrom,
- referenceIsPartOwner: referenceIsPartOwner);
- }
-
/// Returns classes defined in libraries in [loader].
List<SourceClassBuilder> collectMyClasses() {
List<SourceClassBuilder> result = <SourceClassBuilder>[];
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index 696a640..29c7861 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -34,6 +34,7 @@
import '../../base/common.dart';
import '../../base/instrumentation.dart' show Instrumentation;
import '../../base/nnbd_mode.dart';
+import '../dill/dill_library_builder.dart';
import '../builder/builder.dart';
import '../builder/class_builder.dart';
import '../builder/constructor_builder.dart';
@@ -215,7 +216,7 @@
void registerLibraryBuilder(LibraryBuilder libraryBuilder, [Uri? uri]) {
uri ??= libraryBuilder.importUri;
if (uri.scheme == "dart" && uri.path == "core") {
- coreLibrary = libraryBuilder;
+ _coreLibrary = libraryBuilder;
}
_builders[uri] = libraryBuilder;
}
@@ -231,11 +232,226 @@
@override
LibraryBuilder get coreLibrary => _coreLibrary!;
- void set coreLibrary(LibraryBuilder value) {
- _coreLibrary = value;
+ Ticker get ticker => target.ticker;
+
+ /// Creates a [SourceLibraryBuilder] corresponding to [uri], if one doesn't
+ /// exist already.
+ ///
+ /// [fileUri] must not be null and is a URI that can be passed to FileSystem
+ /// to locate the corresponding file.
+ ///
+ /// [origin] is non-null if the created library is a patch to [origin].
+ ///
+ /// [packageUri] is the base uri for the package which the library belongs to.
+ /// For instance 'package:foo'.
+ ///
+ /// This is used to associate libraries in for instance the 'bin' and 'test'
+ /// folders of a package source with the package uri of the 'lib' folder.
+ ///
+ /// If the [packageUri] is `null` the package association of this library is
+ /// based on its [importUri].
+ ///
+ /// For libraries with a 'package:' [importUri], the package path must match
+ /// the path in the [importUri]. For libraries with a 'dart:' [importUri] the
+ /// [packageUri] must be `null`.
+ ///
+ /// [packageLanguageVersion] is the language version defined by the package
+ /// which the library belongs to, or the current sdk version if the library
+ /// doesn't belong to a package.
+ SourceLibraryBuilder createLibraryBuilder(
+ Uri uri,
+ Uri fileUri,
+ Uri? packageUri,
+ LanguageVersion packageLanguageVersion,
+ SourceLibraryBuilder? origin,
+ Library? referencesFrom,
+ bool? referenceIsPartOwner) {
+ return new SourceLibraryBuilder(
+ uri, fileUri, packageUri, packageLanguageVersion, this, origin,
+ referencesFrom: referencesFrom,
+ referenceIsPartOwner: referenceIsPartOwner);
}
- Ticker get ticker => target.ticker;
+ SourceLibraryBuilder _createSourceLibraryBuilder(
+ Uri uri,
+ Uri? fileUri,
+ SourceLibraryBuilder? origin,
+ Library? referencesFrom,
+ bool? referenceIsPartOwner) {
+ if (fileUri != null &&
+ (fileUri.scheme == "dart" ||
+ fileUri.scheme == "package" ||
+ fileUri.scheme == "dart-ext")) {
+ fileUri = null;
+ }
+ package_config.Package? packageForLanguageVersion;
+ if (fileUri == null) {
+ switch (uri.scheme) {
+ case "package":
+ case "dart":
+ fileUri = target.translateUri(uri) ??
+ new Uri(
+ scheme: untranslatableUriScheme,
+ path: Uri.encodeComponent("$uri"));
+ if (uri.scheme == "package") {
+ packageForLanguageVersion = target.uriTranslator.getPackage(uri);
+ } else {
+ packageForLanguageVersion =
+ target.uriTranslator.packages.packageOf(fileUri);
+ }
+ break;
+
+ default:
+ fileUri = uri;
+ packageForLanguageVersion =
+ target.uriTranslator.packages.packageOf(fileUri);
+ break;
+ }
+ } else {
+ packageForLanguageVersion =
+ target.uriTranslator.packages.packageOf(fileUri);
+ }
+ LanguageVersion? packageLanguageVersion;
+ Uri? packageUri;
+ Message? packageLanguageVersionProblem;
+ if (packageForLanguageVersion != null) {
+ Uri importUri = origin?.importUri ?? uri;
+ if (importUri.scheme != 'dart' &&
+ importUri.scheme != 'package' &&
+ // ignore: unnecessary_null_comparison
+ packageForLanguageVersion.name != null) {
+ packageUri =
+ new Uri(scheme: 'package', path: packageForLanguageVersion.name);
+ }
+ if (packageForLanguageVersion.languageVersion != null) {
+ if (packageForLanguageVersion.languageVersion
+ is package_config.InvalidLanguageVersion) {
+ packageLanguageVersionProblem =
+ messageLanguageVersionInvalidInDotPackages;
+ packageLanguageVersion = new InvalidLanguageVersion(
+ fileUri, 0, noLength, target.currentSdkVersion, false);
+ } else {
+ Version version = new Version(
+ packageForLanguageVersion.languageVersion!.major,
+ packageForLanguageVersion.languageVersion!.minor);
+ if (version > target.currentSdkVersion) {
+ packageLanguageVersionProblem =
+ templateLanguageVersionTooHigh.withArguments(
+ target.currentSdkVersion.major,
+ target.currentSdkVersion.minor);
+ packageLanguageVersion = new InvalidLanguageVersion(
+ fileUri, 0, noLength, target.currentSdkVersion, false);
+ } else {
+ packageLanguageVersion = new ImplicitLanguageVersion(version);
+ }
+ }
+ }
+ }
+ packageLanguageVersion ??=
+ new ImplicitLanguageVersion(target.currentSdkVersion);
+
+ SourceLibraryBuilder libraryBuilder = createLibraryBuilder(
+ uri,
+ fileUri,
+ packageUri,
+ packageLanguageVersion,
+ origin,
+ referencesFrom,
+ referenceIsPartOwner);
+ if (packageLanguageVersionProblem != null) {
+ libraryBuilder.addPostponedProblem(
+ packageLanguageVersionProblem, 0, noLength, libraryBuilder.fileUri);
+ }
+
+ // Add any additional logic after this block. Setting the
+ // firstSourceUri and first library should be done as early as
+ // possible.
+ firstSourceUri ??= uri;
+ first ??= libraryBuilder;
+
+ _checkForDartCore(uri, libraryBuilder);
+
+ Uri libraryUri = origin?.importUri ?? uri;
+ if (target.backendTarget.mayDefineRestrictedType(libraryUri)) {
+ libraryBuilder.mayImplementRestrictedTypes = true;
+ }
+ if (uri.scheme == "dart") {
+ target.readPatchFiles(libraryBuilder);
+ }
+ _unparsedLibraries.addLast(libraryBuilder);
+
+ return libraryBuilder;
+ }
+
+ DillLibraryBuilder? _lookupDillLibraryBuilder(Uri uri) {
+ DillLibraryBuilder? libraryBuilder =
+ target.dillTarget.loader.lookupLibraryBuilder(uri);
+ if (libraryBuilder != null) {
+ _checkDillLibraryBuilderNnbdMode(libraryBuilder);
+ _checkForDartCore(uri, libraryBuilder);
+ }
+ return libraryBuilder;
+ }
+
+ void _checkDillLibraryBuilderNnbdMode(DillLibraryBuilder libraryBuilder) {
+ if (!libraryBuilder.isNonNullableByDefault &&
+ (nnbdMode == NnbdMode.Strong || nnbdMode == NnbdMode.Agnostic)) {
+ registerStrongOptOutLibrary(libraryBuilder);
+ } else {
+ NonNullableByDefaultCompiledMode libraryMode =
+ libraryBuilder.library.nonNullableByDefaultCompiledMode;
+ if (libraryMode == NonNullableByDefaultCompiledMode.Invalid) {
+ registerNnbdMismatchLibrary(
+ libraryBuilder, messageInvalidNnbdDillLibrary);
+ } else {
+ switch (nnbdMode) {
+ case NnbdMode.Weak:
+ if (libraryMode != NonNullableByDefaultCompiledMode.Agnostic &&
+ libraryMode != NonNullableByDefaultCompiledMode.Weak) {
+ registerNnbdMismatchLibrary(
+ libraryBuilder, messageWeakWithStrongDillLibrary);
+ }
+ break;
+ case NnbdMode.Strong:
+ if (libraryMode != NonNullableByDefaultCompiledMode.Agnostic &&
+ libraryMode != NonNullableByDefaultCompiledMode.Strong) {
+ registerNnbdMismatchLibrary(
+ libraryBuilder, messageStrongWithWeakDillLibrary);
+ }
+ break;
+ case NnbdMode.Agnostic:
+ if (libraryMode != NonNullableByDefaultCompiledMode.Agnostic) {
+ if (libraryMode == NonNullableByDefaultCompiledMode.Strong) {
+ registerNnbdMismatchLibrary(
+ libraryBuilder, messageAgnosticWithStrongDillLibrary);
+ } else {
+ registerNnbdMismatchLibrary(
+ libraryBuilder, messageAgnosticWithWeakDillLibrary);
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ void _checkForDartCore(Uri uri, LibraryBuilder libraryBuilder) {
+ if (uri.scheme == "dart") {
+ if (uri.path == "core") {
+ _coreLibrary = libraryBuilder;
+ } else if (uri.path == "typed_data") {
+ typedDataLibrary = libraryBuilder;
+ }
+ }
+ // TODO(johnniwinther): If we save the created library in [_builders]
+ // here, i.e. before calling `target.loadExtraRequiredLibraries` below,
+ // the order of the libraries change, making `dart:core` come before the
+ // required arguments. Currently [DillLoader.appendLibrary] one works
+ // when this is not the case.
+ if (_coreLibrary == libraryBuilder) {
+ target.loadExtraRequiredLibraries(this);
+ }
+ }
/// Look up a library builder by the [uri], or if such doesn't exist, create
/// one. The canonical URI of the library is [uri], and its actual location is
@@ -254,135 +470,28 @@
LibraryBuilder? origin,
Library? referencesFrom,
bool? referenceIsPartOwner}) {
- LibraryBuilder builder = _builders.putIfAbsent(uri, () {
- if (fileUri != null &&
- (fileUri!.scheme == "dart" ||
- fileUri!.scheme == "package" ||
- fileUri!.scheme == "dart-ext")) {
- fileUri = null;
+ LibraryBuilder? libraryBuilder = _builders[uri];
+ if (libraryBuilder == null) {
+ if (target.dillTarget.isLoaded) {
+ libraryBuilder = _lookupDillLibraryBuilder(uri);
}
- package_config.Package? packageForLanguageVersion;
- if (fileUri == null) {
- switch (uri.scheme) {
- case "package":
- case "dart":
- fileUri = target.translateUri(uri) ??
- new Uri(
- scheme: untranslatableUriScheme,
- path: Uri.encodeComponent("$uri"));
- if (uri.scheme == "package") {
- packageForLanguageVersion = target.uriTranslator.getPackage(uri);
- } else {
- packageForLanguageVersion =
- target.uriTranslator.packages.packageOf(fileUri!);
- }
- break;
-
- default:
- fileUri = uri;
- packageForLanguageVersion =
- target.uriTranslator.packages.packageOf(fileUri!);
- break;
- }
- } else {
- packageForLanguageVersion =
- target.uriTranslator.packages.packageOf(fileUri!);
- }
- LanguageVersion? packageLanguageVersion;
- Uri? packageUri;
- Message? packageLanguageVersionProblem;
- if (packageForLanguageVersion != null) {
- Uri importUri = origin?.importUri ?? uri;
- if (importUri.scheme != 'dart' &&
- importUri.scheme != 'package' &&
- // ignore: unnecessary_null_comparison
- packageForLanguageVersion.name != null) {
- packageUri =
- new Uri(scheme: 'package', path: packageForLanguageVersion.name);
- }
- if (packageForLanguageVersion.languageVersion != null) {
- if (packageForLanguageVersion.languageVersion
- is package_config.InvalidLanguageVersion) {
- packageLanguageVersionProblem =
- messageLanguageVersionInvalidInDotPackages;
- packageLanguageVersion = new InvalidLanguageVersion(
- fileUri!, 0, noLength, target.currentSdkVersion, false);
- } else {
- Version version = new Version(
- packageForLanguageVersion.languageVersion!.major,
- packageForLanguageVersion.languageVersion!.minor);
- if (version > target.currentSdkVersion) {
- packageLanguageVersionProblem =
- templateLanguageVersionTooHigh.withArguments(
- target.currentSdkVersion.major,
- target.currentSdkVersion.minor);
- packageLanguageVersion = new InvalidLanguageVersion(
- fileUri!, 0, noLength, target.currentSdkVersion, false);
- } else {
- packageLanguageVersion = new ImplicitLanguageVersion(version);
- }
- }
- }
- }
- packageLanguageVersion ??=
- new ImplicitLanguageVersion(target.currentSdkVersion);
-
- LibraryBuilder library = target.createLibraryBuilder(
- uri,
- fileUri!,
- packageUri,
- packageLanguageVersion,
- origin as SourceLibraryBuilder?,
- referencesFrom,
- referenceIsPartOwner);
- if (packageLanguageVersionProblem != null &&
- library is SourceLibraryBuilder) {
- library.addPostponedProblem(
- packageLanguageVersionProblem, 0, noLength, library.fileUri);
+ if (libraryBuilder == null) {
+ libraryBuilder = _createSourceLibraryBuilder(
+ uri,
+ fileUri,
+ origin as SourceLibraryBuilder?,
+ referencesFrom,
+ referenceIsPartOwner);
}
- if (uri.scheme == "dart") {
- if (uri.path == "core") {
- _coreLibrary = library;
- } else if (uri.path == "typed_data") {
- typedDataLibrary = library;
- }
- }
- if (library.loader != this) {
- if (_coreLibrary == library) {
- target.loadExtraRequiredLibraries(this);
- }
- // This library isn't owned by this loader, so no further processing
- // should be attempted.
- return library;
- }
-
- {
- // Add any additional logic after this block. Setting the
- // firstSourceUri and first library should be done as early as
- // possible.
- firstSourceUri ??= uri;
- first ??= library;
- }
- if (_coreLibrary == library) {
- target.loadExtraRequiredLibraries(this);
- }
- Uri libraryUri = origin?.importUri ?? uri;
- if (target.backendTarget.mayDefineRestrictedType(libraryUri)) {
- library.mayImplementRestrictedTypes = true;
- }
- if (uri.scheme == "dart") {
- target.readPatchFiles(library as SourceLibraryBuilder);
- }
- _unparsedLibraries.addLast(library);
- return library;
- });
+ _builders[uri] = libraryBuilder;
+ }
if (accessor == null) {
- if (builder.loader == this && first != builder) {
+ if (libraryBuilder.loader == this && first != libraryBuilder) {
unhandled("null", "accessor", charOffset, uri);
}
} else {
- builder.recordAccess(charOffset, noLength, accessor.fileUri);
+ libraryBuilder.recordAccess(charOffset, noLength, accessor.fileUri);
if (!accessor.isPatch &&
!accessor.isPart &&
!target.backendTarget
@@ -391,7 +500,7 @@
noLength, accessor.fileUri);
}
}
- return builder;
+ return libraryBuilder;
}
void _ensureCoreLibrary() {
diff --git a/pkg/front_end/testing.json b/pkg/front_end/testing.json
index bc37385..cc90a5b 100644
--- a/pkg/front_end/testing.json
+++ b/pkg/front_end/testing.json
@@ -248,7 +248,7 @@
"pattern": [
"pkg/front_end/.*\\.dart$",
"pkg/front_end/.*\\.crash_dart$",
- "tests/.*\\.dart$"
+ "/tests/.*\\.dart$"
],
"exclude": []
},
diff --git a/pkg/front_end/tool/dart_doctest_impl.dart b/pkg/front_end/tool/dart_doctest_impl.dart
index 3ef774c..1e51b84 100644
--- a/pkg/front_end/tool/dart_doctest_impl.dart
+++ b/pkg/front_end/tool/dart_doctest_impl.dart
@@ -51,6 +51,7 @@
show useImplicitCreationExpressionInCfe;
// ignore: import_of_legacy_library_into_null_safe
import 'package:front_end/src/fasta/source/source_library_builder.dart';
+import 'package:front_end/src/fasta/source/source_loader.dart';
import 'package:front_end/src/fasta/uri_translator.dart';
import 'package:kernel/kernel.dart' as kernel
show Combinator, Component, LibraryDependency, Library, Location, Source;
@@ -878,7 +879,20 @@
: super(fileSystem, includeComments, dillTarget, uriTranslator);
@override
- LibraryBuilder createLibraryBuilder(
+ SourceLoader createLoader() {
+ return new DocTestSourceLoader(compiler, fileSystem, includeComments, this);
+ }
+}
+
+class DocTestSourceLoader extends SourceLoader {
+ final DocTestIncrementalCompiler compiler;
+
+ DocTestSourceLoader(this.compiler, FileSystem fileSystem,
+ bool includeComments, DocTestIncrementalKernelTarget target)
+ : super(fileSystem, includeComments, target);
+
+ @override
+ SourceLibraryBuilder createLibraryBuilder(
Uri uri,
Uri fileUri,
Uri? packageUri,
diff --git a/tests/standalone/io/socket_source_address_test.dart b/tests/standalone/io/socket_source_address_test.dart
index 1e7eb34..e8e5b23 100644
--- a/tests/standalone/io/socket_source_address_test.dart
+++ b/tests/standalone/io/socket_source_address_test.dart
@@ -8,7 +8,7 @@
import 'test_utils.dart' show retry, throws, withTempDir;
-Future testArguments(connectFunction, String socketDir) async {
+Future testArguments(connectFunction) async {
var sourceAddress;
final serverIPv4 = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0);
serverIPv4.listen((_) {
@@ -20,12 +20,6 @@
throw 'Unexpected connection from address $sourceAddress';
});
- ServerSocket serverUnix = await ServerSocket.bind(
- InternetAddress('$socketDir/sock', type: InternetAddressType.unix), 0);
- serverUnix.listen((_) {
- throw 'Unexpected connection from address $sourceAddress';
- });
-
// Illegal type for sourceAddress.
for (sourceAddress in ['www.google.com', 'abc']) {
await throws(
@@ -46,7 +40,7 @@
for (sourceAddress in [
'::1',
InternetAddress.loopbackIPv6,
- InternetAddress('$socketDir/sock', type: InternetAddressType.unix)
+ InternetAddress('sock', type: InternetAddressType.unix)
]) {
await throws(
() => connectFunction('127.0.0.1', serverIPv4.port,
@@ -57,13 +51,26 @@
for (sourceAddress in [
'127.0.0.1',
InternetAddress.loopbackIPv4,
- InternetAddress('$socketDir/sock', type: InternetAddressType.unix)
+ InternetAddress('sock', type: InternetAddressType.unix)
]) {
await throws(
() => connectFunction('::1', serverIPv6.port,
sourceAddress: sourceAddress),
(e) => e is SocketException);
}
+
+ await serverIPv4.close();
+ await serverIPv6.close();
+}
+
+Future testUnixDomainArguments(connectFunction, String socketDir) async {
+ var sourceAddress;
+ final serverUnix = await ServerSocket.bind(
+ InternetAddress('$socketDir/sock', type: InternetAddressType.unix), 0);
+ serverUnix.listen((_) {
+ throw 'Unexpected connection from address $sourceAddress';
+ });
+
// Address family mismatch for Unix domain sockets.
for (sourceAddress in [
'127.0.0.1',
@@ -80,8 +87,6 @@
e is SocketException &&
e.toString().contains('Address family not supported'));
}
- await serverIPv4.close();
- await serverIPv6.close();
await serverUnix.close();
}
@@ -156,16 +161,24 @@
main() async {
await retry(() async {
- await withTempDir('unix_socket_test', (Directory dir) async {
- await testArguments(RawSocket.connect, "${dir.path}");
- });
+ await testArguments(RawSocket.connect);
});
await retry(() async {
- await withTempDir('unix_socket_test', (Directory dir) async {
- await testArguments(Socket.connect, "${dir.path}");
- });
+ await testArguments(Socket.connect);
});
+ if (Platform.isMacOS || Platform.isLinux || Platform.isAndroid) {
+ await retry(() async {
+ await withTempDir('unix_socket_test', (Directory dir) async {
+ await testUnixDomainArguments(RawSocket.connect, "${dir.path}");
+ });
+ });
+ await retry(() async {
+ await withTempDir('unix_socket_test', (Directory dir) async {
+ await testUnixDomainArguments(Socket.connect, "${dir.path}");
+ });
+ });
+ }
await retry(() async {
await testConnect(
InternetAddress.anyIPv4, false, RawSocket.connect, (s) => s.close());
diff --git a/tests/standalone_2/io/socket_source_address_test.dart b/tests/standalone_2/io/socket_source_address_test.dart
index 7e77209..f118367 100644
--- a/tests/standalone_2/io/socket_source_address_test.dart
+++ b/tests/standalone_2/io/socket_source_address_test.dart
@@ -10,7 +10,7 @@
import 'test_utils.dart' show retry, throws, withTempDir;
-Future testArguments(connectFunction, String socketDir) async {
+Future testArguments(connectFunction) async {
var sourceAddress;
final serverIPv4 = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0);
serverIPv4.listen((_) {
@@ -22,12 +22,6 @@
throw 'Unexpected connection from address $sourceAddress';
});
- ServerSocket serverUnix = await ServerSocket.bind(
- InternetAddress('$socketDir/sock', type: InternetAddressType.unix), 0);
- serverUnix.listen((_) {
- throw 'Unexpected connection from address $sourceAddress';
- });
-
// Illegal type for sourceAddress.
for (sourceAddress in ['www.google.com', 'abc']) {
await throws(
@@ -48,7 +42,7 @@
for (sourceAddress in [
'::1',
InternetAddress.loopbackIPv6,
- InternetAddress('$socketDir/sock', type: InternetAddressType.unix)
+ InternetAddress('sock', type: InternetAddressType.unix)
]) {
await throws(
() => connectFunction('127.0.0.1', serverIPv4.port,
@@ -59,13 +53,26 @@
for (sourceAddress in [
'127.0.0.1',
InternetAddress.loopbackIPv4,
- InternetAddress('$socketDir/sock', type: InternetAddressType.unix)
+ InternetAddress('sock', type: InternetAddressType.unix)
]) {
await throws(
() => connectFunction('::1', serverIPv6.port,
sourceAddress: sourceAddress),
(e) => e is SocketException);
}
+
+ await serverIPv4.close();
+ await serverIPv6.close();
+}
+
+Future testUnixDomainArguments(connectFunction, String socketDir) async {
+ var sourceAddress;
+ final serverUnix = await ServerSocket.bind(
+ InternetAddress('$socketDir/sock', type: InternetAddressType.unix), 0);
+ serverUnix.listen((_) {
+ throw 'Unexpected connection from address $sourceAddress';
+ });
+
// Address family mismatch for Unix domain sockets.
for (sourceAddress in [
'127.0.0.1',
@@ -82,8 +89,6 @@
e is SocketException &&
e.toString().contains('Address family not supported'));
}
- await serverIPv4.close();
- await serverIPv6.close();
await serverUnix.close();
}
@@ -158,16 +163,24 @@
main() async {
await retry(() async {
- await withTempDir('unix_socket_test', (Directory dir) async {
- await testArguments(RawSocket.connect, "${dir.path}");
- });
+ await testArguments(RawSocket.connect);
});
await retry(() async {
- await withTempDir('unix_socket_test', (Directory dir) async {
- await testArguments(Socket.connect, "${dir.path}");
- });
+ await testArguments(Socket.connect);
});
+ if (Platform.isMacOS || Platform.isLinux || Platform.isAndroid) {
+ await retry(() async {
+ await withTempDir('unix_socket_test', (Directory dir) async {
+ await testUnixDomainArguments(RawSocket.connect, "${dir.path}");
+ });
+ });
+ await retry(() async {
+ await withTempDir('unix_socket_test', (Directory dir) async {
+ await testUnixDomainArguments(Socket.connect, "${dir.path}");
+ });
+ });
+ }
await retry(() async {
await testConnect(
InternetAddress.anyIPv4, false, RawSocket.connect, (s) => s.close());
diff --git a/tools/VERSION b/tools/VERSION
index bf0ea25..5f2e7ac 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 15
PATCH 0
-PRERELEASE 241
+PRERELEASE 242
PRERELEASE_PATCH 0
\ No newline at end of file