Avoid deprecation in source_loader
Change-Id: Idf3250bd8fcc56f7d52e3f245671d2c1b91d0956
Reviewed-on: https://dart-review.googlesource.com/63144
Reviewed-by: Aske Simon Christensen <askesc@google.com>
diff --git a/pkg/front_end/lib/src/base/processed_options.dart b/pkg/front_end/lib/src/base/processed_options.dart
index 771c58c..541a6e5 100644
--- a/pkg/front_end/lib/src/base/processed_options.dart
+++ b/pkg/front_end/lib/src/base/processed_options.dart
@@ -50,11 +50,9 @@
templateInternalProblemUnsupported,
templateSdkRootNotFound,
templateSdkSpecificationNotFound,
+ templateCantReadFile,
templateSdkSummaryNotFound;
-// TODO(ahe): Remove this import.
-import '../fasta/fasta_codes.dart' show templateUnspecified;
-
import '../fasta/messages.dart' show getLocation;
import '../fasta/problems.dart' show DebugAbort, unimplemented;
@@ -257,21 +255,6 @@
return false;
}
- for (var source in inputs) {
- // Note: we don't translate Uris at this point because some of the
- // validation further below must be done before we even construct an
- // UriTranslator
- // TODO(sigmund): consider validating dart/packages uri right after we
- // build the uri translator.
- if (source.scheme != 'dart' &&
- source.scheme != 'package' &&
- !await fileSystem.entityForUri(source).exists()) {
- reportWithoutLocation(
- templateInputFileNotFound.withArguments(source), Severity.error);
- return false;
- }
- }
-
if (_raw.sdkRoot != null &&
!await fileSystem.entityForUri(sdkRoot).exists()) {
reportWithoutLocation(
@@ -294,6 +277,8 @@
}
for (Uri source in _raw.linkedDependencies) {
+ // TODO(ahe): Remove this check, the compiler itself should handle and
+ // recover from this.
if (!await fileSystem.entityForUri(source).exists()) {
reportWithoutLocation(
templateInputFileNotFound.withArguments(source), Severity.error);
@@ -645,11 +630,8 @@
return await file.readAsBytes();
} on FileSystemException catch (error) {
report(
- // TODO(ahe): Change to templateCantReadFile.withArguments(error.uri,
- // error.message) when CL 63144 has landed.
- templateUnspecified
- .withArguments(
- "Error when reading '${error.uri}': ${error.message}")
+ templateCantReadFile
+ .withArguments(error.uri, error.message)
.withoutLocation(),
Severity.error);
return new Uint8List(0);
diff --git a/pkg/front_end/lib/src/fasta/builder/library_builder.dart b/pkg/front_end/lib/src/fasta/builder/library_builder.dart
index 2f29995..b1d0382 100644
--- a/pkg/front_end/lib/src/fasta/builder/library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/library_builder.dart
@@ -53,6 +53,8 @@
exportScopeBuilder = new ScopeBuilder(exportScope),
super(null, -1, fileUri);
+ bool get isSynthetic => false;
+
@override
Declaration get parent => null;
@@ -187,7 +189,13 @@
return 0;
}
- void becomeCoreLibrary(dynamicType);
+ void becomeCoreLibrary() {
+ if (scope.local["dynamic"] == null) {
+ addSyntheticDeclarationOfDynamic();
+ }
+ }
+
+ void addSyntheticDeclarationOfDynamic();
void forEach(void f(String name, Declaration declaration)) {
scope.forEach((String name, Declaration declaration) {
@@ -216,4 +224,6 @@
if (!isPatch) return;
unsupported("${runtimeType}.applyPatches", -1, fileUri);
}
+
+ void recordAccess(int charOffset, int length, Uri fileUri) {}
}
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
index ba16545..2838eb7 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
@@ -10,6 +10,7 @@
show
Class,
DartType,
+ DynamicType,
Field,
Library,
ListLiteral,
@@ -72,14 +73,12 @@
@override
Library get target => library;
- void becomeCoreLibrary(dynamicType) {
- if (scope.local["dynamic"] == null) {
- addBuilder(
- "dynamic",
- new DynamicTypeBuilder<KernelTypeBuilder, DartType>(
- dynamicType, this, -1),
- -1);
- }
+ void addSyntheticDeclarationOfDynamic() {
+ addBuilder(
+ "dynamic",
+ new DynamicTypeBuilder<KernelTypeBuilder, DartType>(
+ const DynamicType(), this, -1),
+ -1);
}
void addClass(Class cls) {
diff --git a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
index 3855396..994f876 100644
--- a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
+++ b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
@@ -580,6 +580,26 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Template<Message Function(Uri uri_, String string)> templateCantReadFile =
+ const Template<Message Function(Uri uri_, String string)>(
+ messageTemplate: r"""Error when reading '#uri': #string""",
+ withArguments: _withArgumentsCantReadFile);
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Code<Message Function(Uri uri_, String string)> codeCantReadFile =
+ const Code<Message Function(Uri uri_, String string)>(
+ "CantReadFile", templateCantReadFile,
+ analyzerCode: "URI_DOES_NOT_EXIST");
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+Message _withArgumentsCantReadFile(Uri uri_, String string) {
+ String uri = relativizeUri(uri_);
+ return new Message(codeCantReadFile,
+ message: """Error when reading '${uri}': ${string}""",
+ arguments: {'uri': uri_, 'string': string});
+}
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
Token
@@ -7427,6 +7447,25 @@
const MessageCode("UnterminatedToken", message: r"""Incomplete token.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Template<Message Function(Uri uri_)> templateUntranslatableUri =
+ const Template<Message Function(Uri uri_)>(
+ messageTemplate: r"""Not found: '#uri'""",
+ withArguments: _withArgumentsUntranslatableUri);
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Code<Message Function(Uri uri_)> codeUntranslatableUri =
+ const Code<Message Function(Uri uri_)>(
+ "UntranslatableUri", templateUntranslatableUri,
+ analyzerCode: "URI_DOES_NOT_EXIST");
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+Message _withArgumentsUntranslatableUri(Uri uri_) {
+ String uri = relativizeUri(uri_);
+ return new Message(codeUntranslatableUri,
+ message: """Not found: '${uri}'""", arguments: {'uri': uri_});
+}
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<Message Function(String name)>
templateUseOfDeprecatedIdentifier =
const Template<Message Function(String name)>(
diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
index f9a4ca8..b1ed5a3 100644
--- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart
+++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
@@ -490,7 +490,8 @@
assert(dillLoadedData != null && userCode != null);
return await context.runInContext((_) async {
- LibraryBuilder library = userCode.loader.read(libraryUri, -1);
+ LibraryBuilder library =
+ userCode.loader.read(libraryUri, -1, accessor: userCode.loader.first);
Class kernelClass;
if (className != null) {
@@ -600,8 +601,8 @@
List<Uri> invalidatedImportUris = <Uri>[];
bool isInvalidated(Uri importUri, Uri fileUri) {
- if (invalidatedUris.contains(importUri) ||
- (importUri != fileUri && invalidatedUris.contains(fileUri))) {
+ if (invalidatedUris.contains(importUri)) return true;
+ if (importUri != fileUri && invalidatedUris.contains(fileUri)) {
return true;
}
if (hasToCheckPackageUris &&
@@ -609,6 +610,7 @@
uriTranslator.translate(importUri, false) != fileUri) {
return true;
}
+ if (builders[importUri]?.isSynthetic == true) return true;
return false;
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
index 7b48148..d153f1c 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
@@ -12,6 +12,7 @@
Class,
ConstructorInvocation,
DartType,
+ DynamicType,
Expression,
Field,
Library,
@@ -162,14 +163,12 @@
Uri get uri => library.importUri;
- void becomeCoreLibrary(dynamicType) {
- if (scope.local["dynamic"] == null) {
- addBuilder(
- "dynamic",
- new DynamicTypeBuilder<KernelTypeBuilder, DartType>(
- dynamicType, this, -1),
- -1);
- }
+ void addSyntheticDeclarationOfDynamic() {
+ addBuilder(
+ "dynamic",
+ new DynamicTypeBuilder<KernelTypeBuilder, DartType>(
+ const DynamicType(), this, -1),
+ -1);
}
KernelTypeBuilder addNamedType(
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 86122bb..5daa713 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -15,7 +15,6 @@
Component,
Constructor,
DartType,
- DynamicType,
EmptyStatement,
Expression,
ExpressionStatement,
@@ -151,7 +150,7 @@
}
void read(Uri uri) {
- loader.read(uri, -1);
+ loader.read(uri, -1, accessor: loader.first);
}
@override
@@ -238,7 +237,7 @@
() async {
loader.createTypeInferenceEngine();
await loader.buildOutlines();
- loader.coreLibrary.becomeCoreLibrary(const DynamicType());
+ loader.coreLibrary.becomeCoreLibrary();
dynamicType.bind(loader.coreLibrary["dynamic"]);
loader.resolveParts();
loader.computeLibraryScopes();
@@ -810,13 +809,13 @@
KernelLibraryBuilder first;
for (Uri patch in patches) {
if (first == null) {
- first =
- library.loader.read(patch, -1, fileUri: patch, origin: library);
+ first = library.loader.read(patch, -1,
+ fileUri: patch, origin: library, accessor: library);
} else {
// If there's more than one patch file, it's interpreted as a part of
// the patch library.
KernelLibraryBuilder part =
- library.loader.read(patch, -1, fileUri: patch);
+ library.loader.read(patch, -1, fileUri: patch, accessor: first);
first.parts.add(part);
part.addPartOf(null, null, "${first.uri}", -1);
}
diff --git a/pkg/front_end/lib/src/fasta/loader.dart b/pkg/front_end/lib/src/fasta/loader.dart
index f1f9d5c..0d794a7 100644
--- a/pkg/front_end/lib/src/fasta/loader.dart
+++ b/pkg/front_end/lib/src/fasta/loader.dart
@@ -23,7 +23,7 @@
templateInternalProblemContextSeverity,
templateSourceBodySummary;
-import 'problems.dart' show internalProblem;
+import 'problems.dart' show internalProblem, unhandled;
import 'rewrite_severity.dart' show rewriteSeverity;
@@ -35,6 +35,8 @@
import 'type_inference/type_inference_engine.dart' show TypeInferenceEngine;
+const String untranslatableUriScheme = "org-dartlang-untranslatable-uri";
+
abstract class Loader<L> {
final Map<Uri, LibraryBuilder> builders = <Uri, LibraryBuilder>{};
@@ -78,6 +80,8 @@
TypeInferenceEngine get typeInferenceEngine => null;
+ bool get isSourceLoader => false;
+
/// Look up a library builder by the name [uri], or if such doesn't
/// exist, create one. The canonical URI of the library is [uri], and its
/// actual location is [fileUri].
@@ -102,7 +106,10 @@
switch (uri.scheme) {
case "package":
case "dart":
- fileUri = target.translateUri(uri);
+ fileUri = target.translateUri(uri) ??
+ new Uri(
+ scheme: untranslatableUriScheme,
+ path: Uri.encodeComponent("$uri"));
break;
default:
@@ -114,9 +121,11 @@
target.createLibraryBuilder(uri, fileUri, origin);
if (uri.scheme == "dart" && uri.path == "core") {
coreLibrary = library;
- target.loadExtraRequiredLibraries(this);
}
if (library.loader != this) {
+ if (coreLibrary == library) {
+ target.loadExtraRequiredLibraries(this);
+ }
// This library isn't owned by this loader, so not further processing
// should be attempted.
return library;
@@ -129,6 +138,9 @@
firstSourceUri ??= uri;
first ??= library;
}
+ if (coreLibrary == library) {
+ target.loadExtraRequiredLibraries(this);
+ }
if (target.backendTarget.mayDefineRestrictedType(origin?.uri ?? uri)) {
library.mayImplementRestrictedTypes = true;
}
@@ -138,19 +150,25 @@
unparsedLibraries.addLast(library);
return library;
});
- if (accessor != null &&
- !accessor.isPatch &&
- !target.backendTarget
- .allowPlatformPrivateLibraryAccess(accessor.uri, uri)) {
- accessor.addProblem(messagePlatformPrivateLibraryAccess, charOffset,
- noLength, accessor.fileUri);
+ if (accessor == null) {
+ if (builder.loader == this && first != builder && isSourceLoader) {
+ unhandled("null", "accessor", charOffset, uri);
+ }
+ } else {
+ builder.recordAccess(charOffset, noLength, accessor.fileUri);
+ if (!accessor.isPatch &&
+ !target.backendTarget
+ .allowPlatformPrivateLibraryAccess(accessor.uri, uri)) {
+ accessor.addProblem(messagePlatformPrivateLibraryAccess, charOffset,
+ noLength, accessor.fileUri);
+ }
}
return builder;
}
void ensureCoreLibrary() {
if (coreLibrary == null) {
- read(Uri.parse("dart:core"), -1);
+ read(Uri.parse("dart:core"), 0, accessor: first);
assert(coreLibrary != null);
}
}
diff --git a/pkg/front_end/lib/src/fasta/rewrite_severity.dart b/pkg/front_end/lib/src/fasta/rewrite_severity.dart
index ae106ad..6ffcfb2 100644
--- a/pkg/front_end/lib/src/fasta/rewrite_severity.dart
+++ b/pkg/front_end/lib/src/fasta/rewrite_severity.dart
@@ -48,7 +48,6 @@
case "kernel/body_builder.dart":
case "source/diet_listener.dart":
case "source/source_library_builder.dart":
- case "source/source_loader.dart":
return severity;
}
} else if (code == msg.codeMissingExplicitTypeArguments) {
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index a96b82c..62794ae 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -40,6 +40,7 @@
import '../fasta_codes.dart'
show
+ Message,
messageConstructorWithWrongName,
messageExpectedUri,
messageMemberWithSameNameAsClass,
@@ -98,6 +99,8 @@
@override
final bool disableTypeInference;
+ final List<Object> accessors = <Object>[];
+
String documentationComment;
String name;
@@ -116,6 +119,10 @@
bool canAddImplementationBuilders = false;
+ /// Non-null if this library causes an error upon access, that is, there was
+ /// an error reading its source.
+ Message accessProblem;
+
SourceLibraryBuilder(SourceLoader loader, Uri fileUri, Scope scope)
: this.fromScopes(loader, fileUri, new DeclarationBuilder<T>.library(),
scope ?? new Scope.top());
@@ -134,6 +141,9 @@
List<UnresolvedType<T>> get types => libraryDeclaration.types;
+ @override
+ bool get isSynthetic => accessProblem != null;
+
T addNamedType(Object name, List<T> arguments, int charOffset);
T addMixinApplication(T supertype, List<T> mixins, int charOffset);
@@ -308,7 +318,7 @@
}
} else {
resolvedUri = resolve(this.uri, uri, uriOffset);
- builder = loader.read(resolvedUri, charOffset, accessor: this);
+ builder = loader.read(resolvedUri, uriOffset, accessor: this);
}
imports.add(new Import(this, builder, deferred, prefix, combinators,
@@ -759,6 +769,33 @@
member.instrumentTopLevelInference(instrumentation);
});
}
+
+ @override
+ void recordAccess(int charOffset, int length, Uri fileUri) {
+ accessors.add(fileUri);
+ accessors.add(charOffset);
+ accessors.add(length);
+ if (accessProblem != null) {
+ addProblem(accessProblem, charOffset, length, fileUri);
+ }
+ }
+
+ void addProblemAtAccessors(Message message) {
+ if (accessProblem == null) {
+ if (accessors.isEmpty && this == loader.first) {
+ // This is the entry point library, and nobody access it directly. So
+ // we need to report a problem.
+ loader.addProblem(message, -1, 1, null);
+ }
+ for (int i = 0; i < accessors.length; i += 3) {
+ Uri accessor = accessors[i];
+ int charOffset = accessors[i + 1];
+ int length = accessors[i + 2];
+ addProblem(message, charOffset, length, accessor);
+ }
+ accessProblem = message;
+ }
+ }
}
/// Unlike [Scope], this scope is used during construction of builders to
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 9f48ebd..fa1b8fb 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -6,6 +6,8 @@
import 'dart:async' show Future;
+import 'dart:convert' show utf8;
+
import 'dart:typed_data' show Uint8List;
import 'package:kernel/ast.dart'
@@ -45,18 +47,17 @@
NamedTypeBuilder,
TypeBuilder;
-import '../deprecated_problems.dart' show deprecated_inputError;
-
import '../export.dart' show Export;
import '../fasta_codes.dart'
show
LocatedMessage,
Message,
- noLength,
SummaryTemplate,
Template,
+ noLength,
templateAmbiguousSupertypes,
+ templateCantReadFile,
templateCyclicClassHierarchy,
templateExtendingEnum,
templateExtendingRestricted,
@@ -64,7 +65,8 @@
templateIllegalMixinDueToConstructors,
templateIllegalMixinDueToConstructorsCause,
templateInternalProblemUriMissingScheme,
- templateSourceOutlineSummary;
+ templateSourceOutlineSummary,
+ templateUntranslatableUri;
import '../fasta_codes.dart' as fasta_codes;
@@ -77,7 +79,7 @@
import '../kernel/body_builder.dart' show BodyBuilder;
-import '../loader.dart' show Loader;
+import '../loader.dart' show Loader, untranslatableUriScheme;
import '../parser/class_member_parser.dart' show ClassMemberParser;
@@ -138,37 +140,55 @@
Template<SummaryTemplate> get outlineSummaryTemplate =>
templateSourceOutlineSummary;
+ bool get isSourceLoader => true;
+
Future<Token> tokenize(SourceLibraryBuilder library,
{bool suppressLexicalErrors: false}) async {
Uri uri = library.fileUri;
- if (uri == null) {
- return deprecated_inputError(
- library.uri, -1, "Not found: ${library.uri}.");
- } else if (!uri.hasScheme) {
- return internalProblem(
- templateInternalProblemUriMissingScheme.withArguments(uri),
- -1,
- library.uri);
- } else if (uri.scheme == SourceLibraryBuilder.MALFORMED_URI_SCHEME) {
- // Simulate empty file
- return null;
- }
- // Get the library text from the cache, or read from the file system.
+ // Lookup the file URI in the cache.
List<int> bytes = sourceBytes[uri];
+
if (bytes == null) {
- try {
- List<int> rawBytes = await fileSystem.entityForUri(uri).readAsBytes();
- Uint8List zeroTerminatedBytes = new Uint8List(rawBytes.length + 1);
- zeroTerminatedBytes.setRange(0, rawBytes.length, rawBytes);
+ // Error recovery.
+ if (uri.scheme == untranslatableUriScheme) {
+ Message message = templateUntranslatableUri.withArguments(library.uri);
+ library.addProblemAtAccessors(message);
+ bytes = synthesizeSourceForMissingFile(library.uri, null);
+ } else if (!uri.hasScheme) {
+ return internalProblem(
+ templateInternalProblemUriMissingScheme.withArguments(uri),
+ -1,
+ library.uri);
+ } else if (uri.scheme == SourceLibraryBuilder.MALFORMED_URI_SCHEME) {
+ bytes = synthesizeSourceForMissingFile(library.uri, null);
+ }
+ if (bytes != null) {
+ Uint8List zeroTerminatedBytes = new Uint8List(bytes.length + 1);
+ zeroTerminatedBytes.setRange(0, bytes.length, bytes);
bytes = zeroTerminatedBytes;
sourceBytes[uri] = bytes;
- byteCount += rawBytes.length;
- } on FileSystemException catch (e) {
- return deprecated_inputError(uri, -1, e.message);
}
}
+ if (bytes == null) {
+ // If it isn't found in the cache, read the file read from the file
+ // system.
+ List<int> rawBytes;
+ try {
+ rawBytes = await fileSystem.entityForUri(uri).readAsBytes();
+ } on FileSystemException catch (e) {
+ Message message = templateCantReadFile.withArguments(uri, e.message);
+ library.addProblemAtAccessors(message);
+ rawBytes = synthesizeSourceForMissingFile(library.uri, message);
+ }
+ Uint8List zeroTerminatedBytes = new Uint8List(rawBytes.length + 1);
+ zeroTerminatedBytes.setRange(0, rawBytes.length, rawBytes);
+ bytes = zeroTerminatedBytes;
+ sourceBytes[uri] = bytes;
+ byteCount += rawBytes.length;
+ }
+
ScannerResult result = scan(bytes, includeComments: includeComments);
Token token = result.tokens;
if (!suppressLexicalErrors) {
@@ -186,6 +206,19 @@
return token;
}
+ List<int> synthesizeSourceForMissingFile(Uri uri, Message message) {
+ switch ("$uri") {
+ case "dart:core":
+ return utf8.encode(defaultDartCoreSource);
+
+ case "dart:async":
+ return utf8.encode(defaultDartAsyncSource);
+
+ default:
+ return utf8.encode(message == null ? "" : "/* ${message.message} */");
+ }
+ }
+
List<int> getSource(List<int> bytes) {
// bytes is 0-terminated. We don't want that included.
if (bytes is Uint8List) {
@@ -612,7 +645,7 @@
if (library.loader == this) {
SourceLibraryBuilder sourceLibrary = library;
L target = sourceLibrary.build(coreLibrary);
- if (!library.isPatch) {
+ if (!library.isPatch && !library.isSynthetic) {
libraries.add(target);
}
}
@@ -947,3 +980,117 @@
typeInferenceEngine = null;
}
}
+
+const String defaultDartCoreSource = """
+import 'dart:_internal';
+import 'dart:async';
+
+print(object) {}
+
+class Iterator {}
+
+class Iterable {}
+
+class List extends Iterable {
+ factory List.unmodifiable(elements) => null;
+}
+
+class Map extends Iterable {
+ factory Map.unmodifiable(other) => null;
+}
+
+class NoSuchMethodError {
+ NoSuchMethodError.withInvocation(receiver, invocation);
+}
+
+class Null {}
+
+class Object {
+ noSuchMethod(invocation) => null;
+}
+
+class String {}
+
+class Symbol {}
+
+class Type {}
+
+class _InvocationMirror {
+ _InvocationMirror._withType(_memberName, _type, _typeArguments,
+ _positionalArguments, _namedArguments);
+}
+
+class bool {}
+
+class double extends num {}
+
+class int extends num {}
+
+class num {}
+
+class _SyncIterable {}
+
+class _SyncIterator {
+ var _current;
+ var _yieldEachIterable;
+}
+""";
+
+const String defaultDartAsyncSource = """
+_asyncErrorWrapperHelper(continuation) {}
+
+_asyncStackTraceHelper(async_op) {}
+
+_asyncThenWrapperHelper(continuation) {}
+
+_awaitHelper(object, thenCallback, errorCallback, awaiter) {}
+
+_completeOnAsyncReturn(completer, value) {}
+
+class _AsyncStarStreamController {
+ add(event) {}
+
+ addError(error, stackTrace) {}
+
+ addStream(stream) {}
+
+ close() {}
+
+ get stream => null;
+}
+
+class Completer {
+ factory Completer.sync() => null;
+
+ get future;
+
+ complete([value]);
+
+ completeError(error, [stackTrace]);
+}
+
+class Future {
+ factory Future.microtask(computation) => null;
+}
+
+class FutureOr {
+}
+
+class _AsyncAwaitCompleter implements Completer {
+ get future => null;
+
+ complete([value]) {}
+
+ completeError(error, [stackTrace]) {}
+}
+
+class Stream {}
+
+class _StreamIterator {
+ get current => null;
+
+ moveNext() {}
+
+ cancel() {}
+}
+""";
diff --git a/pkg/front_end/lib/src/fasta/target_implementation.dart b/pkg/front_end/lib/src/fasta/target_implementation.dart
index 3361321..08581aa 100644
--- a/pkg/front_end/lib/src/fasta/target_implementation.dart
+++ b/pkg/front_end/lib/src/fasta/target_implementation.dart
@@ -94,13 +94,14 @@
/// type String, which is the name of the native method.
Declaration getNativeAnnotation(Loader loader) {
if (cachedNativeAnnotation != null) return cachedNativeAnnotation;
- LibraryBuilder internal = loader.read(Uri.parse("dart:_internal"), -1);
+ LibraryBuilder internal = loader.read(Uri.parse("dart:_internal"), -1,
+ accessor: loader.coreLibrary);
return cachedNativeAnnotation = internal.getConstructor("ExternalName");
}
void loadExtraRequiredLibraries(Loader loader) {
for (String uri in backendTarget.extraRequiredLibraries) {
- loader.read(Uri.parse(uri), -1);
+ loader.read(Uri.parse(uri), 0, accessor: loader.coreLibrary);
}
}
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index c527e0a..9bbe9e3 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -2768,3 +2768,21 @@
factory A.f({int x = 42}) = A.g;
A.g() {}
}
+
+UntranslatableUri:
+ template: "Not found: '#uri'"
+ analyzerCode: URI_DOES_NOT_EXIST
+ script: |
+ import "dart:non_existing_library";
+
+ main() {
+ }
+
+CantReadFile:
+ template: "Error when reading '#uri': #string"
+ analyzerCode: URI_DOES_NOT_EXIST
+ script: |
+ import "non_existing_file.dart";
+
+ main() {
+ }
diff --git a/pkg/front_end/test/incremental_load_from_dill_test.dart b/pkg/front_end/test/incremental_load_from_dill_test.dart
index 70f828e..68f91f0 100644
--- a/pkg/front_end/test/incremental_load_from_dill_test.dart
+++ b/pkg/front_end/test/incremental_load_from_dill_test.dart
@@ -35,6 +35,8 @@
import 'package:kernel/target/targets.dart' show TargetFlags;
+import 'package:kernel/text/ast_to_text.dart' show componentToString;
+
import "package:testing/testing.dart"
show Chain, ChainContext, Result, Step, TestDescription, runMe;
@@ -277,6 +279,7 @@
util.throwOnEmptyMixinBodies(component);
print("Compile took ${stopwatch.elapsedMilliseconds} ms");
newestWholeComponent = serializeComponent(component);
+ print("*****\n\ncomponent:\n${componentToString(component)}\n\n\n");
if (component.libraries.length != world["expectedLibraryCount"]) {
throw "Expected ${world["expectedLibraryCount"]} libraries, "
"got ${component.libraries.length}";
@@ -317,6 +320,7 @@
performErrorAndWarningCheck(
world, gotError, formattedErrors, gotWarning, formattedWarnings);
List<int> thisWholeComponent = serializeComponent(component2);
+ print("*****\n\ncomponent2:\n${componentToString(component2)}\n\n\n");
checkIsEqual(newestWholeComponent, thisWholeComponent);
}
}
diff --git a/pkg/front_end/test/src/base/processed_options_test.dart b/pkg/front_end/test/src/base/processed_options_test.dart
index 2e74c1d..f7f4fcf 100644
--- a/pkg/front_end/test/src/base/processed_options_test.dart
+++ b/pkg/front_end/test/src/base/processed_options_test.dart
@@ -344,9 +344,8 @@
..onError = (e) => errors.add(e);
var options = new ProcessedOptions(raw, [Uri.parse('foo.dart')]);
var result = await options.validateOptions();
- expect(errors.single.message,
- startsWith(_stringPrefixOf(templateInputFileNotFound)));
- expect(result, isFalse);
+ expect(errors, isEmpty);
+ expect(result, isTrue);
}
test_validateOptions_root_exists() async {
diff --git a/pkg/front_end/testcases/compile.status b/pkg/front_end/testcases/compile.status
index ba0d63c..8f7efbe 100644
--- a/pkg/front_end/testcases/compile.status
+++ b/pkg/front_end/testcases/compile.status
@@ -6,28 +6,16 @@
# testing generating Kernel ASTs directly, that is, code in
# pkg/fasta/lib/src/kernel/.
-rasta/unsupported_platform_library: RuntimeError # OK, this must report an error at runtime.
-
DeltaBlue: Fail # Fasta and dartk disagree on static initializers
+ambiguous_exports: RuntimeError # Expected, this file exports two main methods.
bug31124: RuntimeError # Test has an intentional error
call: Fail # Test can't run.
+co19_language_metadata_syntax_t04: RuntimeError # Fasta doesn't recover well
+constructor_const_inference: RuntimeError # Test exercises strong mode semantics. See also Issue #33813.
+external_import: RuntimeError # Expected -- test uses import which doesn't exist.
fallthrough: Fail # Missing FallThroughError.
function_type_recovery: Fail
-invocations: Fail
-micro: Fail # External method marked abstract.
-named_parameters: Fail # Missing types and unnecessary default values.
-optional: Fail # Unnecessary default values.
-redirecting_factory: Fail # Missing types on constructor parameters.
-redirecting_factory_chain_test: Fail # Missing support for RedirectingFactoryConstructor.
-redirecting_factory_simple_test: Fail # Missing support for RedirectingFactoryConstructor.
-redirecting_factory_typeargs_test: Fail # Missing support for RedirectingFactoryConstructor.
-redirecting_factory_typeparam_test: Fail # Missing support for RedirectingFactoryConstructor.
-redirecting_factory_typeparambounds_test: Fail # Missing support for RedirectingFactoryConstructor.
-statements: Fail # Make async tranformer optional for golden file testing.
-type_variable_as_super: Fail
-uninitialized_fields: Fail # Fasta and dartk disagree on static initializers
-void_methods: Fail # Bad return from setters.
-
+incomplete_field_formal_parameter: Fail # Fasta doesn't recover well
inference/bug31436: RuntimeError # Test exercises Dart 2.0 semantics
inference/constructors_too_many_positional_arguments: Fail
inference/downwards_inference_annotations_locals: Fail # Issue #30031
@@ -41,11 +29,13 @@
inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param_via_expr1: Fail
inference/unsafe_block_closure_inference_function_call_explicit_type_param_via_expr1: Fail
inference/unsafe_block_closure_inference_function_call_explicit_type_param_via_expr2: RuntimeError
-
instantiate_to_bound/body_typedef_super_bounded_type: Fail # Issue 33444
instantiate_to_bound/non_simple_class_parametrized_typedef_cycle: RuntimeError # May be related to Issue 33479
instantiate_to_bound/typedef_super_bounded_type: Fail # Issue 33444
-
+invocations: Fail
+micro: Fail # External method marked abstract.
+named_parameters: Fail # Missing types and unnecessary default values.
+optional: Fail # Unnecessary default values.
rasta/abstract_constructor: Fail
rasta/bad_constructor_redirection: Fail
rasta/bad_continue: Fail
@@ -62,7 +52,10 @@
rasta/constant_get_and_invoke: Fail
rasta/deferred_lib: Fail
rasta/deferred_load: Fail
+rasta/duplicated_mixin: RuntimeError # Expected, this file has no main method.
+rasta/export: RuntimeError # Expected, this file has no main method.
rasta/external_factory_redirection: Fail
+rasta/foo: RuntimeError # Expected, this file has no main method.
rasta/for_loop: Fail
rasta/generic_factory: Fail
rasta/issue_000001: Fail
@@ -98,15 +91,20 @@
rasta/unresolved_constructor: Fail
rasta/unresolved_for_in: RuntimeError # Test contains a compile-time error, signaled at run time in the JIT VM
rasta/unresolved_recovery: Fail
-
+redirecting_factory: Fail # Missing types on constructor parameters.
+redirecting_factory_chain_test: Fail # Missing support for RedirectingFactoryConstructor.
+redirecting_factory_const_inference: RuntimeError # Test exercises strong mode semantics. See also Issue #33813.
+redirecting_factory_simple_test: Fail # Missing support for RedirectingFactoryConstructor.
+redirecting_factory_typeargs_test: Fail # Missing support for RedirectingFactoryConstructor.
+redirecting_factory_typeparam_test: Fail # Missing support for RedirectingFactoryConstructor.
+redirecting_factory_typeparambounds_test: Fail # Missing support for RedirectingFactoryConstructor.
regress/issue_29975: Fail # Issue 29975.
regress/issue_29976: RuntimeError # Issue 29976.
regress/issue_29982: Fail # Issue 29982.
regress/issue_30836: RuntimeError # Issue 30836.
-regress/issue_33452: RuntimeError # Test has an intentional error
regress/issue_32972: RuntimeError
+regress/issue_33452: RuntimeError # Test has an intentional error
regress/issue_34225: RuntimeError
-
runtime_checks/implicit_downcast_constructor_initializer: RuntimeError # Test exercises strong mode semantics
runtime_checks/implicit_downcast_do: RuntimeError # Test exercises strong mode semantics
runtime_checks/implicit_downcast_for_condition: RuntimeError # Test exercises strong mode semantics
@@ -119,15 +117,7 @@
runtime_checks_new/mixin_forwarding_stub_getter: RuntimeError # Test exercises strong mode semantics
runtime_checks_new/mixin_forwarding_stub_setter: RuntimeError # Test exercises strong mode semantics
runtime_checks_new/stub_checked_via_target: RuntimeError # Test exercises strong mode semantics
-constructor_const_inference: RuntimeError # Test exercises strong mode semantics. See also Issue #33813.
-redirecting_factory_const_inference: RuntimeError # Test exercises strong mode semantics. See also Issue #33813.
-
-ambiguous_exports: RuntimeError # Expected, this file exports two main methods.
-rasta/duplicated_mixin: RuntimeError # Expected, this file has no main method.
-rasta/export: RuntimeError # Expected, this file has no main method.
-rasta/foo: RuntimeError # Expected, this file has no main method.
-
-incomplete_field_formal_parameter: Fail # Fasta doesn't recover well
-
-co19_language_metadata_syntax_t04: RuntimeError # Fasta doesn't recover well
-external_import: RuntimeError # Expected -- test uses import which doesn't exist.
+statements: Fail # Make async tranformer optional for golden file testing.
+type_variable_as_super: Fail
+uninitialized_fields: Fail # Fasta and dartk disagree on static initializers
+void_methods: Fail # Bad return from setters.
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/deleting_file.yaml b/pkg/front_end/testcases/incremental_initialize_from_dill/deleting_file.yaml
index 970db47..2933c37 100644
--- a/pkg/front_end/testcases/incremental_initialize_from_dill/deleting_file.yaml
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/deleting_file.yaml
@@ -24,7 +24,7 @@
expectedLibraryCount: 2
- entry: main.dart
errors: true
- warnings: false
+ warnings: true
invalidate:
- b.dart
sources:
@@ -37,7 +37,7 @@
expectedLibraryCount: 1
- entry: main.dart
errors: true
- warnings: false
+ warnings: true
checkInvalidatedFiles: false
worldType: updated
invalidate:
@@ -52,7 +52,7 @@
expectedLibraryCount: 1
- entry: main.dart
errors: true
- warnings: false
+ warnings: true
checkInvalidatedFiles: false
worldType: updated
invalidate:
@@ -64,4 +64,4 @@
print("Hello no. 1");
b();
}
- expectedLibraryCount: 1
\ No newline at end of file
+ expectedLibraryCount: 1
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/invaldation_across_compile_time_error.yaml b/pkg/front_end/testcases/incremental_initialize_from_dill/invalidation_across_compile_time_error.yaml
similarity index 96%
rename from pkg/front_end/testcases/incremental_initialize_from_dill/invaldation_across_compile_time_error.yaml
rename to pkg/front_end/testcases/incremental_initialize_from_dill/invalidation_across_compile_time_error.yaml
index f1213e3..c627364 100644
--- a/pkg/front_end/testcases/incremental_initialize_from_dill/invaldation_across_compile_time_error.yaml
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/invalidation_across_compile_time_error.yaml
@@ -40,7 +40,7 @@
sources:
main.dart: |
import "b.dart";
- import "nonexistin.dart";
+ import "nonexisting.dart";
main() {
print("hello");
b();
@@ -52,7 +52,7 @@
c();
}
errors: true
- expectedLibraryCount: 1
+ expectedLibraryCount: 3
- entry: main.dart
worldType: updated
expectInitializeFromDill: false
@@ -66,4 +66,4 @@
print("hello");
b();
}
- expectedLibraryCount: 3
\ No newline at end of file
+ expectedLibraryCount: 3
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/updated_package_4.yaml b/pkg/front_end/testcases/incremental_initialize_from_dill/updated_package_4.yaml
index 84a4e54..b59c18e 100644
--- a/pkg/front_end/testcases/incremental_initialize_from_dill/updated_package_4.yaml
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/updated_package_4.yaml
@@ -32,4 +32,5 @@
sources:
.packages:
errors: true
- expectedLibraryCount: 1
\ No newline at end of file
+ warnings: true
+ expectedLibraryCount: 1
diff --git a/pkg/front_end/testcases/rasta/unsupported_platform_library.dart b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart
index ca1de9b..fa8123d 100644
--- a/pkg/front_end/testcases/rasta/unsupported_platform_library.dart
+++ b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart
@@ -4,3 +4,5 @@
import 'dart:html';
import 'dart:io';
+
+main() {}
diff --git a/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.direct.expect b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.direct.expect
index 7073760..0c3e32a 100644
--- a/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.direct.expect
+++ b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.direct.expect
@@ -1,6 +1,10 @@
+// Errors:
+//
+// pkg/front_end/testcases/rasta/unsupported_platform_library.dart:5:8: Error: Not found: 'dart:html'
+// import 'dart:html';
+// ^
+
library;
import self as self;
-static method #main() → dynamic {
- throw "dart:html:1: Error: Not found: dart:html.";
-}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.direct.transformed.expect b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.direct.transformed.expect
index 7073760..0c3e32a 100644
--- a/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.direct.transformed.expect
+++ b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.direct.transformed.expect
@@ -1,6 +1,10 @@
+// Errors:
+//
+// pkg/front_end/testcases/rasta/unsupported_platform_library.dart:5:8: Error: Not found: 'dart:html'
+// import 'dart:html';
+// ^
+
library;
import self as self;
-static method #main() → dynamic {
- throw "dart:html:1: Error: Not found: dart:html.";
-}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.outline.expect b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.outline.expect
index cc97b3e..6a28c0d 100644
--- a/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.outline.expect
+++ b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.outline.expect
@@ -1,2 +1,5 @@
library;
import self as self;
+
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.strong.expect b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.strong.expect
new file mode 100644
index 0000000..0c3e32a
--- /dev/null
+++ b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.strong.expect
@@ -0,0 +1,10 @@
+// Errors:
+//
+// pkg/front_end/testcases/rasta/unsupported_platform_library.dart:5:8: Error: Not found: 'dart:html'
+// import 'dart:html';
+// ^
+
+library;
+import self as self;
+
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.strong.transformed.expect b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.strong.transformed.expect
new file mode 100644
index 0000000..0c3e32a
--- /dev/null
+++ b/pkg/front_end/testcases/rasta/unsupported_platform_library.dart.strong.transformed.expect
@@ -0,0 +1,10 @@
+// Errors:
+//
+// pkg/front_end/testcases/rasta/unsupported_platform_library.dart:5:8: Error: Not found: 'dart:html'
+// import 'dart:html';
+// ^
+
+library;
+import self as self;
+
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/strong.status b/pkg/front_end/testcases/strong.status
index 9f5cea1..c1ac933 100644
--- a/pkg/front_end/testcases/strong.status
+++ b/pkg/front_end/testcases/strong.status
@@ -190,7 +190,6 @@
rasta/unresolved_constructor: Fail
rasta/unresolved_for_in: Fail
rasta/unresolved_recovery: Fail
-rasta/unsupported_platform_library: Fail
regress/issue_29975: Fail # Issue 29975.
regress/issue_29976: TypeCheckError # Issue 29976.
diff --git a/pkg/front_end/tool/fasta_perf.dart b/pkg/front_end/tool/fasta_perf.dart
index ea099cd..4b9fb26 100644
--- a/pkg/front_end/tool/fasta_perf.dart
+++ b/pkg/front_end/tool/fasta_perf.dart
@@ -243,23 +243,7 @@
options.sdkSummary = sdkRoot.resolve('outline.dill');
}
- var entrypoints = [
- entryUri,
- // These extra libraries are added to match the same set of libraries
- // scanned by default by the VM and the other benchmarks.
- Uri.parse('dart:async'),
- Uri.parse('dart:collection'),
- Uri.parse('dart:convert'),
- Uri.parse('dart:core'),
- Uri.parse('dart:developer'),
- Uri.parse('dart:_internal'),
- Uri.parse('dart:io'),
- Uri.parse('dart:isolate'),
- Uri.parse('dart:math'),
- Uri.parse('dart:mirrors'),
- Uri.parse('dart:typed_data'),
- ];
- var program = await kernelForComponent(entrypoints, options);
+ var program = await kernelForComponent([entryUri], options);
timer.stop();
var name = 'kernel_gen_e2e${compileSdk ? "" : "_sum"}';
diff --git a/runtime/observatory/tests/service/service_kernel.status b/runtime/observatory/tests/service/service_kernel.status
index 472019f..35be1d2 100644
--- a/runtime/observatory/tests/service/service_kernel.status
+++ b/runtime/observatory/tests/service/service_kernel.status
@@ -108,6 +108,7 @@
# These are the non-kernel specific versions so skip tests and allow errors.
[ $compiler == dartk ]
add_breakpoint_rpc_test: SkipByDesign # non-kernel specific version of add_breakpoint_rpc_kernel_test.
+bad_reload_test: RuntimeError # Issue 34025
evaluate_activation_in_method_class_test: RuntimeError
evaluate_activation_test/instance: RuntimeError # http://dartbug.com/20047
evaluate_activation_test/scope: RuntimeError # http://dartbug.com/20047
diff --git a/tests/compiler/dart2js/end_to_end/user_crash_test.dart b/tests/compiler/dart2js/end_to_end/user_crash_test.dart
index 508dec5..27ecab2 100644
--- a/tests/compiler/dart2js/end_to_end/user_crash_test.dart
+++ b/tests/compiler/dart2js/end_to_end/user_crash_test.dart
@@ -5,11 +5,15 @@
import 'dart:async';
import 'package:async_helper/async_helper.dart';
import 'package:expect/expect.dart';
+import 'package:front_end/src/fasta/messages.dart'
+ show templateCantReadFile, messageMissingMain;
import 'package:compiler/compiler_new.dart';
import '../helpers/memory_compiler.dart';
final EXCEPTION = 'Crash-marker';
+final Uri entryPoint = Uri.parse('memory:main.dart');
+
main() {
runTests() async {
test('Empty program', await run());
@@ -39,9 +43,11 @@
packagesDiscoveryProvider: (_) => new Future.error(EXCEPTION)),
expectedExceptions: [EXCEPTION]);
+ var cantReadFile =
+ templateCantReadFile.withArguments(entryPoint, EXCEPTION);
List<String> expectedLines = [
- 'Error: Input file not found: memory:main.dart.',
- 'memory:main.dart:\nError: Crash-marker',
+ "Error: ${cantReadFile.message}",
+ "${entryPoint}:\nError: ${messageMissingMain.message}",
];
test('Throw in input provider',
await run(memorySourceFiles: new CrashingMap()),
@@ -69,7 +75,7 @@
"Unexpected number of exceptions.");
for (int i = 0; i < expectedLines.length; i++) {
if (expectedLines[i] != null) {
- Expect.equals(expectedLines[i], result.lines[i]);
+ Expect.stringEquals(expectedLines[i], result.lines[i]);
}
}
}
@@ -82,7 +88,7 @@
await runZoned(() async {
try {
await runCompiler(
- entryPoint: Uri.parse('memory:main.dart'),
+ entryPoint: entryPoint,
memorySourceFiles: memorySourceFiles,
diagnosticHandler: diagnostics,
packagesDiscoveryProvider: packagesDiscoveryProvider);
diff --git a/tests/standalone_2/standalone_2_kernel.status b/tests/standalone_2/standalone_2_kernel.status
index 347a812..3019ae9 100644
--- a/tests/standalone_2/standalone_2_kernel.status
+++ b/tests/standalone_2/standalone_2_kernel.status
@@ -37,9 +37,6 @@
[ $compiler == dartkb ]
no_lazy_dispatchers_test: SkipByDesign # KBC interpreter doesn't support --no_lazy_dispatchers
-[ $compiler == fasta ]
-io/arguments_test: CompileTimeError
-
[ $fasta ]
deferred_transitive_import_error_test: CompileTimeError
package/package1_test: CompileTimeError