Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: pkg/front_end/lib/src/fasta/source/source_library_builder.dart

Issue 2781623003: Improve semantics of parts. (Closed)
Patch Set: Update language status. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-kernel.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/source/source_library_builder.dart
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 139ba365a186ea05e326ff972c599bf1630775f7..7152ee4939cfd01f6f8898c0c6d5dca4e320affe 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
@@ -12,8 +12,6 @@ import '../errors.dart' show inputError, internalError;
import '../export.dart' show Export;
-import '../messages.dart' show warning;
-
import '../import.dart' show Import;
import 'source_loader.dart' show SourceLoader;
@@ -339,11 +337,15 @@ abstract class SourceLibraryBuilder<T extends TypeBuilder, R>
}
void includeParts() {
+ Set<Uri> seenParts = new Set<Uri>();
for (SourceLibraryBuilder<T, R> part in parts.toList()) {
if (part == this) {
addCompileTimeError(-1, "A file can't be a part of itself.");
- } else {
+ } else if (seenParts.add(part.fileUri)) {
includePart(part);
+ } else {
+ addCompileTimeError(
+ -1, "Can't use '${part.fileUri}' as a part more than once.");
}
}
}
@@ -351,21 +353,21 @@ abstract class SourceLibraryBuilder<T extends TypeBuilder, R>
void includePart(SourceLibraryBuilder<T, R> part) {
if (name != null) {
if (!part.isPart) {
- warning(
- part.fileUri,
+ addCompileTimeError(
-1,
- "Has no 'part of' declaration but is used as "
- "a part by ${name} ($uri).");
+ "Can't use ${part.fileUri} as a part, because it has no 'part of'"
+ " declaration.");
parts.remove(part);
return;
}
if (part.partOfName != name && part.partOfUri != uri) {
String partName = part.partOfName ?? "${part.partOfUri}";
String myName = name == null ? "'$uri'" : "'${name}' ($uri)";
- warning(part.fileUri, -1,
- "Is part of '$partName' but is used as a part by $myName.");
- parts.remove(part);
- return;
+ addWarning(
+ -1,
+ "Using '${part.fileUri}' as part of '$myName' but it's 'part of'"
+ " declaration says '$partName'.");
+ // The part is still included.
}
}
part.members.forEach((String name, Builder builder) {
« no previous file with comments | « no previous file | tests/co19/co19-kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698