Reproduction of dartbug.com/35715
Get an error saying something like
"The argument type 'dart.core::String' can't be assigned to
the parameter type 'dart.core::String'"
Change-Id: I327c613a2070495653e4089475a4f3edf550e9d4
Reviewed-on: https://dart-review.googlesource.com/c/91228
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
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 0e1d3a8..3f75732 100644
--- a/pkg/front_end/test/incremental_load_from_dill_test.dart
+++ b/pkg/front_end/test/incremental_load_from_dill_test.dart
@@ -192,7 +192,8 @@
final List<int> sdkSummaryData =
await new File.fromUri(platformUri).readAsBytes();
- List<int> newestWholeComponent;
+ List<int> newestWholeComponentData;
+ Component newestWholeComponent;
MemoryFileSystem fs;
Map<String, String> sourceFiles;
CompilerOptions options;
@@ -208,8 +209,11 @@
}
fs.entityForUri(sdkSummary).writeAsBytesSync(sdkSummaryData);
bool expectInitializeFromDill = false;
- if (newestWholeComponent != null && newestWholeComponent.isNotEmpty) {
- fs.entityForUri(initializeFrom).writeAsBytesSync(newestWholeComponent);
+ if (newestWholeComponentData != null &&
+ newestWholeComponentData.isNotEmpty) {
+ fs
+ .entityForUri(initializeFrom)
+ .writeAsBytesSync(newestWholeComponentData);
expectInitializeFromDill = true;
}
if (world["expectInitializeFromDill"] != null) {
@@ -256,7 +260,12 @@
Uri entry = base.resolve(world["entry"]);
if (brandNewWorld) {
- compiler = new TestIncrementalCompiler(options, entry, initializeFrom);
+ if (world["fromComponent"] == true) {
+ compiler = new TestIncrementalCompiler.fromComponent(
+ options, entry, newestWholeComponent);
+ } else {
+ compiler = new TestIncrementalCompiler(options, entry, initializeFrom);
+ }
}
List<Uri> invalidated = new List<Uri>();
@@ -275,7 +284,8 @@
world, gotError, formattedErrors, gotWarning, formattedWarnings);
util.throwOnEmptyMixinBodies(component);
print("Compile took ${stopwatch.elapsedMilliseconds} ms");
- newestWholeComponent = serializeComponent(component);
+ newestWholeComponentData = serializeComponent(component);
+ newestWholeComponent = component;
print("*****\n\ncomponent:\n${componentToString(component)}\n\n\n");
if (component.libraries.length != world["expectedLibraryCount"]) {
throw "Expected ${world["expectedLibraryCount"]} libraries, "
@@ -316,7 +326,7 @@
world, gotError, formattedErrors, gotWarning, formattedWarnings);
List<int> thisWholeComponent = serializeComponent(component2);
print("*****\n\ncomponent2:\n${componentToString(component2)}\n\n\n");
- checkIsEqual(newestWholeComponent, thisWholeComponent);
+ checkIsEqual(newestWholeComponentData, thisWholeComponent);
}
}
}
@@ -480,6 +490,13 @@
new ProcessedOptions(options: options, inputs: [entryPoint])),
initializeFrom);
+ TestIncrementalCompiler.fromComponent(CompilerOptions options,
+ this.entryPoint, Component componentToInitializeFrom)
+ : super.fromComponent(
+ new CompilerContext(
+ new ProcessedOptions(options: options, inputs: [entryPoint])),
+ componentToInitializeFrom);
+
@override
void recordInvalidatedImportUrisForTesting(List<Uri> uris) {
invalidatedImportUrisForTesting = uris.isEmpty ? null : uris.toSet();
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/load_from_component_explicitly_import_dart_core.yaml b/pkg/front_end/testcases/incremental_initialize_from_dill/load_from_component_explicitly_import_dart_core.yaml
new file mode 100644
index 0000000..9fbdf62
--- /dev/null
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/load_from_component_explicitly_import_dart_core.yaml
@@ -0,0 +1,50 @@
+# Copyright (c) 2019, 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.
+
+# Initialize from component, where the component is linked to one sdk, and where
+# the incremental compiler loads another sdk. Risk when doing this: Having two
+# definitions of the same thing (e.g. the class 'String'), which could lead to
+# errors such as "The argument type 'dart.core::String' can't be assigned to
+# the parameter type 'dart.core::String'".
+
+type: newworld
+strong: true
+worlds:
+ - entry: main.dart
+ errors: false
+ warnings: false
+ sources:
+ main.dart: |
+ import "b.dart";
+
+ main() {
+ useString("hello");
+ }
+ b.dart: |
+ import "dart:core";
+
+ void useString(String s) {
+ print("Hello from useString: $s");
+ }
+ expectedLibraryCount: 2
+ - entry: main.dart
+ errors: false
+ warnings: false
+ fromComponent: true
+ invalidate:
+ - main.dart
+ sources:
+ main.dart: |
+ import "b.dart";
+
+ main() {
+ useString("hello");
+ }
+ b.dart: |
+ import "dart:core";
+
+ void useString(String s) {
+ print("Hello from useString: $s");
+ }
+ expectedLibraryCount: 2
\ No newline at end of file
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/status.status b/pkg/front_end/testcases/incremental_initialize_from_dill/status.status
index f3d01d2..003bd93 100644
--- a/pkg/front_end/testcases/incremental_initialize_from_dill/status.status
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/status.status
@@ -3,3 +3,5 @@
# BSD-style license that can be found in the LICENSE.md file.
# Status file for the test suite ../test/incremental_load_from_dill_yaml_test.dart.
+
+load_from_component_explicitly_import_dart_core: Crash
\ No newline at end of file