[CFE] Set accessor problem on malformed uri (aka set as synthetic)
This avoids a crash caused by libraries with such an uri being
used as a part, and a DillLibraryBuilder thus being added (or attempted
to be added) to a list of SourceLibraryBuilders.
Change-Id: I4f7dc8e982e86407337b2c6ea2e3ef608e7f1064
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176081
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
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 54420e8..3ec6fc8 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -216,6 +216,7 @@
-1,
library.importUri);
} else if (uri.scheme == SourceLibraryBuilder.MALFORMED_URI_SCHEME) {
+ library.addProblemAtAccessors(messageExpectedUri);
bytes = synthesizeSourceForMissingFile(library.importUri, null);
}
if (bytes != null) {
diff --git a/pkg/front_end/test/incremental_load_from_dill_suite.dart b/pkg/front_end/test/incremental_load_from_dill_suite.dart
index 3a00d7e..3c88456 100644
--- a/pkg/front_end/test/incremental_load_from_dill_suite.dart
+++ b/pkg/front_end/test/incremental_load_from_dill_suite.dart
@@ -1825,9 +1825,14 @@
invalidatedUris.map((uri) => uri.pathSegments.last).toSet();
Set<Uri> result = new Set<Uri>();
for (Uri uri in invalidatedImportUrisForTesting) {
- if (uri.pathSegments.last == "nonexisting.dart") continue;
+ if (uri.pathSegments.isNotEmpty &&
+ uri.pathSegments.last == "nonexisting.dart") {
+ continue;
+ }
if (invalidatedFilenames.contains(entryPoint.pathSegments.last) ||
- invalidatedFilenames.contains(uri.pathSegments.last)) result.add(uri);
+ invalidatedFilenames.contains(uri.pathSegments.last)) {
+ result.add(uri);
+ }
}
return result.isEmpty ? null : result;
diff --git a/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.outline.expect b/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.outline.expect
index a493720..3b1e61e 100644
--- a/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.outline.expect
+++ b/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.outline.expect
@@ -47,18 +47,46 @@
}
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/patch_lib.dart:8:8: Error: Expected a URI.
+// import ':c';
+// ^
+//
import self as self3;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/patch_lib.dart:9:1: Error: Expected a URI.
+// export ':d';
+// ^
+//
import self as self4;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/origin_lib.dart:5:8: Error: Expected a URI.
+// import ':a';
+// ^
+//
import self as self5;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/origin_lib.dart:6:1: Error: Expected a URI.
+// export ':b';
+// ^
+//
import self as self6;
diff --git a/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.strong.expect b/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.strong.expect
index 02eadb5..2ff6f4b 100644
--- a/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.strong.expect
+++ b/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.strong.expect
@@ -50,18 +50,46 @@
}
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/patch_lib.dart:8:8: Error: Expected a URI.
+// import ':c';
+// ^
+//
import self as self2;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/patch_lib.dart:9:1: Error: Expected a URI.
+// export ':d';
+// ^
+//
import self as self3;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/origin_lib.dart:5:8: Error: Expected a URI.
+// import ':a';
+// ^
+//
import self as self4;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/origin_lib.dart:6:1: Error: Expected a URI.
+// export ':b';
+// ^
+//
import self as self5;
diff --git a/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.strong.transformed.expect b/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.strong.transformed.expect
index 02eadb5..2ff6f4b 100644
--- a/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/platform_invalid_uris/main.dart.strong.transformed.expect
@@ -50,18 +50,46 @@
}
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/patch_lib.dart:8:8: Error: Expected a URI.
+// import ':c';
+// ^
+//
import self as self2;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/patch_lib.dart:9:1: Error: Expected a URI.
+// export ':d';
+// ^
+//
import self as self3;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/origin_lib.dart:5:8: Error: Expected a URI.
+// import ':a';
+// ^
+//
import self as self4;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/platform_invalid_uris/origin_lib.dart:6:1: Error: Expected a URI.
+// export ':b';
+// ^
+//
import self as self5;
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_part_uri_01.yaml b/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_part_uri_01.yaml
index 3cf6bc9..2620942c 100644
--- a/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_part_uri_01.yaml
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_part_uri_01.yaml
@@ -11,11 +11,12 @@
main.dart: |
// The space makes the scheme invalid -- this causes Uri.parse to throw.
part ' package:foo/bar.dart';
- expectedLibraryCount: 2
+ expectedLibraryCount: 1
errors: true
- entry: main.dart
errors: false
worldType: updated
+ checkInvalidatedFiles: false
invalidate:
- main.dart
sources:
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_part_uri_01.yaml.world.1.expect b/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_part_uri_01.yaml.world.1.expect
index 38a3f82..8763205 100644
--- a/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_part_uri_01.yaml.world.1.expect
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_part_uri_01.yaml.world.1.expect
@@ -1,5 +1,12 @@
main = <No Member>;
library from "org-dartlang-malformed-uri:?+package%3Afoo%2Fbar.dart" as ?+p {
+//
+// Problems in library:
+//
+// org-dartlang-test:///main.dart:2:6: Error: Expected a URI.
+// part ' package:foo/bar.dart';
+// ^
+//
}
library from "org-dartlang-test:///main.dart" as main {
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_uri_as_part.yaml b/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_uri_as_part.yaml
new file mode 100644
index 0000000..a77a588
--- /dev/null
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_uri_as_part.yaml
@@ -0,0 +1,22 @@
+# Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+# 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.
+
+type: newworld
+worlds:
+ - entry: main.dart
+ errors: true
+ sources:
+ main.dart: |
+ part '$foo';
+ main() {}
+ expectedLibraryCount: 1
+
+ - entry: main.dart
+ errors: true
+ worldType: updated
+ checkInvalidatedFiles: false
+ expectInitializeFromDill: false
+ invalidate:
+ - main.dart
+ expectedLibraryCount: 1
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_uri_as_part.yaml.world.1.expect b/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_uri_as_part.yaml.world.1.expect
new file mode 100644
index 0000000..144eef3
--- /dev/null
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_uri_as_part.yaml.world.1.expect
@@ -0,0 +1,23 @@
+main = main::main;
+library from "org-dartlang-malformed-uri:bad5" as bad5 {
+//
+// Problems in library:
+//
+// org-dartlang-test:///main.dart:1:6: Error: Expected a URI.
+// part '$foo';
+// ^
+//
+
+}
+library from "org-dartlang-test:///main.dart" as main {
+//
+// Problems in library:
+//
+// org-dartlang-test:///main.dart:1:7: Error: Can't use string interpolation in a URI.
+// part '$foo';
+// ^
+//
+
+ part org-dartlang-malformed-uri:bad5;
+ static method main() → dynamic {}
+}
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_uri_as_part.yaml.world.2.expect b/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_uri_as_part.yaml.world.2.expect
new file mode 100644
index 0000000..144eef3
--- /dev/null
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/invalid_uri_as_part.yaml.world.2.expect
@@ -0,0 +1,23 @@
+main = main::main;
+library from "org-dartlang-malformed-uri:bad5" as bad5 {
+//
+// Problems in library:
+//
+// org-dartlang-test:///main.dart:1:6: Error: Expected a URI.
+// part '$foo';
+// ^
+//
+
+}
+library from "org-dartlang-test:///main.dart" as main {
+//
+// Problems in library:
+//
+// org-dartlang-test:///main.dart:1:7: Error: Can't use string interpolation in a URI.
+// part '$foo';
+// ^
+//
+
+ part org-dartlang-malformed-uri:bad5;
+ static method main() → dynamic {}
+}
diff --git a/pkg/front_end/testcases/regress/issue_29977.dart.outline.expect b/pkg/front_end/testcases/regress/issue_29977.dart.outline.expect
index 7c9a95c..f162b6e 100644
--- a/pkg/front_end/testcases/regress/issue_29977.dart.outline.expect
+++ b/pkg/front_end/testcases/regress/issue_29977.dart.outline.expect
@@ -15,4 +15,11 @@
;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_29977.dart:5:8: Error: Expected a URI.
+// import 'data:async';
+// ^
+//
import self as self2;
diff --git a/pkg/front_end/testcases/regress/issue_29977.dart.strong.expect b/pkg/front_end/testcases/regress/issue_29977.dart.strong.expect
index b940300..2709154 100644
--- a/pkg/front_end/testcases/regress/issue_29977.dart.strong.expect
+++ b/pkg/front_end/testcases/regress/issue_29977.dart.strong.expect
@@ -14,4 +14,11 @@
static method main() → dynamic {}
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_29977.dart:5:8: Error: Expected a URI.
+// import 'data:async';
+// ^
+//
import self as self2;
diff --git a/pkg/front_end/testcases/regress/issue_29977.dart.strong.transformed.expect b/pkg/front_end/testcases/regress/issue_29977.dart.strong.transformed.expect
index b940300..2709154 100644
--- a/pkg/front_end/testcases/regress/issue_29977.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/regress/issue_29977.dart.strong.transformed.expect
@@ -14,4 +14,11 @@
static method main() → dynamic {}
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_29977.dart:5:8: Error: Expected a URI.
+// import 'data:async';
+// ^
+//
import self as self2;
diff --git a/pkg/front_end/testcases/regress/issue_29987.dart.outline.expect b/pkg/front_end/testcases/regress/issue_29987.dart.outline.expect
index 31663c2..25fefc3 100644
--- a/pkg/front_end/testcases/regress/issue_29987.dart.outline.expect
+++ b/pkg/front_end/testcases/regress/issue_29987.dart.outline.expect
@@ -15,4 +15,11 @@
;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_29987.dart:5:8: Error: Expected a URI.
+// import "dart_:core";
+// ^
+//
import self as self2;
diff --git a/pkg/front_end/testcases/regress/issue_29987.dart.strong.expect b/pkg/front_end/testcases/regress/issue_29987.dart.strong.expect
index 1a60106..4430e45 100644
--- a/pkg/front_end/testcases/regress/issue_29987.dart.strong.expect
+++ b/pkg/front_end/testcases/regress/issue_29987.dart.strong.expect
@@ -14,4 +14,11 @@
static method main() → dynamic {}
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_29987.dart:5:8: Error: Expected a URI.
+// import "dart_:core";
+// ^
+//
import self as self2;
diff --git a/pkg/front_end/testcases/regress/issue_29987.dart.strong.transformed.expect b/pkg/front_end/testcases/regress/issue_29987.dart.strong.transformed.expect
index 1a60106..4430e45 100644
--- a/pkg/front_end/testcases/regress/issue_29987.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/regress/issue_29987.dart.strong.transformed.expect
@@ -14,4 +14,11 @@
static method main() → dynamic {}
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_29987.dart:5:8: Error: Expected a URI.
+// import "dart_:core";
+// ^
+//
import self as self2;
diff --git a/pkg/front_end/testcases/regress/issue_30994.dart.outline.expect b/pkg/front_end/testcases/regress/issue_30994.dart.outline.expect
index 468c487..248fabb 100644
--- a/pkg/front_end/testcases/regress/issue_30994.dart.outline.expect
+++ b/pkg/front_end/testcases/regress/issue_30994.dart.outline.expect
@@ -43,28 +43,77 @@
;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:6:6: Error: Expected a URI.
+// part '$foo';
+// ^
+//
import self as self2;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:7:6: Error: Expected a URI.
+// part '$foo/bar';
+// ^
+//
import self as self3;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:8:6: Error: Expected a URI.
+// part '$for/bar';
+// ^
+//
import self as self4;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:9:6: Error: Expected a URI.
+// part '${true}';
+// ^
+//
import self as self5;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:10:6: Error: Expected a URI.
+// part 'the${1}thing';
+// ^
+//
import self as self6;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:11:6: Error: Expected a URI.
+// part 'part_$foo${'a'}.dart';
+// ^
+//
import self as self7;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:12:6: Error: Expected a URI.
+// part 'part_${'a'}_$foo.dart';
+// ^
+//
import self as self8;
diff --git a/pkg/front_end/testcases/regress/issue_30994.dart.strong.expect b/pkg/front_end/testcases/regress/issue_30994.dart.strong.expect
index 99b330c..212f13d 100644
--- a/pkg/front_end/testcases/regress/issue_30994.dart.strong.expect
+++ b/pkg/front_end/testcases/regress/issue_30994.dart.strong.expect
@@ -42,28 +42,77 @@
static method main() → dynamic {}
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:6:6: Error: Expected a URI.
+// part '$foo';
+// ^
+//
import self as self2;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:7:6: Error: Expected a URI.
+// part '$foo/bar';
+// ^
+//
import self as self3;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:8:6: Error: Expected a URI.
+// part '$for/bar';
+// ^
+//
import self as self4;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:9:6: Error: Expected a URI.
+// part '${true}';
+// ^
+//
import self as self5;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:10:6: Error: Expected a URI.
+// part 'the${1}thing';
+// ^
+//
import self as self6;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:11:6: Error: Expected a URI.
+// part 'part_$foo${'a'}.dart';
+// ^
+//
import self as self7;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:12:6: Error: Expected a URI.
+// part 'part_${'a'}_$foo.dart';
+// ^
+//
import self as self8;
diff --git a/pkg/front_end/testcases/regress/issue_30994.dart.strong.transformed.expect b/pkg/front_end/testcases/regress/issue_30994.dart.strong.transformed.expect
index 99b330c..212f13d 100644
--- a/pkg/front_end/testcases/regress/issue_30994.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/regress/issue_30994.dart.strong.transformed.expect
@@ -42,28 +42,77 @@
static method main() → dynamic {}
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:6:6: Error: Expected a URI.
+// part '$foo';
+// ^
+//
import self as self2;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:7:6: Error: Expected a URI.
+// part '$foo/bar';
+// ^
+//
import self as self3;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:8:6: Error: Expected a URI.
+// part '$for/bar';
+// ^
+//
import self as self4;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:9:6: Error: Expected a URI.
+// part '${true}';
+// ^
+//
import self as self5;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:10:6: Error: Expected a URI.
+// part 'the${1}thing';
+// ^
+//
import self as self6;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:11:6: Error: Expected a URI.
+// part 'part_$foo${'a'}.dart';
+// ^
+//
import self as self7;
library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/regress/issue_30994.dart:12:6: Error: Expected a URI.
+// part 'part_${'a'}_$foo.dart';
+// ^
+//
import self as self8;