Version 1.22.0-dev.5.0
Merge 8360a89fce5d77bc9b1bde3662b88125675e6a2a into dev
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d24dffa..13b2450 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
### Language
+ * Breaking change: ['Generalized tear-offs'](https://github.com/gbracha/generalizedTearOffs/blob/master/proposal.md)
+ are no longer supported, and will cause errors. We updated the language spec
+ and added warnings in 1.21, and are now taking the last step to fully
+ de-support them. They were previously supported in the VM only.
+
* The `assert()` statement has been expanded to support an optional second
`message` argument (SDK issue [27342](https://github.com/dart-lang/sdk/issues/27342)).
diff --git a/DEPS b/DEPS
index 882fa0f..a9f0ba1 100644
--- a/DEPS
+++ b/DEPS
@@ -86,7 +86,7 @@
"observatory_pub_packages_rev": "@26aad88f1c1915d39bbcbff3cad589e2402fdcf1",
"observe_tag": "@0.13.5",
"package_config_tag": "@1.0.0",
- "package_resolver_tag": "@1.0.2",
+ "package_resolver_tag": "@1.0.2+1",
"path_tag": "@1.4.1",
"plugin_tag": "@0.2.0",
"ply_rev": "@604b32590ffad5cbb82e4afef1d305512d06ae93",
diff --git a/README.md b/README.md
index e2a2f1e..8799041 100644
--- a/README.md
+++ b/README.md
@@ -14,8 +14,9 @@
## Building Dart
-Learn how to [get the source](https://github.com/dart-lang/sdk/wiki/Building#getting-the-source)
-and [prepare your machine to build the SDK](https://github.com/dart-lang/sdk/wiki/Preparing-your-machine-to-build-the-Dart-SDK).
+If you want to build Dart yourself, here is a guide to
+[getting the source, preparing your machine to build the SDK, and
+building](https://github.com/dart-lang/sdk/wiki/Building).
There are more documents on our [wiki](https://github.com/dart-lang/sdk/wiki).
diff --git a/pkg/analysis_server/lib/plugin/protocol/protocol.dart b/pkg/analysis_server/lib/plugin/protocol/protocol.dart
index 92ef921..49e19c1 100644
--- a/pkg/analysis_server/lib/plugin/protocol/protocol.dart
+++ b/pkg/analysis_server/lib/plugin/protocol/protocol.dart
@@ -567,6 +567,12 @@
RequestErrorCode.UNSUPPORTED_FEATURE, message));
/**
+ * Return a table mapping the names of result fields to their values. Should
+ * be `null` if there is no result to send.
+ */
+ Map<String, Object> get result => _result;
+
+ /**
* Return a table representing the structure of the Json object that will be
* sent to the client to represent this response.
*/
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 5ee2afd..771f9f1 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -332,12 +332,6 @@
final Set<String> priorityFiles = new Set<String>();
/**
- * The cached results for [priorityFiles].
- * These results must have not `null` units.
- */
- final Map<String, nd.AnalysisResult> priorityFileResults = {};
-
- /**
* Initialize a newly created server to receive requests from and send
* responses to the given [channel].
*
@@ -630,10 +624,6 @@
* otherwise in the first driver, otherwise `null` is returned.
*/
Future<nd.AnalysisResult> getAnalysisResult(String path) async {
- nd.AnalysisResult result = priorityFileResults[path];
- if (result != null) {
- return result;
- }
try {
nd.AnalysisDriver driver = getAnalysisDriver(path);
return await driver?.getResult(path);
@@ -1182,6 +1172,13 @@
_onAnalysisCompleteCompleter.complete();
_onAnalysisCompleteCompleter = null;
}
+ // Perform on-idle actions.
+ if (!status.isAnalyzing) {
+ if (generalAnalysisServices
+ .contains(GeneralAnalysisService.ANALYZED_FILES)) {
+ sendAnalysisNotificationAnalyzedFiles(this);
+ }
+ }
// Only send status when subscribed.
if (!serverServices.contains(ServerService.STATUS)) {
return;
@@ -1333,10 +1330,6 @@
*/
void setPriorityFiles(String requestId, List<String> files) {
if (options.enableNewAnalysisDriver) {
- // Flush results for files that are not priority anymore.
- priorityFiles
- .difference(files.toSet())
- .forEach(priorityFileResults.remove);
priorityFiles.clear();
priorityFiles.addAll(files);
// Set priority files in drivers.
@@ -1466,8 +1459,6 @@
void updateContent(String id, Map<String, dynamic> changes) {
if (options.enableNewAnalysisDriver) {
changes.forEach((file, change) {
- priorityFileResults.remove(file);
-
// Prepare the new contents.
String oldContents = fileContentOverlay[file];
String newContents;
@@ -1846,10 +1837,6 @@
// TODO(scheglov) send server status
});
analysisDriver.results.listen((result) {
- if (analysisServer.priorityFiles.contains(result.path) &&
- result.unit != null) {
- analysisServer.priorityFileResults[result.path] = result;
- }
new_sendErrorNotification(analysisServer, result);
String path = result.path;
CompilationUnit unit = result.unit;
@@ -1999,11 +1986,6 @@
sendAnalysisNotificationFlushResults(analysisServer, flushedFiles);
nd.AnalysisDriver driver = analysisServer.driverMap.remove(folder);
driver.dispose();
- // Remove cached priority results for the driver.
- var results = analysisServer.priorityFileResults;
- results.keys
- .where((key) => results[key].driver == driver)
- .forEach(results.remove);
} else {
AnalysisContext context = analysisServer.folderMap.remove(folder);
sendAnalysisNotificationFlushResults(analysisServer, flushedFiles);
diff --git a/pkg/analysis_server/lib/src/operation/operation_analysis.dart b/pkg/analysis_server/lib/src/operation/operation_analysis.dart
index c95f09a..96d4538 100644
--- a/pkg/analysis_server/lib/src/operation/operation_analysis.dart
+++ b/pkg/analysis_server/lib/src/operation/operation_analysis.dart
@@ -135,13 +135,17 @@
void sendAnalysisNotificationAnalyzedFiles(AnalysisServer server) {
_sendNotification(server, () {
- // TODO(paulberry): if it proves to be too inefficient to recompute the set
- // of analyzed files each time analysis is complete, consider modifying the
- // analysis engine to update this set incrementally as analysis is
- // performed.
- LibraryDependencyCollector collector =
- new LibraryDependencyCollector(server.analysisContexts.toList());
- Set<String> analyzedFiles = collector.collectLibraryDependencies();
+ Set<String> analyzedFiles;
+ if (server.options.enableNewAnalysisDriver) {
+ analyzedFiles = server.driverMap.values
+ .map((driver) => driver.knownFiles)
+ .expand((files) => files)
+ .toSet();
+ } else {
+ LibraryDependencyCollector collector =
+ new LibraryDependencyCollector(server.analysisContexts.toList());
+ analyzedFiles = collector.collectLibraryDependencies();
+ }
Set<String> prevAnalyzedFiles = server.prevAnalyzedFiles;
if (prevAnalyzedFiles != null &&
prevAnalyzedFiles.length == analyzedFiles.length &&
diff --git a/pkg/analysis_server/lib/src/server/driver.dart b/pkg/analysis_server/lib/src/server/driver.dart
index 072fa75..ea6074e 100644
--- a/pkg/analysis_server/lib/src/server/driver.dart
+++ b/pkg/analysis_server/lib/src/server/driver.dart
@@ -242,9 +242,10 @@
"incremental-resolution-validation";
/**
- * The name of the option used to enable using the new analysis driver.
+ * The name of the option used to disable using the new analysis driver.
*/
- static const String ENABLE_NEW_ANALYSIS_DRIVER = 'enable-new-analysis-driver';
+ static const String DISABLE_NEW_ANALYSIS_DRIVER =
+ 'disable-new-analysis-driver';
/**
* The name of the option used to enable using pub summary manager.
@@ -393,7 +394,7 @@
analysisServerOptions.enableIncrementalResolutionValidation =
results[INCREMENTAL_RESOLUTION_VALIDATION];
analysisServerOptions.enableNewAnalysisDriver =
- results[ENABLE_NEW_ANALYSIS_DRIVER];
+ !results[DISABLE_NEW_ANALYSIS_DRIVER];
analysisServerOptions.enablePubSummaryManager =
results[ENABLE_PUB_SUMMARY_MANAGER];
analysisServerOptions.finerGrainedInvalidation =
@@ -543,8 +544,8 @@
help: "enable validation of incremental resolution results (slow)",
defaultsTo: false,
negatable: false);
- parser.addFlag(ENABLE_NEW_ANALYSIS_DRIVER,
- help: "enable using new analysis driver",
+ parser.addFlag(DISABLE_NEW_ANALYSIS_DRIVER,
+ help: "disable using new analysis driver",
defaultsTo: false,
negatable: false);
parser.addFlag(ENABLE_PUB_SUMMARY_MANAGER,
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index 52fe213..efec5ee 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -1541,7 +1541,7 @@
}
// prepare LibraryElement
LibraryElement libraryElement =
- context.getResult(librarySource, LIBRARY_ELEMENT1);
+ context.computeResult(librarySource, LIBRARY_ELEMENT1);
if (libraryElement == null) {
continue;
}
@@ -1659,6 +1659,9 @@
void _addFix_makeEnclosingClassAbstract() {
ClassDeclaration enclosingClass =
node.getAncestor((node) => node is ClassDeclaration);
+ if (enclosingClass == null) {
+ return;
+ }
String className = enclosingClass.name.name;
_addInsertEdit(enclosingClass.classKeyword.offset, 'abstract ');
_addFix(DartFixKind.MAKE_CLASS_ABSTRACT, [className]);
diff --git a/pkg/analysis_server/test/abstract_context.dart b/pkg/analysis_server/test/abstract_context.dart
index 6375766..ac7d8c0 100644
--- a/pkg/analysis_server/test/abstract_context.dart
+++ b/pkg/analysis_server/test/abstract_context.dart
@@ -10,17 +10,17 @@
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
+import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer/source/package_map_resolver.dart';
import 'package:analyzer/src/dart/analysis/byte_store.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart';
+import 'package:analyzer/src/dart/sdk/sdk.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/engine.dart' as engine;
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source_io.dart';
-import 'mock_sdk.dart';
-
/**
* Finds an [Element] with the given [name].
*/
@@ -44,7 +44,10 @@
typedef void _ElementVisitorFunction(Element element);
class AbstractContextTest {
- static final DartSdk SDK = new MockSdk();
+ static final DartSdk SDK = new FolderBasedDartSdk(
+ PhysicalResourceProvider.INSTANCE,
+ FolderBasedDartSdk.defaultSdkDirectory(PhysicalResourceProvider.INSTANCE))
+ ..useSummary = true;
static final UriResolver SDK_RESOLVER = new DartUriResolver(SDK);
MemoryResourceProvider provider;
@@ -83,11 +86,12 @@
}
Source addSource(String path, String content, [Uri uri]) {
+ File file = newFile(path, content);
if (enableNewAnalysisDriver) {
+ driver.addFile(path);
_fileContentOverlay[path] = content;
return null;
} else {
- File file = newFile(path, content);
Source source = file.createSource(uri);
ChangeSet changeSet = new ChangeSet();
changeSet.addedSource(source);
diff --git a/pkg/analysis_server/test/analysis/notification_analyzedFiles_test.dart b/pkg/analysis_server/test/analysis/notification_analyzedFiles_test.dart
index f9c95ae..25cef9d 100644
--- a/pkg/analysis_server/test/analysis/notification_analyzedFiles_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_analyzedFiles_test.dart
@@ -17,6 +17,7 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(AnalysisNotificationAnalyzedFilesTest);
+ defineReflectiveTests(AnalysisNotificationAnalyzedFilesTest_Driver);
});
}
@@ -30,9 +31,9 @@
expect(analyzedFiles, contains(filePath));
}
- Future prepareAnalyzedFiles() {
+ Future<Null> prepareAnalyzedFiles() async {
addGeneralAnalysisSubscription(GeneralAnalysisService.ANALYZED_FILES);
- return waitForTasksFinished();
+ await pumpEventQueue();
}
void processNotification(Notification notification) {
@@ -71,12 +72,11 @@
// not trigger the notification to be re-sent.
addTestFile('class A {}');
await prepareAnalyzedFiles();
- await waitForTasksFinished();
expect(analyzedFilesReceived, isTrue);
+
analyzedFilesReceived = false;
modifyTestFile('class B {}');
- await pumpEventQueue();
- await waitForTasksFinished();
+ await prepareAnalyzedFiles();
expect(analyzedFilesReceived, isFalse);
}
@@ -85,10 +85,11 @@
// re-sent, even if nothing has changed.
addTestFile('class A {}');
await prepareAnalyzedFiles();
- await waitForTasksFinished();
expect(analyzedFilesReceived, isTrue);
+
unsubscribeAnalyzedFiles();
analyzedFilesReceived = false;
+
await prepareAnalyzedFiles();
expect(analyzedFilesReceived, isTrue);
assertHasFile(testFile);
@@ -98,15 +99,13 @@
// Making a change that *does* affect the set of reachable files should
// trigger the notification to be re-sent.
addTestFile('class A {}');
- addFile('/foo.dart', 'library foo');
+ addFile('/foo.dart', 'library foo;');
await prepareAnalyzedFiles();
- await waitForTasksFinished();
expect(analyzedFilesReceived, isTrue);
+
analyzedFilesReceived = false;
modifyTestFile('import "/foo.dart";');
- await pumpEventQueue();
- await waitForTasksFinished();
- expect(analyzedFilesReceived, isTrue);
+ await prepareAnalyzedFiles();
assertHasFile('/foo.dart');
}
@@ -114,3 +113,14 @@
removeGeneralAnalysisSubscription(GeneralAnalysisService.ANALYZED_FILES);
}
}
+
+@reflectiveTest
+class AnalysisNotificationAnalyzedFilesTest_Driver
+ extends AnalysisNotificationAnalyzedFilesTest {
+ @override
+ void setUp() {
+ enableNewAnalysisDriver = true;
+ generateSummaryFiles = true;
+ super.setUp();
+ }
+}
diff --git a/pkg/analysis_server/test/analysis_abstract.dart b/pkg/analysis_server/test/analysis_abstract.dart
index ac463bb..c147c23 100644
--- a/pkg/analysis_server/test/analysis_abstract.dart
+++ b/pkg/analysis_server/test/analysis_abstract.dart
@@ -197,7 +197,8 @@
}
String modifyTestFile(String content) {
- addFile(testFile, content);
+ String path = resourceProvider.convertPath(testFile);
+ resourceProvider.updateFile(path, content);
this.testCode = content;
return testFile;
}
diff --git a/pkg/analysis_server/test/integration/integration_tests.dart b/pkg/analysis_server/test/integration/integration_tests.dart
index b278c96..9a3b906 100644
--- a/pkg/analysis_server/test/integration/integration_tests.dart
+++ b/pkg/analysis_server/test/integration/integration_tests.dart
@@ -698,8 +698,8 @@
if (useAnalysisHighlight2) {
arguments.add('--useAnalysisHighlight2');
}
- if (enableNewAnalysisDriver) {
- arguments.add('--enable-new-analysis-driver');
+ if (!enableNewAnalysisDriver) {
+ arguments.add('--disable-new-analysis-driver');
}
// print('Launching $serverPath');
// print('$dartBinary ${arguments.join(' ')}');
diff --git a/pkg/analysis_server/test/services/completion/dart/combinator_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/combinator_contributor_test.dart
index 3ce88ef..4290b2f 100644
--- a/pkg/analysis_server/test/services/completion/dart/combinator_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/combinator_contributor_test.dart
@@ -65,7 +65,9 @@
class X {}''');
// Assume that imported libraries have been resolved
- context.resolveCompilationUnit2(importedLibSource, importedLibSource);
+ if (!enableNewAnalysisDriver) {
+ context.resolveCompilationUnit2(importedLibSource, importedLibSource);
+ }
await computeSuggestions();
assertSuggestClass('A',
@@ -117,7 +119,9 @@
class X {}''');
// Assume that imported libraries have been resolved
- context.resolveCompilationUnit2(importedLibSource, importedLibSource);
+ if (!enableNewAnalysisDriver) {
+ context.resolveCompilationUnit2(importedLibSource, importedLibSource);
+ }
await computeSuggestions();
assertSuggestClass('A',
@@ -157,18 +161,4 @@
class CombinatorContributorTest_Driver extends CombinatorContributorTest {
@override
bool get enableNewAnalysisDriver => true;
-
- @failingTest
- @override
- test_Combinator_hide() {
-// Bad state: Should not be used with the new analysis driver.
- return super.test_Combinator_hide();
- }
-
- @failingTest
- @override
- test_Combinator_show() {
-// Bad state: Should not be used with the new analysis driver.
- return super.test_Combinator_show();
- }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
index cffa292..6d85584 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
@@ -437,7 +437,7 @@
*/
Future<Null> computeLibrariesContaining([int times = 200]) {
if (enableNewAnalysisDriver) {
- return new Future.value(null);
+ return driver.getResult(testFile).then((result) => null);
}
List<Source> libraries = context.getLibrariesContaining(testSource);
if (libraries.isNotEmpty) {
diff --git a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
index 2466ef4..9f3ce39 100644
--- a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
@@ -656,7 +656,7 @@
assertNotSuggested('G');
//assertSuggestClass('H', COMPLETION_RELEVANCE_LOW);
assertSuggestClass('Object');
- assertSuggestFunction('min', 'num');
+ assertSuggestFunction('min', 'T');
//assertSuggestFunction(
// 'max',
// 'num',
@@ -4532,13 +4532,6 @@
@failingTest
@override
- test_partFile_TypeName() {
- // Bad state: Should not be used with the new analysis driver.
- return super.test_partFile_TypeName();
- }
-
- @failingTest
- @override
test_doc_class() {
// Expected: 'My class.\n'
// 'Short description.'
diff --git a/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart
index 52e5ff5..fe1e24b 100644
--- a/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart
@@ -61,7 +61,7 @@
import "dart:math" as math;
main() {math.^.}''');
await computeSuggestions();
- assertSuggestFunction('min', 'num');
+ assertSuggestFunction('min', 'T');
}
test_libraryPrefix_cascade3() async {
@@ -77,7 +77,7 @@
import "dart:math" as math;
main() {math.^.a}''');
await computeSuggestions();
- assertSuggestFunction('min', 'num');
+ assertSuggestFunction('min', 'T');
}
test_libraryPrefix_deferred() async {
@@ -275,25 +275,4 @@
class LibraryMemberContributorTest_Driver extends LibraryMemberContributorTest {
@override
bool get enableNewAnalysisDriver => true;
-
- @failingTest
- @override
- test_libraryPrefix_deferred() {
-// 'package:analyzer/src/dart/element/element.dart': Failed assertion: line 5729 pos 12: '_loadLibraryFunction != null' is not true.
- return super.test_libraryPrefix_deferred_inPart();
- }
-
- @failingTest
- @override
- test_libraryPrefix_deferred_inPart() {
- // Bad state: Should not be used with the new analysis driver.
- return super.test_libraryPrefix_deferred_inPart();
- }
-
- @failingTest
- @override
- test_PrefixedIdentifier_library_inPart() {
- // Bad state: Should not be used with the new analysis driver.
- return super.test_PrefixedIdentifier_library_inPart();
- }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/library_prefix_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/library_prefix_contributor_test.dart
index cb10497..78bd338 100644
--- a/pkg/analysis_server/test/services/completion/dart/library_prefix_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/library_prefix_contributor_test.dart
@@ -381,11 +381,4 @@
class LibraryPrefixContributorTest_Driver extends LibraryPrefixContributorTest {
@override
bool get enableNewAnalysisDriver => true;
-
- @failingTest
- @override
- test_InstanceCreationExpression_inPart() {
- // Bad state: Should not be used with the new analysis driver.
- return super.test_InstanceCreationExpression_inPart();
- }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/local_constructor_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_constructor_contributor_test.dart
index 948671c..7ee4457 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_constructor_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_constructor_contributor_test.dart
@@ -4153,69 +4153,4 @@
extends LocalConstructorContributorTest {
@override
bool get enableNewAnalysisDriver => true;
-
- @failingTest
- @override
- test_partFile_TypeName2() async {
-// Task failed: BuildCompilationUnitElementTask for source /testA.dart
-// Element mismatch in /testA.dart at /testA.dart
-// #0 DeclarationResolver.resolve (package:analyzer/src/generated/declaration_resolver.dart:50:7)
-// #1 BuildCompilationUnitElementTask.internalPerform (package:analyzer/src/task/dart.dart:1084:33)
-// #2 AnalysisTask._safelyPerform (package:analyzer/task/model.dart:321:9)
-// #3 AnalysisTask.perform (package:analyzer/task/model.dart:220:7)
-// #4 AnalysisDriver.performWorkItem (package:analyzer/src/task/driver.dart:284:10)
-// #5 AnalysisDriver.computeResult (package:analyzer/src/task/driver.dart:109:22)
-// #6 AnalysisContextImpl.computeResult (package:analyzer/src/context/context.dart:723:14)
-// #7 AnalysisContextImpl.computeErrors (package:analyzer/src/context/context.dart:665:12)
-// #8 AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:658:54)
-// #9 PerformanceLog.run (package:analyzer/src/dart/analysis/driver.dart:1427:15)
-// #10 AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:643:20)
-// #11 AnalysisDriver._performWork.<_performWork_async_body> (package:analyzer/src/dart/analysis/driver.dart:910:33)
-// #12 Future.Future.microtask.<anonymous closure> (dart:async/future.dart:184)
-// #13 _rootRun (dart:async/zone.dart:1146)
-// #14 _CustomZone.run (dart:async/zone.dart:1026)
-// #15 _CustomZone.runGuarded (dart:async/zone.dart:924)
-// #16 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
-// #17 _rootRun (dart:async/zone.dart:1150)
-// #18 _CustomZone.run (dart:async/zone.dart:1026)
-// #19 _CustomZone.runGuarded (dart:async/zone.dart:924)
-// #20 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
-// #21 _microtaskLoop (dart:async/schedule_microtask.dart:41)
-// #22 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
-// #23 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:394)
-// #24 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:414)
-// #25 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
-//
-// Caused by Bad state: Unmatched ClassElementImpl class B
-// #0 ElementWalker.validate.check (package:analyzer/src/generated/declaration_resolver.dart:690:9)
-// #1 ElementWalker.validate (package:analyzer/src/generated/declaration_resolver.dart:696:10)
-// #2 DeclarationResolver.resolve (package:analyzer/src/generated/declaration_resolver.dart:48:15)
-// #3 BuildCompilationUnitElementTask.internalPerform (package:analyzer/src/task/dart.dart:1084:33)
-// #4 AnalysisTask._safelyPerform (package:analyzer/task/model.dart:321:9)
-// #5 AnalysisTask.perform (package:analyzer/task/model.dart:220:7)
-// #6 AnalysisDriver.performWorkItem (package:analyzer/src/task/driver.dart:284:10)
-// #7 AnalysisDriver.computeResult (package:analyzer/src/task/driver.dart:109:22)
-// #8 AnalysisContextImpl.computeResult (package:analyzer/src/context/context.dart:723:14)
-// #9 AnalysisContextImpl.computeErrors (package:analyzer/src/context/context.dart:665:12)
-// #10 AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:658:54)
-// #11 PerformanceLog.run (package:analyzer/src/dart/analysis/driver.dart:1427:15)
-// #12 AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:643:20)
-// #13 AnalysisDriver._performWork.<_performWork_async_body> (package:analyzer/src/dart/analysis/driver.dart:910:33)
-// #14 Future.Future.microtask.<anonymous closure> (dart:async/future.dart:184)
-// #15 _rootRun (dart:async/zone.dart:1146)
-// #16 _CustomZone.run (dart:async/zone.dart:1026)
-// #17 _CustomZone.runGuarded (dart:async/zone.dart:924)
-// #18 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
-// #19 _rootRun (dart:async/zone.dart:1150)
-// #20 _CustomZone.run (dart:async/zone.dart:1026)
-// #21 _CustomZone.runGuarded (dart:async/zone.dart:924)
-// #22 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
-// #23 _microtaskLoop (dart:async/schedule_microtask.dart:41)
-// #24 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
-// #25 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:394)
-// #26 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:414)
-// #27 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
-// await super.test_partFile_TypeName2();
- fail('Throws background exception!');
- }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
index 0af28b5..6a49e95 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
@@ -312,18 +312,4 @@
class LocalLibraryContributorTest_Driver extends LocalLibraryContributorTest {
@override
bool get enableNewAnalysisDriver => true;
-
- @failingTest
- @override
- test_partFile_Constructor() {
-// Bad state: Should not be used with the new analysis driver.
- return super.test_partFile_Constructor();
- }
-
- @failingTest
- @override
- test_partFile_TypeName() {
-// Bad state: Should not be used with the new analysis driver.
- return super.test_partFile_TypeName();
- }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/named_constructor_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/named_constructor_contributor_test.dart
index 9b6a1d7..e938523 100644
--- a/pkg/analysis_server/test/services/completion/dart/named_constructor_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/named_constructor_contributor_test.dart
@@ -61,7 +61,9 @@
var m;
main() {new X.^}''');
// Assume that imported libraries are resolved
- await resolveLibraryUnit(libSource);
+ if (!enableNewAnalysisDriver) {
+ await resolveLibraryUnit(libSource);
+ }
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -115,7 +117,9 @@
var m;
main() {new X.^}''');
// Assume that imported libraries are resolved
- await resolveLibraryUnit(libSource);
+ if (!enableNewAnalysisDriver) {
+ await resolveLibraryUnit(libSource);
+ }
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -187,18 +191,4 @@
extends NamedConstructorContributorTest {
@override
bool get enableNewAnalysisDriver => true;
-
- @failingTest
- @override
- test_ConstructorName_importedClass() {
-// Bad state: Should not be used with the new analysis driver.
- return super.test_ConstructorName_importedClass();
- }
-
- @failingTest
- @override
- test_ConstructorName_importedFactory() {
-// Bad state: Should not be used with the new analysis driver.
- return super.test_ConstructorName_importedFactory();
- }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/optype_test.dart b/pkg/analysis_server/test/services/completion/dart/optype_test.dart
index f285173..5c4a758 100644
--- a/pkg/analysis_server/test/services/completion/dart/optype_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/optype_test.dart
@@ -85,6 +85,11 @@
processRequiredPlugins();
}
+ test_Block_final_final2() {
+ addTestSource('main() {final S^ final S x;}');
+ assertOpType(typeNames: true);
+ }
+
test_Annotation() {
// SimpleIdentifier Annotation MethodDeclaration ClassDeclaration
addTestSource('class C { @A^ }');
@@ -325,11 +330,6 @@
assertOpType(typeNames: true);
}
- test_Block_final_final2() {
- addTestSource('main() {final S^ final S x;}');
- assertOpType(typeNames: true);
- }
-
test_Block_identifier_partial() {
addTestSource('class X {a() {var f; {var x;} D^ var r;} void b() { }}');
assertOpType(returnValue: true, typeNames: true, voidReturn: true);
@@ -1567,6 +1567,9 @@
bool get isInSystemLibrary => false;
@override
+ Source get librarySource => null;
+
+ @override
String get shortName => fullName;
@override
diff --git a/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart
index fa7529f..a2d9778 100644
--- a/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart
@@ -238,7 +238,7 @@
import "dart:async" as async;
void main() {async.Future.^.w()}''');
await computeSuggestions();
- assertSuggestMethod('wait', 'Future', 'Future<dynamic>');
+ assertSuggestMethod('wait', 'Future', 'Future<List<T>>');
}
test_PrefixedIdentifier_class_const() async {
diff --git a/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
index 4bdfa13..9801e82 100644
--- a/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
@@ -4163,69 +4163,4 @@
class TypeMemberContributorTest_Driver extends TypeMemberContributorTest {
@override
bool get enableNewAnalysisDriver => true;
-
- @failingTest
- @override
- test_partFile_TypeName2() {
-// Task failed: BuildCompilationUnitElementTask for source /testA.dart
-// Element mismatch in /testA.dart at /testA.dart
-// #0 DeclarationResolver.resolve (package:analyzer/src/generated/declaration_resolver.dart:50:7)
-// #1 BuildCompilationUnitElementTask.internalPerform (package:analyzer/src/task/dart.dart:1084:33)
-// #2 AnalysisTask._safelyPerform (package:analyzer/task/model.dart:321:9)
-// #3 AnalysisTask.perform (package:analyzer/task/model.dart:220:7)
-// #4 AnalysisDriver.performWorkItem (package:analyzer/src/task/driver.dart:284:10)
-// #5 AnalysisDriver.computeResult (package:analyzer/src/task/driver.dart:109:22)
-// #6 AnalysisContextImpl.computeResult (package:analyzer/src/context/context.dart:723:14)
-// #7 AnalysisContextImpl.computeErrors (package:analyzer/src/context/context.dart:665:12)
-// #8 AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:658:54)
-// #9 PerformanceLog.run (package:analyzer/src/dart/analysis/driver.dart:1427:15)
-// #10 AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:643:20)
-// #11 AnalysisDriver._performWork.<_performWork_async_body> (package:analyzer/src/dart/analysis/driver.dart:910:33)
-// #12 Future.Future.microtask.<anonymous closure> (dart:async/future.dart:184)
-// #13 _rootRun (dart:async/zone.dart:1146)
-// #14 _CustomZone.run (dart:async/zone.dart:1026)
-// #15 _CustomZone.runGuarded (dart:async/zone.dart:924)
-// #16 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
-// #17 _rootRun (dart:async/zone.dart:1150)
-// #18 _CustomZone.run (dart:async/zone.dart:1026)
-// #19 _CustomZone.runGuarded (dart:async/zone.dart:924)
-// #20 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
-// #21 _microtaskLoop (dart:async/schedule_microtask.dart:41)
-// #22 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
-// #23 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:394)
-// #24 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:414)
-// #25 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
-//
-// Caused by Bad state: Unmatched ClassElementImpl class B
-// #0 ElementWalker.validate.check (package:analyzer/src/generated/declaration_resolver.dart:690:9)
-// #1 ElementWalker.validate (package:analyzer/src/generated/declaration_resolver.dart:696:10)
-// #2 DeclarationResolver.resolve (package:analyzer/src/generated/declaration_resolver.dart:48:15)
-// #3 BuildCompilationUnitElementTask.internalPerform (package:analyzer/src/task/dart.dart:1084:33)
-// #4 AnalysisTask._safelyPerform (package:analyzer/task/model.dart:321:9)
-// #5 AnalysisTask.perform (package:analyzer/task/model.dart:220:7)
-// #6 AnalysisDriver.performWorkItem (package:analyzer/src/task/driver.dart:284:10)
-// #7 AnalysisDriver.computeResult (package:analyzer/src/task/driver.dart:109:22)
-// #8 AnalysisContextImpl.computeResult (package:analyzer/src/context/context.dart:723:14)
-// #9 AnalysisContextImpl.computeErrors (package:analyzer/src/context/context.dart:665:12)
-// #10 AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:658:54)
-// #11 PerformanceLog.run (package:analyzer/src/dart/analysis/driver.dart:1427:15)
-// #12 AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:643:20)
-// #13 AnalysisDriver._performWork.<_performWork_async_body> (package:analyzer/src/dart/analysis/driver.dart:910:33)
-// #14 Future.Future.microtask.<anonymous closure> (dart:async/future.dart:184)
-// #15 _rootRun (dart:async/zone.dart:1146)
-// #16 _CustomZone.run (dart:async/zone.dart:1026)
-// #17 _CustomZone.runGuarded (dart:async/zone.dart:924)
-// #18 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
-// #19 _rootRun (dart:async/zone.dart:1150)
-// #20 _CustomZone.run (dart:async/zone.dart:1026)
-// #21 _CustomZone.runGuarded (dart:async/zone.dart:924)
-// #22 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
-// #23 _microtaskLoop (dart:async/schedule_microtask.dart:41)
-// #24 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
-// #25 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:394)
-// #26 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:414)
-// #27 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
-// return super.test_partFile_TypeName2();
- fail('Throws background exception.');
- }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart
index 7668499..603a1c2 100644
--- a/pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart
@@ -471,86 +471,6 @@
@failingTest
@override
- test_import_file() {
-// expected other.dart CompletionSuggestionKind.IMPORT null
-// found
-// dart: -> {"kind":"IMPORT","relevance":1000,"completion":"dart:","selectionOffset":5,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:async -> {"kind":"IMPORT","relevance":1000,"completion":"dart:async","selectionOffset":10,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:collection -> {"kind":"IMPORT","relevance":1000,"completion":"dart:collection","selectionOffset":15,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:convert -> {"kind":"IMPORT","relevance":1000,"completion":"dart:convert","selectionOffset":12,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:core -> {"kind":"IMPORT","relevance":500,"completion":"dart:core","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:html -> {"kind":"IMPORT","relevance":1000,"completion":"dart:html","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:math -> {"kind":"IMPORT","relevance":1000,"completion":"dart:math","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// package: -> {"kind":"IMPORT","relevance":1000,"completion":"package:","selectionOffset":8,"selectionLength":0,"isDeprecated":false,"isPotential":false}
- return super.test_import_file();
- }
-
- @failingTest
- @override
- test_import_file2() {
-// expected other.dart CompletionSuggestionKind.IMPORT null
-// found
-// dart: -> {"kind":"IMPORT","relevance":1000,"completion":"dart:","selectionOffset":5,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:async -> {"kind":"IMPORT","relevance":1000,"completion":"dart:async","selectionOffset":10,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:collection -> {"kind":"IMPORT","relevance":1000,"completion":"dart:collection","selectionOffset":15,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:convert -> {"kind":"IMPORT","relevance":1000,"completion":"dart:convert","selectionOffset":12,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:core -> {"kind":"IMPORT","relevance":500,"completion":"dart:core","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:html -> {"kind":"IMPORT","relevance":1000,"completion":"dart:html","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:math -> {"kind":"IMPORT","relevance":1000,"completion":"dart:math","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// package: -> {"kind":"IMPORT","relevance":1000,"completion":"package:","selectionOffset":8,"selectionLength":0,"isDeprecated":false,"isPotential":false}
- return super.test_import_file2();
- }
-
- @failingTest
- @override
- test_import_file_child() {
-// expected foo/bar.dart CompletionSuggestionKind.IMPORT null
-// found
-// dart: -> {"kind":"IMPORT","relevance":1000,"completion":"dart:","selectionOffset":5,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:async -> {"kind":"IMPORT","relevance":1000,"completion":"dart:async","selectionOffset":10,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:collection -> {"kind":"IMPORT","relevance":1000,"completion":"dart:collection","selectionOffset":15,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:convert -> {"kind":"IMPORT","relevance":1000,"completion":"dart:convert","selectionOffset":12,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:core -> {"kind":"IMPORT","relevance":500,"completion":"dart:core","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:html -> {"kind":"IMPORT","relevance":1000,"completion":"dart:html","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:math -> {"kind":"IMPORT","relevance":1000,"completion":"dart:math","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// package: -> {"kind":"IMPORT","relevance":1000,"completion":"package:","selectionOffset":8,"selectionLength":0,"isDeprecated":false,"isPotential":false}
- return super.test_import_file_child();
- }
-
- @failingTest
- @override
- test_import_file_parent() {
-// expected ../blat.dart CompletionSuggestionKind.IMPORT null
-// found
-// dart: -> {"kind":"IMPORT","relevance":1000,"completion":"dart:","selectionOffset":5,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:async -> {"kind":"IMPORT","relevance":1000,"completion":"dart:async","selectionOffset":10,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:collection -> {"kind":"IMPORT","relevance":1000,"completion":"dart:collection","selectionOffset":15,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:convert -> {"kind":"IMPORT","relevance":1000,"completion":"dart:convert","selectionOffset":12,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:core -> {"kind":"IMPORT","relevance":500,"completion":"dart:core","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:html -> {"kind":"IMPORT","relevance":1000,"completion":"dart:html","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:math -> {"kind":"IMPORT","relevance":1000,"completion":"dart:math","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// package: -> {"kind":"IMPORT","relevance":1000,"completion":"package:","selectionOffset":8,"selectionLength":0,"isDeprecated":false,"isPotential":false}
- return super.test_import_file_parent();
- }
-
- @failingTest
- @override
- test_import_file_parent2() {
-// expected ../blat.dart CompletionSuggestionKind.IMPORT null
-// found
-// dart: -> {"kind":"IMPORT","relevance":1000,"completion":"dart:","selectionOffset":5,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:async -> {"kind":"IMPORT","relevance":1000,"completion":"dart:async","selectionOffset":10,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:collection -> {"kind":"IMPORT","relevance":1000,"completion":"dart:collection","selectionOffset":15,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:convert -> {"kind":"IMPORT","relevance":1000,"completion":"dart:convert","selectionOffset":12,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:core -> {"kind":"IMPORT","relevance":500,"completion":"dart:core","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:html -> {"kind":"IMPORT","relevance":1000,"completion":"dart:html","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:math -> {"kind":"IMPORT","relevance":1000,"completion":"dart:math","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// package: -> {"kind":"IMPORT","relevance":1000,"completion":"package:","selectionOffset":8,"selectionLength":0,"isDeprecated":false,"isPotential":false}
- return super.test_import_file_parent2();
- }
-
- @failingTest
- @override
test_part_file() {
// NoSuchMethodError: The getter 'uri' was called on null.
// Receiver: null
@@ -834,86 +754,6 @@
@failingTest
@override
- test_import_file() {
-// expected other.dart CompletionSuggestionKind.IMPORT null
-// found
-// dart: -> {"kind":"IMPORT","relevance":1000,"completion":"dart:","selectionOffset":5,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:async -> {"kind":"IMPORT","relevance":1000,"completion":"dart:async","selectionOffset":10,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:collection -> {"kind":"IMPORT","relevance":1000,"completion":"dart:collection","selectionOffset":15,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:convert -> {"kind":"IMPORT","relevance":1000,"completion":"dart:convert","selectionOffset":12,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:core -> {"kind":"IMPORT","relevance":500,"completion":"dart:core","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:html -> {"kind":"IMPORT","relevance":1000,"completion":"dart:html","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:math -> {"kind":"IMPORT","relevance":1000,"completion":"dart:math","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// package: -> {"kind":"IMPORT","relevance":1000,"completion":"package:","selectionOffset":8,"selectionLength":0,"isDeprecated":false,"isPotential":false}
- return super.test_import_file();
- }
-
- @failingTest
- @override
- test_import_file2() {
-// expected other.dart CompletionSuggestionKind.IMPORT null
-// found
-// dart: -> {"kind":"IMPORT","relevance":1000,"completion":"dart:","selectionOffset":5,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:async -> {"kind":"IMPORT","relevance":1000,"completion":"dart:async","selectionOffset":10,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:collection -> {"kind":"IMPORT","relevance":1000,"completion":"dart:collection","selectionOffset":15,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:convert -> {"kind":"IMPORT","relevance":1000,"completion":"dart:convert","selectionOffset":12,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:core -> {"kind":"IMPORT","relevance":500,"completion":"dart:core","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:html -> {"kind":"IMPORT","relevance":1000,"completion":"dart:html","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:math -> {"kind":"IMPORT","relevance":1000,"completion":"dart:math","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// package: -> {"kind":"IMPORT","relevance":1000,"completion":"package:","selectionOffset":8,"selectionLength":0,"isDeprecated":false,"isPotential":false}
- return super.test_import_file2();
- }
-
- @failingTest
- @override
- test_import_file_child() {
-// expected foo/bar.dart CompletionSuggestionKind.IMPORT null
-// found
-// dart: -> {"kind":"IMPORT","relevance":1000,"completion":"dart:","selectionOffset":5,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:async -> {"kind":"IMPORT","relevance":1000,"completion":"dart:async","selectionOffset":10,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:collection -> {"kind":"IMPORT","relevance":1000,"completion":"dart:collection","selectionOffset":15,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:convert -> {"kind":"IMPORT","relevance":1000,"completion":"dart:convert","selectionOffset":12,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:core -> {"kind":"IMPORT","relevance":500,"completion":"dart:core","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:html -> {"kind":"IMPORT","relevance":1000,"completion":"dart:html","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:math -> {"kind":"IMPORT","relevance":1000,"completion":"dart:math","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// package: -> {"kind":"IMPORT","relevance":1000,"completion":"package:","selectionOffset":8,"selectionLength":0,"isDeprecated":false,"isPotential":false}
- return super.test_import_file_child();
- }
-
- @failingTest
- @override
- test_import_file_parent() {
-// expected ../blat.dart CompletionSuggestionKind.IMPORT null
-// found
-// dart: -> {"kind":"IMPORT","relevance":1000,"completion":"dart:","selectionOffset":5,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:async -> {"kind":"IMPORT","relevance":1000,"completion":"dart:async","selectionOffset":10,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:collection -> {"kind":"IMPORT","relevance":1000,"completion":"dart:collection","selectionOffset":15,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:convert -> {"kind":"IMPORT","relevance":1000,"completion":"dart:convert","selectionOffset":12,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:core -> {"kind":"IMPORT","relevance":500,"completion":"dart:core","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:html -> {"kind":"IMPORT","relevance":1000,"completion":"dart:html","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:math -> {"kind":"IMPORT","relevance":1000,"completion":"dart:math","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// package: -> {"kind":"IMPORT","relevance":1000,"completion":"package:","selectionOffset":8,"selectionLength":0,"isDeprecated":false,"isPotential":false}
- return super.test_import_file_parent();
- }
-
- @failingTest
- @override
- test_import_file_parent2() {
-// expected ../blat.dart CompletionSuggestionKind.IMPORT null
-// found
-// dart: -> {"kind":"IMPORT","relevance":1000,"completion":"dart:","selectionOffset":5,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:async -> {"kind":"IMPORT","relevance":1000,"completion":"dart:async","selectionOffset":10,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:collection -> {"kind":"IMPORT","relevance":1000,"completion":"dart:collection","selectionOffset":15,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:convert -> {"kind":"IMPORT","relevance":1000,"completion":"dart:convert","selectionOffset":12,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:core -> {"kind":"IMPORT","relevance":500,"completion":"dart:core","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:html -> {"kind":"IMPORT","relevance":1000,"completion":"dart:html","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// dart:math -> {"kind":"IMPORT","relevance":1000,"completion":"dart:math","selectionOffset":9,"selectionLength":0,"isDeprecated":false,"isPotential":false}
-// package: -> {"kind":"IMPORT","relevance":1000,"completion":"package:","selectionOffset":8,"selectionLength":0,"isDeprecated":false,"isPotential":false}
- return super.test_import_file_parent2();
- }
-
- @failingTest
- @override
test_part_file() {
// NoSuchMethodError: The getter 'uri' was called on null.
// Receiver: null
diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart
index aff6dd2..b079561 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -4268,8 +4268,12 @@
_assertLinkedGroup(
change.linkedEditGroups[2],
['List<int> items) {'],
- expectedSuggestions(LinkedEditSuggestionKind.TYPE,
- ['List<int>', 'Iterable<int>', 'Object']));
+ expectedSuggestions(LinkedEditSuggestionKind.TYPE, [
+ 'List<int>',
+ 'EfficientLengthIterable<int>',
+ 'Iterable<int>',
+ 'Object'
+ ]));
}
test_undefinedFunction_create_importType() async {
@@ -4908,7 +4912,7 @@
change.linkedEditGroups[index++],
['String s'],
expectedSuggestions(LinkedEditSuggestionKind.TYPE,
- ['String', 'Object', 'Comparable<String>']));
+ ['String', 'Object', 'Comparable<String>', 'Pattern']));
_assertLinkedGroup(change.linkedEditGroups[index++], ['s)']);
}
@@ -4952,7 +4956,7 @@
change.linkedEditGroups[index++],
['String ccc'],
expectedSuggestions(LinkedEditSuggestionKind.TYPE,
- ['String', 'Object', 'Comparable<String>']));
+ ['String', 'Object', 'Comparable<String>', 'Pattern']));
}
test_undefinedMethod_createUnqualified_returnType() async {
diff --git a/pkg/analysis_server/test/services/dependencies/reachable_source_collector_test.dart b/pkg/analysis_server/test/services/dependencies/reachable_source_collector_test.dart
index 23eaf32..94874f9 100644
--- a/pkg/analysis_server/test/services/dependencies/reachable_source_collector_test.dart
+++ b/pkg/analysis_server/test/services/dependencies/reachable_source_collector_test.dart
@@ -48,37 +48,28 @@
Source lib3 = addSource('/lib3.dart', 'import "lib4.dart";');
addSource('/lib4.dart', 'import "lib3.dart";');
- Map<String, List<String>> imports = importsFor(lib1);
-
- // Verify keys.
- expect(
- imports.keys,
- unorderedEquals([
- 'dart:_internal',
- 'dart:async',
- 'dart:core',
- 'dart:html',
- 'dart:math',
- 'file:///lib1.dart',
- 'file:///lib2.dart',
- ]));
- // Values.
- expect(imports['file:///lib1.dart'],
- unorderedEquals(['dart:core', 'dart:html', 'file:///lib2.dart']));
+ {
+ Map<String, List<String>> imports = importsFor(lib1);
+ expect(imports.keys, contains('file:///lib1.dart'));
+ expect(imports.keys, contains('file:///lib2.dart'));
+ expect(imports.keys, contains('dart:core'));
+ expect(imports.keys, contains('dart:html'));
+ expect(imports.keys, contains('dart:math'));
+ expect(imports.keys, isNot(contains('file:///lib3.dart')));
+ expect(imports['file:///lib1.dart'],
+ unorderedEquals(['dart:core', 'dart:html', 'file:///lib2.dart']));
+ }
// Check transitivity.
expect(importsFor(lib2).keys, contains('dart:html'));
// Cycles should be OK.
- expect(
- importsFor(lib3).keys,
- unorderedEquals([
- 'dart:_internal',
- 'dart:async',
- 'dart:core',
- 'dart:math',
- 'file:///lib3.dart',
- 'file:///lib4.dart'
- ]));
+ {
+ Map<String, List<String>> imports = importsFor(lib3);
+ expect(imports.keys, contains('file:///lib3.dart'));
+ expect(imports.keys, contains('file:///lib4.dart'));
+ expect(imports.keys, contains('dart:core'));
+ expect(imports.keys, contains('dart:math'));
+ }
}
}
diff --git a/pkg/analysis_server/test/services/search/hierarchy_test.dart b/pkg/analysis_server/test/services/search/hierarchy_test.dart
index 136d12e..1762d57 100644
--- a/pkg/analysis_server/test/services/search/hierarchy_test.dart
+++ b/pkg/analysis_server/test/services/search/hierarchy_test.dart
@@ -276,16 +276,34 @@
{
ClassElement classA = findElement('A');
List<Element> members = getMembers(classA);
- expect(members.map((e) => e.name),
- unorderedEquals(['ma1', 'ma2', '==', 'toString', 'hashCode']));
+ expect(
+ members.map((e) => e.name),
+ unorderedEquals([
+ 'ma1',
+ 'ma2',
+ '==',
+ 'toString',
+ 'hashCode',
+ 'noSuchMethod',
+ 'runtimeType'
+ ]));
}
{
ClassElement classB = findElement('B');
List<Element> members = getMembers(classB);
expect(
members.map((e) => e.name),
- unorderedEquals(
- ['mb1', 'mb2', 'ma1', 'ma2', '==', 'toString', 'hashCode']));
+ unorderedEquals([
+ 'mb1',
+ 'mb2',
+ 'ma1',
+ 'ma2',
+ '==',
+ 'toString',
+ 'hashCode',
+ 'noSuchMethod',
+ 'runtimeType'
+ ]));
}
}
diff --git a/pkg/analysis_server/test/stress/replay/replay.dart b/pkg/analysis_server/test/stress/replay/replay.dart
index e5525e7..2ca74e4 100644
--- a/pkg/analysis_server/test/stress/replay/replay.dart
+++ b/pkg/analysis_server/test/stress/replay/replay.dart
@@ -5,8 +5,6 @@
/**
* A stress test for the analysis server.
*/
-library analysis_server.test.stress.replay.replay;
-
import 'dart:async';
import 'dart:io';
import 'dart:math' as math;
@@ -23,13 +21,14 @@
import 'package:path/path.dart' as path;
import '../utilities/git.dart';
+import '../utilities/logger.dart';
import '../utilities/server.dart';
import 'operation.dart';
/**
* Run the simulation based on the given command-line [arguments].
*/
-Future main(List<String> arguments) async {
+Future<Null> main(List<String> arguments) async {
Driver driver = new Driver();
await driver.run(arguments);
}
@@ -74,6 +73,12 @@
static const String TEMP_BRANCH_NAME = 'temp';
/**
+ * The name of the command-line flag that will cause verbose output to be
+ * produced.
+ */
+ static String VERBOSE_FLAG_NAME = 'verbose';
+
+ /**
* The style of interaction to use for analysis.updateContent requests.
*/
OverlayStyle overlayStyle;
@@ -96,7 +101,7 @@
/**
* The connection to the analysis server.
*/
- Server server = new Server();
+ Server server;
/**
* A list of the glob patterns used to identify the files being analyzed by
@@ -110,6 +115,16 @@
Statistics statistics;
/**
+ * A flag indicating whether verbose output should be provided.
+ */
+ bool verbose = false;
+
+ /**
+ * The logger to which verbose logging data will be written.
+ */
+ Logger logger;
+
+ /**
* Initialize a newly created driver.
*/
Driver() {
@@ -117,15 +132,27 @@
}
/**
+ * Allow the output from the server to be read and processed.
+ */
+ Future<Null> readServerOutput() async {
+ await new Future.delayed(new Duration(milliseconds: 2));
+ }
+
+ /**
* Run the simulation based on the given command-line arguments ([args]).
*/
- Future run(List<String> args) async {
+ Future<Null> run(List<String> args) async {
//
// Process the command-line arguments.
//
if (!_processCommandLine(args)) {
return null;
}
+ if (verbose) {
+ stdout.writeln();
+ stdout.writeln('-' * 80);
+ stdout.writeln();
+ }
//
// Simulate interactions with the server.
//
@@ -133,7 +160,16 @@
//
// Print out statistics gathered while performing the simulation.
//
+ if (verbose) {
+ stdout.writeln();
+ stdout.writeln('-' * 80);
+ }
+ stdout.writeln();
statistics.print();
+ if (verbose) {
+ stdout.writeln();
+ server.printStatistics();
+ }
exit(0);
return null;
}
@@ -149,7 +185,6 @@
help: 'Print usage information',
defaultsTo: false,
negatable: false);
-
parser.addOption(OVERLAY_STYLE_OPTION_NAME,
help:
'The style of interaction to use for analysis.updateContent requests',
@@ -159,6 +194,11 @@
MULTIPLE_ADD_OVERLAY_STYLE: '<add>+ <remove>'
},
defaultsTo: 'change');
+ parser.addFlag(VERBOSE_FLAG_NAME,
+ abbr: 'v',
+ help: 'Produce verbose output for debugging',
+ defaultsTo: false,
+ negatable: false);
return parser;
}
@@ -286,13 +326,18 @@
overlayStyle = OverlayStyle.multipleAdd;
}
- List<String> arguments = results.arguments;
+ if (results[VERBOSE_FLAG_NAME]) {
+ verbose = true;
+ logger = new Logger(stdout);
+ }
+
+ List<String> arguments = results.rest;
if (arguments.length < 2) {
_showUsage(parser);
return false;
}
repositoryPath = path.normalize(arguments[0]);
- repository = new GitRepository(repositoryPath);
+ repository = new GitRepository(repositoryPath, logger: logger);
analysisRoots = arguments
.sublist(1)
@@ -312,66 +357,69 @@
/**
* Replay the changes in each commit.
*/
- Future _replayChanges() async {
+ Future<Null> _replayChanges() async {
//
// Get the revision history of the repo.
//
LinearCommitHistory history = repository.getCommitHistory();
statistics.commitCount = history.commitIds.length;
LinearCommitHistoryIterator iterator = history.iterator();
- //
- // Iterate over the history, applying changes.
- //
- int dotCount = 0;
- bool firstCheckout = true;
- ErrorMap expectedErrors = null;
- Iterable<String> changedPubspecs;
- while (iterator.moveNext()) {
+ try {
//
- // Checkout the commit on which the changes are based.
+ // Iterate over the history, applying changes.
//
- String commit = iterator.srcCommit;
- repository.checkout(commit);
- if (expectedErrors != null) {
- ErrorMap actualErrors =
- await server.computeErrorMap(server.analyzedDartFiles);
- String difference = expectedErrors.expectErrorMap(actualErrors);
- if (difference != null) {
- stdout.write('Mismatched errors after commit ');
- stdout.writeln(commit);
- stdout.writeln();
- stdout.writeln(difference);
- return;
+ bool firstCheckout = true;
+ ErrorMap expectedErrors = null;
+ Iterable<String> changedPubspecs;
+ while (iterator.moveNext()) {
+ //
+ // Checkout the commit on which the changes are based.
+ //
+ String commit = iterator.srcCommit;
+ repository.checkout(commit);
+ if (expectedErrors != null) {
+// ErrorMap actualErrors =
+ await server.computeErrorMap(server.analyzedDartFiles);
+// String difference = expectedErrors.expectErrorMap(actualErrors);
+// if (difference != null) {
+// stdout.write('Mismatched errors after commit ');
+// stdout.writeln(commit);
+// stdout.writeln();
+// stdout.writeln(difference);
+// return;
+// }
}
+ if (firstCheckout) {
+ changedPubspecs = _findPubspecsInAnalysisRoots();
+ server.sendAnalysisSetAnalysisRoots(analysisRoots, []);
+ firstCheckout = false;
+ } else {
+ server.removeAllOverlays();
+ }
+ await readServerOutput();
+ expectedErrors = await server.computeErrorMap(server.analyzedDartFiles);
+ for (String filePath in changedPubspecs) {
+ _runPub(filePath);
+ }
+ //
+ // Apply the changes.
+ //
+ CommitDelta commitDelta = iterator.next();
+ commitDelta.filterDiffs(analysisRoots, fileGlobs);
+ if (commitDelta.hasDiffs) {
+ statistics.commitsWithChangeInRootCount++;
+ await _replayDiff(commitDelta);
+ }
+ changedPubspecs = commitDelta.filesMatching(PUBSPEC_FILE_NAME);
}
- if (firstCheckout) {
- changedPubspecs = _findPubspecsInAnalysisRoots();
- server.sendAnalysisSetAnalysisRoots(analysisRoots, []);
- firstCheckout = false;
- } else {
- server.removeAllOverlays();
- }
- expectedErrors = await server.computeErrorMap(server.analyzedDartFiles);
- for (String filePath in changedPubspecs) {
- _runPub(filePath);
- }
- //
- // Apply the changes.
- //
- CommitDelta commitDelta = iterator.next();
- commitDelta.filterDiffs(analysisRoots, fileGlobs);
- if (commitDelta.hasDiffs) {
- statistics.commitsWithChangeInRootCount++;
- _replayDiff(commitDelta);
- }
- changedPubspecs = commitDelta.filesMatching(PUBSPEC_FILE_NAME);
- stdout.write('.');
- if (dotCount++ > 100) {
- stdout.writeln();
- dotCount = 0;
+ } finally {
+ // Ensure that the repository is left at the most recent commit.
+ if (history.commitIds.length > 0) {
+ repository.checkout(history.commitIds[0]);
}
}
server.removeAllOverlays();
+ await readServerOutput();
stdout.writeln();
}
@@ -379,7 +427,7 @@
* Replay the changes between two commits, as represented by the given
* [commitDelta].
*/
- void _replayDiff(CommitDelta commitDelta) {
+ Future<Null> _replayDiff(CommitDelta commitDelta) async {
List<FileEdit> editList = <FileEdit>[];
for (DiffRecord record in commitDelta.diffRecords) {
FileEdit edit = new FileEdit(overlayStyle, record);
@@ -404,7 +452,9 @@
AnalysisService.OVERRIDES: currentFile
});
for (ServerOperation operation in edit.getOperations()) {
+ statistics.editCount++;
operation.perform(server);
+ await readServerOutput();
}
}
}
@@ -424,7 +474,8 @@
/**
* Run the simulation by starting up a server and sending it requests.
*/
- Future _runSimulation() async {
+ Future<Null> _runSimulation() async {
+ server = new Server(logger: logger);
Stopwatch stopwatch = new Stopwatch();
statistics.stopwatch = stopwatch;
stopwatch.start();
@@ -443,6 +494,8 @@
try {
await _replayChanges();
} finally {
+ // TODO(brianwilkerson) This needs to be moved into a Zone in order to
+ // ensure that it is always run.
server.sendServerShutdown();
repository.checkout('master');
}
@@ -450,7 +503,7 @@
}
/**
- * Display usage information, preceeded by the [errorMessage] if one is given.
+ * Display usage information, preceded by the [errorMessage] if one is given.
*/
void _showUsage(ArgParser parser, [String errorMessage = null]) {
if (errorMessage != null) {
@@ -469,7 +522,7 @@
There must be at least one analysis root, and all of the analysis roots must be
the absolute path of a directory contained within the repository directory. The
-analysis roots represent the portion of the repository that will be analyzed by
+analysis roots represent the portions of the repository that will be analyzed by
the analysis server.
OPTIONS:''');
@@ -604,6 +657,11 @@
int commitsWithChangeInRootCount = 0;
/**
+ * The total number of edits that were applied.
+ */
+ int editCount = 0;
+
+ /**
* Initialize a newly created set of statistics.
*/
Statistics(this.driver);
@@ -622,6 +680,8 @@
stdout.writeln(commitCount);
stdout.write(' number of commits with a change in an analysis root = ');
stdout.writeln(commitsWithChangeInRootCount);
+ stdout.write(' number of edits = ');
+ stdout.writeln(editCount);
}
/**
diff --git a/pkg/analysis_server/test/stress/utilities/git.dart b/pkg/analysis_server/test/stress/utilities/git.dart
index 32c7e9b..cfcef4f 100644
--- a/pkg/analysis_server/test/stress/utilities/git.dart
+++ b/pkg/analysis_server/test/stress/utilities/git.dart
@@ -5,14 +5,14 @@
/**
* Support for interacting with a git repository.
*/
-library analysis_server.test.stress.utilities.git;
-
import 'dart:convert';
import 'dart:io';
import 'package:analyzer/src/util/glob.dart';
import 'package:path/path.dart' as path;
+import 'logger.dart';
+
/**
* A representation of the differences between two blobs.
*/
@@ -395,10 +395,18 @@
final String path;
/**
+ * The logger to which git commands should be written, or `null` if the
+ * commands should not be written.
+ */
+ final Logger logger;
+
+ /**
* Initialize a newly created repository to represent the git repository at
* the given [path].
+ *
+ * If a [commandSink] is provided, any calls to git will be written to it.
*/
- GitRepository(this.path);
+ GitRepository(this.path, {this.logger = null});
/**
* Checkout the given [commit] from the repository. This is done by running
@@ -454,6 +462,7 @@
* the result of running the process.
*/
ProcessResult _run(List<String> arguments) {
+ logger?.log('git', 'git', arguments: arguments);
return Process.runSync('git', arguments,
stderrEncoding: UTF8, stdoutEncoding: UTF8, workingDirectory: path);
}
diff --git a/pkg/analysis_server/test/stress/utilities/logger.dart b/pkg/analysis_server/test/stress/utilities/logger.dart
new file mode 100644
index 0000000..acf7a74
--- /dev/null
+++ b/pkg/analysis_server/test/stress/utilities/logger.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2017, 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 file.
+
+/**
+ * A utility class used to write logging information during a test.
+ */
+class Logger {
+ /**
+ * The width of the field in which labels are printed.
+ */
+ static const int _labelWidth = 8;
+
+ /**
+ * The separator used to separate the label from the content.
+ */
+ static const String _separator = ' : ';
+
+ /**
+ * The sink to which the logged information should be written.
+ */
+ final StringSink sink;
+
+ /**
+ * Initialize a newly created logger to write to the given [sink].
+ */
+ Logger(this.sink);
+
+ /**
+ * Log the given information.
+ *
+ * The [label] is used to indicate the kind of information being logged, while
+ * the [content] contains the actual information. If a list of [arguments] is
+ * provided, then they will be written after the content.
+ */
+ void log(String label, String content, {List<String> arguments = null}) {
+ for (int i = _labelWidth - label.length; i > 0; i--) {
+ sink.write(' ');
+ }
+ sink.write(label);
+ sink.write(_separator);
+ sink.write(content);
+ arguments?.forEach((String argument) {
+ sink.write(' ');
+ sink.write(argument);
+ });
+ sink.writeln();
+ }
+}
diff --git a/pkg/analysis_server/test/stress/utilities/server.dart b/pkg/analysis_server/test/stress/utilities/server.dart
index ee52fdd..88a44ce 100644
--- a/pkg/analysis_server/test/stress/utilities/server.dart
+++ b/pkg/analysis_server/test/stress/utilities/server.dart
@@ -3,18 +3,24 @@
// BSD-style license that can be found in the LICENSE file.
/**
- * Support for interacting with an analysis server running in a separate
+ * Support for interacting with an analysis server that is running in a separate
* process.
*/
-library analysis_server.test.stress.utilities.server;
-
import 'dart:async';
import 'dart:collection';
+import 'dart:convert' hide JsonDecoder;
+import 'dart:io';
+import 'dart:math' as math;
import 'package:analysis_server/plugin/protocol/protocol.dart';
+import 'package:path/path.dart' as path;
-import '../../integration/integration_test_methods.dart';
-import '../../integration/integration_tests.dart' as base;
+import 'logger.dart';
+
+/**
+ * Return the current time expressed as milliseconds since the epoch.
+ */
+int get currentTime => new DateTime.now().millisecondsSinceEpoch;
/**
* ???
@@ -59,36 +65,222 @@
}
/**
- * An interface for starting and communicating with an analysis server running
- * in a separate process.
+ * Data that has been collected about a request sent to the server.
*/
-class Server extends base.Server with IntegrationTestMixin {
+class RequestData {
+ /**
+ * The unique id of the request.
+ */
+ final String id;
+
+ /**
+ * The method that was requested.
+ */
+ final String method;
+
+ /**
+ * The request parameters.
+ */
+ final Map<String, dynamic> params;
+
+ /**
+ * The time at which the request was sent.
+ */
+ final int requestTime;
+
+ /**
+ * The time at which the response was received, or `null` if no response has
+ * been received.
+ */
+ int responseTime = null;
+
+ /**
+ * The response that was received.
+ */
+ Response _response;
+
+ /**
+ * The completer that will be completed when a response is received.
+ */
+ Completer<Response> _responseCompleter;
+
+ /**
+ * Initialize a newly created set of request data.
+ */
+ RequestData(this.id, this.method, this.params, this.requestTime);
+
+ /**
+ * Return the number of milliseconds that elapsed betwee the request and the
+ * response. This getter assumes that the response was received.
+ */
+ int get elapsedTime => responseTime - requestTime;
+
+ /**
+ * Return a future that will complete when a response is received.
+ */
+ Future<Response> get respondedTo {
+ if (_response != null) {
+ return new Future.value(_response);
+ }
+ if (_responseCompleter == null) {
+ _responseCompleter = new Completer<Response>();
+ }
+ return _responseCompleter.future;
+ }
+
+ /**
+ * Record that the given [response] was received.
+ */
+ void recordResponse(Response response) {
+ if (_response != null) {
+ stdout.writeln(
+ 'Received a second response to a $method request (id = $id)');
+ return;
+ }
+ responseTime = currentTime;
+ _response = response;
+ if (_responseCompleter != null) {
+ _responseCompleter.complete(response);
+ _responseCompleter = null;
+ }
+ }
+}
+
+/**
+ * A utility for starting and communicating with an analysis server that is
+ * running in a separate process.
+ */
+class Server {
+ /**
+ * The label used for communications from the client.
+ */
+ static const String fromClient = 'client';
+
+ /**
+ * The label used for normal communications from the server.
+ */
+ static const String fromServer = 'server';
+
+ /**
+ * The label used for output written by the server on [fromStderr].
+ */
+ static const String fromStderr = 'stderr';
+
+ /**
+ * The logger to which the communications log should be written, or `null` if
+ * the log should not be written.
+ */
+ final Logger logger;
+
+ /**
+ * The process in which the server is running, or `null` if the server hasn't
+ * been started yet.
+ */
+ Process _process = null;
+
+ /**
+ * Number that should be used to compute the 'id' to send in the next command
+ * sent to the server.
+ */
+ int _nextId = 0;
+
+ /**
+ * The analysis roots that are included.
+ */
+ List<String> _analysisRootIncludes = <String>[];
+
+ /**
+ * The analysis roots that are excluded.
+ */
+ List<String> _analysisRootExcludes = <String>[];
+
/**
* A list containing the paths of files for which an overlay has been created.
*/
List<String> filesWithOverlays = <String>[];
/**
+ * The files that the server reported as being analyzed.
+ */
+ List<String> _analyzedFiles = <String>[];
+
+ /**
* A mapping from the absolute paths of files to the most recent set of errors
* received for that file.
*/
ErrorMap _errorMap = new ErrorMap();
/**
+ * The completer that will be completed the next time a 'server.status'
+ * notification is received from the server with 'analyzing' set to false.
+ */
+ Completer<Null> _analysisFinishedCompleter;
+
+ /**
+ * The completer that will be completed the next time a 'server.connected'
+ * notification is received from the server.
+ */
+ Completer<Null> _serverConnectedCompleter;
+
+ /**
+ * A table mapping the ids of requests that have been sent to the server to
+ * data about those requests.
+ */
+ final Map<String, RequestData> _requestDataMap = <String, RequestData>{};
+
+ /**
+ * A table mapping the number of times a request whose 'event' is equal to the
+ * key was sent to the server.
+ */
+ final Map<String, int> _notificationCountMap = <String, int>{};
+
+ /**
* Initialize a new analysis server. The analysis server is not running and
* must be started using [start].
+ *
+ * If a [logger] is provided, the communications between the client (this
+ * test) and the server will be written to it.
*/
- Server() {
- initializeInttestMixin();
- onAnalysisErrors.listen(_recordErrors);
+ Server({this.logger = null});
+
+ /**
+ * Return a future that will complete when a 'server.status' notification is
+ * received from the server with 'analyzing' set to false.
+ *
+ * The future will only be completed by 'server.status' notifications that are
+ * received after this function call, so it is safe to use this getter
+ * multiple times in one test; each time it is used it will wait afresh for
+ * analysis to finish.
+ */
+ Future get analysisFinished {
+ if (_analysisFinishedCompleter == null) {
+ _analysisFinishedCompleter = new Completer();
+ }
+ return _analysisFinishedCompleter.future;
}
/**
* Return a list of the paths of files that are currently being analyzed.
*/
List<String> get analyzedDartFiles {
- // TODO(brianwilkerson) Implement this.
- return <String>[];
+ bool isAnalyzed(String filePath) {
+ // TODO(brianwilkerson) This should use the path package to determine
+ // inclusion, and needs to take exclusions into account.
+ for (String includedRoot in _analysisRootIncludes) {
+ if (filePath.startsWith(includedRoot)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ List<String> analyzedFiles = <String>[];
+ for (String filePath in _analyzedFiles) {
+ if (filePath.endsWith('.dart') && isAnalyzed(filePath)) {
+ analyzedFiles.add(filePath);
+ }
+ }
+ return analyzedFiles;
}
/**
@@ -98,9 +290,6 @@
*/
ErrorMap get errorMap => new ErrorMap.from(_errorMap);
- @override
- base.Server get server => this;
-
/**
* Compute a mapping from each of the file paths in the given list of
* [filePaths] to the list of errors in the file at that path.
@@ -109,9 +298,13 @@
ErrorMap errorMap = new ErrorMap();
List<Future> futures = <Future>[];
for (String filePath in filePaths) {
- futures.add(sendAnalysisGetErrors(filePath)
- .then((AnalysisGetErrorsResult result) {
- errorMap[filePath] = result.errors;
+ RequestData requestData = sendAnalysisGetErrors(filePath);
+ futures.add(requestData.respondedTo.then((Response response) {
+ if (response.result != null) {
+ AnalysisGetErrorsResult result =
+ new AnalysisGetErrorsResult.fromResponse(response);
+ errorMap[filePath] = result.errors;
+ }
}));
}
await Future.wait(futures);
@@ -119,19 +312,168 @@
}
/**
+ * Print information about the communications with the server.
+ */
+ void printStatistics() {
+ void writeSpaces(int count) {
+ for (int i = 0; i < count; i++) {
+ stdout.write(' ');
+ }
+ }
+
+ //
+ // Print information about the requests that were sent.
+ //
+ stdout.writeln('Request Counts');
+ if (_requestDataMap.isEmpty) {
+ stdout.writeln(' none');
+ } else {
+ Map<String, List<RequestData>> requestsByMethod =
+ <String, List<RequestData>>{};
+ _requestDataMap.values.forEach((RequestData requestData) {
+ requestsByMethod
+ .putIfAbsent(requestData.method, () => <RequestData>[])
+ .add(requestData);
+ });
+ List<String> keys = requestsByMethod.keys.toList();
+ keys.sort();
+ int maxCount = requestsByMethod.values
+ .fold(0, (int count, List<RequestData> list) => count + list.length);
+ int countWidth = maxCount.toString().length;
+ for (String key in keys) {
+ List<RequestData> requests = requestsByMethod[key];
+ int noResponseCount = 0;
+ int responseCount = 0;
+ int minTime = -1;
+ int maxTime = -1;
+ int totalTime = 0;
+ requests.forEach((RequestData data) {
+ if (data.responseTime == null) {
+ noResponseCount++;
+ } else {
+ responseCount++;
+ int time = data.elapsedTime;
+ minTime = minTime < 0 ? time : math.min(minTime, time);
+ maxTime = math.max(maxTime, time);
+ totalTime += time;
+ }
+ });
+ String count = requests.length.toString();
+ writeSpaces(countWidth - count.length);
+ stdout.write(' ');
+ stdout.write(count);
+ stdout.write(' - ');
+ stdout.write(key);
+ if (noResponseCount > 0) {
+ stdout.write(', ');
+ stdout.write(noResponseCount);
+ stdout.write(' with no response');
+ }
+ if (maxTime >= 0) {
+ stdout.write(' (');
+ stdout.write(minTime);
+ stdout.write(', ');
+ stdout.write(totalTime / responseCount);
+ stdout.write(', ');
+ stdout.write(maxTime);
+ stdout.write(')');
+ }
+ stdout.writeln();
+ }
+ }
+ //
+ // Print information about the notifications that were received.
+ //
+ stdout.writeln();
+ stdout.writeln('Notification Counts');
+ if (_notificationCountMap.isEmpty) {
+ stdout.writeln(' none');
+ } else {
+ List<String> keys = _notificationCountMap.keys.toList();
+ keys.sort();
+ int maxCount = _notificationCountMap.values.fold(0, math.max);
+ int countWidth = maxCount.toString().length;
+ for (String key in keys) {
+ String count = _notificationCountMap[key].toString();
+ writeSpaces(countWidth - count.length);
+ stdout.write(' ');
+ stdout.write(count);
+ stdout.write(' - ');
+ stdout.writeln(key);
+ }
+ }
+ }
+
+ /**
* Remove any existing overlays.
*/
- Future<AnalysisUpdateContentResult> removeAllOverlays() {
+ void removeAllOverlays() {
Map<String, dynamic> files = new HashMap<String, dynamic>();
for (String path in filesWithOverlays) {
files[path] = new RemoveContentOverlay();
}
- return sendAnalysisUpdateContent(files);
+ sendAnalysisUpdateContent(files);
}
- @override
- Future<AnalysisUpdateContentResult> sendAnalysisUpdateContent(
- Map<String, dynamic> files) {
+ RequestData sendAnalysisGetErrors(String file) {
+ var params = new AnalysisGetErrorsParams(file).toJson();
+ return _send("analysis.getErrors", params);
+ }
+
+ RequestData sendAnalysisGetHover(String file, int offset) {
+ var params = new AnalysisGetHoverParams(file, offset).toJson();
+ return _send("analysis.getHover", params);
+ }
+
+ RequestData sendAnalysisGetLibraryDependencies() {
+ return _send("analysis.getLibraryDependencies", null);
+ }
+
+ RequestData sendAnalysisGetNavigation(String file, int offset, int length) {
+ var params = new AnalysisGetNavigationParams(file, offset, length).toJson();
+ return _send("analysis.getNavigation", params);
+ }
+
+ RequestData sendAnalysisGetReachableSources(String file) {
+ var params = new AnalysisGetReachableSourcesParams(file).toJson();
+ return _send("analysis.getReachableSources", params);
+ }
+
+ void sendAnalysisReanalyze({List<String> roots}) {
+ var params = new AnalysisReanalyzeParams(roots: roots).toJson();
+ _send("analysis.reanalyze", params);
+ }
+
+ void sendAnalysisSetAnalysisRoots(
+ List<String> included, List<String> excluded,
+ {Map<String, String> packageRoots}) {
+ _analysisRootIncludes = included;
+ _analysisRootExcludes = excluded;
+ var params = new AnalysisSetAnalysisRootsParams(included, excluded,
+ packageRoots: packageRoots)
+ .toJson();
+ _send("analysis.setAnalysisRoots", params);
+ }
+
+ void sendAnalysisSetGeneralSubscriptions(
+ List<GeneralAnalysisService> subscriptions) {
+ var params =
+ new AnalysisSetGeneralSubscriptionsParams(subscriptions).toJson();
+ _send("analysis.setGeneralSubscriptions", params);
+ }
+
+ void sendAnalysisSetPriorityFiles(List<String> files) {
+ var params = new AnalysisSetPriorityFilesParams(files).toJson();
+ _send("analysis.setPriorityFiles", params);
+ }
+
+ void sendAnalysisSetSubscriptions(
+ Map<AnalysisService, List<String>> subscriptions) {
+ var params = new AnalysisSetSubscriptionsParams(subscriptions).toJson();
+ _send("analysis.setSubscriptions", params);
+ }
+
+ void sendAnalysisUpdateContent(Map<String, dynamic> files) {
files.forEach((String path, dynamic overlay) {
if (overlay is AddContentOverlay) {
filesWithOverlays.add(path);
@@ -139,14 +481,482 @@
filesWithOverlays.remove(path);
}
});
- return super.sendAnalysisUpdateContent(files);
+ var params = new AnalysisUpdateContentParams(files).toJson();
+ _send('analysis.updateContent', params);
+ }
+
+ void sendAnalysisUpdateOptions(AnalysisOptions options) {
+ var params = new AnalysisUpdateOptionsParams(options).toJson();
+ _send("analysis.updateOptions", params);
+ }
+
+ void sendCompletionGetSuggestions(String file, int offset) {
+ var params = new CompletionGetSuggestionsParams(file, offset).toJson();
+ _send("completion.getSuggestions", params);
+ }
+
+ RequestData sendDiagnosticGetDiagnostics() {
+ return _send("diagnostic.getDiagnostics", null);
+ }
+
+ RequestData sendEditFormat(
+ String file, int selectionOffset, int selectionLength,
+ {int lineLength}) {
+ var params = new EditFormatParams(file, selectionOffset, selectionLength,
+ lineLength: lineLength)
+ .toJson();
+ return _send("edit.format", params);
+ }
+
+ RequestData sendEditGetAssists(String file, int offset, int length) {
+ var params = new EditGetAssistsParams(file, offset, length).toJson();
+ return _send("edit.getAssists", params);
+ }
+
+ RequestData sendEditGetAvailableRefactorings(
+ String file, int offset, int length) {
+ var params =
+ new EditGetAvailableRefactoringsParams(file, offset, length).toJson();
+ return _send("edit.getAvailableRefactorings", params);
+ }
+
+ RequestData sendEditGetFixes(String file, int offset) {
+ var params = new EditGetFixesParams(file, offset).toJson();
+ return _send("edit.getFixes", params);
+ }
+
+ RequestData sendEditGetRefactoring(RefactoringKind kind, String file,
+ int offset, int length, bool validateOnly,
+ {RefactoringOptions options}) {
+ var params = new EditGetRefactoringParams(
+ kind, file, offset, length, validateOnly,
+ options: options)
+ .toJson();
+ return _send("edit.getRefactoring", params);
+ }
+
+ RequestData sendEditOrganizeDirectives(String file) {
+ var params = new EditOrganizeDirectivesParams(file).toJson();
+ return _send("edit.organizeDirectives", params);
+ }
+
+ RequestData sendEditSortMembers(String file) {
+ var params = new EditSortMembersParams(file).toJson();
+ return _send("edit.sortMembers", params);
+ }
+
+ RequestData sendExecutionCreateContext(String contextRoot) {
+ var params = new ExecutionCreateContextParams(contextRoot).toJson();
+ return _send("execution.createContext", params);
+ }
+
+ RequestData sendExecutionDeleteContext(String id) {
+ var params = new ExecutionDeleteContextParams(id).toJson();
+ return _send("execution.deleteContext", params);
+ }
+
+ RequestData sendExecutionMapUri(String id, {String file, String uri}) {
+ var params = new ExecutionMapUriParams(id, file: file, uri: uri).toJson();
+ return _send("execution.mapUri", params);
+ }
+
+ RequestData sendExecutionSetSubscriptions(
+ List<ExecutionService> subscriptions) {
+ var params = new ExecutionSetSubscriptionsParams(subscriptions).toJson();
+ return _send("execution.setSubscriptions", params);
+ }
+
+ void sendSearchFindElementReferences(
+ String file, int offset, bool includePotential) {
+ var params =
+ new SearchFindElementReferencesParams(file, offset, includePotential)
+ .toJson();
+ _send("search.findElementReferences", params);
+ }
+
+ void sendSearchFindMemberDeclarations(String name) {
+ var params = new SearchFindMemberDeclarationsParams(name).toJson();
+ _send("search.findMemberDeclarations", params);
+ }
+
+ void sendSearchFindMemberReferences(String name) {
+ var params = new SearchFindMemberReferencesParams(name).toJson();
+ _send("search.findMemberReferences", params);
+ }
+
+ void sendSearchFindTopLevelDeclarations(String pattern) {
+ var params = new SearchFindTopLevelDeclarationsParams(pattern).toJson();
+ _send("search.findTopLevelDeclarations", params);
+ }
+
+ void sendSearchGetTypeHierarchy(String file, int offset, {bool superOnly}) {
+ var params =
+ new SearchGetTypeHierarchyParams(file, offset, superOnly: superOnly)
+ .toJson();
+ _send("search.getTypeHierarchy", params);
+ }
+
+ RequestData sendServerGetVersion() {
+ return _send("server.getVersion", null);
+ }
+
+ void sendServerSetSubscriptions(List<ServerService> subscriptions) {
+ var params = new ServerSetSubscriptionsParams(subscriptions).toJson();
+ _send("server.setSubscriptions", params);
+ }
+
+ void sendServerShutdown() {
+ _send("server.shutdown", null);
}
/**
- * Record the errors in the given [params].
+ * Start the server and listen for communications from it.
+ *
+ * If [checked] is `true`, the server's VM will be running in checked mode.
+ *
+ * If [debugServer] is `true`, the server will be started with "--debug",
+ * allowing a debugger to be attached.
+ *
+ * If [diagnosticPort] is not `null`, the server will serve status pages to
+ * the specified port.
+ *
+ * If [enableNewAnalysisDriver] is `true`, the server will use the new
+ * analysis driver.
+ *
+ * If [profileServer] is `true`, the server will be started with "--observe"
+ * and "--pause-isolates-on-exit", allowing the observatory to be used.
+ *
+ * If [useAnalysisHighlight2] is `true`, the server will use the new highlight
+ * APIs.
*/
- void _recordErrors(AnalysisErrorsParams params) {
- _errorMap[params.file] = params.errors;
+ Future<Null> start(
+ {bool checked: true,
+ bool debugServer: false,
+ int diagnosticPort,
+ bool enableNewAnalysisDriver: false,
+ bool profileServer: false,
+ String sdkPath,
+ int servicesPort,
+ bool useAnalysisHighlight2: false}) async {
+ if (_process != null) {
+ throw new Exception('Process already started');
+ }
+ String dartBinary = Platform.executable;
+ String rootDir =
+ _findRoot(Platform.script.toFilePath(windows: Platform.isWindows));
+ String serverPath =
+ path.normalize(path.join(rootDir, 'bin', 'server.dart'));
+ List<String> arguments = [];
+ //
+ // Add VM arguments.
+ //
+ if (debugServer) {
+ arguments.add('--debug');
+ }
+ if (profileServer) {
+ if (servicesPort == null) {
+ arguments.add('--observe');
+ } else {
+ arguments.add('--observe=$servicesPort');
+ }
+ arguments.add('--pause-isolates-on-exit');
+ } else if (servicesPort != null) {
+ arguments.add('--enable-vm-service=$servicesPort');
+ }
+ if (Platform.packageRoot != null) {
+ arguments.add('--package-root=${Platform.packageRoot}');
+ }
+ if (Platform.packageConfig != null) {
+ arguments.add('--packages=${Platform.packageConfig}');
+ }
+ if (checked) {
+ arguments.add('--checked');
+ }
+ //
+ // Add the server executable.
+ //
+ arguments.add(serverPath);
+ //
+ // Add server arguments.
+ //
+ if (diagnosticPort != null) {
+ arguments.add('--port');
+ arguments.add(diagnosticPort.toString());
+ }
+ if (sdkPath != null) {
+ arguments.add('--sdk=$sdkPath');
+ }
+ if (useAnalysisHighlight2) {
+ arguments.add('--useAnalysisHighlight2');
+ }
+ if (!enableNewAnalysisDriver) {
+ arguments.add('--disable-new-analysis-driver');
+ }
+// stdout.writeln('Launching $serverPath');
+// stdout.writeln('$dartBinary ${arguments.join(' ')}');
+ _process = await Process.start(dartBinary, arguments);
+ _process.exitCode.then((int code) {
+ if (code != 0) {
+ throw new StateError('Server terminated with exit code $code');
+ }
+ });
+ _listenToOutput();
+ _serverConnectedCompleter = new Completer();
+ return _serverConnectedCompleter.future;
+ }
+
+ /**
+ * Find the root directory of the analysis_server package by proceeding
+ * upward to the 'test' dir, and then going up one more directory.
+ */
+ String _findRoot(String pathname) {
+ while (!['benchmark', 'test'].contains(path.basename(pathname))) {
+ String parent = path.dirname(pathname);
+ if (parent.length >= pathname.length) {
+ throw new Exception("Can't find root directory");
+ }
+ pathname = parent;
+ }
+ return path.dirname(pathname);
+ }
+
+ /**
+ * Handle a [notification] received from the server.
+ */
+ void _handleNotification(Notification notification) {
+ switch (notification.event) {
+ case "server.connected":
+// new ServerConnectedParams.fromNotification(notification);
+ _serverConnectedCompleter.complete(null);
+ break;
+ case "server.error":
+// new ServerErrorParams.fromNotification(notification);
+ throw new StateError('Server error: ${notification.toJson()}');
+ break;
+ case "server.status":
+ if (_analysisFinishedCompleter != null) {
+ ServerStatusParams params =
+ new ServerStatusParams.fromNotification(notification);
+ var analysis = params.analysis;
+ if (analysis != null && !analysis.isAnalyzing) {
+ _analysisFinishedCompleter.complete(null);
+ }
+ }
+ break;
+ case "analysis.analyzedFiles":
+ AnalysisAnalyzedFilesParams params =
+ new AnalysisAnalyzedFilesParams.fromNotification(notification);
+ _analyzedFiles = params.directories;
+ break;
+ case "analysis.errors":
+ AnalysisErrorsParams params =
+ new AnalysisErrorsParams.fromNotification(notification);
+ _errorMap.pathMap[params.file] = params.errors;
+ break;
+ case "analysis.flushResults":
+// new AnalysisFlushResultsParams.fromNotification(notification);
+ _errorMap.pathMap.clear();
+ break;
+ case "analysis.folding":
+// new AnalysisFoldingParams.fromNotification(notification);
+ break;
+ case "analysis.highlights":
+// new AnalysisHighlightsParams.fromNotification(notification);
+ break;
+ case "analysis.implemented":
+// new AnalysisImplementedParams.fromNotification(notification);
+ break;
+ case "analysis.invalidate":
+// new AnalysisInvalidateParams.fromNotification(notification);
+ break;
+ case "analysis.navigation":
+// new AnalysisNavigationParams.fromNotification(notification);
+ break;
+ case "analysis.occurrences":
+// new AnalysisOccurrencesParams.fromNotification(notification);
+ break;
+ case "analysis.outline":
+// new AnalysisOutlineParams.fromNotification(notification);
+ break;
+ case "analysis.overrides":
+// new AnalysisOverridesParams.fromNotification(notification);
+ break;
+ case "completion.results":
+// new CompletionResultsParams.fromNotification(notification);
+ break;
+ case "search.results":
+// new SearchResultsParams.fromNotification(notification);
+ break;
+ case "execution.launchData":
+// new ExecutionLaunchDataParams.fromNotification(notification);
+ break;
+ default:
+ throw new StateError(
+ 'Unhandled notification: ${notification.toJson()}');
+ }
+ }
+
+ /**
+ * Handle a [response] received from the server.
+ */
+ void _handleResponse(Response response) {
+ String id = response.id.toString();
+ RequestData requestData = _requestDataMap[id];
+ requestData.recordResponse(response);
+// switch (requestData.method) {
+// case "analysis.getErrors":
+// break;
+// case "analysis.getHover":
+// break;
+// case "analysis.getLibraryDependencies":
+// break;
+// case "analysis.getNavigation":
+// break;
+// case "analysis.getReachableSources":
+// break;
+// case "analysis.reanalyze":
+// break;
+// case "analysis.setAnalysisRoots":
+// break;
+// case "analysis.setGeneralSubscriptions":
+// break;
+// case "analysis.setPriorityFiles":
+// break;
+// case "analysis.setSubscriptions":
+// break;
+// case 'analysis.updateContent':
+// break;
+// case "analysis.updateOptions":
+// break;
+// case "completion.getSuggestions":
+// break;
+// case "diagnostic.getDiagnostics":
+// break;
+// case "edit.format":
+// break;
+// case "edit.getAssists":
+// break;
+// case "edit.getAvailableRefactorings":
+// break;
+// case "edit.getFixes":
+// break;
+// case "edit.getRefactoring":
+// break;
+// case "edit.organizeDirectives":
+// break;
+// case "edit.sortMembers":
+// break;
+// case "execution.createContext":
+// break;
+// case "execution.deleteContext":
+// break;
+// case "execution.mapUri":
+// break;
+// case "execution.setSubscriptions":
+// break;
+// case "search.findElementReferences":
+// break;
+// case "search.findMemberDeclarations":
+// break;
+// case "search.findMemberReferences":
+// break;
+// case "search.findTopLevelDeclarations":
+// break;
+// case "search.getTypeHierarchy":
+// break;
+// case "server.getVersion":
+// break;
+// case "server.setSubscriptions":
+// break;
+// case "server.shutdown":
+// break;
+// default:
+// throw new StateError('Unhandled response: ${response.toJson()}');
+// }
+ }
+
+ /**
+ * Handle a [line] of input read from stderr.
+ */
+ void _handleStdErr(String line) {
+ String trimmedLine = line.trim();
+ logger?.log(fromStderr, '$trimmedLine');
+ throw new StateError('Message received on stderr: "$trimmedLine"');
+ }
+
+ /**
+ * Handle a [line] of input read from stdout.
+ */
+ void _handleStdOut(String line) {
+ /**
+ * Cast the given [value] to a Map, or throw an [ArgumentError] if the value
+ * cannot be cast.
+ */
+ Map asMap(Object value) {
+ if (value is Map) {
+ return value;
+ }
+ throw new ArgumentError('Expected a Map, found a ${value.runtimeType}');
+ }
+
+ String trimmedLine = line.trim();
+ if (trimmedLine.isEmpty ||
+ trimmedLine.startsWith('Observatory listening on ')) {
+ return;
+ }
+ logger?.log(fromServer, '$trimmedLine');
+ Map message = asMap(JSON.decoder.convert(trimmedLine));
+ if (message.containsKey('id')) {
+ // The message is a response.
+ Response response = new Response.fromJson(message);
+ _handleResponse(response);
+ } else {
+ // The message is a notification.
+ Notification notification = new Notification.fromJson(message);
+ String event = notification.event;
+ _notificationCountMap[event] = (_notificationCountMap[event] ?? 0) + 1;
+ _handleNotification(notification);
+ }
+ }
+
+ /**
+ * Start listening to output from the server.
+ */
+ void _listenToOutput() {
+ /**
+ * Install the given [handler] to listen to transformed output from the
+ * given [stream].
+ */
+ void installHandler(Stream<List<int>> stream, handler(String line)) {
+ stream
+ .transform((new Utf8Codec()).decoder)
+ .transform(new LineSplitter())
+ .listen(handler);
+ }
+
+ installHandler(_process.stdout, _handleStdOut);
+ installHandler(_process.stderr, _handleStdErr);
+ }
+
+ /**
+ * Send a command to the server. An 'id' will be automatically assigned.
+ */
+ RequestData _send(String method, Map<String, dynamic> params,
+ {void onResponse(Response response)}) {
+ String id = '${_nextId++}';
+ RequestData requestData = new RequestData(id, method, params, currentTime);
+ _requestDataMap[id] = requestData;
+ Map<String, dynamic> command = <String, dynamic>{
+ 'id': id,
+ 'method': method
+ };
+ if (params != null) {
+ command['params'] = params;
+ }
+ String line = JSON.encode(command);
+ _process.stdin.add(UTF8.encoder.convert('$line\n'));
+ logger?.log(fromClient, '$line');
+ return requestData;
}
}
@@ -284,6 +1094,6 @@
buffer.writeln(filePath);
_writeErrors(' Expected ', expectedErrors);
buffer.writeln();
- _writeErrors(' Found ', expectedErrors);
+ _writeErrors(' Found ', actualErrors);
}
}
diff --git a/pkg/analyzer/lib/src/command_line/arguments.dart b/pkg/analyzer/lib/src/command_line/arguments.dart
index 22a9670..1871625 100644
--- a/pkg/analyzer/lib/src/command_line/arguments.dart
+++ b/pkg/analyzer/lib/src/command_line/arguments.dart
@@ -53,7 +53,8 @@
* Use the given [resourceProvider], [contentCache] and command-line [args] to
* create a context builder.
*/
-ContextBuilderOptions createContextBuilderOptions(ArgResults args) {
+ContextBuilderOptions createContextBuilderOptions(ArgResults args,
+ {bool strongMode, bool trackCacheDependencies}) {
ContextBuilderOptions builderOptions = new ContextBuilderOptions();
builderOptions.argResults = args;
//
@@ -69,6 +70,12 @@
//
AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
applyAnalysisOptionFlags(defaultOptions, args);
+ if (strongMode != null) {
+ defaultOptions.strongMode = strongMode;
+ }
+ if (trackCacheDependencies != null) {
+ defaultOptions.trackCacheDependencies = trackCacheDependencies;
+ }
builderOptions.defaultOptions = defaultOptions;
//
// Declared variables.
@@ -137,7 +144,7 @@
help: 'The path to the Dart SDK summary file.', hide: hide);
parser.addOption(analysisOptionsFileOption,
- help: 'Path to an analysis options file.', hide: ddc);
+ help: 'Path to an analysis options file.');
parser.addOption(packageRootOption,
abbr: 'p',
@@ -151,16 +158,13 @@
parser.addFlag(strongModeFlag,
help: 'Enable strong static checks (https://goo.gl/DqcBsw)',
- defaultsTo: ddc,
- hide: ddc);
+ defaultsTo: ddc);
parser.addFlag(noImplicitCastsFlag,
negatable: false,
- help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40)',
- hide: ddc);
+ help: 'Disable implicit casts in strong mode (https://goo.gl/cTLz40)');
parser.addFlag(noImplicitDynamicFlag,
negatable: false,
- help: 'Disable implicit dynamic (https://goo.gl/m0UgXD)',
- hide: ddc);
+ help: 'Disable implicit dynamic (https://goo.gl/m0UgXD)');
//
// Hidden flags and options.
//
@@ -173,7 +177,7 @@
help: 'Fix issue 21938.',
defaultsTo: false,
negatable: false,
- hide: hide || ddc);
+ hide: hide);
parser.addFlag(enableInitializingFormalAccessFlag,
help:
'Enable support for allowing access to field formal parameters in a '
@@ -185,7 +189,7 @@
help: 'Relax restrictions on mixins (DEP 34).',
defaultsTo: false,
negatable: false,
- hide: hide || ddc);
+ hide: hide);
// parser.addFlag('enable_type_checks',
// help: 'Check types in constant evaluation.',
// defaultsTo: false,
diff --git a/pkg/analyzer/lib/src/context/context.dart b/pkg/analyzer/lib/src/context/context.dart
index 4f05591..c2c2ec0 100644
--- a/pkg/analyzer/lib/src/context/context.dart
+++ b/pkg/analyzer/lib/src/context/context.dart
@@ -810,8 +810,9 @@
if (source == null) {
return false;
}
- if (_contentCache.getContents(source) != null) {
- return true;
+ bool overriddenExists = _contentCache.getExists(source);
+ if (overriddenExists != null) {
+ return overriddenExists;
}
return source.exists();
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index ef28cb2..c2865a5 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -20,7 +20,7 @@
import 'package:analyzer/src/dart/analysis/status.dart';
import 'package:analyzer/src/dart/analysis/top_level_declaration.dart';
import 'package:analyzer/src/generated/engine.dart'
- show AnalysisContext, AnalysisEngine, AnalysisOptions, ChangeSet;
+ show AnalysisContext, AnalysisEngine, AnalysisOptions;
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/services/lint.dart';
import 'package:analyzer/src/summary/api_signature.dart';
@@ -205,6 +205,11 @@
final _resultController = new StreamController<AnalysisResult>();
/**
+ * Cached results for [_priorityFiles].
+ */
+ final Map<String, AnalysisResult> _priorityResults = {};
+
+ /**
* The instance of the status helper.
*/
final StatusSupport _statusSupport = new StatusSupport();
@@ -306,6 +311,10 @@
* between priority files, nor between priority and non-priority files.
*/
void set priorityFiles(List<String> priorityPaths) {
+ _priorityResults.keys
+ .toSet()
+ .difference(priorityPaths.toSet())
+ .forEach(_priorityResults.remove);
_priorityFiles.clear();
_priorityFiles.addAll(priorityPaths);
_statusSupport.transitionToAnalyzing();
@@ -405,6 +414,7 @@
if (AnalysisEngine.isDartFileName(path)) {
_addedFiles.add(path);
_filesToAnalyze.add(path);
+ _priorityResults.clear();
}
_statusSupport.transitionToAnalyzing();
_scheduler._notify(this);
@@ -434,6 +444,7 @@
if (_addedFiles.contains(path)) {
_filesToAnalyze.add(path);
}
+ _priorityResults.clear();
}
_statusSupport.transitionToAnalyzing();
_scheduler._notify(this);
@@ -515,23 +526,35 @@
*
* The [path] can be any file - explicitly or implicitly analyzed, or neither.
*
- * Causes the analysis state to transition to "analyzing" (if it is not in
- * that state already), the driver will read the file and produce the analysis
- * result for it, which is consistent with the current file state (including
- * the new state of the file), prior to the next time the analysis state
- * transitions to "idle".
+ * If the driver has the cached analysis result for the file, it is returned.
+ *
+ * Otherwise causes the analysis state to transition to "analyzing" (if it is
+ * not in that state already), the driver will read the file and produce the
+ * analysis result for it, which is consistent with the current file state
+ * (including the new state of the file), prior to the next time the analysis
+ * state transitions to "idle".
*/
Future<AnalysisResult> getResult(String path) {
- if (AnalysisEngine.isDartFileName(path)) {
- var completer = new Completer<AnalysisResult>();
- _requestedFiles
- .putIfAbsent(path, () => <Completer<AnalysisResult>>[])
- .add(completer);
- _statusSupport.transitionToAnalyzing();
- _scheduler._notify(this);
- return completer.future;
+ if (!AnalysisEngine.isDartFileName(path)) {
+ return new Future.value();
}
- return new Future.value();
+
+ // Return the cached result.
+ {
+ AnalysisResult result = _priorityResults[path];
+ if (result != null) {
+ return new Future.value(result);
+ }
+ }
+
+ // Schedule analysis.
+ var completer = new Completer<AnalysisResult>();
+ _requestedFiles
+ .putIfAbsent(path, () => <Completer<AnalysisResult>>[])
+ .add(completer);
+ _statusSupport.transitionToAnalyzing();
+ _scheduler._notify(this);
+ return completer.future;
}
/**
@@ -598,6 +621,7 @@
_filesToAnalyze.remove(path);
_fsState.removeFile(path);
_filesToAnalyze.addAll(_addedFiles);
+ _priorityResults.clear();
_statusSupport.transitionToAnalyzing();
_scheduler._notify(this);
}
@@ -659,17 +683,6 @@
_LibraryContext libraryContext = _createLibraryContext(libraryFile);
AnalysisContext analysisContext = _createAnalysisContext(libraryContext);
try {
- analysisContext.setContents(file.source, file.content);
-
- // TODO(scheglov) Remove this.
- // https://github.com/dart-lang/sdk/issues/28110
- analysisContext.setContents(libraryFile.source, libraryFile.content);
- for (FileState part in libraryFile.partedFiles) {
- if (part.exists) {
- analysisContext.setContents(part.source, part.content);
- }
- }
-
CompilationUnit resolvedUnit = analysisContext.resolveCompilationUnit2(
file.source, libraryFile.source);
List<AnalysisError> errors = analysisContext.computeErrors(file.source);
@@ -695,10 +708,14 @@
// Return the result, full or partial.
_logger.writeln('Computed new analysis result.');
- return _getAnalysisResultFromBytes(file, bytes,
+ AnalysisResult result = _getAnalysisResultFromBytes(file, bytes,
content: withUnit ? file.content : null,
withErrors: _addedFiles.contains(path),
resolvedUnit: withUnit ? resolvedUnit : null);
+ if (withUnit && _priorityFiles.contains(path)) {
+ _priorityResults[path] = result;
+ }
+ return result;
} finally {
analysisContext.dispose();
}
@@ -733,12 +750,10 @@
AnalysisContextImpl analysisContext =
AnalysisEngine.instance.createAnalysisContext();
analysisContext.analysisOptions = _analysisOptions;
-
analysisContext.sourceFactory = _sourceFactory.clone();
+ analysisContext.contentCache = new _ContentCacheWrapper(_fsState);
analysisContext.resultProvider =
new InputPackagesResultProvider(analysisContext, libraryContext.store);
- analysisContext
- .applyChanges(new ChangeSet()..addedSource(libraryContext.file.source));
return analysisContext;
}
@@ -1275,6 +1290,8 @@
AnalysisDriverTestView(this.driver);
Set<String> get filesToAnalyze => driver._filesToAnalyze;
+
+ Map<String, AnalysisResult> get priorityResults => driver._priorityResults;
}
/**
@@ -1501,6 +1518,45 @@
}
/**
+ * [ContentCache] wrapper around [FileContentOverlay].
+ */
+class _ContentCacheWrapper implements ContentCache {
+ final FileSystemState fsState;
+
+ _ContentCacheWrapper(this.fsState);
+
+ @override
+ void accept(ContentCacheVisitor visitor) {
+ throw new UnimplementedError();
+ }
+
+ @override
+ String getContents(Source source) {
+ return _getFileForSource(source).content;
+ }
+
+ @override
+ bool getExists(Source source) {
+ return _getFileForSource(source).exists;
+ }
+
+ @override
+ int getModificationStamp(Source source) {
+ return _getFileForSource(source).exists ? 0 : -1;
+ }
+
+ @override
+ String setContents(Source source, String contents) {
+ throw new UnimplementedError();
+ }
+
+ FileState _getFileForSource(Source source) {
+ String path = source.fullName;
+ return fsState.getFileForPath(path);
+ }
+}
+
+/**
* Task that computes the list of files that were added to the driver and
* have at least one reference to an identifier [name] defined outside of the
* file.
diff --git a/pkg/analyzer/lib/src/dart/ast/utilities.dart b/pkg/analyzer/lib/src/dart/ast/utilities.dart
index 3efd68b..4b9857d 100644
--- a/pkg/analyzer/lib/src/dart/ast/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/ast/utilities.dart
@@ -2190,16 +2190,21 @@
* > expressions that evaluate to an integer value or to <b>null</b>.
* > </span>
* > * <span>
- * > An expression of one of the forms <i>-e</i>, <i>e<sub>1</sub> +
- * > e<sub>2</sub></i>, <i>e<sub>1</sub> -e<sub>2</sub></i>,
- * > <i>e<sub>1</sub> * e<sub>2</sub></i>, <i>e<sub>1</sub> /
- * > e<sub>2</sub></i>, <i>e<sub>1</sub> ~/ e<sub>2</sub></i>,
- * > <i>e<sub>1</sub> > e<sub>2</sub></i>, <i>e<sub>1</sub> <
- * > e<sub>2</sub></i>, <i>e<sub>1</sub> >= e<sub>2</sub></i>,
- * > <i>e<sub>1</sub> <= e<sub>2</sub></i> or <i>e<sub>1</sub> %
- * > e<sub>2</sub></i>, where <i>e</i>, <i>e<sub>1</sub></i> and
- * > <i>e<sub>2</sub></i> are constant expressions that evaluate to a numeric
- * > value or to <b>null</b>.
+ * > An expression of one of the forms <i>-e</i>, <i>e<sub>1</sub>
+ * > -e<sub>2</sub></i>, <i>e<sub>1</sub> * e<sub>2</sub></i>,
+ * > <i>e<sub>1</sub> / e<sub>2</sub></i>, <i>e<sub>1</sub> ~/
+ * > e<sub>2</sub></i>, <i>e<sub>1</sub> > e<sub>2</sub></i>,
+ * > <i>e<sub>1</sub> < e<sub>2</sub></i>, <i>e<sub>1</sub> >=
+ * > e<sub>2</sub></i>, <i>e<sub>1</sub> <= e<sub>2</sub></i> or
+ * > <i>e<sub>1</sub> % e<sub>2</sub></i>, where <i>e</i>,
+ * > <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant expressions
+ * > that evaluate to a numeric value or to <b>null</b>.
+ * > </span>
+ * > * <span>
+ * > An expression of one the form <i>e<sub>1</sub> + e<sub>2</sub></i>,
+ * > <i>e<sub>1</sub> -e<sub>2</sub></i> where <i>e<sub>1</sub> and
+ * > e<sub>2</sub></i> are constant expressions that evaluate to a numeric or
+ * > string value or to <b>null</b>.
* > </span>
* > * <span>
* > An expression of the form <i>e<sub>1</sub> ? e<sub>2</sub> :
@@ -2208,6 +2213,8 @@
* > evaluates to a boolean value.
* > </span>
*
+ * However, this comment is now at least a little bit out of sync with the spec.
+ *
* The values returned by instances of this class are therefore `null` and
* instances of the classes `Boolean`, `BigInteger`, `Double`, `String`, and
* `DartObject`.
@@ -2335,6 +2342,9 @@
if (leftOperand is num && rightOperand is num) {
return leftOperand + rightOperand;
}
+ if (leftOperand is String && rightOperand is String) {
+ return leftOperand + rightOperand;
+ }
} else if (node.operator.type == TokenType.STAR) {
// numeric or {@code null}
if (leftOperand is num && rightOperand is num) {
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 47c4009..91b072c 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -786,7 +786,7 @@
}
_checkForTypeAnnotationDeferredClass(returnType);
_checkForIllegalReturnType(returnType);
- _checkForImplicitDynamicReturn(node, node.element);
+ _checkForImplicitDynamicReturn(node.name, node.element);
return super.visitFunctionDeclaration(node);
} finally {
_enclosingFunction = outerFunction;
@@ -850,7 +850,9 @@
if (parameterType is FunctionType &&
parameterType.returnType.isDynamic) {
_errorReporter.reportErrorForNode(
- StrongModeCode.IMPLICIT_DYNAMIC_RETURN, node, [node.identifier]);
+ StrongModeCode.IMPLICIT_DYNAMIC_RETURN,
+ node.identifier,
+ [node.identifier]);
}
}
return super.visitFunctionTypedFormalParameter(node);
@@ -994,7 +996,7 @@
_checkForAllInvalidOverrideErrorCodesForMethod(node);
_checkForTypeAnnotationDeferredClass(returnTypeName);
_checkForIllegalReturnType(returnTypeName);
- _checkForImplicitDynamicReturn(node, node.element);
+ _checkForImplicitDynamicReturn(node.name, node.element);
_checkForMustCallSuper(node);
return super.visitMethodDeclaration(node);
} finally {
@@ -3972,7 +3974,8 @@
}
}
- void _checkForImplicitDynamicReturn(AstNode node, ExecutableElement element) {
+ void _checkForImplicitDynamicReturn(
+ AstNode functionName, ExecutableElement element) {
if (_options.implicitDynamic) {
return;
}
@@ -3982,8 +3985,8 @@
if (element != null &&
element.hasImplicitReturnType &&
element.returnType.isDynamic) {
- _errorReporter.reportErrorForNode(
- StrongModeCode.IMPLICIT_DYNAMIC_RETURN, node, [element.displayName]);
+ _errorReporter.reportErrorForNode(StrongModeCode.IMPLICIT_DYNAMIC_RETURN,
+ functionName, [element.displayName]);
}
}
diff --git a/pkg/analyzer/lib/src/generated/source.dart b/pkg/analyzer/lib/src/generated/source.dart
index e4ceae7..83a4783 100644
--- a/pkg/analyzer/lib/src/generated/source.dart
+++ b/pkg/analyzer/lib/src/generated/source.dart
@@ -66,6 +66,17 @@
String getContents(Source source) => _contentMap[source.fullName];
/**
+ * Return `true` if the given [source] exists, `false` if it does not exist,
+ * or `null` if this cache does not override existence of the source.
+ *
+ * <b>Note:</b> This method is not intended to be used except by
+ * [AnalysisContext.exists].
+ */
+ bool getExists(Source source) {
+ return _contentMap.containsKey(source.fullName) ? true : null;
+ }
+
+ /**
* Return the modification stamp of the given [source], or `null` if this
* cache does not override the contents of the source.
*
@@ -411,6 +422,9 @@
@override
bool exists() => false;
+
+ @override
+ String toString() => 'NonExistingSource($uri, $fullName)';
}
/**
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 0bc2d9a..24eb692 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -335,6 +335,93 @@
expect(allResults[0].path, b);
}
+ test_cachedPriorityResults() async {
+ var a = _p('/test/bin/a.dart');
+ provider.newFile(a, 'var a = 1;');
+
+ driver.priorityFiles = [a];
+
+ AnalysisResult result1 = await driver.getResult(a);
+ expect(driver.test.priorityResults, containsPair(a, result1));
+
+ AnalysisResult result2 = await driver.getResult(a);
+ expect(result2, same(result1));
+ }
+
+ test_cachedPriorityResults_flush_onAnyFileChange() async {
+ var a = _p('/test/bin/a.dart');
+ var b = _p('/test/bin/b.dart');
+ provider.newFile(a, 'var a = 1;');
+ provider.newFile(a, 'var b = 2;');
+
+ driver.priorityFiles = [a];
+
+ AnalysisResult result1 = await driver.getResult(a);
+ expect(driver.test.priorityResults, containsPair(a, result1));
+
+ // Change a file.
+ // The cache is flushed.
+ driver.changeFile(a);
+ expect(driver.test.priorityResults, isEmpty);
+ AnalysisResult result2 = await driver.getResult(a);
+ expect(driver.test.priorityResults, containsPair(a, result2));
+
+ // Add a file.
+ // The cache is flushed.
+ driver.addFile(b);
+ expect(driver.test.priorityResults, isEmpty);
+ AnalysisResult result3 = await driver.getResult(a);
+ expect(driver.test.priorityResults, containsPair(a, result3));
+
+ // Remove a file.
+ // The cache is flushed.
+ driver.removeFile(b);
+ expect(driver.test.priorityResults, isEmpty);
+ }
+
+ test_cachedPriorityResults_flush_onPrioritySetChange() async {
+ var a = _p('/test/bin/a.dart');
+ var b = _p('/test/bin/b.dart');
+ provider.newFile(a, 'var a = 1;');
+ provider.newFile(a, 'var b = 2;');
+
+ driver.priorityFiles = [a];
+
+ AnalysisResult result1 = await driver.getResult(a);
+ expect(driver.test.priorityResults, hasLength(1));
+ expect(driver.test.priorityResults, containsPair(a, result1));
+
+ // Make "a" and "b" priority.
+ // We still have the result for "a" cached.
+ driver.priorityFiles = [a, b];
+ expect(driver.test.priorityResults, hasLength(1));
+ expect(driver.test.priorityResults, containsPair(a, result1));
+
+ // Get the result for "b".
+ AnalysisResult result2 = await driver.getResult(b);
+ expect(driver.test.priorityResults, hasLength(2));
+ expect(driver.test.priorityResults, containsPair(a, result1));
+ expect(driver.test.priorityResults, containsPair(b, result2));
+
+ // Only "b" is priority.
+ // The result for "a" is flushed.
+ driver.priorityFiles = [b];
+ expect(driver.test.priorityResults, hasLength(1));
+ expect(driver.test.priorityResults, containsPair(b, result2));
+ }
+
+ test_cachedPriorityResults_notPriority() async {
+ var a = _p('/test/bin/a.dart');
+ provider.newFile(a, 'var a = 1;');
+
+ AnalysisResult result1 = await driver.getResult(a);
+ expect(driver.test.priorityResults, isEmpty);
+
+ // The file is not priority, so its result is not cached.
+ AnalysisResult result2 = await driver.getResult(a);
+ expect(result2, isNot(same(result1)));
+ }
+
test_changeFile_implicitlyAnalyzed() async {
var a = _p('/test/lib/a.dart');
var b = _p('/test/lib/b.dart');
@@ -661,6 +748,23 @@
}
}
+ test_getResult_fileContentOverlay_throughAnalysisContext() async {
+ var a = _p('/test/bin/a.dart');
+ var b = _p('/test/bin/b.dart');
+
+ provider.newFile(a, 'import "b.dart";');
+ provider.newFile(b, 'var v = 1;');
+ contentOverlay[b] = 'var v = 2;';
+
+ var result = await driver.getResult(a);
+
+ // The content that was set into the overlay for "b" should be visible
+ // through the AnalysisContext that was used to analyze "a".
+ CompilationUnitElement unitA = result.unit.element;
+ Source sourceB = unitA.library.imports[0].importedLibrary.source;
+ expect(unitA.context.getContents(sourceB).data, 'var v = 2;');
+ }
+
test_getResult_inferTypes_finalField() async {
addTestFile(
r'''
@@ -1023,7 +1127,7 @@
expect(driver.hasFilesToAnalyze, isFalse);
// Add a new file, it should be analyzed.
- addTestFile('main() {}', priority: true);
+ addTestFile('main() {}', priority: false);
expect(driver.hasFilesToAnalyze, isTrue);
// Wait for idle, nothing to do.
diff --git a/pkg/analyzer/test/src/dart/ast/utilities_test.dart b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
index 368c307..8ccaa8a 100644
--- a/pkg/analyzer/test/src/dart/ast/utilities_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
@@ -196,6 +196,11 @@
expect(value, true);
}
+ void test_binary_plus_string() {
+ Object value = _getConstantValue("'hello ' + 'world'");
+ expect(value, 'hello world');
+ }
+
void test_binary_plus_double() {
Object value = _getConstantValue("2.3 + 3.2");
expect(value, 2.3 + 3.2);
@@ -206,6 +211,26 @@
expect(value, 5);
}
+ void test_binary_plus_string_int() {
+ Object value = _getConstantValue("5 + 'world'");
+ expect(value, ConstantEvaluator.NOT_A_CONSTANT);
+ }
+
+ void test_binary_plus_int_string() {
+ Object value = _getConstantValue("'world' + 5");
+ expect(value, ConstantEvaluator.NOT_A_CONSTANT);
+ }
+
+ void test_binary_plus_double_string() {
+ Object value = _getConstantValue("'world' + 5.5");
+ expect(value, ConstantEvaluator.NOT_A_CONSTANT);
+ }
+
+ void test_binary_plus_string_double() {
+ Object value = _getConstantValue("5.5 + 'world'");
+ expect(value, ConstantEvaluator.NOT_A_CONSTANT);
+ }
+
void test_binary_remainder_double() {
Object value = _getConstantValue("3.2 % 2.3");
expect(value, 3.2 % 2.3);
diff --git a/pkg/analyzer/test/src/task/strong/checker_test.dart b/pkg/analyzer/test/src/task/strong/checker_test.dart
index 6ad54c7..8ebcd1c 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -2353,7 +2353,7 @@
// accessors
set x(int value) {}
-/*error:IMPLICIT_DYNAMIC_RETURN*/get y0 => 42;
+get /*error:IMPLICIT_DYNAMIC_RETURN*/y0 => 42;
dynamic get y1 => 42;
// function typed formals
diff --git a/pkg/compiler/lib/src/closure.dart b/pkg/compiler/lib/src/closure.dart
index 2d3c15e..07987db 100644
--- a/pkg/compiler/lib/src/closure.dart
+++ b/pkg/compiler/lib/src/closure.dart
@@ -10,7 +10,7 @@
import 'common.dart';
import 'compiler.dart' show Compiler;
import 'constants/expressions.dart';
-import 'dart_types.dart';
+import 'elements/resolution_types.dart';
import 'elements/elements.dart';
import 'elements/modelx.dart'
show BaseFunctionElementX, ClassElementX, ElementX;
@@ -179,14 +179,14 @@
bool get isInstanceMember => true;
bool get isAssignable => false;
- DartType computeType(Resolution resolution) => type;
+ ResolutionDartType computeType(Resolution resolution) => type;
- DartType get type {
+ ResolutionDartType get type {
if (local is LocalElement) {
LocalElement element = local;
return element.type;
}
- return const DynamicType();
+ return const ResolutionDynamicType();
}
String toString() => "ClosureFieldElement($name)";
@@ -210,9 +210,9 @@
// TODO(ahe): These classes continuously cause problems. We need to find
// a more general solution.
class ClosureClassElement extends ClassElementX {
- DartType rawType;
- DartType thisType;
- FunctionType callType;
+ ResolutionDartType rawType;
+ ResolutionDartType thisType;
+ ResolutionFunctionType callType;
/// Node that corresponds to this closure, used for source position.
final FunctionExpression node;
@@ -241,8 +241,8 @@
: backend.helpers.closureClass;
superclass.ensureResolved(compiler.resolution);
supertype = superclass.thisType;
- interfaces = const Link<DartType>();
- thisType = rawType = new InterfaceType(this);
+ interfaces = const Link<ResolutionDartType>();
+ thisType = rawType = new ResolutionInterfaceType(this);
allSupertypesAndSelf =
superclass.allSupertypesAndSelf.extendClass(thisType);
callType = methodElement.type;
@@ -303,9 +303,9 @@
: this.box = box,
super(name, ElementKind.FIELD, box.executableContext);
- DartType computeType(Resolution resolution) => type;
+ ResolutionDartType computeType(Resolution resolution) => type;
- DartType get type => variableElement.type;
+ ResolutionDartType get type => variableElement.type;
@override
Entity get declaredEntity => variableElement;
@@ -752,7 +752,7 @@
}
}
- void useTypeVariableAsLocal(TypeVariableType typeVariable) {
+ void useTypeVariableAsLocal(ResolutionTypeVariableType typeVariable) {
useLocal(new TypeVariableLocal(typeVariable, outermostElement));
}
@@ -800,7 +800,7 @@
visitTypeAnnotation(TypeAnnotation node) {
MemberElement member = executableContext.memberContext;
- DartType type = elements.getType(node);
+ ResolutionDartType type = elements.getType(node);
// TODO(karlklose,johnniwinther): if the type is null, the annotation is
// from a parameter which has been analyzed before the method has been
// resolved and the result has been thrown away.
@@ -811,7 +811,7 @@
// This is a closure in a factory constructor. Since there is no
// [:this:], we have to mark the type arguments as free variables to
// capture them in the closure.
- type.forEachTypeVariable((TypeVariableType variable) {
+ type.forEachTypeVariable((ResolutionTypeVariableType variable) {
useTypeVariableAsLocal(variable);
});
}
@@ -858,13 +858,14 @@
registerNeedsThis();
} else if (node.isTypeTest || node.isTypeCast) {
TypeAnnotation annotation = node.typeAnnotationFromIsCheckOrCast;
- DartType type = elements.getType(annotation);
+ ResolutionDartType type = elements.getType(annotation);
analyzeType(type);
} else if (node.isTypeTest) {
- DartType type = elements.getType(node.typeAnnotationFromIsCheckOrCast);
+ ResolutionDartType type =
+ elements.getType(node.typeAnnotationFromIsCheckOrCast);
analyzeType(type);
} else if (node.isTypeCast) {
- DartType type = elements.getType(node.arguments.head);
+ ResolutionDartType type = elements.getType(node.arguments.head);
analyzeType(type);
}
node.visitChildren(this);
@@ -883,25 +884,25 @@
}
visitNewExpression(NewExpression node) {
- DartType type = elements.getType(node);
+ ResolutionDartType type = elements.getType(node);
analyzeType(type);
node.visitChildren(this);
}
visitLiteralList(LiteralList node) {
- DartType type = elements.getType(node);
+ ResolutionDartType type = elements.getType(node);
analyzeType(type);
node.visitChildren(this);
}
visitLiteralMap(LiteralMap node) {
- DartType type = elements.getType(node);
+ ResolutionDartType type = elements.getType(node);
analyzeType(type);
node.visitChildren(this);
}
- void analyzeTypeVariables(DartType type) {
- type.forEachTypeVariable((TypeVariableType typeVariable) {
+ void analyzeTypeVariables(ResolutionDartType type) {
+ type.forEachTypeVariable((ResolutionTypeVariableType typeVariable) {
// Field initializers are inlined and access the type variable as
// normal parameters.
if (!outermostElement.isField && !outermostElement.isConstructor) {
@@ -912,7 +913,7 @@
});
}
- void analyzeType(DartType type) {
+ void analyzeType(ResolutionDartType type) {
// TODO(johnniwinther): Find out why this can be null.
if (type == null) return;
if (outermostElement.isClassMember &&
@@ -1118,7 +1119,7 @@
}
inNewScope(node, () {
- DartType type = element.type;
+ ResolutionDartType type = element.type;
// If the method needs RTI, or checked mode is set, we need to
// escape the potential type variables used in that closure.
if (element is FunctionElement &&
@@ -1196,7 +1197,7 @@
/// A type variable as a local variable.
class TypeVariableLocal implements Local {
- final TypeVariableType typeVariable;
+ final ResolutionTypeVariableType typeVariable;
final ExecutableElement executableContext;
TypeVariableLocal(this.typeVariable, this.executableContext);
diff --git a/pkg/compiler/lib/src/common/backend_api.dart b/pkg/compiler/lib/src/common/backend_api.dart
index 639b9a3..e375db2 100644
--- a/pkg/compiler/lib/src/common/backend_api.dart
+++ b/pkg/compiler/lib/src/common/backend_api.dart
@@ -15,7 +15,8 @@
import '../constants/constant_system.dart' show ConstantSystem;
import '../constants/expressions.dart' show ConstantExpression;
import '../constants/values.dart' show ConstantValue;
-import '../dart_types.dart' show DartType, InterfaceType;
+import '../elements/resolution_types.dart'
+ show ResolutionDartType, ResolutionInterfaceType;
import '../elements/elements.dart'
show
ClassElement,
@@ -150,12 +151,12 @@
/// Called to instruct to the backend register [type] as instantiated on
/// [enqueuer].
- void registerInstantiatedType(InterfaceType type) {}
+ void registerInstantiatedType(ResolutionInterfaceType type) {}
/// Register a runtime type variable bound tests between [typeArgument] and
/// [bound].
void registerTypeVariableBoundsSubtypeCheck(
- DartType typeArgument, DartType bound) {}
+ ResolutionDartType typeArgument, ResolutionDartType bound) {}
/// Called to instruct the backend to register that a closure exists for a
/// function on an instantiated generic class. Any backend specific
@@ -359,10 +360,10 @@
ConstantExpression getConstant(Node node);
/// Registers [type] as instantiated.
- void registerInstantiatedType(InterfaceType type);
+ void registerInstantiatedType(ResolutionInterfaceType type);
/// Resolves [typeName] to a type in the context of [node].
- DartType resolveTypeFromString(Node node, String typeName);
+ ResolutionDartType resolveTypeFromString(Node node, String typeName);
}
/// Backend transformation methods for the world impacts.
@@ -419,5 +420,6 @@
bool isDefaultEqualityImplementation(Element element);
bool isInterceptorClass(ClassElement cls);
- bool isNative(Element element);
+ bool isNativeClass(ClassElement element);
+ bool isNativeMember(MemberElement element);
}
diff --git a/pkg/compiler/lib/src/common/codegen.dart b/pkg/compiler/lib/src/common/codegen.dart
index 748f222..cd17e56 100644
--- a/pkg/compiler/lib/src/common/codegen.dart
+++ b/pkg/compiler/lib/src/common/codegen.dart
@@ -7,7 +7,8 @@
import '../common.dart';
import '../common/backend_api.dart' show Backend;
import '../constants/values.dart' show ConstantValue;
-import '../dart_types.dart' show DartType, InterfaceType;
+import '../elements/resolution_types.dart'
+ show ResolutionDartType, ResolutionInterfaceType;
import '../elements/elements.dart'
show
AstElement,
@@ -28,8 +29,9 @@
Iterable<ConstantValue> get compileTimeConstants => const <ConstantValue>[];
- Iterable<Pair<DartType, DartType>> get typeVariableBoundsSubtypeChecks {
- return const <Pair<DartType, DartType>>[];
+ Iterable<Pair<ResolutionDartType, ResolutionDartType>>
+ get typeVariableBoundsSubtypeChecks {
+ return const <Pair<ResolutionDartType, ResolutionDartType>>[];
}
Iterable<String> get constSymbols => const <String>[];
@@ -47,7 +49,8 @@
class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
Setlet<ConstantValue> _compileTimeConstants;
- Setlet<Pair<DartType, DartType>> _typeVariableBoundsSubtypeChecks;
+ Setlet<Pair<ResolutionDartType, ResolutionDartType>>
+ _typeVariableBoundsSubtypeChecks;
Setlet<String> _constSymbols;
List<Set<ClassElement>> _specializedGetInterceptors;
bool _usesInterceptor = false;
@@ -76,18 +79,20 @@
}
void registerTypeVariableBoundsSubtypeCheck(
- DartType subtype, DartType supertype) {
+ ResolutionDartType subtype, ResolutionDartType supertype) {
if (_typeVariableBoundsSubtypeChecks == null) {
- _typeVariableBoundsSubtypeChecks = new Setlet<Pair<DartType, DartType>>();
+ _typeVariableBoundsSubtypeChecks =
+ new Setlet<Pair<ResolutionDartType, ResolutionDartType>>();
}
- _typeVariableBoundsSubtypeChecks
- .add(new Pair<DartType, DartType>(subtype, supertype));
+ _typeVariableBoundsSubtypeChecks.add(
+ new Pair<ResolutionDartType, ResolutionDartType>(subtype, supertype));
}
- Iterable<Pair<DartType, DartType>> get typeVariableBoundsSubtypeChecks {
+ Iterable<Pair<ResolutionDartType, ResolutionDartType>>
+ get typeVariableBoundsSubtypeChecks {
return _typeVariableBoundsSubtypeChecks != null
? _typeVariableBoundsSubtypeChecks
- : const <Pair<DartType, DartType>>[];
+ : const <Pair<ResolutionDartType, ResolutionDartType>>[];
}
void registerConstSymbol(String name) {
@@ -184,7 +189,7 @@
}
void registerTypeVariableBoundsSubtypeCheck(
- DartType subtype, DartType supertype) {
+ ResolutionDartType subtype, ResolutionDartType supertype) {
worldImpact.registerTypeVariableBoundsSubtypeCheck(subtype, supertype);
}
@@ -208,7 +213,7 @@
worldImpact.registerTypeConstant(element);
}
- void registerInstantiation(InterfaceType type) {
+ void registerInstantiation(ResolutionInterfaceType type) {
registerTypeUse(new TypeUse.instantiation(type));
}
diff --git a/pkg/compiler/lib/src/common/resolution.dart b/pkg/compiler/lib/src/common/resolution.dart
index 9d3c852..0ccd78e 100644
--- a/pkg/compiler/lib/src/common/resolution.dart
+++ b/pkg/compiler/lib/src/common/resolution.dart
@@ -10,12 +10,13 @@
import '../constants/expressions.dart' show ConstantExpression;
import '../constants/values.dart' show ConstantValue;
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart' show DartType, Types;
+import '../elements/resolution_types.dart' show ResolutionDartType, Types;
import '../elements/elements.dart'
show
AstElement,
ClassElement,
Element,
+ Entity,
ExecutableElement,
FunctionElement,
FunctionSignature,
@@ -112,7 +113,7 @@
/// Returns `true` if [element] is a native element, that is, that the
/// corresponding entity already exists in the target language.
- bool isNative(Element element) => false;
+ bool isNative(Entity element) => false;
/// Returns `true` if [element] is a foreign element, that is, that the
/// backend has specialized handling for the element.
@@ -150,7 +151,8 @@
void registerClass(ClassElement cls);
void resolveMetadataAnnotation(MetadataAnnotation metadataAnnotation);
FunctionSignature resolveSignature(FunctionElement function);
- DartType resolveTypeAnnotation(Element element, TypeAnnotation node);
+ ResolutionDartType resolveTypeAnnotation(
+ Element element, TypeAnnotation node);
/// Returns `true` if [element] has been resolved.
// TODO(johnniwinther): Normalize semantics between normal and deserialized
diff --git a/pkg/compiler/lib/src/compile_time_constants.dart b/pkg/compiler/lib/src/compile_time_constants.dart
index d99734e..9d2d6db 100644
--- a/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/pkg/compiler/lib/src/compile_time_constants.dart
@@ -14,7 +14,7 @@
import 'constants/expressions.dart';
import 'constants/values.dart';
import 'core_types.dart' show CommonElements;
-import 'dart_types.dart';
+import 'elements/resolution_types.dart';
import 'elements/elements.dart';
import 'elements/modelx.dart' show ConstantVariableMixin;
import 'resolution/operators.dart';
@@ -252,7 +252,7 @@
checkType &&
expression != null &&
element.isField) {
- DartType elementType = element.type;
+ ResolutionDartType elementType = element.type;
ConstantValue value = getConstantValue(expression);
if (elementType.isMalformed && !value.isNull) {
if (isConst) {
@@ -272,7 +272,7 @@
expression = null;
}
} else {
- DartType constantType = value.getType(commonElements);
+ ResolutionDartType constantType = value.getType(commonElements);
if (!constantSystem.isSubtype(
compiler.types, constantType, elementType)) {
if (isConst) {
@@ -470,7 +470,7 @@
argumentExpressions.add(argument.expression);
argumentValues.add(argument.value);
}
- DartType type = elements.getType(node);
+ ResolutionDartType type = elements.getType(node);
return new AstConstant(
context,
node,
@@ -508,7 +508,7 @@
valueExpressions.add(value.expression);
map[key.value] = value.value;
}
- InterfaceType type = elements.getType(node);
+ ResolutionInterfaceType type = elements.getType(node);
return new AstConstant(
context,
node,
@@ -594,7 +594,7 @@
}
AstConstant visitLiteralSymbol(LiteralSymbol node) {
- InterfaceType type = commonElements.symbolType;
+ ResolutionInterfaceType type = commonElements.symbolType;
String text = node.slowNameString;
List<AstConstant> arguments = <AstConstant>[
new AstConstant(context, node, new StringConstantExpression(text),
@@ -608,7 +608,7 @@
context, node, new SymbolConstantExpression(text), constant.value);
}
- ConstantValue makeTypeConstant(DartType elementType) {
+ ConstantValue makeTypeConstant(ResolutionDartType elementType) {
return constantSystem.createType(compiler, elementType);
}
@@ -624,7 +624,7 @@
Element element = elements[node];
if (Elements.isClass(element) || Elements.isTypedef(element)) {
TypeDeclarationElement typeDeclarationElement = element;
- DartType type = typeDeclarationElement.rawType;
+ ResolutionDartType type = typeDeclarationElement.rawType;
return new AstConstant(element, node, new TypeConstantExpression(type),
makeTypeConstant(type));
}
@@ -637,13 +637,13 @@
if (send.isPropertyAccess) {
AstConstant result;
if (Elements.isStaticOrTopLevelFunction(element)) {
- FunctionElement function = element;
+ MethodElement function = element;
function.computeType(resolution);
result = new AstConstant(
context,
send,
new FunctionConstantExpression(function),
- new FunctionConstantValue(function));
+ new FunctionConstantValue(function, function.type));
} else if (Elements.isStaticOrTopLevelField(element)) {
ConstantExpression elementExpression;
if (element.isConst) {
@@ -660,7 +660,7 @@
}
} else if (Elements.isClass(element) || Elements.isTypedef(element)) {
assert(elements.isTypeLiteral(send));
- DartType elementType = elements.getTypeLiteralType(send);
+ ResolutionDartType elementType = elements.getTypeLiteralType(send);
result = new AstConstant(
context,
send,
@@ -810,7 +810,8 @@
if (condition == null || condition.isError) {
return condition;
} else if (!condition.value.isBool) {
- DartType conditionType = condition.value.getType(commonElements);
+ ResolutionDartType conditionType =
+ condition.value.getType(commonElements);
if (isEvaluatingConstant) {
reporter.reportErrorMessage(node.condition, MessageKind.NOT_ASSIGNABLE,
{'fromType': conditionType, 'toType': commonElements.boolType});
@@ -897,16 +898,20 @@
message: MessageKind.DEFERRED_COMPILE_TIME_CONSTANT_CONSTRUCTION);
}
- InterfaceType type = elements.getType(node);
+ ResolutionInterfaceType type = elements.getType(node);
CallStructure callStructure = elements.getSelector(send).callStructure;
return createConstructorInvocation(node, type, constructor, callStructure,
arguments: node.send.arguments);
}
- AstConstant createConstructorInvocation(Node node, InterfaceType type,
- ConstructorElement constructor, CallStructure callStructure,
- {Link<Node> arguments, List<AstConstant> normalizedArguments}) {
+ AstConstant createConstructorInvocation(
+ Node node,
+ ResolutionInterfaceType type,
+ ConstructorElement constructor,
+ CallStructure callStructure,
+ {Link<Node> arguments,
+ List<AstConstant> normalizedArguments}) {
// TODO(ahe): This is nasty: we must eagerly analyze the
// constructor to ensure the redirectionTarget has been computed
// correctly. Find a way to avoid this.
@@ -917,7 +922,7 @@
compiler.resolver.resolveRedirectionChain(constructor, node);
bool isInvalid = false;
- InterfaceType constructedType = type;
+ ResolutionInterfaceType constructedType = type;
ConstructorElement implementation;
if (constructor.isRedirectingFactory) {
if (constructor.isEffectiveTargetMalformed) {
@@ -994,7 +999,7 @@
AstConstant createFromEnvironmentConstant(
Node node,
- InterfaceType type,
+ ResolutionInterfaceType type,
ConstructorElement constructor,
CallStructure callStructure,
List<AstConstant> normalizedArguments,
@@ -1008,7 +1013,7 @@
}
if (!firstArgument.isString) {
- DartType type = defaultValue.getType(commonElements);
+ ResolutionDartType type = defaultValue.getType(commonElements);
return reportNotCompileTimeConstant(
normalizedArguments[0].node,
MessageKind.NOT_ASSIGNABLE,
@@ -1017,7 +1022,7 @@
if (constructor.isIntFromEnvironmentConstructor &&
!(defaultValue.isNull || defaultValue.isInt)) {
- DartType type = defaultValue.getType(commonElements);
+ ResolutionDartType type = defaultValue.getType(commonElements);
return reportNotCompileTimeConstant(
normalizedArguments[1].node,
MessageKind.NOT_ASSIGNABLE,
@@ -1026,7 +1031,7 @@
if (constructor.isBoolFromEnvironmentConstructor &&
!(defaultValue.isNull || defaultValue.isBool)) {
- DartType type = defaultValue.getType(commonElements);
+ ResolutionDartType type = defaultValue.getType(commonElements);
return reportNotCompileTimeConstant(
normalizedArguments[1].node,
MessageKind.NOT_ASSIGNABLE,
@@ -1035,7 +1040,7 @@
if (constructor.isStringFromEnvironmentConstructor &&
!(defaultValue.isNull || defaultValue.isString)) {
- DartType type = defaultValue.getType(commonElements);
+ ResolutionDartType type = defaultValue.getType(commonElements);
return reportNotCompileTimeConstant(
normalizedArguments[1].node,
MessageKind.NOT_ASSIGNABLE,
@@ -1092,9 +1097,9 @@
ConstantCompilerBase handler,
Element context,
Node node,
- InterfaceType type,
+ ResolutionInterfaceType type,
ConstructorElement constructor,
- InterfaceType constructedType,
+ ResolutionInterfaceType constructedType,
ConstructorElement target,
CallStructure callStructure,
List<AstConstant> concreteArguments,
@@ -1163,7 +1168,7 @@
}
class ConstructorEvaluator extends CompileTimeConstantEvaluator {
- final InterfaceType constructedType;
+ final ResolutionInterfaceType constructedType;
final ConstructorElement constructor;
final Map<Element, AstConstant> definitions;
final Map<Element, AstConstant> fieldValues;
@@ -1175,7 +1180,7 @@
* Invariant: [constructor] must be an implementation element.
*/
ConstructorEvaluator(
- InterfaceType this.constructedType,
+ ResolutionInterfaceType this.constructedType,
ConstructorElement constructor,
ConstantCompiler handler,
Compiler compiler)
@@ -1208,8 +1213,9 @@
void potentiallyCheckType(TypedElement element, AstConstant constant) {
if (compiler.options.enableTypeAssertions) {
- DartType elementType = element.type.substByContext(constructedType);
- DartType constantType = constant.value.getType(commonElements);
+ ResolutionDartType elementType =
+ element.type.substByContext(constructedType);
+ ResolutionDartType constantType = constant.value.getType(commonElements);
if (!constantSystem.isSubtype(
compiler.types, constantType, elementType)) {
reporter.withCurrentElement(constant.element, () {
@@ -1250,7 +1256,7 @@
void evaluateSuperOrRedirectSend(List<AstConstant> compiledArguments,
CallStructure callStructure, ConstructorElement targetConstructor) {
- InterfaceType type =
+ ResolutionInterfaceType type =
constructedType.asInstanceOf(targetConstructor.enclosingClass);
if (compiler.serialization.isDeserialized(targetConstructor)) {
List<ConstantExpression> arguments =
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index 9670004..4a377dc 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -25,7 +25,12 @@
import 'compile_time_constants.dart';
import 'constants/values.dart';
import 'core_types.dart' show CommonElements;
-import 'dart_types.dart' show DartType, DynamicType, InterfaceType, Types;
+import 'elements/resolution_types.dart'
+ show
+ ResolutionDartType,
+ ResolutionDynamicType,
+ ResolutionInterfaceType,
+ Types;
import 'deferred_load.dart' show DeferredLoadTask;
import 'diagnostics/code_location.dart';
import 'diagnostics/diagnostic_listener.dart' show DiagnosticReporter;
@@ -691,9 +696,7 @@
assert(mainFunction != null);
ClosedWorldRefiner closedWorldRefiner = closeResolution();
- // TODO(johnniwinther): Make [ClosedWorld] a property of
- // [ClosedWorldRefiner].
- ClosedWorld closedWorld = resolverWorld.closedWorldForTesting;
+ ClosedWorld closedWorld = closedWorldRefiner.closedWorld;
reporter.log('Inferring types...');
globalInference.runGlobalTypeInference(
@@ -706,6 +709,7 @@
reporter.log('Compiling...');
phase = PHASE_COMPILING;
+ codegenWorld.open(closedWorld);
enqueuer.codegen.applyImpact(backend.onCodegenStart(closedWorld));
if (compileAll) {
libraryLoader.libraries.forEach((LibraryElement library) {
@@ -1309,45 +1313,45 @@
_nativeAnnotationClass ??= _findRequired(jsHelperLibrary, 'Native');
@override
- InterfaceType get objectType {
+ ResolutionInterfaceType get objectType {
objectClass.ensureResolved(resolution);
return objectClass.rawType;
}
@override
- InterfaceType get boolType {
+ ResolutionInterfaceType get boolType {
boolClass.ensureResolved(resolution);
return boolClass.rawType;
}
@override
- InterfaceType get doubleType {
+ ResolutionInterfaceType get doubleType {
doubleClass.ensureResolved(resolution);
return doubleClass.rawType;
}
@override
- InterfaceType get functionType {
+ ResolutionInterfaceType get functionType {
functionClass.ensureResolved(resolution);
return functionClass.rawType;
}
@override
- InterfaceType get intType {
+ ResolutionInterfaceType get intType {
intClass.ensureResolved(resolution);
return intClass.rawType;
}
@override
- InterfaceType get resourceType {
+ ResolutionInterfaceType get resourceType {
resourceClass.ensureResolved(resolution);
return resourceClass.rawType;
}
@override
- InterfaceType listType([DartType elementType]) {
+ ResolutionInterfaceType listType([ResolutionDartType elementType]) {
listClass.ensureResolved(resolution);
- InterfaceType type = listClass.rawType;
+ ResolutionInterfaceType type = listClass.rawType;
if (elementType == null) {
return type;
}
@@ -1355,59 +1359,60 @@
}
@override
- InterfaceType mapType([DartType keyType, DartType valueType]) {
+ ResolutionInterfaceType mapType(
+ [ResolutionDartType keyType, ResolutionDartType valueType]) {
mapClass.ensureResolved(resolution);
- InterfaceType type = mapClass.rawType;
+ ResolutionInterfaceType type = mapClass.rawType;
if (keyType == null && valueType == null) {
return type;
} else if (keyType == null) {
- keyType = const DynamicType();
+ keyType = const ResolutionDynamicType();
} else if (valueType == null) {
- valueType = const DynamicType();
+ valueType = const ResolutionDynamicType();
}
return type.createInstantiation([keyType, valueType]);
}
@override
- InterfaceType get nullType {
+ ResolutionInterfaceType get nullType {
nullClass.ensureResolved(resolution);
return nullClass.rawType;
}
@override
- InterfaceType get numType {
+ ResolutionInterfaceType get numType {
numClass.ensureResolved(resolution);
return numClass.rawType;
}
@override
- InterfaceType get stringType {
+ ResolutionInterfaceType get stringType {
stringClass.ensureResolved(resolution);
return stringClass.rawType;
}
@override
- InterfaceType get symbolType {
+ ResolutionInterfaceType get symbolType {
symbolClass.ensureResolved(resolution);
return symbolClass.rawType;
}
@override
- InterfaceType get typeType {
+ ResolutionInterfaceType get typeType {
typeClass.ensureResolved(resolution);
return typeClass.rawType;
}
@override
- InterfaceType get stackTraceType {
+ ResolutionInterfaceType get stackTraceType {
stackTraceClass.ensureResolved(resolution);
return stackTraceClass.rawType;
}
@override
- InterfaceType iterableType([DartType elementType]) {
+ ResolutionInterfaceType iterableType([ResolutionDartType elementType]) {
iterableClass.ensureResolved(resolution);
- InterfaceType type = iterableClass.rawType;
+ ResolutionInterfaceType type = iterableClass.rawType;
if (elementType == null) {
return type;
}
@@ -1415,9 +1420,9 @@
}
@override
- InterfaceType futureType([DartType elementType]) {
+ ResolutionInterfaceType futureType([ResolutionDartType elementType]) {
futureClass.ensureResolved(resolution);
- InterfaceType type = futureClass.rawType;
+ ResolutionInterfaceType type = futureClass.rawType;
if (elementType == null) {
return type;
}
@@ -1425,9 +1430,9 @@
}
@override
- InterfaceType streamType([DartType elementType]) {
+ ResolutionInterfaceType streamType([ResolutionDartType elementType]) {
streamClass.ensureResolved(resolution);
- InterfaceType type = streamClass.rawType;
+ ResolutionInterfaceType type = streamClass.rawType;
if (elementType == null) {
return type;
}
@@ -1474,6 +1479,18 @@
ConstructorElement _filledListConstructor;
ConstructorElement get filledListConstructor =>
_filledListConstructor ??= listClass.lookupConstructor("filled");
+
+ // TODO(johnniwinther): Change types to `ClassElement` when these are not
+ // called with unrelated elements.
+ bool isNumberOrStringSupertype(/*Class*/ Element element) {
+ return element == coreLibrary.find('Comparable');
+ }
+
+ bool isStringOnlySupertype(/*Class*/ Element element) {
+ return element == coreLibrary.find('Pattern');
+ }
+
+ bool isListSupertype(/*Class*/ Element element) => element == iterableClass;
}
class CompilerDiagnosticReporter extends DiagnosticReporter {
@@ -1971,7 +1988,8 @@
}
@override
- DartType resolveTypeAnnotation(Element element, TypeAnnotation node) {
+ ResolutionDartType resolveTypeAnnotation(
+ Element element, TypeAnnotation node) {
return _compiler.resolver.resolveTypeAnnotation(element, node);
}
diff --git a/pkg/compiler/lib/src/constant_system_dart.dart b/pkg/compiler/lib/src/constant_system_dart.dart
index 8df511f..b0e7ce7 100644
--- a/pkg/compiler/lib/src/constant_system_dart.dart
+++ b/pkg/compiler/lib/src/constant_system_dart.dart
@@ -7,7 +7,7 @@
import 'compiler.dart' show Compiler;
import 'constants/constant_system.dart';
import 'constants/values.dart';
-import 'dart_types.dart';
+import 'elements/resolution_types.dart';
import 'tree/dartstring.dart' show DartString;
const DART_CONSTANT_SYSTEM = const DartConstantSystem();
@@ -433,18 +433,19 @@
NullConstantValue createNull() => new NullConstantValue();
@override
- ListConstantValue createList(InterfaceType type, List<ConstantValue> values) {
+ ListConstantValue createList(
+ ResolutionInterfaceType type, List<ConstantValue> values) {
return new ListConstantValue(type, values);
}
@override
- MapConstantValue createMap(Compiler compiler, InterfaceType type,
+ MapConstantValue createMap(Compiler compiler, ResolutionInterfaceType type,
List<ConstantValue> keys, List<ConstantValue> values) {
return new MapConstantValue(type, keys, values);
}
@override
- ConstantValue createType(Compiler compiler, DartType type) {
+ ConstantValue createType(Compiler compiler, ResolutionDartType type) {
// TODO(johnniwinther): Change the `Type` type to
// `compiler.commonElements.typeType` and check the backend specific value
// in [checkConstMapKeysDontOverrideEquals] in 'members.dart'.
@@ -465,7 +466,7 @@
bool isBool(ConstantValue constant) => constant.isBool;
bool isNull(ConstantValue constant) => constant.isNull;
- bool isSubtype(DartTypes types, DartType s, DartType t) {
+ bool isSubtype(DartTypes types, ResolutionDartType s, ResolutionDartType t) {
return types.isSubtype(s, t);
}
}
diff --git a/pkg/compiler/lib/src/constants/constant_constructors.dart b/pkg/compiler/lib/src/constants/constant_constructors.dart
index 7945601..38a182d 100644
--- a/pkg/compiler/lib/src/constants/constant_constructors.dart
+++ b/pkg/compiler/lib/src/constants/constant_constructors.dart
@@ -7,7 +7,7 @@
library dart2js.constants.constant_constructors;
import '../common.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../resolution/operators.dart';
import '../resolution/semantic_visitor.dart';
@@ -112,7 +112,7 @@
FunctionExpression node,
ConstructorElement constructor,
NodeList parameters,
- InterfaceType redirectionType,
+ ResolutionInterfaceType redirectionType,
ConstructorElement redirectionTarget,
_) {
List<String> argumentNames = [];
@@ -230,7 +230,7 @@
ConstructedConstantExpression visitSuperConstructorInvoke(
Send node,
ConstructorElement superConstructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
@@ -243,7 +243,7 @@
ConstructedConstantExpression visitImplicitSuperConstructorInvoke(
FunctionExpression node,
ConstructorElement superConstructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
_) {
return new ConstructedConstantExpression(type, superConstructor,
CallStructure.NO_ARGS, const <ConstantExpression>[]);
diff --git a/pkg/compiler/lib/src/constants/constant_system.dart b/pkg/compiler/lib/src/constants/constant_system.dart
index edccf03..b8c964e 100644
--- a/pkg/compiler/lib/src/constants/constant_system.dart
+++ b/pkg/compiler/lib/src/constants/constant_system.dart
@@ -5,7 +5,7 @@
library dart2js.constant_system;
import '../compiler.dart' show Compiler;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../resolution/operators.dart';
import '../tree/dartstring.dart' show DartString;
import 'values.dart';
@@ -63,18 +63,19 @@
ConstantValue createString(DartString string);
ConstantValue createBool(bool value);
ConstantValue createNull();
- ConstantValue createList(InterfaceType type, List<ConstantValue> values);
+ ConstantValue createList(
+ ResolutionInterfaceType type, List<ConstantValue> values);
// TODO(johnniwinther): Remove the need for [compiler].
- ConstantValue createMap(Compiler compiler, InterfaceType type,
+ ConstantValue createMap(Compiler compiler, ResolutionInterfaceType type,
List<ConstantValue> keys, List<ConstantValue> values);
// TODO(johnniwinther): Remove the need for [compiler].
- ConstantValue createType(Compiler compiler, DartType type);
+ ConstantValue createType(Compiler compiler, ResolutionDartType type);
// TODO(johnniwinther): Remove the need for [compiler].
ConstantValue createSymbol(Compiler compiler, String text);
// We need to special case the subtype check for JavaScript constant
// system because an int is a double at runtime.
- bool isSubtype(DartTypes types, DartType s, DartType t);
+ bool isSubtype(DartTypes types, ResolutionDartType s, ResolutionDartType t);
/** Returns true if the [constant] is an integer at runtime. */
bool isInt(ConstantValue constant);
diff --git a/pkg/compiler/lib/src/constants/constructors.dart b/pkg/compiler/lib/src/constants/constructors.dart
index c0e09b6..8199bbc 100644
--- a/pkg/compiler/lib/src/constants/constructors.dart
+++ b/pkg/compiler/lib/src/constants/constructors.dart
@@ -4,7 +4,7 @@
library dart2js.constants.constructors;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart' show FieldElement;
import '../universe/call_structure.dart' show CallStructure;
import '../util/util.dart';
@@ -23,7 +23,7 @@
/// Computes the type of the instance created in a const constructor
/// invocation with type [newType].
- InterfaceType computeInstanceType(InterfaceType newType);
+ ResolutionInterfaceType computeInstanceType(ResolutionInterfaceType newType);
/// Computes the constant expressions of the fields of the created instance
/// in a const constructor invocation with [arguments].
@@ -49,7 +49,7 @@
/// A generative constant constructor.
class GenerativeConstantConstructor implements ConstantConstructor {
- final InterfaceType type;
+ final ResolutionInterfaceType type;
final Map<dynamic /*int|String*/, ConstantExpression> defaultValues;
final Map<FieldElement, ConstantExpression> fieldMap;
final ConstructedConstantExpression superConstructorInvocation;
@@ -59,7 +59,7 @@
ConstantConstructorKind get kind => ConstantConstructorKind.GENERATIVE;
- InterfaceType computeInstanceType(InterfaceType newType) {
+ ResolutionInterfaceType computeInstanceType(ResolutionInterfaceType newType) {
return type.substByContext(newType);
}
@@ -152,7 +152,7 @@
return ConstantConstructorKind.REDIRECTING_GENERATIVE;
}
- InterfaceType computeInstanceType(InterfaceType newType) {
+ ResolutionInterfaceType computeInstanceType(ResolutionInterfaceType newType) {
return thisConstructorInvocation
.computeInstanceType()
.substByContext(newType);
@@ -207,7 +207,7 @@
return ConstantConstructorKind.REDIRECTING_FACTORY;
}
- InterfaceType computeInstanceType(InterfaceType newType) {
+ ResolutionInterfaceType computeInstanceType(ResolutionInterfaceType newType) {
return targetConstructorInvocation
.computeInstanceType()
.substByContext(newType);
diff --git a/pkg/compiler/lib/src/constants/expressions.dart b/pkg/compiler/lib/src/constants/expressions.dart
index f68dbe1..2a5b434 100644
--- a/pkg/compiler/lib/src/constants/expressions.dart
+++ b/pkg/compiler/lib/src/constants/expressions.dart
@@ -7,12 +7,12 @@
import '../common.dart';
import '../constants/constant_system.dart';
import '../core_types.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart'
show
ConstructorElement,
FieldElement,
- FunctionElement,
+ MethodElement,
PrefixElement,
VariableElement;
import '../resolution/operators.dart';
@@ -80,7 +80,7 @@
/// Returns the type of this constant expression, if it is independent of the
/// environment values.
- DartType getKnownType(CommonElements commonElements) => null;
+ ResolutionDartType getKnownType(CommonElements commonElements) => null;
/// Returns a text string resembling the Dart code creating this constant.
String toDartText() {
@@ -236,7 +236,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.boolType;
}
@@ -272,7 +272,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.intType;
}
@@ -308,7 +308,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.doubleType;
}
@@ -344,7 +344,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.stringType;
}
@@ -378,13 +378,13 @@
bool _equals(NullConstantExpression other) => true;
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.nullType;
}
/// Literal list constant.
class ListConstantExpression extends ConstantExpression {
- final InterfaceType type;
+ final ResolutionInterfaceType type;
final List<ConstantExpression> values;
ListConstantExpression(this.type, this.values);
@@ -439,7 +439,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) => type;
+ ResolutionDartType getKnownType(CommonElements commonElements) => type;
@override
bool get isImplicit => false;
@@ -450,7 +450,7 @@
/// Literal map constant.
class MapConstantExpression extends ConstantExpression {
- final InterfaceType type;
+ final ResolutionInterfaceType type;
final List<ConstantExpression> keys;
final List<ConstantExpression> values;
@@ -518,7 +518,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) => type;
+ ResolutionDartType getKnownType(CommonElements commonElements) => type;
@override
bool get isImplicit => false;
@@ -531,7 +531,7 @@
/// Invocation of a const constructor.
class ConstructedConstantExpression extends ConstantExpression {
- final InterfaceType type;
+ final ResolutionInterfaceType type;
final ConstructorElement target;
final CallStructure callStructure;
final List<ConstantExpression> arguments;
@@ -568,7 +568,7 @@
.computeInstanceFields(arguments, callStructure);
}
- InterfaceType computeInstanceType() {
+ ResolutionInterfaceType computeInstanceType() {
return target.constantConstructor.computeInstanceType(type);
}
@@ -695,7 +695,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.stringType;
@override
@@ -736,17 +736,17 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.symbolType;
}
/// Type literal.
class TypeConstantExpression extends ConstantExpression {
- /// Either [DynamicType] or a raw [GenericType].
- final DartType type;
+ /// Either [ResolutionDynamicType] or a raw [GenericType].
+ final ResolutionDartType type;
TypeConstantExpression(this.type) {
- assert(type is GenericType || type is DynamicType);
+ assert(type is GenericType || type is ResolutionDynamicType);
}
ConstantExpressionKind get kind => ConstantExpressionKind.TYPE;
@@ -775,7 +775,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.typeType;
}
@@ -813,7 +813,7 @@
/// Reference to a top-level or static function.
class FunctionConstantExpression extends ConstantExpression {
- final FunctionElement element;
+ final MethodElement element;
FunctionConstantExpression(this.element);
@@ -831,7 +831,7 @@
@override
ConstantValue evaluate(
Environment environment, ConstantSystem constantSystem) {
- return new FunctionConstantValue(element);
+ return new FunctionConstantValue(element, element.type);
}
@override
@@ -843,7 +843,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.functionType;
}
@@ -894,9 +894,9 @@
left.apply(arguments), operator, right.apply(arguments));
}
- DartType getKnownType(CommonElements commonElements) {
- DartType knownLeftType = left.getKnownType(commonElements);
- DartType knownRightType = right.getKnownType(commonElements);
+ ResolutionDartType getKnownType(CommonElements commonElements) {
+ ResolutionDartType knownLeftType = left.getKnownType(commonElements);
+ ResolutionDartType knownRightType = right.getKnownType(commonElements);
switch (operator.kind) {
case BinaryOperatorKind.EQ:
case BinaryOperatorKind.NOT_EQ:
@@ -1036,7 +1036,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.boolType;
@override
@@ -1092,7 +1092,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) {
+ ResolutionDartType getKnownType(CommonElements commonElements) {
return expression.getKnownType(commonElements);
}
@@ -1155,7 +1155,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.intType;
@override
@@ -1227,9 +1227,9 @@
}
@override
- DartType getKnownType(CommonElements commonElements) {
- DartType trueType = trueExp.getKnownType(commonElements);
- DartType falseType = falseExp.getKnownType(commonElements);
+ ResolutionDartType getKnownType(CommonElements commonElements) {
+ ResolutionDartType trueType = trueExp.getKnownType(commonElements);
+ ResolutionDartType falseType = falseExp.getKnownType(commonElements);
if (trueType == falseType) {
return trueType;
}
@@ -1408,7 +1408,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.boolType;
}
@@ -1474,7 +1474,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.intType;
}
@@ -1536,7 +1536,7 @@
}
@override
- DartType getKnownType(CommonElements commonElements) =>
+ ResolutionDartType getKnownType(CommonElements commonElements) =>
commonElements.stringType;
}
@@ -1641,11 +1641,11 @@
}
}
- void writeTypeArguments(InterfaceType type) {
+ void writeTypeArguments(ResolutionInterfaceType type) {
if (type.treatAsRaw) return;
sb.write('<');
bool needsComma = false;
- for (DartType value in type.typeArguments) {
+ for (ResolutionDartType value in type.typeArguments) {
if (needsComma) {
sb.write(', ');
}
diff --git a/pkg/compiler/lib/src/constants/values.dart b/pkg/compiler/lib/src/constants/values.dart
index 5be89fc..9cf9b4b 100644
--- a/pkg/compiler/lib/src/constants/values.dart
+++ b/pkg/compiler/lib/src/constants/values.dart
@@ -6,9 +6,9 @@
import '../common.dart';
import '../core_types.dart';
-import '../dart_types.dart';
-import '../elements/elements.dart'
- show FieldElement, FunctionElement, PrefixElement;
+import '../elements/elements.dart' show Entity;
+import '../elements/entities.dart';
+import '../elements/resolution_types.dart';
import '../tree/dartstring.dart';
import '../util/util.dart' show Hashing;
@@ -82,7 +82,7 @@
bool get isNegativeInfinity => false;
// TODO(johnniwinther): Replace with a 'type' getter.
- DartType getType(CommonElements types);
+ ResolutionDartType getType(CommonElements types);
List<ConstantValue> getDependencies();
@@ -112,11 +112,11 @@
}
class FunctionConstantValue extends ConstantValue {
- FunctionElement element;
+ final FunctionEntity element;
+ // TODO(johnniwinther): Should the type be derived from [element].
+ final ResolutionFunctionType type;
- FunctionConstantValue(this.element) {
- assert(element.type != null);
- }
+ FunctionConstantValue(this.element, this.type);
bool get isFunction => true;
@@ -131,7 +131,7 @@
return new DartString.literal(element.name);
}
- DartType getType(CommonElements types) => element.type;
+ ResolutionDartType getType(CommonElements types) => type;
int get hashCode => (17 * element.hashCode) & 0x7fffffff;
@@ -140,7 +140,7 @@
ConstantValueKind get kind => ConstantValueKind.FUNCTION;
String toDartText() {
- if (element.isStatic) {
+ if (element.enclosingClass != null) {
return '${element.enclosingClass.name}.${element.name}';
} else {
return '${element.name}';
@@ -189,7 +189,7 @@
get primitiveValue => null;
- DartType getType(CommonElements types) => types.nullType;
+ ResolutionDartType getType(CommonElements types) => types.nullType;
// The magic constant has no meaning. It is just a random value.
int get hashCode => 785965825;
@@ -261,7 +261,7 @@
bool get isOne => primitiveValue == 1;
- DartType getType(CommonElements types) => types.intType;
+ ResolutionDartType getType(CommonElements types) => types.intType;
// We have to override the equality operator so that ints and doubles are
// treated as separate constants.
@@ -322,7 +322,7 @@
bool get isNegativeInfinity => primitiveValue == -double.INFINITY;
- DartType getType(CommonElements types) => types.doubleType;
+ ResolutionDartType getType(CommonElements types) => types.doubleType;
bool operator ==(var other) {
if (other is! DoubleConstantValue) return false;
@@ -359,7 +359,7 @@
bool get isBool => true;
- DartType getType(CommonElements types) => types.boolType;
+ ResolutionDartType getType(CommonElements types) => types.boolType;
BoolConstantValue negate();
@@ -427,7 +427,7 @@
bool get isString => true;
- DartType getType(CommonElements types) => types.stringType;
+ ResolutionDartType getType(CommonElements types) => types.stringType;
bool operator ==(var other) {
if (identical(this, other)) return true;
@@ -452,13 +452,13 @@
}
abstract class ObjectConstantValue extends ConstantValue {
- final InterfaceType type;
+ final ResolutionInterfaceType type;
ObjectConstantValue(this.type);
bool get isObject => true;
- DartType getType(CommonElements types) => type;
+ ResolutionDartType getType(CommonElements types) => type;
void _unparseTypeArguments(StringBuffer sb) {
if (!type.treatAsRaw) {
@@ -471,9 +471,10 @@
class TypeConstantValue extends ObjectConstantValue {
/// The user type that this constant represents.
- final DartType representedType;
+ final ResolutionDartType representedType;
- TypeConstantValue(this.representedType, InterfaceType type) : super(type);
+ TypeConstantValue(this.representedType, ResolutionInterfaceType type)
+ : super(type);
bool get isType => true;
@@ -499,7 +500,7 @@
final List<ConstantValue> entries;
final int hashCode;
- ListConstantValue(InterfaceType type, List<ConstantValue> entries)
+ ListConstantValue(ResolutionInterfaceType type, List<ConstantValue> entries)
: this.entries = entries,
hashCode = Hashing.listHash(entries, Hashing.objectHash(type)),
super(type);
@@ -559,8 +560,8 @@
final int hashCode;
Map<ConstantValue, ConstantValue> _lookupMap;
- MapConstantValue(
- InterfaceType type, List<ConstantValue> keys, List<ConstantValue> values)
+ MapConstantValue(ResolutionInterfaceType type, List<ConstantValue> keys,
+ List<ConstantValue> values)
: this.keys = keys,
this.values = values,
this.hashCode = Hashing.listHash(
@@ -637,7 +638,7 @@
class InterceptorConstantValue extends ConstantValue {
/// The type for which this interceptor holds the methods. The constant
/// is a dispatch table for this type.
- final DartType dispatchedType;
+ final ResolutionDartType dispatchedType;
InterceptorConstantValue(this.dispatchedType);
@@ -656,7 +657,8 @@
return visitor.visitInterceptor(this, arg);
}
- DartType getType(CommonElements types) => const DynamicType();
+ ResolutionDartType getType(CommonElements types) =>
+ const ResolutionDynamicType();
ConstantValueKind get kind => ConstantValueKind.INTERCEPTOR;
@@ -689,7 +691,8 @@
return visitor.visitSynthetic(this, arg);
}
- DartType getType(CommonElements types) => const DynamicType();
+ ResolutionDartType getType(CommonElements types) =>
+ const ResolutionDynamicType();
ConstantValueKind get kind => ConstantValueKind.SYNTHETIC;
@@ -701,11 +704,11 @@
class ConstructedConstantValue extends ObjectConstantValue {
// TODO(johnniwinther): Make [fields] private to avoid misuse of the map
// ordering and mutability.
- final Map<FieldElement, ConstantValue> fields;
+ final Map<FieldEntity, ConstantValue> fields;
final int hashCode;
ConstructedConstantValue(
- InterfaceType type, Map<FieldElement, ConstantValue> fields)
+ ResolutionInterfaceType type, Map<FieldEntity, ConstantValue> fields)
: this.fields = fields,
hashCode = Hashing.unorderedMapHash(fields, Hashing.objectHash(type)),
super(type) {
@@ -722,7 +725,7 @@
if (hashCode != other.hashCode) return false;
if (type != other.type) return false;
if (fields.length != other.fields.length) return false;
- for (FieldElement field in fields.keys) {
+ for (FieldEntity field in fields.keys) {
if (fields[field] != other.fields[field]) return false;
}
return true;
@@ -742,7 +745,7 @@
_unparseTypeArguments(sb);
sb.write('(');
int i = 0;
- fields.forEach((FieldElement field, ConstantValue value) {
+ fields.forEach((FieldEntity field, ConstantValue value) {
if (i > 0) sb.write(',');
sb.write(field.name);
sb.write('=');
@@ -759,7 +762,7 @@
sb.write(type);
sb.write('(');
int i = 0;
- fields.forEach((FieldElement field, ConstantValue value) {
+ fields.forEach((FieldEntity field, ConstantValue value) {
if (i > 0) sb.write(',');
sb.write(field.name);
sb.write('=');
@@ -777,7 +780,7 @@
DeferredConstantValue(this.referenced, this.prefix);
final ConstantValue referenced;
- final PrefixElement prefix;
+ final Entity prefix;
bool get isReference => true;
@@ -793,7 +796,7 @@
accept(ConstantValueVisitor visitor, arg) => visitor.visitDeferred(this, arg);
- DartType getType(CommonElements types) => referenced.getType(types);
+ ResolutionDartType getType(CommonElements types) => referenced.getType(types);
ConstantValueKind get kind => ConstantValueKind.DEFERRED;
@@ -819,7 +822,8 @@
List<ConstantValue> getDependencies() => const <ConstantValue>[];
@override
- DartType getType(CommonElements types) => const DynamicType();
+ ResolutionDartType getType(CommonElements types) =>
+ const ResolutionDynamicType();
ConstantValueKind get kind => ConstantValueKind.NON_CONSTANT;
diff --git a/pkg/compiler/lib/src/core_types.dart b/pkg/compiler/lib/src/core_types.dart
index 6f70cbb..cbd1f59 100644
--- a/pkg/compiler/lib/src/core_types.dart
+++ b/pkg/compiler/lib/src/core_types.dart
@@ -5,7 +5,7 @@
// TODO(sigmund): rename and move to common/elements.dart
library dart2js.type_system;
-import 'dart_types.dart';
+import 'elements/resolution_types.dart';
import 'elements/elements.dart'
show
ClassElement,
@@ -135,68 +135,78 @@
ConstructorElement get filledListConstructor;
/// The `Object` type defined in 'dart:core'.
- InterfaceType get objectType;
+ ResolutionInterfaceType get objectType;
/// The `bool` type defined in 'dart:core'.
- InterfaceType get boolType;
+ ResolutionInterfaceType get boolType;
/// The `num` type defined in 'dart:core'.
- InterfaceType get numType;
+ ResolutionInterfaceType get numType;
/// The `int` type defined in 'dart:core'.
- InterfaceType get intType;
+ ResolutionInterfaceType get intType;
/// The `double` type defined in 'dart:core'.
- InterfaceType get doubleType;
+ ResolutionInterfaceType get doubleType;
/// The `Resource` type defined in 'dart:core'.
- InterfaceType get resourceType;
+ ResolutionInterfaceType get resourceType;
/// The `String` type defined in 'dart:core'.
- InterfaceType get stringType;
+ ResolutionInterfaceType get stringType;
/// The `Symbol` type defined in 'dart:core'.
- InterfaceType get symbolType;
+ ResolutionInterfaceType get symbolType;
/// The `Function` type defined in 'dart:core'.
- InterfaceType get functionType;
+ ResolutionInterfaceType get functionType;
/// The `Null` type defined in 'dart:core'.
- InterfaceType get nullType;
+ ResolutionInterfaceType get nullType;
/// The `Type` type defined in 'dart:core'.
- InterfaceType get typeType;
+ ResolutionInterfaceType get typeType;
/// The `StackTrace` type defined in 'dart:core';
- InterfaceType get stackTraceType;
+ ResolutionInterfaceType get stackTraceType;
/// Returns an instance of the `List` type defined in 'dart:core' with
/// [elementType] as its type argument.
///
/// If no type argument is provided, the canonical raw type is returned.
- InterfaceType listType([DartType elementType]);
+ ResolutionInterfaceType listType([ResolutionDartType elementType]);
/// Returns an instance of the `Map` type defined in 'dart:core' with
/// [keyType] and [valueType] as its type arguments.
///
/// If no type arguments are provided, the canonical raw type is returned.
- InterfaceType mapType([DartType keyType, DartType valueType]);
+ ResolutionInterfaceType mapType(
+ [ResolutionDartType keyType, ResolutionDartType valueType]);
/// Returns an instance of the `Iterable` type defined in 'dart:core' with
/// [elementType] as its type argument.
///
/// If no type argument is provided, the canonical raw type is returned.
- InterfaceType iterableType([DartType elementType]);
+ ResolutionInterfaceType iterableType([ResolutionDartType elementType]);
/// Returns an instance of the `Future` type defined in 'dart:async' with
/// [elementType] as its type argument.
///
/// If no type argument is provided, the canonical raw type is returned.
- InterfaceType futureType([DartType elementType]);
+ ResolutionInterfaceType futureType([ResolutionDartType elementType]);
/// Returns an instance of the `Stream` type defined in 'dart:async' with
/// [elementType] as its type argument.
///
/// If no type argument is provided, the canonical raw type is returned.
- InterfaceType streamType([DartType elementType]);
+ ResolutionInterfaceType streamType([ResolutionDartType elementType]);
+
+ /// Returns `true` if [element] is a superclass of `String` or `num`.
+ bool isNumberOrStringSupertype(ClassElement element);
+
+ /// Returns `true` if [element] is a superclass of `String`.
+ bool isStringOnlySupertype(ClassElement element);
+
+ /// Returns `true` if [element] is a superclass of `List`.
+ bool isListSupertype(ClassElement element);
}
diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart
index 838a783..5359f61 100644
--- a/pkg/compiler/lib/src/deferred_load.dart
+++ b/pkg/compiler/lib/src/deferred_load.dart
@@ -15,7 +15,7 @@
ConstructedConstantValue,
DeferredConstantValue,
StringConstantValue;
-import 'dart_types.dart';
+import 'elements/resolution_types.dart';
import 'elements/elements.dart'
show
AccessorElement,
@@ -278,27 +278,27 @@
}
/// Recursively collects all the dependencies of [type].
- void collectTypeDependencies(DartType type) {
+ void collectTypeDependencies(ResolutionDartType type) {
// TODO(het): we would like to separate out types that are only needed for
// rti from types that are needed for their members.
if (type is GenericType) {
type.typeArguments.forEach(collectTypeDependencies);
}
- if (type is FunctionType) {
- for (DartType argumentType in type.parameterTypes) {
+ if (type is ResolutionFunctionType) {
+ for (ResolutionDartType argumentType in type.parameterTypes) {
collectTypeDependencies(argumentType);
}
- for (DartType argumentType in type.optionalParameterTypes) {
+ for (ResolutionDartType argumentType in type.optionalParameterTypes) {
collectTypeDependencies(argumentType);
}
- for (DartType argumentType in type.namedParameterTypes) {
+ for (ResolutionDartType argumentType in type.namedParameterTypes) {
collectTypeDependencies(argumentType);
}
collectTypeDependencies(type.returnType);
- } else if (type is TypedefType) {
+ } else if (type is ResolutionTypedefType) {
elements.add(type.element);
collectTypeDependencies(type.unaliased);
- } else if (type is InterfaceType) {
+ } else if (type is ResolutionInterfaceType) {
elements.add(type.element);
}
}
@@ -338,7 +338,7 @@
default:
}
}, visitTypeUse: (TypeUse typeUse) {
- DartType type = typeUse.type;
+ ResolutionDartType type = typeUse.type;
switch (typeUse.kind) {
case TypeUseKind.TYPE_LITERAL:
if (type.isTypedef || type.isInterfaceType) {
@@ -544,8 +544,9 @@
for (ConstantValue dependency in dependentConstants) {
if (dependency is DeferredConstantValue) {
- _mapConstantDependencies(dependency,
- new _DeclaredDeferredImport(dependency.prefix.deferredImport));
+ PrefixElement prefix = dependency.prefix;
+ _mapConstantDependencies(
+ dependency, new _DeclaredDeferredImport(prefix.deferredImport));
} else {
_mapConstantDependencies(dependency, import);
}
diff --git a/pkg/compiler/lib/src/elements/common.dart b/pkg/compiler/lib/src/elements/common.dart
index 3be91d3..ddc8ddd 100644
--- a/pkg/compiler/lib/src/elements/common.dart
+++ b/pkg/compiler/lib/src/elements/common.dart
@@ -8,9 +8,10 @@
import '../common/names.dart' show Identifiers, Names, Uris;
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart' show DartType, InterfaceType, FunctionType;
import '../util/util.dart' show Link;
import 'elements.dart';
+import 'resolution_types.dart'
+ show ResolutionDartType, ResolutionInterfaceType, ResolutionFunctionType;
abstract class ElementCommon implements Element {
@override
@@ -188,13 +189,13 @@
abstract class ClassElementCommon implements ClassElement {
@override
- Link<DartType> get allSupertypes => allSupertypesAndSelf.supertypes;
+ Link<ResolutionDartType> get allSupertypes => allSupertypesAndSelf.supertypes;
@override
int get hierarchyDepth => allSupertypesAndSelf.maxDepth;
@override
- InterfaceType asInstanceOf(ClassElement cls) {
+ ResolutionInterfaceType asInstanceOf(ClassElement cls) {
if (cls == this) return thisType;
return allSupertypesAndSelf.asInstanceOf(cls);
}
@@ -455,7 +456,7 @@
return false;
}
- FunctionType get callType {
+ ResolutionFunctionType get callType {
MemberSignature member = lookupInterfaceMember(Names.call);
return member != null && member.isMethod ? member.type : null;
}
@@ -497,7 +498,7 @@
}
abstract class FunctionSignatureCommon implements FunctionSignature {
- DartType get returnType => type.returnType;
+ ResolutionDartType get returnType => type.returnType;
void forEachRequiredParameter(void function(Element parameter)) {
requiredParameters.forEach(function);
diff --git a/pkg/compiler/lib/src/elements/elements.dart b/pkg/compiler/lib/src/elements/elements.dart
index ded810b..e6cb031 100644
--- a/pkg/compiler/lib/src/elements/elements.dart
+++ b/pkg/compiler/lib/src/elements/elements.dart
@@ -10,7 +10,6 @@
import '../constants/constructors.dart';
import '../constants/expressions.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
import '../ordered_typeset.dart' show OrderedTypeSet;
import '../resolution/scope.dart' show Scope;
import '../resolution/tree_elements.dart' show TreeElements;
@@ -22,6 +21,7 @@
import '../util/util.dart';
import '../world.dart' show ClosedWorld;
import 'entities.dart';
+import 'resolution_types.dart';
import 'visitor.dart' show ElementVisitor;
part 'names.dart';
@@ -141,7 +141,7 @@
* are elements corresponding to "dynamic", "null", and unresolved
* references.
*
- * Elements are distinct from types ([DartType]). For example, there
+ * Elements are distinct from types ([ResolutionDartType]). For example, there
* is one declaration of the class List, but several related types,
* for example, List, List<int>, List<String>, etc.
*
@@ -676,23 +676,6 @@
return null;
}
- static bool isNumberOrStringSupertype(
- Element element, CommonElements commonElements) {
- LibraryElement coreLibrary = commonElements.coreLibrary;
- return (element == coreLibrary.find('Comparable'));
- }
-
- static bool isStringOnlySupertype(
- Element element, CommonElements commonElements) {
- LibraryElement coreLibrary = commonElements.coreLibrary;
- return element == coreLibrary.find('Pattern');
- }
-
- static bool isListSupertype(Element element, CommonElements commonElements) {
- LibraryElement coreLibrary = commonElements.coreLibrary;
- return element == coreLibrary.find('Iterable');
- }
-
/// A `compareTo` function that places [Element]s in a consistent order based
/// on the source code order.
static int compareByPosition(Element a, Element b) {
@@ -804,7 +787,7 @@
constructor = constructor.effectiveTarget;
ClassElement cls = constructor.enclosingClass;
return cls.library == closedWorld.commonElements.typedDataLibrary &&
- closedWorld.backendClasses.isNative(cls) &&
+ closedWorld.backendClasses.isNativeClass(cls) &&
closedWorld.isSubtypeOf(
cls, closedWorld.commonElements.typedDataClass) &&
closedWorld.isSubtypeOf(cls, closedWorld.commonElements.listClass) &&
@@ -1015,18 +998,18 @@
/// arguments.
///
/// For instance `F<T>` for `typedef void F<T>(T t)`.
- TypedefType get thisType;
+ ResolutionTypedefType get thisType;
/// The type defined by this typedef with `dynamic` as its type arguments.
///
/// For instance `F<dynamic>` for `typedef void F<T>(T t)`.
- TypedefType get rawType;
+ ResolutionTypedefType get rawType;
/// The type, function type if well-defined, for which this typedef is an
/// alias.
///
/// For instance `(int)->void` for `typedef void F(int)`.
- DartType get alias;
+ ResolutionDartType get alias;
void checkCyclicReference(Resolution resolution);
}
@@ -1182,9 +1165,9 @@
}
abstract class FunctionSignature {
- FunctionType get type;
- DartType get returnType;
- List<DartType> get typeVariables;
+ ResolutionFunctionType get type;
+ ResolutionDartType get returnType;
+ List<ResolutionDartType> get typeVariables;
List<FormalElement> get requiredParameters;
List<FormalElement> get optionalParameters;
@@ -1225,7 +1208,7 @@
List<ParameterElement> get parameters;
/// The type of this function.
- FunctionType get type;
+ ResolutionFunctionType get type;
/// The synchronous/asynchronous marker on this function.
AsyncMarker get asyncMarker;
@@ -1370,7 +1353,8 @@
/// Compute the type of the effective target of this constructor for an
/// instantiation site with type [:newType:].
- InterfaceType computeEffectiveTargetType(InterfaceType newType);
+ ResolutionInterfaceType computeEffectiveTargetType(
+ ResolutionInterfaceType newType);
/// If this is a synthesized constructor [definingConstructor] points to
/// the generative constructor from which this constructor was created.
@@ -1426,14 +1410,14 @@
/// error and calling [computeType] covers that error.
/// This method will go away!
@deprecated
- DartType computeType(Resolution resolution);
+ ResolutionDartType computeType(Resolution resolution);
/**
* The type variables declared on this declaration. The type variables are not
* available until the type of the element has been computed through
* [computeType].
*/
- List<DartType> get typeVariables;
+ List<ResolutionDartType> get typeVariables;
}
/// [TypeDeclarationElement] defines the common interface for class/interface
@@ -1474,9 +1458,9 @@
* used to distinguish explicit and implicit uses of the [dynamic]
* type arguments. For instance should [:List:] be the [rawType] of the
* [:List:] class element whereas [:List<dynamic>:] should be its own
- * instantiation of [InterfaceType] with [:dynamic:] as type argument. Using
- * this distinction, we can print the raw type with type arguments only when
- * the input source has used explicit type arguments.
+ * instantiation of [ResolutionInterfaceType] with [:dynamic:] as type
+ * argument. Using this distinction, we can print the raw type with type
+ * arguments only when the input source has used explicit type arguments.
*/
GenericType get rawType;
@@ -1490,24 +1474,24 @@
/// The length of the longest inheritance path from [:Object:].
int get hierarchyDepth;
- InterfaceType get rawType;
- InterfaceType get thisType;
+ ResolutionInterfaceType get rawType;
+ ResolutionInterfaceType get thisType;
ClassElement get superclass;
/// The direct supertype of this class.
- DartType get supertype;
+ ResolutionDartType get supertype;
/// Ordered set of all supertypes of this class including the class itself.
OrderedTypeSet get allSupertypesAndSelf;
/// A list of all supertypes of this class excluding the class itself.
- Link<DartType> get allSupertypes;
+ Link<ResolutionDartType> get allSupertypes;
/// Returns the this type of this class as an instance of [cls].
- InterfaceType asInstanceOf(ClassElement cls);
+ ResolutionInterfaceType asInstanceOf(ClassElement cls);
/// A list of all direct superinterfaces of this class.
- Link<DartType> get interfaces;
+ Link<ResolutionDartType> get interfaces;
bool get hasConstructor;
Link<Element> get constructors;
@@ -1618,12 +1602,12 @@
/// Returns the type of the 'call' method in the interface of this class, or
/// `null` if the interface has no 'call' method.
- FunctionType get callType;
+ ResolutionFunctionType get callType;
}
abstract class MixinApplicationElement extends ClassElement {
ClassElement get mixin;
- InterfaceType get mixinType;
+ ResolutionInterfaceType get mixinType;
/// If this is an unnamed mixin application [subclass] is the subclass for
/// which this mixin application is created.
@@ -1680,7 +1664,7 @@
/// The [Element] for a type variable declaration on a generic class or typedef.
abstract class TypeVariableElement extends Element
- implements AstElement, TypedElement {
+ implements AstElement, TypedElement, TypeVariableEntity {
/// The name of this type variable, taking privacy into account.
Name get memberName;
@@ -1696,11 +1680,11 @@
int get index;
/// The [type] defined by the type variable.
- TypeVariableType get type;
+ ResolutionTypeVariableType get type;
/// The upper bound on the type variable. If not explicitly declared, this is
/// `Object`.
- DartType get bound;
+ ResolutionDartType get bound;
}
abstract class MetadataAnnotation implements Spannable {
@@ -1724,9 +1708,9 @@
/// error and calling [computeType] covers that error.
/// This method will go away!
@deprecated
- DartType computeType(Resolution resolution);
+ ResolutionDartType computeType(Resolution resolution);
- DartType get type;
+ ResolutionDartType get type;
}
/// An [Element] that can define a function type.
@@ -1877,13 +1861,13 @@
/// The type of the member when accessed. For getters and setters this is the
/// return type and argument type, respectively. For methods the type is the
/// [functionType] defined by the return type and parameters.
- DartType get type;
+ ResolutionDartType get type;
/// The function type of the member. For a getter `Foo get foo` this is
/// `() -> Foo`, for a setter `void set foo(Foo _)` this is `(Foo) -> void`.
/// For methods the function type is defined by the return type and
/// parameters.
- FunctionType get functionType;
+ ResolutionFunctionType get functionType;
/// Returns `true` if this member is a getter, possibly implictly defined by a
/// field declaration.
@@ -1925,7 +1909,7 @@
/// class B<S> extends A<S> {}
/// The declarer of `m` in `A` is `A<T>` whereas the declarer of `m` in `B` is
/// `A<S>`.
- InterfaceType get declarer;
+ ResolutionInterfaceType get declarer;
/// Returns `true` if this member is static.
bool get isStatic;
diff --git a/pkg/compiler/lib/src/elements/entities.dart b/pkg/compiler/lib/src/elements/entities.dart
index ce1fc56..c794268 100644
--- a/pkg/compiler/lib/src/elements/entities.dart
+++ b/pkg/compiler/lib/src/elements/entities.dart
@@ -12,8 +12,11 @@
/// and/or Dart-in-JS classes.
abstract class ClassEntity extends Entity {
bool get isClosure;
- void forEachInstanceField(f(ClassEntity cls, FieldEntity field),
- {bool includeSuperAndInjectedMembers: false});
+}
+
+abstract class TypeVariableEntity extends Entity {
+ Entity get typeDeclaration;
+ int get index;
}
/// Stripped down super interface for member like entities, that is,
@@ -22,6 +25,7 @@
/// Currently only [MemberElement] but later also kernel based Dart members
/// and/or Dart-in-JS properties.
abstract class MemberEntity extends Entity {
+ bool get isConstructor;
bool get isField;
bool get isFunction;
bool get isGetter;
diff --git a/pkg/compiler/lib/src/elements/modelx.dart b/pkg/compiler/lib/src/elements/modelx.dart
index c2d2e75..4d5c79d 100644
--- a/pkg/compiler/lib/src/elements/modelx.dart
+++ b/pkg/compiler/lib/src/elements/modelx.dart
@@ -11,7 +11,6 @@
import '../constants/constant_constructors.dart';
import '../constants/constructors.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
import '../diagnostics/messages.dart' show MessageTemplate;
import '../ordered_typeset.dart' show OrderedTypeSet;
import '../resolution/class_members.dart' show ClassMemberMixin;
@@ -27,6 +26,7 @@
import '../util/util.dart';
import 'common.dart';
import 'elements.dart';
+import 'resolution_types.dart';
import 'visitor.dart' show ElementVisitor;
/// Object that identifies a declaration site.
@@ -266,7 +266,7 @@
get effectiveTarget => this;
- computeEffectiveTargetType(InterfaceType newType) => unsupported();
+ computeEffectiveTargetType(ResolutionInterfaceType newType) => unsupported();
get definingConstructor => null;
@@ -290,7 +290,7 @@
}
@override
- List<DartType> get typeVariables => unsupported();
+ List<ResolutionDartType> get typeVariables => unsupported();
}
/// A constructor that was synthesized to recover from a compile-time error.
@@ -378,7 +378,8 @@
}
@override
- void setEffectiveTarget(ConstructorElement target, InterfaceType type,
+ void setEffectiveTarget(
+ ConstructorElement target, ResolutionInterfaceType type,
{bool isMalformed: false}) {
throw new UnsupportedError("setEffectiveTarget");
}
@@ -565,7 +566,7 @@
bool get isTopLevel => false;
- DynamicType get type => const DynamicType();
+ ResolutionDynamicType get type => const ResolutionDynamicType();
}
/// Element synthesized to diagnose an ambiguous import.
@@ -1274,7 +1275,8 @@
void forEachLocalMember(f(Element member)) => importScope.forEach(f);
- DartType computeType(Resolution resolution) => const DynamicType();
+ ResolutionDartType computeType(Resolution resolution) =>
+ const ResolutionDynamicType();
Token get position => firstPosition;
@@ -1299,16 +1301,16 @@
with
AstElementMixin,
AnalyzableElementX,
- TypeDeclarationElementX<TypedefType>
+ TypeDeclarationElementX<ResolutionTypedefType>
implements TypedefElement {
Typedef cachedNode;
/**
* The type annotation which defines this typedef.
*/
- DartType aliasCache;
+ ResolutionDartType aliasCache;
- DartType get alias {
+ ResolutionDartType get alias {
assert(invariant(this, hasBeenCheckedForCycles,
message: "$this has not been checked for cycles."));
return aliasCache;
@@ -1340,7 +1342,7 @@
*/
FunctionSignature functionSignature;
- TypedefType computeType(Resolution resolution) {
+ ResolutionTypedefType computeType(Resolution resolution) {
if (thisTypeCache != null) return thisTypeCache;
Typedef node = parseNode(resolution.parsingContext);
setThisAndRawTypes(createTypeVariables(node.typeParameters));
@@ -1354,8 +1356,8 @@
}
}
- TypedefType createType(List<DartType> typeArguments) {
- return new TypedefType(this, typeArguments);
+ ResolutionTypedefType createType(List<ResolutionDartType> typeArguments) {
+ return new ResolutionTypedefType(this, typeArguments);
}
Scope buildScope() {
@@ -1383,7 +1385,7 @@
// forwards its [computeType] and [parseNode] methods to this class.
class VariableList implements DeclarationSite {
VariableDefinitions definitions;
- DartType type;
+ ResolutionDartType type;
final Modifiers modifiers;
List<MetadataAnnotation> metadataInternal;
@@ -1419,7 +1421,8 @@
return definitions;
}
- DartType computeType(Element element, Resolution resolution) => type;
+ ResolutionDartType computeType(Element element, Resolution resolution) =>
+ type;
}
abstract class ConstantVariableMixin implements VariableElement {
@@ -1559,7 +1562,7 @@
definitionsCache = definitions;
}
- DartType computeType(Resolution resolution) {
+ ResolutionDartType computeType(Resolution resolution) {
if (variables.type != null) return variables.type;
// Call [parseNode] to ensure that [definitionsCache] and [initializerCache]
// are set as a consequence of calling [computeType].
@@ -1567,7 +1570,7 @@
return variables.computeType(this, resolution);
}
- DartType get type {
+ ResolutionDartType get type {
assert(invariant(this, variables.type != null,
message: "Type has not been computed for $this."));
return variables.type;
@@ -1638,7 +1641,7 @@
: variables = new VariableList(Modifiers.EMPTY)
..definitions = new VariableDefinitions(
null, Modifiers.EMPTY, new NodeList.singleton(name))
- ..type = const DynamicType(),
+ ..type = const ResolutionDynamicType(),
super(name.source, ElementKind.FIELD, enclosingElement);
VariableDefinitions get definitionsCache => variables.definitions;
@@ -1657,7 +1660,7 @@
throw new UnsupportedError("resolvedAst");
}
- DynamicType get type => const DynamicType();
+ ResolutionDynamicType get type => const ResolutionDynamicType();
Token get token => node.getBeginToken();
@@ -1714,7 +1717,7 @@
throw new UnsupportedError("copyWithEnclosing");
}
- DartType computeType(Resolution resolution) => type;
+ ResolutionDartType computeType(Resolution resolution) => type;
}
/// [Element] for a parameter-like element.
@@ -1723,10 +1726,10 @@
implements FormalElement {
final VariableDefinitions definitions;
final Identifier identifier;
- DartType typeCache;
+ ResolutionDartType typeCache;
@override
- List<DartType> get typeVariables => functionSignature.typeVariables;
+ List<ResolutionDartType> get typeVariables => functionSignature.typeVariables;
/**
* Function signature for a variable with a function type. The signature is
@@ -1748,13 +1751,13 @@
Node parseNode(ParsingContext parsing) => definitions;
- DartType computeType(Resolution resolution) {
+ ResolutionDartType computeType(Resolution resolution) {
assert(invariant(this, type != null,
message: "Parameter type has not been set for $this."));
return type;
}
- DartType get type {
+ ResolutionDartType get type {
assert(invariant(this, typeCache != null,
message: "Parameter type has not been set for $this."));
return typeCache;
@@ -1777,7 +1780,7 @@
VariableDefinitions get node => definitions;
- FunctionType get functionType => type;
+ ResolutionFunctionType get functionType => type;
accept(ElementVisitor visitor, arg) {
return visitor.visitFormalElement(this, arg);
@@ -1896,7 +1899,7 @@
bool get isMalformed => true;
- DynamicType get type => const DynamicType();
+ ResolutionDynamicType get type => const ResolutionDynamicType();
}
class AbstractFieldElementX extends ElementX
@@ -1908,7 +1911,7 @@
AbstractFieldElementX(String name, Element enclosing)
: super(name, ElementKind.ABSTRACT_FIELD, enclosing);
- DartType computeType(Compiler compiler) {
+ ResolutionDartType computeType(Compiler compiler) {
throw "internal error: AbstractFieldElement has no type";
}
@@ -1954,18 +1957,18 @@
// TODO(karlklose): all these lists should have element type [FormalElement].
class FunctionSignatureX extends FunctionSignatureCommon
implements FunctionSignature {
- final List<DartType> typeVariables;
+ final List<ResolutionDartType> typeVariables;
final List<Element> requiredParameters;
final List<Element> optionalParameters;
final int requiredParameterCount;
final int optionalParameterCount;
final bool optionalParametersAreNamed;
final List<Element> orderedOptionalParameters;
- final FunctionType type;
+ final ResolutionFunctionType type;
final bool hasOptionalParameters;
FunctionSignatureX(
- {this.typeVariables: const <DartType>[],
+ {this.typeVariables: const <ResolutionDartType>[],
this.requiredParameters: const <Element>[],
this.requiredParameterCount: 0,
List<Element> optionalParameters: const <Element>[],
@@ -1980,7 +1983,7 @@
abstract class BaseFunctionElementX extends ElementX
with PatchMixin<FunctionElement>, AstElementMixin
implements FunctionElement {
- DartType typeCache;
+ ResolutionDartType typeCache;
final Modifiers modifiers;
List<FunctionElement> nestedClosures = new List<FunctionElement>();
@@ -2031,7 +2034,7 @@
return list;
}
- FunctionType computeType(Resolution resolution) {
+ ResolutionFunctionType computeType(Resolution resolution) {
if (typeCache != null) return typeCache;
_computeSignature(resolution);
assert(invariant(this, typeCache != null,
@@ -2039,7 +2042,7 @@
return typeCache;
}
- FunctionType get type {
+ ResolutionFunctionType get type {
assert(invariant(this, typeCache != null,
message: "Type has not been computed for $this."));
return typeCache;
@@ -2066,7 +2069,7 @@
AstElement get definingElement => implementation;
@override
- List<DartType> get typeVariables => functionSignature.typeVariables;
+ List<ResolutionDartType> get typeVariables => functionSignature.typeVariables;
}
abstract class FunctionElementX extends BaseFunctionElementX
@@ -2219,7 +2222,7 @@
/// Returns the empty list of type variables by default.
@override
- List<DartType> get typeVariables => functionSignature.typeVariables;
+ List<ResolutionDartType> get typeVariables => functionSignature.typeVariables;
}
abstract class ConstructorElementX extends FunctionElementX
@@ -2251,7 +2254,7 @@
/// These fields are set by the post process queue when checking for cycles.
ConstructorElement effectiveTargetInternal;
- DartType _effectiveTargetType;
+ ResolutionDartType _effectiveTargetType;
bool _isEffectiveTargetMalformed;
bool get hasEffectiveTarget {
@@ -2288,7 +2291,7 @@
return _redirectionDeferredPrefix;
}
- void setEffectiveTarget(ConstructorElement target, DartType type,
+ void setEffectiveTarget(ConstructorElement target, ResolutionDartType type,
{bool isMalformed: false}) {
if (isPatched) {
patch.setEffectiveTarget(target, type, isMalformed: isMalformed);
@@ -2320,7 +2323,7 @@
return this;
}
- DartType get effectiveTargetType {
+ ResolutionDartType get effectiveTargetType {
if (isPatched) {
return patch.effectiveTargetType;
}
@@ -2329,7 +2332,8 @@
return _effectiveTargetType;
}
- DartType computeEffectiveTargetType(InterfaceType newType) {
+ ResolutionDartType computeEffectiveTargetType(
+ ResolutionInterfaceType newType) {
if (isPatched) {
return patch.computeEffectiveTargetType(newType);
}
@@ -2363,7 +2367,8 @@
DeferredLoaderGetterElementX(PrefixElement prefix)
: this.prefix = prefix,
super(Identifiers.loadLibrary, Modifiers.EMPTY, prefix, false) {
- functionSignature = new FunctionSignatureX(type: new FunctionType(this));
+ functionSignature =
+ new FunctionSignatureX(type: new ResolutionFunctionType(this));
}
bool get isClassMember => false;
@@ -2428,7 +2433,7 @@
bool get isInstanceMember => true;
- FunctionType computeType(Resolution resolution) {
+ ResolutionFunctionType computeType(Resolution resolution) {
DiagnosticReporter reporter = resolution.reporter;
reporter.internalError(this, '$this.computeType.');
return null;
@@ -2473,7 +2478,7 @@
: super('', ElementKind.GENERATIVE_CONSTRUCTOR, Modifiers.EMPTY,
enclosing) {
functionSignature = new FunctionSignatureX(
- type: new FunctionType.synthesized(enclosingClass.thisType));
+ type: new ResolutionFunctionType.synthesized(enclosingClass.thisType));
_resolvedAst =
new SynthesizedResolvedAst(this, ResolvedAstKind.DEFAULT_CONSTRUCTOR);
}
@@ -2496,7 +2501,7 @@
ResolvedAst get resolvedAst => _resolvedAst;
- DartType get type {
+ ResolutionDartType get type {
if (isDefaultConstructor) {
return super.type;
} else {
@@ -2510,7 +2515,8 @@
if (hasFunctionSignature) return;
if (definingConstructor.isMalformed) {
functionSignature = new FunctionSignatureX(
- type: new FunctionType.synthesized(enclosingClass.thisType));
+ type:
+ new ResolutionFunctionType.synthesized(enclosingClass.thisType));
}
// TODO(johnniwinther): Ensure that the function signature (and with it the
// function type) substitutes type variables correctly.
@@ -2550,9 +2556,9 @@
* used to distinguish explicit and implicit uses of the [dynamic]
* type arguments. For instance should [:List:] be the [rawType] of the
* [:List:] class element whereas [:List<dynamic>:] should be its own
- * instantiation of [InterfaceType] with [:dynamic:] as type argument. Using
- * this distinction, we can print the raw type with type arguments only when
- * the input source has used explicit type arguments.
+ * instantiation of [ResolutionInterfaceType] with [:dynamic:] as type
+ * argument. Using this distinction, we can print the raw type with type
+ * arguments only when the input source has used explicit type arguments.
*
* This type is computed together with [thisType] in [computeType].
*/
@@ -2570,9 +2576,9 @@
return rawTypeCache;
}
- T createType(List<DartType> typeArguments);
+ T createType(List<ResolutionDartType> typeArguments);
- void setThisAndRawTypes(List<DartType> typeParameters) {
+ void setThisAndRawTypes(List<ResolutionDartType> typeParameters) {
assert(invariant(this, thisTypeCache == null,
message: "This type has already been set on $this."));
assert(invariant(this, rawTypeCache == null,
@@ -2581,32 +2587,33 @@
if (typeParameters.isEmpty) {
rawTypeCache = thisTypeCache;
} else {
- List<DartType> dynamicParameters =
- new List.filled(typeParameters.length, const DynamicType());
+ List<ResolutionDartType> dynamicParameters =
+ new List.filled(typeParameters.length, const ResolutionDynamicType());
rawTypeCache = createType(dynamicParameters);
}
}
- List<DartType> get typeVariables => thisType.typeArguments;
+ List<ResolutionDartType> get typeVariables => thisType.typeArguments;
/**
* Creates the type variables, their type and corresponding element, for the
* type variables declared in [parameter] on [element]. The bounds of the type
* variables are not set until [element] has been resolved.
*/
- List<DartType> createTypeVariables(NodeList parameters) {
- if (parameters == null) return const <DartType>[];
+ List<ResolutionDartType> createTypeVariables(NodeList parameters) {
+ if (parameters == null) return const <ResolutionDartType>[];
// Create types and elements for type variable.
Link<Node> nodes = parameters.nodes;
- List<DartType> arguments =
+ List<ResolutionDartType> arguments =
new List.generate(nodes.slowLength(), (int index) {
TypeVariable node = nodes.head;
String variableName = node.name.source;
nodes = nodes.tail;
TypeVariableElementX variableElement =
new TypeVariableElementX(variableName, this, index, node);
- TypeVariableType variableType = new TypeVariableType(variableElement);
+ ResolutionTypeVariableType variableType =
+ new ResolutionTypeVariableType(variableElement);
variableElement.typeCache = variableType;
return variableType;
}, growable: false);
@@ -2623,14 +2630,14 @@
AstElementMixin,
AnalyzableElementX,
ClassElementCommon,
- TypeDeclarationElementX<InterfaceType>,
+ TypeDeclarationElementX<ResolutionInterfaceType>,
PatchMixin<ClassElement>,
ClassMemberMixin
implements ClassElement {
final int id;
- DartType supertype;
- Link<DartType> interfaces;
+ ResolutionDartType supertype;
+ Link<ResolutionDartType> interfaces;
int supertypeLoadState;
int resolutionState;
bool isProxy = false;
@@ -2650,7 +2657,7 @@
@override
bool get isEnumClass => false;
- InterfaceType computeType(Resolution resolution) {
+ ResolutionInterfaceType computeType(Resolution resolution) {
if (isPatch) {
origin.computeType(resolution);
thisTypeCache = origin.thisType;
@@ -2663,7 +2670,7 @@
}
void computeThisAndRawType(
- Resolution resolution, List<DartType> typeVariables) {
+ Resolution resolution, List<ResolutionDartType> typeVariables) {
if (thisTypeCache == null) {
if (origin == null) {
setThisAndRawTypes(typeVariables);
@@ -2675,11 +2682,11 @@
}
@override
- InterfaceType createType(List<DartType> typeArguments) {
- return new InterfaceType(this, typeArguments);
+ ResolutionInterfaceType createType(List<ResolutionDartType> typeArguments) {
+ return new ResolutionInterfaceType(this, typeArguments);
}
- List<DartType> computeTypeParameters(ParsingContext parsing);
+ List<ResolutionDartType> computeTypeParameters(ParsingContext parsing);
bool get isObject {
assert(invariant(this, isResolved,
@@ -2787,7 +2794,7 @@
addMember(constructor, reporter);
}
- List<DartType> computeTypeParameters(ParsingContext parsing) {
+ List<ResolutionDartType> computeTypeParameters(ParsingContext parsing) {
ClassNode node = parseNode(parsing);
return createTypeVariables(node.typeParameters);
}
@@ -2855,8 +2862,8 @@
return visitor.visitEnumClassElement(this, arg);
}
- List<DartType> computeTypeParameters(ParsingContext parsing) =>
- const <DartType>[];
+ List<ResolutionDartType> computeTypeParameters(ParsingContext parsing) =>
+ const <ResolutionDartType>[];
List<FieldElement> get enumValues {
assert(invariant(this, _enumValues != null,
@@ -3092,7 +3099,7 @@
implements MixinApplicationElement {
Link<ConstructorElement> constructors = new Link<ConstructorElement>();
- InterfaceType mixinType;
+ ResolutionInterfaceType mixinType;
MixinApplicationElementX(String name, Element enclosing, int id)
: super(name, enclosing, id, STATE_NOT_STARTED);
@@ -3130,7 +3137,7 @@
addConstructor(constructor);
}
- List<DartType> computeTypeParameters(ParsingContext parsing) {
+ List<ResolutionDartType> computeTypeParameters(ParsingContext parsing) {
NamedMixinApplication named = node.asNamedMixinApplication();
if (named == null) {
throw new SpannableAssertionFailure(
@@ -3237,8 +3244,8 @@
implements TypeVariableElement {
final int index;
final Node node;
- TypeVariableType typeCache;
- DartType boundCache;
+ ResolutionTypeVariableType typeCache;
+ ResolutionDartType boundCache;
TypeVariableElementX(
String name, GenericElement enclosing, this.index, this.node)
@@ -3246,15 +3253,15 @@
GenericElement get typeDeclaration => enclosingElement;
- TypeVariableType computeType(Resolution resolution) => type;
+ ResolutionTypeVariableType computeType(Resolution resolution) => type;
- TypeVariableType get type {
+ ResolutionTypeVariableType get type {
assert(invariant(this, typeCache != null,
message: "Type has not been set on $this."));
return typeCache;
}
- DartType get bound {
+ ResolutionDartType get bound {
assert(invariant(this, boundCache != null,
message: "Bound has not been set on $this."));
return boundCache;
diff --git a/pkg/compiler/lib/src/dart_types.dart b/pkg/compiler/lib/src/elements/resolution_types.dart
similarity index 68%
rename from pkg/compiler/lib/src/dart_types.dart
rename to pkg/compiler/lib/src/elements/resolution_types.dart
index b151ed9..42012e2 100644
--- a/pkg/compiler/lib/src/dart_types.dart
+++ b/pkg/compiler/lib/src/elements/resolution_types.dart
@@ -2,19 +2,23 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library dart_types;
+/// Implementation of the Dart types hierarchy in 'types.dart' specifically
+/// tailored to the resolution phase of the compiler.
+
+library resolution_types;
import 'dart:math' show min;
-import 'common/resolution.dart' show Resolution;
-import 'common.dart';
-import 'core_types.dart';
-import 'elements/elements.dart';
-import 'elements/modelx.dart' show TypeDeclarationElementX;
-import 'ordered_typeset.dart' show OrderedTypeSet;
-import 'util/util.dart' show equalElements;
+import '../common.dart';
+import '../common/resolution.dart' show Resolution;
+import '../core_types.dart';
+import '../ordered_typeset.dart' show OrderedTypeSet;
+import '../util/util.dart' show equalElements;
+import 'elements.dart';
+import 'modelx.dart' show TypeDeclarationElementX;
+import 'types.dart';
-enum TypeKind {
+enum ResolutionTypeKind {
FUNCTION,
INTERFACE,
TYPEDEF,
@@ -24,12 +28,12 @@
VOID,
}
-abstract class DartType {
+abstract class ResolutionDartType implements DartType {
String get name;
- TypeKind get kind;
+ ResolutionTypeKind get kind;
- const DartType();
+ const ResolutionDartType();
/**
* Returns the [Element] which declared this type.
@@ -49,15 +53,16 @@
*
* (lambda x.e0)e1 -> [e1/x]e0.
*
- * See [TypeVariableType] for a motivation for this method.
+ * See [ResolutionTypeVariableType] for a motivation for this method.
*
* Invariant: There must be the same number of [arguments] and [parameters].
*/
- DartType subst(List<DartType> arguments, List<DartType> parameters);
+ ResolutionDartType subst(
+ List<ResolutionDartType> arguments, List<ResolutionDartType> parameters);
/// Performs the substitution of the type arguments of [type] for their
/// corresponding type variables in this type.
- DartType substByContext(GenericType type) {
+ ResolutionDartType substByContext(GenericType type) {
return subst(type.typeArguments, type.element.typeVariables);
}
@@ -80,20 +85,20 @@
/// For example, the unaliased type of `typedef A Func<A,B>(B b)` is the
/// function type `(B) -> A` and the unaliased type of `Func<int,String>`
/// is the function type `(String) -> int`.
- DartType get unaliased => this;
+ ResolutionDartType get unaliased => this;
/**
* If this type is malformed or a generic type created with the wrong number
* of type arguments then [userProvidedBadType] holds the bad type provided
* by the user.
*/
- DartType get userProvidedBadType => null;
+ ResolutionDartType get userProvidedBadType => null;
/// Is [: true :] if this type has no explict type arguments.
bool get isRaw => true;
/// Returns the raw version of this type.
- DartType asRaw() => this;
+ ResolutionDartType asRaw() => this;
/// Is [: true :] if this type has no non-dynamic type arguments.
bool get treatAsRaw => isRaw;
@@ -102,25 +107,25 @@
bool get treatAsDynamic => false;
/// Is [: true :] if this type is the dynamic type.
- bool get isDynamic => kind == TypeKind.DYNAMIC;
+ bool get isDynamic => kind == ResolutionTypeKind.DYNAMIC;
/// Is [: true :] if this type is the void type.
- bool get isVoid => kind == TypeKind.VOID;
+ bool get isVoid => kind == ResolutionTypeKind.VOID;
/// Is [: true :] if this is the type of `Object` from dart:core.
bool get isObject => false;
/// Is [: true :] if this type is an interface type.
- bool get isInterfaceType => kind == TypeKind.INTERFACE;
+ bool get isInterfaceType => kind == ResolutionTypeKind.INTERFACE;
/// Is [: true :] if this type is a typedef.
- bool get isTypedef => kind == TypeKind.TYPEDEF;
+ bool get isTypedef => kind == ResolutionTypeKind.TYPEDEF;
/// Is [: true :] if this type is a function type.
- bool get isFunctionType => kind == TypeKind.FUNCTION;
+ bool get isFunctionType => kind == ResolutionTypeKind.FUNCTION;
/// Is [: true :] if this type is a type variable.
- bool get isTypeVariable => kind == TypeKind.TYPE_VARIABLE;
+ bool get isTypeVariable => kind == ResolutionTypeKind.TYPE_VARIABLE;
/// Is [: true :] if this type is a malformed type.
bool get isMalformed => false;
@@ -129,14 +134,16 @@
bool get isEnumType => false;
/// Returns an occurrence of a type variable within this type, if any.
- TypeVariableType get typeVariableOccurrence => null;
+ ResolutionTypeVariableType get typeVariableOccurrence => null;
- /// Applies [f] to each occurence of a [TypeVariableType] within this type.
- void forEachTypeVariable(f(TypeVariableType variable)) {}
+ /// Applies [f] to each occurence of a [ResolutionTypeVariableType] within
+ /// this type.
+ void forEachTypeVariable(f(ResolutionTypeVariableType variable)) {}
- TypeVariableType _findTypeVariableOccurrence(List<DartType> types) {
- for (DartType type in types) {
- TypeVariableType typeVariable = type.typeVariableOccurrence;
+ ResolutionTypeVariableType _findTypeVariableOccurrence(
+ List<ResolutionDartType> types) {
+ for (ResolutionDartType type in types) {
+ ResolutionTypeVariableType typeVariable = type.typeVariableOccurrence;
if (typeVariable != null) {
return typeVariable;
}
@@ -158,16 +165,17 @@
void visitChildren(DartTypeVisitor visitor, var argument) {}
static void visitList(
- List<DartType> types, DartTypeVisitor visitor, var argument) {
- for (DartType type in types) {
+ List<ResolutionDartType> types, DartTypeVisitor visitor, var argument) {
+ for (ResolutionDartType type in types) {
type.accept(visitor, argument);
}
}
- /// Returns a [DartType] which corresponds to [this] except that each
- /// contained [MethodTypeVariableType] is replaced by a [DynamicType].
+ /// Returns a [ResolutionDartType] which corresponds to [this] except that
+ /// each contained [MethodTypeVariableType] is replaced by a
+ /// [ResolutionDynamicType].
/// GENERIC_METHODS: Temporary, only used with '--generic-method-syntax'.
- DartType get dynamifyMethodTypeVariableType => this;
+ ResolutionDartType get dynamifyMethodTypeVariableType => this;
/// Returns true iff [this] is or contains a [MethodTypeVariableType].
/// GENERIC_METHODS: Temporary, only used with '--generic-method-syntax'
@@ -196,24 +204,26 @@
* [: String :] because we must substitute [: String :] for the
* the type variable [: T :].
*/
-class TypeVariableType extends DartType {
+class ResolutionTypeVariableType extends ResolutionDartType
+ implements TypeVariableType {
final TypeVariableElement element;
- TypeVariableType(this.element);
+ ResolutionTypeVariableType(this.element);
- TypeKind get kind => TypeKind.TYPE_VARIABLE;
+ ResolutionTypeKind get kind => ResolutionTypeKind.TYPE_VARIABLE;
String get name => element.name;
- DartType subst(List<DartType> arguments, List<DartType> parameters) {
+ ResolutionDartType subst(
+ List<ResolutionDartType> arguments, List<ResolutionDartType> parameters) {
assert(arguments.length == parameters.length);
if (parameters.isEmpty) {
// Return fast on empty substitutions.
return this;
}
for (int index = 0; index < arguments.length; index++) {
- TypeVariableType parameter = parameters[index];
- DartType argument = arguments[index];
+ ResolutionTypeVariableType parameter = parameters[index];
+ ResolutionDartType argument = arguments[index];
if (parameter == this) {
return argument;
}
@@ -222,9 +232,9 @@
return this;
}
- TypeVariableType get typeVariableOccurrence => this;
+ ResolutionTypeVariableType get typeVariableOccurrence => this;
- void forEachTypeVariable(f(TypeVariableType variable)) {
+ void forEachTypeVariable(f(ResolutionTypeVariableType variable)) {
f(this);
}
@@ -235,7 +245,7 @@
int get hashCode => 17 * element.hashCode;
bool operator ==(other) {
- if (other is! TypeVariableType) return false;
+ if (other is! ResolutionTypeVariableType) return false;
return identical(other.element, element);
}
@@ -245,7 +255,7 @@
/// Provides a thin model of method type variables: They are treated as if
/// their value were `dynamic` when used in a type annotation, and as a
/// malformed type when used in an `as` or `is` expression.
-class MethodTypeVariableType extends TypeVariableType {
+class MethodTypeVariableType extends ResolutionTypeVariableType {
MethodTypeVariableType(TypeVariableElement element) : super(element);
@override
@@ -255,22 +265,24 @@
bool get isMalformed => true;
@override
- DartType get dynamifyMethodTypeVariableType => const DynamicType();
+ ResolutionDartType get dynamifyMethodTypeVariableType =>
+ const ResolutionDynamicType();
@override
get containsMethodTypeVariableType => true;
}
-class VoidType extends DartType {
- const VoidType();
+class ResolutionVoidType extends ResolutionDartType implements VoidType {
+ const ResolutionVoidType();
- TypeKind get kind => TypeKind.VOID;
+ ResolutionTypeKind get kind => ResolutionTypeKind.VOID;
String get name => 'void';
Element get element => null;
- DartType subst(List<DartType> arguments, List<DartType> parameters) {
+ ResolutionDartType subst(
+ List<ResolutionDartType> arguments, List<ResolutionDartType> parameters) {
// Void cannot be substituted.
return this;
}
@@ -284,7 +296,7 @@
int get hashCode => 6007;
}
-class MalformedType extends DartType {
+class MalformedType extends ResolutionDartType {
final ErroneousElement element;
/**
@@ -294,7 +306,7 @@
* [declaredType] is [: Map<String> :] whereas for an unresolved type
* [userProvidedBadType] is [: null :].
*/
- final DartType userProvidedBadType;
+ final ResolutionDartType userProvidedBadType;
/**
* Type arguments for the malformed typed, if these cannot fit in the
@@ -305,7 +317,7 @@
* [: dynamic :] and [: T :], respectively, or for [: X<int> :] where [: X :]
* is not resolved or does not imply a type.
*/
- final List<DartType> typeArguments;
+ final List<ResolutionDartType> typeArguments;
final int hashCode = _nextHash = (_nextHash + 1).toUnsigned(30);
static int _nextHash = 43765;
@@ -313,11 +325,12 @@
MalformedType(this.element, this.userProvidedBadType,
[this.typeArguments = null]);
- TypeKind get kind => TypeKind.MALFORMED_TYPE;
+ ResolutionTypeKind get kind => ResolutionTypeKind.MALFORMED_TYPE;
String get name => element.name;
- DartType subst(List<DartType> arguments, List<DartType> parameters) {
+ ResolutionDartType subst(
+ List<ResolutionDartType> arguments, List<ResolutionDartType> parameters) {
// Malformed types are not substitutable.
return this;
}
@@ -352,11 +365,12 @@
}
}
-abstract class GenericType extends DartType {
+abstract class GenericType extends ResolutionDartType {
final TypeDeclarationElement element;
- final List<DartType> typeArguments;
+ final List<ResolutionDartType> typeArguments;
- GenericType(TypeDeclarationElement element, List<DartType> typeArguments,
+ GenericType(
+ TypeDeclarationElement element, List<ResolutionDartType> typeArguments,
{bool checkTypeArgumentCount: true})
: this.element = element,
this.typeArguments = typeArguments,
@@ -377,9 +391,10 @@
}
/// Creates a new instance of this type using the provided type arguments.
- GenericType createInstantiation(List<DartType> newTypeArguments);
+ GenericType createInstantiation(List<ResolutionDartType> newTypeArguments);
- DartType subst(List<DartType> arguments, List<DartType> parameters) {
+ ResolutionDartType subst(
+ List<ResolutionDartType> arguments, List<ResolutionDartType> parameters) {
if (typeArguments.isEmpty) {
// Return fast on non-generic types.
return this;
@@ -389,7 +404,7 @@
// Return fast on empty substitutions.
return this;
}
- List<DartType> newTypeArguments =
+ List<ResolutionDartType> newTypeArguments =
Types.substTypes(typeArguments, arguments, parameters);
if (!identical(typeArguments, newTypeArguments)) {
// Create a new type only if necessary.
@@ -398,18 +413,18 @@
return this;
}
- TypeVariableType get typeVariableOccurrence {
+ ResolutionTypeVariableType get typeVariableOccurrence {
return _findTypeVariableOccurrence(typeArguments);
}
- void forEachTypeVariable(f(TypeVariableType variable)) {
- for (DartType type in typeArguments) {
+ void forEachTypeVariable(f(ResolutionTypeVariableType variable)) {
+ for (ResolutionDartType type in typeArguments) {
type.forEachTypeVariable(f);
}
}
void visitChildren(DartTypeVisitor visitor, var argument) {
- DartType.visitList(typeArguments, visitor, argument);
+ ResolutionDartType.visitList(typeArguments, visitor, argument);
}
String toString() {
@@ -427,17 +442,17 @@
final bool containsMethodTypeVariableType;
@override
- DartType get dynamifyMethodTypeVariableType {
+ ResolutionDartType get dynamifyMethodTypeVariableType {
if (!containsMethodTypeVariableType) return this;
- List<DartType> newTypeArguments = typeArguments
- .map((DartType type) => type.dynamifyMethodTypeVariableType)
+ List<ResolutionDartType> newTypeArguments = typeArguments
+ .map((ResolutionDartType type) => type.dynamifyMethodTypeVariableType)
.toList();
return createInstantiation(newTypeArguments);
}
int get hashCode {
int hash = element.hashCode;
- for (DartType argument in typeArguments) {
+ for (ResolutionDartType argument in typeArguments) {
int argumentHash = argument != null ? argument.hashCode : 0;
hash = 17 * hash + 3 * argumentHash;
}
@@ -460,29 +475,29 @@
bool get treatAsRaw {
if (isRaw) return true;
- for (DartType type in typeArguments) {
+ for (ResolutionDartType type in typeArguments) {
if (!type.treatAsDynamic) return false;
}
return true;
}
}
-class InterfaceType extends GenericType {
+class ResolutionInterfaceType extends GenericType implements InterfaceType {
int _hashCode;
- InterfaceType(ClassElement element,
- [List<DartType> typeArguments = const <DartType>[]])
+ ResolutionInterfaceType(ClassElement element,
+ [List<ResolutionDartType> typeArguments = const <ResolutionDartType>[]])
: super(element, typeArguments) {
assert(invariant(element, element.isDeclaration));
}
- InterfaceType.forUserProvidedBadType(ClassElement element,
- [List<DartType> typeArguments = const <DartType>[]])
+ ResolutionInterfaceType.forUserProvidedBadType(ClassElement element,
+ [List<ResolutionDartType> typeArguments = const <ResolutionDartType>[]])
: super(element, typeArguments, checkTypeArgumentCount: false);
ClassElement get element => super.element;
- TypeKind get kind => TypeKind.INTERFACE;
+ ResolutionTypeKind get kind => ResolutionTypeKind.INTERFACE;
String get name => element.name;
@@ -490,22 +505,23 @@
bool get isEnumType => element.isEnumClass;
- InterfaceType createInstantiation(List<DartType> newTypeArguments) {
- return new InterfaceType(element, newTypeArguments);
+ ResolutionInterfaceType createInstantiation(
+ List<ResolutionDartType> newTypeArguments) {
+ return new ResolutionInterfaceType(element, newTypeArguments);
}
/**
* Returns the type as an instance of class [other], if possible, null
* otherwise.
*/
- InterfaceType asInstanceOf(ClassElement other) {
+ ResolutionInterfaceType asInstanceOf(ClassElement other) {
other = other.declaration;
if (element == other) return this;
- InterfaceType supertype = element.asInstanceOf(other);
+ ResolutionInterfaceType supertype = element.asInstanceOf(other);
if (supertype != null) {
- List<DartType> arguments = Types.substTypes(
+ List<ResolutionDartType> arguments = Types.substTypes(
supertype.typeArguments, typeArguments, element.typeVariables);
- return new InterfaceType(supertype.element, arguments);
+ return new ResolutionInterfaceType(supertype.element, arguments);
}
return null;
}
@@ -528,7 +544,7 @@
int get hashCode => _hashCode ??= super.hashCode;
- InterfaceType asRaw() => super.asRaw();
+ ResolutionInterfaceType asRaw() => super.asRaw();
accept(DartTypeVisitor visitor, var argument) {
return visitor.visitInterfaceType(this, argument);
@@ -536,22 +552,21 @@
/// Returns the type of the 'call' method in this interface type, or
/// `null` if the interface type has no 'call' method.
- FunctionType get callType {
- FunctionType type = element.callType;
+ ResolutionFunctionType get callType {
+ ResolutionFunctionType type = element.callType;
return type != null && isGeneric ? type.substByContext(this) : type;
}
}
-/**
- * Special subclass of [InterfaceType] used for generic interface types created
- * with the wrong number of type arguments.
- *
- * The type uses [:dynamic:] for all it s type arguments.
- */
-class BadInterfaceType extends InterfaceType {
- final InterfaceType userProvidedBadType;
+/// Special subclass of [ResolutionInterfaceType] used for generic interface
+/// types created with the wrong number of type arguments.
+///
+/// The type uses `dynamic` for all it s type arguments.
+class BadInterfaceType extends ResolutionInterfaceType {
+ final ResolutionInterfaceType userProvidedBadType;
- BadInterfaceType(ClassElement element, InterfaceType this.userProvidedBadType)
+ BadInterfaceType(
+ ClassElement element, ResolutionInterfaceType this.userProvidedBadType)
: super(element, element.rawType.typeArguments);
String toString() {
@@ -560,15 +575,16 @@
}
/**
- * Special subclass of [TypedefType] used for generic typedef types created
- * with the wrong number of type arguments.
+ * Special subclass of [ResolutionTypedefType] used for generic typedef types
+ * created with the wrong number of type arguments.
*
* The type uses [:dynamic:] for all it s type arguments.
*/
-class BadTypedefType extends TypedefType {
- final TypedefType userProvidedBadType;
+class BadTypedefType extends ResolutionTypedefType {
+ final ResolutionTypedefType userProvidedBadType;
- BadTypedefType(TypedefElement element, TypedefType this.userProvidedBadType)
+ BadTypedefType(
+ TypedefElement element, ResolutionTypedefType this.userProvidedBadType)
: super(element, element.rawType.typeArguments);
String toString() {
@@ -576,11 +592,12 @@
}
}
-class FunctionType extends DartType {
+class ResolutionFunctionType extends ResolutionDartType
+ implements FunctionType {
final FunctionTypedElement element;
- final DartType returnType;
- final List<DartType> parameterTypes;
- final List<DartType> optionalParameterTypes;
+ final ResolutionDartType returnType;
+ final List<ResolutionDartType> parameterTypes;
+ final List<ResolutionDartType> optionalParameterTypes;
/**
* The names of the named parameters ordered lexicographically.
@@ -591,36 +608,47 @@
* The types of the named parameters in the order corresponding to the
* [namedParameters].
*/
- final List<DartType> namedParameterTypes;
+ final List<ResolutionDartType> namedParameterTypes;
- factory FunctionType(FunctionTypedElement element,
- [DartType returnType = const DynamicType(),
- List<DartType> parameterTypes = const <DartType>[],
- List<DartType> optionalParameterTypes = const <DartType>[],
+ factory ResolutionFunctionType(FunctionTypedElement element,
+ [ResolutionDartType returnType = const ResolutionDynamicType(),
+ List<ResolutionDartType> parameterTypes = const <ResolutionDartType>[],
+ List<ResolutionDartType> optionalParameterTypes =
+ const <ResolutionDartType>[],
List<String> namedParameters = const <String>[],
- List<DartType> namedParameterTypes = const <DartType>[]]) {
+ List<ResolutionDartType> namedParameterTypes =
+ const <ResolutionDartType>[]]) {
assert(invariant(CURRENT_ELEMENT_SPANNABLE, element != null));
assert(invariant(element, element.isDeclaration));
- return new FunctionType.internal(element, returnType, parameterTypes,
+ return new ResolutionFunctionType.internal(
+ element,
+ returnType,
+ parameterTypes,
+ optionalParameterTypes,
+ namedParameters,
+ namedParameterTypes);
+ }
+
+ factory ResolutionFunctionType.synthesized(
+ [ResolutionDartType returnType = const ResolutionDynamicType(),
+ List<ResolutionDartType> parameterTypes = const <ResolutionDartType>[],
+ List<ResolutionDartType> optionalParameterTypes =
+ const <ResolutionDartType>[],
+ List<String> namedParameters = const <String>[],
+ List<ResolutionDartType> namedParameterTypes =
+ const <ResolutionDartType>[]]) {
+ return new ResolutionFunctionType.internal(null, returnType, parameterTypes,
optionalParameterTypes, namedParameters, namedParameterTypes);
}
- factory FunctionType.synthesized(
- [DartType returnType = const DynamicType(),
- List<DartType> parameterTypes = const <DartType>[],
- List<DartType> optionalParameterTypes = const <DartType>[],
+ ResolutionFunctionType.internal(FunctionTypedElement this.element,
+ [ResolutionDartType returnType = const ResolutionDynamicType(),
+ List<ResolutionDartType> parameterTypes = const <ResolutionDartType>[],
+ List<ResolutionDartType> optionalParameterTypes =
+ const <ResolutionDartType>[],
List<String> namedParameters = const <String>[],
- List<DartType> namedParameterTypes = const <DartType>[]]) {
- return new FunctionType.internal(null, returnType, parameterTypes,
- optionalParameterTypes, namedParameters, namedParameterTypes);
- }
-
- FunctionType.internal(FunctionTypedElement this.element,
- [DartType returnType = const DynamicType(),
- List<DartType> parameterTypes = const <DartType>[],
- List<DartType> optionalParameterTypes = const <DartType>[],
- List<String> namedParameters = const <String>[],
- List<DartType> namedParameterTypes = const <DartType>[]])
+ List<ResolutionDartType> namedParameterTypes =
+ const <ResolutionDartType>[]])
: this.returnType = returnType,
this.parameterTypes = parameterTypes,
this.optionalParameterTypes = optionalParameterTypes,
@@ -638,9 +666,9 @@
assert(namedParameters.length == namedParameterTypes.length);
}
- TypeKind get kind => TypeKind.FUNCTION;
+ ResolutionTypeKind get kind => ResolutionTypeKind.FUNCTION;
- DartType getNamedParameterType(String name) {
+ ResolutionDartType getNamedParameterType(String name) {
for (int i = 0; i < namedParameters.length; i++) {
if (namedParameters[i] == name) {
return namedParameterTypes[i];
@@ -649,19 +677,20 @@
return null;
}
- DartType subst(List<DartType> arguments, List<DartType> parameters) {
+ ResolutionDartType subst(
+ List<ResolutionDartType> arguments, List<ResolutionDartType> parameters) {
if (parameters.isEmpty) {
assert(arguments.isEmpty);
// Return fast on empty substitutions.
return this;
}
- DartType newReturnType = returnType.subst(arguments, parameters);
+ ResolutionDartType newReturnType = returnType.subst(arguments, parameters);
bool changed = !identical(newReturnType, returnType);
- List<DartType> newParameterTypes =
+ List<ResolutionDartType> newParameterTypes =
Types.substTypes(parameterTypes, arguments, parameters);
- List<DartType> newOptionalParameterTypes =
+ List<ResolutionDartType> newOptionalParameterTypes =
Types.substTypes(optionalParameterTypes, arguments, parameters);
- List<DartType> newNamedParameterTypes =
+ List<ResolutionDartType> newNamedParameterTypes =
Types.substTypes(namedParameterTypes, arguments, parameters);
if (!changed &&
(!identical(parameterTypes, newParameterTypes) ||
@@ -671,7 +700,7 @@
}
if (changed) {
// Create a new type only if necessary.
- return new FunctionType.internal(
+ return new ResolutionFunctionType.internal(
element,
newReturnType,
newParameterTypes,
@@ -682,8 +711,9 @@
return this;
}
- TypeVariableType get typeVariableOccurrence {
- TypeVariableType typeVariableType = returnType.typeVariableOccurrence;
+ ResolutionTypeVariableType get typeVariableOccurrence {
+ ResolutionTypeVariableType typeVariableType =
+ returnType.typeVariableOccurrence;
if (typeVariableType != null) return typeVariableType;
typeVariableType = _findTypeVariableOccurrence(parameterTypes);
@@ -695,15 +725,15 @@
return _findTypeVariableOccurrence(namedParameterTypes);
}
- void forEachTypeVariable(f(TypeVariableType variable)) {
+ void forEachTypeVariable(f(ResolutionTypeVariableType variable)) {
returnType.forEachTypeVariable(f);
- parameterTypes.forEach((DartType type) {
+ parameterTypes.forEach((ResolutionDartType type) {
type.forEachTypeVariable(f);
});
- optionalParameterTypes.forEach((DartType type) {
+ optionalParameterTypes.forEach((ResolutionDartType type) {
type.forEachTypeVariable(f);
});
- namedParameterTypes.forEach((DartType type) {
+ namedParameterTypes.forEach((ResolutionDartType type) {
type.forEachTypeVariable(f);
});
}
@@ -714,9 +744,9 @@
void visitChildren(DartTypeVisitor visitor, var argument) {
returnType.accept(visitor, argument);
- DartType.visitList(parameterTypes, visitor, argument);
- DartType.visitList(optionalParameterTypes, visitor, argument);
- DartType.visitList(namedParameterTypes, visitor, argument);
+ ResolutionDartType.visitList(parameterTypes, visitor, argument);
+ ResolutionDartType.visitList(optionalParameterTypes, visitor, argument);
+ ResolutionDartType.visitList(namedParameterTypes, visitor, argument);
}
String toString() {
@@ -759,17 +789,25 @@
int computeArity() => parameterTypes.length;
@override
- DartType get dynamifyMethodTypeVariableType {
+ ResolutionDartType get dynamifyMethodTypeVariableType {
if (!containsMethodTypeVariableType) return this;
- DartType eraseIt(DartType type) => type.dynamifyMethodTypeVariableType;
- DartType newReturnType = returnType.dynamifyMethodTypeVariableType;
- List<DartType> newParameterTypes = parameterTypes.map(eraseIt).toList();
- List<DartType> newOptionalParameterTypes =
+ ResolutionDartType eraseIt(ResolutionDartType type) =>
+ type.dynamifyMethodTypeVariableType;
+ ResolutionDartType newReturnType =
+ returnType.dynamifyMethodTypeVariableType;
+ List<ResolutionDartType> newParameterTypes =
+ parameterTypes.map(eraseIt).toList();
+ List<ResolutionDartType> newOptionalParameterTypes =
optionalParameterTypes.map(eraseIt).toList();
- List<DartType> newNamedParameterTypes =
+ List<ResolutionDartType> newNamedParameterTypes =
namedParameterTypes.map(eraseIt).toList();
- return new FunctionType.internal(element, newReturnType, newParameterTypes,
- newOptionalParameterTypes, namedParameters, newNamedParameterTypes);
+ return new ResolutionFunctionType.internal(
+ element,
+ newReturnType,
+ newParameterTypes,
+ newOptionalParameterTypes,
+ namedParameters,
+ newNamedParameterTypes);
}
@override
@@ -777,23 +815,23 @@
int get hashCode {
int hash = 3 * returnType.hashCode;
- for (DartType parameter in parameterTypes) {
+ for (ResolutionDartType parameter in parameterTypes) {
hash = 17 * hash + 5 * parameter.hashCode;
}
- for (DartType parameter in optionalParameterTypes) {
+ for (ResolutionDartType parameter in optionalParameterTypes) {
hash = 19 * hash + 7 * parameter.hashCode;
}
for (String name in namedParameters) {
hash = 23 * hash + 11 * name.hashCode;
}
- for (DartType parameter in namedParameterTypes) {
+ for (ResolutionDartType parameter in namedParameterTypes) {
hash = 29 * hash + 13 * parameter.hashCode;
}
return hash;
}
bool operator ==(other) {
- if (other is! FunctionType) return false;
+ if (other is! ResolutionFunctionType) return false;
return returnType == other.returnType &&
equalElements(parameterTypes, other.parameterTypes) &&
equalElements(optionalParameterTypes, other.optionalParameterTypes) &&
@@ -802,35 +840,36 @@
}
}
-bool _typeContainsMethodTypeVariableType(DartType type) =>
+bool _typeContainsMethodTypeVariableType(ResolutionDartType type) =>
type.containsMethodTypeVariableType;
-class TypedefType extends GenericType {
- DartType _unaliased;
+class ResolutionTypedefType extends GenericType {
+ ResolutionDartType _unaliased;
- TypedefType(TypedefElement element,
- [List<DartType> typeArguments = const <DartType>[]])
+ ResolutionTypedefType(TypedefElement element,
+ [List<ResolutionDartType> typeArguments = const <ResolutionDartType>[]])
: super(element, typeArguments);
- TypedefType.forUserProvidedBadType(TypedefElement element,
- [List<DartType> typeArguments = const <DartType>[]])
+ ResolutionTypedefType.forUserProvidedBadType(TypedefElement element,
+ [List<ResolutionDartType> typeArguments = const <ResolutionDartType>[]])
: super(element, typeArguments, checkTypeArgumentCount: false);
TypedefElement get element => super.element;
- TypeKind get kind => TypeKind.TYPEDEF;
+ ResolutionTypeKind get kind => ResolutionTypeKind.TYPEDEF;
String get name => element.name;
- TypedefType createInstantiation(List<DartType> newTypeArguments) {
- return new TypedefType(element, newTypeArguments);
+ ResolutionTypedefType createInstantiation(
+ List<ResolutionDartType> newTypeArguments) {
+ return new ResolutionTypedefType(element, newTypeArguments);
}
void computeUnaliased(Resolution resolution) {
if (_unaliased == null) {
element.ensureResolved(resolution);
if (element.isMalformed) {
- _unaliased = const DynamicType();
+ _unaliased = const ResolutionDynamicType();
return;
}
element.checkCyclicReference(resolution);
@@ -839,9 +878,9 @@
}
}
- DartType get unaliased {
+ ResolutionDartType get unaliased {
if (_unaliased == null) {
- DartType definition = element.alias.unaliased;
+ ResolutionDartType definition = element.alias.unaliased;
_unaliased = definition.substByContext(this);
}
return _unaliased;
@@ -849,7 +888,7 @@
int get hashCode => super.hashCode;
- TypedefType asRaw() => super.asRaw();
+ ResolutionTypedefType asRaw() => super.asRaw();
accept(DartTypeVisitor visitor, var argument) {
return visitor.visitTypedefType(this, argument);
@@ -859,8 +898,8 @@
/**
* Special type for the `dynamic` type.
*/
-class DynamicType extends DartType {
- const DynamicType();
+class ResolutionDynamicType extends ResolutionDartType implements DynamicType {
+ const ResolutionDynamicType();
Element get element => null;
@@ -868,9 +907,11 @@
bool get treatAsDynamic => true;
- TypeKind get kind => TypeKind.DYNAMIC;
+ ResolutionTypeKind get kind => ResolutionTypeKind.DYNAMIC;
- DartType subst(List<DartType> arguments, List<DartType> parameters) => this;
+ ResolutionDartType subst(List<ResolutionDartType> arguments,
+ List<ResolutionDartType> parameters) =>
+ this;
accept(DartTypeVisitor visitor, var argument) {
return visitor.visitDynamicType(this, argument);
@@ -901,16 +942,17 @@
* `B<F>` and `B<String>`.
*/
class InterfaceMember implements MemberSignature {
- final InterfaceType instance;
+ final ResolutionInterfaceType instance;
final MemberSignature member;
InterfaceMember(this.instance, this.member);
Name get name => member.name;
- DartType get type => member.type.substByContext(instance);
+ ResolutionDartType get type => member.type.substByContext(instance);
- FunctionType get functionType => member.functionType.substByContext(instance);
+ ResolutionFunctionType get functionType =>
+ member.functionType.substByContext(instance);
bool get isGetter => member.isGetter;
@@ -924,37 +966,38 @@
abstract class DartTypeVisitor<R, A> {
const DartTypeVisitor();
- R visit(DartType type, A argument) => type.accept(this, argument);
+ R visit(ResolutionDartType type, A argument) => type.accept(this, argument);
- R visitVoidType(VoidType type, A argument) => null;
+ R visitVoidType(ResolutionVoidType type, A argument) => null;
- R visitTypeVariableType(TypeVariableType type, A argument) => null;
+ R visitTypeVariableType(ResolutionTypeVariableType type, A argument) => null;
- R visitFunctionType(FunctionType type, A argument) => null;
+ R visitFunctionType(ResolutionFunctionType type, A argument) => null;
R visitMalformedType(MalformedType type, A argument) => null;
- R visitInterfaceType(InterfaceType type, A argument) => null;
+ R visitInterfaceType(ResolutionInterfaceType type, A argument) => null;
- R visitTypedefType(TypedefType type, A argument) => null;
+ R visitTypedefType(ResolutionTypedefType type, A argument) => null;
- R visitDynamicType(DynamicType type, A argument) => null;
+ R visitDynamicType(ResolutionDynamicType type, A argument) => null;
}
abstract class BaseDartTypeVisitor<R, A> extends DartTypeVisitor<R, A> {
const BaseDartTypeVisitor();
- R visitType(DartType type, A argument);
+ R visitType(ResolutionDartType type, A argument);
@override
- R visitVoidType(VoidType type, A argument) => visitType(type, argument);
-
- @override
- R visitTypeVariableType(TypeVariableType type, A argument) =>
+ R visitVoidType(ResolutionVoidType type, A argument) =>
visitType(type, argument);
@override
- R visitFunctionType(FunctionType type, A argument) =>
+ R visitTypeVariableType(ResolutionTypeVariableType type, A argument) =>
+ visitType(type, argument);
+
+ @override
+ R visitFunctionType(ResolutionFunctionType type, A argument) =>
visitType(type, argument);
@override
@@ -964,59 +1007,63 @@
R visitGenericType(GenericType type, A argument) => visitType(type, argument);
@override
- R visitInterfaceType(InterfaceType type, A argument) =>
+ R visitInterfaceType(ResolutionInterfaceType type, A argument) =>
visitGenericType(type, argument);
@override
- R visitTypedefType(TypedefType type, A argument) =>
+ R visitTypedefType(ResolutionTypedefType type, A argument) =>
visitGenericType(type, argument);
@override
- R visitDynamicType(DynamicType type, A argument) => visitType(type, argument);
+ R visitDynamicType(ResolutionDynamicType type, A argument) =>
+ visitType(type, argument);
}
/**
* Abstract visitor for determining relations between types.
*/
abstract class AbstractTypeRelation
- extends BaseDartTypeVisitor<bool, DartType> {
+ extends BaseDartTypeVisitor<bool, ResolutionDartType> {
final Resolution resolution;
AbstractTypeRelation(this.resolution);
CommonElements get commonElements => resolution.commonElements;
- bool visitType(DartType t, DartType s) {
+ bool visitType(ResolutionDartType t, ResolutionDartType s) {
throw 'internal error: unknown type kind ${t.kind}';
}
- bool visitVoidType(VoidType t, DartType s) {
- assert(s is! VoidType);
+ bool visitVoidType(ResolutionVoidType t, ResolutionDartType s) {
+ assert(s is! ResolutionVoidType);
return false;
}
- bool invalidTypeArguments(DartType t, DartType s);
+ bool invalidTypeArguments(ResolutionDartType t, ResolutionDartType s);
- bool invalidFunctionReturnTypes(DartType t, DartType s);
+ bool invalidFunctionReturnTypes(ResolutionDartType t, ResolutionDartType s);
- bool invalidFunctionParameterTypes(DartType t, DartType s);
+ bool invalidFunctionParameterTypes(
+ ResolutionDartType t, ResolutionDartType s);
- bool invalidTypeVariableBounds(DartType bound, DartType s);
+ bool invalidTypeVariableBounds(
+ ResolutionDartType bound, ResolutionDartType s);
- bool invalidCallableType(DartType callType, DartType s);
+ bool invalidCallableType(ResolutionDartType callType, ResolutionDartType s);
/// Handle as dynamic for both subtype and more specific relation to avoid
/// spurious errors from malformed types.
- bool visitMalformedType(MalformedType t, DartType s) => true;
+ bool visitMalformedType(MalformedType t, ResolutionDartType s) => true;
- bool visitInterfaceType(InterfaceType t, DartType s) {
+ bool visitInterfaceType(ResolutionInterfaceType t, ResolutionDartType s) {
// TODO(johnniwinther): Currently needed since literal types like int,
// double, bool etc. might not have been resolved yet.
t.element.ensureResolved(resolution);
- bool checkTypeArguments(InterfaceType instance, InterfaceType other) {
- List<DartType> tTypeArgs = instance.typeArguments;
- List<DartType> sTypeArgs = other.typeArguments;
+ bool checkTypeArguments(
+ ResolutionInterfaceType instance, ResolutionInterfaceType other) {
+ List<ResolutionDartType> tTypeArgs = instance.typeArguments;
+ List<ResolutionDartType> sTypeArgs = other.typeArguments;
assert(tTypeArgs.length == sTypeArgs.length);
for (int i = 0; i < tTypeArgs.length; i++) {
if (invalidTypeArguments(tTypeArgs[i], sTypeArgs[i])) {
@@ -1026,8 +1073,8 @@
return true;
}
- if (s is InterfaceType) {
- InterfaceType instance = t.asInstanceOf(s.element);
+ if (s is ResolutionInterfaceType) {
+ ResolutionInterfaceType instance = t.asInstanceOf(s.element);
if (instance != null && checkTypeArguments(instance, s)) {
return true;
}
@@ -1035,21 +1082,21 @@
if (s == commonElements.functionType && t.element.callType != null) {
return true;
- } else if (s is FunctionType) {
- FunctionType callType = t.callType;
+ } else if (s is ResolutionFunctionType) {
+ ResolutionFunctionType callType = t.callType;
return callType != null && !invalidCallableType(callType, s);
}
return false;
}
- bool visitFunctionType(FunctionType t, DartType s) {
+ bool visitFunctionType(ResolutionFunctionType t, ResolutionDartType s) {
if (s == commonElements.functionType) {
return true;
}
- if (s is! FunctionType) return false;
- FunctionType tf = t;
- FunctionType sf = s;
+ if (s is! ResolutionFunctionType) return false;
+ ResolutionFunctionType tf = t;
+ ResolutionFunctionType sf = s;
if (invalidFunctionReturnTypes(tf.returnType, sf.returnType)) {
return false;
}
@@ -1062,8 +1109,8 @@
// x.o : optionalParameterTypes on [:x:], and
// len(xs) : length of list [:xs:].
- Iterator<DartType> tps = tf.parameterTypes.iterator;
- Iterator<DartType> sps = sf.parameterTypes.iterator;
+ Iterator<ResolutionDartType> tps = tf.parameterTypes.iterator;
+ Iterator<ResolutionDartType> sps = sf.parameterTypes.iterator;
bool sNotEmpty = sps.moveNext();
bool tNotEmpty = tps.moveNext();
tNext() => (tNotEmpty = tps.moveNext());
@@ -1094,9 +1141,9 @@
// subset relation with a linear search for [:sf.namedParameters:]
// within [:tf.namedParameters:].
List<String> tNames = tf.namedParameters;
- List<DartType> tTypes = tf.namedParameterTypes;
+ List<ResolutionDartType> tTypes = tf.namedParameterTypes;
List<String> sNames = sf.namedParameters;
- List<DartType> sTypes = sf.namedParameterTypes;
+ List<ResolutionDartType> sTypes = sf.namedParameterTypes;
int tIndex = 0;
int sIndex = 0;
while (tIndex < tNames.length && sIndex < sNames.length) {
@@ -1141,9 +1188,10 @@
return true;
}
- bool visitTypeVariableType(TypeVariableType t, DartType s) {
+ bool visitTypeVariableType(
+ ResolutionTypeVariableType t, ResolutionDartType s) {
// Identity check is handled in [isSubtype].
- DartType bound = t.element.bound;
+ ResolutionDartType bound = t.element.bound;
if (bound.isTypeVariable) {
// The bound is potentially cyclic so we need to be extra careful.
Set<TypeVariableElement> seenTypeVariables =
@@ -1173,7 +1221,7 @@
class MoreSpecificVisitor extends AbstractTypeRelation {
MoreSpecificVisitor(Resolution resolution) : super(resolution);
- bool isMoreSpecific(DartType t, DartType s) {
+ bool isMoreSpecific(ResolutionDartType t, ResolutionDartType s) {
if (identical(t, s) || s.treatAsDynamic || t == commonElements.nullType) {
return true;
}
@@ -1194,24 +1242,26 @@
return t.accept(this, s);
}
- bool invalidTypeArguments(DartType t, DartType s) {
+ bool invalidTypeArguments(ResolutionDartType t, ResolutionDartType s) {
return !isMoreSpecific(t, s);
}
- bool invalidFunctionReturnTypes(DartType t, DartType s) {
+ bool invalidFunctionReturnTypes(ResolutionDartType t, ResolutionDartType s) {
if (s.treatAsDynamic && t.isVoid) return true;
return !s.isVoid && !isMoreSpecific(t, s);
}
- bool invalidFunctionParameterTypes(DartType t, DartType s) {
+ bool invalidFunctionParameterTypes(
+ ResolutionDartType t, ResolutionDartType s) {
return !isMoreSpecific(t, s);
}
- bool invalidTypeVariableBounds(DartType bound, DartType s) {
+ bool invalidTypeVariableBounds(
+ ResolutionDartType bound, ResolutionDartType s) {
return !isMoreSpecific(bound, s);
}
- bool invalidCallableType(DartType callType, DartType s) {
+ bool invalidCallableType(ResolutionDartType callType, ResolutionDartType s) {
return !isMoreSpecific(callType, s);
}
}
@@ -1222,31 +1272,33 @@
class SubtypeVisitor extends MoreSpecificVisitor {
SubtypeVisitor(Resolution resolution) : super(resolution);
- bool isSubtype(DartType t, DartType s) {
+ bool isSubtype(ResolutionDartType t, ResolutionDartType s) {
return t.treatAsDynamic || isMoreSpecific(t, s);
}
- bool isAssignable(DartType t, DartType s) {
+ bool isAssignable(ResolutionDartType t, ResolutionDartType s) {
return isSubtype(t, s) || isSubtype(s, t);
}
- bool invalidTypeArguments(DartType t, DartType s) {
+ bool invalidTypeArguments(ResolutionDartType t, ResolutionDartType s) {
return !isSubtype(t, s);
}
- bool invalidFunctionReturnTypes(DartType t, DartType s) {
+ bool invalidFunctionReturnTypes(ResolutionDartType t, ResolutionDartType s) {
return !s.isVoid && !isAssignable(t, s);
}
- bool invalidFunctionParameterTypes(DartType t, DartType s) {
+ bool invalidFunctionParameterTypes(
+ ResolutionDartType t, ResolutionDartType s) {
return !isAssignable(t, s);
}
- bool invalidTypeVariableBounds(DartType bound, DartType s) {
+ bool invalidTypeVariableBounds(
+ ResolutionDartType bound, ResolutionDartType s) {
return !isSubtype(bound, s);
}
- bool invalidCallableType(DartType callType, DartType s) {
+ bool invalidCallableType(ResolutionDartType callType, ResolutionDartType s) {
return !isSubtype(callType, s);
}
}
@@ -1256,8 +1308,11 @@
* substitute for the bound of [typeVariable]. [bound] holds the bound against
* which [typeArgument] should be checked.
*/
-typedef void CheckTypeVariableBound(GenericType type, DartType typeArgument,
- TypeVariableType typeVariable, DartType bound);
+typedef void CheckTypeVariableBound(
+ GenericType type,
+ ResolutionDartType typeArgument,
+ ResolutionTypeVariableType typeVariable,
+ ResolutionDartType bound);
/// Basic interface for the Dart type system.
abstract class DartTypes {
@@ -1265,11 +1320,11 @@
CommonElements get commonElements;
/// Returns `true` if [t] is a subtype of [s].
- bool isSubtype(DartType t, DartType s);
+ bool isSubtype(ResolutionDartType t, ResolutionDartType s);
/// Returns `true` if [t] might be a subtype of [s] for some values of
/// type variables in [s] and [t].
- bool isPotentialSubtype(DartType t, DartType s);
+ bool isPotentialSubtype(ResolutionDartType t, ResolutionDartType s);
}
class Types implements DartTypes {
@@ -1308,13 +1363,14 @@
///
/// This method is used in the static typing of await and type checking of
/// return.
- DartType flatten(DartType type) {
- if (type is InterfaceType) {
+ ResolutionDartType flatten(ResolutionDartType type) {
+ if (type is ResolutionInterfaceType) {
if (type.element == commonElements.futureClass) {
// T = Future<S>
return flatten(type.typeArguments.first);
}
- InterfaceType futureType = type.asInstanceOf(commonElements.futureClass);
+ ResolutionInterfaceType futureType =
+ type.asInstanceOf(commonElements.futureClass);
if (futureType != null) {
// T << Future<S>
return futureType.typeArguments.single;
@@ -1324,13 +1380,14 @@
}
/// Returns true if [t] is more specific than [s].
- bool isMoreSpecific(DartType t, DartType s) {
+ bool isMoreSpecific(ResolutionDartType t, ResolutionDartType s) {
return moreSpecificVisitor.isMoreSpecific(t, s);
}
/// Returns the most specific type of [t] and [s] or `null` if neither is more
/// specific than the other.
- DartType getMostSpecific(DartType t, DartType s) {
+ ResolutionDartType getMostSpecific(
+ ResolutionDartType t, ResolutionDartType s) {
if (isMoreSpecific(t, s)) {
return t;
} else if (isMoreSpecific(s, t)) {
@@ -1341,11 +1398,11 @@
}
/** Returns true if t is a subtype of s */
- bool isSubtype(DartType t, DartType s) {
+ bool isSubtype(ResolutionDartType t, ResolutionDartType s) {
return subtypeVisitor.isSubtype(t, s);
}
- bool isAssignable(DartType r, DartType s) {
+ bool isAssignable(ResolutionDartType r, ResolutionDartType s) {
return subtypeVisitor.isAssignable(r, s);
}
@@ -1353,13 +1410,13 @@
static const int MAYBE_SUBTYPE = 0;
static const int NOT_SUBTYPE = -1;
- int computeSubtypeRelation(DartType t, DartType s) {
+ int computeSubtypeRelation(ResolutionDartType t, ResolutionDartType s) {
// TODO(johnniwinther): Compute this directly in [isPotentialSubtype].
if (isSubtype(t, s)) return IS_SUBTYPE;
return isPotentialSubtype(t, s) ? MAYBE_SUBTYPE : NOT_SUBTYPE;
}
- bool isPotentialSubtype(DartType t, DartType s) {
+ bool isPotentialSubtype(ResolutionDartType t, ResolutionDartType s) {
// TODO(johnniwinther): Return a set of variable points in the positive
// cases.
return potentialSubtypeVisitor.isSubtype(t, s);
@@ -1373,13 +1430,14 @@
void checkTypeVariableBounds(
GenericType type, CheckTypeVariableBound checkTypeVariableBound) {
TypeDeclarationElement element = type.element;
- List<DartType> typeArguments = type.typeArguments;
- List<DartType> typeVariables = element.typeVariables;
+ List<ResolutionDartType> typeArguments = type.typeArguments;
+ List<ResolutionDartType> typeVariables = element.typeVariables;
assert(typeVariables.length == typeArguments.length);
for (int index = 0; index < typeArguments.length; index++) {
- TypeVariableType typeVariable = typeVariables[index];
- DartType bound = typeVariable.element.bound.substByContext(type);
- DartType typeArgument = typeArguments[index];
+ ResolutionTypeVariableType typeVariable = typeVariables[index];
+ ResolutionDartType bound =
+ typeVariable.element.bound.substByContext(type);
+ ResolutionDartType typeArgument = typeArguments[index];
checkTypeVariableBound(type, typeArgument, typeVariable, bound);
}
}
@@ -1390,12 +1448,13 @@
* If no types are changed by the substitution, the [types] is returned
* instead of a newly created list.
*/
- static List<DartType> substTypes(List<DartType> types,
- List<DartType> arguments, List<DartType> parameters) {
+ static List<ResolutionDartType> substTypes(List<ResolutionDartType> types,
+ List<ResolutionDartType> arguments, List<ResolutionDartType> parameters) {
bool changed = false;
- List<DartType> result = new List<DartType>.generate(types.length, (index) {
- DartType type = types[index];
- DartType argument = type.subst(arguments, parameters);
+ List<ResolutionDartType> result =
+ new List<ResolutionDartType>.generate(types.length, (index) {
+ ResolutionDartType type = types[index];
+ ResolutionDartType argument = type.subst(arguments, parameters);
if (!changed && !identical(argument, type)) {
changed = true;
}
@@ -1409,9 +1468,9 @@
* Returns the [ClassElement] which declares the type variables occurring in
* [type], or [:null:] if [type] does not contain type variables.
*/
- static ClassElement getClassContext(DartType type) {
+ static ClassElement getClassContext(ResolutionDartType type) {
ClassElement contextClass;
- type.forEachTypeVariable((TypeVariableType typeVariable) {
+ type.forEachTypeVariable((ResolutionTypeVariableType typeVariable) {
if (typeVariable.element.typeDeclaration is! ClassElement) return;
contextClass = typeVariable.element.typeDeclaration;
});
@@ -1445,7 +1504,7 @@
* * malformed types
* * statement types
*/
- static int compare(DartType a, DartType b) {
+ static int compare(ResolutionDartType a, ResolutionDartType b) {
if (a == b) return 0;
if (a.isVoid) {
// [b] is not void => a < b.
@@ -1461,7 +1520,7 @@
// [a] is not dynamic => a > b.
return 1;
}
- bool isDefinedByDeclaration(DartType type) {
+ bool isDefinedByDeclaration(ResolutionDartType type) {
return type.isInterfaceType || type.isTypedef || type.isTypeVariable;
}
@@ -1494,8 +1553,8 @@
}
if (a.isFunctionType) {
if (b.isFunctionType) {
- FunctionType aFunc = a;
- FunctionType bFunc = b;
+ ResolutionFunctionType aFunc = a;
+ ResolutionFunctionType bFunc = b;
int result = compare(aFunc.returnType, bFunc.returnType);
if (result != 0) return result;
result = compareList(aFunc.parameterTypes, bFunc.parameterTypes);
@@ -1533,7 +1592,8 @@
return Elements.compareByPosition(a.element, b.element);
}
- static int compareList(List<DartType> a, List<DartType> b) {
+ static int compareList(
+ List<ResolutionDartType> a, List<ResolutionDartType> b) {
for (int index = 0; index < min(a.length, b.length); index++) {
int result = compare(a[index], b[index]);
if (result != 0) return result;
@@ -1546,18 +1606,19 @@
return 0;
}
- static List<DartType> sorted(Iterable<DartType> types) {
+ static List<ResolutionDartType> sorted(Iterable<ResolutionDartType> types) {
return types.toList()..sort(compare);
}
/// Computes the least upper bound of two interface types [a] and [b].
- InterfaceType computeLeastUpperBoundInterfaces(
- InterfaceType a, InterfaceType b) {
+ ResolutionInterfaceType computeLeastUpperBoundInterfaces(
+ ResolutionInterfaceType a, ResolutionInterfaceType b) {
/// Returns the set of supertypes of [type] at depth [depth].
- Set<DartType> getSupertypesAtDepth(InterfaceType type, int depth) {
+ Set<ResolutionDartType> getSupertypesAtDepth(
+ ResolutionInterfaceType type, int depth) {
OrderedTypeSet types = type.element.allSupertypesAndSelf;
- Set<DartType> set = new Set<DartType>();
- types.forEach(depth, (DartType supertype) {
+ Set<ResolutionDartType> set = new Set<ResolutionDartType>();
+ types.forEach(depth, (ResolutionDartType supertype) {
set.add(supertype.substByContext(type));
});
return set;
@@ -1567,9 +1628,9 @@
ClassElement bClass = b.element;
int maxCommonDepth = min(aClass.hierarchyDepth, bClass.hierarchyDepth);
for (int depth = maxCommonDepth; depth >= 0; depth--) {
- Set<DartType> aTypeSet = getSupertypesAtDepth(a, depth);
- Set<DartType> bTypeSet = getSupertypesAtDepth(b, depth);
- Set<DartType> intersection = aTypeSet..retainAll(bTypeSet);
+ Set<ResolutionDartType> aTypeSet = getSupertypesAtDepth(a, depth);
+ Set<ResolutionDartType> bTypeSet = getSupertypesAtDepth(b, depth);
+ Set<ResolutionDartType> intersection = aTypeSet..retainAll(bTypeSet);
if (intersection.length == 1) {
return intersection.first;
}
@@ -1582,11 +1643,11 @@
/// Computes the least upper bound of the types in the longest prefix of [a]
/// and [b].
- List<DartType> computeLeastUpperBoundsTypes(
- List<DartType> a, List<DartType> b) {
- if (a.isEmpty || b.isEmpty) return const <DartType>[];
+ List<ResolutionDartType> computeLeastUpperBoundsTypes(
+ List<ResolutionDartType> a, List<ResolutionDartType> b) {
+ if (a.isEmpty || b.isEmpty) return const <ResolutionDartType>[];
int prefixLength = min(a.length, b.length);
- List<DartType> types = new List<DartType>(prefixLength);
+ List<ResolutionDartType> types = new List<ResolutionDartType>(prefixLength);
for (int index = 0; index < prefixLength; index++) {
types[index] = computeLeastUpperBound(a[index], b[index]);
}
@@ -1604,21 +1665,24 @@
/// bound of the longest common prefix of the optional parameters of [a] and
/// [b], and the named parameters are the least upper bound of those common to
/// [a] and [b].
- DartType computeLeastUpperBoundFunctionTypes(FunctionType a, FunctionType b) {
+ ResolutionDartType computeLeastUpperBoundFunctionTypes(
+ ResolutionFunctionType a, ResolutionFunctionType b) {
if (a.parameterTypes.length != b.parameterTypes.length) {
return commonElements.functionType;
}
- DartType returnType = computeLeastUpperBound(a.returnType, b.returnType);
- List<DartType> parameterTypes =
+ ResolutionDartType returnType =
+ computeLeastUpperBound(a.returnType, b.returnType);
+ List<ResolutionDartType> parameterTypes =
computeLeastUpperBoundsTypes(a.parameterTypes, b.parameterTypes);
- List<DartType> optionalParameterTypes = computeLeastUpperBoundsTypes(
- a.optionalParameterTypes, b.optionalParameterTypes);
+ List<ResolutionDartType> optionalParameterTypes =
+ computeLeastUpperBoundsTypes(
+ a.optionalParameterTypes, b.optionalParameterTypes);
List<String> namedParameters = <String>[];
List<String> aNamedParameters = a.namedParameters;
List<String> bNamedParameters = b.namedParameters;
- List<DartType> namedParameterTypes = <DartType>[];
- List<DartType> aNamedParameterTypes = a.namedParameterTypes;
- List<DartType> bNamedParameterTypes = b.namedParameterTypes;
+ List<ResolutionDartType> namedParameterTypes = <ResolutionDartType>[];
+ List<ResolutionDartType> aNamedParameterTypes = a.namedParameterTypes;
+ List<ResolutionDartType> bNamedParameterTypes = b.namedParameterTypes;
int aIndex = 0;
int bIndex = 0;
while (
@@ -1638,7 +1702,7 @@
bIndex++;
}
}
- return new FunctionType.synthesized(returnType, parameterTypes,
+ return new ResolutionFunctionType.synthesized(returnType, parameterTypes,
optionalParameterTypes, namedParameters, namedParameterTypes);
}
@@ -1646,8 +1710,9 @@
/// type variable. The least upper bound of a type variable is defined in
/// terms of its bound, but to ensure reflexivity we need to check for common
/// bounds transitively.
- DartType computeLeastUpperBoundTypeVariableTypes(DartType a, DartType b) {
- Set<DartType> typeVariableBounds = new Set<DartType>();
+ ResolutionDartType computeLeastUpperBoundTypeVariableTypes(
+ ResolutionDartType a, ResolutionDartType b) {
+ Set<ResolutionDartType> typeVariableBounds = new Set<ResolutionDartType>();
while (a.isTypeVariable) {
if (a == b) return a;
typeVariableBounds.add(a);
@@ -1663,7 +1728,8 @@
}
/// Computes the least upper bound for [a] and [b].
- DartType computeLeastUpperBound(DartType a, DartType b) {
+ ResolutionDartType computeLeastUpperBound(
+ ResolutionDartType a, ResolutionDartType b) {
if (a == b) return a;
if (a.isTypeVariable || b.isTypeVariable) {
@@ -1675,8 +1741,9 @@
b.computeUnaliased(resolution);
b = b.unaliased;
- if (a.treatAsDynamic || b.treatAsDynamic) return const DynamicType();
- if (a.isVoid || b.isVoid) return const VoidType();
+ if (a.treatAsDynamic || b.treatAsDynamic)
+ return const ResolutionDynamicType();
+ if (a.isVoid || b.isVoid) return const ResolutionVoidType();
if (a.isFunctionType && b.isFunctionType) {
return computeLeastUpperBoundFunctionTypes(a, b);
@@ -1692,7 +1759,7 @@
if (a.isInterfaceType && b.isInterfaceType) {
return computeLeastUpperBoundInterfaces(a, b);
}
- return const DynamicType();
+ return const ResolutionDynamicType();
}
/// Computes the unaliased type of the first non type variable bound of
@@ -1722,17 +1789,18 @@
/// unaliasedBound(U) = unaliasedBound(Baz) = ()->dynamic
/// unaliasedBound(X) = unaliasedBound(Y) = `Object`
///
- static DartType computeUnaliasedBound(Resolution resolution, DartType type) {
- DartType originalType = type;
+ static ResolutionDartType computeUnaliasedBound(
+ Resolution resolution, ResolutionDartType type) {
+ ResolutionDartType originalType = type;
while (type.isTypeVariable) {
- TypeVariableType variable = type;
+ ResolutionTypeVariableType variable = type;
type = variable.element.bound;
if (type == originalType) {
type = resolution.commonElements.objectType;
}
}
if (type.isMalformed) {
- return const DynamicType();
+ return const ResolutionDynamicType();
}
type.computeUnaliased(resolution);
return type.unaliased;
@@ -1765,8 +1833,8 @@
/// When typechecking `o.foo` the interface type of the static type of `o` is
/// used to lookup the existence and type of `foo`.
///
- static InterfaceType computeInterfaceType(
- Resolution resolution, DartType type) {
+ static ResolutionInterfaceType computeInterfaceType(
+ Resolution resolution, ResolutionDartType type) {
type = computeUnaliasedBound(resolution, type);
if (type.treatAsDynamic) {
return null;
@@ -1788,8 +1856,8 @@
class PotentialSubtypeVisitor extends SubtypeVisitor {
PotentialSubtypeVisitor(Resolution resolution) : super(resolution);
- bool isSubtype(DartType t, DartType s) {
- if (t is TypeVariableType || s is TypeVariableType) {
+ bool isSubtype(ResolutionDartType t, ResolutionDartType s) {
+ if (t is ResolutionTypeVariableType || s is ResolutionTypeVariableType) {
return true;
}
return super.isSubtype(t, s);
@@ -1803,9 +1871,10 @@
/// visited type by structurally matching it with the argument type. If the
/// constraints are too complex or the two types are too different, `false`
/// is returned. Otherwise, the [constraintMap] holds the valid constraints.
-class MoreSpecificSubtypeVisitor extends BaseDartTypeVisitor<bool, DartType> {
+class MoreSpecificSubtypeVisitor
+ extends BaseDartTypeVisitor<bool, ResolutionDartType> {
final Types types;
- Map<TypeVariableType, DartType> constraintMap;
+ Map<ResolutionTypeVariableType, ResolutionDartType> constraintMap;
MoreSpecificSubtypeVisitor(this.types);
@@ -1814,30 +1883,31 @@
///
/// Note that this computation is a heuristic. It does not find a suggestion
/// in all possible cases.
- InterfaceType computeMoreSpecific(
- ClassElement element, InterfaceType supertype) {
- InterfaceType supertypeInstance =
+ ResolutionInterfaceType computeMoreSpecific(
+ ClassElement element, ResolutionInterfaceType supertype) {
+ ResolutionInterfaceType supertypeInstance =
element.thisType.asInstanceOf(supertype.element);
if (supertypeInstance == null) return null;
- constraintMap = new Map<TypeVariableType, DartType>();
- element.typeVariables.forEach((TypeVariableType typeVariable) {
- constraintMap[typeVariable] = const DynamicType();
+ constraintMap = new Map<ResolutionTypeVariableType, ResolutionDartType>();
+ element.typeVariables.forEach((ResolutionTypeVariableType typeVariable) {
+ constraintMap[typeVariable] = const ResolutionDynamicType();
});
if (supertypeInstance.accept(this, supertype)) {
- List<DartType> variables = element.typeVariables;
- List<DartType> typeArguments = new List<DartType>.generate(
- variables.length, (int index) => constraintMap[variables[index]]);
+ List<ResolutionDartType> variables = element.typeVariables;
+ List<ResolutionDartType> typeArguments =
+ new List<ResolutionDartType>.generate(
+ variables.length, (int index) => constraintMap[variables[index]]);
return element.thisType.createInstantiation(typeArguments);
}
return null;
}
- bool visitType(DartType type, DartType argument) {
+ bool visitType(ResolutionDartType type, ResolutionDartType argument) {
return types.isMoreSpecific(type, argument);
}
- bool visitTypes(List<DartType> a, List<DartType> b) {
+ bool visitTypes(List<ResolutionDartType> a, List<ResolutionDartType> b) {
int prefixLength = min(a.length, b.length);
for (int index = 0; index < prefixLength; index++) {
if (!a[index].accept(this, b[index])) return false;
@@ -1845,14 +1915,17 @@
return prefixLength == a.length && a.length == b.length;
}
- bool visitTypeVariableType(TypeVariableType type, DartType argument) {
- DartType constraint = types.getMostSpecific(constraintMap[type], argument);
+ bool visitTypeVariableType(
+ ResolutionTypeVariableType type, ResolutionDartType argument) {
+ ResolutionDartType constraint =
+ types.getMostSpecific(constraintMap[type], argument);
constraintMap[type] = constraint;
return constraint != null;
}
- bool visitFunctionType(FunctionType type, DartType argument) {
- if (argument is FunctionType) {
+ bool visitFunctionType(
+ ResolutionFunctionType type, ResolutionDartType argument) {
+ if (argument is ResolutionFunctionType) {
if (type.parameterTypes.length != argument.parameterTypes.length) {
return false;
}
@@ -1877,7 +1950,7 @@
return false;
}
- bool visitGenericType(GenericType type, DartType argument) {
+ bool visitGenericType(GenericType type, ResolutionDartType argument) {
if (argument is GenericType) {
if (type.element != argument.element) return false;
return visitTypes(type.typeArguments, argument.typeArguments);
@@ -1895,7 +1968,7 @@
/// Creates textual representation of [type] as if a member by the [name] were
/// declared. For instance 'String foo' for `format(String, 'foo')`.
- String format(DartType type, String name) {
+ String format(ResolutionDartType type, String name) {
sb = new StringBuffer();
usedNames = new Set<String>();
type.accept(this, name);
@@ -1917,13 +1990,13 @@
return proposal;
}
- void visit(DartType type, [_]) {
+ void visit(ResolutionDartType type, [_]) {
type.accept(this, null);
}
- void visitTypes(List<DartType> types, String prefix) {
+ void visitTypes(List<ResolutionDartType> types, String prefix) {
bool needsComma = false;
- for (DartType type in types) {
+ for (ResolutionDartType type in types) {
if (needsComma) {
sb.write(', ');
}
@@ -1932,7 +2005,7 @@
}
}
- void visitType(DartType type, String name) {
+ void visitType(ResolutionDartType type, String name) {
if (name == null) {
sb.write(type);
} else {
@@ -1953,7 +2026,7 @@
}
}
- void visitFunctionType(FunctionType type, String name) {
+ void visitFunctionType(ResolutionFunctionType type, String name) {
visit(type.returnType);
sb.write(' ');
if (name != null) {
@@ -1979,7 +2052,7 @@
}
sb.write('{');
List<String> namedParameters = type.namedParameters;
- List<DartType> namedParameterTypes = type.namedParameterTypes;
+ List<ResolutionDartType> namedParameterTypes = type.namedParameterTypes;
needsComma = false;
for (int index = 0; index < namedParameters.length; index++) {
if (needsComma) {
diff --git a/pkg/compiler/lib/src/elements/types.dart b/pkg/compiler/lib/src/elements/types.dart
new file mode 100644
index 0000000..0e97957
--- /dev/null
+++ b/pkg/compiler/lib/src/elements/types.dart
@@ -0,0 +1,87 @@
+// Copyright (c) 2016, 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 file.
+
+import 'entities.dart';
+
+/// Hierarchy to describe types in Dart.
+///
+/// This hierarchy is a super hierarchy of the use-case specific hierarchies
+/// used in different parts of the compiler. This hierarchy abstracts details
+/// not generally needed or required for the Dart type hierarchy. For instance,
+/// the hierarchy in 'resolution_types.dart' has properties supporting lazy
+/// computation (like computeAlias) and distinctions between 'Foo' and
+/// 'Foo<dynamic>', features that are not needed for code generation and not
+/// supported from kernel.
+///
+/// Current only 'resolution_types.dart' implement this hierarchy but when the
+/// compiler moves to use [Entity] instead of [Element] this hierarchy can be
+/// implementated directly but other entity systems, for instance based directly
+/// on kernel ir without the need for [Element].
+
+abstract class DartType {
+ /// Returns the unaliased type of this type.
+ ///
+ /// The unaliased type of a typedef'd type is the unaliased type to which its
+ /// name is bound. The unaliased version of any other type is the type itself.
+ ///
+ /// For example, the unaliased type of `typedef A Func<A,B>(B b)` is the
+ /// function type `(B) -> A` and the unaliased type of `Func<int,String>`
+ /// is the function type `(String) -> int`.
+ DartType get unaliased;
+
+ /// Is `true` if this type has no non-dynamic type arguments.
+ bool get treatAsRaw;
+
+ /// Is `true` if this type should be treated as the dynamic type.
+ bool get treatAsDynamic;
+
+ /// Is `true` if this type is the dynamic type.
+ bool get isDynamic;
+
+ /// Is `true` if this type is the void type.
+ bool get isVoid;
+
+ /// Is `true` if this is the type of `Object` from dart:core.
+ bool get isObject;
+
+ /// Is `true` if this type is an interface type.
+ bool get isInterfaceType;
+
+ /// Is `true` if this type is a typedef.
+ bool get isTypedef;
+
+ /// Is `true` if this type is a function type.
+ bool get isFunctionType;
+
+ /// Is `true` if this type is a type variable.
+ bool get isTypeVariable;
+
+ /// Is `true` if this type is a malformed type.
+ bool get isMalformed;
+}
+
+abstract class InterfaceType extends DartType {
+ ClassEntity get element;
+}
+
+abstract class TypeVariableType extends DartType {
+ TypeVariableEntity get element;
+}
+
+abstract class VoidType extends DartType {}
+
+abstract class DynamicType extends DartType {}
+
+abstract class FunctionType extends DartType {
+ DartType get returnType;
+ List<DartType> get parameterTypes;
+ List<DartType> get optionalParameterTypes;
+
+ /// The names of the named parameters ordered lexicographically.
+ List<String> get namedParameters;
+
+ /// The types of the named parameters in the order corresponding to the
+ /// [namedParameters].
+ List<DartType> get namedParameterTypes;
+}
diff --git a/pkg/compiler/lib/src/enqueue.dart b/pkg/compiler/lib/src/enqueue.dart
index 3af5382..8b89336 100644
--- a/pkg/compiler/lib/src/enqueue.dart
+++ b/pkg/compiler/lib/src/enqueue.dart
@@ -14,7 +14,8 @@
import 'common.dart';
import 'compiler.dart' show Compiler, GlobalDependencyRegistry;
import 'options.dart';
-import 'dart_types.dart' show DartType, InterfaceType;
+import 'elements/resolution_types.dart'
+ show ResolutionDartType, ResolutionInterfaceType;
import 'elements/elements.dart'
show
AnalyzableElement,
@@ -183,7 +184,7 @@
impactSource, worldImpact, _impactVisitor, impactUse);
}
- void _registerInstantiatedType(InterfaceType type,
+ void _registerInstantiatedType(ResolutionInterfaceType type,
{ConstructorElement constructor,
bool mirrorUsage: false,
bool nativeUsage: false,
@@ -274,7 +275,7 @@
}
void processTypeUse(TypeUse typeUse) {
- DartType type = typeUse.type;
+ ResolutionDartType type = typeUse.type;
switch (typeUse.kind) {
case TypeUseKind.INSTANTIATION:
_registerInstantiatedType(type, globalDependency: false);
@@ -305,7 +306,7 @@
}
}
- void _registerIsCheck(DartType type) {
+ void _registerIsCheck(ResolutionDartType type) {
type = _universe.registerIsCheck(type);
// Even in checked mode, type annotations for return type and argument
// types do not imply type checks, so there should never be a check
diff --git a/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart b/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
index f9773c4..20ae0de 100644
--- a/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
+++ b/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
@@ -11,7 +11,7 @@
import '../compiler.dart' show Compiler;
import '../constants/constant_system.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../resolution/operators.dart';
import '../resolution/semantic_visitor.dart';
@@ -79,7 +79,7 @@
* [isNullable] indicates whether the annotation implies a null
* type.
*/
- T narrowType(T type, DartType annotation, {bool isNullable: true});
+ T narrowType(T type, ResolutionDartType annotation, {bool isNullable: true});
/**
* Returns the non-nullable type [T].
@@ -1009,7 +1009,7 @@
}
void updateIsChecks(List<Node> tests, {bool usePositive}) {
- void narrow(Element element, DartType type, Node node) {
+ void narrow(Element element, ResolutionDartType type, Node node) {
if (element is LocalElement) {
T existing = locals.use(element);
T newType = types.narrowType(existing, type, isNullable: false);
@@ -1025,7 +1025,8 @@
} else {
if (!usePositive) continue;
}
- DartType type = elements.getType(node.typeAnnotationFromIsCheckOrCast);
+ ResolutionDartType type =
+ elements.getType(node.typeAnnotationFromIsCheckOrCast);
narrow(elements[node.receiver], type, node);
} else {
Element receiverElement = elements[node.receiver];
@@ -1042,7 +1043,7 @@
}
} else {
// Narrow the elements to a non-null type.
- DartType objectType = closedWorld.commonElements.objectType;
+ ResolutionDartType objectType = closedWorld.commonElements.objectType;
if (Elements.isLocal(receiverElement)) {
narrow(receiverElement, objectType, node);
}
@@ -1148,21 +1149,21 @@
}
@override
- T visitIs(Send node, Node expression, DartType type, _) {
+ T visitIs(Send node, Node expression, ResolutionDartType type, _) {
potentiallyAddIsCheck(node);
visit(expression);
return types.boolType;
}
@override
- T visitIsNot(Send node, Node expression, DartType type, _) {
+ T visitIsNot(Send node, Node expression, ResolutionDartType type, _) {
potentiallyAddIsCheck(node);
visit(expression);
return types.boolType;
}
@override
- T visitAs(Send node, Node expression, DartType type, _) {
+ T visitAs(Send node, Node expression, ResolutionDartType type, _) {
T receiverType = visit(expression);
return types.narrowType(receiverType, type);
}
@@ -1360,7 +1361,7 @@
T visitCatchBlock(CatchBlock node) {
Node exception = node.exception;
if (exception != null) {
- DartType type = elements.getType(node.type);
+ ResolutionDartType type = elements.getType(node.type);
T mask = type == null || type.treatAsDynamic || type.isTypeVariable
? types.dynamicType
: types.nonNullSubtype(type.element);
diff --git a/pkg/compiler/lib/src/inferrer/node_tracer.dart b/pkg/compiler/lib/src/inferrer/node_tracer.dart
index 058d36d..72c6965 100644
--- a/pkg/compiler/lib/src/inferrer/node_tracer.dart
+++ b/pkg/compiler/lib/src/inferrer/node_tracer.dart
@@ -113,10 +113,14 @@
bool _wouldBeTooManyUsers(Set users) {
int seenSoFar = analyzedElements.length;
if (seenSoFar + users.length <= MAX_ANALYSIS_COUNT) return false;
- int actualWork = users
- .where((TypeInformation user) => !analyzedElements.contains(user.owner))
- .length;
- return seenSoFar + actualWork > MAX_ANALYSIS_COUNT;
+ int actualWork = 0;
+ for (TypeInformation user in users) {
+ if (!analyzedElements.contains(user.owner)) {
+ actualWork++;
+ if (actualWork > MAX_ANALYSIS_COUNT - seenSoFar) return true;
+ }
+ }
+ return false;
}
void analyze() {
diff --git a/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart b/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
index 1001ce2a..2f7abd5 100644
--- a/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
@@ -10,7 +10,7 @@
import '../compiler.dart' show Compiler;
import '../constants/values.dart' show ConstantValue, IntConstantValue;
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart' show DartType;
+import '../elements/resolution_types.dart' show ResolutionDartType;
import '../elements/elements.dart';
import '../js_backend/backend_helpers.dart';
import '../js_backend/js_backend.dart' as js;
@@ -1735,8 +1735,13 @@
}
@override
- T errorNonConstantConstructorInvoke(ast.NewExpression node, Element element,
- DartType type, ast.NodeList arguments, CallStructure callStructure, _) {
+ T errorNonConstantConstructorInvoke(
+ ast.NewExpression node,
+ Element element,
+ ResolutionDartType type,
+ ast.NodeList arguments,
+ CallStructure callStructure,
+ _) {
return bulkHandleNew(node, _);
}
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
index 3b7884e..7cf3baa 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
@@ -11,7 +11,7 @@
import '../compiler.dart' show Compiler;
import '../constants/expressions.dart' show ConstantExpression;
import '../constants/values.dart';
-import '../dart_types.dart' show DartType;
+import '../elements/resolution_types.dart' show ResolutionDartType;
import '../elements/elements.dart';
import '../js_backend/js_backend.dart' show Annotations, JavaScriptBackend;
import '../resolution/tree_elements.dart' show TreeElementMapping;
@@ -269,7 +269,8 @@
return newType;
}
- TypeInformation narrowType(TypeInformation type, DartType annotation,
+ TypeInformation narrowType(
+ TypeInformation type, ResolutionDartType annotation,
{bool isNullable: true}) {
if (annotation.treatAsDynamic) return type;
if (annotation.isVoid) return nullType;
@@ -858,7 +859,8 @@
if (value != null) {
if (value.isFunction) {
FunctionConstantValue functionConstant = value;
- type = types.allocateClosure(node, functionConstant.element);
+ MethodElement function = functionConstant.element;
+ type = types.allocateClosure(node, function);
} else {
// Although we might find a better type, we have to keep
// the old type around to ensure that we get a complete view
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
index 7cf31f0..7244856 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
@@ -10,7 +10,8 @@
import '../common/names.dart' show Identifiers;
import '../compiler.dart' show Compiler;
import '../constants/values.dart';
-import '../dart_types.dart' show DartType, FunctionType, TypeKind;
+import '../elements/resolution_types.dart'
+ show ResolutionDartType, ResolutionFunctionType, ResolutionTypeKind;
import '../elements/elements.dart';
import '../js_backend/backend.dart';
import '../tree/dartstring.dart' show DartString;
@@ -482,7 +483,7 @@
element.isConstructor);
TypedElement typedElement = element;
var elementType = typedElement.type;
- if (elementType.kind != TypeKind.FUNCTION) {
+ if (elementType.kind != ResolutionTypeKind.FUNCTION) {
return safeType(inferrer);
} else {
return inferrer
@@ -527,7 +528,7 @@
assert(
element.isFunction || element.isGetter || element.isFactoryConstructor);
- FunctionType type = element.type;
+ ResolutionFunctionType type = element.type;
return _narrowType(inferrer.closedWorld, mask, type.returnType);
}
@@ -1725,7 +1726,7 @@
}
TypeMask _narrowType(
- ClosedWorld closedWorld, TypeMask type, DartType annotation,
+ ClosedWorld closedWorld, TypeMask type, ResolutionDartType annotation,
{bool isNullable: true}) {
if (annotation.treatAsDynamic) return type;
if (annotation.isObject) return type;
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index 2ef3e2a..002cf4e 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -26,7 +26,7 @@
import '../constants/expressions.dart';
import '../constants/values.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../deferred_load.dart' show DeferredLoadTask;
import '../dump_info.dart' show DumpInfoTask;
import '../elements/elements.dart';
@@ -409,8 +409,7 @@
/**
* A set of members that are called from subclasses via `super`.
*/
- final Set<FunctionElement> aliasedSuperMembers =
- new Setlet<FunctionElement>();
+ final Set<MethodElement> aliasedSuperMembers = new Setlet<MethodElement>();
List<CompilerTask> get tasks {
List<CompilerTask> result = functionCompiler.tasks;
@@ -757,7 +756,8 @@
/**
* Record that [method] is called from a subclass via `super`.
*/
- bool maybeRegisterAliasedSuperMember(Element member, Selector selector) {
+ bool maybeRegisterAliasedSuperMember(
+ MemberElement member, Selector selector) {
if (!canUseAliasedSuperMember(member, selector)) {
// Invoking a super getter isn't supported, this would require changes to
// compact field descriptors in the emitter.
@@ -790,10 +790,10 @@
/// keyword) which is only allowed for internal libraries or via the typed
/// JavaScriptInterop mechanism which is allowed for user libraries.
@override
- bool isNative(Element element) => nativeData.isNative(element);
+ bool isNative(Entity element) => nativeData.isNative(element);
/// Returns the [NativeBehavior] for calling the native [method].
- native.NativeBehavior getNativeMethodBehavior(FunctionElement method) {
+ native.NativeBehavior getNativeMethodBehavior(MethodElement method) {
return nativeData.getNativeMethodBehavior(method);
}
@@ -1071,7 +1071,7 @@
void computeImpactForCompileTimeConstantInternal(ConstantValue constant,
WorldImpactBuilder impactBuilder, bool isForResolution) {
- DartType type = constant.getType(compiler.commonElements);
+ ResolutionDartType type = constant.getType(compiler.commonElements);
computeImpactForInstantiatedConstantType(type, impactBuilder);
if (constant.isFunction) {
@@ -1098,10 +1098,10 @@
}
void computeImpactForInstantiatedConstantType(
- DartType type, WorldImpactBuilder impactBuilder) {
- DartType instantiatedType =
+ ResolutionDartType type, WorldImpactBuilder impactBuilder) {
+ ResolutionDartType instantiatedType =
type.isFunctionType ? commonElements.functionType : type;
- if (type is InterfaceType) {
+ if (type is ResolutionInterfaceType) {
impactBuilder
.registerTypeUse(new TypeUse.instantiation(instantiatedType));
if (classNeedsRtiField(type.element)) {
@@ -1259,7 +1259,7 @@
return impactBuilder;
}
- void registerInstantiatedType(InterfaceType type) {
+ void registerInstantiatedType(ResolutionInterfaceType type) {
lookupMapAnalysis.registerInstantiatedType(type);
}
@@ -1343,7 +1343,7 @@
}
void registerTypeVariableBoundsSubtypeCheck(
- DartType typeArgument, DartType bound) {
+ ResolutionDartType typeArgument, ResolutionDartType bound) {
rti.registerTypeVariableBoundsSubtypeCheck(typeArgument, bound);
}
@@ -1376,7 +1376,7 @@
ConstantExpression constant = resolver.getConstant(argument);
if (constant != null && constant.kind == ConstantExpressionKind.TYPE) {
TypeConstantExpression typeConstant = constant;
- if (typeConstant.type is InterfaceType) {
+ if (typeConstant.type is ResolutionInterfaceType) {
resolver.registerInstantiatedType(typeConstant.type);
// No native behavior for this call.
return null;
@@ -1592,7 +1592,8 @@
* the resolver with interface types (int, String, ...), and by the SSA
* backend with implementation types (JSInt, JSString, ...).
*/
- CheckedModeHelper getCheckedModeHelper(DartType type, {bool typeCast}) {
+ CheckedModeHelper getCheckedModeHelper(ResolutionDartType type,
+ {bool typeCast}) {
return getCheckedModeHelperInternal(type,
typeCast: typeCast, nativeCheckOnly: false);
}
@@ -1602,7 +1603,8 @@
* check/type cast on [type] at runtime. If no native helper exists for
* [type], [:null:] is returned.
*/
- CheckedModeHelper getNativeCheckedModeHelper(DartType type, {bool typeCast}) {
+ CheckedModeHelper getNativeCheckedModeHelper(ResolutionDartType type,
+ {bool typeCast}) {
return getCheckedModeHelperInternal(type,
typeCast: typeCast, nativeCheckOnly: true);
}
@@ -1611,7 +1613,7 @@
* Returns the checked mode helper for the type check/type cast for [type]. If
* [nativeCheckOnly] is [:true:], only names for native helpers are returned.
*/
- CheckedModeHelper getCheckedModeHelperInternal(DartType type,
+ CheckedModeHelper getCheckedModeHelperInternal(ResolutionDartType type,
{bool typeCast, bool nativeCheckOnly}) {
String name = getCheckedModeHelperNameInternal(type,
typeCast: typeCast, nativeCheckOnly: nativeCheckOnly);
@@ -1621,9 +1623,9 @@
return helper;
}
- String getCheckedModeHelperNameInternal(DartType type,
+ String getCheckedModeHelperNameInternal(ResolutionDartType type,
{bool typeCast, bool nativeCheckOnly}) {
- assert(type.kind != TypeKind.TYPEDEF);
+ assert(type.kind != ResolutionTypeKind.TYPEDEF);
if (type.isMalformed) {
// The same error is thrown for type test and type cast of a malformed
// type so we only need one check method.
@@ -1665,7 +1667,7 @@
element == helpers.jsPositiveIntClass) {
if (nativeCheckOnly) return null;
return typeCast ? 'intTypeCast' : 'intTypeCheck';
- } else if (Elements.isNumberOrStringSupertype(element, commonElements)) {
+ } else if (commonElements.isNumberOrStringSupertype(element)) {
if (nativeCheck) {
return typeCast
? 'numberOrStringSuperNativeTypeCast'
@@ -1675,7 +1677,7 @@
? 'numberOrStringSuperTypeCast'
: 'numberOrStringSuperTypeCheck';
}
- } else if (Elements.isStringOnlySupertype(element, commonElements)) {
+ } else if (commonElements.isStringOnlySupertype(element)) {
if (nativeCheck) {
return typeCast
? 'stringSuperNativeTypeCast'
@@ -1689,7 +1691,7 @@
if (nativeCheckOnly) return null;
return typeCast ? 'listTypeCast' : 'listTypeCheck';
} else {
- if (Elements.isListSupertype(element, commonElements)) {
+ if (commonElements.isListSupertype(element)) {
if (nativeCheck) {
return typeCast
? 'listSuperNativeTypeCast'
@@ -1734,7 +1736,7 @@
* Returns [:true:] if the checking of [type] is performed directly on the
* object and not on an interceptor.
*/
- bool hasDirectCheckFor(DartType type) {
+ bool hasDirectCheckFor(ResolutionDartType type) {
Element element = type.element;
return element == commonElements.stringClass ||
element == commonElements.boolClass ||
@@ -1748,7 +1750,7 @@
element == helpers.jsUnmodifiableArrayClass;
}
- bool mayGenerateInstanceofCheck(DartType type) {
+ bool mayGenerateInstanceofCheck(ResolutionDartType type) {
// We can use an instanceof check for raw types that have no subclass that
// is mixed-in or in an implements clause.
@@ -2021,7 +2023,7 @@
ConstantValue value =
compiler.constants.getConstantValue(metadata.constant);
if (value == null) continue;
- DartType type = value.getType(compiler.commonElements);
+ ResolutionDartType type = value.getType(compiler.commonElements);
if (metaTargetsUsed.contains(type.element)) return true;
}
return false;
@@ -2808,7 +2810,7 @@
bool hasAsCast = false;
bool hasTypeLiteral = false;
for (TypeUse typeUse in worldImpact.typeUses) {
- DartType type = typeUse.type;
+ ResolutionDartType type = typeUse.type;
switch (typeUse.kind) {
case TypeUseKind.INSTANTIATION:
case TypeUseKind.MIRROR_INSTANTIATION:
@@ -2975,7 +2977,8 @@
assert(selector != null);
worldImpact.registerDynamicUse(new DynamicUse(selector, null));
}
- for (InterfaceType instantiatedType in backendImpact.instantiatedTypes) {
+ for (ResolutionInterfaceType instantiatedType
+ in backendImpact.instantiatedTypes) {
backend.registerBackendUse(instantiatedType.element);
worldImpact.registerTypeUse(new TypeUse.instantiation(instantiatedType));
}
@@ -3001,7 +3004,7 @@
}
/// Register [type] as required for the runtime type information system.
- void registerRequiredType(DartType type) {
+ void registerRequiredType(ResolutionDartType type) {
// If [argument] has type variables or is a type variable, this method
// registers a RTI dependency between the class where the type variable is
// defined (that is the enclosing class of the current element being
@@ -3014,7 +3017,7 @@
}
// TODO(johnniwinther): Maybe split this into [onAssertType] and [onTestType].
- void onIsCheck(DartType type, TransformedWorldImpact transformed) {
+ void onIsCheck(ResolutionDartType type, TransformedWorldImpact transformed) {
registerRequiredType(type);
type.computeUnaliased(backend.resolution);
type = type.unaliased;
@@ -3040,7 +3043,7 @@
}
}
}
- if (type is FunctionType) {
+ if (type is ResolutionFunctionType) {
registerBackendImpact(transformed, impacts.functionTypeCheck);
}
if (type.element != null && backend.isNative(type.element)) {
@@ -3048,7 +3051,8 @@
}
}
- void onIsCheckForCodegen(DartType type, TransformedWorldImpact transformed) {
+ void onIsCheckForCodegen(
+ ResolutionDartType type, TransformedWorldImpact transformed) {
type = type.unaliased;
registerBackendImpact(transformed, impacts.typeCheck);
@@ -3091,7 +3095,7 @@
TransformedWorldImpact transformed = new TransformedWorldImpact(impact);
for (TypeUse typeUse in impact.typeUses) {
- DartType type = typeUse.type;
+ ResolutionDartType type = typeUse.type;
switch (typeUse.kind) {
case TypeUseKind.INSTANTIATION:
backend.lookupMapAnalysis.registerInstantiatedType(type);
@@ -3108,7 +3112,7 @@
backend.addCompileTimeConstantForEmission(constant);
}
- for (Pair<DartType, DartType> check
+ for (Pair<ResolutionDartType, ResolutionDartType> check
in impact.typeVariableBoundsSubtypeChecks) {
backend.registerTypeVariableBoundsSubtypeCheck(check.a, check.b);
}
@@ -3271,7 +3275,12 @@
}
@override
- bool isNative(Element element) {
+ bool isNativeClass(ClassElement element) {
+ return helpers.backend.isNative(element);
+ }
+
+ @override
+ bool isNativeMember(MemberElement element) {
return helpers.backend.isNative(element);
}
}
diff --git a/pkg/compiler/lib/src/js_backend/backend_helpers.dart b/pkg/compiler/lib/src/js_backend/backend_helpers.dart
index 6967ca8..3d7944e 100644
--- a/pkg/compiler/lib/src/js_backend/backend_helpers.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_helpers.dart
@@ -25,6 +25,7 @@
import '../library_loader.dart' show LoadedLibraries;
import '../universe/call_structure.dart' show CallStructure;
import '../universe/selector.dart' show Selector;
+import 'constant_system_javascript.dart';
import 'js_backend.dart';
/// Helper classes and functions for the JavaScript backend.
@@ -112,9 +113,9 @@
MethodElement jsArrayRemoveLast;
MethodElement jsArrayAdd;
MethodElement jsStringSplit;
- Element jsStringToString;
- Element jsStringOperatorAdd;
- Element objectEquals;
+ MethodElement jsStringToString;
+ MethodElement jsStringOperatorAdd;
+ MethodElement objectEquals;
ClassElement typeLiteralClass;
ClassElement mapLiteralClass;
@@ -181,7 +182,7 @@
ClassElement _symbolImplementationClass;
ClassElement get symbolImplementationClass {
- return _symbolImplementationClass ??= find(internalLibrary, 'Symbol');
+ return _symbolImplementationClass ??= _find(internalLibrary, 'Symbol');
}
final Selector symbolValidatedConstructorSelector =
@@ -202,12 +203,14 @@
}
// TODO(johnniwinther): Make these private.
- // TODO(johnniwinther): Split into findHelperFunction and findHelperClass and
- // add a check that the element has the expected kind.
- Element findHelper(String name) => find(jsHelperLibrary, name);
- Element findAsyncHelper(String name) => find(asyncLibrary, name);
- Element findInterceptor(String name) => find(interceptorsLibrary, name);
- Element find(LibraryElement library, String name) {
+ // TODO(johnniwinther): Split into _findHelperFunction and _findHelperClass
+ // and add a check that the element has the expected kind.
+ Element _findHelper(String name) => _find(jsHelperLibrary, name);
+ FunctionElement _findHelperFunction(String name) =>
+ _find(jsHelperLibrary, name);
+ Element _findAsyncHelper(String name) => _find(asyncLibrary, name);
+ Element _findInterceptor(String name) => _find(interceptorsLibrary, name);
+ Element _find(LibraryElement library, String name) {
Element element = library.implementation.findLocal(name);
assert(invariant(library, element != null,
message: "Element '$name' not found in '${library.canonicalUri}'."));
@@ -245,7 +248,7 @@
void initializeHelperClasses(DiagnosticReporter reporter) {
final List missingHelperClasses = [];
ClassElement lookupHelperClass(String name) {
- ClassElement result = findHelper(name);
+ ClassElement result = _findHelper(name);
if (result == null) {
missingHelperClasses.add(name);
}
@@ -267,11 +270,11 @@
Uri uri = library.canonicalUri;
FunctionElement findMethod(String name) {
- return find(library, name);
+ return _find(library, name);
}
ClassElement findClass(String name) {
- return find(library, name);
+ return _find(library, name);
}
if (uri == DART_INTERCEPTORS) {
@@ -302,10 +305,10 @@
jsMutableIndexableClass = findClass('JSMutableIndexable');
} else if (uri == DART_JS_HELPER) {
initializeHelperClasses(reporter);
- assertTest = findHelper('assertTest');
- assertThrow = findHelper('assertThrow');
- assertHelper = findHelper('assertHelper');
- assertUnreachableMethod = findHelper('assertUnreachable');
+ assertTest = _findHelper('assertTest');
+ assertThrow = _findHelper('assertThrow');
+ assertHelper = _findHelper('assertHelper');
+ assertUnreachableMethod = _findHelper('assertUnreachable');
typeLiteralClass = findClass('TypeImpl');
constMapLiteralClass = findClass('ConstantMap');
@@ -323,21 +326,21 @@
requiresPreambleMarker = findMethod('requiresPreamble');
} else if (uri == DART_JS_MIRRORS) {
- disableTreeShakingMarker = find(library, 'disableTreeShaking');
- preserveMetadataMarker = find(library, 'preserveMetadata');
- preserveUrisMarker = find(library, 'preserveUris');
- preserveLibraryNamesMarker = find(library, 'preserveLibraryNames');
+ disableTreeShakingMarker = _find(library, 'disableTreeShaking');
+ preserveMetadataMarker = _find(library, 'preserveMetadata');
+ preserveUrisMarker = _find(library, 'preserveUris');
+ preserveLibraryNamesMarker = _find(library, 'preserveLibraryNames');
} else if (uri == DART_JS_NAMES) {
- preserveNamesMarker = find(library, 'preserveNames');
+ preserveNamesMarker = _find(library, 'preserveNames');
} else if (uri == DART_EMBEDDED_NAMES) {
- jsGetNameEnum = find(library, 'JsGetName');
- jsBuiltinEnum = find(library, 'JsBuiltin');
+ jsGetNameEnum = _find(library, 'JsGetName');
+ jsBuiltinEnum = _find(library, 'JsBuiltin');
} else if (uri == Uris.dart__native_typed_data) {
typedArrayClass = findClass('NativeTypedArray');
typedArrayOfIntClass = findClass('NativeTypedArrayOfInt');
} else if (uri == PACKAGE_JS) {
- jsAnnotationClass = find(library, 'JS');
- jsAnonymousClass = find(library, '_Anonymous');
+ jsAnnotationClass = _find(library, 'JS');
+ jsAnonymousClass = _find(library, '_Anonymous');
}
}
@@ -463,23 +466,23 @@
}
Element get badMain {
- return findHelper('badMain');
+ return _findHelper('badMain');
}
Element get missingMain {
- return findHelper('missingMain');
+ return _findHelper('missingMain');
}
Element get mainHasTooManyParameters {
- return findHelper('mainHasTooManyParameters');
+ return _findHelper('mainHasTooManyParameters');
}
MethodElement get loadLibraryWrapper {
- return findHelper("_loadLibraryWrapper");
+ return _findHelper("_loadLibraryWrapper");
}
Element get boolConversionCheck {
- return findHelper('boolConversionCheck');
+ return _findHelper('boolConversionCheck');
}
MethodElement _traceHelper;
@@ -491,148 +494,148 @@
}
MethodElement get _consoleTraceHelper {
- return findHelper('consoleTraceHelper');
+ return _findHelper('consoleTraceHelper');
}
MethodElement get _postTraceHelper {
- return findHelper('postTraceHelper');
+ return _findHelper('postTraceHelper');
}
- FunctionElement get closureFromTearOff {
- return findHelper('closureFromTearOff');
+ MethodElement get closureFromTearOff {
+ return _findHelper('closureFromTearOff');
}
Element get isJsIndexable {
- return findHelper('isJsIndexable');
+ return _findHelper('isJsIndexable');
}
- Element get throwIllegalArgumentException {
- return findHelper('iae');
+ MethodElement get throwIllegalArgumentException {
+ return _findHelper('iae');
}
- Element get throwIndexOutOfRangeException {
- return findHelper('ioore');
+ MethodElement get throwIndexOutOfRangeException {
+ return _findHelper('ioore');
}
Element get exceptionUnwrapper {
- return findHelper('unwrapException');
+ return _findHelper('unwrapException');
}
Element get throwRuntimeError {
- return findHelper('throwRuntimeError');
+ return _findHelper('throwRuntimeError');
}
Element get throwTypeError {
- return findHelper('throwTypeError');
+ return _findHelper('throwTypeError');
}
Element get throwAbstractClassInstantiationError {
- return findHelper('throwAbstractClassInstantiationError');
+ return _findHelper('throwAbstractClassInstantiationError');
}
Element get checkConcurrentModificationError {
if (cachedCheckConcurrentModificationError == null) {
cachedCheckConcurrentModificationError =
- findHelper('checkConcurrentModificationError');
+ _findHelper('checkConcurrentModificationError');
}
return cachedCheckConcurrentModificationError;
}
- Element get throwConcurrentModificationError {
- return findHelper('throwConcurrentModificationError');
+ MethodElement get throwConcurrentModificationError {
+ return _findHelper('throwConcurrentModificationError');
}
- Element get checkInt => _checkInt ??= findHelper('checkInt');
+ Element get checkInt => _checkInt ??= _findHelper('checkInt');
Element _checkInt;
- Element get checkNum => _checkNum ??= findHelper('checkNum');
+ Element get checkNum => _checkNum ??= _findHelper('checkNum');
Element _checkNum;
- Element get checkString => _checkString ??= findHelper('checkString');
+ Element get checkString => _checkString ??= _findHelper('checkString');
Element _checkString;
- Element get stringInterpolationHelper {
- return findHelper('S');
+ MethodElement get stringInterpolationHelper {
+ return _findHelper('S');
}
- Element get wrapExceptionHelper {
- return findHelper(r'wrapException');
+ MethodElement get wrapExceptionHelper {
+ return _findHelper(r'wrapException');
}
- Element get throwExpressionHelper {
- return findHelper('throwExpression');
+ MethodElement get throwExpressionHelper {
+ return _findHelper('throwExpression');
}
Element get closureConverter {
- return findHelper('convertDartClosureToJS');
+ return _findHelper('convertDartClosureToJS');
}
Element get traceFromException {
- return findHelper('getTraceFromException');
+ return _findHelper('getTraceFromException');
}
Element get setRuntimeTypeInfo {
- return findHelper('setRuntimeTypeInfo');
+ return _findHelper('setRuntimeTypeInfo');
}
Element get getRuntimeTypeInfo {
- return findHelper('getRuntimeTypeInfo');
+ return _findHelper('getRuntimeTypeInfo');
}
- Element get getTypeArgumentByIndex {
- return findHelper('getTypeArgumentByIndex');
+ MethodElement get getTypeArgumentByIndex {
+ return _findHelper('getTypeArgumentByIndex');
}
Element get computeSignature {
- return findHelper('computeSignature');
+ return _findHelper('computeSignature');
}
Element get getRuntimeTypeArguments {
- return findHelper('getRuntimeTypeArguments');
+ return _findHelper('getRuntimeTypeArguments');
}
- Element get getRuntimeTypeArgument {
- return findHelper('getRuntimeTypeArgument');
+ MethodElement get getRuntimeTypeArgument {
+ return _findHelper('getRuntimeTypeArgument');
}
Element get runtimeTypeToString {
- return findHelper('runtimeTypeToString');
+ return _findHelper('runtimeTypeToString');
}
Element get assertIsSubtype {
- return findHelper('assertIsSubtype');
+ return _findHelper('assertIsSubtype');
}
Element get checkSubtype {
- return findHelper('checkSubtype');
+ return _findHelper('checkSubtype');
}
Element get assertSubtype {
- return findHelper('assertSubtype');
+ return _findHelper('assertSubtype');
}
Element get subtypeCast {
- return findHelper('subtypeCast');
+ return _findHelper('subtypeCast');
}
Element get checkSubtypeOfRuntimeType {
- return findHelper('checkSubtypeOfRuntimeType');
+ return _findHelper('checkSubtypeOfRuntimeType');
}
Element get assertSubtypeOfRuntimeType {
- return findHelper('assertSubtypeOfRuntimeType');
+ return _findHelper('assertSubtypeOfRuntimeType');
}
Element get subtypeOfRuntimeTypeCast {
- return findHelper('subtypeOfRuntimeTypeCast');
+ return _findHelper('subtypeOfRuntimeTypeCast');
}
Element get checkDeferredIsLoaded {
- return findHelper('checkDeferredIsLoaded');
+ return _findHelper('checkDeferredIsLoaded');
}
Element get throwNoSuchMethod {
- return findHelper('throwNoSuchMethod');
+ return _findHelper('throwNoSuchMethod');
}
Element get genericNoSuchMethod =>
@@ -648,75 +651,75 @@
MethodElement _malformedTypeError;
Element get createRuntimeType {
- return findHelper('createRuntimeType');
+ return _findHelper('createRuntimeType');
}
Element get fallThroughError {
- return findHelper("getFallThroughError");
+ return _findHelper("getFallThroughError");
}
Element get createInvocationMirror {
- return findHelper('createInvocationMirror');
+ return _findHelper('createInvocationMirror');
}
Element get cyclicThrowHelper {
- return findHelper("throwCyclicInit");
+ return _findHelper("throwCyclicInit");
}
Element get asyncHelper {
- return findAsyncHelper("_asyncHelper");
+ return _findAsyncHelper("_asyncHelper");
}
Element get wrapBody {
- return findAsyncHelper("_wrapJsFunctionForAsync");
+ return _findAsyncHelper("_wrapJsFunctionForAsync");
}
Element get yieldStar {
- ClassElement classElement = findAsyncHelper("_IterationMarker");
+ ClassElement classElement = _findAsyncHelper("_IterationMarker");
classElement.ensureResolved(resolution);
return classElement.lookupLocalMember("yieldStar");
}
Element get yieldSingle {
- ClassElement classElement = findAsyncHelper("_IterationMarker");
+ ClassElement classElement = _findAsyncHelper("_IterationMarker");
classElement.ensureResolved(resolution);
return classElement.lookupLocalMember("yieldSingle");
}
Element get syncStarUncaughtError {
- ClassElement classElement = findAsyncHelper("_IterationMarker");
+ ClassElement classElement = _findAsyncHelper("_IterationMarker");
classElement.ensureResolved(resolution);
return classElement.lookupLocalMember("uncaughtError");
}
Element get asyncStarHelper {
- return findAsyncHelper("_asyncStarHelper");
+ return _findAsyncHelper("_asyncStarHelper");
}
Element get streamOfController {
- return findAsyncHelper("_streamOfController");
+ return _findAsyncHelper("_streamOfController");
}
Element get endOfIteration {
- ClassElement classElement = findAsyncHelper("_IterationMarker");
+ ClassElement classElement = _findAsyncHelper("_IterationMarker");
classElement.ensureResolved(resolution);
return classElement.lookupLocalMember("endOfIteration");
}
Element get syncStarIterable {
- ClassElement classElement = findAsyncHelper("_SyncStarIterable");
+ ClassElement classElement = _findAsyncHelper("_SyncStarIterable");
classElement.ensureResolved(resolution);
return classElement;
}
Element get futureImplementation {
- ClassElement classElement = findAsyncHelper('_Future');
+ ClassElement classElement = _findAsyncHelper('_Future');
classElement.ensureResolved(resolution);
return classElement;
}
Element get controllerStream {
- ClassElement classElement = findAsyncHelper("_ControllerStream");
+ ClassElement classElement = _findAsyncHelper("_ControllerStream");
classElement.ensureResolved(resolution);
return classElement;
}
@@ -728,13 +731,13 @@
}
Element get syncCompleterConstructor {
- ClassElement classElement = find(asyncLibrary, "Completer");
+ ClassElement classElement = _find(asyncLibrary, "Completer");
classElement.ensureResolved(resolution);
return classElement.lookupConstructor("sync");
}
Element get asyncStarController {
- ClassElement classElement = findAsyncHelper("_AsyncStarStreamController");
+ ClassElement classElement = _findAsyncHelper("_AsyncStarStreamController");
classElement.ensureResolved(resolution);
return classElement;
}
@@ -745,65 +748,90 @@
}
Element get streamIteratorConstructor {
- ClassElement classElement = find(asyncLibrary, "StreamIterator");
+ ClassElement classElement = _find(asyncLibrary, "StreamIterator");
classElement.ensureResolved(resolution);
return classElement.lookupConstructor("");
}
ClassElement get VoidRuntimeType {
- return findHelper('VoidRuntimeType');
+ return _findHelper('VoidRuntimeType');
}
ClassElement get RuntimeType {
- return findHelper('RuntimeType');
+ return _findHelper('RuntimeType');
}
ClassElement get RuntimeFunctionType {
- return findHelper('RuntimeFunctionType');
+ return _findHelper('RuntimeFunctionType');
}
ClassElement get RuntimeTypePlain {
- return findHelper('RuntimeTypePlain');
+ return _findHelper('RuntimeTypePlain');
}
ClassElement get RuntimeTypeGeneric {
- return findHelper('RuntimeTypeGeneric');
+ return _findHelper('RuntimeTypeGeneric');
}
ClassElement get DynamicRuntimeType {
- return findHelper('DynamicRuntimeType');
+ return _findHelper('DynamicRuntimeType');
+ }
+
+ MethodElement get getDynamicRuntimeType {
+ // TODO(johnniwinther): Support this in mocks.
+ return jsHelperLibrary.find('getDynamicRuntimeType');
+ }
+
+ MethodElement get getVoidRuntimeType {
+ // TODO(johnniwinther): Support this in mocks.
+ return jsHelperLibrary.find('getVoidRuntimeType');
+ }
+
+ MethodElement get buildInterfaceType {
+ // TODO(johnniwinther): Support this in mocks.
+ return jsHelperLibrary.find('buildInterfaceType');
+ }
+
+ MethodElement get buildFunctionType {
+ // TODO(johnniwinther): Support this in mocks.
+ return jsHelperLibrary.find('buildFunctionType');
+ }
+
+ MethodElement get buildNamedFunctionType {
+ // TODO(johnniwinther): Support this in mocks.
+ return jsHelperLibrary.find('buildNamedFunctionType');
}
MethodElement get functionTypeTestMetaHelper {
- return findHelper('functionTypeTestMetaHelper');
+ return _findHelper('functionTypeTestMetaHelper');
}
MethodElement get defineProperty {
- return findHelper('defineProperty');
+ return _findHelper('defineProperty');
}
Element get startRootIsolate {
- return find(isolateHelperLibrary, START_ROOT_ISOLATE);
+ return _find(isolateHelperLibrary, START_ROOT_ISOLATE);
}
Element get currentIsolate {
- return find(isolateHelperLibrary, '_currentIsolate');
+ return _find(isolateHelperLibrary, '_currentIsolate');
}
Element get callInIsolate {
- return find(isolateHelperLibrary, '_callInIsolate');
+ return _find(isolateHelperLibrary, '_callInIsolate');
}
Element get findIndexForNativeSubclassType {
- return findInterceptor('findIndexForNativeSubclassType');
+ return _findInterceptor('findIndexForNativeSubclassType');
}
- Element get convertRtiToRuntimeType {
- return findHelper('convertRtiToRuntimeType');
+ MethodElement get convertRtiToRuntimeType {
+ return _findHelper('convertRtiToRuntimeType');
}
ClassElement get stackTraceClass {
- return findHelper('_StackTrace');
+ return _findHelper('_StackTrace');
}
MethodElement _objectNoSuchMethod;
@@ -815,4 +843,33 @@
}
return _objectNoSuchMethod;
}
+
+ ClassElement get constantMapClass =>
+ _findHelper(JavaScriptMapConstant.DART_CLASS);
+ ClassElement get constantStringMapClass =>
+ _findHelper(JavaScriptMapConstant.DART_STRING_CLASS);
+ ClassElement get constantProtoMapClass =>
+ _findHelper(JavaScriptMapConstant.DART_PROTO_CLASS);
+ ClassElement get generalConstantMapClass =>
+ _findHelper(JavaScriptMapConstant.DART_GENERAL_CLASS);
+
+ ClassElement get annotationCreatesClass {
+ return _findHelper('Creates');
+ }
+
+ ClassElement get annotationReturnsClass {
+ return _findHelper('Returns');
+ }
+
+ ClassElement get annotationJSNameClass {
+ return _findHelper('JSName');
+ }
+
+ MethodElement get toStringForNativeObject {
+ return _findHelper('toStringForNativeObject');
+ }
+
+ MethodElement get hashCodeForNativeObject {
+ return _findHelper('hashCodeForNativeObject');
+ }
}
diff --git a/pkg/compiler/lib/src/js_backend/backend_impact.dart b/pkg/compiler/lib/src/js_backend/backend_impact.dart
index 2a3244c..be5e9cf 100644
--- a/pkg/compiler/lib/src/js_backend/backend_impact.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_impact.dart
@@ -7,7 +7,7 @@
import '../common/names.dart';
import '../compiler.dart' show Compiler;
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart' show InterfaceType;
+import '../elements/resolution_types.dart' show ResolutionInterfaceType;
import '../elements/elements.dart' show ClassElement, Element;
import '../universe/selector.dart';
import '../util/enumset.dart';
@@ -26,7 +26,7 @@
final List<Element> staticUses;
final List<Element> globalUses;
final List<Selector> dynamicUses;
- final List<InterfaceType> instantiatedTypes;
+ final List<ResolutionInterfaceType> instantiatedTypes;
final List<ClassElement> instantiatedClasses;
final List<ClassElement> globalClasses;
final List<BackendImpact> otherImpacts;
@@ -36,7 +36,7 @@
{this.staticUses: const <Element>[],
this.globalUses: const <Element>[],
this.dynamicUses: const <Selector>[],
- this.instantiatedTypes: const <InterfaceType>[],
+ this.instantiatedTypes: const <ResolutionInterfaceType>[],
this.instantiatedClasses: const <ClassElement>[],
this.globalClasses: const <ClassElement>[],
this.otherImpacts: const <BackendImpact>[],
@@ -269,19 +269,12 @@
BackendImpact _constantMapLiteral;
BackendImpact get constantMapLiteral {
- if (_constantMapLiteral == null) {
- ClassElement find(String name) {
- return helpers.find(helpers.jsHelperLibrary, name);
- }
-
- _constantMapLiteral = new BackendImpact(instantiatedClasses: [
- find(JavaScriptMapConstant.DART_CLASS),
- find(JavaScriptMapConstant.DART_PROTO_CLASS),
- find(JavaScriptMapConstant.DART_STRING_CLASS),
- find(JavaScriptMapConstant.DART_GENERAL_CLASS)
- ]);
- }
- return _constantMapLiteral;
+ return _constantMapLiteral ??= new BackendImpact(instantiatedClasses: [
+ helpers.constantMapClass,
+ helpers.constantProtoMapClass,
+ helpers.constantStringMapClass,
+ helpers.generalConstantMapClass,
+ ]);
}
BackendImpact _symbolConstructor;
diff --git a/pkg/compiler/lib/src/js_backend/backend_serialization.dart b/pkg/compiler/lib/src/js_backend/backend_serialization.dart
index 523f188..834daae 100644
--- a/pkg/compiler/lib/src/js_backend/backend_serialization.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_serialization.dart
@@ -5,7 +5,7 @@
library js_backend.serialization;
import '../common/backend_api.dart' show BackendSerialization;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../js/js.dart' as js;
import '../native/native.dart';
@@ -156,7 +156,7 @@
static const int SPECIAL_TYPE = 2;
static int getTypeKind(var type) {
- if (type is DartType) {
+ if (type is ResolutionDartType) {
// TODO(johnniwinther): Remove this when annotation are no longer resolved
// to this-types.
if (type is GenericType &&
@@ -169,8 +169,8 @@
return SPECIAL_TYPE;
}
- /// Returns a list of the non-this-type [DartType]s in [types].
- static List<DartType> filterDartTypes(List types) {
+ /// Returns a list of the non-this-type [ResolutionDartType]s in [types].
+ static List<ResolutionDartType> filterDartTypes(List types) {
return types.where((type) => getTypeKind(type) == NORMAL_TYPE).toList();
}
diff --git a/pkg/compiler/lib/src/js_backend/checked_mode_helpers.dart b/pkg/compiler/lib/src/js_backend/checked_mode_helpers.dart
index 38e0070..818f82c 100644
--- a/pkg/compiler/lib/src/js_backend/checked_mode_helpers.dart
+++ b/pkg/compiler/lib/src/js_backend/checked_mode_helpers.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import '../compiler.dart' show Compiler;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../js/js.dart' as jsAst;
import '../js/js.dart' show js;
@@ -20,8 +20,10 @@
StaticUse getStaticUse(Compiler compiler) {
JavaScriptBackend backend = compiler.backend;
+ // TODO(johnniwinther): Refactor this to avoid looking up directly in the
+ // js helper library but instead access helpers directly on backend helpers.
return new StaticUse.staticInvoke(
- backend.helpers.findHelper(name), callStructure);
+ backend.helpers.jsHelperLibrary.find(name), callStructure);
}
CallStructure get callStructure => CallStructure.ONE_ARG;
@@ -89,7 +91,8 @@
void generateAdditionalArguments(SsaCodeGenerator codegen,
HTypeConversion node, List<jsAst.Expression> arguments) {
- ErroneousElement element = node.typeExpression.element;
+ MalformedType type = node.typeExpression;
+ ErroneousElement element = type.element;
arguments.add(js.escapedString(element.message));
}
}
@@ -101,7 +104,7 @@
void generateAdditionalArguments(SsaCodeGenerator codegen,
HTypeConversion node, List<jsAst.Expression> arguments) {
- DartType type = node.typeExpression;
+ ResolutionDartType type = node.typeExpression;
jsAst.Name additionalArgument = codegen.backend.namer.operatorIsType(type);
arguments.add(js.quoteName(additionalArgument));
}
@@ -127,7 +130,7 @@
void generateAdditionalArguments(SsaCodeGenerator codegen,
HTypeConversion node, List<jsAst.Expression> arguments) {
- DartType type = node.typeExpression;
+ ResolutionDartType type = node.typeExpression;
Element element = type.element;
jsAst.Name isField = codegen.backend.namer.operatorIs(element);
arguments.add(js.quoteName(isField));
diff --git a/pkg/compiler/lib/src/js_backend/constant_emitter.dart b/pkg/compiler/lib/src/js_backend/constant_emitter.dart
index 31bcccb..15787e7 100644
--- a/pkg/compiler/lib/src/js_backend/constant_emitter.dart
+++ b/pkg/compiler/lib/src/js_backend/constant_emitter.dart
@@ -5,7 +5,7 @@
import '../common.dart';
import '../compiler.dart' show Compiler;
import '../constants/values.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../io/code_output.dart';
import '../js/js.dart' as jsAst;
@@ -269,7 +269,7 @@
@override
jsAst.Expression visitType(TypeConstantValue constant, [_]) {
- DartType type = constant.representedType;
+ ResolutionDartType type = constant.representedType;
jsAst.Name typeName = namer.runtimeTypeName(type.element);
return new jsAst.Call(getHelperProperty(backend.helpers.createRuntimeType),
[js.quoteName(typeName)]);
@@ -323,8 +323,8 @@
}
jsAst.Expression maybeAddTypeArguments(
- InterfaceType type, jsAst.Expression value) {
- if (type is InterfaceType &&
+ ResolutionInterfaceType type, jsAst.Expression value) {
+ if (type is ResolutionInterfaceType &&
!type.treatAsRaw &&
backend.classNeedsRti(type.element)) {
return new jsAst.Call(
@@ -334,8 +334,8 @@
return value;
}
- jsAst.Expression _reifiedTypeArguments(InterfaceType type) {
- jsAst.Expression unexpected(TypeVariableType variable) {
+ jsAst.Expression _reifiedTypeArguments(ResolutionInterfaceType type) {
+ jsAst.Expression unexpected(ResolutionTypeVariableType variable) {
reporter.internalError(
NO_LOCATION_SPANNABLE,
"Unexpected type variable '${variable.getStringAsDeclared(null)}'"
@@ -345,7 +345,7 @@
List<jsAst.Expression> arguments = <jsAst.Expression>[];
RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder;
- for (DartType argument in type.typeArguments) {
+ for (ResolutionDartType argument in type.typeArguments) {
arguments.add(rtiEncoder.getTypeRepresentation(argument, unexpected));
}
return new jsAst.ArrayInitializer(arguments);
diff --git a/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart b/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
index ee445b3..43e516b 100644
--- a/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
+++ b/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
@@ -9,7 +9,7 @@
import '../constants/constant_system.dart';
import '../constants/values.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart' show ClassElement, FieldElement;
import '../tree/dartstring.dart' show DartString, LiteralDartString;
import 'js_backend.dart';
@@ -298,12 +298,13 @@
NullConstantValue createNull() => new NullConstantValue();
@override
- ListConstantValue createList(InterfaceType type, List<ConstantValue> values) {
+ ListConstantValue createList(
+ ResolutionInterfaceType type, List<ConstantValue> values) {
return new ListConstantValue(type, values);
}
@override
- ConstantValue createType(Compiler compiler, DartType type) {
+ ConstantValue createType(Compiler compiler, ResolutionDartType type) {
return new TypeConstantValue(
type,
compiler.backend.backendClasses.typeImplementation
@@ -329,7 +330,7 @@
bool isBool(ConstantValue constant) => constant.isBool;
bool isNull(ConstantValue constant) => constant.isNull;
- bool isSubtype(DartTypes types, DartType s, DartType t) {
+ bool isSubtype(DartTypes types, ResolutionDartType s, ResolutionDartType t) {
// At runtime, an integer is both an integer and a double: the
// integer type check is Math.floor, which will return true only
// for real integers, and our double type check is 'typeof number'
@@ -341,8 +342,11 @@
return types.isSubtype(s, t);
}
- MapConstantValue createMap(Compiler compiler, InterfaceType sourceType,
- List<ConstantValue> keys, List<ConstantValue> values) {
+ MapConstantValue createMap(
+ Compiler compiler,
+ ResolutionInterfaceType sourceType,
+ List<ConstantValue> keys,
+ List<ConstantValue> values) {
JavaScriptBackend backend = compiler.backend;
CommonElements commonElements = compiler.commonElements;
@@ -363,26 +367,25 @@
}
bool hasProtoKey = (protoValue != null);
- DartType keysType;
+ ResolutionDartType keysType;
if (sourceType.treatAsRaw) {
keysType = commonElements.listType();
} else {
keysType = commonElements.listType(sourceType.typeArguments.first);
}
ListConstantValue keysList = new ListConstantValue(keysType, keys);
- String className = onlyStringKeys
+ ClassElement classElement = onlyStringKeys
? (hasProtoKey
- ? JavaScriptMapConstant.DART_PROTO_CLASS
- : JavaScriptMapConstant.DART_STRING_CLASS)
- : JavaScriptMapConstant.DART_GENERAL_CLASS;
- ClassElement classElement = backend.helpers.jsHelperLibrary.find(className);
+ ? backend.helpers.constantProtoMapClass
+ : backend.helpers.constantStringMapClass)
+ : backend.helpers.generalConstantMapClass;
classElement.ensureResolved(compiler.resolution);
- List<DartType> typeArgument = sourceType.typeArguments;
- InterfaceType type;
+ List<ResolutionDartType> typeArgument = sourceType.typeArguments;
+ ResolutionInterfaceType type;
if (sourceType.treatAsRaw) {
type = classElement.rawType;
} else {
- type = new InterfaceType(classElement, typeArgument);
+ type = new ResolutionInterfaceType(classElement, typeArgument);
}
return new JavaScriptMapConstant(
type, keysList, values, protoValue, onlyStringKeys);
@@ -393,7 +396,7 @@
// TODO(johnniwinther): Create a backend agnostic value.
JavaScriptBackend backend = compiler.backend;
ClassElement symbolClass = backend.helpers.symbolImplementationClass;
- InterfaceType type = symbolClass.rawType;
+ ResolutionInterfaceType type = symbolClass.rawType;
ConstantValue argument = createString(new DartString.literal(text));
Map<FieldElement, ConstantValue> fields = <FieldElement, ConstantValue>{};
symbolClass.forEachInstanceField(
@@ -428,7 +431,7 @@
final ConstantValue protoValue;
final bool onlyStringKeys;
- JavaScriptMapConstant(InterfaceType type, ListConstantValue keyList,
+ JavaScriptMapConstant(ResolutionInterfaceType type, ListConstantValue keyList,
List<ConstantValue> values, this.protoValue, this.onlyStringKeys)
: this.keyList = keyList,
super(type, keyList.entries, values);
diff --git a/pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart b/pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart
index d87ffa3..a89b86d 100644
--- a/pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart
+++ b/pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart
@@ -4,7 +4,7 @@
import '../compiler.dart' show Compiler;
import '../constants/values.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../enqueue.dart' show Enqueuer;
import '../universe/use.dart' show StaticUse;
@@ -86,7 +86,7 @@
joinFor(forResolution: forResolution).instantiatedClasses.add(classElement);
}
- void registerTypeLiteral(DartType type) {
+ void registerTypeLiteral(ResolutionDartType type) {
if (type.isInterfaceType) {
// TODO(sra): If we had a flow query from the type literal expression to
// the Type argument of the metadata lookup, we could tell if this type
@@ -189,7 +189,7 @@
}
TypeConstantValue makeTypeConstant(ClassElement element) {
- DartType elementType = element.rawType;
+ ResolutionDartType elementType = element.rawType;
return backend.constantSystem.createType(compiler, elementType);
}
diff --git a/pkg/compiler/lib/src/js_backend/enqueuer.dart b/pkg/compiler/lib/src/js_backend/enqueuer.dart
index 55fda27..65759e5 100644
--- a/pkg/compiler/lib/src/js_backend/enqueuer.dart
+++ b/pkg/compiler/lib/src/js_backend/enqueuer.dart
@@ -13,7 +13,8 @@
import '../common/work.dart' show WorkItem;
import '../common.dart';
import '../compiler.dart' show Compiler;
-import '../dart_types.dart' show DartType, InterfaceType;
+import '../elements/resolution_types.dart'
+ show ResolutionDartType, ResolutionInterfaceType;
import '../elements/elements.dart' show Entity, MemberElement, TypedElement;
import '../elements/entities.dart';
import '../enqueue.dart';
@@ -105,7 +106,7 @@
impactSource, worldImpact, _impactVisitor, impactUse);
}
- void _registerInstantiatedType(InterfaceType type,
+ void _registerInstantiatedType(ResolutionInterfaceType type,
{bool mirrorUsage: false, bool nativeUsage: false}) {
task.measure(() {
_universe.registerTypeInstantiation(type, _applyClassUse,
@@ -183,7 +184,7 @@
}
void processTypeUse(TypeUse typeUse) {
- DartType type = typeUse.type;
+ ResolutionDartType type = typeUse.type;
switch (typeUse.kind) {
case TypeUseKind.INSTANTIATION:
_registerInstantiatedType(type);
@@ -209,7 +210,7 @@
}
}
- void _registerIsCheck(DartType type) {
+ void _registerIsCheck(ResolutionDartType type) {
type = _universe.registerIsCheck(type);
// Even in checked mode, type annotations for return type and argument
// types do not imply type checks, so there should never be a check
diff --git a/pkg/compiler/lib/src/js_backend/js_interop_analysis.dart b/pkg/compiler/lib/src/js_backend/js_interop_analysis.dart
index 3b75b49..a89326b 100644
--- a/pkg/compiler/lib/src/js_backend/js_interop_analysis.dart
+++ b/pkg/compiler/lib/src/js_backend/js_interop_analysis.dart
@@ -8,7 +8,8 @@
import '../common.dart';
import '../constants/values.dart'
show ConstantValue, ConstructedConstantValue, StringConstantValue;
-import '../dart_types.dart' show DartType, DynamicType, FunctionType;
+import '../elements/resolution_types.dart'
+ show ResolutionDartType, ResolutionDynamicType, ResolutionFunctionType;
import '../diagnostics/messages.dart' show MessageKind;
import '../elements/elements.dart'
show
@@ -187,11 +188,13 @@
return new jsAst.Block(statements);
}
- FunctionType buildJsFunctionType() {
+ ResolutionFunctionType buildJsFunctionType() {
// TODO(jacobr): consider using codegenWorld.isChecks to determine the
// range of positional arguments that need to be supported by JavaScript
// function types.
- return new FunctionType.synthesized(const DynamicType(), [],
- new List<DartType>.filled(16, const DynamicType()));
+ return new ResolutionFunctionType.synthesized(
+ const ResolutionDynamicType(),
+ [],
+ new List<ResolutionDartType>.filled(16, const ResolutionDynamicType()));
}
}
diff --git a/pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart b/pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart
index 4a51239..d7bf72e 100644
--- a/pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart
+++ b/pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart
@@ -17,8 +17,8 @@
NullConstantValue,
StringConstantValue,
TypeConstantValue;
-import '../dart_types.dart' show DartType;
-import '../dart_types.dart' show InterfaceType;
+import '../elements/resolution_types.dart' show ResolutionDartType;
+import '../elements/resolution_types.dart' show ResolutionInterfaceType;
import '../elements/elements.dart'
show ClassElement, FieldElement, LibraryElement, VariableElement;
import '../universe/use.dart' show StaticUse;
@@ -264,7 +264,7 @@
}
/// Callback from the enqueuer, invoked when [type] is instantiated.
- void registerInstantiatedType(InterfaceType type) {
+ void registerInstantiatedType(ResolutionInterfaceType type) {
if (!_isEnabled || !_inCodegen) return;
// TODO(sigmund): only add if .runtimeType is ever used
_addClassUse(type.element);
@@ -274,10 +274,10 @@
/// Records generic type arguments in [type], in case they are retrieved and
/// returned using a type-argument expression.
- void _addGenerics(InterfaceType type) {
+ void _addGenerics(ResolutionInterfaceType type) {
if (!type.isGeneric) return;
for (var arg in type.typeArguments) {
- if (arg is InterfaceType) {
+ if (arg is ResolutionInterfaceType) {
_addClassUse(arg.element);
// Note: this call was needed to generate correct code for
// type_lookup_map/generic_type_test
@@ -431,7 +431,7 @@
/// Restores [original] to contain all of the entries marked as possibly used.
void _prepareForEmission() {
ListConstantValue originalEntries = original.fields[analysis.entriesField];
- DartType listType = originalEntries.type;
+ ResolutionDartType listType = originalEntries.type;
List<ConstantValue> keyValuePairs = <ConstantValue>[];
usedEntries.forEach((key, value) {
keyValuePairs.add(key);
diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart
index 717cbc6..c5b70b8 100644
--- a/pkg/compiler/lib/src/js_backend/namer.dart
+++ b/pkg/compiler/lib/src/js_backend/namer.dart
@@ -14,7 +14,7 @@
import '../compiler.dart' show Compiler;
import '../constants/values.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../diagnostics/invariant.dart' show DEBUG_MODE;
import '../elements/elements.dart';
import '../elements/entities.dart';
@@ -1369,7 +1369,7 @@
/// this.super$A$foo(); // super.foo()
/// }
///
- jsAst.Name aliasedSuperMemberPropertyName(Element member) {
+ jsAst.Name aliasedSuperMemberPropertyName(MemberElement member) {
assert(!member.isField); // Fields do not need super aliases.
return _disambiguateInternalMember(member, () {
String invocationName = operatorNameToIdentifier(member.name);
@@ -1475,18 +1475,18 @@
String get functionTypeNamedParametersTag => r'named';
- Map<FunctionType, jsAst.Name> functionTypeNameMap =
- new HashMap<FunctionType, jsAst.Name>();
+ Map<ResolutionFunctionType, jsAst.Name> functionTypeNameMap =
+ new HashMap<ResolutionFunctionType, jsAst.Name>();
final FunctionTypeNamer functionTypeNamer;
- jsAst.Name getFunctionTypeName(FunctionType functionType) {
+ jsAst.Name getFunctionTypeName(ResolutionFunctionType functionType) {
return functionTypeNameMap.putIfAbsent(functionType, () {
String proposedName = functionTypeNamer.computeName(functionType);
return getFreshName(instanceScope, proposedName);
});
}
- jsAst.Name operatorIsType(DartType type) {
+ jsAst.Name operatorIsType(ResolutionDartType type) {
if (type.isFunctionType) {
// TODO(erikcorry): Reduce from $isx to ix when we are minifying.
return new CompoundName([
@@ -1792,7 +1792,7 @@
// Generates something like 'Type_String_k8F', using the simple name of the
// type and a hash to disambiguate the same name in different libraries.
addRoot('Type');
- DartType type = constant.representedType;
+ ResolutionDartType type = constant.representedType;
String name = type.element?.name;
if (name == null) {
// e.g. DartType 'dynamic' has no element.
@@ -1914,7 +1914,7 @@
@override
int visitType(TypeConstantValue constant, [_]) {
- DartType type = constant.representedType;
+ ResolutionDartType type = constant.representedType;
// This name includes the library name and type parameters.
String name = rtiEncoder.getTypeRepresentationForTypeConstant(type);
return _hashString(4, name);
@@ -2028,33 +2028,33 @@
FunctionTypeNamer(this.rtiEncoder);
- String computeName(DartType type) {
+ String computeName(ResolutionDartType type) {
sb = new StringBuffer();
visit(type);
return sb.toString();
}
- visit(DartType type, [_]) {
+ visit(ResolutionDartType type, [_]) {
type.accept(this, null);
}
- visitType(DartType type, _) {
+ visitType(ResolutionDartType type, _) {
sb.write(type.name);
}
- visitFunctionType(FunctionType type, _) {
+ visitFunctionType(ResolutionFunctionType type, _) {
if (rtiEncoder.isSimpleFunctionType(type)) {
sb.write('args${type.parameterTypes.length}');
return;
}
visit(type.returnType);
sb.write('_');
- for (DartType parameter in type.parameterTypes) {
+ for (ResolutionDartType parameter in type.parameterTypes) {
sb.write('_');
visit(parameter);
}
bool first = false;
- for (DartType parameter in type.optionalParameterTypes) {
+ for (ResolutionDartType parameter in type.optionalParameterTypes) {
if (!first) {
sb.write('_');
}
@@ -2064,7 +2064,7 @@
}
if (!type.namedParameterTypes.isEmpty) {
first = false;
- for (DartType parameter in type.namedParameterTypes) {
+ for (ResolutionDartType parameter in type.namedParameterTypes) {
if (!first) {
sb.write('_');
}
diff --git a/pkg/compiler/lib/src/js_backend/native_data.dart b/pkg/compiler/lib/src/js_backend/native_data.dart
index 31fe7d6..e30010d 100644
--- a/pkg/compiler/lib/src/js_backend/native_data.dart
+++ b/pkg/compiler/lib/src/js_backend/native_data.dart
@@ -6,7 +6,13 @@
import '../common.dart';
import '../elements/elements.dart'
- show ClassElement, Element, FieldElement, FunctionElement, MemberElement;
+ show
+ ClassElement,
+ Element,
+ Entity,
+ FieldElement,
+ FunctionElement,
+ MemberElement;
import '../native/behavior.dart' show NativeBehavior;
/// Additional element information for native classes and methods and js-interop
@@ -102,7 +108,10 @@
/// Computes the name for [element] to use in the generated JavaScript. This
/// is either given through a native annotation or a js interop annotation.
- String getFixedBackendName(Element element) {
+ String getFixedBackendName(Entity entity) {
+ // TODO(johnniwinther): Remove this assignment from [Entity] to [Element]
+ // when `.declaration` is no longer needed.
+ Element element = entity;
String name = nativeMemberName[element.declaration];
if (name == null && isJsInterop(element)) {
// If an element isJsInterop but _isJsInterop is false that means it is
diff --git a/pkg/compiler/lib/src/js_backend/patch_resolver.dart b/pkg/compiler/lib/src/js_backend/patch_resolver.dart
index 358dcf8..f7477fe 100644
--- a/pkg/compiler/lib/src/js_backend/patch_resolver.dart
+++ b/pkg/compiler/lib/src/js_backend/patch_resolver.dart
@@ -8,7 +8,7 @@
import '../common/resolution.dart' show Resolution;
import '../common/tasks.dart' show CompilerTask;
import '../compiler.dart' show Compiler;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart';
import '../tree/tree.dart';
@@ -54,8 +54,10 @@
assert(invariant(origin, originParameter.patch == patchParameter,
message: "Inconsistent repatch of $originParameter."));
}
- DartType originParameterType = originParameter.computeType(resolution);
- DartType patchParameterType = patchParameter.computeType(resolution);
+ ResolutionDartType originParameterType =
+ originParameter.computeType(resolution);
+ ResolutionDartType patchParameterType =
+ patchParameter.computeType(resolution);
if (originParameterType != patchParameterType) {
reporter.reportError(
reporter.createMessage(
diff --git a/pkg/compiler/lib/src/js_backend/runtime_types.dart b/pkg/compiler/lib/src/js_backend/runtime_types.dart
index dcf964b..08f0dcb 100644
--- a/pkg/compiler/lib/src/js_backend/runtime_types.dart
+++ b/pkg/compiler/lib/src/js_backend/runtime_types.dart
@@ -13,8 +13,9 @@
Iterable<ClassElement> get classes;
}
-typedef jsAst.Expression OnVariableCallback(TypeVariableType variable);
-typedef bool ShouldEncodeTypedefCallback(TypedefType variable);
+typedef jsAst.Expression OnVariableCallback(
+ ResolutionTypeVariableType variable);
+typedef bool ShouldEncodeTypedefCallback(ResolutionTypedefType variable);
// TODO(johnniwinther): Rename to something like [RuntimeTypeUsageCollector]
// we semantics is more clear.
@@ -30,7 +31,7 @@
void registerClassUsingTypeVariableExpression(ClassElement cls);
void registerRtiDependency(Element element, Element dependency);
void registerTypeVariableBoundsSubtypeCheck(
- DartType typeArgument, DartType bound);
+ ResolutionDartType typeArgument, ResolutionDartType bound);
Set<ClassElement> getClassesUsedInSubstitutions(
JavaScriptBackend backend, TypeChecks checks);
@@ -51,7 +52,7 @@
/// Return all classes that are referenced in the type of the function, i.e.,
/// in the return type or the argument types.
- Set<ClassElement> getReferencedClasses(FunctionType type);
+ Set<ClassElement> getReferencedClasses(ResolutionFunctionType type);
/// Return all classes that are uses a type arguments.
Set<ClassElement> getRequiredArgumentClasses(JavaScriptBackend backend);
@@ -60,9 +61,9 @@
Substitution getSubstitution(ClassElement cls, ClassElement other);
- static bool hasTypeArguments(DartType type) {
- if (type is InterfaceType) {
- InterfaceType interfaceType = type;
+ static bool hasTypeArguments(ResolutionDartType type) {
+ if (type is ResolutionInterfaceType) {
+ ResolutionInterfaceType interfaceType = type;
return !interfaceType.treatAsRaw;
}
return false;
@@ -70,12 +71,13 @@
}
abstract class RuntimeTypesEncoder {
- bool isSimpleFunctionType(FunctionType type);
+ bool isSimpleFunctionType(ResolutionFunctionType type);
- jsAst.Expression getSignatureEncoding(DartType type, jsAst.Expression this_);
+ jsAst.Expression getSignatureEncoding(
+ ResolutionDartType type, jsAst.Expression this_);
jsAst.Expression getSubstitutionRepresentation(
- List<DartType> types, OnVariableCallback onVariable);
+ List<ResolutionDartType> types, OnVariableCallback onVariable);
jsAst.Expression getSubstitutionCode(Substitution substitution);
jsAst.Expression getSubstitutionCodeForVariable(
Substitution substitution, int index);
@@ -92,10 +94,10 @@
/// Returns a [jsAst.Expression] representing the given [type]. Type variables
/// are replaced by the [jsAst.Expression] returned by [onVariable].
jsAst.Expression getTypeRepresentation(
- DartType type, OnVariableCallback onVariable,
+ ResolutionDartType type, OnVariableCallback onVariable,
[ShouldEncodeTypedefCallback shouldEncodeTypedef]);
- String getTypeRepresentationForTypeConstant(DartType type);
+ String getTypeRepresentationForTypeConstant(ResolutionDartType type);
}
class _RuntimeTypes implements RuntimeTypes {
@@ -113,9 +115,9 @@
final Set<ClassElement> classesUsingTypeVariableExpression;
// The set of type arguments tested against type variable bounds.
- final Set<DartType> checkedTypeArguments;
+ final Set<ResolutionDartType> checkedTypeArguments;
// The set of tested type variable bounds.
- final Set<DartType> checkedBounds;
+ final Set<ResolutionDartType> checkedBounds;
TypeChecks cachedRequiredChecks;
@@ -127,8 +129,8 @@
methodsNeedingRti = new Set<Element>(),
rtiDependencies = new Map<ClassElement, Set<ClassElement>>(),
classesUsingTypeVariableExpression = new Set<ClassElement>(),
- checkedTypeArguments = new Set<DartType>(),
- checkedBounds = new Set<DartType>();
+ checkedTypeArguments = new Set<ResolutionDartType>(),
+ checkedBounds = new Set<ResolutionDartType>();
Set<ClassElement> directlyInstantiatedArguments;
Set<ClassElement> allInstantiatedArguments;
@@ -150,7 +152,7 @@
@override
void registerTypeVariableBoundsSubtypeCheck(
- DartType typeArgument, DartType bound) {
+ ResolutionDartType typeArgument, ResolutionDartType bound) {
checkedTypeArguments.add(typeArgument);
checkedBounds.add(bound);
}
@@ -175,13 +177,13 @@
// If there are no classes that use their variables in checks, there is
// nothing to do.
if (classesUsingChecks.isEmpty) return;
- Set<DartType> instantiatedTypes = universe.instantiatedTypes;
+ Set<ResolutionDartType> instantiatedTypes = universe.instantiatedTypes;
if (cannotDetermineInstantiatedTypesPrecisely) {
- for (DartType type in instantiatedTypes) {
- if (type.kind != TypeKind.INTERFACE) continue;
- InterfaceType interface = type;
+ for (ResolutionDartType type in instantiatedTypes) {
+ if (type.kind != ResolutionTypeKind.INTERFACE) continue;
+ ResolutionInterfaceType interface = type;
do {
- for (DartType argument in interface.typeArguments) {
+ for (ResolutionDartType argument in interface.typeArguments) {
universe.registerIsCheck(argument);
}
interface = interface.element.supertype;
@@ -193,18 +195,18 @@
// set of is-checks.
// TODO(karlklose): replace this with code that uses a subtype lookup
// datastructure in the world.
- for (DartType type in instantiatedTypes) {
- if (type.kind != TypeKind.INTERFACE) continue;
- InterfaceType classType = type;
+ for (ResolutionDartType type in instantiatedTypes) {
+ if (type.kind != ResolutionTypeKind.INTERFACE) continue;
+ ResolutionInterfaceType classType = type;
for (ClassElement cls in classesUsingChecks) {
- InterfaceType current = classType;
+ ResolutionInterfaceType current = classType;
do {
// We need the type as instance of its superclass anyway, so we just
// try to compute the substitution; if the result is [:null:], the
// classes are not related.
- InterfaceType instance = current.asInstanceOf(cls);
+ ResolutionInterfaceType instance = current.asInstanceOf(cls);
if (instance == null) break;
- for (DartType argument in instance.typeArguments) {
+ for (ResolutionDartType argument in instance.typeArguments) {
universe.registerIsCheck(argument);
}
current = current.element.supertype;
@@ -242,7 +244,7 @@
}
Set<ClassElement> classesUsingTypeVariableTests = new Set<ClassElement>();
- resolverWorld.isChecks.forEach((DartType type) {
+ resolverWorld.isChecks.forEach((ResolutionDartType type) {
if (type.isTypeVariable) {
TypeVariableElement variable = type.element;
// GENERIC_METHODS: When generic method support is complete enough to
@@ -267,9 +269,9 @@
}
// Compute the set of all classes and methods that need runtime type
// information.
- compiler.resolverWorld.isChecks.forEach((DartType type) {
+ compiler.resolverWorld.isChecks.forEach((ResolutionDartType type) {
if (type.isInterfaceType) {
- InterfaceType itf = type;
+ ResolutionInterfaceType itf = type;
if (!itf.treatAsRaw) {
potentiallyAddForRti(itf.element);
}
@@ -283,7 +285,7 @@
}
if (type.isFunctionType) {
void analyzeMethod(TypedElement method) {
- DartType memberType = method.type;
+ ResolutionDartType memberType = method.type;
ClassElement contextClass = Types.getClassContext(memberType);
if (contextClass != null &&
compiler.types.isPotentialSubtype(memberType, type)) {
@@ -301,7 +303,7 @@
});
if (compiler.options.enableTypeAssertions) {
void analyzeMethod(TypedElement method) {
- DartType memberType = method.type;
+ ResolutionDartType memberType = method.type;
ClassElement contextClass = Types.getClassContext(memberType);
if (contextClass != null) {
potentiallyAddForRti(contextClass);
@@ -343,7 +345,7 @@
// and precompute the substitutions for them.
assert(invariant(element, element.allSupertypes != null,
message: 'Supertypes have not been computed for $element.'));
- for (DartType supertype in element.allSupertypes) {
+ for (ResolutionDartType supertype in element.allSupertypes) {
ClassElement superelement = supertype.element;
if (checked.contains(superelement)) {
Substitution substitution =
@@ -356,9 +358,9 @@
}
void computeRequiredChecks() {
- Set<DartType> isChecks = compiler.codegenWorld.isChecks;
+ Set<ResolutionDartType> isChecks = compiler.codegenWorld.isChecks;
// These types are needed for is-checks against function types.
- Set<DartType> instantiatedTypesAndClosures =
+ Set<ResolutionDartType> instantiatedTypesAndClosures =
computeInstantiatedTypesAndClosures(compiler.codegenWorld);
computeInstantiatedArguments(instantiatedTypesAndClosures, isChecks);
computeCheckedArguments(instantiatedTypesAndClosures, isChecks);
@@ -366,14 +368,14 @@
computeChecks(allInstantiatedArguments, checkedArguments);
}
- Set<DartType> computeInstantiatedTypesAndClosures(
+ Set<ResolutionDartType> computeInstantiatedTypesAndClosures(
CodegenWorldBuilder universe) {
- Set<DartType> instantiatedTypes =
- new Set<DartType>.from(universe.instantiatedTypes);
- for (DartType instantiatedType in universe.instantiatedTypes) {
+ Set<ResolutionDartType> instantiatedTypes =
+ new Set<ResolutionDartType>.from(universe.instantiatedTypes);
+ for (ResolutionDartType instantiatedType in universe.instantiatedTypes) {
if (instantiatedType.isInterfaceType) {
- InterfaceType interface = instantiatedType;
- FunctionType callType = interface.callType;
+ ResolutionInterfaceType interface = instantiatedType;
+ ResolutionFunctionType callType = interface.callType;
if (callType != null) {
instantiatedTypes.add(callType);
}
@@ -399,8 +401,8 @@
* have a type check against this supertype that includes a check against
* the type arguments.
*/
- void computeInstantiatedArguments(
- Set<DartType> instantiatedTypes, Set<DartType> isChecks) {
+ void computeInstantiatedArguments(Set<ResolutionDartType> instantiatedTypes,
+ Set<ResolutionDartType> isChecks) {
ArgumentCollector superCollector = new ArgumentCollector(backend);
ArgumentCollector directCollector = new ArgumentCollector(backend);
FunctionArgumentCollector functionArgumentCollector =
@@ -408,8 +410,8 @@
// We need to add classes occuring in function type arguments, like for
// instance 'I' for [: o is C<f> :] where f is [: typedef I f(); :].
- void collectFunctionTypeArguments(Iterable<DartType> types) {
- for (DartType type in types) {
+ void collectFunctionTypeArguments(Iterable<ResolutionDartType> types) {
+ for (ResolutionDartType type in types) {
functionArgumentCollector.collect(type);
}
}
@@ -417,13 +419,13 @@
collectFunctionTypeArguments(isChecks);
collectFunctionTypeArguments(checkedBounds);
- void collectTypeArguments(Iterable<DartType> types,
+ void collectTypeArguments(Iterable<ResolutionDartType> types,
{bool isTypeArgument: false}) {
- for (DartType type in types) {
+ for (ResolutionDartType type in types) {
directCollector.collect(type, isTypeArgument: isTypeArgument);
if (type.isInterfaceType) {
ClassElement cls = type.element;
- for (DartType supertype in cls.allSupertypes) {
+ for (ResolutionDartType supertype in cls.allSupertypes) {
superCollector.collect(supertype, isTypeArgument: isTypeArgument);
}
}
@@ -434,7 +436,7 @@
collectTypeArguments(checkedTypeArguments, isTypeArgument: true);
for (ClassElement cls in superCollector.classes.toList()) {
- for (DartType supertype in cls.allSupertypes) {
+ for (ResolutionDartType supertype in cls.allSupertypes) {
superCollector.collect(supertype);
}
}
@@ -446,8 +448,8 @@
}
/// Collects all type arguments used in is-checks.
- void computeCheckedArguments(
- Set<DartType> instantiatedTypes, Set<DartType> isChecks) {
+ void computeCheckedArguments(Set<ResolutionDartType> instantiatedTypes,
+ Set<ResolutionDartType> isChecks) {
ArgumentCollector collector = new ArgumentCollector(backend);
FunctionArgumentCollector functionArgumentCollector =
new FunctionArgumentCollector(backend);
@@ -455,8 +457,8 @@
// We need to add types occuring in function type arguments, like for
// instance 'J' for [: (J j) {} is f :] where f is
// [: typedef void f(I i); :] and 'J' is a subtype of 'I'.
- void collectFunctionTypeArguments(Iterable<DartType> types) {
- for (DartType type in types) {
+ void collectFunctionTypeArguments(Iterable<ResolutionDartType> types) {
+ for (ResolutionDartType type in types) {
functionArgumentCollector.collect(type);
}
}
@@ -464,9 +466,9 @@
collectFunctionTypeArguments(instantiatedTypes);
collectFunctionTypeArguments(checkedTypeArguments);
- void collectTypeArguments(Iterable<DartType> types,
+ void collectTypeArguments(Iterable<ResolutionDartType> types,
{bool isTypeArgument: false}) {
- for (DartType type in types) {
+ for (ResolutionDartType type in types) {
collector.collect(type, isTypeArgument: isTypeArgument);
}
}
@@ -508,7 +510,7 @@
}
@override
- Set<ClassElement> getReferencedClasses(FunctionType type) {
+ Set<ClassElement> getReferencedClasses(ResolutionFunctionType type) {
FunctionArgumentCollector collector =
new FunctionArgumentCollector(backend);
collector.collect(type);
@@ -529,8 +531,8 @@
return true;
}
- InterfaceType originalType = cls.thisType;
- InterfaceType type = originalType.asInstanceOf(check);
+ ResolutionInterfaceType originalType = cls.thisType;
+ ResolutionInterfaceType type = originalType.asInstanceOf(check);
// [type] is not a subtype of [check]. we do not generate a check and do not
// need a substitution.
if (type == null) return true;
@@ -538,8 +540,8 @@
// Run through both lists of type variables and check if the type variables
// are identical at each position. If they are not, we need to calculate a
// substitution function.
- List<DartType> variables = cls.typeVariables;
- List<DartType> arguments = type.typeArguments;
+ List<ResolutionDartType> variables = cls.typeVariables;
+ List<ResolutionDartType> arguments = type.typeArguments;
if (variables.length != arguments.length) {
return false;
}
@@ -571,9 +573,9 @@
// Unnamed mixin application classes do not need substitutions, because they
// are never instantiated and their checks are overwritten by the class that
// they are mixed into.
- InterfaceType type = cls.thisType;
- InterfaceType target = type.asInstanceOf(check);
- List<DartType> typeVariables = cls.typeVariables;
+ ResolutionInterfaceType type = cls.thisType;
+ ResolutionInterfaceType target = type.asInstanceOf(check);
+ List<ResolutionDartType> typeVariables = cls.typeVariables;
if (typeVariables.isEmpty && !alwaysGenerateFunction) {
return new Substitution.list(target.typeArguments);
} else {
@@ -609,7 +611,7 @@
@override
jsAst.Expression getTypeRepresentation(
- DartType type, OnVariableCallback onVariable,
+ ResolutionDartType type, OnVariableCallback onVariable,
[ShouldEncodeTypedefCallback shouldEncodeTypedef]) {
// GENERIC_METHODS: When generic method support is complete enough to
// include a runtime value for method type variables this must be updated.
@@ -619,17 +621,18 @@
@override
jsAst.Expression getSubstitutionRepresentation(
- List<DartType> types, OnVariableCallback onVariable) {
+ List<ResolutionDartType> types, OnVariableCallback onVariable) {
List<jsAst.Expression> elements = types
- .map((DartType type) => getTypeRepresentation(type, onVariable))
+ .map((ResolutionDartType type) =>
+ getTypeRepresentation(type, onVariable))
.toList(growable: false);
return new jsAst.ArrayInitializer(elements);
}
- jsAst.Expression getTypeEncoding(DartType type,
+ jsAst.Expression getTypeEncoding(ResolutionDartType type,
{bool alwaysGenerateFunction: false}) {
ClassElement contextClass = Types.getClassContext(type);
- jsAst.Expression onVariable(TypeVariableType v) {
+ jsAst.Expression onVariable(ResolutionTypeVariableType v) {
return new jsAst.VariableUse(v.name);
}
@@ -648,7 +651,8 @@
}
@override
- jsAst.Expression getSignatureEncoding(DartType type, jsAst.Expression this_) {
+ jsAst.Expression getSignatureEncoding(
+ ResolutionDartType type, jsAst.Expression this_) {
ClassElement contextClass = Types.getClassContext(type);
jsAst.Expression encoding =
getTypeEncoding(type, alwaysGenerateFunction: true);
@@ -682,15 +686,16 @@
*/
@override
jsAst.Expression getSubstitutionCode(Substitution substitution) {
- jsAst.Expression declaration(TypeVariableType variable) {
+ jsAst.Expression declaration(ResolutionTypeVariableType variable) {
return new jsAst.Parameter(getVariableName(variable.name));
}
- jsAst.Expression use(TypeVariableType variable) {
+ jsAst.Expression use(ResolutionTypeVariableType variable) {
return new jsAst.VariableUse(getVariableName(variable.name));
}
- if (substitution.arguments.every((DartType type) => type.isDynamic)) {
+ if (substitution.arguments
+ .every((ResolutionDartType type) => type.isDynamic)) {
return backend.emitter.emitter.generateFunctionThatReturnsNull();
} else {
jsAst.Expression value =
@@ -708,11 +713,11 @@
@override
jsAst.Expression getSubstitutionCodeForVariable(
Substitution substitution, int index) {
- jsAst.Expression declaration(TypeVariableType variable) {
+ jsAst.Expression declaration(ResolutionTypeVariableType variable) {
return new jsAst.Parameter(getVariableName(variable.name));
}
- jsAst.Expression use(TypeVariableType variable) {
+ jsAst.Expression use(ResolutionTypeVariableType variable) {
return new jsAst.VariableUse(getVariableName(variable.name));
}
@@ -736,14 +741,14 @@
backend.namer.internalGlobal('functionThatReturnsNull');
@override
- String getTypeRepresentationForTypeConstant(DartType type) {
+ String getTypeRepresentationForTypeConstant(ResolutionDartType type) {
JavaScriptBackend backend = compiler.backend;
Namer namer = backend.namer;
if (type.isDynamic) return "dynamic";
String name = namer.uniqueNameForTypeConstantElement(type.element);
if (!type.element.isClass) return name;
- InterfaceType interface = type;
- List<DartType> variables = interface.element.typeVariables;
+ ResolutionInterfaceType interface = type;
+ List<ResolutionDartType> variables = interface.element.typeVariables;
// Type constants can currently only be raw types, so there is no point
// adding ground-term type parameters, as they would just be 'dynamic'.
// TODO(sra): Since the result string is used only in constructing constant
@@ -755,11 +760,11 @@
}
@override
- bool isSimpleFunctionType(FunctionType type) {
+ bool isSimpleFunctionType(ResolutionFunctionType type) {
if (!type.returnType.isDynamic) return false;
if (!type.optionalParameterTypes.isEmpty) return false;
if (!type.namedParameterTypes.isEmpty) return false;
- for (DartType parameter in type.parameterTypes) {
+ for (ResolutionDartType parameter in type.parameterTypes) {
if (!parameter.isDynamic) return false;
}
return true;
@@ -782,12 +787,13 @@
* the type representation for type variables.
*/
jsAst.Expression getTypeRepresentation(
- DartType type,
+ ResolutionDartType type,
OnVariableCallback onVariable,
ShouldEncodeTypedefCallback encodeTypedef) {
this.onVariable = onVariable;
- this.shouldEncodeTypedef =
- (encodeTypedef != null) ? encodeTypedef : (TypedefType type) => false;
+ this.shouldEncodeTypedef = (encodeTypedef != null)
+ ? encodeTypedef
+ : (ResolutionTypedefType type) => false;
jsAst.Expression representation = visit(type);
this.onVariable = null;
this.shouldEncodeTypedef = null;
@@ -799,27 +805,28 @@
}
@override
- visit(DartType type, [_]) => type.accept(this, null);
+ visit(ResolutionDartType type, [_]) => type.accept(this, null);
- visitTypeVariableType(TypeVariableType type, _) {
+ visitTypeVariableType(ResolutionTypeVariableType type, _) {
return onVariable(type);
}
- visitDynamicType(DynamicType type, _) {
+ visitDynamicType(ResolutionDynamicType type, _) {
return js('null');
}
- visitInterfaceType(InterfaceType type, _) {
+ visitInterfaceType(ResolutionInterfaceType type, _) {
jsAst.Expression name = getJavaScriptClassName(type.element);
return type.treatAsRaw ? name : visitList(type.typeArguments, head: name);
}
- jsAst.Expression visitList(List<DartType> types, {jsAst.Expression head}) {
+ jsAst.Expression visitList(List<ResolutionDartType> types,
+ {jsAst.Expression head}) {
List<jsAst.Expression> elements = <jsAst.Expression>[];
if (head != null) {
elements.add(head);
}
- for (DartType type in types) {
+ for (ResolutionDartType type in types) {
jsAst.Expression element = visit(type);
if (element is jsAst.LiteralNull) {
elements.add(new jsAst.ArrayHole());
@@ -845,7 +852,7 @@
.expressionTemplateFor('{ ${namer.functionTypeTag}: "dynafunc" }');
}
- visitFunctionType(FunctionType type, _) {
+ visitFunctionType(ResolutionFunctionType type, _) {
List<jsAst.Property> properties = <jsAst.Property>[];
void addProperty(String name, jsAst.Expression value) {
@@ -871,7 +878,7 @@
if (!type.namedParameterTypes.isEmpty) {
List<jsAst.Property> namedArguments = <jsAst.Property>[];
List<String> names = type.namedParameters;
- List<DartType> types = type.namedParameterTypes;
+ List<ResolutionDartType> types = type.namedParameterTypes;
assert(types.length == names.length);
for (int index = 0; index < types.length; index++) {
jsAst.Expression name = js.string(names[index]);
@@ -888,14 +895,14 @@
return js('null');
}
- visitVoidType(VoidType type, _) {
+ visitVoidType(ResolutionVoidType type, _) {
// TODO(ahe): Reify void type ("null" means "dynamic").
return js('null');
}
- visitTypedefType(TypedefType type, _) {
+ visitTypedefType(ResolutionTypedefType type, _) {
bool shouldEncode = shouldEncodeTypedef(type);
- DartType unaliasedType = type.unaliased;
+ ResolutionDartType unaliasedType = type.unaliased;
if (shouldEncode) {
jsAst.ObjectInitializer initializer = unaliasedType.accept(this, null);
// We have to encode the aliased type.
@@ -946,28 +953,28 @@
ArgumentCollector(this.backend);
- collect(DartType type, {bool isTypeArgument: false}) {
+ collect(ResolutionDartType type, {bool isTypeArgument: false}) {
visit(type, isTypeArgument);
}
/// Collect all types in the list as if they were arguments of an
/// InterfaceType.
- collectAll(List<DartType> types) {
- for (DartType type in types) {
+ collectAll(List<ResolutionDartType> types) {
+ for (ResolutionDartType type in types) {
visit(type, true);
}
}
- visitTypedefType(TypedefType type, bool isTypeArgument) {
+ visitTypedefType(ResolutionTypedefType type, bool isTypeArgument) {
type.unaliased.accept(this, isTypeArgument);
}
- visitInterfaceType(InterfaceType type, bool isTypeArgument) {
+ visitInterfaceType(ResolutionInterfaceType type, bool isTypeArgument) {
if (isTypeArgument) classes.add(type.element);
type.visitChildren(this, true);
}
- visitFunctionType(FunctionType type, _) {
+ visitFunctionType(ResolutionFunctionType type, _) {
type.visitChildren(this, true);
}
}
@@ -978,30 +985,30 @@
FunctionArgumentCollector(this.backend);
- collect(DartType type) {
+ collect(ResolutionDartType type) {
visit(type, false);
}
/// Collect all types in the list as if they were arguments of an
/// InterfaceType.
- collectAll(Link<DartType> types) {
- for (DartType type in types) {
+ collectAll(Link<ResolutionDartType> types) {
+ for (ResolutionDartType type in types) {
visit(type, true);
}
}
- visitTypedefType(TypedefType type, bool inFunctionType) {
+ visitTypedefType(ResolutionTypedefType type, bool inFunctionType) {
type.unaliased.accept(this, inFunctionType);
}
- visitInterfaceType(InterfaceType type, bool inFunctionType) {
+ visitInterfaceType(ResolutionInterfaceType type, bool inFunctionType) {
if (inFunctionType) {
classes.add(type.element);
}
type.visitChildren(this, inFunctionType);
}
- visitFunctionType(FunctionType type, _) {
+ visitFunctionType(ResolutionFunctionType type, _) {
type.visitChildren(this, true);
}
}
@@ -1018,12 +1025,12 @@
//TODO(floitsch): Remove support for non-function substitutions.
class Substitution {
final bool isFunction;
- final List<DartType> arguments;
- final List<DartType> parameters;
+ final List<ResolutionDartType> arguments;
+ final List<ResolutionDartType> parameters;
Substitution.list(this.arguments)
: isFunction = false,
- parameters = const <DartType>[];
+ parameters = const <ResolutionDartType>[];
Substitution.function(this.arguments, this.parameters) : isFunction = true;
}
diff --git a/pkg/compiler/lib/src/js_backend/type_variable_handler.dart b/pkg/compiler/lib/src/js_backend/type_variable_handler.dart
index a32a3b5..898e910 100644
--- a/pkg/compiler/lib/src/js_backend/type_variable_handler.dart
+++ b/pkg/compiler/lib/src/js_backend/type_variable_handler.dart
@@ -6,7 +6,7 @@
import '../compiler.dart' show Compiler;
import '../constants/expressions.dart';
import '../constants/values.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../enqueue.dart' show Enqueuer;
import '../js/js.dart' as jsAst;
@@ -101,10 +101,10 @@
// Do not process classes twice.
if (_typeVariables.containsKey(cls)) return;
- InterfaceType typeVariableType = _typeVariableClass.thisType;
+ ResolutionInterfaceType typeVariableType = _typeVariableClass.thisType;
List<jsAst.Expression> constants = <jsAst.Expression>[];
- for (TypeVariableType currentTypeVariable in cls.typeVariables) {
+ for (ResolutionTypeVariableType currentTypeVariable in cls.typeVariables) {
TypeVariableElement typeVariableElement = currentTypeVariable.element;
jsAst.Expression boundIndex =
diff --git a/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart b/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
index 9c39229..0cc5b97 100644
--- a/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
+++ b/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
@@ -122,7 +122,7 @@
/// Returns the JS expression representing the type [e].
///
/// The given type [e] might be a Typedef.
- jsAst.Expression typeAccess(Element e) {
+ jsAst.Expression typeAccess(Entity e) {
return emitter.typeAccess(e);
}
@@ -214,7 +214,7 @@
jsAst.Expression interceptorClassAccess(ClassElement e);
/// Returns the JS expression representing the type [e].
- jsAst.Expression typeAccess(Element e);
+ jsAst.Expression typeAccess(Entity e);
/// Returns the JS expression representing a function that returns 'null'
jsAst.Expression generateFunctionThatReturnsNull();
diff --git a/pkg/compiler/lib/src/js_emitter/constant_ordering.dart b/pkg/compiler/lib/src/js_emitter/constant_ordering.dart
index 6baa377..1991726 100644
--- a/pkg/compiler/lib/src/js_emitter/constant_ordering.dart
+++ b/pkg/compiler/lib/src/js_emitter/constant_ordering.dart
@@ -5,8 +5,9 @@
library dart2js.js_emitter.constant_ordering;
import '../constants/values.dart';
-import '../dart_types.dart';
-import '../elements/elements.dart' show Element, Elements, FieldElement;
+import '../elements/elements.dart' show Entity, Elements;
+import '../elements/entities.dart' show FieldEntity;
+import '../elements/resolution_types.dart';
import '../js_backend/js_backend.dart' show SyntheticConstantKind;
import '../tree/dartstring.dart' show DartString;
@@ -44,13 +45,13 @@
return 0;
}
- static int compareElements(Element a, Element b) {
+ static int compareElements(Entity a, Entity b) {
int r = a.name.compareTo(b.name);
if (r != 0) return r;
return Elements.compareByPosition(a, b);
}
- static int compareDartTypes(DartType a, DartType b) {
+ static int compareDartTypes(ResolutionDartType a, ResolutionDartType b) {
if (a == b) return 0;
int r = a.kind.index.compareTo(b.kind.index);
if (r != 0) return r;
@@ -119,8 +120,8 @@
int r = compareDartTypes(a.type, b.type);
if (r != 0) return r;
- List<FieldElement> aFields = a.fields.keys.toList()..sort(compareElements);
- List<FieldElement> bFields = b.fields.keys.toList()..sort(compareElements);
+ List<FieldEntity> aFields = a.fields.keys.toList()..sort(compareElements);
+ List<FieldEntity> bFields = b.fields.keys.toList()..sort(compareElements);
r = compareLists(compareElements, aFields, bFields);
if (r != 0) return r;
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart
index 3f813ad..fa91726 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart
@@ -176,7 +176,7 @@
fieldNameParts.add(new jsAst.LiteralString('-'));
if (fieldElement.isTopLevel ||
backend.isAccessibleByReflection(fieldElement.enclosingClass)) {
- DartType type = fieldElement.type;
+ ResolutionDartType type = fieldElement.type;
fieldNameParts.add(task.metadataCollector.reifyType(type));
}
}
@@ -295,7 +295,7 @@
}
if (backend.isAccessibleByReflection(classElement)) {
- List<DartType> typeVars = classElement.typeVariables;
+ List<ResolutionDartType> typeVars = classElement.typeVariables;
Iterable typeVariableProperties =
emitter.typeVariableHandler.typeVariablesOf(classElement);
@@ -349,7 +349,7 @@
if (classElement.supertype != null) {
types.add(task.metadataCollector.reifyType(classElement.supertype));
}
- for (DartType interface in classElement.interfaces) {
+ for (ResolutionDartType interface in classElement.interfaces) {
types.add(task.metadataCollector.reifyType(interface));
}
// TODO(herhut): Fix use of reflection name here.
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
index c1b7824..298d736 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
@@ -16,7 +16,7 @@
import '../../compiler.dart' show Compiler;
import '../../constants/values.dart';
import '../../core_types.dart' show CommonElements;
-import '../../dart_types.dart' show DartType;
+import '../../elements/resolution_types.dart' show ResolutionDartType;
import '../../deferred_load.dart' show OutputUnit;
import '../../elements/elements.dart'
show
@@ -326,7 +326,7 @@
}
@override
- jsAst.Expression isolateStaticClosureAccess(FunctionElement element) {
+ jsAst.Expression isolateStaticClosureAccess(MethodElement element) {
return jsAst.js('#.#()',
[namer.globalObjectFor(element), namer.staticClosureName(element)]);
}
@@ -1223,7 +1223,7 @@
for (TypedefElement typedef in typedefsNeededForReflection) {
LibraryElement library = typedef.library;
// TODO(karlklose): add a TypedefBuilder and move this code there.
- DartType type = typedef.alias;
+ ResolutionDartType type = typedef.alias;
// TODO(zarah): reify type variables once reflection on type arguments of
// typedefs is supported.
jsAst.Expression typeIndex =
diff --git a/pkg/compiler/lib/src/js_emitter/js_emitter.dart b/pkg/compiler/lib/src/js_emitter/js_emitter.dart
index fb87380..de47054 100644
--- a/pkg/compiler/lib/src/js_emitter/js_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/js_emitter.dart
@@ -16,14 +16,14 @@
import '../compiler.dart' show Compiler;
import '../constants/values.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart'
+import '../elements/resolution_types.dart'
show
- DartType,
- FunctionType,
- InterfaceType,
- TypedefType,
+ ResolutionDartType,
+ ResolutionFunctionType,
+ ResolutionInterfaceType,
+ ResolutionTypedefType,
Types,
- TypeVariableType;
+ ResolutionTypeVariableType;
import '../deferred_load.dart' show OutputUnit;
import '../elements/elements.dart'
show
@@ -31,6 +31,7 @@
ConstructorElement,
Element,
ElementKind,
+ Entity,
FieldElement,
FunctionElement,
FunctionSignature,
diff --git a/pkg/compiler/lib/src/js_emitter/lazy_emitter/model_emitter.dart b/pkg/compiler/lib/src/js_emitter/lazy_emitter/model_emitter.dart
index 8cb0eb1..640bf8a 100644
--- a/pkg/compiler/lib/src/js_emitter/lazy_emitter/model_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/lazy_emitter/model_emitter.dart
@@ -23,7 +23,7 @@
import '../../compiler.dart' show Compiler;
import '../../constants/values.dart' show ConstantValue, FunctionConstantValue;
import '../../core_types.dart' show CommonElements;
-import '../../elements/elements.dart' show ClassElement, FunctionElement;
+import '../../elements/elements.dart' show ClassElement, MethodElement;
import '../../js/js.dart' as js;
import '../../js_backend/js_backend.dart'
show JavaScriptBackend, Namer, ConstantEmitter;
@@ -103,7 +103,7 @@
return deepCompareConstants(a, b);
}
- js.Expression generateStaticClosureAccess(FunctionElement element) {
+ js.Expression generateStaticClosureAccess(MethodElement element) {
return js.js('#.#()',
[namer.globalObjectFor(element), namer.staticClosureName(element)]);
}
diff --git a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
index 94b014a..d625e44 100644
--- a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
+++ b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
@@ -130,8 +130,8 @@
}
/// A map used to canonicalize the entries of types.
- Map<OutputUnit, Map<DartType, _BoundMetadataEntry>> _typesMap =
- <OutputUnit, Map<DartType, _BoundMetadataEntry>>{};
+ Map<OutputUnit, Map<ResolutionDartType, _BoundMetadataEntry>> _typesMap =
+ <OutputUnit, Map<ResolutionDartType, _BoundMetadataEntry>>{};
// To support incremental compilation, we have to be able to eagerly emit
// metadata and add metadata later on. We use the below two counters for
@@ -266,13 +266,15 @@
return _addGlobalMetadata(_emitter.constantReference(constant));
}
- jsAst.Expression reifyType(DartType type, {ignoreTypeVariables: false}) {
+ jsAst.Expression reifyType(ResolutionDartType type,
+ {ignoreTypeVariables: false}) {
return reifyTypeForOutputUnit(
type, _compiler.deferredLoadTask.mainOutputUnit,
ignoreTypeVariables: ignoreTypeVariables);
}
- jsAst.Expression reifyTypeForOutputUnit(DartType type, OutputUnit outputUnit,
+ jsAst.Expression reifyTypeForOutputUnit(
+ ResolutionDartType type, OutputUnit outputUnit,
{ignoreTypeVariables: false}) {
return addTypeInOutputUnit(type, outputUnit,
ignoreTypeVariables: ignoreTypeVariables);
@@ -303,13 +305,13 @@
});
}
- jsAst.Expression _computeTypeRepresentation(DartType type,
+ jsAst.Expression _computeTypeRepresentation(ResolutionDartType type,
{ignoreTypeVariables: false}) {
jsAst.Expression representation =
_backend.rtiEncoder.getTypeRepresentation(type, (variable) {
if (ignoreTypeVariables) return new jsAst.LiteralNull();
return _typeVariableHandler.reifyTypeVariable(variable.element);
- }, (TypedefType typedef) {
+ }, (ResolutionTypedefType typedef) {
return _backend.isAccessibleByReflection(typedef.element);
});
@@ -323,10 +325,12 @@
return representation;
}
- jsAst.Expression addTypeInOutputUnit(DartType type, OutputUnit outputUnit,
+ jsAst.Expression addTypeInOutputUnit(
+ ResolutionDartType type, OutputUnit outputUnit,
{ignoreTypeVariables: false}) {
if (_typesMap[outputUnit] == null) {
- _typesMap[outputUnit] = new Map<DartType, _BoundMetadataEntry>();
+ _typesMap[outputUnit] =
+ new Map<ResolutionDartType, _BoundMetadataEntry>();
}
return _typesMap[outputUnit].putIfAbsent(type, () {
_BoundMetadataEntry result = new _BoundMetadataEntry(
diff --git a/pkg/compiler/lib/src/js_emitter/native_emitter.dart b/pkg/compiler/lib/src/js_emitter/native_emitter.dart
index 1f39802..b782831 100644
--- a/pkg/compiler/lib/src/js_emitter/native_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/native_emitter.dart
@@ -264,11 +264,11 @@
// parameter that was not provided for this stub.
for (jsAst.Parameter stubParameter in stubParameters) {
if (stubParameter.name == name) {
- DartType type = parameter.type.unaliased;
- if (type is FunctionType) {
+ ResolutionDartType type = parameter.type.unaliased;
+ if (type is ResolutionFunctionType) {
// The parameter type is a function type either directly or through
// typedef(s).
- FunctionType functionType = type;
+ ResolutionFunctionType functionType = type;
int arity = functionType.computeArity();
statements.add(js
.statement('# = #(#, $arity)', [name, closureConverter, name]));
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/field_visitor.dart b/pkg/compiler/lib/src/js_emitter/program_builder/field_visitor.dart
index 75ca6f5..5b07be3 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder/field_visitor.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder/field_visitor.dart
@@ -165,7 +165,7 @@
bool canAvoidGeneratedCheckedSetter(VariableElement member) {
// We never generate accessors for top-level/static fields.
if (!member.isInstanceMember) return true;
- DartType type = member.type;
+ ResolutionDartType type = member.type;
return type.treatAsDynamic || type.isObject;
}
}
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
index be27411..0448ef6 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
@@ -11,7 +11,8 @@
import '../../constants/values.dart'
show ConstantValue, InterceptorConstantValue;
import '../../core_types.dart' show CommonElements;
-import '../../dart_types.dart' show DartType, FunctionType, TypedefType;
+import '../../elements/resolution_types.dart'
+ show ResolutionDartType, ResolutionFunctionType, ResolutionTypedefType;
import '../../deferred_load.dart' show DeferredLoadTask, OutputUnit;
import '../../elements/elements.dart'
show
@@ -383,7 +384,7 @@
// Generating stubs for direct calls and stubs for call-through
// of getters that happen to be functions.
bool isFunctionLike = false;
- FunctionType functionType = null;
+ ResolutionFunctionType functionType = null;
if (member.isFunction) {
FunctionElement fn = member;
@@ -391,14 +392,14 @@
} else if (member.isGetter) {
if (_compiler.options.trustTypeAnnotations) {
GetterElement getter = member;
- DartType returnType = getter.type.returnType;
+ ResolutionDartType returnType = getter.type.returnType;
if (returnType.isFunctionType) {
functionType = returnType;
} else if (returnType.treatAsDynamic ||
_compiler.types.isSubtype(
returnType, backend.commonElements.functionType)) {
if (returnType.isTypedef) {
- TypedefType typedef = returnType;
+ ResolutionTypedefType typedef = returnType;
// TODO(jacobr): can we just use typdef.unaliased instead?
functionType = typedef.element.functionSignature.type;
} else {
@@ -761,7 +762,7 @@
callName = namer.invocationName(callSelector);
}
- DartType memberType;
+ ResolutionDartType memberType;
if (element.isGenerativeConstructorBody) {
// TODO(herhut): Why does this need to be normalized away? We never need
// this information anyway as they cannot be torn off or
@@ -801,7 +802,8 @@
functionType: functionType);
}
- js.Expression _generateFunctionType(DartType type, OutputUnit outputUnit) {
+ js.Expression _generateFunctionType(
+ ResolutionDartType type, OutputUnit outputUnit) {
if (type.containsTypeVariables) {
js.Expression thisAccess = js.js(r'this.$receiver');
return backend.rtiEncoder.getSignatureEncoding(type, thisAccess);
@@ -945,7 +947,7 @@
callName = namer.invocationName(callSelector);
}
js.Expression functionType;
- DartType type = element.type;
+ ResolutionDartType type = element.type;
if (needsTearOff || canBeReflected) {
OutputUnit outputUnit =
_compiler.deferredLoadTask.outputUnitForElement(element);
diff --git a/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart b/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart
index c6365ae..362c6c3 100644
--- a/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart
@@ -6,7 +6,7 @@
// Function signatures used in the generation of runtime type information.
typedef void FunctionTypeSignatureEmitter(
- Element method, FunctionType methodType);
+ Element method, ResolutionFunctionType methodType);
typedef void SubstitutionEmitter(Element element, {bool emitNull});
@@ -44,7 +44,7 @@
Iterable<ClassElement> get classesUsingTypeVariableExpression =>
backend.rti.classesUsingTypeVariableExpression;
- Set<FunctionType> get checkedFunctionTypes =>
+ Set<ResolutionFunctionType> get checkedFunctionTypes =>
typeTestRegistry.checkedFunctionTypes;
/// Generates all properties necessary for is-checks on the [classElement].
@@ -75,7 +75,7 @@
}
void generateFunctionTypeSignature(
- FunctionElement method, FunctionType type) {
+ FunctionElement method, ResolutionFunctionType type) {
assert(method.isImplementation);
jsAst.Expression thisAccess = new jsAst.This();
if (!method.isAbstract) {
@@ -217,7 +217,7 @@
}
if (supertypesNeedSubstitutions) {
- for (DartType supertype in cls.allSupertypes) {
+ for (ResolutionDartType supertype in cls.allSupertypes) {
ClassElement superclass = supertype.element;
if (generated.contains(superclass)) continue;
@@ -253,12 +253,13 @@
_generateInterfacesIsTests(commonElements.functionClass,
generateIsTest, generateSubstitution, generated);
}
- FunctionType callType = callFunction.computeType(compiler.resolution);
+ ResolutionFunctionType callType =
+ callFunction.computeType(compiler.resolution);
generateFunctionTypeSignature(callFunction, callType);
}
}
- for (DartType interfaceType in cls.interfaces) {
+ for (ResolutionDartType interfaceType in cls.interfaces) {
_generateInterfacesIsTests(interfaceType.element, generateIsTest,
generateSubstitution, generated);
}
@@ -282,7 +283,7 @@
tryEmitTest(cls);
- for (DartType interfaceType in cls.interfaces) {
+ for (ResolutionDartType interfaceType in cls.interfaces) {
Element element = interfaceType.element;
tryEmitTest(element);
_generateInterfacesIsTests(
@@ -302,7 +303,7 @@
List<StubMethod> stubs = <StubMethod>[];
ClassElement superclass = classElement;
while (superclass != null) {
- for (TypeVariableType parameter in superclass.typeVariables) {
+ for (ResolutionTypeVariableType parameter in superclass.typeVariables) {
if (backend.emitter.readTypeVariables.contains(parameter.element)) {
stubs.add(
_generateTypeVariableReader(classElement, parameter.element));
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
index 8a1bb2a..b84608b 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
@@ -34,7 +34,7 @@
import '../../compiler.dart' show Compiler;
import '../../constants/values.dart' show ConstantValue, FunctionConstantValue;
import '../../core_types.dart' show CommonElements;
-import '../../elements/elements.dart' show ClassElement, FunctionElement;
+import '../../elements/elements.dart' show ClassElement, MethodElement;
import '../../hash/sha1.dart' show Hasher;
import '../../io/code_output.dart';
import '../../io/line_column_provider.dart'
@@ -128,7 +128,7 @@
return deepCompareConstants(a, b);
}
- js.Expression generateStaticClosureAccess(FunctionElement element) {
+ js.Expression generateStaticClosureAccess(MethodElement element) {
return js.js('#.#()',
[namer.globalObjectFor(element), namer.staticClosureName(element)]);
}
diff --git a/pkg/compiler/lib/src/js_emitter/type_test_registry.dart b/pkg/compiler/lib/src/js_emitter/type_test_registry.dart
index 040a4eb..9efbbeb 100644
--- a/pkg/compiler/lib/src/js_emitter/type_test_registry.dart
+++ b/pkg/compiler/lib/src/js_emitter/type_test_registry.dart
@@ -17,7 +17,7 @@
* The set of function types that checked, both explicity through tests of
* typedefs and implicitly through type annotations in checked mode.
*/
- Set<FunctionType> checkedFunctionTypes;
+ Set<ResolutionFunctionType> checkedFunctionTypes;
/// Initially contains all classes that need RTI. After
/// [computeNeededClasses]
@@ -29,8 +29,8 @@
Iterable<ClassElement> get classesUsingTypeVariableTests {
if (cachedClassesUsingTypeVariableTests == null) {
cachedClassesUsingTypeVariableTests = compiler.codegenWorld.isChecks
- .where((DartType t) => t is TypeVariableType)
- .map((TypeVariableType v) => v.element.enclosingClass)
+ .where((ResolutionDartType t) => t is ResolutionTypeVariableType)
+ .map((ResolutionTypeVariableType v) => v.element.enclosingClass)
.toList();
}
return cachedClassesUsingTypeVariableTests;
@@ -92,7 +92,7 @@
// 3. Add classes that contain checked generic function types. These are
// needed to store the signature encoding.
- for (FunctionType type in checkedFunctionTypes) {
+ for (ResolutionFunctionType type in checkedFunctionTypes) {
ClassElement contextClass = Types.getClassContext(type);
if (contextClass != null) {
rtiNeededClasses.add(contextClass);
@@ -128,7 +128,7 @@
backend.generatedCode.keys.where((element) {
return canBeReflectedAsFunction(element) && canBeReified(element);
}).forEach((FunctionElement function) {
- DartType type = function.type;
+ ResolutionDartType type = function.type;
for (ClassElement cls in backend.rti.getReferencedClasses(type)) {
while (cls != null) {
rtiNeededClasses.add(cls);
@@ -147,11 +147,11 @@
compiler.codegenWorld, classesUsingTypeVariableTests);
checkedClasses = new Set<ClassElement>();
- checkedFunctionTypes = new Set<FunctionType>();
- compiler.codegenWorld.isChecks.forEach((DartType t) {
- if (t is InterfaceType) {
+ checkedFunctionTypes = new Set<ResolutionFunctionType>();
+ compiler.codegenWorld.isChecks.forEach((ResolutionDartType t) {
+ if (t is ResolutionInterfaceType) {
checkedClasses.add(t.element);
- } else if (t is FunctionType) {
+ } else if (t is ResolutionFunctionType) {
checkedFunctionTypes.add(t);
}
});
diff --git a/pkg/compiler/lib/src/kernel/constant_visitor.dart b/pkg/compiler/lib/src/kernel/constant_visitor.dart
index 0d1e1a6..3d0405d 100644
--- a/pkg/compiler/lib/src/kernel/constant_visitor.dart
+++ b/pkg/compiler/lib/src/kernel/constant_visitor.dart
@@ -94,7 +94,8 @@
@override
ir.Node visitConcatenate(ConcatenateConstantExpression exp, Kernel kernel) {
- throw new UnimplementedError('${exp.toStructuredText()} is not supported.');
+ return new ir.StringConcatenation(
+ exp.expressions.map((e) => visit(e, kernel)).toList());
}
@override
diff --git a/pkg/compiler/lib/src/kernel/error.dart b/pkg/compiler/lib/src/kernel/error.dart
index 464112f..df2daaf 100644
--- a/pkg/compiler/lib/src/kernel/error.dart
+++ b/pkg/compiler/lib/src/kernel/error.dart
@@ -4,7 +4,7 @@
import 'package:kernel/ast.dart' as ir;
-import "../dart_types.dart" show DartType;
+import "../elements/resolution_types.dart" show ResolutionDartType;
import "../elements/elements.dart" show Element, ErroneousElement;
import "../resolution/operators.dart"
show AssignmentOperator, BinaryOperator, IncDecOperator, UnaryOperator;
@@ -100,7 +100,7 @@
ir.Expression errorNonConstantConstructorInvoke(
NewExpression node,
Element element,
- DartType type,
+ ResolutionDartType type,
NodeList arguments,
CallStructure callStructure,
_) {
diff --git a/pkg/compiler/lib/src/kernel/kernel.dart b/pkg/compiler/lib/src/kernel/kernel.dart
index 964854a..373c873 100644
--- a/pkg/compiler/lib/src/kernel/kernel.dart
+++ b/pkg/compiler/lib/src/kernel/kernel.dart
@@ -13,8 +13,13 @@
import '../compiler.dart' show Compiler;
import '../constants/expressions.dart'
show ConstantExpression, TypeConstantExpression;
-import '../dart_types.dart'
- show DartType, FunctionType, InterfaceType, TypeKind, TypeVariableType;
+import '../elements/resolution_types.dart'
+ show
+ ResolutionDartType,
+ ResolutionFunctionType,
+ ResolutionInterfaceType,
+ ResolutionTypeKind,
+ ResolutionTypeVariableType;
import '../diagnostics/messages.dart' show MessageKind;
import '../diagnostics/spannable.dart' show Spannable;
import '../elements/elements.dart'
@@ -152,10 +157,18 @@
Queue<ir.Member> members = new Queue<ir.Member>();
library.implementation.forEachLocalMember((Element e) {
if (e.isClass) {
- classes.addFirst(classToIr(e));
+ ClassElement cls = e;
+ if (!cls.isResolved) return;
+ classes.addFirst(classToIr(cls));
} else if (e.isFunction || e.isAccessor) {
+ if (!compiler.resolution.hasBeenResolved(e) && !e.isMalformed) {
+ return;
+ }
members.addFirst(functionToIr(e));
} else if (e.isField) {
+ if (!compiler.resolution.hasBeenResolved(e) && !e.isMalformed) {
+ return;
+ }
members.addFirst(fieldToIr(e));
} else if (e.isTypedef) {
// Ignored, typedefs are unaliased on use.
@@ -188,8 +201,7 @@
ir.Class classToIr(ClassElement cls) {
cls = cls.declaration;
return classes.putIfAbsent(cls, () {
- cls.ensureResolved(compiler.resolution);
- compiler.enqueuer.resolution.emptyDeferredQueueForTesting();
+ assert(cls.isResolved);
String name = computeName(cls);
ir.Class classNode = new ir.Class(
name: name,
@@ -213,6 +225,10 @@
}
cls.implementation
.forEachMember((ClassElement enclosingClass, Element member) {
+ if (!compiler.resolution.hasBeenResolved(member) &&
+ !member.isMalformed) {
+ return;
+ }
if (member.enclosingClass.declaration != cls) {
// TODO(het): figure out why impact_test triggers this
//internalError(cls, "`$member` isn't mine.");
@@ -284,7 +300,7 @@
bool hasHierarchyProblem(ClassElement cls) => cls.hasIncompleteHierarchy;
- ir.InterfaceType interfaceTypeToIr(InterfaceType type) {
+ ir.InterfaceType interfaceTypeToIr(ResolutionInterfaceType type) {
ir.Class cls = classToIr(type.element);
if (type.typeArguments.isEmpty) {
return cls.rawType;
@@ -293,7 +309,7 @@
}
}
- ir.Supertype supertypeToIr(InterfaceType type) {
+ ir.Supertype supertypeToIr(ResolutionInterfaceType type) {
ir.Class cls = classToIr(type.element);
if (type.typeArguments.isEmpty) {
return cls.asRawSupertype;
@@ -302,7 +318,7 @@
}
}
- ir.FunctionType functionTypeToIr(FunctionType type) {
+ ir.FunctionType functionTypeToIr(ResolutionFunctionType type) {
List<ir.TypeParameter> typeParameters = <ir.TypeParameter>[];
int requiredParameterCount = type.parameterTypes.length;
List<ir.DartType> positionalParameters =
@@ -320,11 +336,11 @@
requiredParameterCount: requiredParameterCount);
}
- ir.TypeParameterType typeVariableTypeToIr(TypeVariableType type) {
+ ir.TypeParameterType typeVariableTypeToIr(ResolutionTypeVariableType type) {
return new ir.TypeParameterType(typeVariableToIr(type.element));
}
- List<ir.DartType> typesToIr(List<DartType> types) {
+ List<ir.DartType> typesToIr(List<ResolutionDartType> types) {
List<ir.DartType> result = new List<ir.DartType>(types.length);
for (int i = 0; i < types.length; i++) {
result[i] = typeToIr(types[i]);
@@ -332,7 +348,7 @@
return result;
}
- List<ir.Supertype> supertypesToIr(List<DartType> types) {
+ List<ir.Supertype> supertypesToIr(List<ResolutionDartType> types) {
List<ir.Supertype> result = new List<ir.Supertype>(types.length);
for (int i = 0; i < types.length; i++) {
result[i] = supertypeToIr(types[i]);
@@ -340,28 +356,28 @@
return result;
}
- ir.DartType typeToIr(DartType type) {
+ ir.DartType typeToIr(ResolutionDartType type) {
switch (type.kind) {
- case TypeKind.FUNCTION:
+ case ResolutionTypeKind.FUNCTION:
return functionTypeToIr(type);
- case TypeKind.INTERFACE:
+ case ResolutionTypeKind.INTERFACE:
return interfaceTypeToIr(type);
- case TypeKind.TYPEDEF:
+ case ResolutionTypeKind.TYPEDEF:
type.computeUnaliased(compiler.resolution);
return typeToIr(type.unaliased);
- case TypeKind.TYPE_VARIABLE:
+ case ResolutionTypeKind.TYPE_VARIABLE:
return typeVariableTypeToIr(type);
- case TypeKind.MALFORMED_TYPE:
+ case ResolutionTypeKind.MALFORMED_TYPE:
return const ir.InvalidType();
- case TypeKind.DYNAMIC:
+ case ResolutionTypeKind.DYNAMIC:
return const ir.DynamicType();
- case TypeKind.VOID:
+ case ResolutionTypeKind.VOID:
return const ir.VoidType();
}
}
@@ -409,8 +425,8 @@
}
function = function.declaration;
return functions.putIfAbsent(function, () {
- compiler.resolution.ensureResolved(function);
- compiler.enqueuer.resolution.emptyDeferredQueueForTesting();
+ assert(compiler.resolution.hasBeenResolved(function) ||
+ function.isMalformed);
function = function.implementation;
ir.Member member;
ir.Constructor constructor;
@@ -483,14 +499,14 @@
assert(factoryTypeParameters.isEmpty);
if (!function.isFactoryConstructor) return;
ClassElement cls = function.enclosingClass;
- for (DartType type in cls.typeVariables) {
+ for (ResolutionDartType type in cls.typeVariables) {
if (type.isTypeVariable) {
TypeVariableElement variable = type.element;
factoryTypeParameters[variable] =
new ir.TypeParameter(variable.name, null);
}
}
- for (DartType type in cls.typeVariables) {
+ for (ResolutionDartType type in cls.typeVariables) {
if (type.isTypeVariable) {
TypeVariableElement variable = type.element;
factoryTypeParameters[variable].bound = typeToIr(variable.bound);
@@ -509,8 +525,13 @@
}
field = field.declaration;
return fields.putIfAbsent(field, () {
+ // TODO(sigmund): remove `ensureResolved` here. It appears we hit this
+ // case only in metadata: when a constant has a field that is never read,
+ // but it is initialized in the constant constructor.
compiler.resolution.ensureResolved(field);
compiler.enqueuer.resolution.emptyDeferredQueueForTesting();
+ assert(compiler.resolution.hasBeenResolved(field) || field.isMalformed);
+
field = field.implementation;
ir.DartType type =
field.isMalformed ? const ir.InvalidType() : typeToIr(field.type);
@@ -552,7 +573,7 @@
addWork(variable, () {
if (variable.typeDeclaration.isClass) {
ClassElement cls = variable.typeDeclaration;
- cls.ensureResolved(compiler.resolution);
+ assert(cls.isResolved);
parameter.parent = classToIr(cls);
} else {
FunctionElement method = variable.typeDeclaration;
@@ -564,11 +585,11 @@
});
}
- List<ir.TypeParameter> typeVariablesToIr(List<DartType> variables) {
+ List<ir.TypeParameter> typeVariablesToIr(List<ResolutionDartType> variables) {
List<ir.TypeParameter> result =
new List<ir.TypeParameter>(variables.length);
for (int i = 0; i < variables.length; i++) {
- TypeVariableType type = variables[i];
+ ResolutionTypeVariableType type = variables[i];
result[i] = typeVariableToIr(type.element);
}
return result;
@@ -597,7 +618,7 @@
}
ConstructorTarget computeEffectiveTarget(
- ConstructorElement constructor, DartType type) {
+ ConstructorElement constructor, ResolutionDartType type) {
constructor = constructor.implementation;
Set<ConstructorElement> seen = new Set<ConstructorElement>();
functionToIr(constructor);
@@ -688,12 +709,14 @@
LibraryElement library =
compiler.libraryLoader.lookupLibrary(Uris.dart_core);
ClassElement cls = library.implementation.localLookup(className);
+ cls.ensureResolved(compiler.resolution);
assert(invariant(CURRENT_ELEMENT_SPANNABLE, cls != null,
message: 'dart:core class $className not found.'));
ConstructorElement constructor = cls.lookupConstructor(constructorName);
assert(invariant(CURRENT_ELEMENT_SPANNABLE, constructor != null,
message: "Constructor '$constructorName' not found "
"in class '$className'."));
+ compiler.resolution.ensureResolved(constructor);
return functionToIr(constructor);
}
@@ -703,6 +726,7 @@
Element function = library.implementation.localLookup(name);
assert(invariant(CURRENT_ELEMENT_SPANNABLE, function != null,
message: "dart:core method '$name' not found."));
+ compiler.resolution.ensureResolved(function);
return functionToIr(function);
}
@@ -761,7 +785,7 @@
class ConstructorTarget {
final ConstructorElement element;
- final DartType type;
+ final ResolutionDartType type;
ConstructorTarget(this.element, this.type);
diff --git a/pkg/compiler/lib/src/kernel/kernel_visitor.dart b/pkg/compiler/lib/src/kernel/kernel_visitor.dart
index ea28f68..905ea0f 100644
--- a/pkg/compiler/lib/src/kernel/kernel_visitor.dart
+++ b/pkg/compiler/lib/src/kernel/kernel_visitor.dart
@@ -31,7 +31,8 @@
IntFromEnvironmentConstantExpression,
StringFromEnvironmentConstantExpression,
TypeConstantExpression;
-import '../dart_types.dart' show DartType, InterfaceType;
+import '../elements/resolution_types.dart'
+ show ResolutionDartType, ResolutionInterfaceType;
import '../diagnostics/spannable.dart' show Spannable;
import '../elements/elements.dart'
show
@@ -259,7 +260,7 @@
// This works around a bug in dart2js.
// TODO(ahe): Fix the bug in dart2js and remove this function.
- ir.DartType typeToIrHack(DartType type) {
+ ir.DartType typeToIrHack(ResolutionDartType type) {
if (currentElement.isSynthesized &&
currentElement.enclosingClass.isMixinApplication &&
!kernel.hasHierarchyProblem(currentElement.enclosingClass)) {
@@ -283,7 +284,7 @@
// is Super<S> and it should be Sub<T>, but we settle for Super<T> for
// now). So we need to translate Sub<T> to an instance of Super, which is
// Super<T> (not Super<S>).
- InterfaceType supertype =
+ ResolutionInterfaceType supertype =
currentElement.enclosingClass.asInstanceOf(superclass);
// Once we have [supertype], we know how to substitute S with T: the type
// arguments of [supertype] corresponds to T, and the type variables of
@@ -1121,7 +1122,7 @@
ir.InvalidExpression visitAbstractClassConstructorInvoke(
NewExpression node,
ConstructorElement element,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
@@ -1146,7 +1147,8 @@
}
@override
- ir.AsExpression visitAs(Send node, Node expression, DartType type, _) {
+ ir.AsExpression visitAs(
+ Send node, Node expression, ResolutionDartType type, _) {
return new ir.AsExpression(
visitForValue(expression), kernel.typeToIr(type));
}
@@ -1172,7 +1174,7 @@
isConst: isConst)
: buildStaticInvoke(target.element, arguments, isConst: isConst);
if (target.type.isInterfaceType) {
- InterfaceType type = target.type;
+ ResolutionInterfaceType type = target.type;
if (type.isGeneric) {
invoke.arguments.types.addAll(kernel.typesToIr(type.typeArguments));
}
@@ -1261,7 +1263,7 @@
ir.InvalidExpression visitConstructorIncompatibleInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
@@ -1370,7 +1372,7 @@
ir.InvocationExpression visitFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
@@ -1499,7 +1501,7 @@
ir.InvocationExpression visitGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
@@ -1571,7 +1573,7 @@
@override
ir.Initializer visitImplicitSuperConstructorInvoke(FunctionExpression node,
- ConstructorElement superConstructor, InterfaceType type, _) {
+ ConstructorElement superConstructor, ResolutionInterfaceType type, _) {
if (superConstructor == null) {
// TODO(ahe): Semantic visitor shouldn't call this.
return new ir.InvalidInitializer();
@@ -1667,18 +1669,19 @@
return buildConstructorInvoke(node, isConst: true);
}
- ir.IsExpression buildIs(Node expression, DartType type) {
+ ir.IsExpression buildIs(Node expression, ResolutionDartType type) {
return new ir.IsExpression(
visitForValue(expression), kernel.typeToIr(type));
}
@override
- ir.IsExpression visitIs(Send node, Node expression, DartType type, _) {
+ ir.IsExpression visitIs(
+ Send node, Node expression, ResolutionDartType type, _) {
return buildIs(expression, type);
}
@override
- ir.Not visitIsNot(Send node, Node expression, DartType type, _) {
+ ir.Not visitIsNot(Send node, Node expression, ResolutionDartType type, _) {
return new ir.Not(buildIs(expression, type));
}
@@ -1899,7 +1902,7 @@
FunctionExpression node,
ConstructorElement constructor,
NodeList parameters,
- DartType redirectionType, // TODO(ahe): Should be InterfaceType.
+ ResolutionDartType redirectionType, // TODO(ahe): Should be InterfaceType.
ConstructorElement redirectionTarget,
_) {
if (!constructor.isFactoryConstructor) {
@@ -1928,9 +1931,9 @@
ir.InvocationExpression visitRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
ConstructorElement effectiveTarget,
- InterfaceType effectiveTargetType,
+ ResolutionInterfaceType effectiveTargetType,
NodeList arguments,
CallStructure callStructure,
_) {
@@ -1951,7 +1954,7 @@
ir.InvocationExpression visitRedirectingGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
@@ -2060,10 +2063,10 @@
returnType = typeToIrHack(signature.type.returnType);
}
if (function.isFactoryConstructor) {
- InterfaceType type = function.enclosingClass.thisType;
+ ResolutionInterfaceType type = function.enclosingClass.thisType;
if (type.isGeneric) {
typeParameters = new List<ir.TypeParameter>();
- for (DartType parameter in type.typeArguments) {
+ for (ResolutionDartType parameter in type.typeArguments) {
typeParameters.add(kernel.typeVariableToIr(parameter.element));
}
}
@@ -2162,12 +2165,20 @@
}
@override
- ir.StaticInvocation handleStaticFunctionIncompatibleInvoke(
+ ir.Expression handleStaticFunctionIncompatibleInvoke(
Send node,
MethodElement function,
NodeList arguments,
CallStructure callStructure,
_) {
+ if (!kernel.compiler.resolution.hasBeenResolved(function) &&
+ !function.isMalformed) {
+ // TODO(sigmund): consider calling nSM or handle recovery differently
+ // here. This case occurs only when this call was the only call to
+ // function, and knowing that the call was erroneous, our resolver didn't
+ // enqueue function itself.
+ return new ir.InvalidExpression();
+ }
return buildStaticInvoke(function, arguments, isConst: false);
}
@@ -2241,14 +2252,9 @@
}
@override
- ir.MethodInvocation handleStaticSetterInvoke(
- Send node,
- FunctionElement setter,
- NodeList arguments,
- CallStructure callStructure,
- _) {
- return buildCall(buildStaticAccessor(null, setter).buildSimpleRead(),
- callStructure, arguments);
+ ir.Expression handleStaticSetterInvoke(Send node, FunctionElement setter,
+ NodeList arguments, CallStructure callStructure, _) {
+ return new ir.InvalidExpression();
}
@override
@@ -2294,7 +2300,7 @@
ir.Initializer visitSuperConstructorInvoke(
Send node,
ConstructorElement superConstructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
diff --git a/pkg/compiler/lib/src/kernel/unresolved.dart b/pkg/compiler/lib/src/kernel/unresolved.dart
index 49e2b3d..7560ccb 100644
--- a/pkg/compiler/lib/src/kernel/unresolved.dart
+++ b/pkg/compiler/lib/src/kernel/unresolved.dart
@@ -4,7 +4,8 @@
import 'package:kernel/ast.dart' as ir;
-import "../dart_types.dart" show DartType, InterfaceType;
+import "../elements/resolution_types.dart"
+ show ResolutionDartType, ResolutionInterfaceType;
import "../elements/elements.dart"
show
AstElement,
@@ -157,7 +158,7 @@
ir.Expression visitUnresolvedClassConstructorInvoke(
NewExpression node,
ErroneousElement element,
- DartType type,
+ ResolutionDartType type,
NodeList arguments,
Selector selector,
_) {
@@ -170,7 +171,7 @@
ir.Expression visitUnresolvedConstructorInvoke(
NewExpression node,
Element constructor,
- DartType type,
+ ResolutionDartType type,
NodeList arguments,
Selector selector,
_) {
@@ -211,7 +212,7 @@
ir.Expression visitUnresolvedRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
diff --git a/pkg/compiler/lib/src/mirrors_used.dart b/pkg/compiler/lib/src/mirrors_used.dart
index 3c20fc9..dde7af1 100644
--- a/pkg/compiler/lib/src/mirrors_used.dart
+++ b/pkg/compiler/lib/src/mirrors_used.dart
@@ -16,16 +16,17 @@
ListConstantValue,
StringConstantValue,
TypeConstantValue;
-import 'dart_types.dart' show DartType, InterfaceType;
+import 'elements/resolution_types.dart'
+ show ResolutionDartType, ResolutionInterfaceType;
import 'elements/elements.dart'
show
ClassElement,
Element,
+ FieldElement,
ImportElement,
LibraryElement,
MetadataAnnotation,
- ScopeContainerElement,
- VariableElement;
+ ScopeContainerElement;
import 'resolution/tree_elements.dart' show TreeElements;
import 'tree/tree.dart' show NamedArgument, NewExpression, Node;
@@ -314,12 +315,12 @@
/// Convert a [constant] to an instance of [MirrorUsage] using information
/// that was resolved during [MirrorUsageAnalyzerTask.validate].
MirrorUsage buildUsage(ConstructedConstantValue constant) {
- Map<Element, ConstantValue> fields = constant.fields;
+ Map<FieldElement, ConstantValue> fields = constant.fields;
ClassElement cls = compiler.commonElements.mirrorsUsedClass;
- VariableElement symbolsField = cls.lookupLocalMember('symbols');
- VariableElement targetsField = cls.lookupLocalMember('targets');
- VariableElement metaTargetsField = cls.lookupLocalMember('metaTargets');
- VariableElement overrideField = cls.lookupLocalMember('override');
+ FieldElement symbolsField = cls.lookupLocalMember('symbols');
+ FieldElement targetsField = cls.lookupLocalMember('targets');
+ FieldElement metaTargetsField = cls.lookupLocalMember('metaTargets');
+ FieldElement overrideField = cls.lookupLocalMember('override');
return new MirrorUsage(
cachedStrings[fields[symbolsField]],
@@ -414,14 +415,14 @@
}
/// Find the first non-implementation interface of constant.
- DartType apiTypeOf(ConstantValue constant) {
- DartType type = constant.getType(compiler.commonElements);
+ ResolutionDartType apiTypeOf(ConstantValue constant) {
+ ResolutionDartType type = constant.getType(compiler.commonElements);
LibraryElement library = type.element.library;
if (type.isInterfaceType && library.isInternalLibrary) {
- InterfaceType interface = type;
+ ResolutionInterfaceType interface = type;
ClassElement cls = type.element;
cls.ensureResolved(compiler.resolution);
- for (DartType supertype in cls.allSupertypes) {
+ for (ResolutionDartType supertype in cls.allSupertypes) {
if (supertype.isInterfaceType &&
!supertype.element.library.isInternalLibrary) {
return interface.asInstanceOf(supertype.element);
@@ -445,8 +446,8 @@
}
List<Element> result = <Element>[];
for (var entry in list) {
- if (entry is DartType) {
- DartType type = entry;
+ if (entry is ResolutionDartType) {
+ ResolutionDartType type = entry;
result.add(type.element);
} else {
String string = entry;
diff --git a/pkg/compiler/lib/src/native/behavior.dart b/pkg/compiler/lib/src/native/behavior.dart
index 63ae4e3..e236975 100644
--- a/pkg/compiler/lib/src/native/behavior.dart
+++ b/pkg/compiler/lib/src/native/behavior.dart
@@ -9,7 +9,7 @@
import '../constants/expressions.dart';
import '../constants/values.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../js/js.dart' as js;
import '../js_backend/js_backend.dart';
@@ -130,10 +130,12 @@
* `null` may be returned.
*/
class NativeBehavior {
- /// [DartType]s or [SpecialType]s returned or yielded by the native element.
+ /// [ResolutionDartType]s or [SpecialType]s returned or yielded by the native
+ /// element.
final List typesReturned = [];
- /// [DartType]s or [SpecialType]s instantiated by the native element.
+ /// [ResolutionDartType]s or [SpecialType]s instantiated by the native
+ /// element.
final List typesInstantiated = [];
String codeTemplateText;
@@ -744,14 +746,14 @@
static NativeBehavior ofMethodElement(
FunctionElement element, Compiler compiler) {
- FunctionType type = element.computeType(compiler.resolution);
+ ResolutionFunctionType type = element.computeType(compiler.resolution);
List<ConstantExpression> metadata = <ConstantExpression>[];
for (MetadataAnnotation annotation in element.implementation.metadata) {
annotation.ensureResolved(compiler.resolution);
metadata.add(annotation.constant);
}
- DartType lookup(String name) {
+ ResolutionDartType lookup(String name) {
Element e = element.buildScope().lookup(name);
if (e == null) return null;
if (e is! ClassElement) return null;
@@ -766,7 +768,7 @@
static NativeBehavior ofMethod(
Spannable spannable,
- FunctionType type,
+ ResolutionFunctionType type,
List<ConstantExpression> metadata,
TypeLookup lookupType,
Compiler compiler,
@@ -785,7 +787,7 @@
behavior.typesReturned.add(
!isJsInterop || compiler.options.trustJSInteropTypeAnnotations
? returnType
- : const DynamicType());
+ : const ResolutionDynamicType());
if (!type.returnType.isVoid) {
// Declared types are nullable.
behavior.typesReturned.add(compiler.commonElements.nullType);
@@ -793,10 +795,10 @@
behavior._capture(type, compiler.resolution,
isInterop: isJsInterop, compiler: compiler);
- for (DartType type in type.optionalParameterTypes) {
+ for (ResolutionDartType type in type.optionalParameterTypes) {
behavior._escape(type, compiler.resolution);
}
- for (DartType type in type.namedParameterTypes) {
+ for (ResolutionDartType type in type.namedParameterTypes) {
behavior._escape(type, compiler.resolution);
}
@@ -808,14 +810,14 @@
static NativeBehavior ofFieldElementLoad(
MemberElement element, Compiler compiler) {
Resolution resolution = compiler.resolution;
- DartType type = element.computeType(resolution);
+ ResolutionDartType type = element.computeType(resolution);
List<ConstantExpression> metadata = <ConstantExpression>[];
for (MetadataAnnotation annotation in element.implementation.metadata) {
annotation.ensureResolved(compiler.resolution);
metadata.add(annotation.constant);
}
- DartType lookup(String name) {
+ ResolutionDartType lookup(String name) {
Element e = element.buildScope().lookup(name);
if (e == null) return null;
if (e is! ClassElement) return null;
@@ -830,7 +832,7 @@
static NativeBehavior ofFieldLoad(
Spannable spannable,
- DartType type,
+ ResolutionDartType type,
List<ConstantExpression> metadata,
TypeLookup lookupType,
Compiler compiler,
@@ -841,7 +843,7 @@
behavior.typesReturned.add(
!isJsInterop || compiler.options.trustJSInteropTypeAnnotations
? type
- : const DynamicType());
+ : const ResolutionDynamicType());
// Declared types are nullable.
behavior.typesReturned.add(resolution.commonElements.nullType);
behavior._capture(type, resolution,
@@ -853,11 +855,12 @@
static NativeBehavior ofFieldElementStore(
MemberElement field, Resolution resolution) {
- DartType type = field.computeType(resolution);
+ ResolutionDartType type = field.computeType(resolution);
return ofFieldStore(type, resolution);
}
- static NativeBehavior ofFieldStore(DartType type, Resolution resolution) {
+ static NativeBehavior ofFieldStore(
+ ResolutionDartType type, Resolution resolution) {
var behavior = new NativeBehavior();
behavior._escape(type, resolution);
// We don't override the default behaviour - the annotations apply to
@@ -924,15 +927,15 @@
/// Models the behavior of having intances of [type] escape from Dart code
/// into native code.
- void _escape(DartType type, Resolution resolution) {
+ void _escape(ResolutionDartType type, Resolution resolution) {
type.computeUnaliased(resolution);
type = type.unaliased;
- if (type is FunctionType) {
- FunctionType functionType = type;
+ if (type is ResolutionFunctionType) {
+ ResolutionFunctionType functionType = type;
// A function might be called from native code, passing us novel
// parameters.
_escape(functionType.returnType, resolution);
- for (DartType parameter in functionType.parameterTypes) {
+ for (ResolutionDartType parameter in functionType.parameterTypes) {
_capture(parameter, resolution);
}
}
@@ -944,15 +947,15 @@
///
/// We assume that JS-interop APIs cannot instantiate Dart types or
/// non-JSInterop native types.
- void _capture(DartType type, Resolution resolution,
+ void _capture(ResolutionDartType type, Resolution resolution,
{bool isInterop: false, Compiler compiler}) {
type.computeUnaliased(resolution);
type = type.unaliased;
- if (type is FunctionType) {
- FunctionType functionType = type;
+ if (type is ResolutionFunctionType) {
+ ResolutionFunctionType functionType = type;
_capture(functionType.returnType, resolution,
isInterop: isInterop, compiler: compiler);
- for (DartType parameter in functionType.parameterTypes) {
+ for (ResolutionDartType parameter in functionType.parameterTypes) {
_escape(parameter, resolution);
}
} else {
@@ -992,7 +995,7 @@
Spannable spannable, DiagnosticReporter reporter, TypeLookup lookupType) {
if (typeString == '=Object') return SpecialType.JsObject;
if (typeString == 'dynamic') {
- return const DynamicType();
+ return const ResolutionDynamicType();
}
var type = lookupType(typeString);
if (type != null) return type;
@@ -1001,7 +1004,7 @@
if (index < 1) {
reporter.reportErrorMessage(spannable, MessageKind.GENERIC,
{'text': "Type '$typeString' not found."});
- return const DynamicType();
+ return const ResolutionDynamicType();
}
type = lookupType(typeString.substring(0, index));
if (type != null) {
@@ -1010,6 +1013,6 @@
}
reporter.reportErrorMessage(spannable, MessageKind.GENERIC,
{'text': "Type '$typeString' not found."});
- return const DynamicType();
+ return const ResolutionDynamicType();
}
}
diff --git a/pkg/compiler/lib/src/native/enqueue.dart b/pkg/compiler/lib/src/native/enqueue.dart
index e5405ba..4aa5ba0 100644
--- a/pkg/compiler/lib/src/native/enqueue.dart
+++ b/pkg/compiler/lib/src/native/enqueue.dart
@@ -10,7 +10,7 @@
import '../compiler.dart' show Compiler;
import '../constants/values.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart' show FunctionElementX;
import '../js_backend/backend_helpers.dart' show BackendHelpers;
@@ -29,7 +29,7 @@
*/
class NativeEnqueuer {
/// Called when a [type] has been instantiated natively.
- void onInstantiatedType(InterfaceType type) {}
+ void onInstantiatedType(ResolutionInterfaceType type) {}
/// Initial entry point to native enqueuer.
WorldImpact processNativeClasses(Iterable<LibraryElement> libraries) =>
@@ -99,7 +99,7 @@
DiagnosticReporter get reporter => compiler.reporter;
CommonElements get commonElements => compiler.commonElements;
- void onInstantiatedType(InterfaceType type) {
+ void onInstantiatedType(ResolutionInterfaceType type) {
if (_unusedClasses.remove(type.element)) {
_registeredClasses.add(type.element);
}
@@ -283,18 +283,10 @@
void findAnnotationClasses() {
if (_annotationCreatesClass != null) return;
- ClassElement find(name) {
- Element e = helpers.findHelper(name);
- if (e == null || e is! ClassElement) {
- reporter.internalError(NO_LOCATION_SPANNABLE,
- "Could not find implementation class '${name}'.");
- }
- return e;
- }
- _annotationCreatesClass = find('Creates');
- _annotationReturnsClass = find('Returns');
- _annotationJsNameClass = find('JSName');
+ _annotationCreatesClass = helpers.annotationCreatesClass;
+ _annotationReturnsClass = helpers.annotationReturnsClass;
+ _annotationJsNameClass = helpers.annotationJSNameClass;
}
/// Returns the JSName annotation string or `null` if no JSName annotation is
@@ -430,7 +422,7 @@
void _processNativeBehavior(
WorldImpactBuilder impactBuilder, NativeBehavior behavior, cause) {
- void registerInstantiation(InterfaceType type) {
+ void registerInstantiation(ResolutionInterfaceType type) {
impactBuilder.registerTypeUse(new TypeUse.nativeInstantiation(type));
}
@@ -443,7 +435,7 @@
}
continue;
}
- if (type is InterfaceType) {
+ if (type is ResolutionInterfaceType) {
if (type == commonElements.intType) {
registerInstantiation(type);
} else if (type == commonElements.doubleType) {
@@ -470,14 +462,14 @@
// actual implementation classes such as `JSArray` et al.
matchingClasses
.addAll(_findUnusedClassesMatching((ClassElement nativeClass) {
- InterfaceType nativeType = nativeClass.thisType;
- InterfaceType specType = type.element.thisType;
+ ResolutionInterfaceType nativeType = nativeClass.thisType;
+ ResolutionInterfaceType specType = type.element.thisType;
return compiler.types.isSubtype(nativeType, specType);
}));
} else if (type.isDynamic) {
matchingClasses.addAll(_unusedClasses);
} else {
- assert(type is VoidType);
+ assert(type is ResolutionVoidType);
}
}
if (matchingClasses.isNotEmpty && _registeredClasses.isEmpty) {
@@ -498,17 +490,16 @@
}
Iterable<ClassElement> _onFirstNativeClass(WorldImpactBuilder impactBuilder) {
- void staticUse(name) {
- Element element = helpers.findHelper(name);
+ void staticUse(element) {
impactBuilder.registerStaticUse(new StaticUse.foreignUse(element));
backend.registerBackendUse(element);
compiler.globalDependencies.registerDependency(element);
}
- staticUse('defineProperty');
- staticUse('toStringForNativeObject');
- staticUse('hashCodeForNativeObject');
- staticUse('convertDartClosureToJS');
+ staticUse(helpers.defineProperty);
+ staticUse(helpers.toStringForNativeObject);
+ staticUse(helpers.hashCodeForNativeObject);
+ staticUse(helpers.closureConverter);
return _findNativeExceptions();
}
@@ -644,7 +635,7 @@
// be instantiated (abstract or simply unused).
_addSubtypes(cls.superclass, emitter);
- for (DartType type in cls.allSupertypes) {
+ for (ResolutionDartType type in cls.allSupertypes) {
List<Element> subtypes =
emitter.subtypes.putIfAbsent(type.element, () => <ClassElement>[]);
subtypes.add(cls);
diff --git a/pkg/compiler/lib/src/native/ssa.dart b/pkg/compiler/lib/src/native/ssa.dart
index a7f185f..e0839a0 100644
--- a/pkg/compiler/lib/src/native/ssa.dart
+++ b/pkg/compiler/lib/src/native/ssa.dart
@@ -5,7 +5,7 @@
import '../common.dart';
import '../compiler.dart' show Compiler;
import '../constants/values.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../js/js.dart' as js;
import '../js_backend/js_backend.dart';
@@ -19,13 +19,13 @@
void handleSsaNative(SsaBuilder builder, Expression nativeBody) {
Compiler compiler = builder.compiler;
- FunctionElement element = builder.target;
+ MethodElement element = builder.target;
NativeEmitter nativeEmitter = builder.nativeEmitter;
JavaScriptBackend backend = builder.backend;
DiagnosticReporter reporter = compiler.reporter;
HInstruction convertDartClosure(
- ParameterElement parameter, FunctionType type) {
+ ParameterElement parameter, ResolutionFunctionType type) {
HInstruction local = builder.localsHandler.readLocal(parameter);
ConstantValue arityConstant =
builder.constantSystem.createInt(type.computeArity());
@@ -73,9 +73,9 @@
inputs.add(builder.localsHandler.readThis());
}
parameters.forEachParameter((ParameterElement parameter) {
- DartType type = parameter.type.unaliased;
+ ResolutionDartType type = parameter.type.unaliased;
HInstruction input = builder.localsHandler.readLocal(parameter);
- if (type is FunctionType) {
+ if (type is ResolutionFunctionType) {
// The parameter type is a function type either directly or through
// typedef(s).
input = convertDartClosure(parameter, type);
diff --git a/pkg/compiler/lib/src/ordered_typeset.dart b/pkg/compiler/lib/src/ordered_typeset.dart
index 4e37362..4798c43 100644
--- a/pkg/compiler/lib/src/ordered_typeset.dart
+++ b/pkg/compiler/lib/src/ordered_typeset.dart
@@ -5,7 +5,7 @@
library ordered_typeset;
import 'common.dart';
-import 'dart_types.dart';
+import 'elements/resolution_types.dart';
import 'diagnostics/diagnostic_listener.dart' show DiagnosticReporter;
import 'elements/elements.dart' show ClassElement;
import 'util/util.dart' show Link, LinkBuilder;
@@ -29,30 +29,35 @@
* C: [C, B, A, Object]
*/
class OrderedTypeSet {
- final List<Link<DartType>> _levels;
- final Link<DartType> types;
- final Link<DartType> _supertypes;
+ final List<Link<ResolutionDartType>> _levels;
+ final Link<ResolutionDartType> types;
+ final Link<ResolutionDartType> _supertypes;
- OrderedTypeSet.internal(List<Link<DartType>> this._levels,
- Link<DartType> this.types, Link<DartType> this._supertypes);
+ OrderedTypeSet.internal(
+ List<Link<ResolutionDartType>> this._levels,
+ Link<ResolutionDartType> this.types,
+ Link<ResolutionDartType> this._supertypes);
- factory OrderedTypeSet.singleton(DartType type) {
- Link<DartType> types =
- new LinkEntry<DartType>(type, const Link<DartType>());
- List<Link<DartType>> list = new List<Link<DartType>>(1);
+ factory OrderedTypeSet.singleton(ResolutionDartType type) {
+ Link<ResolutionDartType> types = new LinkEntry<ResolutionDartType>(
+ type, const Link<ResolutionDartType>());
+ List<Link<ResolutionDartType>> list = new List<Link<ResolutionDartType>>(1);
list[0] = types;
- return new OrderedTypeSet.internal(list, types, const Link<DartType>());
+ return new OrderedTypeSet.internal(
+ list, types, const Link<ResolutionDartType>());
}
/// Creates a new [OrderedTypeSet] for [type] when it directly extends the
/// class which this set represents. This is for instance used to create the
/// type set for [ClosureClassElement] which extends [Closure].
- OrderedTypeSet extendClass(InterfaceType type) {
+ OrderedTypeSet extendClass(ResolutionInterfaceType type) {
assert(invariant(type.element, types.head.treatAsRaw,
message: 'Cannot extend generic class ${types.head} using '
'OrderedTypeSet.extendClass'));
- Link<DartType> extendedTypes = new LinkEntry<DartType>(type, types);
- List<Link<DartType>> list = new List<Link<DartType>>(levels + 1);
+ Link<ResolutionDartType> extendedTypes =
+ new LinkEntry<ResolutionDartType>(type, types);
+ List<Link<ResolutionDartType>> list =
+ new List<Link<ResolutionDartType>>(levels + 1);
for (int i = 0; i < levels; i++) {
list[i] = _levels[i];
}
@@ -61,24 +66,24 @@
list, extendedTypes, _supertypes.prepend(types.head));
}
- Link<DartType> get supertypes => _supertypes;
+ Link<ResolutionDartType> get supertypes => _supertypes;
int get levels => _levels.length;
int get maxDepth => levels - 1;
- Link<DartType> operator [](int index) {
+ Link<ResolutionDartType> operator [](int index) {
if (index < levels) {
return _levels[index];
}
- return const Link<DartType>();
+ return const Link<ResolutionDartType>();
}
/// Returns the offsets into [types] at which each level begins.
List<int> get levelOffsets {
List<int> offsets = new List.filled(levels, -1);
int offset = 0;
- Link<DartType> pointer = types;
+ Link<ResolutionDartType> pointer = types;
for (int depth = maxDepth; depth >= 0; depth--) {
while (!identical(pointer, _levels[depth])) {
pointer = pointer.tail;
@@ -89,11 +94,11 @@
return offsets;
}
- void forEach(int level, void f(DartType type)) {
+ void forEach(int level, void f(ResolutionDartType type)) {
if (level < levels) {
- Link<DartType> pointer = _levels[level];
- Link<DartType> end =
- level > 0 ? _levels[level - 1] : const Link<DartType>();
+ Link<ResolutionDartType> pointer = _levels[level];
+ Link<ResolutionDartType> end =
+ level > 0 ? _levels[level - 1] : const Link<ResolutionDartType>();
// TODO(het): checking `isNotEmpty` should be unnecessary, remove when
// constants are properly canonicalized
while (pointer.isNotEmpty && !identical(pointer, end)) {
@@ -103,12 +108,12 @@
}
}
- InterfaceType asInstanceOf(ClassElement cls) {
+ ResolutionInterfaceType asInstanceOf(ClassElement cls) {
int level = cls.hierarchyDepth;
if (level < levels) {
- Link<DartType> pointer = _levels[level];
- Link<DartType> end =
- level > 0 ? _levels[level - 1] : const Link<DartType>();
+ Link<ResolutionDartType> pointer = _levels[level];
+ Link<ResolutionDartType> end =
+ level > 0 ? _levels[level - 1] : const Link<ResolutionDartType>();
// TODO(het): checking `isNotEmpty` should be unnecessary, remove when
// constants are properly canonicalized
while (pointer.isNotEmpty && !identical(pointer, end)) {
@@ -142,23 +147,26 @@
* C: [C, B, A, Object]
*/
class OrderedTypeSetBuilder {
- Map<int, LinkEntry<DartType>> map = new Map<int, LinkEntry<DartType>>();
+ Map<int, LinkEntry<ResolutionDartType>> map =
+ new Map<int, LinkEntry<ResolutionDartType>>();
// TODO(15296): Avoid computing this order on the side when member
// lookup handles multiply inherited members correctly.
- LinkBuilder<DartType> allSupertypes = new LinkBuilder<DartType>();
+ LinkBuilder<ResolutionDartType> allSupertypes =
+ new LinkBuilder<ResolutionDartType>();
int maxDepth = -1;
final DiagnosticReporter reporter;
final ClassElement cls;
- InterfaceType _objectType;
+ ResolutionInterfaceType _objectType;
// TODO(johnniwinther): Provide access to `Object` in deserialization and
// make [objectType] mandatory.
- OrderedTypeSetBuilder(this.cls, {this.reporter, InterfaceType objectType})
+ OrderedTypeSetBuilder(this.cls,
+ {this.reporter, ResolutionInterfaceType objectType})
: this._objectType = objectType;
OrderedTypeSet createOrderedTypeSet(
- InterfaceType supertype, Link<DartType> interfaces) {
+ ResolutionInterfaceType supertype, Link<ResolutionDartType> interfaces) {
if (_objectType == null) {
// Find `Object` through in hierarchy. This is used for serialization
// where it is assumed that the hierarchy is valid.
@@ -171,12 +179,16 @@
// TODO(15296): Collapse these iterations to one when the order is not
// needed.
add(supertype);
- for (Link<DartType> link = interfaces; !link.isEmpty; link = link.tail) {
+ for (Link<ResolutionDartType> link = interfaces;
+ !link.isEmpty;
+ link = link.tail) {
add(link.head);
}
addAllSupertypes(supertype);
- for (Link<DartType> link = interfaces; !link.isEmpty; link = link.tail) {
+ for (Link<ResolutionDartType> link = interfaces;
+ !link.isEmpty;
+ link = link.tail) {
addAllSupertypes(link.head);
}
add(cls.thisType);
@@ -187,20 +199,20 @@
* Adds [type] and all supertypes of [type] to [allSupertypes] while
* substituting type variables.
*/
- void addAllSupertypes(InterfaceType type) {
+ void addAllSupertypes(ResolutionInterfaceType type) {
ClassElement classElement = type.element;
- Link<DartType> supertypes = classElement.allSupertypes;
+ Link<ResolutionDartType> supertypes = classElement.allSupertypes;
assert(invariant(cls, supertypes != null,
message: "Supertypes not computed on $classElement "
"during resolution of $cls"));
while (!supertypes.isEmpty) {
- DartType supertype = supertypes.head;
+ ResolutionDartType supertype = supertypes.head;
add(supertype.substByContext(type));
supertypes = supertypes.tail;
}
}
- void add(InterfaceType type) {
+ void add(ResolutionInterfaceType type) {
if (type.element == cls) {
if (type != _objectType) {
allSupertypes.addLast(_objectType);
@@ -214,11 +226,11 @@
}
}
- void _addAtDepth(InterfaceType type, int depth) {
- LinkEntry<DartType> prev = null;
- LinkEntry<DartType> link = map[depth];
+ void _addAtDepth(ResolutionInterfaceType type, int depth) {
+ LinkEntry<ResolutionDartType> prev = null;
+ LinkEntry<ResolutionDartType> link = map[depth];
while (link != null) {
- DartType existingType = link.head;
+ ResolutionDartType existingType = link.head;
if (existingType == type) return;
if (existingType.element == type.element) {
if (reporter != null) {
@@ -236,7 +248,8 @@
prev = link;
link = link.tail;
}
- LinkEntry<DartType> next = new LinkEntry<DartType>(type);
+ LinkEntry<ResolutionDartType> next =
+ new LinkEntry<ResolutionDartType>(type);
next.tail = null;
if (prev == null) {
map[depth] = next;
@@ -249,19 +262,20 @@
}
OrderedTypeSet toTypeSet() {
- List<Link<DartType>> levels = new List<Link<DartType>>(maxDepth + 1);
+ List<Link<ResolutionDartType>> levels =
+ new List<Link<ResolutionDartType>>(maxDepth + 1);
if (maxDepth < 0) {
- return new OrderedTypeSet.internal(
- levels, const Link<DartType>(), const Link<DartType>());
+ return new OrderedTypeSet.internal(levels,
+ const Link<ResolutionDartType>(), const Link<ResolutionDartType>());
}
- Link<DartType> next = const Link<DartType>();
+ Link<ResolutionDartType> next = const Link<ResolutionDartType>();
for (int depth = 0; depth <= maxDepth; depth++) {
- LinkEntry<DartType> first = map[depth];
+ LinkEntry<ResolutionDartType> first = map[depth];
if (first == null) {
levels[depth] = next;
} else {
levels[depth] = first;
- LinkEntry<DartType> last = first;
+ LinkEntry<ResolutionDartType> last = first;
while (last.tail != null) {
last = last.tail;
}
@@ -277,7 +291,7 @@
StringBuffer sb = new StringBuffer();
for (int depth = 0; depth <= maxDepth; depth++) {
sb.write('$depth: ');
- LinkEntry<DartType> first = map[depth];
+ LinkEntry<ResolutionDartType> first = map[depth];
if (first != null) {
sb.write('${first.head}');
while (first.tail != null) {
diff --git a/pkg/compiler/lib/src/parser/partial_elements.dart b/pkg/compiler/lib/src/parser/partial_elements.dart
index 1f37ff3..c68e5e4 100644
--- a/pkg/compiler/lib/src/parser/partial_elements.dart
+++ b/pkg/compiler/lib/src/parser/partial_elements.dart
@@ -6,7 +6,7 @@
import '../common.dart';
import '../common/resolution.dart' show ParsingContext, Resolution;
-import '../dart_types.dart' show DynamicType;
+import '../elements/resolution_types.dart' show ResolutionDynamicType;
import '../elements/elements.dart'
show
CompilationUnitElement,
@@ -258,7 +258,7 @@
return resolution.resolveTypeAnnotation(element, node.type);
});
} else {
- type = const DynamicType();
+ type = const ResolutionDynamicType();
}
assert(type != null);
return type;
diff --git a/pkg/compiler/lib/src/patch_parser.dart b/pkg/compiler/lib/src/patch_parser.dart
index 82c20b0..a356887 100644
--- a/pkg/compiler/lib/src/patch_parser.dart
+++ b/pkg/compiler/lib/src/patch_parser.dart
@@ -120,7 +120,7 @@
import 'common.dart';
import 'compiler.dart' show Compiler;
import 'constants/values.dart' show ConstantValue;
-import 'dart_types.dart' show DartType;
+import 'elements/resolution_types.dart' show ResolutionDartType;
import 'elements/elements.dart';
import 'elements/modelx.dart'
show
@@ -204,8 +204,8 @@
Token token = parser.parseTopLevelDeclaration(cls.beginToken);
assert(identical(token, cls.endToken.next));
} on ParserError catch (e) {
- // No need to recover from a parser error in platform libraries, user
- // will never see this if the libraries are tested correctly.
+ // No need to recover from a parser error in platform libraries,
+ // user will never see this if the libraries are tested correctly.
reporter.internalError(cls, "Parser error in patch file: $e");
}
cls.cachedNode = listener.popNode();
@@ -428,7 +428,8 @@
void validate(Compiler compiler, Element element,
MetadataAnnotation annotation, ConstantValue constant) {
- DartType annotationType = constant.getType(compiler.commonElements);
+ ResolutionDartType annotationType =
+ constant.getType(compiler.commonElements);
if (annotationType.element !=
compiler.commonElements.nativeAnnotationClass) {
DiagnosticReporter reporter = compiler.reporter;
@@ -497,7 +498,8 @@
@override
void validate(Compiler compiler, Element element,
MetadataAnnotation annotation, ConstantValue constant) {
- DartType annotationType = constant.getType(compiler.commonElements);
+ ResolutionDartType annotationType =
+ constant.getType(compiler.commonElements);
if (annotationType.element !=
compiler.commonElements.patchAnnotationClass) {
DiagnosticReporter reporter = compiler.reporter;
diff --git a/pkg/compiler/lib/src/resolution/access_semantics.dart b/pkg/compiler/lib/src/resolution/access_semantics.dart
index ffb71f9..15e280a 100644
--- a/pkg/compiler/lib/src/resolution/access_semantics.dart
+++ b/pkg/compiler/lib/src/resolution/access_semantics.dart
@@ -8,7 +8,7 @@
library dart2js.access_semantics;
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
/// Enum representing the different kinds of destinations which a property
@@ -477,7 +477,7 @@
final Element element;
/// The type on which the constructor is invoked.
- final DartType type;
+ final ResolutionDartType type;
ConstructorAccessSemantics(this.kind, this.element, this.type);
diff --git a/pkg/compiler/lib/src/resolution/class_hierarchy.dart b/pkg/compiler/lib/src/resolution/class_hierarchy.dart
index 7f2a57a..a63a093 100644
--- a/pkg/compiler/lib/src/resolution/class_hierarchy.dart
+++ b/pkg/compiler/lib/src/resolution/class_hierarchy.dart
@@ -7,7 +7,7 @@
import '../common.dart';
import '../common/resolution.dart' show Resolution;
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart'
show
@@ -28,7 +28,7 @@
import 'resolution_common.dart' show CommonResolverVisitor, MappingVisitor;
import 'scope.dart' show Scope, TypeDeclarationScope;
-class TypeDefinitionVisitor extends MappingVisitor<DartType> {
+class TypeDefinitionVisitor extends MappingVisitor<ResolutionDartType> {
Scope scope;
final TypeDeclarationElement enclosingElement;
TypeDeclarationElement get element => enclosingElement;
@@ -41,18 +41,18 @@
CommonElements get commonElements => resolution.commonElements;
- DartType get objectType => commonElements.objectType;
+ ResolutionDartType get objectType => commonElements.objectType;
void resolveTypeVariableBounds(NodeList node) {
if (node == null) return;
Setlet<String> nameSet = new Setlet<String>();
// Resolve the bounds of type variables.
- Iterator<DartType> types = element.typeVariables.iterator;
+ Iterator<ResolutionDartType> types = element.typeVariables.iterator;
Link<Node> nodeLink = node.nodes;
while (!nodeLink.isEmpty) {
types.moveNext();
- TypeVariableType typeVariable = types.current;
+ ResolutionTypeVariableType typeVariable = types.current;
String typeName = typeVariable.name;
TypeVariable typeNode = nodeLink.head;
registry.useType(typeNode, typeVariable);
@@ -66,7 +66,7 @@
TypeVariableElementX variableElement = typeVariable.element;
if (typeNode.bound != null) {
- DartType boundType =
+ ResolutionDartType boundType =
typeResolver.resolveTypeAnnotation(this, typeNode.bound);
variableElement.boundCache = boundType;
@@ -74,7 +74,7 @@
Link<TypeVariableElement> seenTypeVariables =
const Link<TypeVariableElement>();
seenTypeVariables = seenTypeVariables.prepend(variableElement);
- DartType bound = boundType;
+ ResolutionDartType bound = boundType;
while (bound.isTypeVariable) {
TypeVariableElement element = bound.element;
if (seenTypeVariables.contains(element)) {
@@ -122,7 +122,7 @@
ResolutionRegistry registry)
: super(resolution, classElement, registry);
- DartType visitClassNode(ClassNode node) {
+ ResolutionDartType visitClassNode(ClassNode node) {
if (element == null) {
throw reporter.internalError(node, 'element is null');
}
@@ -143,7 +143,8 @@
if (element.supertype == null && node.superclass != null) {
MixinApplication superMixin = node.superclass.asMixinApplication();
if (superMixin != null) {
- DartType supertype = resolveSupertype(element, superMixin.superclass);
+ ResolutionDartType supertype =
+ resolveSupertype(element, superMixin.superclass);
Link<Node> link = superMixin.mixins.nodes;
while (!link.isEmpty) {
supertype =
@@ -223,7 +224,7 @@
}
@override
- DartType visitEnum(Enum node) {
+ ResolutionDartType visitEnum(Enum node) {
if (element == null) {
throw reporter.internalError(node, 'element is null');
}
@@ -232,9 +233,9 @@
element, 'cyclic resolution of class $element');
}
- InterfaceType enumType = element.computeType(resolution);
+ ResolutionInterfaceType enumType = element.computeType(resolution);
element.supertype = objectType;
- element.interfaces = const Link<DartType>();
+ element.interfaces = const Link<ResolutionDartType>();
calculateAllSupertypes(element);
if (node.names.nodes.isEmpty) {
@@ -250,8 +251,8 @@
/// Resolves the mixed type for [mixinNode] and checks that the mixin type
/// is a valid, non-blacklisted interface type. The mixin type is returned.
- DartType checkMixinType(TypeAnnotation mixinNode) {
- DartType mixinType = resolveType(mixinNode);
+ ResolutionDartType checkMixinType(TypeAnnotation mixinNode) {
+ ResolutionDartType mixinType = resolveType(mixinNode);
if (isBlackListed(mixinType)) {
reporter.reportErrorMessage(
mixinNode, MessageKind.CANNOT_MIXIN, {'type': mixinType});
@@ -267,7 +268,7 @@
return mixinType;
}
- DartType visitNamedMixinApplication(NamedMixinApplication node) {
+ ResolutionDartType visitNamedMixinApplication(NamedMixinApplication node) {
if (element == null) {
throw reporter.internalError(node, 'element is null');
}
@@ -282,7 +283,7 @@
// Generate anonymous mixin application elements for the
// intermediate mixin applications (excluding the last).
- DartType supertype = resolveSupertype(element, node.superclass);
+ ResolutionDartType supertype = resolveSupertype(element, node.superclass);
Link<Node> link = node.mixins.nodes;
while (!link.tail.isEmpty) {
supertype = applyMixin(supertype, checkMixinType(link.head), link.head);
@@ -292,25 +293,28 @@
return element.computeType(resolution);
}
- DartType applyMixin(DartType supertype, DartType mixinType, Node node) {
+ ResolutionDartType applyMixin(
+ ResolutionDartType supertype, ResolutionDartType mixinType, Node node) {
String superName = supertype.name;
String mixinName = mixinType.name;
MixinApplicationElementX mixinApplication =
new UnnamedMixinApplicationElementX("${superName}+${mixinName}",
element, resolution.idGenerator.getNextFreeId(), node);
// Create synthetic type variables for the mixin application.
- List<DartType> typeVariables = <DartType>[];
+ List<ResolutionDartType> typeVariables = <ResolutionDartType>[];
int index = 0;
- for (TypeVariableType type in element.typeVariables) {
+ for (ResolutionTypeVariableType type in element.typeVariables) {
TypeVariableElementX typeVariableElement = new TypeVariableElementX(
type.name, mixinApplication, index, type.element.node);
- TypeVariableType typeVariable = new TypeVariableType(typeVariableElement);
+ ResolutionTypeVariableType typeVariable =
+ new ResolutionTypeVariableType(typeVariableElement);
typeVariables.add(typeVariable);
index++;
}
// Setup bounds on the synthetic type variables.
- for (TypeVariableType type in element.typeVariables) {
- TypeVariableType typeVariable = typeVariables[type.element.index];
+ for (ResolutionTypeVariableType type in element.typeVariables) {
+ ResolutionTypeVariableType typeVariable =
+ typeVariables[type.element.index];
TypeVariableElementX typeVariableElement = typeVariable.element;
typeVariableElement.typeCache = typeVariable;
typeVariableElement.boundCache =
@@ -327,7 +331,7 @@
mixinApplication.supertypeLoadState = STATE_DONE;
// Replace the synthetic type variables by the original type variables in
// the returned type (which should be the type actually extended).
- InterfaceType mixinThisType = mixinApplication.thisType;
+ ResolutionInterfaceType mixinThisType = mixinApplication.thisType;
return mixinThisType.subst(
element.typeVariables, mixinThisType.typeArguments);
}
@@ -348,7 +352,7 @@
}
void doApplyMixinTo(MixinApplicationElementX mixinApplication,
- DartType supertype, DartType mixinType) {
+ ResolutionDartType supertype, ResolutionDartType mixinType) {
Node node = mixinApplication.parseNode(resolution.parsingContext);
if (mixinApplication.supertype != null) {
@@ -363,10 +367,10 @@
// Named mixin application may have an 'implements' clause.
NamedMixinApplication namedMixinApplication =
node.asNamedMixinApplication();
- Link<DartType> interfaces = (namedMixinApplication != null)
+ Link<ResolutionDartType> interfaces = (namedMixinApplication != null)
? resolveInterfaces(
namedMixinApplication.interfaces, namedMixinApplication.superclass)
- : const Link<DartType>();
+ : const Link<ResolutionDartType>();
// The class that is the result of a mixin application implements
// the interface of the class that was mixed in so always prepend
@@ -383,7 +387,7 @@
}
ClassElement superclass = supertype.element;
- if (mixinType.kind != TypeKind.INTERFACE) {
+ if (mixinType.kind != ResolutionTypeKind.INTERFACE) {
mixinApplication.hasIncompleteHierarchy = true;
mixinApplication.allSupertypesAndSelf = superclass.allSupertypesAndSelf;
return;
@@ -411,8 +415,8 @@
calculateAllSupertypes(mixinApplication);
}
- InterfaceType resolveMixinFor(
- MixinApplicationElement mixinApplication, DartType mixinType) {
+ ResolutionInterfaceType resolveMixinFor(
+ MixinApplicationElement mixinApplication, ResolutionDartType mixinType) {
ClassElement mixin = mixinType.element;
mixin.ensureResolved(resolution);
@@ -437,12 +441,13 @@
return mixinType;
}
- DartType resolveType(TypeAnnotation node) {
+ ResolutionDartType resolveType(TypeAnnotation node) {
return typeResolver.resolveTypeAnnotation(this, node);
}
- DartType resolveSupertype(ClassElement cls, TypeAnnotation superclass) {
- DartType supertype = resolveType(superclass);
+ ResolutionDartType resolveSupertype(
+ ClassElement cls, TypeAnnotation superclass) {
+ ResolutionDartType supertype = resolveType(superclass);
if (supertype != null) {
if (supertype.isMalformed) {
reporter.reportErrorMessage(
@@ -467,11 +472,12 @@
return supertype;
}
- Link<DartType> resolveInterfaces(NodeList interfaces, Node superclass) {
- Link<DartType> result = const Link<DartType>();
+ Link<ResolutionDartType> resolveInterfaces(
+ NodeList interfaces, Node superclass) {
+ Link<ResolutionDartType> result = const Link<ResolutionDartType>();
if (interfaces == null) return result;
for (Link<Node> link = interfaces.nodes; !link.isEmpty; link = link.tail) {
- DartType interfaceType = resolveType(link.head);
+ ResolutionDartType interfaceType = resolveType(link.head);
if (interfaceType != null) {
if (interfaceType.isMalformed) {
reporter.reportErrorMessage(
@@ -532,7 +538,7 @@
*/
void calculateAllSupertypes(BaseClassElementX cls) {
if (cls.allSupertypesAndSelf != null) return;
- final DartType supertype = cls.supertype;
+ final ResolutionDartType supertype = cls.supertype;
if (supertype != null) {
cls.allSupertypesAndSelf = new OrderedTypeSetBuilder(cls,
reporter: reporter, objectType: commonElements.objectType)
@@ -544,7 +550,7 @@
}
}
- isBlackListed(DartType type) {
+ isBlackListed(ResolutionDartType type) {
LibraryElement lib = element.library;
return !identical(lib, resolution.commonElements.coreLibrary) &&
!resolution.target.isTargetSpecificLibrary(lib) &&
diff --git a/pkg/compiler/lib/src/resolution/class_members.dart b/pkg/compiler/lib/src/resolution/class_members.dart
index 07bf004..f2f670b 100644
--- a/pkg/compiler/lib/src/resolution/class_members.dart
+++ b/pkg/compiler/lib/src/resolution/class_members.dart
@@ -7,7 +7,7 @@
import '../common.dart';
import '../common/names.dart' show Identifiers, Names;
import '../common/resolution.dart' show Resolution;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart'
show
ClassElement,
@@ -99,7 +99,7 @@
/// If [name] and [names] are not null, the computation is restricted to
/// members with these names.
void computeSuperClassMembers(String name, Setlet<Name> names) {
- InterfaceType supertype = cls.supertype;
+ ResolutionInterfaceType supertype = cls.supertype;
if (supertype == null) return;
ClassElement superclass = supertype.element;
@@ -162,7 +162,7 @@
}
} else {
LibraryElement library = cls.library;
- InterfaceType thisType = cls.thisType;
+ ResolutionInterfaceType thisType = cls.thisType;
void createMember(MemberElement element) {
if (element.isConstructor) return;
@@ -170,8 +170,8 @@
if (shouldSkipName(elementName)) return;
if (nameText != null && elementName != nameText) return;
- void addDeclaredMember(
- Name name, DartType type, FunctionType functionType) {
+ void addDeclaredMember(Name name, ResolutionDartType type,
+ ResolutionFunctionType functionType) {
DeclaredMember inherited = classMembers[name];
DeclaredMember declared;
if (element.isAbstract) {
@@ -188,32 +188,33 @@
Name name = new Name(element.name, library);
if (element.isField) {
- DartType type = element.computeType(resolution);
- addDeclaredMember(name, type, new FunctionType.synthesized(type));
+ ResolutionDartType type = element.computeType(resolution);
+ addDeclaredMember(
+ name, type, new ResolutionFunctionType.synthesized(type));
if (!element.isConst && !element.isFinal) {
addDeclaredMember(
name.setter,
type,
- new FunctionType.synthesized(
- const VoidType(), <DartType>[type]));
+ new ResolutionFunctionType.synthesized(
+ const ResolutionVoidType(), <ResolutionDartType>[type]));
}
} else if (element.isGetter) {
- FunctionType functionType = element.computeType(resolution);
- DartType type = functionType.returnType;
+ ResolutionFunctionType functionType = element.computeType(resolution);
+ ResolutionDartType type = functionType.returnType;
addDeclaredMember(name, type, functionType);
} else if (element.isSetter) {
- FunctionType functionType = element.computeType(resolution);
- DartType type;
+ ResolutionFunctionType functionType = element.computeType(resolution);
+ ResolutionDartType type;
if (!functionType.parameterTypes.isEmpty) {
type = functionType.parameterTypes.first;
} else {
- type = const DynamicType();
+ type = const ResolutionDynamicType();
}
name = name.setter;
addDeclaredMember(name, type, functionType);
} else {
assert(invariant(element, element.isFunction));
- FunctionType type = element.computeType(resolution);
+ ResolutionFunctionType type = element.computeType(resolution);
addDeclaredMember(name, type, type);
}
}
@@ -380,7 +381,7 @@
}
}
- DartType declaredType = declared.functionType;
+ ResolutionDartType declaredType = declared.functionType;
for (Member inherited in superMember.declarations) {
if (inherited.element == declared.element) {
// TODO(ahe): For some reason, "call" elements are repeated in
@@ -425,7 +426,7 @@
reportError(MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD,
MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT);
} else {
- DartType inheritedType = inherited.functionType;
+ ResolutionDartType inheritedType = inherited.functionType;
if (!resolution.types.isSubtype(declaredType, inheritedType)) {
void reportWarning(
var marker, MessageKind warningKind, MessageKind infoKind) {
@@ -595,7 +596,7 @@
Map<Name, Setlet<Member>> computeSuperInterfaceMembers(
String name, Setlet<Name> names) {
- InterfaceType supertype = cls.supertype;
+ ResolutionInterfaceType supertype = cls.supertype;
assert(invariant(cls, supertype != null,
message: "Interface members computed for $cls."));
ClassElement superclass = supertype.element;
@@ -604,7 +605,7 @@
new Map<Name, Setlet<Member>>();
void inheritInterfaceMember(
- InterfaceType supertype, MemberSignature member) {
+ ResolutionInterfaceType supertype, MemberSignature member) {
if (shouldSkipMember(member)) return;
Setlet<Member> members = inheritedInterfaceMembers.putIfAbsent(
member.name, () => new Setlet<Member>());
@@ -613,7 +614,7 @@
}
}
- void inheritInterfaceMembers(InterfaceType supertype) {
+ void inheritInterfaceMembers(ResolutionInterfaceType supertype) {
supertype.element.forEachInterfaceMember((MemberSignature member) {
inheritInterfaceMember(supertype, member);
});
@@ -629,10 +630,10 @@
}
// Inherit interface members from superinterfaces.
- for (Link<DartType> link = cls.interfaces;
+ for (Link<ResolutionDartType> link = cls.interfaces;
!link.isEmpty;
link = link.tail) {
- InterfaceType superinterface = link.head;
+ ResolutionInterfaceType superinterface = link.head;
if (names != null) {
MembersCreator._computeClassMember(
resolution, superinterface.element, name, names);
@@ -668,7 +669,7 @@
void computeInterfaceMembers(
Map<Name, Setlet<Member>> inheritedInterfaceMembers,
Map<Name, Member> declaredMembers) {
- InterfaceType thisType = cls.thisType;
+ ResolutionInterfaceType thisType = cls.thisType;
// Compute the interface members by overriding the inherited members with
// a declared member or by computing a single, possibly synthesized,
// inherited member.
@@ -688,8 +689,8 @@
} else {
bool someAreGetters = false;
bool allAreGetters = true;
- Map<DartType, Setlet<Member>> subtypesOfAllInherited =
- new Map<DartType, Setlet<Member>>();
+ Map<ResolutionDartType, Setlet<Member>> subtypesOfAllInherited =
+ new Map<ResolutionDartType, Setlet<Member>>();
outer:
for (Member inherited in inheritedMembers) {
if (inherited.isGetter) {
@@ -773,7 +774,7 @@
requiredParameters = 1;
}
if (member.type.isFunctionType) {
- FunctionType type = member.type;
+ ResolutionFunctionType type = member.type;
type.namedParameters.forEach((String name) => names.add(name));
requiredParameters = type.parameterTypes.length;
optionalParameters = type.optionalParameterTypes.length;
@@ -792,24 +793,25 @@
// TODO(johnniwinther): Support function types with both optional
// and named parameters?
if (optionalParameters == 0 || names.isEmpty) {
- DartType dynamic = const DynamicType();
- List<DartType> requiredParameterTypes =
+ ResolutionDartType dynamic = const ResolutionDynamicType();
+ List<ResolutionDartType> requiredParameterTypes =
new List.filled(minRequiredParameters, dynamic);
- List<DartType> optionalParameterTypes =
+ List<ResolutionDartType> optionalParameterTypes =
new List.filled(optionalParameters, dynamic);
List<String> namedParameters = names.toList()
..sort((a, b) => a.compareTo(b));
- List<DartType> namedParameterTypes =
+ List<ResolutionDartType> namedParameterTypes =
new List.filled(namedParameters.length, dynamic);
- FunctionType memberType = new FunctionType.synthesized(
- const DynamicType(),
- requiredParameterTypes,
- optionalParameterTypes,
- namedParameters,
- namedParameterTypes);
- DartType type = memberType;
+ ResolutionFunctionType memberType =
+ new ResolutionFunctionType.synthesized(
+ const ResolutionDynamicType(),
+ requiredParameterTypes,
+ optionalParameterTypes,
+ namedParameters,
+ namedParameterTypes);
+ ResolutionDartType type = memberType;
if (inheritedMembers.first.isGetter || inheritedMembers.first.isSetter) {
- type = const DynamicType();
+ type = const ResolutionDynamicType();
}
interfaceMembers[name] =
new SyntheticMember(inheritedMembers, type, memberType);
diff --git a/pkg/compiler/lib/src/resolution/constructors.dart b/pkg/compiler/lib/src/resolution/constructors.dart
index 6a4ab3b..bd127d0 100644
--- a/pkg/compiler/lib/src/resolution/constructors.dart
+++ b/pkg/compiler/lib/src/resolution/constructors.dart
@@ -11,7 +11,7 @@
GenerativeConstantConstructor,
RedirectingGenerativeConstantConstructor;
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart'
show
@@ -139,7 +139,7 @@
}
}
- InterfaceType getSuperOrThisLookupTarget(Node diagnosticNode,
+ ResolutionInterfaceType getSuperOrThisLookupTarget(Node diagnosticNode,
{bool isSuperCall}) {
if (isSuperCall) {
// Calculate correct lookup target and constructor name.
@@ -163,7 +163,7 @@
}, inConstantInitializer: isConst);
bool isSuperCall = Initializers.isSuperConstructorCall(node);
- InterfaceType targetType =
+ ResolutionInterfaceType targetType =
getSuperOrThisLookupTarget(node, isSuperCall: isSuperCall);
ClassElement lookupTarget = targetType.element;
String constructorName =
@@ -210,7 +210,7 @@
assert(superClass != null);
assert(superClass.isResolved);
- InterfaceType targetType =
+ ResolutionInterfaceType targetType =
getSuperOrThisLookupTarget(functionNode, isSuperCall: true);
ClassElement lookupTarget = targetType.element;
ConstructorElement calledConstructor =
@@ -488,7 +488,7 @@
ConstructorResult reportAndCreateErroneousConstructorElement(
Spannable diagnosticNode,
ConstructorResultKind resultKind,
- DartType type,
+ ResolutionDartType type,
String name,
MessageKind kind,
Map arguments,
@@ -515,8 +515,11 @@
return new ConstructorResult.forError(resultKind, error, type);
}
- ConstructorResult resolveConstructor(PrefixElement prefix, InterfaceType type,
- Node diagnosticNode, String constructorName) {
+ ConstructorResult resolveConstructor(
+ PrefixElement prefix,
+ ResolutionInterfaceType type,
+ Node diagnosticNode,
+ String constructorName) {
ClassElement cls = type.element;
cls.ensureResolved(resolution);
ConstructorElement constructor =
@@ -616,7 +619,7 @@
ConstructorResult visitTypeAnnotation(TypeAnnotation node) {
// This is not really resolving a type-annotation, but the name of the
// constructor. Therefore we allow deferred types.
- DartType type = resolver.resolveTypeAnnotation(node,
+ ResolutionDartType type = resolver.resolveTypeAnnotation(node,
malformedIsError: inConstContext,
deferredIsMalformed: false,
registerCheckedModeCheck: false);
@@ -747,7 +750,7 @@
error, new MalformedType(error, null));
}
- ConstructorResult constructorResultForType(Node node, DartType type,
+ ConstructorResult constructorResultForType(Node node, ResolutionDartType type,
{PrefixElement prefix}) {
String name = type.name;
if (type.isTypeVariable) {
@@ -816,12 +819,12 @@
/// The type of the new expression. For instance `Foo<String>` in
/// `new prefix.Foo<String>.constructorName()`.
- final DartType type;
+ final ResolutionDartType type;
/// Creates a fully resolved constructor access where [element] is resolved
/// to a constructor and [type] to an interface type.
ConstructorResult(this.kind, this.prefix, ConstructorElement this.element,
- InterfaceType this.type);
+ ResolutionInterfaceType this.type);
/// Creates a fully resolved constructor access where [element] is an
/// [ErroneousElement].
diff --git a/pkg/compiler/lib/src/resolution/enum_creator.dart b/pkg/compiler/lib/src/resolution/enum_creator.dart
index 6b94c22..5fd1a68 100644
--- a/pkg/compiler/lib/src/resolution/enum_creator.dart
+++ b/pkg/compiler/lib/src/resolution/enum_creator.dart
@@ -6,7 +6,7 @@
import '../common.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart';
import '../tokens/keyword.dart' show Keyword;
@@ -206,13 +206,14 @@
void createMembers() {
Enum node = enumClass.node;
- InterfaceType enumType = enumClass.thisType;
+ ResolutionInterfaceType enumType = enumClass.thisType;
AstBuilder builder = new AstBuilder(enumClass.position.charOffset);
- InterfaceType intType = commonElements.intType;
- InterfaceType stringType = commonElements.stringType;
+ ResolutionInterfaceType intType = commonElements.intType;
+ ResolutionInterfaceType stringType = commonElements.stringType;
- EnumFieldElementX addInstanceMember(String name, InterfaceType type) {
+ EnumFieldElementX addInstanceMember(
+ String name, ResolutionInterfaceType type) {
Identifier identifier = builder.identifier(name);
VariableList variableList =
new VariableList(builder.modifiers(isFinal: true));
@@ -243,8 +244,8 @@
FunctionSignatureX constructorSignature = new FunctionSignatureX(
requiredParameters: [indexFormal],
requiredParameterCount: 1,
- type: new FunctionType(
- constructor, const DynamicType(), <DartType>[intType]));
+ type: new ResolutionFunctionType(constructor,
+ const ResolutionDynamicType(), <ResolutionDartType>[intType]));
constructor.functionSignature = constructorSignature;
enumClass.addMember(constructor, reporter);
@@ -308,8 +309,8 @@
EnumMethodElementX toString = new EnumMethodElementX(
'toString', enumClass, Modifiers.EMPTY, toStringNode);
- FunctionSignatureX toStringSignature =
- new FunctionSignatureX(type: new FunctionType(toString, stringType));
+ FunctionSignatureX toStringSignature = new FunctionSignatureX(
+ type: new ResolutionFunctionType(toString, stringType));
toString.functionSignature = toStringSignature;
enumClass.addMember(toString, reporter);
diff --git a/pkg/compiler/lib/src/resolution/member_impl.dart b/pkg/compiler/lib/src/resolution/member_impl.dart
index 8c4eb1c..70f2a7a 100644
--- a/pkg/compiler/lib/src/resolution/member_impl.dart
+++ b/pkg/compiler/lib/src/resolution/member_impl.dart
@@ -7,9 +7,9 @@
class DeclaredMember implements Member {
final Name name;
final Element element;
- final InterfaceType declarer;
- final DartType type;
- final FunctionType functionType;
+ final ResolutionInterfaceType declarer;
+ final ResolutionDartType type;
+ final ResolutionFunctionType functionType;
DeclaredMember(
this.name, this.element, this.declarer, this.type, this.functionType);
@@ -36,7 +36,7 @@
/// class C<U> extends B<U> {}
/// The member `T m()` is declared in `A<T>` and inherited from `A<S>` into
/// `B` as `S m()`, and further from `B<U>` into `C` as `U m()`.
- DeclaredMember inheritFrom(InterfaceType instance) {
+ DeclaredMember inheritFrom(ResolutionInterfaceType instance) {
// If the member is declared in a non-generic class its type cannot change
// as a result of inheritance.
if (!declarer.isGeneric) return this;
@@ -44,7 +44,7 @@
return _newInheritedMember(instance);
}
- InheritedMember _newInheritedMember(InterfaceType instance) {
+ InheritedMember _newInheritedMember(ResolutionInterfaceType instance) {
return new InheritedMember(this, instance);
}
@@ -63,7 +63,7 @@
return sb.toString();
}
- void printOn(StringBuffer sb, DartType type) {
+ void printOn(StringBuffer sb, ResolutionDartType type) {
if (isStatic) {
sb.write('static ');
}
@@ -89,13 +89,18 @@
class DeclaredAbstractMember extends DeclaredMember {
final DeclaredMember implementation;
- DeclaredAbstractMember(Name name, Element element, InterfaceType declarer,
- DartType type, FunctionType functionType, this.implementation)
+ DeclaredAbstractMember(
+ Name name,
+ Element element,
+ ResolutionInterfaceType declarer,
+ ResolutionDartType type,
+ ResolutionFunctionType functionType,
+ this.implementation)
: super(name, element, declarer, type, functionType);
bool get isAbstract => true;
- InheritedMember _newInheritedMember(InterfaceType instance) {
+ InheritedMember _newInheritedMember(ResolutionInterfaceType instance) {
return new InheritedAbstractMember(this, instance,
implementation != null ? implementation.inheritFrom(instance) : null);
}
@@ -103,10 +108,10 @@
class InheritedMember implements DeclaredMember {
final DeclaredMember declaration;
- final InterfaceType instance;
+ final ResolutionInterfaceType instance;
InheritedMember(
- DeclaredMember this.declaration, InterfaceType this.instance) {
+ DeclaredMember this.declaration, ResolutionInterfaceType this.instance) {
assert(instance.isGeneric);
assert(!declaration.isStatic);
}
@@ -115,7 +120,7 @@
Name get name => declaration.name;
- InterfaceType get declarer => instance;
+ ResolutionInterfaceType get declarer => instance;
bool get isStatic => false;
@@ -131,13 +136,13 @@
Member get implementation => this;
- DartType get type => declaration.type.substByContext(instance);
+ ResolutionDartType get type => declaration.type.substByContext(instance);
- FunctionType get functionType {
+ ResolutionFunctionType get functionType {
return declaration.functionType.substByContext(instance);
}
- DeclaredMember inheritFrom(InterfaceType newInstance) {
+ DeclaredMember inheritFrom(ResolutionInterfaceType newInstance) {
assert(invariant(declaration.element, () {
// Assert that if [instance] contains type variables, then these are
// defined in the declaration of [newInstance] and will therefore be
@@ -152,7 +157,7 @@
return _newInheritedMember(newInstance);
}
- InheritedMember _newInheritedMember(InterfaceType newInstance) {
+ InheritedMember _newInheritedMember(ResolutionInterfaceType newInstance) {
return new InheritedMember(
declaration, instance.substByContext(newInstance));
}
@@ -166,7 +171,7 @@
return declaration == other.declaration && instance == other.instance;
}
- void printOn(StringBuffer sb, DartType type) {
+ void printOn(StringBuffer sb, ResolutionDartType type) {
declaration.printOn(sb, type);
sb.write(' inherited from $instance');
}
@@ -181,13 +186,13 @@
class InheritedAbstractMember extends InheritedMember {
final DeclaredMember implementation;
- InheritedAbstractMember(
- DeclaredMember declaration, InterfaceType instance, this.implementation)
+ InheritedAbstractMember(DeclaredMember declaration,
+ ResolutionInterfaceType instance, this.implementation)
: super(declaration, instance);
bool get isAbstract => true;
- InheritedMember _newInheritedMember(InterfaceType newInstance) {
+ InheritedMember _newInheritedMember(ResolutionInterfaceType newInstance) {
return new InheritedAbstractMember(
declaration,
instance.substByContext(newInstance),
@@ -210,8 +215,8 @@
}
class SyntheticMember extends AbstractSyntheticMember {
- final DartType type;
- final FunctionType functionType;
+ final ResolutionDartType type;
+ final ResolutionFunctionType functionType;
SyntheticMember(Setlet<Member> inheritedMembers, this.type, this.functionType)
: super(inheritedMembers);
@@ -231,9 +236,9 @@
class ErroneousMember extends AbstractSyntheticMember {
ErroneousMember(Setlet<Member> inheritedMembers) : super(inheritedMembers);
- DartType get type => functionType;
+ ResolutionDartType get type => functionType;
- FunctionType get functionType {
+ ResolutionFunctionType get functionType {
throw new UnsupportedError('Erroneous members have no type.');
}
diff --git a/pkg/compiler/lib/src/resolution/members.dart b/pkg/compiler/lib/src/resolution/members.dart
index 85b4902..8fa327f 100644
--- a/pkg/compiler/lib/src/resolution/members.dart
+++ b/pkg/compiler/lib/src/resolution/members.dart
@@ -13,7 +13,7 @@
import '../constants/expressions.dart';
import '../constants/values.dart';
import '../core_types.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart'
show
@@ -338,7 +338,7 @@
// objects than [Element] from this method.
element = commonElements.typeClass;
// Set the type to be `dynamic` to mark that this is a type literal.
- registry.setType(node, const DynamicType());
+ registry.setType(node, const ResolutionDynamicType());
}
element = reportLookupErrorIfAny(element, node, name);
if (element == null) {
@@ -413,7 +413,7 @@
// Create the scope where the type variables are introduced, if any.
scope = new MethodScope(scope, function);
functionSignature.typeVariables
- .forEach((DartType type) => addToScope(type.element));
+ .forEach((ResolutionDartType type) => addToScope(type.element));
// Create the scope for the function body, and put the parameters in scope.
scope = new BlockScope(scope);
@@ -1101,7 +1101,7 @@
// mutation/access to unpromoted variables.
Send notTypeNode = node.arguments.head.asSend();
- DartType type;
+ ResolutionDartType type;
SendStructure sendStructure;
if (notTypeNode != null) {
// `e is! T`.
@@ -1133,7 +1133,7 @@
visitExpression(expression);
Node typeNode = node.arguments.head;
- DartType type =
+ ResolutionDartType type =
resolveTypeAnnotation(typeNode, registerCheckedModeCheck: false);
// GENERIC_METHODS: Method type variables are not reified, so we must inform
@@ -1195,7 +1195,7 @@
if (expressionResult.isConstant) {
bool isValidConstant;
ConstantExpression expressionConstant = expressionResult.constant;
- DartType knownExpressionType =
+ ResolutionDartType knownExpressionType =
expressionConstant.getKnownType(commonElements);
switch (operator.kind) {
case UnaryOperatorKind.COMPLEMENT:
@@ -1372,8 +1372,10 @@
bool isValidConstant;
ConstantExpression leftConstant = leftResult.constant;
ConstantExpression rightConstant = rightResult.constant;
- DartType knownLeftType = leftConstant.getKnownType(commonElements);
- DartType knownRightType = rightConstant.getKnownType(commonElements);
+ ResolutionDartType knownLeftType =
+ leftConstant.getKnownType(commonElements);
+ ResolutionDartType knownRightType =
+ rightConstant.getKnownType(commonElements);
switch (operator.kind) {
case BinaryOperatorKind.EQ:
case BinaryOperatorKind.NOT_EQ:
@@ -1978,8 +1980,12 @@
// the [GetStructure].
// TODO(johnniwinther): Remove [element] when it is no longer needed for
// evaluating constants.
- ResolutionResult handleConstantTypeLiteralAccess(Send node, Name name,
- TypeDeclarationElement element, DartType type, ConstantAccess semantics) {
+ ResolutionResult handleConstantTypeLiteralAccess(
+ Send node,
+ Name name,
+ TypeDeclarationElement element,
+ ResolutionDartType type,
+ ConstantAccess semantics) {
registry.useElement(node, element);
registry.registerTypeLiteral(node, type);
@@ -2013,8 +2019,12 @@
// the [GetStructure].
// TODO(johnniwinther): Remove [element] when it is no longer needed for
// evaluating constants.
- ResolutionResult handleConstantTypeLiteralUpdate(SendSet node, Name name,
- TypeDeclarationElement element, DartType type, ConstantAccess semantics) {
+ ResolutionResult handleConstantTypeLiteralUpdate(
+ SendSet node,
+ Name name,
+ TypeDeclarationElement element,
+ ResolutionDartType type,
+ ConstantAccess semantics) {
// TODO(johnniwinther): Remove this when all constants are evaluated.
resolver.constantCompiler.evaluate(semantics.constant);
@@ -2045,7 +2055,7 @@
ResolutionResult handleTypedefTypeLiteralAccess(
Send node, Name name, TypedefElement typdef) {
typdef.ensureResolved(resolution);
- DartType type = typdef.rawType;
+ ResolutionDartType type = typdef.rawType;
ConstantExpression constant = new TypeConstantExpression(type);
AccessSemantics semantics = new ConstantAccess.typedefTypeLiteral(constant);
return handleConstantTypeLiteralAccess(node, name, typdef, type, semantics);
@@ -2056,7 +2066,7 @@
ResolutionResult handleTypedefTypeLiteralUpdate(
SendSet node, Name name, TypedefElement typdef) {
typdef.ensureResolved(resolution);
- DartType type = typdef.rawType;
+ ResolutionDartType type = typdef.rawType;
ConstantExpression constant = new TypeConstantExpression(type);
AccessSemantics semantics = new ConstantAccess.typedefTypeLiteral(constant);
return handleConstantTypeLiteralUpdate(node, name, typdef, type, semantics);
@@ -2065,7 +2075,7 @@
/// Handle access to a type literal of the type 'dynamic'. Like `dynamic` or
/// `dynamic()`.
ResolutionResult handleDynamicTypeLiteralAccess(Send node) {
- DartType type = const DynamicType();
+ ResolutionDartType type = const ResolutionDynamicType();
ConstantExpression constant = new TypeConstantExpression(
// TODO(johnniwinther): Use [type] when evaluation of constants is done
// directly on the constant expressions.
@@ -2078,9 +2088,9 @@
/// Handle update to a type literal of the type 'dynamic'. Like `dynamic++` or
/// `dynamic = 0`.
ResolutionResult handleDynamicTypeLiteralUpdate(SendSet node) {
- DartType type = const DynamicType();
+ ResolutionDartType type = const ResolutionDynamicType();
ConstantExpression constant =
- new TypeConstantExpression(const DynamicType());
+ new TypeConstantExpression(const ResolutionDynamicType());
AccessSemantics semantics = new ConstantAccess.dynamicTypeLiteral(constant);
return handleConstantTypeLiteralUpdate(node, const PublicName('dynamic'),
commonElements.typeClass, type, semantics);
@@ -2091,7 +2101,7 @@
ResolutionResult handleClassTypeLiteralAccess(
Send node, Name name, ClassElement cls) {
cls.ensureResolved(resolution);
- DartType type = cls.rawType;
+ ResolutionDartType type = cls.rawType;
ConstantExpression constant = new TypeConstantExpression(type);
AccessSemantics semantics = new ConstantAccess.classTypeLiteral(constant);
return handleConstantTypeLiteralAccess(node, name, cls, type, semantics);
@@ -2102,7 +2112,7 @@
ResolutionResult handleClassTypeLiteralUpdate(
SendSet node, Name name, ClassElement cls) {
cls.ensureResolved(resolution);
- DartType type = cls.rawType;
+ ResolutionDartType type = cls.rawType;
ConstantExpression constant = new TypeConstantExpression(type);
AccessSemantics semantics = new ConstantAccess.classTypeLiteral(constant);
return handleConstantTypeLiteralUpdate(node, name, cls, type, semantics);
@@ -3042,7 +3052,7 @@
}
/// Callback for native enqueuer to parse a type. Returns [:null:] on error.
- DartType resolveTypeFromString(Node node, String typeName) {
+ ResolutionDartType resolveTypeFromString(Node node, String typeName) {
Element element = lookupInScope(reporter, node, scope, typeName);
if (element == null) return null;
if (element is! ClassElement) return null;
@@ -3659,11 +3669,12 @@
// Check that the target constructor is type compatible with the
// redirecting constructor.
ClassElement targetClass = redirectionTarget.enclosingClass;
- InterfaceType type = registry.getType(node);
- FunctionType targetConstructorType = redirectionTarget
+ ResolutionInterfaceType type = registry.getType(node);
+ ResolutionFunctionType targetConstructorType = redirectionTarget
.computeType(resolution)
.subst(type.typeArguments, targetClass.typeVariables);
- FunctionType constructorType = constructor.computeType(resolution);
+ ResolutionFunctionType constructorType =
+ constructor.computeType(resolution);
bool isSubtype =
resolution.types.isSubtype(targetConstructorType, constructorType);
if (!isSubtype) {
@@ -3672,7 +3683,7 @@
// TODO(johnniwinther): Handle this (potentially) erroneous case.
isValidAsConstant = false;
}
- if (type.typeArguments.any((DartType type) => !type.isDynamic)) {
+ if (type.typeArguments.any((ResolutionDartType type) => !type.isDynamic)) {
registry.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK);
}
@@ -3738,11 +3749,11 @@
}
ResolutionResult visitVariableDefinitions(VariableDefinitions node) {
- DartType type;
+ ResolutionDartType type;
if (node.type != null) {
type = resolveTypeAnnotation(node.type);
} else {
- type = const DynamicType();
+ type = const ResolutionDynamicType();
}
VariableList variables = new VariableList.node(node, type);
VariableDefinitionsVisitor visitor =
@@ -3823,7 +3834,7 @@
CallStructure callStructure = selector.callStructure;
registry.useElement(node.send, constructor);
- DartType type = result.type;
+ ResolutionDartType type = result.type;
ConstructorAccessKind kind;
bool isInvalid = false;
switch (result.kind) {
@@ -3896,8 +3907,9 @@
constructor.declaration, callStructure, type)
: new StaticUse.typedConstructorInvoke(
constructor.declaration, callStructure, type));
- InterfaceType interfaceType = type;
- if (interfaceType.typeArguments.any((DartType type) => !type.isDynamic)) {
+ ResolutionInterfaceType interfaceType = type;
+ if (interfaceType.typeArguments
+ .any((ResolutionDartType type) => !type.isDynamic)) {
registry.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK);
}
}
@@ -3913,7 +3925,7 @@
.compileNode(argumentNode, registry.mapping);
ConstantValue name = resolution.constants.getConstantValue(constant);
if (!name.isString) {
- DartType type = name.getType(commonElements);
+ ResolutionDartType type = name.getType(commonElements);
reporter.reportErrorMessage(
argumentNode, MessageKind.STRING_EXPECTED, {'type': type});
} else {
@@ -4004,7 +4016,7 @@
for (ConstantValue key in map.keys) {
if (!key.isObject) continue;
ObjectConstantValue objectConstant = key;
- DartType keyType = objectConstant.type;
+ ResolutionDartType keyType = objectConstant.type;
ClassElement cls = keyType.element;
if (cls == commonElements.stringClass) continue;
Element equals = cls.lookupMember('==');
@@ -4075,11 +4087,11 @@
inConstContext: inConstContext));
}
- DartType resolveTypeAnnotation(TypeAnnotation node,
+ ResolutionDartType resolveTypeAnnotation(TypeAnnotation node,
{bool malformedIsError: false,
bool deferredIsMalformed: true,
bool registerCheckedModeCheck: true}) {
- DartType type = typeResolver.resolveTypeAnnotation(this, node,
+ ResolutionDartType type = typeResolver.resolveTypeAnnotation(this, node,
malformedIsError: malformedIsError,
deferredIsMalformed: deferredIsMalformed);
if (registerCheckedModeCheck) {
@@ -4093,7 +4105,7 @@
sendIsMemberAccess = false;
NodeList arguments = node.typeArguments;
- DartType typeArgument;
+ ResolutionDartType typeArgument;
if (arguments != null) {
Link<Node> nodes = arguments.nodes;
if (nodes.isEmpty) {
@@ -4110,7 +4122,7 @@
}
}
}
- DartType listType;
+ ResolutionDartType listType;
if (typeArgument != null) {
if (node.isConst && typeArgument.containsTypeVariables) {
reporter.reportErrorMessage(
@@ -4388,8 +4400,8 @@
sendIsMemberAccess = false;
NodeList arguments = node.typeArguments;
- DartType keyTypeArgument;
- DartType valueTypeArgument;
+ ResolutionDartType keyTypeArgument;
+ ResolutionDartType valueTypeArgument;
if (arguments != null) {
Link<Node> nodes = arguments.nodes;
if (nodes.isEmpty) {
@@ -4413,7 +4425,7 @@
}
}
}
- DartType mapType;
+ ResolutionDartType mapType;
if (valueTypeArgument != null) {
mapType = commonElements.mapType(keyTypeArgument, valueTypeArgument);
} else {
@@ -4468,7 +4480,7 @@
return visit(node.expression);
}
- DartType typeOfConstant(ConstantValue constant) {
+ ResolutionDartType typeOfConstant(ConstantValue constant) {
if (constant.isInt) return commonElements.intType;
if (constant.isBool) return commonElements.boolType;
if (constant.isDouble) return commonElements.doubleType;
@@ -4480,7 +4492,7 @@
return objectConstant.type;
}
- bool overridesEquals(DartType type) {
+ bool overridesEquals(ResolutionDartType type) {
ClassElement cls = type.element;
Element equals = cls.lookupMember('==');
return equals.enclosingClass != commonElements.objectClass;
@@ -4488,7 +4500,7 @@
void checkCaseExpressions(SwitchStatement node) {
CaseMatch firstCase = null;
- DartType firstCaseType = null;
+ ResolutionDartType firstCaseType = null;
DiagnosticMessage error;
List<DiagnosticMessage> infos = <DiagnosticMessage>[];
@@ -4508,7 +4520,7 @@
message: 'No constant computed for $node'));
ConstantValue value = resolution.constants.getConstantValue(constant);
- DartType caseType =
+ ResolutionDartType caseType =
value.getType(commonElements); //typeOfConstant(value);
if (firstCaseType == null) {
@@ -4731,7 +4743,7 @@
inCatchBlock = oldInCatchBlock;
if (node.type != null) {
- DartType exceptionType =
+ ResolutionDartType exceptionType =
resolveTypeAnnotation(node.type, registerCheckedModeCheck: false);
if (exceptionDefinition != null) {
Node exceptionVariable = exceptionDefinition.definitions.nodes.head;
@@ -4745,7 +4757,7 @@
Node stackTraceVariable = stackTraceDefinition.definitions.nodes.head;
VariableElementX stackTraceElement =
registry.getDefinition(stackTraceVariable);
- InterfaceType stackTraceType = commonElements.stackTraceType;
+ ResolutionInterfaceType stackTraceType = commonElements.stackTraceType;
stackTraceElement.variables.type = stackTraceType;
}
return const NoneResult();
diff --git a/pkg/compiler/lib/src/resolution/registry.dart b/pkg/compiler/lib/src/resolution/registry.dart
index 3784bd9..83edcfe 100644
--- a/pkg/compiler/lib/src/resolution/registry.dart
+++ b/pkg/compiler/lib/src/resolution/registry.dart
@@ -9,7 +9,7 @@
show Backend, ForeignResolver, NativeRegistry;
import '../common/resolution.dart' show ResolutionImpact, Target;
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../diagnostics/source_span.dart';
import '../elements/elements.dart';
import '../tree/tree.dart';
@@ -230,16 +230,17 @@
// Node-to-Type mapping functionality.
//////////////////////////////////////////////////////////////////////////////
- DartType useType(Node annotation, DartType type) {
+ ResolutionDartType useType(Node annotation, ResolutionDartType type) {
if (type != null) {
mapping.setType(annotation, type);
}
return type;
}
- void setType(Node node, DartType type) => mapping.setType(node, type);
+ void setType(Node node, ResolutionDartType type) =>
+ mapping.setType(node, type);
- DartType getType(Node node) => mapping.getType(node);
+ ResolutionDartType getType(Node node) => mapping.getType(node);
//////////////////////////////////////////////////////////////////////////////
// Node-to-Constant mapping functionality.
@@ -334,7 +335,7 @@
}
/// Register checked mode check of [type] if it isn't `dynamic`.
- void registerCheckedModeCheck(DartType type) {
+ void registerCheckedModeCheck(ResolutionDartType type) {
if (!type.isDynamic) {
impactBuilder.registerTypeUse(new TypeUse.checkedModeCheck(type));
}
@@ -344,19 +345,19 @@
mapping.addSuperUse(span);
}
- void registerTypeLiteral(Send node, DartType type) {
+ void registerTypeLiteral(Send node, ResolutionDartType type) {
mapping.setType(node, type);
impactBuilder.registerTypeUse(new TypeUse.typeLiteral(type));
}
- void registerLiteralList(Node node, InterfaceType type,
+ void registerLiteralList(Node node, ResolutionInterfaceType type,
{bool isConstant, bool isEmpty}) {
setType(node, type);
impactBuilder.registerListLiteral(
new ListLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty));
}
- void registerMapLiteral(Node node, InterfaceType type,
+ void registerMapLiteral(Node node, ResolutionInterfaceType type,
{bool isConstant, bool isEmpty}) {
setType(node, type);
impactBuilder.registerMapLiteral(
@@ -394,7 +395,7 @@
return target.defaultSuperclass(element);
}
- void registerInstantiation(InterfaceType type) {
+ void registerInstantiation(ResolutionInterfaceType type) {
impactBuilder.registerTypeUse(new TypeUse.instantiation(type));
}
@@ -429,12 +430,12 @@
}
@override
- void registerInstantiatedType(InterfaceType type) {
+ void registerInstantiatedType(ResolutionInterfaceType type) {
registry.registerInstantiation(type);
}
@override
- DartType resolveTypeFromString(Node node, String typeName) {
+ ResolutionDartType resolveTypeFromString(Node node, String typeName) {
return visitor.resolveTypeFromString(node, typeName);
}
}
diff --git a/pkg/compiler/lib/src/resolution/resolution.dart b/pkg/compiler/lib/src/resolution/resolution.dart
index e4d8f21..59694a2 100644
--- a/pkg/compiler/lib/src/resolution/resolution.dart
+++ b/pkg/compiler/lib/src/resolution/resolution.dart
@@ -20,7 +20,7 @@
ErroneousConstantExpression;
import '../constants/values.dart' show ConstantValue;
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart'
show
@@ -310,7 +310,7 @@
// Ensure the signature of the synthesized element is
// resolved. This is the only place where the resolver is
// seeing this element.
- FunctionType type = element.computeType(resolution);
+ ResolutionFunctionType type = element.computeType(resolution);
if (!target.isMalformed) {
registry.registerStaticUse(new StaticUse.superConstructorInvoke(
// TODO(johnniwinther): Provide the right call structure for
@@ -366,13 +366,13 @@
}
ResolverVisitor visitor = visitorFor(element);
ResolutionRegistry registry = visitor.registry;
- // TODO(johnniwinther): Maybe remove this when placeholderCollector migrates
- // to the backend ast.
+ // TODO(johnniwinther): Maybe remove this when placeholderCollector
+ // migrates to the backend ast.
registry.defineElement(element.definition, element);
// TODO(johnniwinther): Share the resolved type between all variables
// declared in the same declaration.
if (tree.type != null) {
- DartType type = visitor.resolveTypeAnnotation(tree.type);
+ ResolutionDartType type = visitor.resolveTypeAnnotation(tree.type);
assert(invariant(
element,
element.variables.type == null ||
@@ -387,7 +387,7 @@
// Only assign the dynamic type if the element has no known type. This
// happens for enum fields where the type is known but is not in the
// synthesized AST.
- element.variables.type = const DynamicType();
+ element.variables.type = const ResolutionDynamicType();
} else {
registry.registerCheckedModeCheck(element.variables.type);
}
@@ -438,29 +438,32 @@
});
}
- DartType resolveTypeAnnotation(Element element, TypeAnnotation annotation) {
- DartType type = _resolveReturnType(element, annotation);
+ ResolutionDartType resolveTypeAnnotation(
+ Element element, TypeAnnotation annotation) {
+ ResolutionDartType type = _resolveReturnType(element, annotation);
if (type.isVoid) {
reporter.reportErrorMessage(annotation, MessageKind.VOID_NOT_ALLOWED);
}
return type;
}
- DartType _resolveReturnType(Element element, TypeAnnotation annotation) {
- if (annotation == null) return const DynamicType();
- DartType result = visitorFor(element).resolveTypeAnnotation(annotation);
+ ResolutionDartType _resolveReturnType(
+ Element element, TypeAnnotation annotation) {
+ if (annotation == null) return const ResolutionDynamicType();
+ ResolutionDartType result =
+ visitorFor(element).resolveTypeAnnotation(annotation);
assert(invariant(annotation, result != null,
message: "No type computed for $annotation."));
if (result == null) {
// TODO(karklose): warning.
- return const DynamicType();
+ return const ResolutionDynamicType();
}
return result;
}
void resolveRedirectionChain(ConstructorElement constructor, Spannable node) {
ConstructorElement target = constructor;
- DartType targetType;
+ ResolutionDartType targetType;
List<ConstructorElement> seen = new List<ConstructorElement>();
bool isMalformed = false;
// Follow the chain of redirections and check for cycles.
@@ -515,7 +518,8 @@
message: 'No ResolvedAst for $factory.'));
FunctionExpression functionNode = resolvedAst.node;
RedirectingFactoryBody redirectionNode = resolvedAst.body;
- DartType factoryType = resolvedAst.elements.getType(redirectionNode);
+ ResolutionDartType factoryType =
+ resolvedAst.elements.getType(redirectionNode);
if (!factoryType.isDynamic) {
targetType = targetType.substByContext(factoryType);
}
@@ -543,7 +547,7 @@
cls.supertype = cls.allSupertypes.head;
assert(invariant(from, cls.supertype != null,
message: 'Missing supertype on cyclic class $cls.'));
- cls.interfaces = const Link<DartType>();
+ cls.interfaces = const Link<ResolutionDartType>();
return;
}
cls.supertypeLoadState = STATE_STARTED;
@@ -1098,10 +1102,10 @@
annotation.constant = constant;
constantCompiler.evaluate(annotation.constant);
- // TODO(johnniwinther): Register the relation between the annotation
- // and the annotated element instead. This will allow the backend to
- // retrieve the backend constant and only register metadata on the
- // elements for which it is needed. (Issue 17732).
+ // TODO(johnniwinther): Register the relation between the
+ // annotation and the annotated element instead. This will allow
+ // the backend to retrieve the backend constant and only register
+ // metadata on the elements for which it is needed. (Issue 17732).
annotation.resolutionState = STATE_DONE;
}));
}
diff --git a/pkg/compiler/lib/src/resolution/resolution_result.dart b/pkg/compiler/lib/src/resolution/resolution_result.dart
index c3ba485..fd7576f 100644
--- a/pkg/compiler/lib/src/resolution/resolution_result.dart
+++ b/pkg/compiler/lib/src/resolution/resolution_result.dart
@@ -5,7 +5,7 @@
library dart2js.resolution.result;
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../tree/tree.dart';
import '../universe/call_structure.dart' show CallStructure;
@@ -32,7 +32,7 @@
ResultKind get kind;
Node get node => null;
Element get element => null;
- DartType get type => null;
+ ResolutionDartType get type => null;
ConstantExpression get constant => null;
bool get isConstant => false;
}
@@ -67,9 +67,10 @@
String toString() => 'ElementResult($element)';
}
-/// The result for the resolution of a node that points to an [DartType].
+/// The result for the resolution of a node that points to an
+/// [ResolutionDartType].
class TypeResult extends ResolutionResult {
- final DartType type;
+ final ResolutionDartType type;
TypeResult(this.type) {
assert(type != null);
diff --git a/pkg/compiler/lib/src/resolution/scope.dart b/pkg/compiler/lib/src/resolution/scope.dart
index e03304e..380b764 100644
--- a/pkg/compiler/lib/src/resolution/scope.dart
+++ b/pkg/compiler/lib/src/resolution/scope.dart
@@ -4,7 +4,7 @@
library dart2js.resolution.scope;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
abstract class Scope {
@@ -66,7 +66,7 @@
/// available, but where locally declared and inherited members are not
/// available.
abstract class TypeVariablesScope extends NestedScope {
- List<DartType> get typeVariables;
+ List<ResolutionDartType> get typeVariables;
TypeVariablesScope(Scope parent) : super(parent) {
assert(parent != null);
@@ -77,7 +77,7 @@
}
Element lookupTypeVariable(String name) {
- for (TypeVariableType type in typeVariables) {
+ for (ResolutionTypeVariableType type in typeVariables) {
if (type.name == name) {
return type.element;
}
@@ -99,7 +99,7 @@
final GenericElement element;
@override
- List<DartType> get typeVariables => element.typeVariables;
+ List<ResolutionDartType> get typeVariables => element.typeVariables;
TypeDeclarationScope(Scope parent, this.element) : super(parent);
diff --git a/pkg/compiler/lib/src/resolution/semantic_visitor.dart b/pkg/compiler/lib/src/resolution/semantic_visitor.dart
index c4fe79a..304b852 100644
--- a/pkg/compiler/lib/src/resolution/semantic_visitor.dart
+++ b/pkg/compiler/lib/src/resolution/semantic_visitor.dart
@@ -6,7 +6,7 @@
import '../common.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../tree/tree.dart';
import '../universe/call_structure.dart' show CallStructure;
@@ -1431,7 +1431,7 @@
/// class C {}
/// m() => expression is C;
///
- R visitIs(Send node, Node expression, DartType type, A arg);
+ R visitIs(Send node, Node expression, ResolutionDartType type, A arg);
/// Is not test of [expression] against [type].
///
@@ -1440,7 +1440,7 @@
/// class C {}
/// m() => expression is! C;
///
- R visitIsNot(Send node, Node expression, DartType type, A arg);
+ R visitIsNot(Send node, Node expression, ResolutionDartType type, A arg);
/// As cast of [expression] to [type].
///
@@ -1449,7 +1449,7 @@
/// class C {}
/// m() => expression as C;
///
- R visitAs(Send node, Node expression, DartType type, A arg);
+ R visitAs(Send node, Node expression, ResolutionDartType type, A arg);
/// Compound assignment expression of [rhs] with [operator] of the property on
/// [receiver] whose getter and setter are defined by [getterSelector] and
@@ -2228,8 +2228,8 @@
/// If-null assignment expression of [rhs] to the type literal for the type
/// variable [element]. That is, [rhs] is only evaluated and assigned, if
- /// the value is of the [element] is `null`. The behavior is thus equivalent to
- /// a type literal access.
+ /// the value is of the [element] is `null`. The behavior is thus equivalent
+ /// to a type literal access.
///
/// For instance:
///
@@ -3867,7 +3867,7 @@
R visitGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg);
@@ -3888,7 +3888,7 @@
R visitRedirectingGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg);
@@ -3908,7 +3908,7 @@
R visitFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg);
@@ -3932,9 +3932,9 @@
R visitRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
ConstructorElement effectiveTarget,
- InterfaceType effectiveTargetType,
+ ResolutionInterfaceType effectiveTargetType,
NodeList arguments,
CallStructure callStructure,
A arg);
@@ -3953,7 +3953,7 @@
// TODO(johnniwinther): Change [type] to [InterfaceType] when is it not
// `dynamic`.
R visitUnresolvedConstructorInvoke(NewExpression node, Element constructor,
- DartType type, NodeList arguments, Selector selector, A arg);
+ ResolutionDartType type, NodeList arguments, Selector selector, A arg);
/// Invocation of a constructor on an unresolved [type] with [arguments].
///
@@ -3966,7 +3966,7 @@
// TODO(johnniwinther): Change [type] to [MalformedType] when is it not
// `dynamic`.
R visitUnresolvedClassConstructorInvoke(NewExpression node, Element element,
- DartType type, NodeList arguments, Selector selector, A arg);
+ ResolutionDartType type, NodeList arguments, Selector selector, A arg);
/// Constant invocation of a non-constant constructor.
///
@@ -3977,8 +3977,13 @@
/// }
/// m() => const C(true, 42);
///
- R errorNonConstantConstructorInvoke(NewExpression node, Element element,
- DartType type, NodeList arguments, CallStructure callStructure, A arg);
+ R errorNonConstantConstructorInvoke(
+ NewExpression node,
+ Element element,
+ ResolutionDartType type,
+ NodeList arguments,
+ CallStructure callStructure,
+ A arg);
/// Invocation of a constructor on an abstract [type] with [arguments].
///
@@ -3991,7 +3996,7 @@
R visitAbstractClassConstructorInvoke(
NewExpression node,
ConstructorElement element,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg);
@@ -4012,7 +4017,7 @@
R visitUnresolvedRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg);
@@ -4029,7 +4034,7 @@
R visitConstructorIncompatibleInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg);
@@ -4609,7 +4614,7 @@
FunctionExpression node,
ConstructorElement constructor,
NodeList parameters,
- InterfaceType redirectionType,
+ ResolutionInterfaceType redirectionType,
ConstructorElement redirectionTarget,
A arg);
@@ -4653,7 +4658,7 @@
R visitSuperConstructorInvoke(
Send node,
ConstructorElement superConstructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg);
@@ -4671,7 +4676,7 @@
/// }
///
R visitImplicitSuperConstructorInvoke(FunctionExpression node,
- ConstructorElement superConstructor, InterfaceType type, A arg);
+ ConstructorElement superConstructor, ResolutionInterfaceType type, A arg);
/// An super constructor invocation of an unresolved with [arguments] as
/// found in generative constructor initializers.
diff --git a/pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart b/pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart
index b9ebd0b..d46a6ef 100644
--- a/pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart
+++ b/pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart
@@ -26,8 +26,13 @@
}
@override
- R errorNonConstantConstructorInvoke(NewExpression node, Element element,
- DartType type, NodeList arguments, CallStructure callStructure, A arg) {
+ R errorNonConstantConstructorInvoke(
+ NewExpression node,
+ Element element,
+ ResolutionDartType type,
+ NodeList arguments,
+ CallStructure callStructure,
+ A arg) {
return bulkHandleError(node, null, arg);
}
@@ -1913,17 +1918,17 @@
abstract class BaseBulkMixin<R, A>
implements SemanticSendVisitor<R, A>, BulkHandle<R, A> {
@override
- R visitAs(Send node, Node expression, DartType type, A arg) {
+ R visitAs(Send node, Node expression, ResolutionDartType type, A arg) {
return bulkHandleNode(node, 'As cast `#` unhandled.', arg);
}
@override
- R visitIs(Send node, Node expression, DartType type, A arg) {
+ R visitIs(Send node, Node expression, ResolutionDartType type, A arg) {
return bulkHandleNode(node, 'Is test `#` unhandled.', arg);
}
@override
- R visitIsNot(Send node, Node expression, DartType type, A arg) {
+ R visitIsNot(Send node, Node expression, ResolutionDartType type, A arg) {
return bulkHandleNode(node, 'Is not test `#` unhandled.', arg);
}
@@ -2196,7 +2201,7 @@
R visitAbstractClassConstructorInvoke(
NewExpression node,
ConstructorElement element,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -2231,7 +2236,7 @@
R visitConstructorIncompatibleInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -2242,7 +2247,7 @@
R visitGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -2253,7 +2258,7 @@
R visitRedirectingGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -2264,7 +2269,7 @@
R visitFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -2275,9 +2280,9 @@
R visitRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
ConstructorElement effectiveTarget,
- InterfaceType effectiveTargetType,
+ ResolutionInterfaceType effectiveTargetType,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -2286,13 +2291,13 @@
@override
R visitUnresolvedClassConstructorInvoke(NewExpression node, Element element,
- DartType type, NodeList arguments, Selector selector, A arg) {
+ ResolutionDartType type, NodeList arguments, Selector selector, A arg) {
return bulkHandleNew(node, arg);
}
@override
R visitUnresolvedConstructorInvoke(NewExpression node, Element constructor,
- DartType type, NodeList arguments, Selector selector, A arg) {
+ ResolutionDartType type, NodeList arguments, Selector selector, A arg) {
return bulkHandleNew(node, arg);
}
@@ -2300,7 +2305,7 @@
R visitUnresolvedRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -2434,7 +2439,7 @@
FunctionExpression node,
ConstructorElement constructor,
NodeList parameters,
- InterfaceType redirectionType,
+ ResolutionInterfaceType redirectionType,
ConstructorElement redirectionTarget,
A arg) {
return bulkHandleConstructorDeclaration(node, arg);
@@ -2489,7 +2494,7 @@
R visitSuperConstructorInvoke(
Send node,
ConstructorElement superConstructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -2497,8 +2502,11 @@
}
@override
- R visitImplicitSuperConstructorInvoke(FunctionExpression node,
- ConstructorElement superConstructor, InterfaceType type, A arg) {
+ R visitImplicitSuperConstructorInvoke(
+ FunctionExpression node,
+ ConstructorElement superConstructor,
+ ResolutionInterfaceType type,
+ A arg) {
return bulkHandleInitializer(node, arg);
}
@@ -3019,7 +3027,7 @@
}
@override
- R visitAs(Send node, Node expression, DartType type, A arg) {
+ R visitAs(Send node, Node expression, ResolutionDartType type, A arg) {
apply(expression, arg);
return null;
}
@@ -3235,13 +3243,13 @@
}
@override
- R visitIs(Send node, Node expression, DartType type, A arg) {
+ R visitIs(Send node, Node expression, ResolutionDartType type, A arg) {
apply(expression, arg);
return null;
}
@override
- R visitIsNot(Send node, Node expression, DartType type, A arg) {
+ R visitIsNot(Send node, Node expression, ResolutionDartType type, A arg) {
apply(expression, arg);
return null;
}
@@ -4427,7 +4435,7 @@
R visitConstructorIncompatibleInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -4439,7 +4447,7 @@
R visitUnresolvedClassConstructorInvoke(
NewExpression node,
Element constructor,
- DartType type,
+ ResolutionDartType type,
NodeList arguments,
Selector selector,
A arg) {
@@ -4449,7 +4457,7 @@
@override
R visitUnresolvedConstructorInvoke(NewExpression node, Element constructor,
- DartType type, NodeList arguments, Selector selector, A arg) {
+ ResolutionDartType type, NodeList arguments, Selector selector, A arg) {
apply(arguments, arg);
return null;
}
@@ -4458,7 +4466,7 @@
R visitFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -4470,7 +4478,7 @@
R visitGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -4482,9 +4490,9 @@
R visitRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
ConstructorElement effectiveTarget,
- InterfaceType effectiveTargetType,
+ ResolutionInterfaceType effectiveTargetType,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -4496,7 +4504,7 @@
R visitRedirectingGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -4508,7 +4516,7 @@
R visitAbstractClassConstructorInvoke(
NewExpression node,
ConstructorElement element,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -4520,7 +4528,7 @@
R visitUnresolvedRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -4529,8 +4537,13 @@
}
@override
- R errorNonConstantConstructorInvoke(NewExpression node, Element element,
- DartType type, NodeList arguments, CallStructure callStructure, A arg) {
+ R errorNonConstantConstructorInvoke(
+ NewExpression node,
+ Element element,
+ ResolutionDartType type,
+ NodeList arguments,
+ CallStructure callStructure,
+ A arg) {
apply(arguments, arg);
return null;
}
@@ -4934,7 +4947,7 @@
FunctionExpression node,
ConstructorElement constructor,
NodeList parameters,
- InterfaceType redirectionType,
+ ResolutionInterfaceType redirectionType,
ConstructorElement redirectionTarget,
A arg) {
applyParameters(parameters, arg);
@@ -4965,7 +4978,7 @@
R visitSuperConstructorInvoke(
Send node,
ConstructorElement superConstructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -4974,8 +4987,11 @@
}
@override
- R visitImplicitSuperConstructorInvoke(FunctionExpression node,
- ConstructorElement superConstructor, InterfaceType type, A arg) {
+ R visitImplicitSuperConstructorInvoke(
+ FunctionExpression node,
+ ConstructorElement superConstructor,
+ ResolutionInterfaceType type,
+ A arg) {
return null;
}
@@ -8217,13 +8233,18 @@
/// handled uniformly.
abstract class BaseImplementationOfNewMixin<R, A>
implements SemanticSendVisitor<R, A> {
- R handleConstructorInvoke(NewExpression node, ConstructorElement constructor,
- DartType type, NodeList arguments, CallStructure callStructure, A arg);
+ R handleConstructorInvoke(
+ NewExpression node,
+ ConstructorElement constructor,
+ ResolutionDartType type,
+ NodeList arguments,
+ CallStructure callStructure,
+ A arg);
R visitGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -8235,7 +8256,7 @@
R visitRedirectingGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -8247,7 +8268,7 @@
R visitFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -8259,9 +8280,9 @@
R visitRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
ConstructorElement effectiveTarget,
- InterfaceType effectiveTargetType,
+ ResolutionInterfaceType effectiveTargetType,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -8271,14 +8292,14 @@
@override
R visitUnresolvedConstructorInvoke(NewExpression node, Element constructor,
- DartType type, NodeList arguments, Selector selector, A arg) {
+ ResolutionDartType type, NodeList arguments, Selector selector, A arg) {
return handleConstructorInvoke(
node, constructor, type, arguments, selector.callStructure, arg);
}
@override
R visitUnresolvedClassConstructorInvoke(NewExpression node, Element element,
- DartType type, NodeList arguments, Selector selector, A arg) {
+ ResolutionDartType type, NodeList arguments, Selector selector, A arg) {
return handleConstructorInvoke(
node, element, type, arguments, selector.callStructure, arg);
}
@@ -8287,7 +8308,7 @@
R visitAbstractClassConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
@@ -8299,7 +8320,7 @@
R visitUnresolvedRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
A arg) {
diff --git a/pkg/compiler/lib/src/resolution/send_resolver.dart b/pkg/compiler/lib/src/resolution/send_resolver.dart
index d53d4ec..0d44a31 100644
--- a/pkg/compiler/lib/src/resolution/send_resolver.dart
+++ b/pkg/compiler/lib/src/resolution/send_resolver.dart
@@ -6,7 +6,7 @@
import '../common.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../tree/tree.dart';
import 'semantic_visitor.dart';
@@ -58,7 +58,7 @@
class RedirectingFactoryConstructorDeclStructure<R, A>
extends DeclStructure<R, A> {
- InterfaceType redirectionTargetType;
+ ResolutionInterfaceType redirectionTargetType;
ConstructorElement redirectionTarget;
RedirectingFactoryConstructorDeclStructure(ConstructorElement constructor,
@@ -234,7 +234,7 @@
if (!constructorInvocationSeen) {
ConstructorElement currentConstructor = elements[node];
ClassElement currentClass = currentConstructor.enclosingClass;
- InterfaceType supertype = currentClass.supertype;
+ ResolutionInterfaceType supertype = currentClass.supertype;
if (supertype != null) {
ClassElement superclass = supertype.element;
ConstructorElement superConstructor =
diff --git a/pkg/compiler/lib/src/resolution/send_structure.dart b/pkg/compiler/lib/src/resolution/send_structure.dart
index 0d0de9f..6f9d97f 100644
--- a/pkg/compiler/lib/src/resolution/send_structure.dart
+++ b/pkg/compiler/lib/src/resolution/send_structure.dart
@@ -6,7 +6,7 @@
import '../common.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../resolution/tree_elements.dart' show TreeElements;
import '../tree/tree.dart';
@@ -112,7 +112,7 @@
/// The structure for a [Send] of the form `a is T`.
class IsStructure<R, A> implements SendStructure<R, A> {
/// The type that the expression is tested against.
- final DartType type;
+ final ResolutionDartType type;
IsStructure(this.type);
@@ -129,7 +129,7 @@
/// The structure for a [Send] of the form `a is! T`.
class IsNotStructure<R, A> implements SendStructure<R, A> {
/// The type that the expression is tested against.
- final DartType type;
+ final ResolutionDartType type;
IsNotStructure(this.type);
@@ -146,7 +146,7 @@
/// The structure for a [Send] of the form `a as T`.
class AsStructure<R, A> implements SendStructure<R, A> {
/// The type that the expression is cast to.
- final DartType type;
+ final ResolutionDartType type;
AsStructure(this.type);
@@ -2114,7 +2114,7 @@
arg);
}
ConstructorElement effectiveTarget = constructor.effectiveTarget;
- InterfaceType effectiveTargetType =
+ ResolutionInterfaceType effectiveTargetType =
constructor.computeEffectiveTargetType(semantics.type);
if (callStructure
.signatureApplies(effectiveTarget.functionSignature)) {
@@ -2238,7 +2238,7 @@
NewStructure resolve(NewExpression node) {
Element element = elements[node.send];
Selector selector = elements.getSelector(node.send);
- DartType type = elements.getType(node);
+ ResolutionDartType type = elements.getType(node);
ConstantExpression constant = elements.getConstant(node);
if (element.isMalformed ||
constant == null ||
@@ -2275,7 +2275,7 @@
R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
Element element = elements[node.send];
Selector selector = elements.getSelector(node.send);
- DartType type = elements.getType(node);
+ ResolutionDartType type = elements.getType(node);
ConstantExpression constant = elements.getConstant(node);
if (element.isMalformed ||
constant == null ||
@@ -2474,7 +2474,7 @@
class SuperConstructorInvokeStructure<R, A> extends InitializerStructure<R, A> {
final Send node;
final ConstructorElement constructor;
- final InterfaceType type;
+ final ResolutionInterfaceType type;
final CallStructure callStructure;
SuperConstructorInvokeStructure(
@@ -2492,7 +2492,7 @@
extends InitializerStructure<R, A> {
final FunctionExpression node;
final ConstructorElement constructor;
- final InterfaceType type;
+ final ResolutionInterfaceType type;
ImplicitSuperConstructorInvokeStructure(
this.node, this.constructor, this.type);
diff --git a/pkg/compiler/lib/src/resolution/signatures.dart b/pkg/compiler/lib/src/resolution/signatures.dart
index 0dd1363..ae39454 100644
--- a/pkg/compiler/lib/src/resolution/signatures.dart
+++ b/pkg/compiler/lib/src/resolution/signatures.dart
@@ -6,7 +6,7 @@
import '../common.dart';
import '../common/resolution.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart'
show
@@ -148,7 +148,7 @@
if (fieldElement != null) {
element.typeCache = fieldElement.computeType(resolution);
} else {
- element.typeCache = const DynamicType();
+ element.typeCache = const ResolutionDynamicType();
}
}
}
@@ -306,17 +306,17 @@
bool isFunctionExpression: false}) {
DiagnosticReporter reporter = resolution.reporter;
- List<DartType> createTypeVariables(NodeList typeVariableNodes) {
+ List<ResolutionDartType> createTypeVariables(NodeList typeVariableNodes) {
if (element.isPatch) {
FunctionTypedElement origin = element.origin;
origin.computeType(resolution);
return origin.typeVariables;
}
- if (typeVariableNodes == null) return const <DartType>[];
+ if (typeVariableNodes == null) return const <ResolutionDartType>[];
// Create the types and elements corresponding to [typeVariableNodes].
Link<Node> nodes = typeVariableNodes.nodes;
- List<DartType> arguments =
+ List<ResolutionDartType> arguments =
new List.generate(nodes.slowLength(), (int index) {
TypeVariable node = nodes.head;
String variableName = node.name.source;
@@ -326,8 +326,8 @@
// GENERIC_METHODS: When method type variables are implemented fully we
// must resolve the actual bounds; currently we just claim that
// every method type variable has upper bound [dynamic].
- variableElement.boundCache = const DynamicType();
- TypeVariableType variableType =
+ variableElement.boundCache = const ResolutionDynamicType();
+ ResolutionTypeVariableType variableType =
new MethodTypeVariableType(variableElement);
variableElement.typeCache = variableType;
return variableType;
@@ -335,7 +335,8 @@
return arguments;
}
- List<DartType> typeVariableTypes = createTypeVariables(typeVariables);
+ List<ResolutionDartType> typeVariableTypes =
+ createTypeVariables(typeVariables);
scope = new FunctionSignatureBuildingScope(scope, typeVariableTypes);
SignatureResolver visitor = new SignatureResolver(
resolution, element, scope, registry,
@@ -370,7 +371,7 @@
requiredParameterCount = parametersBuilder.length;
parameters = parametersBuilder.toList();
}
- DartType returnType;
+ ResolutionDartType returnType;
if (element.isFactoryConstructor) {
returnType = element.enclosingClass.thisType;
// Because there is no type annotation for the return type of
@@ -408,13 +409,15 @@
formalParameters, MessageKind.ILLEGAL_SETTER_FORMALS);
}
}
- LinkBuilder<DartType> parameterTypes = new LinkBuilder<DartType>();
+ LinkBuilder<ResolutionDartType> parameterTypes =
+ new LinkBuilder<ResolutionDartType>();
for (FormalElement parameter in parameters) {
parameterTypes.addLast(parameter.type);
}
- List<DartType> optionalParameterTypes = const <DartType>[];
+ List<ResolutionDartType> optionalParameterTypes =
+ const <ResolutionDartType>[];
List<String> namedParameters = const <String>[];
- List<DartType> namedParameterTypes = const <DartType>[];
+ List<ResolutionDartType> namedParameterTypes = const <ResolutionDartType>[];
List<Element> orderedOptionalParameters =
visitor.optionalParameters.toList();
if (visitor.optionalParametersAreNamed) {
@@ -423,8 +426,8 @@
return a.name.compareTo(b.name);
});
LinkBuilder<String> namedParametersBuilder = new LinkBuilder<String>();
- LinkBuilder<DartType> namedParameterTypesBuilder =
- new LinkBuilder<DartType>();
+ LinkBuilder<ResolutionDartType> namedParameterTypesBuilder =
+ new LinkBuilder<ResolutionDartType>();
for (FormalElement parameter in orderedOptionalParameters) {
namedParametersBuilder.addLast(parameter.name);
namedParameterTypesBuilder.addLast(parameter.type);
@@ -434,15 +437,15 @@
namedParameterTypesBuilder.toLink().toList(growable: false);
} else {
// TODO(karlklose); replace when [visitor.optinalParameters] is a [List].
- LinkBuilder<DartType> optionalParameterTypesBuilder =
- new LinkBuilder<DartType>();
+ LinkBuilder<ResolutionDartType> optionalParameterTypesBuilder =
+ new LinkBuilder<ResolutionDartType>();
for (FormalElement parameter in visitor.optionalParameters) {
optionalParameterTypesBuilder.addLast(parameter.type);
}
optionalParameterTypes =
optionalParameterTypesBuilder.toLink().toList(growable: false);
}
- FunctionType type = new FunctionType(
+ ResolutionFunctionType type = new ResolutionFunctionType(
element.declaration,
returnType,
parameterTypes.toLink().toList(growable: false),
@@ -460,19 +463,19 @@
type: type);
}
- DartType resolveTypeAnnotation(TypeAnnotation annotation) {
- DartType type = resolveReturnType(annotation);
+ ResolutionDartType resolveTypeAnnotation(TypeAnnotation annotation) {
+ ResolutionDartType type = resolveReturnType(annotation);
if (type.isVoid) {
reporter.reportErrorMessage(annotation, MessageKind.VOID_NOT_ALLOWED);
}
return type;
}
- DartType resolveReturnType(TypeAnnotation annotation) {
- if (annotation == null) return const DynamicType();
- DartType result = resolver.resolveTypeAnnotation(annotation);
+ ResolutionDartType resolveReturnType(TypeAnnotation annotation) {
+ if (annotation == null) return const ResolutionDynamicType();
+ ResolutionDartType result = resolver.resolveTypeAnnotation(annotation);
if (result == null) {
- return const DynamicType();
+ return const ResolutionDynamicType();
}
return result;
}
@@ -482,7 +485,7 @@
/// variables of the function signature itself when its signature is analyzed.
class FunctionSignatureBuildingScope extends TypeVariablesScope {
@override
- final List<DartType> typeVariables;
+ final List<ResolutionDartType> typeVariables;
FunctionSignatureBuildingScope(Scope parent, this.typeVariables)
: super(parent);
diff --git a/pkg/compiler/lib/src/resolution/tree_elements.dart b/pkg/compiler/lib/src/resolution/tree_elements.dart
index f9c239c..df32daa 100644
--- a/pkg/compiler/lib/src/resolution/tree_elements.dart
+++ b/pkg/compiler/lib/src/resolution/tree_elements.dart
@@ -6,7 +6,7 @@
import '../common.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../diagnostics/source_span.dart';
import '../elements/elements.dart';
import '../tree/tree.dart';
@@ -22,7 +22,7 @@
void forEachConstantNode(f(Node n, ConstantExpression c));
Element operator [](Node node);
- Map<Node, DartType> get typesCache;
+ Map<Node, ResolutionDartType> get typesCache;
/// Returns the [SendStructure] that describes the semantics of [node].
SendStructure getSendStructure(Send node);
@@ -34,7 +34,7 @@
Selector getSelector(Node node);
Selector getGetterSelectorInComplexSendSet(SendSet node);
Selector getOperatorSelectorInComplexSendSet(SendSet node);
- DartType getType(Node node);
+ ResolutionDartType getType(Node node);
/// Returns the for-in loop variable for [node].
Element getForInVariable(ForIn node);
@@ -57,7 +57,7 @@
bool isTypeLiteral(Send node);
/// Returns the type that the type literal [node] refers to.
- DartType getTypeLiteralType(Send node);
+ ResolutionDartType getTypeLiteralType(Send node);
/// Returns a list of nodes that potentially mutate [element] anywhere in its
/// scope.
@@ -94,10 +94,11 @@
class TreeElementMapping extends TreeElements {
final AnalyzableElement analyzedElement;
Map<Spannable, Selector> _selectors;
- Map<Node, DartType> _types;
+ Map<Node, ResolutionDartType> _types;
- Map<Node, DartType> _typesCache;
- Map<Node, DartType> get typesCache => _typesCache ??= <Node, DartType>{};
+ Map<Node, ResolutionDartType> _typesCache;
+ Map<Node, ResolutionDartType> get typesCache =>
+ _typesCache ??= <Node, ResolutionDartType>{};
Setlet<SourceSpan> _superUses;
Map<Node, ConstantExpression> _constants;
@@ -176,15 +177,15 @@
_newStructureMap[node] = newStructure;
}
- void setType(Node node, DartType type) {
+ void setType(Node node, ResolutionDartType type) {
if (_types == null) {
- _types = new Maplet<Node, DartType>();
+ _types = new Maplet<Node, ResolutionDartType>();
}
_types[node] = type;
}
@override
- DartType getType(Node node) => _types != null ? _types[node] : null;
+ ResolutionDartType getType(Node node) => _types != null ? _types[node] : null;
@override
Iterable<SourceSpan> get superUses {
@@ -260,7 +261,7 @@
}
@override
- DartType getTypeLiteralType(Send node) {
+ ResolutionDartType getTypeLiteralType(Send node) {
return getType(node);
}
diff --git a/pkg/compiler/lib/src/resolution/type_resolver.dart b/pkg/compiler/lib/src/resolution/type_resolver.dart
index 3acc024..318e748 100644
--- a/pkg/compiler/lib/src/resolution/type_resolver.dart
+++ b/pkg/compiler/lib/src/resolution/type_resolver.dart
@@ -6,7 +6,7 @@
import '../common.dart';
import '../common/resolution.dart' show Resolution;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart'
show
AmbiguousElement,
@@ -63,17 +63,18 @@
return element;
}
- DartType resolveTypeAnnotation(MappingVisitor visitor, TypeAnnotation node,
+ ResolutionDartType resolveTypeAnnotation(
+ MappingVisitor visitor, TypeAnnotation node,
{bool malformedIsError: false, bool deferredIsMalformed: true}) {
ResolutionRegistry registry = visitor.registry;
Identifier typeName;
- DartType type;
+ ResolutionDartType type;
- DartType checkNoTypeArguments(DartType type) {
- List<DartType> arguments = new List<DartType>();
- bool hasTypeArgumentMismatch =
- resolveTypeArguments(visitor, node, const <DartType>[], arguments);
+ ResolutionDartType checkNoTypeArguments(ResolutionDartType type) {
+ List<ResolutionDartType> arguments = new List<ResolutionDartType>();
+ bool hasTypeArgumentMismatch = resolveTypeArguments(
+ visitor, node, const <ResolutionDartType>[], arguments);
if (hasTypeArgumentMismatch) {
return new MalformedType(
new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH,
@@ -93,12 +94,12 @@
} else {
typeName = node.typeName.asIdentifier();
if (identical(typeName.source, 'void')) {
- type = const VoidType();
+ type = const ResolutionVoidType();
checkNoTypeArguments(type);
registry.useType(node, type);
return type;
} else if (identical(typeName.source, 'dynamic')) {
- type = const DynamicType();
+ type = const ResolutionDynamicType();
checkNoTypeArguments(type);
registry.useType(node, type);
return type;
@@ -108,9 +109,9 @@
Element element = resolveTypeName(prefixName, typeName, visitor.scope,
deferredIsMalformed: deferredIsMalformed);
- DartType reportFailureAndCreateType(
+ ResolutionDartType reportFailureAndCreateType(
MessageKind messageKind, Map messageArguments,
- {DartType userProvidedBadType,
+ {ResolutionDartType userProvidedBadType,
Element erroneousElement,
List<DiagnosticMessage> infos: const <DiagnosticMessage>[]}) {
if (malformedIsError) {
@@ -126,8 +127,9 @@
erroneousElement = new ErroneousElementX(messageKind, messageArguments,
typeName.source, visitor.enclosingElement);
}
- List<DartType> arguments = <DartType>[];
- resolveTypeArguments(visitor, node, const <DartType>[], arguments);
+ List<ResolutionDartType> arguments = <ResolutionDartType>[];
+ resolveTypeArguments(
+ visitor, node, const <ResolutionDartType>[], arguments);
return new MalformedType(
erroneousElement, userProvidedBadType, arguments);
}
@@ -149,14 +151,14 @@
element.messageKind, element.messageArguments,
erroneousElement: element);
} else {
- type = const DynamicType();
+ type = const ResolutionDynamicType();
}
} else if (!element.impliesType) {
type = reportFailureAndCreateType(
MessageKind.NOT_A_TYPE, {'node': node.typeName});
} else if (element.library.isPlatformLibrary &&
element.name == 'FutureOr') {
- type = const DynamicType();
+ type = const ResolutionDynamicType();
registry.useType(node, type);
return type;
} else {
@@ -167,22 +169,22 @@
// [computeType].
resolver.ensureClassWillBeResolvedInternal(cls);
cls.computeType(resolution);
- List<DartType> arguments = <DartType>[];
+ List<ResolutionDartType> arguments = <ResolutionDartType>[];
bool hasTypeArgumentMismatch =
resolveTypeArguments(visitor, node, cls.typeVariables, arguments);
if (hasTypeArgumentMismatch) {
type = new BadInterfaceType(
cls.declaration,
- new InterfaceType.forUserProvidedBadType(
+ new ResolutionInterfaceType.forUserProvidedBadType(
cls.declaration, arguments));
} else {
if (arguments.isEmpty) {
type = cls.rawType;
} else {
- type = new InterfaceType(
+ type = new ResolutionInterfaceType(
cls.declaration, arguments.toList(growable: false));
addTypeVariableBoundsCheck =
- arguments.any((DartType type) => !type.isDynamic);
+ arguments.any((ResolutionDartType type) => !type.isDynamic);
}
}
} else if (element.isTypedef) {
@@ -190,19 +192,22 @@
// TODO(johnniwinther): [ensureResolved] should imply [computeType].
typdef.ensureResolved(resolution);
typdef.computeType(resolution);
- List<DartType> arguments = <DartType>[];
+ List<ResolutionDartType> arguments = <ResolutionDartType>[];
bool hasTypeArgumentMismatch = resolveTypeArguments(
visitor, node, typdef.typeVariables, arguments);
if (hasTypeArgumentMismatch) {
- type = new BadTypedefType(typdef,
- new TypedefType.forUserProvidedBadType(typdef, arguments));
+ type = new BadTypedefType(
+ typdef,
+ new ResolutionTypedefType.forUserProvidedBadType(
+ typdef, arguments));
} else {
if (arguments.isEmpty) {
type = typdef.rawType;
} else {
- type = new TypedefType(typdef, arguments.toList(growable: false));
+ type = new ResolutionTypedefType(
+ typdef, arguments.toList(growable: false));
addTypeVariableBoundsCheck =
- arguments.any((DartType type) => !type.isDynamic);
+ arguments.any((ResolutionDartType type) => !type.isDynamic);
}
}
} else if (element.isTypeVariable) {
@@ -237,8 +242,8 @@
/// Checks the type arguments of [type] against the type variable bounds.
void checkTypeVariableBounds(TypeAnnotation node, GenericType type) {
- void checkTypeVariableBound(_, DartType typeArgument,
- TypeVariableType typeVariable, DartType bound) {
+ void checkTypeVariableBound(_, ResolutionDartType typeArgument,
+ ResolutionTypeVariableType typeVariable, ResolutionDartType bound) {
if (!types.isSubtype(typeArgument, bound)) {
reporter.reportWarningMessage(
node, MessageKind.INVALID_TYPE_VARIABLE_BOUND, {
@@ -259,8 +264,11 @@
* Returns [: true :] if the number of type arguments did not match the
* number of type variables.
*/
- bool resolveTypeArguments(MappingVisitor visitor, TypeAnnotation node,
- List<DartType> typeVariables, List<DartType> arguments) {
+ bool resolveTypeArguments(
+ MappingVisitor visitor,
+ TypeAnnotation node,
+ List<ResolutionDartType> typeVariables,
+ List<ResolutionDartType> arguments) {
if (node.typeArguments == null) {
return false;
}
@@ -275,7 +283,8 @@
typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
typeArgumentCountMismatch = true;
}
- DartType argType = resolveTypeAnnotation(visitor, typeArguments.head);
+ ResolutionDartType argType =
+ resolveTypeAnnotation(visitor, typeArguments.head);
// TODO(karlklose): rewrite to not modify [arguments].
arguments.add(argType);
}
diff --git a/pkg/compiler/lib/src/resolution/typedefs.dart b/pkg/compiler/lib/src/resolution/typedefs.dart
index 1c52c93..90fc2c3 100644
--- a/pkg/compiler/lib/src/resolution/typedefs.dart
+++ b/pkg/compiler/lib/src/resolution/typedefs.dart
@@ -6,7 +6,7 @@
import '../common.dart';
import '../common/resolution.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart'
show FunctionSignature, TypedefElement, TypeVariableElement;
import '../elements/modelx.dart' show ErroneousElementX, TypedefElementX;
@@ -69,11 +69,11 @@
TypedefCyclicVisitor(this.reporter, this.element);
- visitType(DartType type, _) {
+ visitType(ResolutionDartType type, _) {
// Do nothing.
}
- visitTypedefType(TypedefType type, _) {
+ visitTypedefType(ResolutionTypedefType type, _) {
TypedefElementX typedefElement = type.element;
if (seenTypedefs.contains(typedefElement)) {
if (!hasCyclicReference && identical(element, typedefElement)) {
@@ -123,15 +123,15 @@
}
}
- visitFunctionType(FunctionType type, _) {
+ visitFunctionType(ResolutionFunctionType type, _) {
type.visitChildren(this, null);
}
- visitInterfaceType(InterfaceType type, _) {
+ visitInterfaceType(ResolutionInterfaceType type, _) {
type.visitChildren(this, null);
}
- visitTypeVariableType(TypeVariableType type, _) {
+ visitTypeVariableType(ResolutionTypeVariableType type, _) {
TypeVariableElement typeVariableElement = type.element;
if (seenTypeVariables.contains(typeVariableElement)) {
// Avoid running in cycles on cyclic type variable bounds.
diff --git a/pkg/compiler/lib/src/serialization/constant_serialization.dart b/pkg/compiler/lib/src/serialization/constant_serialization.dart
index fae3d2f..a3025c2 100644
--- a/pkg/compiler/lib/src/serialization/constant_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/constant_serialization.dart
@@ -6,7 +6,7 @@
import '../constants/constructors.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart' show FieldElement;
import '../resolution/operators.dart';
import '../universe/call_structure.dart' show CallStructure;
@@ -17,9 +17,9 @@
/// [ObjectEncoder].
///
/// This class is called from the [Serializer] when a [ConstantExpression] needs
-/// serialization. The [ObjectEncoder] ensures that any [Element], [DartType],
-/// and other [ConstantExpression] that the serialized [ConstantExpression]
-/// depends upon are also serialized.
+/// serialization. The [ObjectEncoder] ensures that any [Element],
+/// [ResolutionDartType], and other [ConstantExpression] that the serialized
+/// [ConstantExpression] depends upon are also serialized.
class ConstantSerializer
extends ConstantExpressionVisitor<dynamic, ObjectEncoder> {
const ConstantSerializer();
@@ -182,7 +182,7 @@
///
/// The class is called from the [Deserializer] when a [ConstantExpression]
/// needs deserialization. The [ObjectDecoder] ensures that any [Element],
- /// [DartType], and other [ConstantExpression] that the deserialized
+ /// [ResolutionDartType], and other [ConstantExpression] that the deserialized
/// [ConstantExpression] depends upon are available.
static ConstantExpression deserialize(ObjectDecoder decoder) {
ConstantExpressionKind kind =
@@ -281,8 +281,8 @@
///
/// This class is called from the [ConstructorSerializer] when the [Serializer]
/// is serializing constant constructor. The [ObjectEncoder] ensures that any
-/// [Element], [DartType], and [ConstantExpression] that the serialized
-/// [ConstantConstructor] depends upon are also serialized.
+/// [Element], [ResolutionDartType], and [ConstantExpression] that the
+/// serialized [ConstantConstructor] depends upon are also serialized.
class ConstantConstructorSerializer
extends ConstantConstructorVisitor<dynamic, ObjectEncoder> {
const ConstantConstructorSerializer();
@@ -341,13 +341,13 @@
///
/// The class is called from the [Deserializer] when a constant constructor
/// needs deserialization. The [ObjectDecoder] ensures that any [Element],
- /// [DartType], and [ConstantExpression] that the deserialized
+ /// [ResolutionDartType], and [ConstantExpression] that the deserialized
/// [ConstantConstructor] depends upon are available.
static ConstantConstructor deserialize(ObjectDecoder decoder) {
ConstantConstructorKind kind =
decoder.getEnum(Key.KIND, ConstantConstructorKind.values);
- DartType readType() {
+ ResolutionDartType readType() {
return decoder.getType(Key.TYPE);
}
diff --git a/pkg/compiler/lib/src/serialization/element_serialization.dart b/pkg/compiler/lib/src/serialization/element_serialization.dart
index 64a7782..743952e 100644
--- a/pkg/compiler/lib/src/serialization/element_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/element_serialization.dart
@@ -7,7 +7,7 @@
import '../common.dart';
import '../constants/constructors.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../diagnostics/messages.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart'
@@ -71,9 +71,9 @@
/// encoding into them into [ObjectEncoder]s.
///
/// This class is called from the [Serializer] when an [Element] needs
-/// serialization. The [ObjectEncoder] ensures that any [Element], [DartType],
-/// and [ConstantExpression] that the serialized [Element] depends upon are also
-/// serialized.
+/// serialization. The [ObjectEncoder] ensures that any [Element],
+/// [ResolutionDartType], and [ConstantExpression] that the serialized [Element]
+/// depends upon are also serialized.
const List<ElementSerializer> ELEMENT_SERIALIZERS = const [
const ErrorSerializer(),
const LibrarySerializer(),
@@ -179,7 +179,7 @@
/// Serialize the parameters of [element] into [encoder].
static void serializeParameters(
FunctionElement element, ObjectEncoder encoder) {
- FunctionType type = element.type;
+ ResolutionFunctionType type = element.type;
encoder.setType(Key.RETURN_TYPE, type.returnType);
encoder.setElements(Key.PARAMETERS, element.parameters);
}
@@ -420,7 +420,7 @@
}
if (element.isObject) return;
- List<InterfaceType> mixins = <InterfaceType>[];
+ List<ResolutionInterfaceType> mixins = <ResolutionInterfaceType>[];
ClassElement superclass = element.superclass;
while (superclass.isUnnamedMixinApplication) {
MixinApplicationElement mixinElement = superclass;
@@ -428,12 +428,13 @@
superclass = mixinElement.superclass;
}
mixins = mixins.reversed.toList();
- InterfaceType supertype = element.thisType.asInstanceOf(superclass);
+ ResolutionInterfaceType supertype =
+ element.thisType.asInstanceOf(superclass);
encoder.setType(Key.SUPERTYPE, supertype);
encoder.setTypes(Key.MIXINS, mixins);
encoder.setTypes(Key.INTERFACES, element.interfaces.toList());
- FunctionType callType = element.declaration.callType;
+ ResolutionFunctionType callType = element.declaration.callType;
if (callType != null) {
encoder.setType(Key.CALL_TYPE, element.callType);
}
@@ -848,8 +849,8 @@
///
/// The class is called from the [Deserializer] when an [Element]
/// needs deserialization. The [ObjectDecoder] ensures that any [Element],
- /// [DartType], and [ConstantExpression] that the deserialized [Element]
- /// depends upon are available.
+ /// [ResolutionDartType], and [ConstantExpression] that the deserialized
+ /// [Element] depends upon are available.
static Element deserialize(
ObjectDecoder decoder, SerializedElementKind elementKind) {
switch (elementKind) {
diff --git a/pkg/compiler/lib/src/serialization/equivalence.dart b/pkg/compiler/lib/src/serialization/equivalence.dart
index 81aefc9..907c8d4 100644
--- a/pkg/compiler/lib/src/serialization/equivalence.dart
+++ b/pkg/compiler/lib/src/serialization/equivalence.dart
@@ -10,7 +10,7 @@
import '../common/resolution.dart';
import '../constants/expressions.dart';
import '../constants/values.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/visitor.dart';
import '../js_backend/backend_serialization.dart'
@@ -97,7 +97,7 @@
}
/// Returns `true` if types [a] and [b] are equivalent.
-bool areTypesEquivalent(DartType a, DartType b) {
+bool areTypesEquivalent(ResolutionDartType a, ResolutionDartType b) {
if (identical(a, b)) return true;
if (a == null || b == null) return false;
return const TypeEquivalence().visit(a, b);
@@ -123,7 +123,8 @@
}
/// Returns `true` if the lists of types, [a] and [b], are equivalent.
-bool areTypeListsEquivalent(List<DartType> a, List<DartType> b) {
+bool areTypeListsEquivalent(
+ List<ResolutionDartType> a, List<ResolutionDartType> b) {
return areListsEquivalent(a, b, areTypesEquivalent);
}
@@ -359,7 +360,7 @@
}
bool testTypes(Object object1, Object object2, String property,
- DartType type1, DartType type2) {
+ ResolutionDartType type1, ResolutionDartType type2) {
return areTypesEquivalent(type1, type2);
}
@@ -374,7 +375,7 @@
}
bool testTypeLists(Object object1, Object object2, String property,
- List<DartType> list1, List<DartType> list2) {
+ List<ResolutionDartType> list1, List<ResolutionDartType> list2) {
return areTypeListsEquivalent(list1, list2);
}
@@ -592,22 +593,25 @@
}
}
-/// Visitor that checks for equivalence of [DartType]s.
-class TypeEquivalence implements DartTypeVisitor<bool, DartType> {
+/// Visitor that checks for equivalence of [ResolutionDartType]s.
+class TypeEquivalence implements DartTypeVisitor<bool, ResolutionDartType> {
final TestStrategy strategy;
const TypeEquivalence([this.strategy = const TestStrategy()]);
- bool visit(DartType type1, DartType type2) {
+ bool visit(ResolutionDartType type1, ResolutionDartType type2) {
return strategy.test(type1, type2, 'kind', type1.kind, type2.kind) &&
type1.accept(this, type2);
}
@override
- bool visitDynamicType(DynamicType type, DynamicType other) => true;
+ bool visitDynamicType(
+ ResolutionDynamicType type, ResolutionDynamicType other) =>
+ true;
@override
- bool visitFunctionType(FunctionType type, FunctionType other) {
+ bool visitFunctionType(
+ ResolutionFunctionType type, ResolutionFunctionType other) {
return strategy.testTypeLists(type, other, 'parameterTypes',
type.parameterTypes, other.parameterTypes) &&
strategy.testTypeLists(type, other, 'optionalParameterTypes',
@@ -629,7 +633,8 @@
bool visitMalformedType(MalformedType type, MalformedType other) => true;
@override
- bool visitTypeVariableType(TypeVariableType type, TypeVariableType other) {
+ bool visitTypeVariableType(
+ ResolutionTypeVariableType type, ResolutionTypeVariableType other) {
return strategy.testElements(
type, other, 'element', type.element, other.element) &&
strategy.test(type, other, 'is MethodTypeVariableType',
@@ -637,15 +642,18 @@
}
@override
- bool visitVoidType(VoidType type, VoidType argument) => true;
+ bool visitVoidType(ResolutionVoidType type, ResolutionVoidType argument) =>
+ true;
@override
- bool visitInterfaceType(InterfaceType type, InterfaceType other) {
+ bool visitInterfaceType(
+ ResolutionInterfaceType type, ResolutionInterfaceType other) {
return visitGenericType(type, other);
}
@override
- bool visitTypedefType(TypedefType type, TypedefType other) {
+ bool visitTypedefType(
+ ResolutionTypedefType type, ResolutionTypedefType other) {
return visitGenericType(type, other);
}
}
@@ -874,8 +882,9 @@
@override
bool visitFunction(
FunctionConstantValue value1, FunctionConstantValue value2) {
- return strategy.testElements(
- value1, value2, 'element', value1.element, value2.element);
+ MethodElement method1 = value1.element;
+ MethodElement method2 = value2.element;
+ return strategy.testElements(value1, value2, 'element', method1, method2);
}
@override
diff --git a/pkg/compiler/lib/src/serialization/impact_serialization.dart b/pkg/compiler/lib/src/serialization/impact_serialization.dart
index 90c1570..3b8e4b1 100644
--- a/pkg/compiler/lib/src/serialization/impact_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/impact_serialization.dart
@@ -6,7 +6,7 @@
import '../common/resolution.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../universe/selector.dart';
import '../universe/feature.dart';
@@ -137,7 +137,7 @@
StaticUseKind kind = object.getEnum(Key.KIND, StaticUseKind.values);
Element usedElement =
deserializeElementReference(element, Key.ELEMENT, Key.NAME, object);
- DartType type = object.getType(Key.TYPE, isOptional: true);
+ ResolutionDartType type = object.getType(Key.TYPE, isOptional: true);
staticUses.add(new StaticUse.internal(usedElement, kind, type));
}
@@ -154,7 +154,7 @@
for (int index = 0; index < typeUseDecoder.length; index++) {
ObjectDecoder object = typeUseDecoder.getObject(index);
TypeUseKind kind = object.getEnum(Key.KIND, TypeUseKind.values);
- DartType type = object.getType(Key.TYPE);
+ ResolutionDartType type = object.getType(Key.TYPE);
typeUses.add(new TypeUse.internal(type, kind));
}
@@ -174,7 +174,7 @@
listLiterals = <ListLiteralUse>[];
for (int i = 0; i < listLiteralDecoder.length; i++) {
ObjectDecoder useDecoder = listLiteralDecoder.getObject(i);
- DartType type = useDecoder.getType(Key.TYPE);
+ ResolutionDartType type = useDecoder.getType(Key.TYPE);
bool isConstant = useDecoder.getBool(Key.IS_CONST);
bool isEmpty = useDecoder.getBool(Key.IS_EMPTY);
listLiterals.add(
@@ -189,7 +189,7 @@
mapLiterals = <MapLiteralUse>[];
for (int i = 0; i < mapLiteralDecoder.length; i++) {
ObjectDecoder useDecoder = mapLiteralDecoder.getObject(i);
- DartType type = useDecoder.getType(Key.TYPE);
+ ResolutionDartType type = useDecoder.getType(Key.TYPE);
bool isConstant = useDecoder.getBool(Key.IS_CONST);
bool isEmpty = useDecoder.getBool(Key.IS_EMPTY);
mapLiterals.add(
diff --git a/pkg/compiler/lib/src/serialization/modelz.dart b/pkg/compiler/lib/src/serialization/modelz.dart
index a628cbf..e1fb5d0 100644
--- a/pkg/compiler/lib/src/serialization/modelz.dart
+++ b/pkg/compiler/lib/src/serialization/modelz.dart
@@ -13,7 +13,7 @@
import '../common/resolution.dart' show Resolution;
import '../constants/constructors.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/common.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart' show FunctionSignatureX;
@@ -762,10 +762,10 @@
}
abstract class TypedElementMixin implements DeserializedElementZ, TypedElement {
- DartType _type;
+ ResolutionDartType _type;
@override
- DartType get type {
+ ResolutionDartType get type {
if (_type == null) {
_type = _decoder.getType(Key.TYPE);
}
@@ -773,7 +773,7 @@
}
@override
- DartType computeType(Resolution resolution) => type;
+ ResolutionDartType computeType(Resolution resolution) => type;
}
abstract class ParametersMixin
@@ -792,8 +792,8 @@
int requiredParameterCount = 0;
int optionalParameterCount = 0;
bool optionalParametersAreNamed = false;
- List<DartType> parameterTypes = <DartType>[];
- List<DartType> optionalParameterTypes = <DartType>[];
+ List<ResolutionDartType> parameterTypes = <ResolutionDartType>[];
+ List<ResolutionDartType> optionalParameterTypes = <ResolutionDartType>[];
for (ParameterElement parameter in parameters) {
if (parameter.isOptional) {
optionalParameterCount++;
@@ -811,10 +811,11 @@
}
}
List<String> namedParameters = const <String>[];
- List<DartType> namedParameterTypes = const <DartType>[];
+ List<ResolutionDartType> namedParameterTypes =
+ const <ResolutionDartType>[];
if (optionalParametersAreNamed) {
namedParameters = <String>[];
- namedParameterTypes = <DartType>[];
+ namedParameterTypes = <ResolutionDartType>[];
orderedOptionalParameters.sort((Element a, Element b) {
return a.name.compareTo(b.name);
});
@@ -823,10 +824,10 @@
namedParameterTypes.add(parameter.type);
}
}
- List<DartType> typeVariables =
+ List<ResolutionDartType> typeVariables =
_decoder.getTypes(Key.TYPE_VARIABLES, isOptional: true);
- FunctionType type = new FunctionType(
+ ResolutionFunctionType type = new ResolutionFunctionType(
this,
_decoder.getType(Key.RETURN_TYPE),
parameterTypes,
@@ -866,15 +867,15 @@
}
@override
- List<DartType> get typeVariables => functionSignature.typeVariables;
+ List<ResolutionDartType> get typeVariables => functionSignature.typeVariables;
}
abstract class ClassElementMixin
implements ElementZ, ClassElement, class_members.ClassMemberMixin {
bool _isResolved = false;
- InterfaceType _createType(List<DartType> typeArguments) {
- return new InterfaceType(this, typeArguments);
+ ResolutionInterfaceType _createType(List<ResolutionDartType> typeArguments) {
+ return new ResolutionInterfaceType(this, typeArguments);
}
@override
@@ -926,37 +927,37 @@
class_members.ClassMemberMixin,
ContainerMixin,
LibraryMemberMixin,
- TypeDeclarationMixin<InterfaceType>,
+ TypeDeclarationMixin<ResolutionInterfaceType>,
ClassElementMixin
implements ClassElement {
bool _isObject;
- DartType _supertype;
+ ResolutionDartType _supertype;
OrderedTypeSet _allSupertypesAndSelf;
- Link<DartType> _interfaces;
- FunctionType _callType;
+ Link<ResolutionDartType> _interfaces;
+ ResolutionFunctionType _callType;
ClassElementZ(ObjectDecoder decoder) : super(decoder);
@override
- List<DartType> _getTypeVariables() {
+ List<ResolutionDartType> _getTypeVariables() {
return _decoder.getTypes(Key.TYPE_VARIABLES, isOptional: true);
}
void _ensureSuperHierarchy() {
if (_interfaces == null) {
- InterfaceType supertype =
+ ResolutionInterfaceType supertype =
_decoder.getType(Key.SUPERTYPE, isOptional: true);
if (supertype == null) {
_isObject = true;
_allSupertypesAndSelf = new OrderedTypeSet.singleton(thisType);
- _interfaces = const Link<DartType>();
+ _interfaces = const Link<ResolutionDartType>();
} else {
_isObject = false;
_interfaces =
toLink(_decoder.getTypes(Key.INTERFACES, isOptional: true));
- List<InterfaceType> mixins =
+ List<ResolutionInterfaceType> mixins =
_decoder.getTypes(Key.MIXINS, isOptional: true);
- for (InterfaceType mixin in mixins) {
+ for (ResolutionInterfaceType mixin in mixins) {
MixinApplicationElement mixinElement =
new UnnamedMixinApplicationElementZ(this, supertype, mixin);
supertype = mixinElement.thisType
@@ -976,7 +977,7 @@
}
@override
- DartType get supertype {
+ ResolutionDartType get supertype {
_ensureSuperHierarchy();
return _supertype;
}
@@ -997,7 +998,7 @@
}
@override
- Link<DartType> get interfaces {
+ Link<ResolutionDartType> get interfaces {
_ensureSuperHierarchy();
return _interfaces;
}
@@ -1012,7 +1013,7 @@
bool get isUnnamedMixinApplication => false;
@override
- FunctionType get callType {
+ ResolutionFunctionType get callType {
_ensureSuperHierarchy();
// TODO(johnniwinther): Why can't this always be computed in ensureResolved?
return _callType;
@@ -1031,12 +1032,13 @@
class NamedMixinApplicationElementZ extends ClassElementZ
with MixinApplicationElementMixin {
Link<Element> _constructors;
- InterfaceType _mixinType;
+ ResolutionInterfaceType _mixinType;
NamedMixinApplicationElementZ(ObjectDecoder decoder) : super(decoder);
@override
- InterfaceType get mixinType => _mixinType ??= _decoder.getType(Key.MIXIN);
+ ResolutionInterfaceType get mixinType =>
+ _mixinType ??= _decoder.getType(Key.MIXIN);
@override
ClassElement get subclass => null;
@@ -1047,22 +1049,22 @@
ClassElementCommon,
ClassElementMixin,
class_members.ClassMemberMixin,
- TypeDeclarationMixin<InterfaceType>,
+ TypeDeclarationMixin<ResolutionInterfaceType>,
AnalyzableElementMixin,
AstElementMixinZ,
MixinApplicationElementCommon,
MixinApplicationElementMixin {
final String name;
final ClassElement subclass;
- final InterfaceType _supertypeBase;
- final InterfaceType _mixinBase;
- InterfaceType _supertype;
- Link<DartType> _interfaces;
+ final ResolutionInterfaceType _supertypeBase;
+ final ResolutionInterfaceType _mixinBase;
+ ResolutionInterfaceType _supertype;
+ Link<ResolutionDartType> _interfaces;
OrderedTypeSet _allSupertypesAndSelf;
Link<ConstructorElement> _constructors;
- UnnamedMixinApplicationElementZ(
- this.subclass, InterfaceType supertype, InterfaceType mixin)
+ UnnamedMixinApplicationElementZ(this.subclass,
+ ResolutionInterfaceType supertype, ResolutionInterfaceType mixin)
: this._supertypeBase = supertype,
this._mixinBase = mixin,
this.name = "${supertype.name}+${mixin.name}";
@@ -1099,20 +1101,22 @@
}
@override
- List<DartType> _getTypeVariables() {
+ List<ResolutionDartType> _getTypeVariables() {
// Create synthetic type variables for the mixin application.
- List<DartType> typeVariables = <DartType>[];
+ List<ResolutionDartType> typeVariables = <ResolutionDartType>[];
int index = 0;
- for (TypeVariableType type in subclass.typeVariables) {
+ for (ResolutionTypeVariableType type in subclass.typeVariables) {
SyntheticTypeVariableElementZ typeVariableElement =
new SyntheticTypeVariableElementZ(this, index, type.name);
- TypeVariableType typeVariable = new TypeVariableType(typeVariableElement);
+ ResolutionTypeVariableType typeVariable =
+ new ResolutionTypeVariableType(typeVariableElement);
typeVariables.add(typeVariable);
index++;
}
// Setup bounds on the synthetic type variables.
- for (TypeVariableType type in subclass.typeVariables) {
- TypeVariableType typeVariable = typeVariables[type.element.index];
+ for (ResolutionTypeVariableType type in subclass.typeVariables) {
+ ResolutionTypeVariableType typeVariable =
+ typeVariables[type.element.index];
SyntheticTypeVariableElementZ typeVariableElement = typeVariable.element;
typeVariableElement._type = typeVariable;
typeVariableElement._bound =
@@ -1122,7 +1126,7 @@
}
@override
- InterfaceType get supertype {
+ ResolutionInterfaceType get supertype {
if (_supertype == null) {
// Substitute the type variables in [_supertypeBase] provided by
// [_subclass] with the type variables in this unnamed mixin application.
@@ -1141,7 +1145,7 @@
}
@override
- Link<DartType> get interfaces {
+ Link<ResolutionDartType> get interfaces {
if (_interfaces == null) {
// Substitute the type variables in [_mixinBase] provided by
// [_subclass] with the type variables in this unnamed mixin application.
@@ -1154,7 +1158,7 @@
// abstract class S+M<S+M.T> extends S<S+M.T> implements M<S+M.T> {}
// but the mixin is provided as M<C.T> and we need to substitute S+M.T
// for C.T.
- _interfaces = const Link<DartType>()
+ _interfaces = const Link<ResolutionDartType>()
.prepend(_mixinBase.subst(typeVariables, subclass.typeVariables));
}
return _interfaces;
@@ -1187,7 +1191,7 @@
LibraryElement get library => enclosingElement.library;
@override
- InterfaceType get mixinType => interfaces.head;
+ ResolutionInterfaceType get mixinType => interfaces.head;
@override
int get sourceOffset => subclass.sourceOffset;
@@ -1300,7 +1304,9 @@
PrefixElement get redirectionDeferredPrefix => null;
@override
- InterfaceType computeEffectiveTargetType(InterfaceType newType) => newType;
+ ResolutionInterfaceType computeEffectiveTargetType(
+ ResolutionInterfaceType newType) =>
+ newType;
}
class GenerativeConstructorElementZ extends ConstructorElementZ {
@@ -1339,7 +1345,7 @@
}
class RedirectingFactoryConstructorElementZ extends ConstructorElementZ {
- DartType _effectiveTargetType;
+ ResolutionDartType _effectiveTargetType;
ConstructorElement _immediateRedirectionTarget;
PrefixElement _redirectionDeferredPrefix;
bool _effectiveTargetIsMalformed;
@@ -1380,7 +1386,8 @@
}
@override
- DartType computeEffectiveTargetType(InterfaceType newType) {
+ ResolutionDartType computeEffectiveTargetType(
+ ResolutionInterfaceType newType) {
_ensureEffectiveTarget();
return _effectiveTargetType.substByContext(newType);
}
@@ -1432,12 +1439,13 @@
AsyncMarker get asyncMarker => AsyncMarker.SYNC;
@override
- InterfaceType computeEffectiveTargetType(InterfaceType newType) {
+ ResolutionInterfaceType computeEffectiveTargetType(
+ ResolutionInterfaceType newType) {
return enclosingClass.thisType.substByContext(newType);
}
@override
- DartType computeType(Resolution resolution) => type;
+ ResolutionDartType computeType(Resolution resolution) => type;
@override
bool get isConst => false;
@@ -1541,14 +1549,14 @@
SourceSpan get sourcePosition => enclosingClass.sourcePosition;
@override
- FunctionType get type {
+ ResolutionFunctionType get type {
// TODO(johnniwinther): Ensure that the function type substitutes type
// variables correctly.
return definingConstructor.type;
}
@override
- List<DartType> get typeVariables => _unsupported("typeVariables");
+ List<ResolutionDartType> get typeVariables => _unsupported("typeVariables");
}
abstract class MemberElementMixin
@@ -1839,7 +1847,7 @@
abstract class TypeDeclarationMixin<T extends GenericType>
implements ElementZ, TypeDeclarationElement {
- List<DartType> _typeVariables;
+ List<ResolutionDartType> _typeVariables;
T _rawType;
T _thisType;
Name _memberName;
@@ -1851,21 +1859,21 @@
return _memberName;
}
- List<DartType> _getTypeVariables();
+ List<ResolutionDartType> _getTypeVariables();
void _ensureTypes() {
if (_typeVariables == null) {
_typeVariables = _getTypeVariables();
- _rawType = _createType(new List<DartType>.filled(
- _typeVariables.length, const DynamicType()));
+ _rawType = _createType(new List<ResolutionDartType>.filled(
+ _typeVariables.length, const ResolutionDynamicType()));
_thisType = _createType(_typeVariables);
}
}
- T _createType(List<DartType> typeArguments);
+ T _createType(List<ResolutionDartType> typeArguments);
@override
- List<DartType> get typeVariables {
+ List<ResolutionDartType> get typeVariables {
_ensureTypes();
return _typeVariables;
}
@@ -1895,18 +1903,18 @@
AstElementMixinZ,
LibraryMemberMixin,
ParametersMixin,
- TypeDeclarationMixin<TypedefType>
+ TypeDeclarationMixin<ResolutionTypedefType>
implements TypedefElement {
- DartType _alias;
+ ResolutionDartType _alias;
TypedefElementZ(ObjectDecoder decoder) : super(decoder);
- TypedefType _createType(List<DartType> typeArguments) {
- return new TypedefType(this, typeArguments);
+ ResolutionTypedefType _createType(List<ResolutionDartType> typeArguments) {
+ return new ResolutionTypedefType(this, typeArguments);
}
@override
- List<DartType> _getTypeVariables() {
+ List<ResolutionDartType> _getTypeVariables() {
return _decoder.getTypes(Key.TYPE_VARIABLES, isOptional: true);
}
@@ -1919,7 +1927,7 @@
}
@override
- DartType get alias {
+ ResolutionDartType get alias {
if (_alias == null) {
_alias = _decoder.getType(Key.ALIAS);
}
@@ -1937,8 +1945,8 @@
with AnalyzableElementMixin, AstElementMixinZ, TypedElementMixin
implements TypeVariableElement {
GenericElement _typeDeclaration;
- TypeVariableType _type;
- DartType _bound;
+ ResolutionTypeVariableType _type;
+ ResolutionDartType _bound;
Name _memberName;
TypeVariableElementZ(ObjectDecoder decoder) : super(decoder);
@@ -1980,7 +1988,7 @@
return _typeDeclaration;
}
- DartType get bound {
+ ResolutionDartType get bound {
if (_bound == null) {
_bound = _decoder.getType(Key.BOUND);
}
@@ -1997,8 +2005,8 @@
final TypeDeclarationElement typeDeclaration;
final int index;
final String name;
- TypeVariableType _type;
- DartType _bound;
+ ResolutionTypeVariableType _type;
+ ResolutionDartType _bound;
Name _memberName;
SyntheticTypeVariableElementZ(this.typeDeclaration, this.index, this.name);
@@ -2024,14 +2032,14 @@
}
@override
- TypeVariableType get type {
+ ResolutionTypeVariableType get type {
assert(invariant(this, _type != null,
message: "Type variable type has not been set on $this."));
return _type;
}
@override
- TypeVariableType computeType(Resolution resolution) => type;
+ ResolutionTypeVariableType computeType(Resolution resolution) => type;
@override
Element get enclosingElement => typeDeclaration;
@@ -2039,7 +2047,7 @@
@override
Element get enclosingClass => typeDeclaration;
- DartType get bound {
+ ResolutionDartType get bound {
assert(invariant(this, _bound != null,
message: "Type variable bound has not been set on $this."));
return _bound;
@@ -2060,7 +2068,7 @@
implements ParameterElement {
FunctionElement _functionDeclaration;
ConstantExpression _constant;
- DartType _type;
+ ResolutionDartType _type;
ParameterElementZ(ObjectDecoder decoder) : super(decoder);
@@ -2127,7 +2135,7 @@
MemberElement get memberContext => executableContext.memberContext;
@override
- List<DartType> get typeVariables => functionSignature.typeVariables;
+ List<ResolutionDartType> get typeVariables => functionSignature.typeVariables;
}
class LocalParameterElementZ extends ParameterElementZ
diff --git a/pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart b/pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart
index 3f58490..85044fb 100644
--- a/pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart
@@ -7,7 +7,7 @@
import '../common.dart';
import '../common/resolution.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../diagnostics/diagnostic_listener.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart';
@@ -237,7 +237,7 @@
serializeElementReference(element, Key.ELEMENT, Key.NAME,
getNodeDataEncoder(node), nodeElement);
}
- DartType type = elements.getType(node);
+ ResolutionDartType type = elements.getType(node);
if (type != null) {
getNodeDataEncoder(node).setType(Key.TYPE, type);
}
@@ -250,7 +250,7 @@
if (constant != null) {
getNodeDataEncoder(node).setConstant(Key.CONSTANT, constant);
}
- DartType cachedType = elements.typesCache[node];
+ ResolutionDartType cachedType = elements.typesCache[node];
if (cachedType != null) {
getNodeDataEncoder(node).setType(Key.CACHED_TYPE, cachedType);
}
@@ -606,7 +606,8 @@
if (nodeElement != null) {
elements[node] = nodeElement;
}
- DartType type = objectDecoder.getType(Key.TYPE, isOptional: true);
+ ResolutionDartType type =
+ objectDecoder.getType(Key.TYPE, isOptional: true);
if (type != null) {
elements.setType(node, type);
}
@@ -620,7 +621,7 @@
if (constant != null) {
elements.setConstant(node, constant);
}
- DartType cachedType =
+ ResolutionDartType cachedType =
objectDecoder.getType(Key.CACHED_TYPE, isOptional: true);
if (cachedType != null) {
elements.typesCache[node] = cachedType;
diff --git a/pkg/compiler/lib/src/serialization/serialization.dart b/pkg/compiler/lib/src/serialization/serialization.dart
index 27baa60..ff18e36 100644
--- a/pkg/compiler/lib/src/serialization/serialization.dart
+++ b/pkg/compiler/lib/src/serialization/serialization.dart
@@ -7,7 +7,7 @@
import '../common.dart';
import '../common/resolution.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../library_loader.dart' show LibraryProvider;
import '../util/enumset.dart';
@@ -23,8 +23,8 @@
/// An object that supports the encoding an [ObjectValue] for serialization.
///
/// The [ObjectEncoder] ensures that nominality and circularities of
-/// non-primitive values like [Element], [DartType] and [ConstantExpression] are
-/// handled.
+/// non-primitive values like [Element], [ResolutionDartType] and
+/// [ConstantExpression] are handled.
class ObjectEncoder extends AbstractEncoder<Key> {
/// Creates an [ObjectEncoder] in the scope of [serializer] that uses [map]
/// as its internal storage.
@@ -37,8 +37,8 @@
/// An object that supports the encoding a [MapValue] for serialization.
///
/// The [MapEncoder] ensures that nominality and circularities of
-/// non-primitive values like [Element], [DartType] and [ConstantExpression] are
-/// handled.
+/// non-primitive values like [Element], [ResolutionDartType] and
+/// [ConstantExpression] are handled.
class MapEncoder extends AbstractEncoder<String> {
/// Creates an [MapEncoder] in the scope of [serializer] that uses [map]
/// as its internal storage.
@@ -52,8 +52,8 @@
/// or [MapValue]s.
///
/// The [ListEncoder] ensures that nominality and circularities of
-/// non-primitive values like [Element], [DartType] and [ConstantExpression] are
-/// handled.
+/// non-primitive values like [Element], [ResolutionDartType] and
+/// [ConstantExpression] are handled.
class ListEncoder {
final Serializer _serializer;
final List<Value> _list;
@@ -151,7 +151,7 @@
}
/// Maps the [key] entry to the [type] in the encoded object.
- void setType(K key, DartType type) {
+ void setType(K key, ResolutionDartType type) {
_checkKey(key);
_map[key] = _serializer.createTypeValue(type);
}
@@ -159,7 +159,7 @@
/// Maps the [key] entry to the [types] in the encoded object.
///
/// If [types] is empty, it is skipped.
- void setTypes(K key, Iterable<DartType> types) {
+ void setTypes(K key, Iterable<ResolutionDartType> types) {
_checkKey(key);
if (types.isNotEmpty) {
_map[key] =
@@ -412,11 +412,12 @@
return list.map(_deserializer.deserializeConstant).toList();
}
- /// Returns the [DartType] value associated with [key] in the decoded object.
+ /// Returns the [ResolutionDartType] value associated with [key] in the
+ /// decoded object.
///
/// If no value is associated with [key], then if [isOptional] is `true`,
/// `null` is returned, otherwise an exception is thrown.
- DartType getType(K key, {bool isOptional: false}) {
+ ResolutionDartType getType(K key, {bool isOptional: false}) {
int id = _map[_getKeyValue(key)];
if (id == null) {
if (isOptional) {
@@ -427,12 +428,12 @@
return _deserializer.deserializeType(id);
}
- /// Returns the list of [DartType] values associated with [key] in the decoded
- /// object.
+ /// Returns the list of [ResolutionDartType] values associated with [key] in
+ /// the decoded object.
///
/// If no value is associated with [key], then if [isOptional] is `true`,
/// and empty [List] is returned, otherwise an exception is thrown.
- List<DartType> getTypes(K key, {bool isOptional: false}) {
+ List<ResolutionDartType> getTypes(K key, {bool isOptional: false}) {
List list = _map[_getKeyValue(key)];
if (list == null) {
if (isOptional) {
@@ -630,9 +631,9 @@
/// Serializer for the transitive closure of a collection of libraries.
///
-/// The serializer creates an [ObjectValue] model of the [Element], [DartType]
-/// and [ConstantExpression] values in the transitive closure of the serialized
-/// libraries.
+/// The serializer creates an [ObjectValue] model of the [Element],
+/// [ResolutionDartType] and [ConstantExpression] values in the transitive
+/// closure of the serialized libraries.
///
/// The model layout of the produced [objectValue] is:
///
@@ -662,7 +663,8 @@
Map<Element, DataObject> _elementMap = <Element, DataObject>{};
Map<ConstantExpression, DataObject> _constantMap =
<ConstantExpression, DataObject>{};
- Map<DartType, DataObject> _typeMap = <DartType, DataObject>{};
+ Map<ResolutionDartType, DataObject> _typeMap =
+ <ResolutionDartType, DataObject>{};
List _pendingList = [];
ElementMatcher shouldInclude;
@@ -848,7 +850,7 @@
/// If [type] has no [DataObject], a new [DataObject] is created and
/// encoding the [ObjectValue] for [type] is put into the work queue of this
/// serializer.
- Value _getTypeId(DartType type) {
+ Value _getTypeId(ResolutionDartType type) {
DataObject dataObject = _typeMap[type];
if (dataObject == null) {
_typeMap[type] = dataObject = new DataObject(
@@ -861,7 +863,7 @@
}
/// Encodes [type] into the [ObjectValue] of [dataObject].
- void _encodeType(DartType type, DataObject dataObject) {
+ void _encodeType(ResolutionDartType type, DataObject dataObject) {
const TypeSerializer().visit(type, new ObjectEncoder(this, dataObject.map));
}
@@ -869,7 +871,7 @@
///
/// If [type] has not already been serialized, it is added to the work
/// queue of this serializer.
- TypeValue createTypeValue(DartType type) {
+ TypeValue createTypeValue(ResolutionDartType type) {
return new TypeValue(type, _getTypeId(type));
}
@@ -982,7 +984,7 @@
ListDecoder _typeList;
ListDecoder _constantList;
Map<int, Element> _elementMap = {};
- Map<int, DartType> _typeMap = {};
+ Map<int, ResolutionDartType> _typeMap = {};
Map<int, ConstantExpression> _constantMap = {};
Deserializer.fromText(
@@ -998,7 +1000,8 @@
return _elementList;
}
- /// Returns the [ListDecoder] for the [DartType]s in this deserializer.
+ /// Returns the [ListDecoder] for the [ResolutionDartType]s in this
+ /// deserializer.
ListDecoder get types {
if (_typeList == null) {
_typeList = _headerObject.getList(Key.TYPES);
@@ -1105,8 +1108,8 @@
return element;
}
- /// Returns the deserialized [DartType] for [id].
- DartType deserializeType(int id) {
+ /// Returns the deserialized [ResolutionDartType] for [id].
+ ResolutionDartType deserializeType(int id) {
if (id == null) throw new ArgumentError('Deserializer.getType(null)');
return _typeMap.putIfAbsent(id, () {
return TypeDeserializer.deserialize(types.getObject(id));
diff --git a/pkg/compiler/lib/src/serialization/serialization_util.dart b/pkg/compiler/lib/src/serialization/serialization_util.dart
index 4883adb..8d60881 100644
--- a/pkg/compiler/lib/src/serialization/serialization_util.dart
+++ b/pkg/compiler/lib/src/serialization/serialization_util.dart
@@ -6,7 +6,7 @@
import '../common.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../diagnostics/messages.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart' show WrappedMessage;
@@ -350,7 +350,7 @@
ConstructorAccessKind constructorAccessKind =
decoder.getEnum(Key.SUB_KIND, ConstructorAccessKind.values);
Element element = decoder.getElement(Key.ELEMENT);
- DartType type = decoder.getType(Key.TYPE);
+ ResolutionDartType type = decoder.getType(Key.TYPE);
ConstructorAccessSemantics semantics =
new ConstructorAccessSemantics(constructorAccessKind, element, type);
Selector selector = deserializeSelector(decoder.getObject(Key.SELECTOR));
diff --git a/pkg/compiler/lib/src/serialization/system.dart b/pkg/compiler/lib/src/serialization/system.dart
index 9e6da49..12b4adb 100644
--- a/pkg/compiler/lib/src/serialization/system.dart
+++ b/pkg/compiler/lib/src/serialization/system.dart
@@ -9,7 +9,7 @@
import '../common.dart';
import '../common/resolution.dart';
import '../compiler.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../scanner/scanner.dart';
import '../script.dart';
@@ -169,13 +169,13 @@
return _resolutionImpactDeserializer.registerResolutionImpact(constructor,
() {
List<TypeUse> typeUses = <TypeUse>[];
- void addCheckedModeCheck(DartType type) {
+ void addCheckedModeCheck(ResolutionDartType type) {
if (!type.isDynamic) {
typeUses.add(new TypeUse.checkedModeCheck(type));
}
}
- FunctionType type = constructor.type;
+ ResolutionFunctionType type = constructor.type;
// TODO(johnniwinther): Remove this substitution when synthesized
// constructors handle type variables correctly.
type = type.substByContext(constructor.enclosingClass
diff --git a/pkg/compiler/lib/src/serialization/type_serialization.dart b/pkg/compiler/lib/src/serialization/type_serialization.dart
index 29c28f0..c5f68c8 100644
--- a/pkg/compiler/lib/src/serialization/type_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/type_serialization.dart
@@ -4,32 +4,35 @@
library dart2js.serialization.types;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import 'keys.dart';
import 'serialization.dart';
-/// Visitor that serializes a [DartType] by encoding it into an [ObjectEncoder].
+/// Visitor that serializes a [ResolutionDartType] by encoding it into an
+/// [ObjectEncoder].
///
-/// This class is called from the [Serializer] when a [DartType] needs
+/// This class is called from the [Serializer] when a [ResolutionDartType] needs
/// serialization. The [ObjectEncoder] ensures that any [Element], and other
-/// [DartType] that the serialized [DartType] depends upon are also serialized.
+/// [ResolutionDartType] that the serialized [ResolutionDartType] depends upon
+/// are also serialized.
class TypeSerializer extends DartTypeVisitor<dynamic, ObjectEncoder> {
const TypeSerializer();
- void visitType(DartType type, ObjectEncoder encoder) {
+ void visitType(ResolutionDartType type, ObjectEncoder encoder) {
throw new UnsupportedError('Unsupported type: $type');
}
- void visitVoidType(VoidType type, ObjectEncoder encoder) {}
+ void visitVoidType(ResolutionVoidType type, ObjectEncoder encoder) {}
- void visitTypeVariableType(TypeVariableType type, ObjectEncoder encoder) {
+ void visitTypeVariableType(
+ ResolutionTypeVariableType type, ObjectEncoder encoder) {
encoder.setElement(Key.ELEMENT, type.element);
encoder.setBool(
Key.IS_METHOD_TYPE_VARIABLE_TYPE, type is MethodTypeVariableType);
}
- void visitFunctionType(FunctionType type, ObjectEncoder encoder) {
+ void visitFunctionType(ResolutionFunctionType type, ObjectEncoder encoder) {
// TODO(johnniwinther): Support encoding of `type.element`.
encoder.setType(Key.RETURN_TYPE, type.returnType);
encoder.setTypes(Key.PARAMETER_TYPES, type.parameterTypes);
@@ -42,59 +45,61 @@
encoder.setElement(Key.ELEMENT, type.element);
}
- void visitInterfaceType(InterfaceType type, ObjectEncoder encoder) {
+ void visitInterfaceType(ResolutionInterfaceType type, ObjectEncoder encoder) {
encoder.setElement(Key.ELEMENT, type.element);
encoder.setTypes(Key.TYPE_ARGUMENTS, type.typeArguments);
}
- void visitTypedefType(TypedefType type, ObjectEncoder encoder) {
+ void visitTypedefType(ResolutionTypedefType type, ObjectEncoder encoder) {
encoder.setElement(Key.ELEMENT, type.element);
encoder.setTypes(Key.TYPE_ARGUMENTS, type.typeArguments);
}
- void visitDynamicType(DynamicType type, ObjectEncoder encoder) {}
+ void visitDynamicType(ResolutionDynamicType type, ObjectEncoder encoder) {}
}
-/// Utility class for deserializing [DartType]s.
+/// Utility class for deserializing [ResolutionDartType]s.
///
/// This is used by the [Deserializer].
class TypeDeserializer {
- /// Deserializes a [DartType] from an [ObjectDecoder].
+ /// Deserializes a [ResolutionDartType] from an [ObjectDecoder].
///
- /// The class is called from the [Deserializer] when a [DartType] needs
- /// deserialization. The [ObjectDecoder] ensures that any [Element], other
- /// [DartType] that the deserialized [DartType] depends upon are available.
- static DartType deserialize(ObjectDecoder decoder) {
- TypeKind typeKind = decoder.getEnum(Key.KIND, TypeKind.values);
+ /// The class is called from the [Deserializer] when a [ResolutionDartType]
+ /// needs deserialization. The [ObjectDecoder] ensures that any [Element],
+ /// other [ResolutionDartType] that the deserialized [ResolutionDartType]
+ /// depends upon are available.
+ static ResolutionDartType deserialize(ObjectDecoder decoder) {
+ ResolutionTypeKind typeKind =
+ decoder.getEnum(Key.KIND, ResolutionTypeKind.values);
switch (typeKind) {
- case TypeKind.INTERFACE:
- return new InterfaceType(decoder.getElement(Key.ELEMENT),
+ case ResolutionTypeKind.INTERFACE:
+ return new ResolutionInterfaceType(decoder.getElement(Key.ELEMENT),
decoder.getTypes(Key.TYPE_ARGUMENTS, isOptional: true));
- case TypeKind.FUNCTION:
+ case ResolutionTypeKind.FUNCTION:
// TODO(johnniwinther): Support decoding of `type.element`.
- return new FunctionType.synthesized(
+ return new ResolutionFunctionType.synthesized(
decoder.getType(Key.RETURN_TYPE),
decoder.getTypes(Key.PARAMETER_TYPES, isOptional: true),
decoder.getTypes(Key.OPTIONAL_PARAMETER_TYPES, isOptional: true),
decoder.getStrings(Key.NAMED_PARAMETERS, isOptional: true),
decoder.getTypes(Key.NAMED_PARAMETER_TYPES, isOptional: true));
- case TypeKind.TYPE_VARIABLE:
+ case ResolutionTypeKind.TYPE_VARIABLE:
TypeVariableElement element = decoder.getElement(Key.ELEMENT);
if (decoder.getBool(Key.IS_METHOD_TYPE_VARIABLE_TYPE)) {
return new MethodTypeVariableType(element);
}
- return new TypeVariableType(element);
- case TypeKind.TYPEDEF:
- return new TypedefType(decoder.getElement(Key.ELEMENT),
+ return new ResolutionTypeVariableType(element);
+ case ResolutionTypeKind.TYPEDEF:
+ return new ResolutionTypedefType(decoder.getElement(Key.ELEMENT),
decoder.getTypes(Key.TYPE_ARGUMENTS, isOptional: true));
- case TypeKind.MALFORMED_TYPE:
+ case ResolutionTypeKind.MALFORMED_TYPE:
// TODO(johnniwinther): Do we need the 'userProvidedBadType' or maybe
// just a toString of it?
return new MalformedType(decoder.getElement(Key.ELEMENT), null);
- case TypeKind.DYNAMIC:
- return const DynamicType();
- case TypeKind.VOID:
- return const VoidType();
+ case ResolutionTypeKind.DYNAMIC:
+ return const ResolutionDynamicType();
+ case ResolutionTypeKind.VOID:
+ return const ResolutionVoidType();
}
}
}
diff --git a/pkg/compiler/lib/src/serialization/values.dart b/pkg/compiler/lib/src/serialization/values.dart
index f23a6f0..cebbe18 100644
--- a/pkg/compiler/lib/src/serialization/values.dart
+++ b/pkg/compiler/lib/src/serialization/values.dart
@@ -7,7 +7,7 @@
library dart2js.serialization.values;
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import 'keys.dart';
@@ -49,7 +49,7 @@
}
class TypeValue implements Value {
- final DartType type;
+ final ResolutionDartType type;
final Value id;
TypeValue(this.type, this.id);
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 296aa81..685a313 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -16,7 +16,7 @@
import '../constants/expressions.dart';
import '../constants/values.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../diagnostics/messages.dart' show Message, MessageTemplate;
import '../dump_info.dart' show InfoReporter;
import '../elements/elements.dart';
@@ -68,7 +68,7 @@
HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) {
return measure(() {
- Element element = work.element.implementation;
+ MemberElement element = work.element.implementation;
return reporter.withCurrentElement(element, () {
SsaBuilder builder = new SsaBuilder(
work.element.implementation,
@@ -83,7 +83,7 @@
// Default arguments are handled elsewhere, but we must ensure
// that the default values are computed during codegen.
if (!identical(element.kind, ElementKind.FIELD)) {
- FunctionElement function = element;
+ MethodElement function = element;
FunctionSignature signature = function.functionSignature;
signature.forEachOptionalParameter((ParameterElement parameter) {
// This ensures the default value will be computed.
@@ -127,7 +127,7 @@
GraphBuilder
implements SemanticSendVisitor {
/// The element for which this SSA builder is being used.
- final Element target;
+ final MemberElement target;
final ClosedWorld closedWorld;
ResolvedAst resolvedAst;
@@ -177,7 +177,7 @@
* This stack contains declaration elements of the functions being built
* or inlined by this builder.
*/
- final List<Element> sourceElementStack = <Element>[];
+ final List<MemberElement> sourceElementStack = <MemberElement>[];
HInstruction rethrowableException;
@@ -255,7 +255,7 @@
// TODO(johnniwinther): Check that all usages of sourceElement agree on
// implementation/declaration distinction.
@override
- Element get sourceElement => sourceElementStack.last;
+ MemberElement get sourceElement => sourceElementStack.last;
/// Helper to retrieve global inference results for [element] with special
/// care for `ConstructorBodyElement`s which don't exist at the time the
@@ -302,7 +302,7 @@
}
HTypeConversion buildFunctionTypeConversion(
- HInstruction original, DartType type, int kind) {
+ HInstruction original, ResolutionDartType type, int kind) {
HInstruction reifiedType = buildFunctionType(type);
return new HTypeConversion.viaMethodOnType(
type, kind, original.instructionType, reifiedType, original);
@@ -350,7 +350,7 @@
* [selector]) in a specific order (see [addDynamicSendArgumentsToList]).
*/
List<HInstruction> completeDynamicSendArgumentsList(Selector selector,
- FunctionElement function, List<HInstruction> providedArguments) {
+ MethodElement function, List<HInstruction> providedArguments) {
assert(selector.applies(function));
FunctionSignature signature = function.functionSignature;
List<HInstruction> compiledArguments = new List<HInstruction>(
@@ -409,7 +409,7 @@
*/
bool tryInlineMethod(Element element, Selector selector, TypeMask mask,
List<HInstruction> providedArguments, ast.Node currentNode,
- {InterfaceType instanceType}) {
+ {ResolutionInterfaceType instanceType}) {
registry
.addImpact(backend.registerUsedElement(element, forResolution: false));
@@ -423,7 +423,7 @@
if (compiler.elementHasCompileTimeError(element)) return false;
- FunctionElement function = element;
+ MethodElement function = element;
ResolvedAst functionResolvedAst = function.resolvedAst;
bool insideLoop = loopDepth > 0 || graph.calledInLoop;
@@ -437,11 +437,11 @@
if (compiler.options.disableInlining) return false;
assert(invariant(
- currentNode != null ? currentNode : element,
+ currentNode != null ? currentNode : function,
selector != null ||
- Elements.isStaticOrTopLevel(element) ||
- element.isGenerativeConstructorBody,
- message: "Missing selector for inlining of $element."));
+ Elements.isStaticOrTopLevel(function) ||
+ function.isGenerativeConstructorBody,
+ message: "Missing selector for inlining of $function."));
if (selector != null) {
if (!selector.applies(function)) return false;
if (mask != null && !mask.canHit(function, selector, closedWorld)) {
@@ -449,11 +449,11 @@
}
}
- if (backend.isJsInterop(element)) return false;
+ if (backend.isJsInterop(function)) return false;
// Don't inline operator== methods if the parameter can be null.
- if (element.name == '==') {
- if (element.enclosingClass != commonElements.objectClass &&
+ if (function.name == '==') {
+ if (function.enclosingClass != commonElements.objectClass &&
providedArguments[1].canBeNull()) {
return false;
}
@@ -461,15 +461,15 @@
// Generative constructors of native classes should not be called directly
// and have an extra argument that causes problems with inlining.
- if (element.isGenerativeConstructor &&
- backend.isNativeOrExtendsNative(element.enclosingClass)) {
+ if (function.isGenerativeConstructor &&
+ backend.isNativeOrExtendsNative(function.enclosingClass)) {
return false;
}
// A generative constructor body is not seen by global analysis,
// so we should not query for its type.
- if (!element.isGenerativeConstructorBody) {
- if (inferenceResults.resultOf(element).throwsAlways) {
+ if (!function.isGenerativeConstructorBody) {
+ if (inferenceResults.resultOf(function).throwsAlways) {
isReachable = false;
return false;
}
@@ -487,7 +487,7 @@
bool reductiveHeuristic() {
// The call is on a path which is executed rarely, so inline only if it
// does not make the program larger.
- if (isCalledOnce(element)) {
+ if (isCalledOnce(function)) {
return InlineWeeder.canBeInlined(functionResolvedAst, -1, false,
enableUserAssertions: compiler.options.enableUserAssertions);
}
@@ -507,12 +507,12 @@
return false;
}
- if (element.isSynthesized) return true;
+ if (function.isSynthesized) return true;
// Don't inline across deferred import to prevent leaking code. The only
// exception is an empty function (which does not contain code).
bool hasOnlyNonDeferredImportPaths = compiler.deferredLoadTask
- .hasOnlyNonDeferredImportPaths(compiler.currentElement, element);
+ .hasOnlyNonDeferredImportPaths(compiler.currentElement, function);
if (!hasOnlyNonDeferredImportPaths) {
return doesNotContainCode();
@@ -546,7 +546,7 @@
// If a method is called only once, and all the methods in the
// inlining stack are called only once as well, we know we will
// save on output size by inlining this method.
- if (isCalledOnce(element)) {
+ if (isCalledOnce(function)) {
useMaxInliningNodes = false;
}
bool canInline;
@@ -554,9 +554,10 @@
functionResolvedAst, maxInliningNodes, useMaxInliningNodes,
enableUserAssertions: compiler.options.enableUserAssertions);
if (canInline) {
- backend.inlineCache.markAsInlinable(element, insideLoop: insideLoop);
+ backend.inlineCache.markAsInlinable(function, insideLoop: insideLoop);
} else {
- backend.inlineCache.markAsNonInlinable(element, insideLoop: insideLoop);
+ backend.inlineCache
+ .markAsNonInlinable(function, insideLoop: insideLoop);
}
return canInline;
}
@@ -565,8 +566,8 @@
// Add an explicit null check on the receiver before doing the
// inlining. We use [element] to get the same name in the
// NoSuchMethodError message as if we had called it.
- if (element.isInstanceMember &&
- !element.isGenerativeConstructorBody &&
+ if (function.isInstanceMember &&
+ !function.isGenerativeConstructorBody &&
(mask == null || mask.isNullable)) {
addWithPosition(
new HFieldGet(null, providedArguments[0], commonMasks.dynamicType,
@@ -589,7 +590,7 @@
if (meetsHardConstraints() && heuristicSayGoodToGo()) {
doInlining();
- infoReporter?.reportInlined(element,
+ infoReporter?.reportInlined(function,
inliningStack.isEmpty ? target : inliningStack.last.function);
return true;
}
@@ -601,18 +602,18 @@
return inliningStack.isEmpty || inliningStack.last.allFunctionsCalledOnce;
}
- bool isFunctionCalledOnce(element) {
+ bool isFunctionCalledOnce(MethodElement element) {
// ConstructorBodyElements are not in the type inference graph.
if (element is ConstructorBodyElement) return false;
return inferenceResults.resultOf(element).isCalledOnce;
}
- bool isCalledOnce(Element element) {
+ bool isCalledOnce(MethodElement element) {
return allInlinedFunctionsCalledOnce && isFunctionCalledOnce(element);
}
inlinedFrom(ResolvedAst resolvedAst, f()) {
- Element element = resolvedAst.element;
+ MemberElement element = resolvedAst.element;
assert(element is FunctionElement || element is VariableElement);
return reporter.withCurrentElement(element.implementation, () {
// The [sourceElementStack] contains declaration elements.
@@ -653,18 +654,19 @@
}
}
- /// A stack of [DartType]s that have been seen during inlining of factory
- /// constructors. These types are preserved in [HInvokeStatic]s and
+ /// A stack of [ResolutionDartType]s that have been seen during inlining of
+ /// factory constructors. These types are preserved in [HInvokeStatic]s and
/// [HCreate]s inside the inline code and registered during code generation
/// for these nodes.
// TODO(karlklose): consider removing this and keeping the (substituted) types
// of the type variables in an environment (like the [LocalsHandler]).
- final List<DartType> currentInlinedInstantiations = <DartType>[];
+ final List<ResolutionDartType> currentInlinedInstantiations =
+ <ResolutionDartType>[];
final List<AstInliningState> inliningStack = <AstInliningState>[];
Local returnLocal;
- DartType returnType;
+ ResolutionDartType returnType;
bool inTryStatement = false;
@@ -685,7 +687,7 @@
*
* Invariant: [functionElement] must be an implementation element.
*/
- HGraph buildMethod(FunctionElement functionElement) {
+ HGraph buildMethod(MethodElement functionElement) {
assert(invariant(functionElement, functionElement.isImplementation));
graph.calledInLoop = closedWorld.isCalledInLoop(functionElement);
ast.FunctionExpression function = resolvedAst.node;
@@ -768,7 +770,7 @@
return closeFunction();
}
- HGraph buildLazyInitializer(VariableElement variable) {
+ HGraph buildLazyInitializer(FieldElement variable) {
assert(invariant(variable, resolvedAst.element == variable,
message: "Unexpected variable $variable for $resolvedAst."));
inLazyInitializerExpression = true;
@@ -855,7 +857,7 @@
*/
void setupStateForInlining(
FunctionElement function, List<HInstruction> compiledArguments,
- {InterfaceType instanceType}) {
+ {ResolutionInterfaceType instanceType}) {
ResolvedAst resolvedAst = function.resolvedAst;
assert(resolvedAst != null);
localsHandler = new LocalsHandler(this, function, instanceType, compiler);
@@ -881,7 +883,8 @@
ClassElement enclosing = function.enclosingClass;
if ((function.isConstructor || function.isGenerativeConstructorBody) &&
backend.classNeedsRti(enclosing)) {
- enclosing.typeVariables.forEach((TypeVariableType typeVariable) {
+ enclosing.typeVariables
+ .forEach((ResolutionTypeVariableType typeVariable) {
HInstruction argument = compiledArguments[argumentIndex++];
localsHandler.updateLocal(
localsHandler.getTypeVariableAsLocal(typeVariable), argument);
@@ -922,13 +925,13 @@
}
}
- addInlinedInstantiation(DartType type) {
+ addInlinedInstantiation(ResolutionDartType type) {
if (type != null) {
currentInlinedInstantiations.add(type);
}
}
- removeInlinedInstantiation(DartType type) {
+ removeInlinedInstantiation(ResolutionDartType type) {
if (type != null) {
currentInlinedInstantiations.removeLast();
}
@@ -967,16 +970,17 @@
// [currentClass]. For a redirecting constructor, the type is
// the current type. [InterfaceType.asInstanceOf] takes care
// of both.
- InterfaceType type = currentClass.thisType.asInstanceOf(enclosingClass);
+ ResolutionInterfaceType type =
+ currentClass.thisType.asInstanceOf(enclosingClass);
type = localsHandler.substInContext(type);
- List<DartType> arguments = type.typeArguments;
- List<DartType> typeVariables = enclosingClass.typeVariables;
+ List<ResolutionDartType> arguments = type.typeArguments;
+ List<ResolutionDartType> typeVariables = enclosingClass.typeVariables;
if (!type.isRaw) {
assert(arguments.length == typeVariables.length);
- Iterator<DartType> variables = typeVariables.iterator;
- type.typeArguments.forEach((DartType argument) {
+ Iterator<ResolutionDartType> variables = typeVariables.iterator;
+ type.typeArguments.forEach((ResolutionDartType argument) {
variables.moveNext();
- TypeVariableType typeVariable = variables.current;
+ ResolutionTypeVariableType typeVariable = variables.current;
localsHandler.updateLocal(
localsHandler.getTypeVariableAsLocal(typeVariable),
typeBuilder.analyzeTypeArgument(argument, sourceElement));
@@ -984,7 +988,7 @@
} else {
// If the supertype is a raw type, we need to set to null the
// type variables.
- for (TypeVariableType variable in typeVariables) {
+ for (ResolutionTypeVariableType variable in typeVariables) {
localsHandler.updateLocal(
localsHandler.getTypeVariableAsLocal(variable),
graph.addConstantNull(closedWorld));
@@ -1280,19 +1284,20 @@
member, isNativeUpgradeFactory || compiler.compilationFailed));
} else {
fields.add(member);
- DartType type = localsHandler.substInContext(member.type);
+ ResolutionDartType type = localsHandler.substInContext(member.type);
constructorArguments
.add(typeBuilder.potentiallyCheckOrTrustType(value, type));
}
}, includeSuperAndInjectedMembers: true);
- InterfaceType type = classElement.thisType;
+ ResolutionInterfaceType type = classElement.thisType;
TypeMask ssaType =
new TypeMask.nonNullExact(classElement.declaration, closedWorld);
- List<DartType> instantiatedTypes;
+ List<ResolutionDartType> instantiatedTypes;
addInlinedInstantiation(type);
if (!currentInlinedInstantiations.isEmpty) {
- instantiatedTypes = new List<DartType>.from(currentInlinedInstantiations);
+ instantiatedTypes =
+ new List<ResolutionDartType>.from(currentInlinedInstantiations);
}
HInstruction newObject;
@@ -1304,7 +1309,8 @@
// HTypeInfoExpression to set on the newly create object.
hasRtiInput = true;
List<HInstruction> typeArguments = <HInstruction>[];
- classElement.typeVariables.forEach((TypeVariableType typeVariable) {
+ classElement.typeVariables
+ .forEach((ResolutionTypeVariableType typeVariable) {
HInstruction argument = localsHandler
.readLocal(localsHandler.getTypeVariableAsLocal(typeVariable));
typeArguments.add(argument);
@@ -1388,7 +1394,8 @@
if (backend.classNeedsRti(currentClass)) {
// If [currentClass] needs RTI, we add the type variables as
// parameters of the generative constructor body.
- currentClass.typeVariables.forEach((TypeVariableType argument) {
+ currentClass.typeVariables
+ .forEach((ResolutionTypeVariableType argument) {
// TODO(johnniwinther): Substitute [argument] with
// `localsHandler.substInContext(argument)`.
bodyCallInputs.add(localsHandler
@@ -1437,7 +1444,8 @@
var enclosing = element.enclosingElement;
if ((element.isConstructor || element.isGenerativeConstructorBody) &&
backend.classNeedsRti(enclosing)) {
- enclosing.typeVariables.forEach((TypeVariableType typeVariable) {
+ enclosing.typeVariables
+ .forEach((ResolutionTypeVariableType typeVariable) {
HParameterValue param =
addParameter(typeVariable.element, commonMasks.nonNullType);
localsHandler.directLocals[
@@ -1519,8 +1527,8 @@
}
}
- void assertIsSubtype(
- ast.Node node, DartType subtype, DartType supertype, String message) {
+ void assertIsSubtype(ast.Node node, ResolutionDartType subtype,
+ ResolutionDartType supertype, String message) {
HInstruction subtypeInstruction = typeBuilder.analyzeTypeArgument(
localsHandler.substInContext(subtype), sourceElement);
HInstruction supertypeInstruction = typeBuilder.analyzeTypeArgument(
@@ -2392,7 +2400,7 @@
}
@override
- void visitAs(ast.Send node, ast.Node expression, DartType type, _) {
+ void visitAs(ast.Send node, ast.Node expression, ResolutionDartType type, _) {
HInstruction expressionInstruction = visitAndPop(expression);
if (type.isMalformed) {
if (type is MalformedType) {
@@ -2413,13 +2421,14 @@
}
@override
- void visitIs(ast.Send node, ast.Node expression, DartType type, _) {
+ void visitIs(ast.Send node, ast.Node expression, ResolutionDartType type, _) {
HInstruction expressionInstruction = visitAndPop(expression);
push(buildIsNode(node, type, expressionInstruction));
}
@override
- void visitIsNot(ast.Send node, ast.Node expression, DartType type, _) {
+ void visitIsNot(
+ ast.Send node, ast.Node expression, ResolutionDartType type, _) {
HInstruction expressionInstruction = visitAndPop(expression);
HInstruction instruction = buildIsNode(node, type, expressionInstruction);
add(instruction);
@@ -2427,7 +2436,7 @@
}
HInstruction buildIsNode(
- ast.Node node, DartType type, HInstruction expression) {
+ ast.Node node, ResolutionDartType type, HInstruction expression) {
type = localsHandler.substInContext(type).unaliased;
if (type.isMalformed) {
String message;
@@ -3278,14 +3287,14 @@
});
}
- HInstruction handleListConstructor(
- InterfaceType type, ast.Node currentNode, HInstruction newObject) {
+ HInstruction handleListConstructor(ResolutionInterfaceType type,
+ ast.Node currentNode, HInstruction newObject) {
if (!backend.classNeedsRti(type.element) || type.treatAsRaw) {
return newObject;
}
List<HInstruction> inputs = <HInstruction>[];
type = localsHandler.substInContext(type);
- type.typeArguments.forEach((DartType argument) {
+ type.typeArguments.forEach((ResolutionDartType argument) {
inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement));
});
// TODO(15489): Register at codegen.
@@ -3395,8 +3404,8 @@
target = target.immediateRedirectionTarget;
}
}
- InterfaceType type = elements.getType(node);
- InterfaceType expectedType =
+ ResolutionInterfaceType type = elements.getType(node);
+ ResolutionInterfaceType expectedType =
constructorDeclaration.computeEffectiveTargetType(type);
expectedType = localsHandler.substInContext(expectedType);
@@ -3524,12 +3533,12 @@
}
}
- void potentiallyAddTypeArguments(
- List<HInstruction> inputs, ClassElement cls, InterfaceType expectedType,
+ void potentiallyAddTypeArguments(List<HInstruction> inputs, ClassElement cls,
+ ResolutionInterfaceType expectedType,
{SourceInformation sourceInformation}) {
if (!backend.classNeedsRti(cls)) return;
assert(cls.typeVariables.length == expectedType.typeArguments.length);
- expectedType.typeArguments.forEach((DartType argument) {
+ expectedType.typeArguments.forEach((ResolutionDartType argument) {
inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement,
sourceInformation: sourceInformation));
});
@@ -3537,15 +3546,19 @@
/// In checked mode checks the [type] of [node] to be well-bounded. The method
/// returns [:true:] if an error can be statically determined.
- bool checkTypeVariableBounds(ast.NewExpression node, InterfaceType type) {
+ bool checkTypeVariableBounds(
+ ast.NewExpression node, ResolutionInterfaceType type) {
if (!compiler.options.enableTypeAssertions) return false;
- Map<DartType, Set<DartType>> seenChecksMap =
- new Map<DartType, Set<DartType>>();
+ Map<ResolutionDartType, Set<ResolutionDartType>> seenChecksMap =
+ new Map<ResolutionDartType, Set<ResolutionDartType>>();
bool definitelyFails = false;
- void addTypeVariableBoundCheck(GenericType instance, DartType typeArgument,
- TypeVariableType typeVariable, DartType bound) {
+ void addTypeVariableBoundCheck(
+ GenericType instance,
+ ResolutionDartType typeArgument,
+ ResolutionTypeVariableType typeVariable,
+ ResolutionDartType bound) {
if (definitelyFails) return;
int subtypeRelation =
@@ -3565,8 +3578,8 @@
definitelyFails = true;
return;
} else if (subtypeRelation == Types.MAYBE_SUBTYPE) {
- Set<DartType> seenChecks =
- seenChecksMap.putIfAbsent(typeArgument, () => new Set<DartType>());
+ Set<ResolutionDartType> seenChecks = seenChecksMap.putIfAbsent(
+ typeArgument, () => new Set<ResolutionDartType>());
if (!seenChecks.contains(bound)) {
seenChecks.add(bound);
assertIsSubtype(node, typeArgument, bound, message);
@@ -3578,8 +3591,8 @@
if (definitelyFails) {
return true;
}
- for (InterfaceType supertype in type.element.allSupertypes) {
- DartType instance = type.asInstanceOf(supertype.element);
+ for (ResolutionInterfaceType supertype in type.element.allSupertypes) {
+ ResolutionDartType instance = type.asInstanceOf(supertype.element);
compiler.types
.checkTypeVariableBounds(instance, addTypeVariableBoundCheck);
if (definitelyFails) {
@@ -3796,14 +3809,14 @@
/// Generate the literal for [typeVariable] in the current context.
void generateTypeVariableLiteral(
- ast.Send node, TypeVariableType typeVariable) {
+ ast.Send node, ResolutionTypeVariableType typeVariable) {
// GENERIC_METHODS: This provides thin support for method type variables
// by treating them as malformed when evaluated as a literal. For full
// support of generic methods this must be revised.
if (typeVariable is MethodTypeVariableType) {
generateTypeError(node, "Method type variables are not reified");
} else {
- DartType type = localsHandler.substInContext(typeVariable);
+ ResolutionDartType type = localsHandler.substInContext(typeVariable);
HInstruction value = typeBuilder.analyzeTypeArgument(type, sourceElement,
sourceInformation: sourceInformationBuilder.buildGet(node));
pushInvokeStatic(node, helpers.runtimeTypeToString, [value],
@@ -3962,7 +3975,7 @@
void errorNonConstantConstructorInvoke(
ast.NewExpression node,
Element element,
- DartType type,
+ ResolutionDartType type,
ast.NodeList arguments,
CallStructure callStructure,
_) {
@@ -4095,7 +4108,7 @@
var nativeBehavior = new native.NativeBehavior()
..sideEffects.setAllSideEffects();
- DartType type = element.isConstructor
+ ResolutionDartType type = element.isConstructor
? element.enclosingClass.thisType
: element.type.returnType;
// Native behavior effects here are similar to native/behavior.dart.
@@ -4104,7 +4117,7 @@
nativeBehavior.typesReturned.add(
compiler.options.trustJSInteropTypeAnnotations
? type
- : const DynamicType());
+ : const ResolutionDynamicType());
// The allocation effects include the declared type if it is native (which
// includes js interop types).
@@ -4140,7 +4153,7 @@
void pushInvokeStatic(
ast.Node location, MethodElement element, List<HInstruction> arguments,
{TypeMask typeMask,
- InterfaceType instanceType,
+ ResolutionInterfaceType instanceType,
SourceInformation sourceInformation}) {
assert(element.isDeclaration);
// TODO(johnniwinther): Use [sourceInformation] instead of [location].
@@ -4166,7 +4179,7 @@
..sourceInformation = sourceInformation;
if (currentInlinedInstantiations.isNotEmpty) {
instruction.instantiatedTypes =
- new List<DartType>.from(currentInlinedInstantiations);
+ new List<ResolutionDartType>.from(currentInlinedInstantiations);
}
instruction.sideEffects = closedWorld.getSideEffectsOfElement(element);
}
@@ -5126,10 +5139,10 @@
ClassElement targetClass = targetConstructor.enclosingClass;
if (backend.classNeedsRti(targetClass)) {
ClassElement cls = redirectingConstructor.enclosingClass;
- InterfaceType targetType =
+ ResolutionInterfaceType targetType =
redirectingConstructor.computeEffectiveTargetType(cls.thisType);
targetType = localsHandler.substInContext(targetType);
- targetType.typeArguments.forEach((DartType argument) {
+ targetType.typeArguments.forEach((ResolutionDartType argument) {
inputs.add(typeBuilder.analyzeTypeArgument(argument, sourceElement));
});
}
@@ -5145,7 +5158,7 @@
/// either dynamic, Object, or Future.
///
/// We do not accept the internal Future implementation class.
- bool isValidAsyncReturnType(DartType type) {
+ bool isValidAsyncReturnType(ResolutionDartType type) {
assert(isBuildingAsyncFunction);
// TODO(sigurdm): In an internal library a function could be declared:
//
@@ -5156,7 +5169,8 @@
// case.
return type.isDynamic ||
type.isObject ||
- (type is InterfaceType && type.element == commonElements.futureClass);
+ (type is ResolutionInterfaceType &&
+ type.element == commonElements.futureClass);
}
visitReturn(ast.Return node) {
@@ -5236,12 +5250,13 @@
}
HInstruction setRtiIfNeeded(HInstruction object, ast.Node node) {
- InterfaceType type = localsHandler.substInContext(elements.getType(node));
+ ResolutionInterfaceType type =
+ localsHandler.substInContext(elements.getType(node));
if (!backend.classNeedsRti(type.element) || type.treatAsRaw) {
return object;
}
List<HInstruction> arguments = <HInstruction>[];
- for (DartType argument in type.typeArguments) {
+ for (ResolutionDartType argument in type.typeArguments) {
arguments.add(typeBuilder.analyzeTypeArgument(argument, sourceElement));
}
// TODO(15489): Register at codegen.
@@ -5673,8 +5688,8 @@
ConstructorElement functionElement = constructor;
constructor = functionElement.effectiveTarget;
- InterfaceType type = elements.getType(node);
- InterfaceType expectedType =
+ ResolutionInterfaceType type = elements.getType(node);
+ ResolutionInterfaceType expectedType =
functionElement.computeEffectiveTargetType(type);
expectedType = localsHandler.substInContext(expectedType);
@@ -5682,7 +5697,7 @@
if (backend.classNeedsRti(cls)) {
List<HInstruction> typeInputs = <HInstruction>[];
- expectedType.typeArguments.forEach((DartType argument) {
+ expectedType.typeArguments.forEach((ResolutionDartType argument) {
typeInputs
.add(typeBuilder.analyzeTypeArgument(argument, sourceElement));
});
@@ -6243,7 +6258,7 @@
void pushCondition(ast.CatchBlock catchBlock) {
if (catchBlock.onKeyword != null) {
- DartType type = elements.getType(catchBlock.type);
+ ResolutionDartType type = elements.getType(catchBlock.type);
if (type == null) {
reporter.internalError(catchBlock.type, 'On with no type.');
}
@@ -6261,7 +6276,7 @@
// "if" condition above and this "else" branch should be deleted as
// type of declared variable won't matter for the catch
// condition.
- DartType type = elements.getType(declaration.type);
+ ResolutionDartType type = elements.getType(declaration.type);
if (type == null) {
reporter.internalError(catchBlock, 'Catch with unresolved type.');
}
@@ -6412,9 +6427,9 @@
* This method is invoked before inlining the body of [function] into this
* [SsaBuilder].
*/
- void enterInlinedMethod(FunctionElement function,
+ void enterInlinedMethod(MethodElement function,
ResolvedAst functionResolvedAst, List<HInstruction> compiledArguments,
- {InterfaceType instanceType}) {
+ {ResolutionInterfaceType instanceType}) {
AstInliningState state = new AstInliningState(
function,
returnLocal,
@@ -6741,7 +6756,7 @@
class AstInliningState extends InliningState {
final Local oldReturnLocal;
- final DartType oldReturnType;
+ final ResolutionDartType oldReturnType;
final ResolvedAst oldResolvedAst;
final List<HInstruction> oldStack;
final LocalsHandler oldLocalsHandler;
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 1fc734f..a61c7e8 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -16,7 +16,7 @@
InterceptorConstantValue,
StringConstantValue,
TypeConstantValue;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../io/source_information.dart';
import '../js/js.dart' as js;
@@ -101,13 +101,14 @@
/// be null.
ir.FunctionNode _targetFunction;
- /// A stack of [DartType]s that have been seen during inlining of factory
- /// constructors. These types are preserved in [HInvokeStatic]s and
+ /// A stack of [ResolutionDartType]s that have been seen during inlining of
+ /// factory constructors. These types are preserved in [HInvokeStatic]s and
/// [HCreate]s inside the inline code and registered during code generation
/// for these nodes.
// TODO(karlklose): consider removing this and keeping the (substituted) types
// of the type variables in an environment (like the [LocalsHandler]).
- final List<DartType> currentImplicitInstantiations = <DartType>[];
+ final List<ResolutionDartType> currentImplicitInstantiations =
+ <ResolutionDartType>[];
HInstruction rethrowableException;
@@ -234,9 +235,8 @@
addParameter(typeParamElement, commonMasks.nonNullType);
// This is a little bit wacky (and n^2) until we make the localsHandler
// take Kernel DartTypes instead of just the AST DartTypes.
- var typeVariableType = clsElement
- .typeVariables
- .firstWhere((TypeVariableType i) => i.name == typeParameter.name);
+ var typeVariableType = clsElement.typeVariables.firstWhere(
+ (ResolutionTypeVariableType i) => i.name == typeParameter.name);
localsHandler.directLocals[
localsHandler.getTypeVariableAsLocal(typeVariableType)] = param;
});
@@ -277,7 +277,7 @@
constructorArguments,
new TypeMask.nonNullExact(
astAdapter.getClass(constructor.enclosingClass), closedWorld),
- instantiatedTypes: <DartType>[
+ instantiatedTypes: <ResolutionDartType>[
astAdapter.getClass(constructor.enclosingClass).thisType
],
hasRtiInput: false);
@@ -309,34 +309,35 @@
/// Collects field initializers all the way up the inheritance chain.
void _buildInitializers(
ir.Constructor constructor, Map<ir.Field, HInstruction> fieldValues) {
- var foundSuperCall = false;
+ var foundSuperOrRedirectCall = false;
for (var initializer in constructor.initializers) {
- if (initializer is ir.SuperInitializer) {
- foundSuperCall = true;
- var superConstructor = initializer.target;
+ if (initializer is ir.SuperInitializer ||
+ initializer is ir.RedirectingInitializer) {
+ foundSuperOrRedirectCall = true;
+ var superOrRedirectConstructor = initializer.target;
var arguments = _normalizeAndBuildArguments(
- superConstructor.function, initializer.arguments);
- _buildInlinedSuperInitializers(
- superConstructor, arguments, fieldValues);
+ superOrRedirectConstructor.function, initializer.arguments);
+ _buildInlinedInitializers(
+ superOrRedirectConstructor, arguments, fieldValues);
} else if (initializer is ir.FieldInitializer) {
initializer.value.accept(this);
fieldValues[initializer.field] = pop();
}
}
- // TODO(het): does kernel always set the super initializer at the end?
- // If there was no super-call initializer, then call the default constructor
- // in the superclass.
- if (!foundSuperCall) {
+ // Kernel always set the super initializer at the end, so if there was no
+ // super-call initializer, then the default constructor is called in the
+ // superclass.
+ if (!foundSuperOrRedirectCall) {
if (constructor.enclosingClass != astAdapter.objectClass) {
var superclass = constructor.enclosingClass.superclass;
var defaultConstructor = superclass.constructors
- .firstWhere((c) => c.name == '', orElse: () => null);
+ .firstWhere((c) => c.name.name == '', orElse: () => null);
if (defaultConstructor == null) {
compiler.reporter.internalError(
NO_LOCATION_SPANNABLE, 'Could not find default constructor.');
}
- _buildInlinedSuperInitializers(
+ _buildInlinedInitializers(
defaultConstructor, <HInstruction>[], fieldValues);
}
}
@@ -388,7 +389,7 @@
/// Inlines the given super [constructor]'s initializers by collecting it's
/// field values and building its constructor initializers. We visit super
/// constructors all the way up to the [Object] constructor.
- void _buildInlinedSuperInitializers(ir.Constructor constructor,
+ void _buildInlinedInitializers(ir.Constructor constructor,
List<HInstruction> arguments, Map<ir.Field, HInstruction> fieldValues) {
// TODO(het): Handle RTI if class needs it
fieldValues.addAll(_collectFieldValues(constructor.enclosingClass));
@@ -410,7 +411,7 @@
}
HTypeConversion buildFunctionTypeConversion(
- HInstruction original, DartType type, int kind) {
+ HInstruction original, ResolutionDartType type, int kind) {
HInstruction reifiedType = buildFunctionType(type);
return new HTypeConversion.viaMethodOnType(
type, kind, original.instructionType, reifiedType, original);
@@ -429,13 +430,13 @@
closeFunction();
}
- void addImplicitInstantiation(DartType type) {
+ void addImplicitInstantiation(ResolutionDartType type) {
if (type != null) {
currentImplicitInstantiations.add(type);
}
}
- void removeImplicitInstantiation(DartType type) {
+ void removeImplicitInstantiation(ResolutionDartType type) {
if (type != null) {
currentImplicitInstantiations.removeLast();
}
@@ -783,6 +784,146 @@
}
@override
+ visitDoStatement(ir.DoStatement doStatement) {
+ // TODO(efortuna): I think this can be rewritten using
+ // LoopHandler.handleLoop with some tricks about when the "update" happens.
+ LocalsHandler savedLocals = new LocalsHandler.from(localsHandler);
+ localsHandler.startLoop(astAdapter.getNode(doStatement));
+ JumpHandler jumpHandler = loopHandler.beginLoopHeader(doStatement);
+ HLoopInformation loopInfo = current.loopInformation;
+ HBasicBlock loopEntryBlock = current;
+ HBasicBlock bodyEntryBlock = current;
+ JumpTarget target =
+ elements.getTargetDefinition(astAdapter.getNode(doStatement));
+ bool hasContinues = target != null && target.isContinueTarget;
+ if (hasContinues) {
+ // Add extra block to hang labels on.
+ // It doesn't currently work if they are on the same block as the
+ // HLoopInfo. The handling of HLabeledBlockInformation will visit a
+ // SubGraph that starts at the same block again, so the HLoopInfo is
+ // either handled twice, or it's handled after the labeled block info,
+ // both of which generate the wrong code.
+ // Using a separate block is just a simple workaround.
+ bodyEntryBlock = openNewBlock();
+ }
+ localsHandler.enterLoopBody(astAdapter.getNode(doStatement));
+ doStatement.body.accept(this);
+
+ // If there are no continues we could avoid the creation of the condition
+ // block. This could also lead to a block having multiple entries and exits.
+ HBasicBlock bodyExitBlock;
+ bool isAbortingBody = false;
+ if (current != null) {
+ bodyExitBlock = close(new HGoto());
+ } else {
+ isAbortingBody = true;
+ bodyExitBlock = lastOpenedBlock;
+ }
+
+ SubExpression conditionExpression;
+ bool loopIsDegenerate = isAbortingBody && !hasContinues;
+ if (!loopIsDegenerate) {
+ HBasicBlock conditionBlock = addNewBlock();
+
+ List<LocalsHandler> continueHandlers = <LocalsHandler>[];
+ jumpHandler
+ .forEachContinue((HContinue instruction, LocalsHandler locals) {
+ instruction.block.addSuccessor(conditionBlock);
+ continueHandlers.add(locals);
+ });
+
+ if (!isAbortingBody) {
+ bodyExitBlock.addSuccessor(conditionBlock);
+ }
+
+ if (!continueHandlers.isEmpty) {
+ if (!isAbortingBody) continueHandlers.add(localsHandler);
+ localsHandler =
+ savedLocals.mergeMultiple(continueHandlers, conditionBlock);
+ SubGraph bodyGraph = new SubGraph(bodyEntryBlock, bodyExitBlock);
+ List<LabelDefinition> labels = jumpHandler.labels;
+ HSubGraphBlockInformation bodyInfo =
+ new HSubGraphBlockInformation(bodyGraph);
+ HLabeledBlockInformation info;
+ if (!labels.isEmpty) {
+ info =
+ new HLabeledBlockInformation(bodyInfo, labels, isContinue: true);
+ } else {
+ info = new HLabeledBlockInformation.implicit(bodyInfo, target,
+ isContinue: true);
+ }
+ bodyEntryBlock.setBlockFlow(info, conditionBlock);
+ }
+ open(conditionBlock);
+
+ doStatement.condition.accept(this);
+ assert(!isAborted());
+ HInstruction conditionInstruction = popBoolified();
+ HBasicBlock conditionEndBlock = close(
+ new HLoopBranch(conditionInstruction, HLoopBranch.DO_WHILE_LOOP));
+
+ HBasicBlock avoidCriticalEdge = addNewBlock();
+ conditionEndBlock.addSuccessor(avoidCriticalEdge);
+ open(avoidCriticalEdge);
+ close(new HGoto());
+ avoidCriticalEdge.addSuccessor(loopEntryBlock); // The back-edge.
+
+ conditionExpression =
+ new SubExpression(conditionBlock, conditionEndBlock);
+
+ // Avoid a critical edge from the condition to the loop-exit body.
+ HBasicBlock conditionExitBlock = addNewBlock();
+ open(conditionExitBlock);
+ close(new HGoto());
+ conditionEndBlock.addSuccessor(conditionExitBlock);
+
+ loopHandler.endLoop(
+ loopEntryBlock, conditionExitBlock, jumpHandler, localsHandler);
+
+ loopEntryBlock.postProcessLoopHeader();
+ SubGraph bodyGraph = new SubGraph(loopEntryBlock, bodyExitBlock);
+ HLoopBlockInformation loopBlockInfo = new HLoopBlockInformation(
+ HLoopBlockInformation.DO_WHILE_LOOP,
+ null,
+ wrapExpressionGraph(conditionExpression),
+ wrapStatementGraph(bodyGraph),
+ null,
+ loopEntryBlock.loopInformation.target,
+ loopEntryBlock.loopInformation.labels,
+ sourceInformationBuilder.buildLoop(astAdapter.getNode(doStatement)));
+ loopEntryBlock.setBlockFlow(loopBlockInfo, current);
+ loopInfo.loopBlockInformation = loopBlockInfo;
+ } else {
+ // Since the loop has no back edge, we remove the loop information on the
+ // header.
+ loopEntryBlock.loopInformation = null;
+
+ if (jumpHandler.hasAnyBreak()) {
+ // Null branchBlock because the body of the do-while loop always aborts,
+ // so we never get to the condition.
+ loopHandler.endLoop(loopEntryBlock, null, jumpHandler, localsHandler);
+
+ // Since the body of the loop has a break, we attach a synthesized label
+ // to the body.
+ SubGraph bodyGraph = new SubGraph(bodyEntryBlock, bodyExitBlock);
+ JumpTarget target =
+ elements.getTargetDefinition(astAdapter.getNode(doStatement));
+ LabelDefinition label = target.addLabel(null, 'loop');
+ label.setBreakTarget();
+ HLabeledBlockInformation info = new HLabeledBlockInformation(
+ new HSubGraphBlockInformation(bodyGraph), <LabelDefinition>[label]);
+ loopEntryBlock.setBlockFlow(info, current);
+ jumpHandler.forEachBreak((HBreak breakInstruction, _) {
+ HBasicBlock block = breakInstruction.block;
+ block.addAtExit(new HBreak.toLabel(label));
+ block.remove(breakInstruction);
+ });
+ }
+ }
+ jumpHandler.close();
+ }
+
+ @override
void visitIfStatement(ir.IfStatement ifStatement) {
handleIf(
visitCondition: () => ifStatement.condition.accept(this),
@@ -794,7 +935,7 @@
void visitAsExpression(ir.AsExpression asExpression) {
asExpression.operand.accept(this);
HInstruction expressionInstruction = pop();
- DartType type = astAdapter.getDartType(asExpression.type);
+ ResolutionDartType type = astAdapter.getDartType(asExpression.type);
if (type.isMalformed) {
if (type is MalformedType) {
ErroneousElement element = type.element;
@@ -959,13 +1100,13 @@
/// Set the runtime type information if necessary.
HInstruction setListRuntimeTypeInfoIfNeeded(
HInstruction object, ir.ListLiteral listLiteral) {
- InterfaceType type = localsHandler
+ ResolutionInterfaceType type = localsHandler
.substInContext(astAdapter.getDartTypeOfListLiteral(listLiteral));
if (!backend.classNeedsRti(type.element) || type.treatAsRaw) {
return object;
}
List<HInstruction> arguments = <HInstruction>[];
- for (DartType argument in type.typeArguments) {
+ for (ResolutionDartType argument in type.typeArguments) {
arguments.add(typeBuilder.analyzeTypeArgument(argument, sourceElement));
}
// TODO(15489): Register at codegen.
@@ -1031,14 +1172,14 @@
assert(constructor.kind == ir.ProcedureKind.Factory);
- InterfaceType type = localsHandler
+ ResolutionInterfaceType type = localsHandler
.substInContext(astAdapter.getDartTypeOfMapLiteral(mapLiteral));
ir.Class cls = constructor.enclosingClass;
if (backend.classNeedsRti(astAdapter.getElement(cls))) {
List<HInstruction> typeInputs = <HInstruction>[];
- type.typeArguments.forEach((DartType argument) {
+ type.typeArguments.forEach((ResolutionDartType argument) {
typeInputs
.add(typeBuilder.analyzeTypeArgument(argument, sourceElement));
});
@@ -1059,7 +1200,8 @@
// If runtime type information is needed and the map literal has no type
// parameters, 'constructor' is a static function that forwards the call to
// the factory constructor without type parameters.
- assert(constructor.kind == ir.ProcedureKind.Factory);
+ assert(constructor.kind == ir.ProcedureKind.Method ||
+ constructor.kind == ir.ProcedureKind.Factory);
// The instruction type will always be a subtype of the mapLiteralClass, but
// type inference might discover a more specific type, or find nothing (in
@@ -1094,7 +1236,7 @@
}
if (type is ir.TypeParameterType) {
// TODO(sra): Convert the type logic here to use ir.DartType.
- DartType dartType = astAdapter.getDartType(type);
+ ResolutionDartType dartType = astAdapter.getDartType(type);
dartType = localsHandler.substInContext(dartType);
HInstruction value = typeBuilder.analyzeTypeArgument(
dartType, sourceElement,
@@ -1791,7 +1933,7 @@
targetCanThrow: astAdapter.getCanThrow(target, closedWorld));
if (currentImplicitInstantiations.isNotEmpty) {
instruction.instantiatedTypes =
- new List<DartType>.from(currentImplicitInstantiations);
+ new List<ResolutionDartType>.from(currentImplicitInstantiations);
}
instruction.sideEffects = astAdapter.getSideEffects(target, closedWorld);
@@ -1972,7 +2114,7 @@
// Note: The call to "unalias" this type like in the original SSA builder is
// unnecessary in kernel because Kernel has no notion of typedef.
// TODO(efortuna): Add test for this.
- DartType typeValue =
+ ResolutionDartType typeValue =
localsHandler.substInContext(astAdapter.getDartType(type));
if (type is ir.InvalidType) {
generateTypeError(node, (typeValue.element as ErroneousElement).message);
diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart
index 67bcd30..68f7422 100644
--- a/pkg/compiler/lib/src/ssa/codegen.dart
+++ b/pkg/compiler/lib/src/ssa/codegen.dart
@@ -10,9 +10,18 @@
import '../constants/constant_system.dart';
import '../constants/values.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
-import '../elements/elements.dart';
+import '../elements/elements.dart'
+ show
+ Entity,
+ JumpTarget,
+ LabelDefinition,
+ Local,
+ Name,
+ AsyncMarker,
+ ResolvedAst,
+ FunctionElement;
import '../elements/entities.dart';
+import '../elements/resolution_types.dart';
import '../io/source_information.dart';
import '../js/js.dart' as js;
import '../js_backend/backend_helpers.dart' show BackendHelpers;
@@ -794,7 +803,7 @@
js.Catch catchPart = null;
js.Block finallyPart = null;
if (info.catchBlock != null) {
- void register(ClassElement classElement) {
+ void register(ClassEntity classElement) {
if (classElement != null) {
registry.registerInstantiatedClass(classElement);
}
@@ -1641,7 +1650,7 @@
js.Expression object = pop();
String methodName;
List<js.Expression> arguments = visitArguments(node.inputs);
- MemberElement target = node.element;
+ MemberEntity target = node.element;
// TODO(herhut): The namer should return the appropriate backendname here.
if (target != null && !node.isInterceptedCall) {
@@ -1714,16 +1723,16 @@
// [node.element] will be enqueued. We're not using the receiver
// type because our optimizations might end up in a state where the
// invoke dynamic knows more than the receiver.
- ClassElement enclosing = node.element.enclosingClass;
+ ClassEntity enclosing = node.element.enclosingClass;
if (closedWorld.isInstantiated(enclosing)) {
- return new TypeMask.nonNullExact(enclosing.declaration, closedWorld);
+ return closedWorld.commonMasks.createNonNullExact(enclosing);
} else {
// The element is mixed in so a non-null subtype mask is the most
// precise we have.
assert(invariant(node, closedWorld.isUsedAsMixin(enclosing),
message: "Element ${node.element} from $enclosing expected "
"to be mixed in."));
- return new TypeMask.nonNullSubtype(enclosing.declaration, closedWorld);
+ return closedWorld.commonMasks.createNonNullSubtype(enclosing);
}
}
// If [JSInvocationMirror._invokeOn] is enabled, and this call
@@ -1737,7 +1746,7 @@
// If we don't know what we're calling or if we are calling a getter,
// we need to register that fact that we may be calling a closure
// with the same arguments.
- MemberElement target = node.element;
+ MemberEntity target = node.element;
if (target == null || target.isGetter) {
// TODO(kasperl): If we have a typed selector for the call, we
// may know something about the types of closures that need
@@ -1819,8 +1828,8 @@
}
visitInvokeStatic(HInvokeStatic node) {
- MemberElement element = node.element;
- List<DartType> instantiatedTypes = node.instantiatedTypes;
+ MemberEntity element = node.element;
+ List<ResolutionDartType> instantiatedTypes = node.instantiatedTypes;
if (instantiatedTypes != null && !instantiatedTypes.isEmpty) {
instantiatedTypes.forEach((type) {
@@ -1838,7 +1847,8 @@
// confuses loop recognition.
assert(arguments.length == 2);
- Element throwFunction = backend.helpers.throwConcurrentModificationError;
+ FunctionEntity throwFunction =
+ backend.helpers.throwConcurrentModificationError;
registry.registerStaticUse(
new StaticUse.staticInvoke(throwFunction, CallStructure.ONE_ARG));
@@ -1866,8 +1876,8 @@
}
visitInvokeSuper(HInvokeSuper node) {
- MemberElement superElement = node.element;
- ClassElement superClass = superElement.enclosingClass;
+ MemberEntity superElement = node.element;
+ ClassEntity superClass = superElement.enclosingClass;
if (superElement.isField) {
js.Name fieldName = backend.namer.instanceFieldPropertyName(superElement);
use(node.inputs[0]);
@@ -1892,9 +1902,9 @@
// If this is a tear-off, register the fact that a tear-off closure
// will be created, and that this tear-off must bypass ordinary
// dispatch to ensure the super method is invoked.
- FunctionElement helper = backend.helpers.closureFromTearOff;
+ FunctionEntity helper = backend.helpers.closureFromTearOff;
registry.registerStaticUse(new StaticUse.staticInvoke(
- helper, new CallStructure.unnamed(helper.parameters.length)));
+ helper, new CallStructure.unnamed(node.inputs.length)));
registry.registerStaticUse(new StaticUse.superTearOff(node.element));
methodName = backend.namer.invocationName(selector);
} else {
@@ -1924,7 +1934,7 @@
visitFieldGet(HFieldGet node) {
use(node.receiver);
- MemberElement element = node.element;
+ MemberEntity element = node.element;
if (node.isNullCheck) {
// We access a JavaScript member we know all objects besides
// null and undefined have: V8 does not like accessing a member
@@ -1938,15 +1948,16 @@
push(new js.PropertyAccess.field(pop(), 'length')
.withSourceInformation(node.sourceInformation));
} else {
- js.Name name = backend.namer.instanceFieldPropertyName(element);
+ FieldEntity field = element;
+ js.Name name = backend.namer.instanceFieldPropertyName(field);
push(new js.PropertyAccess(pop(), name)
.withSourceInformation(node.sourceInformation));
- registry.registerStaticUse(new StaticUse.fieldGet(element));
+ registry.registerStaticUse(new StaticUse.fieldGet(field));
}
}
visitFieldSet(HFieldSet node) {
- MemberElement element = node.element;
+ MemberEntity element = node.element;
registry.registerStaticUse(new StaticUse.fieldSet(element));
js.Name name = backend.namer.instanceFieldPropertyName(element);
use(node.receiver);
@@ -1957,7 +1968,7 @@
}
visitReadModifyWrite(HReadModifyWrite node) {
- FieldElement element = node.element;
+ FieldEntity element = node.element;
registry.registerStaticUse(new StaticUse.fieldGet(element));
registry.registerStaticUse(new StaticUse.fieldSet(element));
js.Name name = backend.namer.instanceFieldPropertyName(element);
@@ -2055,9 +2066,8 @@
// If the type is a web component, we need to ensure the constructors are
// available to 'upgrade' the native object.
TypeConstantValue type = constant;
- Element element = type.representedType.element;
- if (element != null && element.isClass) {
- registry.registerTypeConstant(element);
+ if (type.representedType.isInterfaceType) {
+ registry.registerTypeConstant(type.representedType.element);
}
}
js.Expression expression = backend.emitter.constantReference(constant);
@@ -2281,7 +2291,7 @@
}
}
- void generateThrowWithHelper(Element helper, argument,
+ void generateThrowWithHelper(FunctionEntity helper, argument,
{SourceInformation sourceInformation}) {
js.Expression jsHelper = backend.emitter.staticFunctionAccess(helper);
List arguments = [];
@@ -2305,7 +2315,7 @@
pushStatement(
new js.Throw(value).withSourceInformation(sourceInformation));
} else {
- Element element = work.element;
+ Entity element = work.element;
if (element is FunctionElement && element.asyncMarker.isYielding) {
// `return <expr>;` is illegal in a sync* or async* function.
// To have the async-translator working, we avoid introducing
@@ -2323,7 +2333,7 @@
HInstruction argument = node.inputs[0];
use(argument);
- Element helper = helpers.throwExpressionHelper;
+ FunctionEntity helper = helpers.throwExpressionHelper;
registry.registerStaticUse(
new StaticUse.staticInvoke(helper, CallStructure.ONE_ARG));
@@ -2397,7 +2407,8 @@
.withSourceInformation(node.sourceInformation));
}
} else {
- Element convertToString = backend.helpers.stringInterpolationHelper;
+ FunctionEntity convertToString =
+ backend.helpers.stringInterpolationHelper;
registry.registerStaticUse(
new StaticUse.staticInvoke(convertToString, CallStructure.ONE_ARG));
js.Expression jsHelper =
@@ -2553,41 +2564,44 @@
push(new js.Binary('!=', pop(), new js.LiteralNull()));
}
- void checkType(HInstruction input, HInstruction interceptor, DartType type,
- SourceInformation sourceInformation,
+ void checkType(HInstruction input, HInstruction interceptor,
+ ResolutionDartType type, SourceInformation sourceInformation,
{bool negative: false}) {
- Element element = type.element;
- if (element == helpers.jsArrayClass) {
- checkArray(input, negative ? '!==' : '===');
- return;
- } else if (element == helpers.jsMutableArrayClass) {
- if (negative) {
- checkImmutableArray(input);
- } else {
- checkMutableArray(input);
+ if (type.isInterfaceType) {
+ ResolutionInterfaceType interfaceType = type;
+ ClassEntity element = interfaceType.element;
+ if (element == helpers.jsArrayClass) {
+ checkArray(input, negative ? '!==' : '===');
+ return;
+ } else if (element == helpers.jsMutableArrayClass) {
+ if (negative) {
+ checkImmutableArray(input);
+ } else {
+ checkMutableArray(input);
+ }
+ return;
+ } else if (element == helpers.jsExtendableArrayClass) {
+ if (negative) {
+ checkFixedArray(input);
+ } else {
+ checkExtendableArray(input);
+ }
+ return;
+ } else if (element == helpers.jsFixedArrayClass) {
+ if (negative) {
+ checkExtendableArray(input);
+ } else {
+ checkFixedArray(input);
+ }
+ return;
+ } else if (element == helpers.jsUnmodifiableArrayClass) {
+ if (negative) {
+ checkMutableArray(input);
+ } else {
+ checkImmutableArray(input);
+ }
+ return;
}
- return;
- } else if (element == helpers.jsExtendableArrayClass) {
- if (negative) {
- checkFixedArray(input);
- } else {
- checkExtendableArray(input);
- }
- return;
- } else if (element == helpers.jsFixedArrayClass) {
- if (negative) {
- checkExtendableArray(input);
- } else {
- checkFixedArray(input);
- }
- return;
- } else if (element == helpers.jsUnmodifiableArrayClass) {
- if (negative) {
- checkMutableArray(input);
- } else {
- checkImmutableArray(input);
- }
- return;
}
if (interceptor != null) {
checkTypeViaProperty(interceptor, type, sourceInformation,
@@ -2597,8 +2611,8 @@
}
}
- void checkTypeViaProperty(
- HInstruction input, DartType type, SourceInformation sourceInformation,
+ void checkTypeViaProperty(HInstruction input, ResolutionDartType type,
+ SourceInformation sourceInformation,
{bool negative: false}) {
registry.registerTypeUse(new TypeUse.isCheck(type));
@@ -2615,8 +2629,8 @@
}
}
- void checkTypeViaInstanceof(
- HInstruction input, DartType type, SourceInformation sourceInformation,
+ void checkTypeViaInstanceof(HInstruction input, ResolutionDartType type,
+ SourceInformation sourceInformation,
{bool negative: false}) {
registry.registerTypeUse(new TypeUse.isCheck(type));
@@ -2635,12 +2649,12 @@
void handleNumberOrStringSupertypeCheck(
HInstruction input,
HInstruction interceptor,
- DartType type,
+ ResolutionDartType type,
SourceInformation sourceInformation,
{bool negative: false}) {
assert(!identical(type.element, commonElements.listClass) &&
- !Elements.isListSupertype(type.element, commonElements) &&
- !Elements.isStringOnlySupertype(type.element, commonElements));
+ !commonElements.isListSupertype(type.element) &&
+ !commonElements.isStringOnlySupertype(type.element));
String relation = negative ? '!==' : '===';
checkNum(input, relation, sourceInformation);
js.Expression numberTest = pop();
@@ -2661,11 +2675,11 @@
}
void handleStringSupertypeCheck(HInstruction input, HInstruction interceptor,
- DartType type, SourceInformation sourceInformation,
+ ResolutionDartType type, SourceInformation sourceInformation,
{bool negative: false}) {
assert(!identical(type.element, commonElements.listClass) &&
- !Elements.isListSupertype(type.element, commonElements) &&
- !Elements.isNumberOrStringSupertype(type.element, commonElements));
+ !commonElements.isListSupertype(type.element) &&
+ !commonElements.isNumberOrStringSupertype(type.element));
String relation = negative ? '!==' : '===';
checkString(input, relation, sourceInformation);
js.Expression stringTest = pop();
@@ -2678,11 +2692,11 @@
}
void handleListOrSupertypeCheck(HInstruction input, HInstruction interceptor,
- DartType type, SourceInformation sourceInformation,
+ ResolutionDartType type, SourceInformation sourceInformation,
{bool negative: false}) {
assert(!identical(type.element, commonElements.stringClass) &&
- !Elements.isStringOnlySupertype(type.element, commonElements) &&
- !Elements.isNumberOrStringSupertype(type.element, commonElements));
+ !commonElements.isStringOnlySupertype(type.element) &&
+ !commonElements.isNumberOrStringSupertype(type.element));
String relation = negative ? '!==' : '===';
checkObject(input, relation, sourceInformation);
js.Expression objectTest = pop();
@@ -2704,7 +2718,7 @@
}
void emitIs(HIs node, String relation, SourceInformation sourceInformation) {
- DartType type = node.typeExpression;
+ ResolutionDartType type = node.typeExpression;
registry.registerTypeUse(new TypeUse.isCheck(type));
HInstruction input = node.expression;
@@ -2719,15 +2733,16 @@
} else {
assert(node.isRawCheck);
HInstruction interceptor = node.interceptor;
- ClassElement objectClass = commonElements.objectClass;
- Element element = type.element;
+ ResolutionInterfaceType interfaceType = type;
+ ClassEntity element = interfaceType.element;
if (element == commonElements.nullClass) {
if (negative) {
checkNonNull(input);
} else {
checkNull(input);
}
- } else if (identical(element, objectClass) || type.treatAsDynamic) {
+ } else if (element ==
+ commonElements.objectClass /* || type.treatAsDynamic*/) {
// The constant folder also does this optimization, but we make
// it safe by assuming it may have not run.
push(newLiteralBool(!negative, sourceInformation));
@@ -2752,15 +2767,15 @@
assert(interceptor == null);
checkTypeViaInstanceof(input, type, sourceInformation,
negative: negative);
- } else if (Elements.isNumberOrStringSupertype(element, commonElements)) {
+ } else if (commonElements.isNumberOrStringSupertype(element)) {
handleNumberOrStringSupertypeCheck(
input, interceptor, type, sourceInformation,
negative: negative);
- } else if (Elements.isStringOnlySupertype(element, commonElements)) {
+ } else if (commonElements.isStringOnlySupertype(element)) {
handleStringSupertypeCheck(input, interceptor, type, sourceInformation,
negative: negative);
- } else if (identical(element, commonElements.listClass) ||
- Elements.isListSupertype(element, commonElements)) {
+ } else if (element == commonElements.listClass ||
+ commonElements.isListSupertype(element)) {
handleListOrSupertypeCheck(input, interceptor, type, sourceInformation,
negative: negative);
} else if (type.isFunctionType) {
@@ -2860,8 +2875,8 @@
}
assert(node.isCheckedModeCheck || node.isCastTypeCheck);
- DartType type = node.typeExpression;
- assert(type.kind != TypeKind.TYPEDEF);
+ ResolutionDartType type = node.typeExpression;
+ assert(!type.isTypedef);
if (type.isFunctionType) {
// TODO(5022): We currently generate $isFunction checks for
// function types.
@@ -2906,7 +2921,7 @@
}
void visitFunctionType(HFunctionType node) {
- FunctionType type = node.dartType;
+ ResolutionFunctionType type = node.dartType;
int inputCount = 0;
use(node.inputs[inputCount++]);
js.Expression returnType = pop();
@@ -2939,14 +2954,15 @@
if (!optionalParameterTypes.isEmpty) {
arguments.add(new js.ArrayInitializer(optionalParameterTypes));
}
- push(js.js('#(#)', [accessHelper('buildFunctionType'), arguments]));
+ push(js.js('#(#)', [accessHelper(helpers.buildFunctionType), arguments]));
} else {
var arguments = [
returnType,
new js.ArrayInitializer(parameterTypes),
new js.ObjectInitializer(namedParameters)
];
- push(js.js('#(#)', [accessHelper('buildNamedFunctionType'), arguments]));
+ push(js.js(
+ '#(#)', [accessHelper(helpers.buildNamedFunctionType), arguments]));
}
}
@@ -2957,7 +2973,7 @@
}
void visitTypeInfoReadVariable(HTypeInfoReadVariable node) {
- TypeVariableElement element = node.variable.element;
+ TypeVariableEntity element = node.variable.element;
int index = element.index;
HInstruction object = node.object;
@@ -2966,8 +2982,8 @@
if (typeVariableAccessNeedsSubstitution(element, object.instructionType)) {
js.Expression typeName =
- js.quoteName(backend.namer.runtimeTypeName(element.enclosingClass));
- Element helperElement = helpers.getRuntimeTypeArgument;
+ js.quoteName(backend.namer.runtimeTypeName(element.typeDeclaration));
+ FunctionEntity helperElement = helpers.getRuntimeTypeArgument;
registry.registerStaticUse(
new StaticUse.staticInvoke(helperElement, CallStructure.THREE_ARGS));
js.Expression helper =
@@ -2975,7 +2991,7 @@
push(js.js(
r'#(#, #, #)', [helper, receiver, typeName, js.js.number(index)]));
} else {
- Element helperElement = helpers.getTypeArgumentByIndex;
+ FunctionEntity helperElement = helpers.getTypeArgumentByIndex;
registry.registerStaticUse(
new StaticUse.staticInvoke(helperElement, CallStructure.TWO_ARGS));
js.Expression helper =
@@ -2995,15 +3011,16 @@
case TypeInfoExpressionKind.COMPLETE:
int index = 0;
js.Expression result = backend.rtiEncoder.getTypeRepresentation(
- node.dartType, (TypeVariableType variable) => arguments[index++]);
+ node.dartType,
+ (ResolutionTypeVariableType variable) => arguments[index++]);
assert(index == node.inputs.length);
push(result);
return;
case TypeInfoExpressionKind.INSTANCE:
// We expect only flat types for the INSTANCE representation.
- assert(
- node.dartType == (node.dartType.element as ClassElement).thisType);
+ assert(node.dartType ==
+ (node.dartType as ResolutionInterfaceType).element.thisType);
registry.registerInstantiatedClass(commonElements.listClass);
push(new js.ArrayInitializer(arguments)
.withSourceInformation(node.sourceInformation));
@@ -3011,14 +3028,14 @@
}
bool typeVariableAccessNeedsSubstitution(
- TypeVariableElement element, TypeMask receiverMask) {
- ClassElement cls = element.enclosingClass;
+ TypeVariableEntity element, TypeMask receiverMask) {
+ ClassEntity cls = element.typeDeclaration;
// See if the receiver type narrows the set of classes to ones that can be
// indexed.
// TODO(sra): Currently the only convenient query is [singleClass]. We
// should iterate over all the concrete classes in [receiverMask].
- ClassElement receiverClass = receiverMask.singleClass(closedWorld);
+ ClassEntity receiverClass = receiverMask.singleClass(closedWorld);
if (receiverClass != null) {
if (backend.rti.isTrivialSubstitution(receiverClass, cls)) {
return false;
@@ -3027,20 +3044,20 @@
if (closedWorld.isUsedAsMixin(cls)) return true;
- return closedWorld.anyStrictSubclassOf(cls, (ClassElement subclass) {
+ return closedWorld.anyStrictSubclassOf(cls, (ClassEntity subclass) {
return !backend.rti.isTrivialSubstitution(subclass, cls);
});
}
void visitReadTypeVariable(HReadTypeVariable node) {
- TypeVariableElement element = node.dartType.element;
- Element helperElement = helpers.convertRtiToRuntimeType;
+ TypeVariableEntity element = node.dartType.element;
+ FunctionEntity helperElement = helpers.convertRtiToRuntimeType;
registry.registerStaticUse(
new StaticUse.staticInvoke(helperElement, CallStructure.ONE_ARG));
use(node.inputs[0]);
if (node.hasReceiver) {
- if (backend.isInterceptorClass(element.enclosingClass)) {
+ if (backend.isInterceptorClass(element.typeDeclaration)) {
int index = element.index;
js.Expression receiver = pop();
js.Expression helper =
@@ -3071,29 +3088,31 @@
use(type);
typeArguments.add(pop());
}
-
- ClassElement cls = node.dartType.element;
+ ResolutionInterfaceType type = node.dartType;
+ ClassEntity cls = type.element;
var arguments = [backend.emitter.typeAccess(cls)];
if (!typeArguments.isEmpty) {
arguments.add(new js.ArrayInitializer(typeArguments));
}
- push(js.js('#(#)',
- [accessHelper('buildInterfaceType', arguments.length), arguments]));
+ push(js.js('#(#)', [
+ accessHelper(helpers.buildInterfaceType, arguments.length),
+ arguments
+ ]));
}
void visitVoidType(HVoidType node) {
- push(js.js('#()', accessHelper('getVoidRuntimeType')));
+ push(js.js('#()', accessHelper(helpers.getVoidRuntimeType)));
}
void visitDynamicType(HDynamicType node) {
- push(js.js('#()', accessHelper('getDynamicRuntimeType')));
+ push(js.js('#()', accessHelper(helpers.getDynamicRuntimeType)));
}
- js.PropertyAccess accessHelper(String name, [int argumentCount = 0]) {
- Element helper = helpers.findHelper(name);
+ js.PropertyAccess accessHelper(FunctionEntity helper,
+ [int argumentCount = 0]) {
if (helper == null) {
// For mocked-up tests.
- return js.js('(void 0).$name');
+ return js.js('(void 0).dummy');
}
registry.registerStaticUse(new StaticUse.staticInvoke(
helper, new CallStructure.unnamed(argumentCount)));
diff --git a/pkg/compiler/lib/src/ssa/codegen_helpers.dart b/pkg/compiler/lib/src/ssa/codegen_helpers.dart
index 75109a9..9773af6 100644
--- a/pkg/compiler/lib/src/ssa/codegen_helpers.dart
+++ b/pkg/compiler/lib/src/ssa/codegen_helpers.dart
@@ -168,7 +168,7 @@
if (candidate is HFieldGet) {
if (candidate.element != setter.element) return false;
if (candidate.receiver != setter.receiver) return false;
- // Recognize only three instructions in sequence in the same block. This
+ // Recognize only three instructions in sequence in the same block. This
// could be broadened to allow non-interfering interleaved instructions.
if (op.block != block) return false;
if (candidate.block != block) return false;
diff --git a/pkg/compiler/lib/src/ssa/graph_builder.dart b/pkg/compiler/lib/src/ssa/graph_builder.dart
index d659977..93700c8 100644
--- a/pkg/compiler/lib/src/ssa/graph_builder.dart
+++ b/pkg/compiler/lib/src/ssa/graph_builder.dart
@@ -7,7 +7,7 @@
import '../common/codegen.dart' show CodegenRegistry;
import '../compiler.dart';
import '../constants/constant_system.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../io/source_information.dart';
import '../js_backend/js_backend.dart';
@@ -201,13 +201,13 @@
return new HSubExpressionBlockInformation(expression);
}
- HInstruction buildFunctionType(FunctionType type) {
+ HInstruction buildFunctionType(ResolutionFunctionType type) {
type.accept(new ReifiedTypeRepresentationBuilder(closedWorld), this);
return pop();
}
HInstruction buildFunctionTypeConversion(
- HInstruction original, DartType type, int kind);
+ HInstruction original, ResolutionDartType type, int kind);
/// Returns the current source element.
///
@@ -222,8 +222,8 @@
localsHandler.directLocals[local] != null;
}
- HInstruction callSetRuntimeTypeInfoWithTypeArguments(
- DartType type, List<HInstruction> rtiInputs, HInstruction newObject) {
+ HInstruction callSetRuntimeTypeInfoWithTypeArguments(ResolutionDartType type,
+ List<HInstruction> rtiInputs, HInstruction newObject) {
if (!backend.classNeedsRti(type.element)) {
return newObject;
}
@@ -251,14 +251,16 @@
ReifiedTypeRepresentationBuilder(this.closedWorld);
- void visit(DartType type, GraphBuilder builder) => type.accept(this, builder);
+ void visit(ResolutionDartType type, GraphBuilder builder) =>
+ type.accept(this, builder);
- void visitVoidType(VoidType type, GraphBuilder builder) {
+ void visitVoidType(ResolutionVoidType type, GraphBuilder builder) {
ClassElement cls = builder.backend.helpers.VoidRuntimeType;
builder.push(new HVoidType(type, new TypeMask.exact(cls, closedWorld)));
}
- void visitTypeVariableType(TypeVariableType type, GraphBuilder builder) {
+ void visitTypeVariableType(
+ ResolutionTypeVariableType type, GraphBuilder builder) {
ClassElement cls = builder.backend.helpers.RuntimeType;
TypeMask instructionType = new TypeMask.subclass(cls, closedWorld);
if (!builder.sourceElement.enclosingElement.isClosure &&
@@ -274,22 +276,22 @@
}
}
- void visitFunctionType(FunctionType type, GraphBuilder builder) {
+ void visitFunctionType(ResolutionFunctionType type, GraphBuilder builder) {
type.returnType.accept(this, builder);
HInstruction returnType = builder.pop();
List<HInstruction> inputs = <HInstruction>[returnType];
- for (DartType parameter in type.parameterTypes) {
+ for (ResolutionDartType parameter in type.parameterTypes) {
parameter.accept(this, builder);
inputs.add(builder.pop());
}
- for (DartType parameter in type.optionalParameterTypes) {
+ for (ResolutionDartType parameter in type.optionalParameterTypes) {
parameter.accept(this, builder);
inputs.add(builder.pop());
}
- List<DartType> namedParameterTypes = type.namedParameterTypes;
+ List<ResolutionDartType> namedParameterTypes = type.namedParameterTypes;
List<String> names = type.namedParameters;
for (int index = 0; index < names.length; index++) {
ast.DartString dartString = new ast.DartString.literal(names[index]);
@@ -305,12 +307,12 @@
}
void visitMalformedType(MalformedType type, GraphBuilder builder) {
- visitDynamicType(const DynamicType(), builder);
+ visitDynamicType(const ResolutionDynamicType(), builder);
}
- void visitInterfaceType(InterfaceType type, GraphBuilder builder) {
+ void visitInterfaceType(ResolutionInterfaceType type, GraphBuilder builder) {
List<HInstruction> inputs = <HInstruction>[];
- for (DartType typeArgument in type.typeArguments) {
+ for (ResolutionDartType typeArgument in type.typeArguments) {
typeArgument.accept(this, builder);
inputs.add(builder.pop());
}
@@ -324,13 +326,13 @@
new HInterfaceType(inputs, type, new TypeMask.exact(cls, closedWorld)));
}
- void visitTypedefType(TypedefType type, GraphBuilder builder) {
- DartType unaliased = type.unaliased;
- if (unaliased is TypedefType) throw 'unable to unalias $type';
+ void visitTypedefType(ResolutionTypedefType type, GraphBuilder builder) {
+ ResolutionDartType unaliased = type.unaliased;
+ if (unaliased is ResolutionTypedefType) throw 'unable to unalias $type';
unaliased.accept(this, builder);
}
- void visitDynamicType(DynamicType type, GraphBuilder builder) {
+ void visitDynamicType(ResolutionDynamicType type, GraphBuilder builder) {
JavaScriptBackend backend = builder.compiler.backend;
ClassElement cls = backend.helpers.DynamicRuntimeType;
builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld)));
diff --git a/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart b/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart
index 2d6a1a7..e015e67 100644
--- a/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart
+++ b/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart
@@ -175,7 +175,7 @@
// code is completely insensitive to the specific instance subclasses, we
// can use the non-leaf class directly.
ClassElement element = type.singleClass(closedWorld);
- if (element != null && backendClasses.isNative(element)) {
+ if (element != null && backendClasses.isNativeClass(element)) {
return element;
}
}
diff --git a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
index 0859c3c..e108ad5 100644
--- a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
+++ b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
@@ -10,7 +10,7 @@
import '../compiler.dart';
import '../constants/expressions.dart';
import '../constants/values.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart';
import '../js/js.dart' as js;
@@ -320,7 +320,7 @@
}
ConstantValue getConstantForType(ir.DartType irType) {
- DartType type = getDartType(irType);
+ ResolutionDartType type = getDartType(irType);
return _backend.constantSystem.createType(_compiler, type.asRaw());
}
@@ -484,22 +484,22 @@
return null;
}
- DartType getDartType(ir.DartType type) {
+ ResolutionDartType getDartType(ir.DartType type) {
return type.accept(_typeConverter);
}
- List<DartType> getDartTypes(List<ir.DartType> types) {
+ List<ResolutionDartType> getDartTypes(List<ir.DartType> types) {
return types.map(getDartType).toList();
}
- DartType getDartTypeOfListLiteral(ir.ListLiteral list) {
+ ResolutionDartType getDartTypeOfListLiteral(ir.ListLiteral list) {
ast.Node node = getNodeOrNull(list);
if (node != null) return elements.getType(node);
assertNodeIsSynthetic(list);
return _compiler.commonElements.listType(getDartType(list.typeArgument));
}
- DartType getDartTypeOfMapLiteral(ir.MapLiteral literal) {
+ ResolutionDartType getDartTypeOfMapLiteral(ir.MapLiteral literal) {
ast.Node node = getNodeOrNull(literal);
if (node != null) return elements.getType(node);
assertNodeIsSynthetic(literal);
@@ -507,15 +507,15 @@
.mapType(getDartType(literal.keyType), getDartType(literal.valueType));
}
- DartType getFunctionReturnType(ir.FunctionNode node) {
+ ResolutionDartType getFunctionReturnType(ir.FunctionNode node) {
return getDartType(node.returnType);
}
/// Computes the function type corresponding the signature of [node].
- FunctionType getFunctionType(ir.FunctionNode node) {
- DartType returnType = getFunctionReturnType(node);
- List<DartType> parameterTypes = <DartType>[];
- List<DartType> optionalParameterTypes = <DartType>[];
+ ResolutionFunctionType getFunctionType(ir.FunctionNode node) {
+ ResolutionDartType returnType = getFunctionReturnType(node);
+ List<ResolutionDartType> parameterTypes = <ResolutionDartType>[];
+ List<ResolutionDartType> optionalParameterTypes = <ResolutionDartType>[];
for (ir.VariableDeclaration variable in node.positionalParameters) {
if (parameterTypes.length == node.requiredParameterCount) {
optionalParameterTypes.add(getDartType(variable.type));
@@ -524,14 +524,14 @@
}
}
List<String> namedParameters = <String>[];
- List<DartType> namedParameterTypes = <DartType>[];
+ List<ResolutionDartType> namedParameterTypes = <ResolutionDartType>[];
List<ir.VariableDeclaration> sortedNamedParameters =
node.namedParameters.toList()..sort((a, b) => a.name.compareTo(b.name));
for (ir.VariableDeclaration variable in sortedNamedParameters) {
namedParameters.add(variable.name);
namedParameterTypes.add(getDartType(variable.type));
}
- return new FunctionType.synthesized(returnType, parameterTypes,
+ return new ResolutionFunctionType.synthesized(returnType, parameterTypes,
optionalParameterTypes, namedParameters, namedParameterTypes);
}
@@ -572,12 +572,12 @@
}
/// Looks up [typeName] for use in the spec-string of a `JS` called.
- // TODO(johnniwinther): Use this in [native.NativeBehavior] instead of calling the
- // `ForeignResolver`.
+ // TODO(johnniwinther): Use this in [native.NativeBehavior] instead of calling
+ // the `ForeignResolver`.
// TODO(johnniwinther): Cache the result to avoid redundant lookups?
native.TypeLookup _typeLookup({bool resolveAsRaw: true}) {
return (String typeName) {
- DartType findIn(Uri uri) {
+ ResolutionDartType findIn(Uri uri) {
LibraryElement library = _compiler.libraryLoader.lookupLibrary(uri);
if (library != null) {
Element element = library.find(typeName);
@@ -590,7 +590,7 @@
return null;
}
- DartType type = findIn(Uris.dart_core);
+ ResolutionDartType type = findIn(Uris.dart_core);
type ??= findIn(BackendHelpers.DART_JS_HELPER);
type ??= findIn(BackendHelpers.DART_INTERCEPTORS);
type ??= findIn(BackendHelpers.DART_ISOLATE_HELPER);
@@ -639,7 +639,8 @@
_compiler.commonElements);
}
- /// Computes the [native.NativeBehavior] for a call to the [JS_BUILTIN] function.
+ /// Computes the [native.NativeBehavior] for a call to the [JS_BUILTIN]
+ /// function.
// TODO(johnniwinther): Cache this for later use.
native.NativeBehavior getNativeBehaviorForJsBuiltinCall(
ir.StaticInvocation node) {
@@ -667,8 +668,8 @@
_compiler.commonElements);
}
- /// Computes the [native.NativeBehavior] for a call to the [JS_EMBEDDED_GLOBAL]
- /// function.
+ /// Computes the [native.NativeBehavior] for a call to the
+ /// [JS_EMBEDDED_GLOBAL] function.
// TODO(johnniwinther): Cache this for later use.
native.NativeBehavior getNativeBehaviorForJsEmbeddedGlobalCall(
ir.StaticInvocation node) {
@@ -720,7 +721,7 @@
/// Computes the native behavior for reading the native [field].
// TODO(johnniwinther): Cache this for later use.
native.NativeBehavior getNativeBehaviorForFieldLoad(ir.Field field) {
- DartType type = getDartType(field.type);
+ ResolutionDartType type = getDartType(field.type);
List<ConstantExpression> metadata = getMetadata(field.annotations);
return native.NativeBehavior.ofFieldLoad(CURRENT_ELEMENT_SPANNABLE, type,
metadata, _typeLookup(resolveAsRaw: false), _compiler,
@@ -730,14 +731,14 @@
/// Computes the native behavior for writing to the native [field].
// TODO(johnniwinther): Cache this for later use.
native.NativeBehavior getNativeBehaviorForFieldStore(ir.Field field) {
- DartType type = getDartType(field.type);
+ ResolutionDartType type = getDartType(field.type);
return native.NativeBehavior.ofFieldStore(type, _compiler.resolution);
}
/// Computes the native behavior for calling [procedure].
// TODO(johnniwinther): Cache this for later use.
native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure) {
- DartType type = getFunctionType(procedure.function);
+ ResolutionDartType type = getFunctionType(procedure.function);
List<ConstantExpression> metadata = getMetadata(procedure.annotations);
return native.NativeBehavior.ofMethod(CURRENT_ELEMENT_SPANNABLE, type,
metadata, _typeLookup(resolveAsRaw: false), _compiler,
@@ -754,21 +755,21 @@
NONE,
}
-/// Visitor that converts kernel dart types into [DartType].
-class DartTypeConverter extends ir.DartTypeVisitor<DartType> {
+/// Visitor that converts kernel dart types into [ResolutionDartType].
+class DartTypeConverter extends ir.DartTypeVisitor<ResolutionDartType> {
final KernelAstAdapter astAdapter;
DartTypeConverter(this.astAdapter);
- DartType visitType(ir.DartType type) => type.accept(this);
+ ResolutionDartType visitType(ir.DartType type) => type.accept(this);
- List<DartType> visitTypes(List<ir.DartType> types) {
+ List<ResolutionDartType> visitTypes(List<ir.DartType> types) {
return new List.generate(
types.length, (int index) => types[index].accept(this));
}
@override
- DartType visitTypeParameterType(ir.TypeParameterType node) {
+ ResolutionDartType visitTypeParameterType(ir.TypeParameterType node) {
if (node.parameter.parent is ir.Class) {
ir.Class cls = node.parameter.parent;
int index = cls.typeParameters.indexOf(node.parameter);
@@ -790,8 +791,8 @@
}
@override
- DartType visitFunctionType(ir.FunctionType node) {
- return new FunctionType.synthesized(
+ ResolutionDartType visitFunctionType(ir.FunctionType node) {
+ return new ResolutionFunctionType.synthesized(
visitType(node.returnType),
visitTypes(node.positionalParameters
.take(node.requiredParameterCount)
@@ -804,23 +805,23 @@
}
@override
- DartType visitInterfaceType(ir.InterfaceType node) {
+ ResolutionDartType visitInterfaceType(ir.InterfaceType node) {
ClassElement cls = astAdapter.getElement(node.classNode);
- return new InterfaceType(cls, visitTypes(node.typeArguments));
+ return new ResolutionInterfaceType(cls, visitTypes(node.typeArguments));
}
@override
- DartType visitVoidType(ir.VoidType node) {
- return const VoidType();
+ ResolutionDartType visitVoidType(ir.VoidType node) {
+ return const ResolutionVoidType();
}
@override
- DartType visitDynamicType(ir.DynamicType node) {
- return const DynamicType();
+ ResolutionDartType visitDynamicType(ir.DynamicType node) {
+ return const ResolutionDynamicType();
}
@override
- DartType visitInvalidType(ir.InvalidType node) {
+ ResolutionDartType visitInvalidType(ir.InvalidType node) {
throw new UnimplementedError("Invalid types not currently supported");
}
}
@@ -854,7 +855,7 @@
ConstantExpression visitConstructorInvocation(ir.ConstructorInvocation node) {
ConstructorElement constructor =
astAdapter.getElement(node.target).declaration;
- List<DartType> typeArguments = <DartType>[];
+ List<ResolutionDartType> typeArguments = <ResolutionDartType>[];
for (ir.DartType type in node.arguments.types) {
typeArguments.add(astAdapter.getDartType(type));
}
diff --git a/pkg/compiler/lib/src/ssa/kernel_impact.dart b/pkg/compiler/lib/src/ssa/kernel_impact.dart
index 4476850..740d723 100644
--- a/pkg/compiler/lib/src/ssa/kernel_impact.dart
+++ b/pkg/compiler/lib/src/ssa/kernel_impact.dart
@@ -8,7 +8,7 @@
import '../common/names.dart';
import '../compiler.dart';
import '../constants/expressions.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../js_backend/backend.dart' show JavaScriptBackend;
import '../kernel/kernel.dart';
@@ -78,8 +78,8 @@
}
/// Add a checked-mode type use of [type] if it is not `dynamic`.
- DartType checkType(ir.DartType irType) {
- DartType type = astAdapter.getDartType(irType);
+ ResolutionDartType checkType(ir.DartType irType) {
+ ResolutionDartType type = astAdapter.getDartType(irType);
if (!type.isDynamic) {
impactBuilder.registerTypeUse(new TypeUse.checkedModeCheck(type));
}
@@ -219,7 +219,7 @@
@override
void visitListLiteral(ir.ListLiteral literal) {
visitNodes(literal.expressions);
- DartType elementType = checkType(literal.typeArgument);
+ ResolutionDartType elementType = checkType(literal.typeArgument);
impactBuilder.registerListLiteral(new ListLiteralUse(
compiler.commonElements.listType(elementType),
@@ -230,8 +230,8 @@
@override
void visitMapLiteral(ir.MapLiteral literal) {
visitNodes(literal.entries);
- DartType keyType = checkType(literal.keyType);
- DartType valueType = checkType(literal.valueType);
+ ResolutionDartType keyType = checkType(literal.keyType);
+ ResolutionDartType valueType = checkType(literal.valueType);
impactBuilder.registerMapLiteral(new MapLiteralUse(
compiler.commonElements.mapType(keyType, valueType),
isConstant: literal.isConst,
@@ -258,14 +258,15 @@
_visitArguments(node.arguments);
Element element = astAdapter.getElement(target).declaration;
ClassElement cls = astAdapter.getElement(target.enclosingClass);
- List<DartType> typeArguments =
+ List<ResolutionDartType> typeArguments =
astAdapter.getDartTypes(node.arguments.types);
- InterfaceType type = new InterfaceType(cls, typeArguments);
+ ResolutionInterfaceType type =
+ new ResolutionInterfaceType(cls, typeArguments);
CallStructure callStructure = astAdapter.getCallStructure(node.arguments);
impactBuilder.registerStaticUse(isConst
? new StaticUse.constConstructorInvoke(element, callStructure, type)
: new StaticUse.typedConstructorInvoke(element, callStructure, type));
- if (typeArguments.any((DartType type) => !type.isDynamic)) {
+ if (typeArguments.any((ResolutionDartType type) => !type.isDynamic)) {
impactBuilder.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK);
}
}
diff --git a/pkg/compiler/lib/src/ssa/locals_handler.dart b/pkg/compiler/lib/src/ssa/locals_handler.dart
index 79d7372..77fe430 100644
--- a/pkg/compiler/lib/src/ssa/locals_handler.dart
+++ b/pkg/compiler/lib/src/ssa/locals_handler.dart
@@ -5,7 +5,7 @@
import '../closure.dart';
import '../common.dart';
import '../compiler.dart' show Compiler;
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../io/source_information.dart';
import '../js/js.dart' as js;
@@ -35,8 +35,8 @@
new Map<Local, CapturedVariable>();
final GraphBuilder builder;
ClosureClassMap closureData;
- Map<TypeVariableType, TypeVariableLocal> typeVariableLocals =
- new Map<TypeVariableType, TypeVariableLocal>();
+ Map<ResolutionTypeVariableType, TypeVariableLocal> typeVariableLocals =
+ new Map<ResolutionTypeVariableType, TypeVariableLocal>();
final ExecutableElement executableContext;
/// The class that defines the current type environment or null if no type
@@ -59,12 +59,12 @@
/// [instanceType] is not used if it contains type variables, since these
/// might not be in scope or from the current instance.
///
- final InterfaceType instanceType;
+ final ResolutionInterfaceType instanceType;
final Compiler _compiler;
LocalsHandler(this.builder, this.executableContext,
- InterfaceType instanceType, this._compiler)
+ ResolutionInterfaceType instanceType, this._compiler)
: this.instanceType =
instanceType == null || instanceType.containsTypeVariables
? null
@@ -79,7 +79,7 @@
/// Substituted type variables occurring in [type] into the context of
/// [contextClass].
- DartType substInContext(DartType type) {
+ ResolutionDartType substInContext(ResolutionDartType type) {
if (contextClass != null) {
ClassElement typeContext = Types.getClassContext(type);
if (typeContext != null) {
@@ -385,7 +385,7 @@
});
}
- Local getTypeVariableAsLocal(TypeVariableType type) {
+ Local getTypeVariableAsLocal(ResolutionTypeVariableType type) {
return typeVariableLocals.putIfAbsent(type, () {
return new TypeVariableLocal(type, executableContext);
});
@@ -640,8 +640,7 @@
Map<Element, TypeMask> cachedTypesOfCapturedVariables =
new Map<Element, TypeMask>();
- TypeMask getTypeOfCapturedVariable(Element element) {
- assert(element.isField);
+ TypeMask getTypeOfCapturedVariable(FieldElement element) {
return cachedTypesOfCapturedVariables.putIfAbsent(element, () {
return TypeMaskFactory.inferredTypeForElement(
element, _globalInferenceResults);
diff --git a/pkg/compiler/lib/src/ssa/nodes.dart b/pkg/compiler/lib/src/ssa/nodes.dart
index a711e41..429178e 100644
--- a/pkg/compiler/lib/src/ssa/nodes.dart
+++ b/pkg/compiler/lib/src/ssa/nodes.dart
@@ -8,13 +8,12 @@
import '../compiler.dart' show Compiler;
import '../constants/constant_system.dart';
import '../constants/values.dart';
-import '../dart_types.dart';
import '../elements/elements.dart'
show Entity, JumpTarget, LabelDefinition, Local;
import '../elements/entities.dart';
+import '../elements/types.dart';
import '../io/source_information.dart';
import '../js/js.dart' as js;
-import '../js_backend/backend_helpers.dart' show BackendHelpers;
import '../js_backend/js_backend.dart';
import '../native/native.dart' as native;
import '../tree/dartstring.dart' as ast;
@@ -1356,8 +1355,9 @@
} else if (kind == HTypeConversion.CHECKED_MODE_CHECK && !type.treatAsRaw) {
throw 'creating compound check to $type (this = ${this})';
} else {
- Entity cls = type.element;
- TypeMask subtype = new TypeMask.subtype(cls, closedWorld);
+ InterfaceType interfaceType = type;
+ TypeMask subtype =
+ new TypeMask.subtype(interfaceType.element, closedWorld);
return new HTypeConversion(type, kind, subtype, this);
}
}
@@ -2795,7 +2795,7 @@
: checkedType = type,
super(<HInstruction>[input], type) {
assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null);
- assert(typeExpression == null || typeExpression.kind != TypeKind.TYPEDEF);
+ assert(typeExpression == null || !typeExpression.isTypedef);
sourceElement = input.sourceElement;
}
@@ -2804,7 +2804,7 @@
: checkedType = type,
super(<HInstruction>[input, typeRepresentation], type),
receiverTypeCheckSelector = null {
- assert(typeExpression.kind != TypeKind.TYPEDEF);
+ assert(!typeExpression.isTypedef);
sourceElement = input.sourceElement;
}
@@ -3264,7 +3264,7 @@
bool typeEquals(HInstruction other) => other is HTypeInfoReadVariable;
bool dataEquals(HTypeInfoReadVariable other) {
- return variable.element == other.variable.element;
+ return variable == other.variable;
}
String toString() => 'HTypeInfoReadVariable($variable)';
@@ -3382,8 +3382,7 @@
bool typeEquals(HInstruction other) => other is HReadTypeVariable;
bool dataEquals(HReadTypeVariable other) {
- return dartType.element == other.dartType.element &&
- hasReceiver == other.hasReceiver;
+ return dartType == other.dartType && hasReceiver == other.hasReceiver;
}
}
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index 2c6cdb8..428bb41 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -9,8 +9,10 @@
import '../constants/constant_system.dart';
import '../constants/values.dart';
import '../core_types.dart' show CommonElements;
-import '../dart_types.dart';
-import '../elements/elements.dart';
+import '../elements/elements.dart'
+ show ClassElement, Entity, FieldElement, MethodElement;
+import '../elements/entities.dart';
+import '../elements/resolution_types.dart';
import '../js/js.dart' as js;
import '../js_backend/backend_helpers.dart' show BackendHelpers;
import '../js_backend/js_backend.dart';
@@ -342,7 +344,7 @@
ListConstantValue constant = constantInput.constant;
return graph.addConstantInt(constant.length, closedWorld);
}
- MemberElement element = helpers.jsIndexableLength;
+ MemberEntity element = helpers.jsIndexableLength;
bool isFixed = isFixedLength(actualReceiver.instructionType, closedWorld);
TypeMask actualType = node.instructionType;
TypeMask resultType = closedWorld.commonMasks.positiveIntType;
@@ -384,13 +386,13 @@
TypeMask mask = node.mask;
HInstruction input = node.inputs[1];
- bool applies(Element element) {
+ bool applies(MemberEntity element) {
return selector.applies(element) &&
(mask == null || mask.canHit(element, selector, closedWorld));
}
if (selector.isCall || selector.isOperator) {
- MethodElement target;
+ FunctionEntity target;
if (input.isExtendableArray(closedWorld)) {
if (applies(helpers.jsArrayRemoveLast)) {
target = helpers.jsArrayRemoveLast;
@@ -451,7 +453,7 @@
}
TypeMask receiverType = node.getDartReceiver(closedWorld).instructionType;
- Element element =
+ MemberEntity element =
closedWorld.locateSingleElement(node.selector, receiverType);
// TODO(ngeoffray): Also fold if it's a getter or variable.
if (element != null &&
@@ -468,9 +470,12 @@
} else {
// TODO(ngeoffray): If the method has optional parameters,
// we should pass the default values.
- FunctionSignature parameters = method.functionSignature;
- if (parameters.optionalParameterCount == 0 ||
- parameters.parameterCount == node.selector.argumentCount) {
+ ResolutionFunctionType type = method.type;
+ int optionalParameterCount =
+ type.optionalParameterTypes.length + type.namedParameters.length;
+ if (optionalParameterCount == 0 ||
+ type.parameterTypes.length + optionalParameterCount ==
+ node.selector.argumentCount) {
node.element = method;
}
}
@@ -484,11 +489,11 @@
if (element != null &&
element.isField &&
element.name == node.selector.name) {
- FieldElement field = element;
+ FieldEntity field = element;
if (!backend.isNative(field) && !node.isCallOnInterceptor(closedWorld)) {
HInstruction receiver = node.getDartReceiver(closedWorld);
TypeMask type = TypeMaskFactory.inferredTypeForElement(
- field, globalInferenceResults);
+ field as Entity, globalInferenceResults);
HInstruction load = new HFieldGet(field, receiver, type);
node.block.addBefore(node, load);
Selector callSelector = new Selector.callClosureFrom(node.selector);
@@ -523,8 +528,8 @@
// foo() native 'return something';
// They should not be used.
- FunctionSignature signature = method.functionSignature;
- if (signature.optionalParametersAreNamed) return null;
+ ResolutionFunctionType type = method.type;
+ if (type.namedParameters.isNotEmpty) return null;
// Return types on native methods don't need to be checked, since the
// declaration has to be truthful.
@@ -533,23 +538,27 @@
// preserve the number of arguments, so check only the actual arguments.
List<HInstruction> inputs = node.inputs.sublist(1);
- int inputPosition = 1; // Skip receiver.
bool canInline = true;
- signature.forEachParameter((ParameterElement element) {
- if (inputPosition++ < inputs.length && canInline) {
- DartType type = element.type.unaliased;
- if (type is FunctionType) {
- canInline = false;
- }
- if (compiler.options.enableTypeAssertions) {
- // TODO(sra): Check if [input] is guaranteed to pass the parameter
- // type check. Consider using a strengthened type check to avoid
- // passing `null` to primitive types since the native methods usually
- // have non-nullable primitive parameter types.
- canInline = false;
+ if (compiler.options.enableTypeAssertions && inputs.length > 1) {
+ // TODO(sra): Check if [input] is guaranteed to pass the parameter
+ // type check. Consider using a strengthened type check to avoid
+ // passing `null` to primitive types since the native methods usually
+ // have non-nullable primitive parameter types.
+ canInline = false;
+ } else {
+ int inputPosition = 1; // Skip receiver.
+ void checkParameterType(ResolutionDartType type) {
+ if (inputPosition++ < inputs.length && canInline) {
+ if (type.unaliased.isFunctionType) {
+ canInline = false;
+ }
}
}
- });
+
+ type.parameterTypes.forEach(checkParameterType);
+ type.optionalParameterTypes.forEach(checkParameterType);
+ type.namedParameterTypes.forEach(checkParameterType);
+ }
if (!canInline) return null;
@@ -729,26 +738,26 @@
}
HInstruction visitIs(HIs node) {
- DartType type = node.typeExpression;
- Element element = type.element;
+ ResolutionDartType type = node.typeExpression;
if (!node.isRawCheck) {
return node;
} else if (type.isTypedef) {
return node;
- } else if (element == commonElements.functionClass) {
+ } else if (type.isFunctionType) {
return node;
}
if (type.isObject || type.treatAsDynamic) {
return graph.addConstantBool(true, closedWorld);
}
-
+ ResolutionInterfaceType interfaceType = type;
+ ClassEntity element = interfaceType.element;
HInstruction expression = node.expression;
if (expression.isInteger(closedWorld)) {
if (element == commonElements.intClass ||
element == commonElements.numClass ||
- Elements.isNumberOrStringSupertype(element, commonElements)) {
+ commonElements.isNumberOrStringSupertype(element)) {
return graph.addConstantBool(true, closedWorld);
} else if (element == commonElements.doubleClass) {
// We let the JS semantics decide for that check. Currently
@@ -760,7 +769,7 @@
} else if (expression.isDouble(closedWorld)) {
if (element == commonElements.doubleClass ||
element == commonElements.numClass ||
- Elements.isNumberOrStringSupertype(element, commonElements)) {
+ commonElements.isNumberOrStringSupertype(element)) {
return graph.addConstantBool(true, closedWorld);
} else if (element == commonElements.intClass) {
// We let the JS semantics decide for that check. Currently
@@ -801,7 +810,7 @@
}
HInstruction visitTypeConversion(HTypeConversion node) {
- DartType type = node.typeExpression;
+ ResolutionDartType type = node.typeExpression;
if (type != null) {
if (type.isMalformed) {
// Malformed types are treated as dynamic statically, but should
@@ -846,7 +855,7 @@
HInstruction removeCheck(HCheck node) => node.checkedInput;
- FieldElement findConcreteFieldForDynamicAccess(
+ FieldEntity findConcreteFieldForDynamicAccess(
HInstruction receiver, Selector selector) {
TypeMask receiverType = receiver.instructionType;
return closedWorld.locateSingleField(selector, receiverType);
@@ -891,7 +900,7 @@
ConstantValue constant = receiver.constant;
if (constant.isConstructedObject) {
ConstructedConstantValue constructedConstant = constant;
- Map<Element, ConstantValue> fields = constructedConstant.fields;
+ Map<FieldEntity, ConstantValue> fields = constructedConstant.fields;
ConstantValue value = fields[node.element];
if (value != null) {
return graph.addConstant(value, closedWorld);
@@ -922,12 +931,12 @@
if (folded != node) return folded;
}
HInstruction receiver = node.getDartReceiver(closedWorld);
- FieldElement field =
+ FieldEntity field =
findConcreteFieldForDynamicAccess(receiver, node.selector);
if (field != null) return directFieldGet(receiver, field);
if (node.element == null) {
- MemberElement element = closedWorld.locateSingleElement(
+ MemberEntity element = closedWorld.locateSingleElement(
node.selector, receiver.instructionType);
if (element != null && element.name == node.selector.name) {
node.element = element;
@@ -942,16 +951,16 @@
return node;
}
- HInstruction directFieldGet(HInstruction receiver, FieldElement field) {
- bool isAssignable = !closedWorld.fieldNeverChanges(field);
+ HInstruction directFieldGet(HInstruction receiver, FieldEntity field) {
+ bool isAssignable = !closedWorld.fieldNeverChanges(field as MemberEntity);
TypeMask type;
if (backend.isNative(field.enclosingClass)) {
type = TypeMaskFactory.fromNativeBehavior(
backend.getNativeFieldLoadBehavior(field), closedWorld);
} else {
- type =
- TypeMaskFactory.inferredTypeForElement(field, globalInferenceResults);
+ type = TypeMaskFactory.inferredTypeForElement(
+ field as Entity, globalInferenceResults);
}
return new HFieldGet(field, receiver, type, isAssignable: isAssignable);
@@ -971,7 +980,7 @@
// convention, but is not a call on an interceptor.
HInstruction value = node.inputs.last;
if (compiler.options.enableTypeAssertions) {
- DartType type = field.type;
+ ResolutionDartType type = field.type;
if (!type.treatAsRaw ||
type.isTypeVariable ||
type.unaliased.isFunctionType) {
@@ -993,7 +1002,7 @@
HInstruction visitInvokeStatic(HInvokeStatic node) {
propagateConstantValueToUses(node);
- MemberElement element = node.element;
+ MemberEntity element = node.element;
if (element == backend.helpers.checkConcurrentModificationError) {
if (node.inputs.length == 2) {
@@ -1124,10 +1133,10 @@
return handleInterceptedCall(node);
}
- bool needsSubstitutionForTypeVariableAccess(ClassElement cls) {
+ bool needsSubstitutionForTypeVariableAccess(ClassEntity cls) {
if (closedWorld.isUsedAsMixin(cls)) return true;
- return closedWorld.anyStrictSubclassOf(cls, (ClassElement subclass) {
+ return closedWorld.anyStrictSubclassOf(cls, (ClassEntity subclass) {
return !backend.rti.isTrivialSubstitution(subclass, cls);
});
}
@@ -1187,15 +1196,15 @@
}
HInstruction visitTypeInfoReadVariable(HTypeInfoReadVariable node) {
- TypeVariableType variable = node.variable;
+ ResolutionTypeVariableType variable = node.variable;
HInstruction object = node.object;
- HInstruction finishGroundType(InterfaceType groundType) {
- InterfaceType typeAtVariable =
+ HInstruction finishGroundType(ResolutionInterfaceType groundType) {
+ ResolutionInterfaceType typeAtVariable =
groundType.asInstanceOf(variable.element.enclosingClass);
if (typeAtVariable != null) {
int index = variable.element.index;
- DartType typeArgument = typeAtVariable.typeArguments[index];
+ ResolutionDartType typeArgument = typeAtVariable.typeArguments[index];
HInstruction replacement = new HTypeInfoExpression(
TypeInfoExpressionKind.COMPLETE,
typeArgument,
@@ -1211,15 +1220,15 @@
/// the allocation for factory constructor call.
HInstruction finishSubstituted(ClassElement createdClass,
HInstruction selectTypeArgumentFromObjectCreation(int index)) {
- HInstruction instructionForTypeVariable(TypeVariableType tv) {
+ HInstruction instructionForTypeVariable(ResolutionTypeVariableType tv) {
return selectTypeArgumentFromObjectCreation(
createdClass.thisType.typeArguments.indexOf(tv));
}
- DartType type = createdClass.thisType
+ ResolutionDartType type = createdClass.thisType
.asInstanceOf(variable.element.enclosingClass)
.typeArguments[variable.element.index];
- if (type is TypeVariableType) {
+ if (type is ResolutionTypeVariableType) {
return instructionForTypeVariable(type);
}
List<HInstruction> arguments = <HInstruction>[];
@@ -1365,7 +1374,7 @@
}
void visitInvokeDynamicMethod(HInvokeDynamicMethod node) {
- MemberElement element = node.element;
+ MemberEntity element = node.element;
if (node.isInterceptedCall) return;
if (element != helpers.jsArrayRemoveLast) return;
if (boundsChecked.contains(node)) return;
@@ -2128,13 +2137,14 @@
}
void visitIs(HIs instruction) {
- DartType type = instruction.typeExpression;
- Element element = type.element;
+ ResolutionDartType type = instruction.typeExpression;
if (!instruction.isRawCheck) {
return;
- } else if (element.isTypedef) {
+ } else if (type.isTypedef) {
return;
}
+ ResolutionInterfaceType interfaceType = type;
+ ClassEntity cls = interfaceType.element;
List<HBasicBlock> trueTargets = <HBasicBlock>[];
List<HBasicBlock> falseTargets = <HBasicBlock>[];
@@ -2143,7 +2153,7 @@
if (trueTargets.isEmpty && falseTargets.isEmpty) return;
- TypeMask convertedType = new TypeMask.nonNullSubtype(element, closedWorld);
+ TypeMask convertedType = new TypeMask.nonNullSubtype(cls, closedWorld);
HInstruction input = instruction.expression;
for (HBasicBlock block in trueTargets) {
@@ -2285,7 +2295,7 @@
void visitFieldGet(HFieldGet instruction) {
if (instruction.isNullCheck) return;
- MemberElement element = instruction.element;
+ MemberEntity element = instruction.element;
HInstruction receiver = instruction.getDartReceiver(closedWorld).nonCheck();
HInstruction existing = memorySet.lookupFieldValue(element, receiver);
if (existing != null) {
@@ -2306,11 +2316,12 @@
memorySet.registerAllocation(instruction);
if (shouldTrackInitialValues(instruction)) {
int argumentIndex = 0;
- instruction.element.forEachInstanceField((_, FieldElement member) {
- if (compiler.elementHasCompileTimeError(member)) return;
+ compiler.codegenWorld.forEachInstanceField(instruction.element,
+ (_, FieldEntity member) {
+ if (compiler.elementHasCompileTimeError(member as Entity)) return;
memorySet.registerFieldValue(
member, instruction, instruction.inputs[argumentIndex++]);
- }, includeSuperAndInjectedMembers: true);
+ });
}
// In case this instruction has as input non-escaping objects, we
// need to mark these objects as escaping.
@@ -2363,11 +2374,11 @@
}
void visitLazyStatic(HLazyStatic instruction) {
- FieldElement field = instruction.element;
+ FieldEntity field = instruction.element;
handleStaticLoad(field, instruction);
}
- void handleStaticLoad(MemberElement element, HInstruction instruction) {
+ void handleStaticLoad(MemberEntity element, HInstruction instruction) {
HInstruction existing = memorySet.lookupFieldValue(element, null);
if (existing != null) {
instruction.block.rewriteWithBetterUser(instruction, existing);
@@ -2442,8 +2453,8 @@
/**
* Maps a field to a map of receiver to value.
*/
- final Map<Element, Map<HInstruction, HInstruction>> fieldValues =
- <Element, Map<HInstruction, HInstruction>>{};
+ final Map<MemberEntity, Map<HInstruction, HInstruction>> fieldValues =
+ <MemberEntity, Map<HInstruction, HInstruction>>{};
/**
* Maps a receiver to a map of keys to value.
@@ -2479,7 +2490,7 @@
.isDisjoint(second.instructionType, closedWorld);
}
- bool isFinal(Element element) {
+ bool isFinal(MemberEntity element) {
return closedWorld.fieldNeverChanges(element);
}
@@ -2511,9 +2522,9 @@
* may be affected by this update.
*/
void registerFieldValueUpdate(
- MemberElement element, HInstruction receiver, HInstruction value) {
+ MemberEntity element, HInstruction receiver, HInstruction value) {
assert(receiver == null || receiver == receiver.nonCheck());
- if (closedWorld.backendClasses.isNative(element)) {
+ if (closedWorld.backendClasses.isNativeMember(element)) {
return; // TODO(14955): Remove this restriction?
}
// [value] is being set in some place in memory, we remove it from
@@ -2531,9 +2542,9 @@
* Registers that `receiver.element` is now [value].
*/
void registerFieldValue(
- MemberElement element, HInstruction receiver, HInstruction value) {
+ MemberEntity element, HInstruction receiver, HInstruction value) {
assert(receiver == null || receiver == receiver.nonCheck());
- if (closedWorld.backendClasses.isNative(element)) {
+ if (closedWorld.backendClasses.isNativeMember(element)) {
return; // TODO(14955): Remove this restriction?
}
Map<HInstruction, HInstruction> map =
@@ -2545,7 +2556,7 @@
* Returns the value stored in `receiver.element`. Returns `null` if we don't
* know.
*/
- HInstruction lookupFieldValue(Element element, HInstruction receiver) {
+ HInstruction lookupFieldValue(MemberEntity element, HInstruction receiver) {
assert(receiver == null || receiver == receiver.nonCheck());
Map<HInstruction, HInstruction> map = fieldValues[element];
return (map == null) ? null : map[receiver];
@@ -2566,7 +2577,7 @@
if (instruction.sideEffects.changesInstanceProperty() ||
instruction.sideEffects.changesStaticProperty()) {
- fieldValues.forEach((element, map) {
+ fieldValues.forEach((MemberEntity element, map) {
if (isFinal(element)) return;
map.forEach((receiver, value) {
if (escapes(receiver)) {
diff --git a/pkg/compiler/lib/src/ssa/type_builder.dart b/pkg/compiler/lib/src/ssa/type_builder.dart
index 48a7d98..03d0ad1 100644
--- a/pkg/compiler/lib/src/ssa/type_builder.dart
+++ b/pkg/compiler/lib/src/ssa/type_builder.dart
@@ -6,7 +6,7 @@
import 'nodes.dart';
import '../closure.dart';
import '../common.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../types/types.dart';
import '../elements/elements.dart';
import '../io/source_information.dart';
@@ -20,7 +20,7 @@
TypeBuilder(this.builder);
/// Create an instruction to simply trust the provided type.
- HInstruction _trustType(HInstruction original, DartType type) {
+ HInstruction _trustType(HInstruction original, ResolutionDartType type) {
assert(builder.compiler.options.trustTypeAnnotations);
assert(type != null);
type = builder.localsHandler.substInContext(type);
@@ -36,7 +36,8 @@
/// Produces code that checks the runtime type is actually the type specified
/// by attempting a type conversion.
- HInstruction _checkType(HInstruction original, DartType type, int kind) {
+ HInstruction _checkType(
+ HInstruction original, ResolutionDartType type, int kind) {
assert(builder.compiler.options.enableTypeAssertions);
assert(type != null);
type = builder.localsHandler.substInContext(type);
@@ -53,7 +54,8 @@
/// Depending on the context and the mode, wrap the given type in an
/// instruction that checks the type is what we expect or automatically
/// trusts the written type.
- HInstruction potentiallyCheckOrTrustType(HInstruction original, DartType type,
+ HInstruction potentiallyCheckOrTrustType(
+ HInstruction original, ResolutionDartType type,
{int kind: HTypeConversion.CHECKED_MODE_CHECK}) {
if (type == null) return original;
HInstruction checkedOrTrusted = original;
@@ -68,7 +70,8 @@
}
/// Helper to create an instruction that gets the value of a type variable.
- HInstruction addTypeVariableReference(TypeVariableType type, Element member,
+ HInstruction addTypeVariableReference(
+ ResolutionTypeVariableType type, Element member,
{SourceInformation sourceInformation}) {
assert(assertTypeInContext(type));
if (type is MethodTypeVariableType) {
@@ -128,7 +131,8 @@
}
/// Generate code to extract the type argument from the object.
- HInstruction readTypeVariable(TypeVariableType variable, Element member,
+ HInstruction readTypeVariable(
+ ResolutionTypeVariableType variable, Element member,
{SourceInformation sourceInformation}) {
assert(member.isInstanceMember);
assert(variable is! MethodTypeVariableType);
@@ -140,14 +144,14 @@
}
HInstruction buildTypeArgumentRepresentations(
- DartType type, Element sourceElement) {
+ ResolutionDartType type, Element sourceElement) {
assert(!type.isTypeVariable);
// Compute the representation of the type arguments, including access
// to the runtime type information for type variables as instructions.
assert(type.element.isClass);
- InterfaceType interface = type;
+ ResolutionInterfaceType interface = type;
List<HInstruction> inputs = <HInstruction>[];
- for (DartType argument in interface.typeArguments) {
+ for (ResolutionDartType argument in interface.typeArguments) {
inputs.add(analyzeTypeArgument(argument, sourceElement));
}
HInstruction representation = new HTypeInfoExpression(
@@ -160,7 +164,7 @@
/// Check that [type] is valid in the context of `localsHandler.contextClass`.
/// This should only be called in assertions.
- bool assertTypeInContext(DartType type, [Spannable spannable]) {
+ bool assertTypeInContext(ResolutionDartType type, [Spannable spannable]) {
return invariant(spannable == null ? CURRENT_ELEMENT_SPANNABLE : spannable,
() {
ClassElement contextClass = Types.getClassContext(type);
@@ -171,7 +175,8 @@
"${builder.localsHandler.contextClass}.");
}
- HInstruction analyzeTypeArgument(DartType argument, Element sourceElement,
+ HInstruction analyzeTypeArgument(
+ ResolutionDartType argument, Element sourceElement,
{SourceInformation sourceInformation}) {
assert(assertTypeInContext(argument));
argument = argument.unaliased;
@@ -221,7 +226,7 @@
/// Invariant: [type] must be valid in the context.
/// See [LocalsHandler.substInContext].
HInstruction buildTypeConversion(
- HInstruction original, DartType type, int kind) {
+ HInstruction original, ResolutionDartType type, int kind) {
if (type == null) return original;
// GENERIC_METHODS: The following statement was added for parsing and
// ignoring method type variables; must be generalized for full support of
diff --git a/pkg/compiler/lib/src/typechecker.dart b/pkg/compiler/lib/src/typechecker.dart
index 94a88bb..0660e3d 100644
--- a/pkg/compiler/lib/src/typechecker.dart
+++ b/pkg/compiler/lib/src/typechecker.dart
@@ -12,7 +12,7 @@
import 'constants/expressions.dart';
import 'constants/values.dart';
import 'core_types.dart';
-import 'dart_types.dart';
+import 'elements/resolution_types.dart';
import 'elements/elements.dart'
show
AbstractFieldElement,
@@ -64,7 +64,7 @@
compiler, resolvedAst.elements, compiler.types);
if (element.isField) {
visitor.analyzingInitializer = true;
- DartType type =
+ ResolutionDartType type =
visitor.analyzeVariableTypeAnnotation(resolvedAst.node);
visitor.analyzeVariableInitializer(element, type, resolvedAst.body);
} else {
@@ -100,7 +100,7 @@
String get name => element.name;
- DartType computeType(Resolution resolution);
+ ResolutionDartType computeType(Resolution resolution);
/// Returns [: true :] if the element can be access as an invocation.
bool isCallable(Compiler compiler) {
@@ -124,7 +124,7 @@
Element get element => member.declarations.first.element;
- DartType computeType(Resolution resolution) => member.type;
+ ResolutionDartType computeType(Resolution resolution) => member.type;
String toString() => 'MemberAccess($member)';
}
@@ -137,7 +137,8 @@
String get name => 'dynamic';
- DartType computeType(Resolution resolution) => const DynamicType();
+ ResolutionDartType computeType(Resolution resolution) =>
+ const ResolutionDynamicType();
bool isCallable(Compiler compiler) => true;
@@ -155,18 +156,18 @@
assert(element != null);
}
- DartType computeType(Resolution resolution) {
+ ResolutionDartType computeType(Resolution resolution) {
if (element.isGetter) {
GetterElement getter = element;
- FunctionType functionType = getter.computeType(resolution);
+ ResolutionFunctionType functionType = getter.computeType(resolution);
return functionType.returnType;
} else if (element.isSetter) {
SetterElement setter = element;
- FunctionType functionType = setter.computeType(resolution);
+ ResolutionFunctionType functionType = setter.computeType(resolution);
if (functionType.parameterTypes.length != 1) {
// TODO(johnniwinther,karlklose): this happens for malformed static
// setters. Treat them the same as instance members.
- return const DynamicType();
+ return const ResolutionDynamicType();
}
return functionType.parameterTypes.first;
} else if (element.isTypedef || element.isClass) {
@@ -186,14 +187,14 @@
/// An access to a promoted variable.
class PromotedAccess extends ElementAccess {
final VariableElement element;
- final DartType type;
+ final ResolutionDartType type;
- PromotedAccess(VariableElement this.element, DartType this.type) {
+ PromotedAccess(VariableElement this.element, ResolutionDartType this.type) {
assert(element != null);
assert(type != null);
}
- DartType computeType(Resolution resolution) => type;
+ ResolutionDartType computeType(Resolution resolution) => type;
String toString() => 'PromotedAccess($element,$type)';
}
@@ -203,14 +204,14 @@
* access of a resolved element through [:this:].
*/
class TypeAccess extends ElementAccess {
- final DartType type;
- TypeAccess(DartType this.type) {
+ final ResolutionDartType type;
+ TypeAccess(ResolutionDartType this.type) {
assert(type != null);
}
Element get element => type.element;
- DartType computeType(Resolution resolution) => type;
+ ResolutionDartType computeType(Resolution resolution) => type;
String toString() => 'TypeAccess($type)';
}
@@ -219,7 +220,7 @@
* An access of a type literal.
*/
class TypeLiteralAccess extends ElementAccess {
- final DartType type;
+ final ResolutionDartType type;
TypeLiteralAccess(this.type) {
assert(type != null);
@@ -229,7 +230,7 @@
String get name => type.name;
- DartType computeType(Resolution resolution) =>
+ ResolutionDartType computeType(Resolution resolution) =>
resolution.commonElements.typeType;
String toString() => 'TypeLiteralAccess($type)';
@@ -238,13 +239,13 @@
/// An access to the 'call' method of a function type.
class FunctionCallAccess implements ElementAccess {
final Element element;
- final DartType type;
+ final ResolutionDartType type;
const FunctionCallAccess(this.element, this.type);
String get name => 'call';
- DartType computeType(Resolution resolution) => type;
+ ResolutionDartType computeType(Resolution resolution) => type;
bool isCallable(Compiler compiler) => true;
@@ -255,7 +256,7 @@
class TypePromotion {
final Send node;
final VariableElement variable;
- final DartType type;
+ final ResolutionDartType type;
final List<TypePromotionMessage> messages = <TypePromotionMessage>[];
TypePromotion(this.node, this.variable, this.type);
@@ -284,13 +285,13 @@
TypePromotionMessage(this.hint, this.infos);
}
-class TypeCheckerVisitor extends Visitor<DartType> {
+class TypeCheckerVisitor extends Visitor<ResolutionDartType> {
final Compiler compiler;
final TreeElements elements;
final Types types;
Node lastSeenNode;
- DartType expectedReturnType;
+ ResolutionDartType expectedReturnType;
AsyncMarker currentAsyncMarker = AsyncMarker.SYNC;
final ClassElement currentClass;
@@ -304,15 +305,15 @@
Resolution get resolution => compiler.resolution;
- InterfaceType get intType => commonElements.intType;
- InterfaceType get doubleType => commonElements.doubleType;
- InterfaceType get boolType => commonElements.boolType;
- InterfaceType get stringType => commonElements.stringType;
+ ResolutionInterfaceType get intType => commonElements.intType;
+ ResolutionInterfaceType get doubleType => commonElements.doubleType;
+ ResolutionInterfaceType get boolType => commonElements.boolType;
+ ResolutionInterfaceType get stringType => commonElements.stringType;
- DartType thisType;
- DartType superType;
+ ResolutionDartType thisType;
+ ResolutionDartType superType;
- Link<DartType> cascadeTypes = const Link<DartType>();
+ Link<ResolutionDartType> cascadeTypes = const Link<ResolutionDartType>();
bool analyzingInitializer = false;
@@ -366,7 +367,7 @@
return null;
}
- DartType getKnownType(VariableElement element) {
+ ResolutionDartType getKnownType(VariableElement element) {
TypePromotion typePromotion = getKnownTypePromotion(element);
if (typePromotion != null) return typePromotion.type;
return element.type;
@@ -383,8 +384,8 @@
superType = currentClass.supertype;
} else {
// If these are used, an error should have been reported by the resolver.
- thisType = const DynamicType();
- superType = const DynamicType();
+ thisType = const ResolutionDynamicType();
+ superType = const ResolutionDynamicType();
}
}
@@ -414,23 +415,24 @@
}
// TODO(karlklose): remove these functions.
- DartType unhandledExpression() => const DynamicType();
+ ResolutionDartType unhandledExpression() => const ResolutionDynamicType();
- DartType analyzeNonVoid(Node node) {
- DartType type = analyze(node);
+ ResolutionDartType analyzeNonVoid(Node node) {
+ ResolutionDartType type = analyze(node);
if (type.isVoid) {
reportTypeWarning(node, MessageKind.VOID_EXPRESSION);
}
return type;
}
- DartType analyzeWithDefault(Node node, DartType defaultValue) {
+ ResolutionDartType analyzeWithDefault(
+ Node node, ResolutionDartType defaultValue) {
return node != null ? analyze(node) : defaultValue;
}
/// If [inInitializer] is true, assignment should be interpreted as write to
/// a field and not to a setter.
- DartType analyze(Node node,
+ ResolutionDartType analyze(Node node,
{bool inInitializer: false, bool mustHaveType: true}) {
if (node == null) {
final String error = 'Unexpected node: null';
@@ -444,7 +446,7 @@
}
bool previouslyInitializer = analyzingInitializer;
analyzingInitializer = inInitializer;
- DartType result = node.accept(this);
+ ResolutionDartType result = node.accept(this);
analyzingInitializer = previouslyInitializer;
if (result == null && mustHaveType) {
reporter.internalError(node, 'Type is null.');
@@ -537,7 +539,7 @@
}
/// Analyze [node] in the context of the known types shown in [context].
- DartType analyzeInPromotedContext(Node context, Node node,
+ ResolutionDartType analyzeInPromotedContext(Node context, Node node,
{bool mustHaveType: true}) {
Link<TypePromotion> knownForNode = const Link<TypePromotion>();
for (TypePromotion typePromotion in getShownTypePromotionsFor(context)) {
@@ -547,7 +549,7 @@
registerKnownTypePromotion(typePromotion);
}
- final DartType type = analyze(node, mustHaveType: mustHaveType);
+ final ResolutionDartType type = analyze(node, mustHaveType: mustHaveType);
while (!knownForNode.isEmpty) {
unregisterKnownTypePromotion(knownForNode.head);
@@ -562,7 +564,8 @@
* return value of type [to]. If `isConst == true`, an error is emitted in
* checked mode, otherwise a warning is issued.
*/
- bool checkAssignable(Spannable spannable, DartType from, DartType to,
+ bool checkAssignable(
+ Spannable spannable, ResolutionDartType from, ResolutionDartType to,
{bool isConst: false}) {
if (!types.isAssignable(from, to)) {
if (compiler.options.enableTypeAssertions && isConst) {
@@ -581,12 +584,12 @@
checkAssignable(condition, analyze(condition), boolType);
}
- void pushCascadeType(DartType type) {
+ void pushCascadeType(ResolutionDartType type) {
cascadeTypes = cascadeTypes.prepend(type);
}
- DartType popCascadeType() {
- DartType type = cascadeTypes.head;
+ ResolutionDartType popCascadeType() {
+ ResolutionDartType type = cascadeTypes.head;
cascadeTypes = cascadeTypes.tail;
return type;
}
@@ -600,13 +603,13 @@
analyzeUntyped(node.statements);
}
- DartType visitCascade(Cascade node) {
+ ResolutionDartType visitCascade(Cascade node) {
analyze(node.expression);
return popCascadeType();
}
- DartType visitCascadeReceiver(CascadeReceiver node) {
- DartType type = analyze(node.expression);
+ ResolutionDartType visitCascadeReceiver(CascadeReceiver node) {
+ ResolutionDartType type = analyze(node.expression);
pushCascadeType(type);
return type;
}
@@ -639,16 +642,16 @@
analyze(node.function);
}
- DartType visitFunctionExpression(FunctionExpression node) {
- DartType type;
- DartType returnType;
+ ResolutionDartType visitFunctionExpression(FunctionExpression node) {
+ ResolutionDartType type;
+ ResolutionDartType returnType;
final FunctionElement element = elements.getFunctionDefinition(node);
assert(invariant(node, element != null,
message: 'FunctionExpression with no element'));
- if (Elements.isUnresolved(element)) return const DynamicType();
+ if (Elements.isUnresolved(element)) return const ResolutionDynamicType();
if (element.isGenerativeConstructor) {
- type = const DynamicType();
- returnType = const VoidType();
+ type = const ResolutionDynamicType();
+ returnType = const ResolutionVoidType();
element.functionSignature.forEachParameter((ParameterElement parameter) {
if (parameter.isInitializingFormal) {
@@ -661,12 +664,12 @@
analyzeUntyped(node.initializers, inInitializer: true);
}
} else {
- FunctionType functionType = element.computeType(resolution);
+ ResolutionFunctionType functionType = element.computeType(resolution);
returnType = functionType.returnType;
type = functionType;
}
ExecutableElement previousExecutableContext = executableContext;
- DartType previousReturnType = expectedReturnType;
+ ResolutionDartType previousReturnType = expectedReturnType;
expectedReturnType = returnType;
AsyncMarker previousAsyncMarker = currentAsyncMarker;
@@ -680,7 +683,7 @@
return type;
}
- DartType visitIdentifier(Identifier node) {
+ ResolutionDartType visitIdentifier(Identifier node) {
if (node.isThis()) {
return thisType;
} else if (node.isSuper()) {
@@ -716,8 +719,8 @@
}
}
- ElementAccess lookupMember(Node node, DartType receiverType, String name,
- MemberKind memberKind, Element receiverElement,
+ ElementAccess lookupMember(Node node, ResolutionDartType receiverType,
+ String name, MemberKind memberKind, Element receiverElement,
{bool lookupClassMember: false, bool isHint: false}) {
if (receiverType.treatAsDynamic) {
return const DynamicAccess();
@@ -727,7 +730,8 @@
isSetter: memberKind == MemberKind.SETTER);
// Lookup the class or interface member [name] in [interface].
- MemberSignature lookupMemberSignature(Name name, InterfaceType interface) {
+ MemberSignature lookupMemberSignature(
+ Name name, ResolutionInterfaceType interface) {
MembersCreator.computeClassMembersByName(
resolution, interface.element, name.text);
return lookupClassMember || analyzingInitializer
@@ -737,8 +741,8 @@
// Compute the access of [name] on [type]. This function takes the special
// 'call' method into account.
- ElementAccess getAccess(
- Name name, DartType unaliasedBound, InterfaceType interface) {
+ ElementAccess getAccess(Name name, ResolutionDartType unaliasedBound,
+ ResolutionInterfaceType interface) {
MemberSignature member = lookupMemberSignature(memberName, interface);
if (member != null) {
if (member is ErroneousMember) {
@@ -756,18 +760,18 @@
// This is an access of the special 'call' method implicitly defined
// on 'Function'. This method can be called with any arguments, which
// we ensure by giving it the type 'dynamic'.
- return new FunctionCallAccess(null, const DynamicType());
+ return new FunctionCallAccess(null, const ResolutionDynamicType());
}
}
return null;
}
- DartType unaliasedBound =
+ ResolutionDartType unaliasedBound =
Types.computeUnaliasedBound(resolution, receiverType);
if (unaliasedBound.treatAsDynamic) {
return new DynamicAccess();
}
- InterfaceType interface =
+ ResolutionInterfaceType interface =
Types.computeInterfaceType(resolution, unaliasedBound);
ElementAccess access = getAccess(memberName, unaliasedBound, interface);
if (access != null) {
@@ -780,10 +784,10 @@
while (!typePromotions.isEmpty) {
TypePromotion typePromotion = typePromotions.head;
if (!typePromotion.isValid) {
- DartType unaliasedBound =
+ ResolutionDartType unaliasedBound =
Types.computeUnaliasedBound(resolution, typePromotion.type);
if (!unaliasedBound.treatAsDynamic) {
- InterfaceType interface =
+ ResolutionInterfaceType interface =
Types.computeInterfaceType(resolution, unaliasedBound);
if (getAccess(memberName, unaliasedBound, interface) != null) {
reportTypePromotionHint(typePromotion);
@@ -873,19 +877,19 @@
return const DynamicAccess();
}
- DartType lookupMemberType(
- Node node, DartType type, String name, MemberKind memberKind,
+ ResolutionDartType lookupMemberType(
+ Node node, ResolutionDartType type, String name, MemberKind memberKind,
{bool isHint: false}) {
return lookupMember(node, type, name, memberKind, null, isHint: isHint)
.computeType(resolution);
}
- void analyzeArguments(Send send, Element element, DartType type,
- [LinkBuilder<DartType> argumentTypes]) {
+ void analyzeArguments(Send send, Element element, ResolutionDartType type,
+ [LinkBuilder<ResolutionDartType> argumentTypes]) {
Link<Node> arguments = send.arguments;
type.computeUnaliased(resolution);
- DartType unaliasedType = type.unaliased;
- if (identical(unaliasedType.kind, TypeKind.FUNCTION)) {
+ ResolutionDartType unaliasedType = type.unaliased;
+ if (identical(unaliasedType.kind, ResolutionTypeKind.FUNCTION)) {
/// Report [warning] including info(s) about the declaration of [element]
/// or [type].
void reportWarning(DiagnosticMessage warning) {
@@ -909,17 +913,18 @@
/// Report a warning on [node] if [argumentType] is not assignable to
/// [parameterType].
- void checkAssignable(
- Spannable node, DartType argumentType, DartType parameterType) {
+ void checkAssignable(Spannable node, ResolutionDartType argumentType,
+ ResolutionDartType parameterType) {
if (!types.isAssignable(argumentType, parameterType)) {
reportWarning(reporter.createMessage(node, MessageKind.NOT_ASSIGNABLE,
{'fromType': argumentType, 'toType': parameterType}));
}
}
- FunctionType funType = unaliasedType;
- Iterator<DartType> parameterTypes = funType.parameterTypes.iterator;
- Iterator<DartType> optionalParameterTypes =
+ ResolutionFunctionType funType = unaliasedType;
+ Iterator<ResolutionDartType> parameterTypes =
+ funType.parameterTypes.iterator;
+ Iterator<ResolutionDartType> optionalParameterTypes =
funType.optionalParameterTypes.iterator;
while (!arguments.isEmpty) {
Node argument = arguments.head;
@@ -927,7 +932,7 @@
if (namedArgument != null) {
argument = namedArgument.expression;
String argumentName = namedArgument.name.source;
- DartType namedParameterType =
+ ResolutionDartType namedParameterType =
funType.getNamedParameterType(argumentName);
if (namedParameterType == null) {
// TODO(johnniwinther): Provide better information on the called
@@ -937,10 +942,10 @@
MessageKind.NAMED_ARGUMENT_NOT_FOUND,
{'argumentName': argumentName}));
- DartType argumentType = analyze(argument);
+ ResolutionDartType argumentType = analyze(argument);
if (argumentTypes != null) argumentTypes.addLast(argumentType);
} else {
- DartType argumentType = analyze(argument);
+ ResolutionDartType argumentType = analyze(argument);
if (argumentTypes != null) argumentTypes.addLast(argumentType);
checkAssignable(argument, argumentType, namedParameterType);
}
@@ -952,16 +957,16 @@
reportWarning(reporter.createMessage(
argument, MessageKind.ADDITIONAL_ARGUMENT));
- DartType argumentType = analyze(argument);
+ ResolutionDartType argumentType = analyze(argument);
if (argumentTypes != null) argumentTypes.addLast(argumentType);
} else {
- DartType argumentType = analyze(argument);
+ ResolutionDartType argumentType = analyze(argument);
if (argumentTypes != null) argumentTypes.addLast(argumentType);
checkAssignable(
argument, argumentType, optionalParameterTypes.current);
}
} else {
- DartType argumentType = analyze(argument);
+ ResolutionDartType argumentType = analyze(argument);
if (argumentTypes != null) argumentTypes.addLast(argumentType);
checkAssignable(argument, argumentType, parameterTypes.current);
}
@@ -976,7 +981,7 @@
}
} else {
while (!arguments.isEmpty) {
- DartType argumentType = analyze(arguments.head);
+ ResolutionDartType argumentType = analyze(arguments.head);
if (argumentTypes != null) argumentTypes.addLast(argumentType);
arguments = arguments.tail;
}
@@ -987,24 +992,24 @@
//
// If provided [argumentTypes] is filled with the argument types during
// analysis.
- DartType analyzeInvocation(Send node, ElementAccess elementAccess,
- [LinkBuilder<DartType> argumentTypes]) {
- DartType type = elementAccess.computeType(resolution);
+ ResolutionDartType analyzeInvocation(Send node, ElementAccess elementAccess,
+ [LinkBuilder<ResolutionDartType> argumentTypes]) {
+ ResolutionDartType type = elementAccess.computeType(resolution);
if (elementAccess.isCallable(compiler)) {
analyzeArguments(node, elementAccess.element, type, argumentTypes);
} else {
reportTypeWarning(
node, MessageKind.NOT_CALLABLE, {'elementName': elementAccess.name});
- analyzeArguments(
- node, elementAccess.element, const DynamicType(), argumentTypes);
+ analyzeArguments(node, elementAccess.element,
+ const ResolutionDynamicType(), argumentTypes);
}
type.computeUnaliased(resolution);
type = type.unaliased;
if (type.isFunctionType) {
- FunctionType funType = type;
+ ResolutionFunctionType funType = type;
return funType.returnType;
} else {
- return const DynamicType();
+ return const ResolutionDynamicType();
}
}
@@ -1032,7 +1037,7 @@
}
}
// e.foo() for some expression e.
- DartType receiverType = analyze(node.receiver);
+ ResolutionDartType receiverType = analyze(node.receiver);
if (receiverType.treatAsDynamic || receiverType.isVoid) {
return const DynamicAccess();
}
@@ -1104,10 +1109,10 @@
* Computes the type of the access of [name] on the [node] possibly using the
* [element] provided for [node] by the resolver.
*/
- DartType computeAccessType(
+ ResolutionDartType computeAccessType(
Send node, String name, Element element, MemberKind memberKind,
{bool lookupClassMember: false}) {
- DartType type = computeAccess(node, name, element, memberKind,
+ ResolutionDartType type = computeAccess(node, name, element, memberKind,
lookupClassMember: lookupClassMember)
.computeType(resolution);
if (type == null) {
@@ -1120,7 +1125,8 @@
/// This is used to provided better hints when trying to promote a supertype
/// to a raw subtype. For instance trying to promote `Iterable<int>` to `List`
/// we suggest the use of `List<int>`, which would make promotion valid.
- DartType computeMoreSpecificType(DartType shownType, DartType knownType) {
+ ResolutionDartType computeMoreSpecificType(
+ ResolutionDartType shownType, ResolutionDartType knownType) {
if (knownType.isInterfaceType &&
shownType.isInterfaceType &&
types.isSubtype(shownType.asRaw(), knownType)) {
@@ -1129,14 +1135,14 @@
// class B<S, U> extends A<S, int> {}
// and a promotion from a [knownType] of `A<double, int>` to a
// [shownType] of `B`.
- InterfaceType knownInterfaceType = knownType;
+ ResolutionInterfaceType knownInterfaceType = knownType;
ClassElement shownClass = shownType.element;
// Compute `B<double, dynamic>` as the subtype of `A<double, int>` using
// the relation between `A<S, int>` and `A<double, int>`.
MoreSpecificSubtypeVisitor visitor =
new MoreSpecificSubtypeVisitor(types);
- InterfaceType shownTypeGeneric =
+ ResolutionInterfaceType shownTypeGeneric =
visitor.computeMoreSpecific(shownClass, knownInterfaceType);
if (shownTypeGeneric != null &&
@@ -1149,11 +1155,11 @@
return null;
}
- DartType visitSend(Send node) {
+ ResolutionDartType visitSend(Send node) {
Element element = elements[node];
if (element != null && element.isConstructor) {
- DartType receiverType;
+ ResolutionDartType receiverType;
if (node.receiver != null) {
receiverType = analyze(node.receiver);
} else if (node.selector.isSuper()) {
@@ -1163,9 +1169,10 @@
assert(node.selector.isThis());
receiverType = thisType;
}
- DartType constructorType = computeConstructorType(element, receiverType);
+ ResolutionDartType constructorType =
+ computeConstructorType(element, receiverType);
analyzeArguments(node, element, constructorType);
- return const DynamicType();
+ return const ResolutionDynamicType();
}
Identifier selector = node.selector.asIdentifier();
@@ -1182,12 +1189,12 @@
}
} else {
// exp() where exp is some complex expression like (o) or foo().
- DartType type = analyze(node.selector);
+ ResolutionDartType type = analyze(node.selector);
return analyzeInvocation(node, new TypeAccess(type));
}
} else if (Elements.isMalformed(element) && selector == null) {
// exp() where exp is an erroneous construct like `new Unresolved()`.
- DartType type = analyze(node.selector);
+ ResolutionDartType type = analyze(node.selector);
return analyzeInvocation(node, new TypeAccess(type));
}
@@ -1209,9 +1216,10 @@
}
if (variable != null && (variable.isVariable || variable.isParameter)) {
- DartType knownType = getKnownType(variable);
+ ResolutionDartType knownType = getKnownType(variable);
if (!knownType.isDynamic) {
- DartType shownType = elements.getType(node.arguments.head);
+ ResolutionDartType shownType =
+ elements.getType(node.arguments.head);
TypePromotion typePromotion =
new TypePromotion(node, variable, shownType);
if (!types.isMoreSpecific(shownType, knownType)) {
@@ -1224,7 +1232,7 @@
'knownType': knownType
}));
} else {
- DartType shownTypeSuggestion =
+ ResolutionDartType shownTypeSuggestion =
computeMoreSpecificType(shownType, knownType);
if (shownTypeSuggestion != null) {
typePromotion.addHint(reporter.createMessage(
@@ -1255,7 +1263,7 @@
return elements.getType(node.arguments.head);
} else if (node.isOperator) {
final Node receiver = node.receiver;
- final DartType receiverType = analyze(receiver);
+ final ResolutionDartType receiverType = analyze(receiver);
if (identical(name, '==') ||
identical(name, '!=')
// TODO(johnniwinther): Remove these.
@@ -1268,14 +1276,14 @@
} else if (identical(name, '||')) {
checkAssignable(receiver, receiverType, boolType);
final Node argument = node.arguments.head;
- final DartType argumentType = analyze(argument);
+ final ResolutionDartType argumentType = analyze(argument);
checkAssignable(argument, argumentType, boolType);
return boolType;
} else if (identical(name, '&&')) {
checkAssignable(receiver, receiverType, boolType);
final Node argument = node.arguments.head;
- final DartType argumentType =
+ final ResolutionDartType argumentType =
analyzeInPromotedContext(receiver, argument);
reshowTypePromotions(node, receiver, argument);
@@ -1289,7 +1297,7 @@
return boolType;
} else if (identical(name, '??')) {
final Node argument = node.arguments.head;
- final DartType argumentType = analyze(argument);
+ final ResolutionDartType argumentType = analyze(argument);
return types.computeLeastUpperBound(receiverType, argumentType);
}
String operatorName = selector.source;
@@ -1324,15 +1332,16 @@
? const DynamicAccess()
: lookupMember(
node, receiverType, operatorName, MemberKind.OPERATOR, null);
- LinkBuilder<DartType> argumentTypesBuilder = new LinkBuilder<DartType>();
- DartType resultType =
+ LinkBuilder<ResolutionDartType> argumentTypesBuilder =
+ new LinkBuilder<ResolutionDartType>();
+ ResolutionDartType resultType =
analyzeInvocation(node, access, argumentTypesBuilder);
if (receiverType == intType) {
if (identical(name, '+') ||
identical(operatorName, '-') ||
identical(name, '*') ||
identical(name, '%')) {
- DartType argumentType = argumentTypesBuilder.toLink().head;
+ ResolutionDartType argumentType = argumentTypesBuilder.toLink().head;
if (argumentType == intType) {
return intType;
} else if (argumentType == doubleType) {
@@ -1355,16 +1364,16 @@
}
/// Returns the first type in the list or [:dynamic:] if the list is empty.
- DartType firstType(List<DartType> list) {
- return list.isEmpty ? const DynamicType() : list.first;
+ ResolutionDartType firstType(List<ResolutionDartType> list) {
+ return list.isEmpty ? const ResolutionDynamicType() : list.first;
}
/**
* Returns the second type in the list or [:dynamic:] if the list is too
* short.
*/
- DartType secondType(List<DartType> list) {
- return list.length < 2 ? const DynamicType() : list[1];
+ ResolutionDartType secondType(List<ResolutionDartType> list) {
+ return list.length < 2 ? const ResolutionDynamicType() : list[1];
}
/**
@@ -1372,24 +1381,25 @@
* of the result. This method also handles increment/decrement expressions
* like [: target++ :].
*/
- DartType checkAssignmentOperator(
- SendSet node, String operatorName, Node valueNode, DartType value) {
+ ResolutionDartType checkAssignmentOperator(SendSet node, String operatorName,
+ Node valueNode, ResolutionDartType value) {
assert(invariant(node, !node.isIndex));
Element setterElement = elements[node];
Element getterElement = elements[node.selector];
Identifier selector = node.selector;
- DartType getter = computeAccessType(
+ ResolutionDartType getter = computeAccessType(
node, selector.source, getterElement, MemberKind.GETTER);
- DartType setter = computeAccessType(
+ ResolutionDartType setter = computeAccessType(
node, selector.source, setterElement, MemberKind.SETTER);
// [operator] is the type of operator+ or operator- on [target].
- DartType operator =
+ ResolutionDartType operator =
lookupMemberType(node, getter, operatorName, MemberKind.OPERATOR);
- if (operator is FunctionType) {
- FunctionType operatorType = operator;
+ if (operator is ResolutionFunctionType) {
+ ResolutionFunctionType operatorType = operator;
// [result] is the type of target o value.
- DartType result = operatorType.returnType;
- DartType operatorArgument = firstType(operatorType.parameterTypes);
+ ResolutionDartType result = operatorType.returnType;
+ ResolutionDartType operatorArgument =
+ firstType(operatorType.parameterTypes);
// Check target o value.
bool validValue = checkAssignable(valueNode, value, operatorArgument);
if (validValue || !(node.isPrefix || node.isPostfix)) {
@@ -1398,7 +1408,7 @@
}
return node.isPostfix ? getter : result;
}
- return const DynamicType();
+ return const ResolutionDynamicType();
}
/**
@@ -1406,43 +1416,47 @@
* of the result. This method also handles increment/decrement expressions
* like [: base[key]++ :].
*/
- DartType checkIndexAssignmentOperator(
- SendSet node, String operatorName, Node valueNode, DartType value) {
+ ResolutionDartType checkIndexAssignmentOperator(SendSet node,
+ String operatorName, Node valueNode, ResolutionDartType value) {
assert(invariant(node, node.isIndex));
- final DartType base = analyze(node.receiver);
+ final ResolutionDartType base = analyze(node.receiver);
final Node keyNode = node.arguments.head;
- final DartType key = analyze(keyNode);
+ final ResolutionDartType key = analyze(keyNode);
// [indexGet] is the type of operator[] on [base].
- DartType indexGet = lookupMemberType(node, base, '[]', MemberKind.OPERATOR);
- if (indexGet is FunctionType) {
- FunctionType indexGetType = indexGet;
- DartType indexGetKey = firstType(indexGetType.parameterTypes);
+ ResolutionDartType indexGet =
+ lookupMemberType(node, base, '[]', MemberKind.OPERATOR);
+ if (indexGet is ResolutionFunctionType) {
+ ResolutionFunctionType indexGetType = indexGet;
+ ResolutionDartType indexGetKey = firstType(indexGetType.parameterTypes);
// Check base[key].
bool validKey = checkAssignable(keyNode, key, indexGetKey);
// [element] is the type of base[key].
- DartType element = indexGetType.returnType;
+ ResolutionDartType element = indexGetType.returnType;
// [operator] is the type of operator o on [element].
- DartType operator =
+ ResolutionDartType operator =
lookupMemberType(node, element, operatorName, MemberKind.OPERATOR);
- if (operator is FunctionType) {
- FunctionType operatorType = operator;
+ if (operator is ResolutionFunctionType) {
+ ResolutionFunctionType operatorType = operator;
// Check base[key] o value.
- DartType operatorArgument = firstType(operatorType.parameterTypes);
+ ResolutionDartType operatorArgument =
+ firstType(operatorType.parameterTypes);
bool validValue = checkAssignable(valueNode, value, operatorArgument);
// [result] is the type of base[key] o value.
- DartType result = operatorType.returnType;
+ ResolutionDartType result = operatorType.returnType;
// [indexSet] is the type of operator[]= on [base].
- DartType indexSet =
+ ResolutionDartType indexSet =
lookupMemberType(node, base, '[]=', MemberKind.OPERATOR);
- if (indexSet is FunctionType) {
- FunctionType indexSetType = indexSet;
- DartType indexSetKey = firstType(indexSetType.parameterTypes);
- DartType indexSetValue = secondType(indexSetType.parameterTypes);
+ if (indexSet is ResolutionFunctionType) {
+ ResolutionFunctionType indexSetType = indexSet;
+ ResolutionDartType indexSetKey =
+ firstType(indexSetType.parameterTypes);
+ ResolutionDartType indexSetValue =
+ secondType(indexSetType.parameterTypes);
if (validKey || indexGetKey != indexSetKey) {
// Only check base[key] on []= if base[key] was valid for [] or
@@ -1457,7 +1471,7 @@
return node.isPostfix ? element : result;
}
}
- return const DynamicType();
+ return const ResolutionDynamicType();
}
visitSendSet(SendSet node) {
@@ -1468,17 +1482,18 @@
// e1 = value
if (node.isIndex) {
// base[key] = value
- final DartType base = analyze(node.receiver);
+ final ResolutionDartType base = analyze(node.receiver);
final Node keyNode = node.arguments.head;
- final DartType key = analyze(keyNode);
+ final ResolutionDartType key = analyze(keyNode);
final Node valueNode = node.arguments.tail.head;
- final DartType value = analyze(valueNode);
- DartType indexSet =
+ final ResolutionDartType value = analyze(valueNode);
+ ResolutionDartType indexSet =
lookupMemberType(node, base, '[]=', MemberKind.OPERATOR);
- DartType indexSetValue = const DynamicType();
- if (indexSet is FunctionType) {
- FunctionType indexSetType = indexSet;
- DartType indexSetKey = firstType(indexSetType.parameterTypes);
+ ResolutionDartType indexSetValue = const ResolutionDynamicType();
+ if (indexSet is ResolutionFunctionType) {
+ ResolutionFunctionType indexSetType = indexSet;
+ ResolutionDartType indexSetKey =
+ firstType(indexSetType.parameterTypes);
checkAssignable(keyNode, key, indexSetKey);
indexSetValue = secondType(indexSetType.parameterTypes);
checkAssignable(node.assignmentOperator, value, indexSetValue);
@@ -1488,7 +1503,7 @@
: types.computeLeastUpperBound(value, indexSetValue);
} else {
// target = value
- DartType target;
+ ResolutionDartType target;
if (analyzingInitializer) {
// Field declaration `Foo target = value;` or initializer
// `this.target = value`. Lookup the getter `target` in the class
@@ -1502,7 +1517,7 @@
node, selector.source, element, MemberKind.SETTER);
}
final Node valueNode = node.arguments.head;
- final DartType value = analyze(valueNode);
+ final ResolutionDartType value = analyze(valueNode);
checkAssignable(node.assignmentOperator, value, target);
return identical(name, '=')
? value
@@ -1563,57 +1578,58 @@
if (node.isIndex) {
// base[key] o= value for some operator o.
final Node valueNode = node.arguments.tail.head;
- final DartType value = analyze(valueNode);
+ final ResolutionDartType value = analyze(valueNode);
return checkIndexAssignmentOperator(
node, operatorName, valueNode, value);
} else {
// target o= value for some operator o.
final Node valueNode = node.arguments.head;
- final DartType value = analyze(valueNode);
+ final ResolutionDartType value = analyze(valueNode);
return checkAssignmentOperator(node, operatorName, valueNode, value);
}
}
}
- DartType visitLiteralInt(LiteralInt node) {
+ ResolutionDartType visitLiteralInt(LiteralInt node) {
return intType;
}
- DartType visitLiteralDouble(LiteralDouble node) {
+ ResolutionDartType visitLiteralDouble(LiteralDouble node) {
return doubleType;
}
- DartType visitLiteralBool(LiteralBool node) {
+ ResolutionDartType visitLiteralBool(LiteralBool node) {
return boolType;
}
- DartType visitLiteralString(LiteralString node) {
+ ResolutionDartType visitLiteralString(LiteralString node) {
return stringType;
}
- DartType visitStringJuxtaposition(StringJuxtaposition node) {
+ ResolutionDartType visitStringJuxtaposition(StringJuxtaposition node) {
analyze(node.first);
analyze(node.second);
return stringType;
}
- DartType visitLiteralNull(LiteralNull node) {
- return const DynamicType();
+ ResolutionDartType visitLiteralNull(LiteralNull node) {
+ return const ResolutionDynamicType();
}
- DartType visitLiteralSymbol(LiteralSymbol node) {
+ ResolutionDartType visitLiteralSymbol(LiteralSymbol node) {
return commonElements.symbolType;
}
- DartType computeConstructorType(
- ConstructorElement constructor, DartType type) {
- if (Elements.isUnresolved(constructor)) return const DynamicType();
- DartType constructorType = constructor.computeType(resolution);
- if (identical(type.kind, TypeKind.INTERFACE)) {
+ ResolutionDartType computeConstructorType(
+ ConstructorElement constructor, ResolutionDartType type) {
+ if (Elements.isUnresolved(constructor))
+ return const ResolutionDynamicType();
+ ResolutionDartType constructorType = constructor.computeType(resolution);
+ if (identical(type.kind, ResolutionTypeKind.INTERFACE)) {
if (constructor.isSynthesized) {
// TODO(johnniwinther): Remove this when synthesized constructors handle
// type variables correctly.
- InterfaceType interfaceType = type;
+ ResolutionInterfaceType interfaceType = type;
ClassElement receiverElement = interfaceType.element;
while (receiverElement.isMixinApplication) {
receiverElement = receiverElement.supertype.element;
@@ -1627,28 +1643,29 @@
return constructorType;
}
- DartType visitNewExpression(NewExpression node) {
+ ResolutionDartType visitNewExpression(NewExpression node) {
Element element = elements[node.send];
- if (Elements.isUnresolved(element)) return const DynamicType();
+ if (Elements.isUnresolved(element)) return const ResolutionDynamicType();
checkPrivateAccess(node, element, element.name);
- DartType newType = elements.getType(node);
+ ResolutionDartType newType = elements.getType(node);
assert(invariant(node, newType != null,
message: "No new type registered in $elements."));
- DartType constructorType = computeConstructorType(element, newType);
+ ResolutionDartType constructorType =
+ computeConstructorType(element, newType);
analyzeArguments(node.send, element, constructorType);
return newType;
}
- DartType visitLiteralList(LiteralList node) {
- InterfaceType listType = elements.getType(node);
- DartType listElementType = firstType(listType.typeArguments);
+ ResolutionDartType visitLiteralList(LiteralList node) {
+ ResolutionInterfaceType listType = elements.getType(node);
+ ResolutionDartType listElementType = firstType(listType.typeArguments);
for (Link<Node> link = node.elements.nodes;
!link.isEmpty;
link = link.tail) {
Node element = link.head;
- DartType elementType = analyze(element);
+ ResolutionDartType elementType = analyze(element);
checkAssignable(element, elementType, listElementType,
isConst: node.isConst);
}
@@ -1682,7 +1699,7 @@
// if the type of e may not be assigned to the declared return type of the
// immediately enclosing function.
if (expression != null) {
- DartType expressionType = analyze(expression);
+ ResolutionDartType expressionType = analyze(expression);
if (executableContext.isGenerativeConstructor) {
// The resolver already emitted an error for this expression.
} else {
@@ -1691,7 +1708,7 @@
commonElements.futureType(types.flatten(expressionType));
}
if (expectedReturnType.isVoid &&
- !types.isAssignable(expressionType, const VoidType())) {
+ !types.isAssignable(expressionType, const ResolutionVoidType())) {
reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID);
} else {
checkAssignable(expression, expressionType, expectedReturnType);
@@ -1699,7 +1716,8 @@
}
} else if (currentAsyncMarker != AsyncMarker.SYNC) {
// `return;` is allowed.
- } else if (!types.isAssignable(expectedReturnType, const VoidType())) {
+ } else if (!types.isAssignable(
+ expectedReturnType, const ResolutionVoidType())) {
// Let f be the function immediately enclosing a return statement of the
// form 'return;' It is a static warning if both of the following
// conditions hold:
@@ -1710,23 +1728,23 @@
}
}
- DartType visitThrow(Throw node) {
+ ResolutionDartType visitThrow(Throw node) {
// TODO(johnniwinther): Handle reachability.
analyze(node.expression);
- return const DynamicType();
+ return const ResolutionDynamicType();
}
- DartType visitAwait(Await node) {
- DartType expressionType = analyze(node.expression);
+ ResolutionDartType visitAwait(Await node) {
+ ResolutionDartType expressionType = analyze(node.expression);
if (resolution.target.supportsAsyncAwait) {
return types.flatten(expressionType);
} else {
- return const DynamicType();
+ return const ResolutionDynamicType();
}
}
- DartType visitYield(Yield node) {
- DartType resultType = analyze(node.expression);
+ ResolutionDartType visitYield(Yield node) {
+ ResolutionDartType resultType = analyze(node.expression);
if (!node.hasStar) {
if (currentAsyncMarker.isAsync) {
resultType = commonElements.streamType(resultType);
@@ -1746,29 +1764,30 @@
checkAssignable(node, resultType, expectedReturnType);
}
- DartType visitTypeAnnotation(TypeAnnotation node) {
+ ResolutionDartType visitTypeAnnotation(TypeAnnotation node) {
return elements.getType(node);
}
- DartType analyzeVariableTypeAnnotation(VariableDefinitions node) {
- DartType type = analyzeWithDefault(node.type, const DynamicType());
+ ResolutionDartType analyzeVariableTypeAnnotation(VariableDefinitions node) {
+ ResolutionDartType type =
+ analyzeWithDefault(node.type, const ResolutionDynamicType());
if (type.isVoid) {
reportTypeWarning(node.type, MessageKind.VOID_VARIABLE);
- type = const DynamicType();
+ type = const ResolutionDynamicType();
}
return type;
}
void analyzeVariableInitializer(
- Spannable spannable, DartType declaredType, Node initializer) {
+ Spannable spannable, ResolutionDartType declaredType, Node initializer) {
if (initializer == null) return;
- DartType expressionType = analyzeNonVoid(initializer);
+ ResolutionDartType expressionType = analyzeNonVoid(initializer);
checkAssignable(spannable, expressionType, declaredType);
}
visitVariableDefinitions(VariableDefinitions node) {
- DartType type = analyzeVariableTypeAnnotation(node);
+ ResolutionDartType type = analyzeVariableTypeAnnotation(node);
for (Link<Node> link = node.definitions.nodes;
!link.isEmpty;
link = link.tail) {
@@ -1799,24 +1818,26 @@
analyzeUntyped(node.body);
}
- DartType visitParenthesizedExpression(ParenthesizedExpression node) {
+ ResolutionDartType visitParenthesizedExpression(
+ ParenthesizedExpression node) {
Expression expression = node.expression;
- DartType type = analyze(expression);
+ ResolutionDartType type = analyze(expression);
for (TypePromotion typePromotion in getShownTypePromotionsFor(expression)) {
showTypePromotion(node, typePromotion);
}
return type;
}
- DartType visitConditional(Conditional node) {
+ ResolutionDartType visitConditional(Conditional node) {
Expression condition = node.condition;
Expression thenExpression = node.thenExpression;
checkCondition(condition);
- DartType thenType = analyzeInPromotedContext(condition, thenExpression);
+ ResolutionDartType thenType =
+ analyzeInPromotedContext(condition, thenExpression);
- DartType elseType = analyze(node.elseExpression);
+ ResolutionDartType elseType = analyze(node.elseExpression);
return types.computeLeastUpperBound(thenType, elseType);
}
@@ -1842,33 +1863,35 @@
// Nothing to do here.
}
- DartType computeForInElementType(ForIn node) {
+ ResolutionDartType computeForInElementType(ForIn node) {
VariableDefinitions declaredIdentifier =
node.declaredIdentifier.asVariableDefinitions();
if (declaredIdentifier != null) {
- return analyzeWithDefault(declaredIdentifier.type, const DynamicType());
+ return analyzeWithDefault(
+ declaredIdentifier.type, const ResolutionDynamicType());
} else {
return analyze(node.declaredIdentifier);
}
}
visitAsyncForIn(AsyncForIn node) {
- DartType elementType = computeForInElementType(node);
- DartType expressionType = analyze(node.expression);
+ ResolutionDartType elementType = computeForInElementType(node);
+ ResolutionDartType expressionType = analyze(node.expression);
if (resolution.target.supportsAsyncAwait) {
- DartType streamOfDynamic = commonElements.streamType();
+ ResolutionDartType streamOfDynamic = commonElements.streamType();
if (!types.isAssignable(expressionType, streamOfDynamic)) {
reportMessage(node.expression, MessageKind.NOT_ASSIGNABLE,
{'fromType': expressionType, 'toType': streamOfDynamic},
isHint: true);
} else {
- InterfaceType interfaceType =
+ ResolutionInterfaceType interfaceType =
Types.computeInterfaceType(resolution, expressionType);
if (interfaceType != null) {
- InterfaceType streamType =
+ ResolutionInterfaceType streamType =
interfaceType.asInstanceOf(streamOfDynamic.element);
if (streamType != null) {
- DartType streamElementType = streamType.typeArguments.first;
+ ResolutionDartType streamElementType =
+ streamType.typeArguments.first;
if (!types.isAssignable(streamElementType, elementType)) {
reportMessage(
node.expression,
@@ -1888,11 +1911,11 @@
}
visitSyncForIn(SyncForIn node) {
- DartType elementType = computeForInElementType(node);
- DartType expressionType = analyze(node.expression);
- DartType iteratorType = lookupMemberType(node.expression, expressionType,
- Identifiers.iterator, MemberKind.GETTER);
- DartType currentType = lookupMemberType(
+ ResolutionDartType elementType = computeForInElementType(node);
+ ResolutionDartType expressionType = analyze(node.expression);
+ ResolutionDartType iteratorType = lookupMemberType(node.expression,
+ expressionType, Identifiers.iterator, MemberKind.GETTER);
+ ResolutionDartType currentType = lookupMemberType(
node.expression, iteratorType, Identifiers.current, MemberKind.GETTER,
isHint: true);
if (!types.isAssignable(currentType, elementType)) {
@@ -1914,17 +1937,17 @@
}
visitLiteralMap(LiteralMap node) {
- InterfaceType mapType = elements.getType(node);
- DartType mapKeyType = firstType(mapType.typeArguments);
- DartType mapValueType = secondType(mapType.typeArguments);
+ ResolutionInterfaceType mapType = elements.getType(node);
+ ResolutionDartType mapKeyType = firstType(mapType.typeArguments);
+ ResolutionDartType mapValueType = secondType(mapType.typeArguments);
bool isConst = node.isConst;
for (Link<Node> link = node.entries.nodes;
!link.isEmpty;
link = link.tail) {
LiteralMapEntry entry = link.head;
- DartType keyType = analyze(entry.key);
+ ResolutionDartType keyType = analyze(entry.key);
checkAssignable(entry.key, keyType, mapKeyType, isConst: isConst);
- DartType valueType = analyze(entry.value);
+ ResolutionDartType valueType = analyze(entry.value);
checkAssignable(entry.value, valueType, mapValueType, isConst: isConst);
}
return mapType;
@@ -1944,7 +1967,7 @@
// switch cases.
// TODO(johnniwinther): Provide hint of duplicate case constants.
- DartType expressionType = analyze(node.expression);
+ ResolutionDartType expressionType = analyze(node.expression);
// Check that all the case expressions are assignable to the expression.
bool hasDefaultCase = false;
@@ -1956,7 +1979,7 @@
CaseMatch caseMatch = labelOrCase.asCaseMatch();
if (caseMatch == null) continue;
- DartType caseType = analyze(caseMatch.expression);
+ ResolutionDartType caseType = analyze(caseMatch.expression);
checkAssignable(caseMatch, expressionType, caseType);
}
diff --git a/pkg/compiler/lib/src/types/abstract_value_domain.dart b/pkg/compiler/lib/src/types/abstract_value_domain.dart
index e19da52..287cd2e 100644
--- a/pkg/compiler/lib/src/types/abstract_value_domain.dart
+++ b/pkg/compiler/lib/src/types/abstract_value_domain.dart
@@ -5,7 +5,7 @@
library dart2js.abstract_value_domain;
import '../constants/values.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../universe/selector.dart' show Selector;
@@ -139,7 +139,7 @@
bool isMorePreciseOrEqual(AbstractValue t1, AbstractValue t2);
- AbstractBool isSubtypeOf(AbstractValue value, DartType type,
+ AbstractBool isSubtypeOf(AbstractValue value, ResolutionDartType type,
{bool allowNull});
/// Returns whether [value] is one of the falsy values: false, 0, -0, NaN,
@@ -149,7 +149,7 @@
AbstractBool strictBoolify(AbstractValue type);
/// Create a type mask containing at least all subtypes of [type].
- AbstractValue subtypesOf(DartType type);
+ AbstractValue subtypesOf(ResolutionDartType type);
/// Returns a subset of [receiver] containing at least the types
/// that can respond to [selector] without throwing.
diff --git a/pkg/compiler/lib/src/types/masks.dart b/pkg/compiler/lib/src/types/masks.dart
index a713dc8..01dff02 100644
--- a/pkg/compiler/lib/src/types/masks.dart
+++ b/pkg/compiler/lib/src/types/masks.dart
@@ -197,4 +197,12 @@
closedWorld.backendClasses.indexingBehaviorImplementation,
closedWorld));
}
+
+ TypeMask createNonNullExact(ClassElement cls) {
+ return new TypeMask.nonNullExact(cls.declaration, closedWorld);
+ }
+
+ TypeMask createNonNullSubtype(ClassElement cls) {
+ return new TypeMask.nonNullSubtype(cls.declaration, closedWorld);
+ }
}
diff --git a/pkg/compiler/lib/src/types/type_mask.dart b/pkg/compiler/lib/src/types/type_mask.dart
index e985433..c2872cd 100644
--- a/pkg/compiler/lib/src/types/type_mask.dart
+++ b/pkg/compiler/lib/src/types/type_mask.dart
@@ -4,9 +4,9 @@
part of masks;
-/// An implementation of a [UniverseSelectorConstraints] that is consists if an only
-/// increasing set of [TypeMask]s, that is, once a mask is added it cannot be
-/// removed.
+/// An implementation of a [UniverseSelectorConstraints] that is consists if an
+/// only increasing set of [TypeMask]s, that is, once a mask is added it cannot
+/// be removed.
class IncreasingTypeMaskSet extends UniverseSelectorConstraints {
bool isAll = false;
Set<TypeMask> _masks;
@@ -349,7 +349,8 @@
* invoked on this type mask. [selector] is used to ensure library
* privacy is taken into account.
*/
- bool canHit(Element element, Selector selector, ClosedWorld closedWorld);
+ bool canHit(
+ MemberElement element, Selector selector, ClosedWorld closedWorld);
/**
* Returns the [element] that is known to always be hit at runtime
diff --git a/pkg/compiler/lib/src/universe/feature.dart b/pkg/compiler/lib/src/universe/feature.dart
index 580da8b..d3d8dfa 100644
--- a/pkg/compiler/lib/src/universe/feature.dart
+++ b/pkg/compiler/lib/src/universe/feature.dart
@@ -8,7 +8,7 @@
/// compilation pipeline, for example during resolution.
library compiler.universe.feature;
-import '../dart_types.dart' show InterfaceType;
+import '../elements/resolution_types.dart' show ResolutionInterfaceType;
/// A language feature that may be seen in the program.
// TODO(johnniwinther): Should mirror usage be part of this?
@@ -88,7 +88,7 @@
/// Describes a use of a map literal in the program.
class MapLiteralUse {
- final InterfaceType type;
+ final ResolutionInterfaceType type;
final bool isConstant;
final bool isEmpty;
@@ -115,7 +115,7 @@
/// Describes the use of a list literal in the program.
class ListLiteralUse {
- final InterfaceType type;
+ final ResolutionInterfaceType type;
final bool isConstant;
final bool isEmpty;
diff --git a/pkg/compiler/lib/src/universe/selector.dart b/pkg/compiler/lib/src/universe/selector.dart
index bc959c1..8ca8637 100644
--- a/pkg/compiler/lib/src/universe/selector.dart
+++ b/pkg/compiler/lib/src/universe/selector.dart
@@ -12,6 +12,7 @@
Elements,
FunctionElement,
FunctionSignature,
+ MemberElement,
Name,
LibraryElement,
PublicName;
@@ -247,7 +248,7 @@
return callStructure.signatureApplies(function.functionSignature);
}
- bool applies(Element element) {
+ bool applies(MemberElement element) {
if (name != element.name) return false;
return appliesUnnamed(element);
}
diff --git a/pkg/compiler/lib/src/universe/use.dart b/pkg/compiler/lib/src/universe/use.dart
index 148c6f4..0354b12 100644
--- a/pkg/compiler/lib/src/universe/use.dart
+++ b/pkg/compiler/lib/src/universe/use.dart
@@ -18,7 +18,7 @@
import '../closure.dart' show BoxFieldElement;
import '../common.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../util/util.dart' show Hashing;
import '../world.dart' show World;
@@ -89,10 +89,10 @@
final Element element;
final StaticUseKind kind;
final int hashCode;
- final DartType type;
+ final ResolutionDartType type;
StaticUse.internal(Element element, StaticUseKind kind,
- [DartType type = null])
+ [ResolutionDartType type = null])
: this.element = element,
this.kind = kind,
this.type = type,
@@ -252,8 +252,8 @@
/// Constructor invocation of [element] with the given [callStructure] on
/// [type].
- factory StaticUse.typedConstructorInvoke(
- ConstructorElement element, CallStructure callStructure, DartType type) {
+ factory StaticUse.typedConstructorInvoke(ConstructorElement element,
+ CallStructure callStructure, ResolutionDartType type) {
assert(invariant(element, type != null,
message: "No type provided for constructor invocation."));
// TODO(johnniwinther): Use the [callStructure].
@@ -263,8 +263,8 @@
/// Constant constructor invocation of [element] with the given
/// [callStructure] on [type].
- factory StaticUse.constConstructorInvoke(
- ConstructorElement element, CallStructure callStructure, DartType type) {
+ factory StaticUse.constConstructorInvoke(ConstructorElement element,
+ CallStructure callStructure, ResolutionDartType type) {
assert(invariant(element, type != null,
message: "No type provided for constructor invocation."));
// TODO(johnniwinther): Use the [callStructure].
@@ -274,7 +274,7 @@
/// Constructor redirection to [element] on [type].
factory StaticUse.constructorRedirect(
- ConstructorElement element, InterfaceType type) {
+ ConstructorElement element, ResolutionInterfaceType type) {
assert(invariant(element, type != null,
message: "No type provided for constructor invocation."));
return new StaticUse.internal(element, StaticUseKind.REDIRECTION, type);
@@ -288,7 +288,7 @@
}
/// Read access of an instance field or boxed field [element].
- factory StaticUse.fieldGet(Element element) {
+ factory StaticUse.fieldGet(FieldElement element) {
assert(invariant(
element, element.isInstanceMember || element is BoxFieldElement,
message: "Field init element $element must be an instance "
@@ -297,7 +297,7 @@
}
/// Write access of an instance field or boxed field [element].
- factory StaticUse.fieldSet(Element element) {
+ factory StaticUse.fieldSet(FieldElement element) {
assert(invariant(
element, element.isInstanceMember || element is BoxFieldElement,
message: "Field init element $element must be an instance "
@@ -341,54 +341,54 @@
NATIVE_INSTANTIATION,
}
-/// Use of a [DartType].
+/// Use of a [ResolutionDartType].
class TypeUse {
- final DartType type;
+ final ResolutionDartType type;
final TypeUseKind kind;
final int hashCode;
- TypeUse.internal(DartType type, TypeUseKind kind)
+ TypeUse.internal(ResolutionDartType type, TypeUseKind kind)
: this.type = type,
this.kind = kind,
this.hashCode = Hashing.objectHash(type, Hashing.objectHash(kind));
/// [type] used in an is check, like `e is T` or `e is! T`.
- factory TypeUse.isCheck(DartType type) {
+ factory TypeUse.isCheck(ResolutionDartType type) {
return new TypeUse.internal(type, TypeUseKind.IS_CHECK);
}
/// [type] used in an as cast, like `e as T`.
- factory TypeUse.asCast(DartType type) {
+ factory TypeUse.asCast(ResolutionDartType type) {
return new TypeUse.internal(type, TypeUseKind.AS_CAST);
}
/// [type] used as a type annotation, like `T foo;`.
- factory TypeUse.checkedModeCheck(DartType type) {
+ factory TypeUse.checkedModeCheck(ResolutionDartType type) {
return new TypeUse.internal(type, TypeUseKind.CHECKED_MODE_CHECK);
}
/// [type] used in a on type catch clause, like `try {} on T catch (e) {}`.
- factory TypeUse.catchType(DartType type) {
+ factory TypeUse.catchType(ResolutionDartType type) {
return new TypeUse.internal(type, TypeUseKind.CATCH_TYPE);
}
/// [type] used as a type literal, like `foo() => T;`.
- factory TypeUse.typeLiteral(DartType type) {
+ factory TypeUse.typeLiteral(ResolutionDartType type) {
return new TypeUse.internal(type, TypeUseKind.TYPE_LITERAL);
}
/// [type] used in an instantiation, like `new T();`.
- factory TypeUse.instantiation(InterfaceType type) {
+ factory TypeUse.instantiation(ResolutionInterfaceType type) {
return new TypeUse.internal(type, TypeUseKind.INSTANTIATION);
}
/// [type] used in an instantiation through mirrors.
- factory TypeUse.mirrorInstantiation(InterfaceType type) {
+ factory TypeUse.mirrorInstantiation(ResolutionInterfaceType type) {
return new TypeUse.internal(type, TypeUseKind.MIRROR_INSTANTIATION);
}
/// [type] used in a native instantiation.
- factory TypeUse.nativeInstantiation(InterfaceType type) {
+ factory TypeUse.nativeInstantiation(ResolutionInterfaceType type) {
return new TypeUse.internal(type, TypeUseKind.NATIVE_INSTANTIATION);
}
diff --git a/pkg/compiler/lib/src/universe/world_builder.dart b/pkg/compiler/lib/src/universe/world_builder.dart
index 05cae63..9ae7a13 100644
--- a/pkg/compiler/lib/src/universe/world_builder.dart
+++ b/pkg/compiler/lib/src/universe/world_builder.dart
@@ -13,7 +13,7 @@
import '../common/resolution.dart' show Resolution;
import '../compiler.dart' show Compiler;
import '../core_types.dart';
-import '../dart_types.dart';
+import '../elements/resolution_types.dart';
import '../elements/elements.dart';
import '../elements/entities.dart';
import '../universe/class_set.dart';
@@ -21,6 +21,7 @@
import '../util/enumset.dart';
import '../util/util.dart';
import '../world.dart' show World, ClosedWorld, ClosedWorldImpl, OpenWorld;
+import 'call_structure.dart' show CallStructure;
import 'selector.dart' show Selector;
import 'use.dart' show DynamicUse, DynamicUseKind, StaticUse, StaticUseKind;
@@ -38,7 +39,7 @@
/// Returns whether [element] is a potential target when being
/// invoked on a receiver with this constraint. [selector] is used to ensure
/// library privacy is taken into account.
- bool canHit(Element element, Selector selector, World world);
+ bool canHit(MemberElement element, Selector selector, World world);
/// Returns whether this [TypeMask] applied to [selector] can hit a
/// [noSuchMethod].
@@ -156,16 +157,16 @@
Iterable<ClassElement> get directlyInstantiatedClasses;
/// All types that are checked either through is, as or checked mode checks.
- Iterable<DartType> get isChecks;
+ Iterable<ResolutionDartType> get isChecks;
/// Registers that [type] is checked in this universe. The unaliased type is
/// returned.
- DartType registerIsCheck(DartType type);
+ ResolutionDartType registerIsCheck(ResolutionDartType type);
/// All directly instantiated types, that is, the types of the directly
/// instantiated classes.
// TODO(johnniwinther): Improve semantic precision.
- Iterable<DartType> get instantiatedTypes;
+ Iterable<ResolutionDartType> get instantiatedTypes;
}
abstract class ResolutionWorldBuilder implements WorldBuilder, OpenWorld {
@@ -213,7 +214,7 @@
/// The type and kind of an instantiation registered through
/// `ResolutionWorldBuilder.registerTypeInstantiation`.
class Instance {
- final InterfaceType type;
+ final ResolutionInterfaceType type;
final Instantiation kind;
final bool isRedirection;
@@ -314,8 +315,8 @@
Map<ConstructorElement, Set<Instance>> instantiationMap;
/// Register [type] as the instantiation [kind] using [constructor].
- void addInstantiation(
- ConstructorElement constructor, InterfaceType type, Instantiation kind,
+ void addInstantiation(ConstructorElement constructor,
+ ResolutionInterfaceType type, Instantiation kind,
{bool isRedirection: false}) {
instantiationMap ??= <ConstructorElement, Set<Instance>>{};
instantiationMap
@@ -422,7 +423,7 @@
/// Fields set.
final Set<Element> fieldSetters = new Set<Element>();
- final Set<DartType> isChecks = new Set<DartType>();
+ final Set<ResolutionDartType> isChecks = new Set<ResolutionDartType>();
/**
* Set of (live) [:call:] methods whose signatures reference type variables.
@@ -525,8 +526,8 @@
///
/// See [directlyInstantiatedClasses].
// TODO(johnniwinther): Improve semantic precision.
- Iterable<DartType> get instantiatedTypes {
- Set<InterfaceType> types = new Set<InterfaceType>();
+ Iterable<ResolutionDartType> get instantiatedTypes {
+ Set<ResolutionInterfaceType> types = new Set<ResolutionInterfaceType>();
getInstantiationMap().forEach((_, InstantiationInfo info) {
if (info.instantiationMap != null) {
for (Set<Instance> instances in info.instantiationMap.values) {
@@ -555,7 +556,7 @@
// subclass and through subtype instantiated types/classes.
// TODO(johnniwinther): Support unknown type arguments for generic types.
void registerTypeInstantiation(
- InterfaceType type, ClassUsedCallback classUsed,
+ ResolutionInterfaceType type, ClassUsedCallback classUsed,
{ConstructorElement constructor,
bool byMirrors: false,
bool isRedirection: false}) {
@@ -589,7 +590,7 @@
// instead.
if (_implementedClasses.add(cls)) {
classUsed(cls, _getClassUsage(cls).implement());
- cls.allSupertypes.forEach((InterfaceType supertype) {
+ cls.allSupertypes.forEach((ResolutionInterfaceType supertype) {
if (_implementedClasses.add(supertype.element)) {
classUsed(
supertype.element, _getClassUsage(supertype.element).implement());
@@ -644,7 +645,7 @@
.addInstantiation(constructor, instance.type, instance.kind);
} else {
ConstructorElement target = constructor.effectiveTarget;
- InterfaceType targetType =
+ ResolutionInterfaceType targetType =
constructor.computeEffectiveTargetType(instance.type);
Instantiation kind = Instantiation.DIRECTLY_INSTANTIATED;
if (target.enclosingClass.isAbstract) {
@@ -724,7 +725,7 @@
return constraints.addReceiverConstraint(mask);
}
- DartType registerIsCheck(DartType type) {
+ ResolutionDartType registerIsCheck(ResolutionDartType type) {
type.computeUnaliased(_resolution);
type = type.unaliased;
// Even in checked mode, type annotations for return type and argument
@@ -976,7 +977,7 @@
ClassHierarchyNode node = _ensureClassHierarchyNode(cls);
ClassSet classSet = new ClassSet(node);
- for (InterfaceType type in cls.allSupertypes) {
+ for (ResolutionInterfaceType type in cls.allSupertypes) {
// TODO(johnniwinther): Optimization: Avoid adding [cls] to
// superclasses.
ClassSet subtypeSet = _ensureClassSet(type.element);
@@ -1051,7 +1052,7 @@
Set<Element> typesImplementedBySubclassesOfCls =
typesImplementedBySubclasses.putIfAbsent(
superclass, () => new Set<ClassElement>());
- for (DartType current in cls.allSupertypes) {
+ for (ResolutionDartType current in cls.allSupertypes) {
typesImplementedBySubclassesOfCls.add(current.element);
}
superclass = superclass.superclass;
@@ -1103,6 +1104,15 @@
///
/// This adds additional access to liveness of selectors and elements.
abstract class CodegenWorldBuilder implements WorldBuilder {
+ /// Opens this world builder using [closedWorld] as the known superset of
+ /// possible runtime entities.
+ void open(ClosedWorld closedWorld);
+
+ /// Calls [f] with every instance field, together with its declarer, in an
+ /// instance of [cls].
+ void forEachInstanceField(
+ ClassEntity cls, void f(ClassEntity declarer, FieldEntity field));
+
void forEachInvokedName(
f(String name, Map<Selector, SelectorConstraints> selectors));
@@ -1134,6 +1144,7 @@
class CodegenWorldBuilderImpl implements CodegenWorldBuilder {
final Backend _backend;
+ ClosedWorld __world;
/// The set of all directly instantiated classes, that is, classes with a
/// generative constructor that has been called directly and not only through
@@ -1149,7 +1160,8 @@
/// directly instantiated classes.
///
/// See [_directlyInstantiatedClasses].
- final Set<DartType> _instantiatedTypes = new Set<DartType>();
+ final Set<ResolutionDartType> _instantiatedTypes =
+ new Set<ResolutionDartType>();
/// Classes implemented by directly instantiated classes.
final Set<ClassElement> _implementedClasses = new Set<ClassElement>();
@@ -1196,15 +1208,31 @@
final Map<String, Set<_MemberUsage>> _instanceFunctionsByName =
<String, Set<_MemberUsage>>{};
- final Set<DartType> isChecks = new Set<DartType>();
+ final Set<ResolutionDartType> isChecks = new Set<ResolutionDartType>();
final SelectorConstraintsStrategy selectorConstraintsStrategy;
CodegenWorldBuilderImpl(this._backend, this.selectorConstraintsStrategy);
- // TODO(johnniwinther): Remove this hack:
- ClosedWorld get _world =>
- _backend.compiler.resolverWorld.closedWorldForTesting;
+ void open(ClosedWorld closedWorld) {
+ assert(invariant(NO_LOCATION_SPANNABLE, __world == null,
+ message: "CodegenWorldBuilder has already been opened."));
+ __world = closedWorld;
+ }
+
+ ClosedWorld get _world {
+ assert(invariant(NO_LOCATION_SPANNABLE, __world != null,
+ message: "CodegenWorldBuilder has not been opened."));
+ return __world;
+ }
+
+ /// Calls [f] with every instance field, together with its declarer, in an
+ /// instance of [cls].
+ void forEachInstanceField(
+ ClassElement cls, void f(ClassEntity declarer, FieldEntity field)) {
+ cls.implementation
+ .forEachInstanceField(f, includeSuperAndInjectedMembers: true);
+ }
Iterable<ClassElement> get processedClasses => _processedClasses.keys
.where((cls) => _processedClasses[cls].isInstantiated);
@@ -1222,7 +1250,7 @@
///
/// See [directlyInstantiatedClasses].
// TODO(johnniwinther): Improve semantic precision.
- Iterable<DartType> get instantiatedTypes => _instantiatedTypes;
+ Iterable<ResolutionDartType> get instantiatedTypes => _instantiatedTypes;
/// Register [type] as (directly) instantiated.
///
@@ -1231,7 +1259,7 @@
// subclass and through subtype instantiated types/classes.
// TODO(johnniwinther): Support unknown type arguments for generic types.
void registerTypeInstantiation(
- InterfaceType type, ClassUsedCallback classUsed,
+ ResolutionInterfaceType type, ClassUsedCallback classUsed,
{bool byMirrors: false}) {
ClassElement cls = type.element;
bool isNative = _backend.isNative(cls);
@@ -1256,7 +1284,7 @@
// include the type arguments.
if (_implementedClasses.add(cls)) {
classUsed(cls, _getClassUsage(cls).implement());
- cls.allSupertypes.forEach((InterfaceType supertype) {
+ cls.allSupertypes.forEach((ResolutionInterfaceType supertype) {
if (_implementedClasses.add(supertype.element)) {
classUsed(
supertype.element, _getClassUsage(supertype.element).implement());
@@ -1379,7 +1407,7 @@
_invokedSetters.forEach(f);
}
- DartType registerIsCheck(DartType type) {
+ ResolutionDartType registerIsCheck(ResolutionDartType type) {
type = type.unaliased;
// Even in checked mode, type annotations for return type and argument
// types do not imply type checks, so there should never be a check
diff --git a/pkg/compiler/lib/src/use_unused_api.dart b/pkg/compiler/lib/src/use_unused_api.dart
index cff74c4..de79fb6 100644
--- a/pkg/compiler/lib/src/use_unused_api.dart
+++ b/pkg/compiler/lib/src/use_unused_api.dart
@@ -17,7 +17,7 @@
import 'constants/expressions.dart' as constants;
import 'constants/values.dart' as constants;
import 'dart2js.dart' as dart2js;
-import 'dart_types.dart' as dart_types;
+import 'elements/resolution_types.dart' as dart_types;
import 'deferred_load.dart' as deferred;
import 'diagnostics/source_span.dart' as diagnostics;
import 'elements/elements.dart' as elements;
diff --git a/pkg/compiler/lib/src/world.dart b/pkg/compiler/lib/src/world.dart
index 490390d..50c708f 100644
--- a/pkg/compiler/lib/src/world.dart
+++ b/pkg/compiler/lib/src/world.dart
@@ -9,7 +9,7 @@
import 'common.dart';
import 'constants/constant_system.dart';
import 'core_types.dart' show CommonElements;
-import 'dart_types.dart';
+import 'elements/resolution_types.dart';
import 'elements/elements.dart'
show
ClassElement,
@@ -252,7 +252,7 @@
FunctionSet get allFunctions;
/// Returns `true` if the field [element] is known to be effectively final.
- bool fieldNeverChanges(Element element);
+ bool fieldNeverChanges(MemberElement element);
/// Extends the receiver type [mask] for calling [selector] to take live
/// `noSuchMethod` handlers into account.
@@ -263,7 +263,7 @@
/// Returns the single [Element] that matches a call to [selector] on a
/// receiver of type [mask]. If multiple targets exist, `null` is returned.
- Element locateSingleElement(Selector selector, TypeMask mask);
+ MemberElement locateSingleElement(Selector selector, TypeMask mask);
/// Returns the single field that matches a call to [selector] on a
/// receiver of type [mask]. If multiple targets exist or the single target
@@ -298,6 +298,9 @@
/// Interface for computing side effects and uses of elements. This is used
/// during type inference to compute the [ClosedWorld] for code generation.
abstract class ClosedWorldRefiner {
+ /// The closed world being refined.
+ ClosedWorld get closedWorld;
+
/// Registers the side [effects] of executing [element].
void registerSideEffects(Element element, SideEffects effects);
@@ -416,6 +419,9 @@
_allFunctions = functionSetBuilder.close(this);
}
+ @override
+ ClosedWorld get closedWorld => this;
+
/// Cache of [FlatTypeMask]s grouped by the 8 possible values of the
/// `FlatTypeMask.flags` property.
final List<Map<ClassElement, TypeMask>> _canonicalizedTypeMasks =
@@ -723,7 +729,7 @@
List<ClassElement> commonSupertypes = <ClassElement>[];
OUTER:
- for (Link<DartType> link = typeSet[depth];
+ for (Link<ResolutionDartType> link = typeSet[depth];
link.head.element != commonElements.objectClass;
link = link.tail) {
ClassElement cls = link.head.element;
@@ -902,7 +908,7 @@
ClassSet classSet = getClassSet(base);
ClassHierarchyNode node = classSet.node;
if (query == ClassQuery.EXACT) {
- return node.isDirectlyInstantiated && !hasConcreteMatch(base, selector);
+ return node.isExplicitlyInstantiated && !hasConcreteMatch(base, selector);
} else if (query == ClassQuery.SUBCLASS) {
return subclassesNeedNoSuchMethod(node);
} else {
@@ -936,7 +942,7 @@
ClassHierarchyNode parentNode = getClassHierarchyNode(cls.superclass);
ClassHierarchyNode node =
_classHierarchyNodes[cls] = new ClassHierarchyNode(parentNode, cls);
- for (InterfaceType type in cls.allSupertypes) {
+ for (ResolutionInterfaceType type in cls.allSupertypes) {
ClassSet subtypeSet = getClassSet(type.element);
subtypeSet.addSubtype(node);
}
@@ -1007,7 +1013,7 @@
return functionsCalledInLoop.contains(element.declaration);
}
- bool fieldNeverChanges(Element element) {
+ bool fieldNeverChanges(MemberElement element) {
if (!element.isField) return false;
if (_backend.isNative(element)) {
// Some native fields are views of data that may be changed by operations.
diff --git a/pkg/dev_compiler/lib/js/amd/dart_sdk.js b/pkg/dev_compiler/lib/js/amd/dart_sdk.js
index bc1747a..a215552 100644
--- a/pkg/dev_compiler/lib/js/amd/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/amd/dart_sdk.js
@@ -52899,7 +52899,7 @@
});
js.JsArray = JsArray();
js._isBrowserType = function(o) {
- return o instanceof Blob || o instanceof Event || window.KeyRange && o instanceof KeyRange || window.IDBKeyRange && o instanceof IDBKeyRange || o instanceof ImageData || o instanceof Node || window.Int8Array && o instanceof Int8Array.__proto__ || o instanceof Window;
+ return o instanceof Object && (o instanceof Blob || o instanceof Event || window.KeyRange && o instanceof KeyRange || window.IDBKeyRange && o instanceof IDBKeyRange || o instanceof ImageData || o instanceof Node || window.Int8Array && o instanceof Int8Array.__proto__ || o instanceof Window);
};
dart.fn(js._isBrowserType, dynamicTobool$());
const _dartObj = Symbol('_dartObj');
diff --git a/pkg/dev_compiler/lib/js/common/dart_sdk.js b/pkg/dev_compiler/lib/js/common/dart_sdk.js
index 9e510b1..deef7b3 100644
--- a/pkg/dev_compiler/lib/js/common/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/common/dart_sdk.js
@@ -52899,7 +52899,7 @@
});
js.JsArray = JsArray();
js._isBrowserType = function(o) {
- return o instanceof Blob || o instanceof Event || window.KeyRange && o instanceof KeyRange || window.IDBKeyRange && o instanceof IDBKeyRange || o instanceof ImageData || o instanceof Node || window.Int8Array && o instanceof Int8Array.__proto__ || o instanceof Window;
+ return o instanceof Object && (o instanceof Blob || o instanceof Event || window.KeyRange && o instanceof KeyRange || window.IDBKeyRange && o instanceof IDBKeyRange || o instanceof ImageData || o instanceof Node || window.Int8Array && o instanceof Int8Array.__proto__ || o instanceof Window);
};
dart.fn(js._isBrowserType, dynamicTobool$());
const _dartObj = Symbol('_dartObj');
diff --git a/pkg/dev_compiler/lib/js/es6/dart_sdk.js b/pkg/dev_compiler/lib/js/es6/dart_sdk.js
index 89e4810..76961b9 100644
--- a/pkg/dev_compiler/lib/js/es6/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/es6/dart_sdk.js
@@ -52897,7 +52897,7 @@
});
js.JsArray = JsArray();
js._isBrowserType = function(o) {
- return o instanceof Blob || o instanceof Event || window.KeyRange && o instanceof KeyRange || window.IDBKeyRange && o instanceof IDBKeyRange || o instanceof ImageData || o instanceof Node || window.Int8Array && o instanceof Int8Array.__proto__ || o instanceof Window;
+ return o instanceof Object && (o instanceof Blob || o instanceof Event || window.KeyRange && o instanceof KeyRange || window.IDBKeyRange && o instanceof IDBKeyRange || o instanceof ImageData || o instanceof Node || window.Int8Array && o instanceof Int8Array.__proto__ || o instanceof Window);
};
dart.fn(js._isBrowserType, dynamicTobool());
const _dartObj = Symbol('_dartObj');
diff --git a/pkg/dev_compiler/lib/js/legacy/dart_sdk.js b/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
index e0639d0..23e0714 100644
--- a/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
+++ b/pkg/dev_compiler/lib/js/legacy/dart_sdk.js
@@ -52900,7 +52900,7 @@
});
js.JsArray = JsArray();
js._isBrowserType = function(o) {
- return o instanceof Blob || o instanceof Event || window.KeyRange && o instanceof KeyRange || window.IDBKeyRange && o instanceof IDBKeyRange || o instanceof ImageData || o instanceof Node || window.Int8Array && o instanceof Int8Array.__proto__ || o instanceof Window;
+ return o instanceof Object && (o instanceof Blob || o instanceof Event || window.KeyRange && o instanceof KeyRange || window.IDBKeyRange && o instanceof IDBKeyRange || o instanceof ImageData || o instanceof Node || window.Int8Array && o instanceof Int8Array.__proto__ || o instanceof Window);
};
dart.fn(js._isBrowserType, dynamicTobool$());
const _dartObj = Symbol('_dartObj');
diff --git a/pkg/dev_compiler/lib/src/analyzer/context.dart b/pkg/dev_compiler/lib/src/analyzer/context.dart
index bdf5d16..188f978 100644
--- a/pkg/dev_compiler/lib/src/analyzer/context.dart
+++ b/pkg/dev_compiler/lib/src/analyzer/context.dart
@@ -11,15 +11,11 @@
import 'package:analyzer/source/custom_resolver.dart';
import 'package:analyzer/source/package_map_resolver.dart';
import 'package:analyzer/src/context/builder.dart';
-import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl;
-import 'package:analyzer/src/dart/sdk/sdk.dart' show FolderBasedDartSdk;
-import 'package:analyzer/src/generated/engine.dart'
- show AnalysisEngine, AnalysisOptionsImpl;
+import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
import 'package:analyzer/src/generated/source.dart'
show DartUriResolver, SourceFactory, UriResolver;
import 'package:analyzer/src/summary/package_bundle_reader.dart'
show InSummaryUriResolver, SummaryDataStore;
-import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk;
import 'package:cli_util/cli_util.dart' show getSdkDir;
import 'package:path/path.dart' as path;
@@ -36,8 +32,7 @@
/// List of summary file paths.
final List<String> summaryPaths;
- /// Path to the dart-sdk. Null if `useMockSdk` is true or if the path couldn't
- /// be determined
+ /// Path to the dart-sdk, or `null` if the path couldn't be determined.
final String dartSdkPath;
/// Path to the dart-sdk summary. If this is set, it will be used in favor
@@ -50,10 +45,11 @@
AnalyzerOptions._(
{this.contextBuilderOptions,
- this.summaryPaths: const [],
+ List<String> summaryPaths,
String dartSdkPath,
this.customUrlMappings: const {}})
- : dartSdkPath = dartSdkPath ?? getSdkDir().path {
+ : dartSdkPath = dartSdkPath ?? getSdkDir().path,
+ summaryPaths = summaryPaths ?? const [] {
contextBuilderOptions.declaredVariables ??= const {};
}
@@ -61,8 +57,9 @@
{String dartSdkPath,
String dartSdkSummaryPath,
List<String> summaryPaths}) {
- var contextBuilderOptions = new ContextBuilderOptions();
- contextBuilderOptions.dartSdkSummaryPath = dartSdkSummaryPath;
+ var contextBuilderOptions = new ContextBuilderOptions()
+ ..defaultOptions = (new AnalysisOptionsImpl()..strongMode = true)
+ ..dartSdkSummaryPath = dartSdkSummaryPath;
return new AnalyzerOptions._(
contextBuilderOptions: contextBuilderOptions,
@@ -72,21 +69,22 @@
factory AnalyzerOptions.fromArguments(ArgResults args,
{String dartSdkSummaryPath, List<String> summaryPaths}) {
- var contextBuilderOptions = createContextBuilderOptions(args);
+ var contextBuilderOptions = createContextBuilderOptions(args,
+ strongMode: true, trackCacheDependencies: false);
- if (dartSdkSummaryPath != null)
- contextBuilderOptions.dartSdkSummaryPath = dartSdkSummaryPath;
- contextBuilderOptions.dartSdkSummaryPath ??=
- path.join(args['dart-sdk'], 'lib', '_internal', 'ddc_sdk.sum');
- if (contextBuilderOptions.dartSdkSummaryPath == 'build') {
- // For building the SDK, we explicitly set the path to none.
- contextBuilderOptions.dartSdkSummaryPath = null;
- }
+ var dartSdkPath = args['dart-sdk'] ?? getSdkDir().path;
+
+ dartSdkSummaryPath ??= contextBuilderOptions.dartSdkSummaryPath;
+ dartSdkSummaryPath ??=
+ path.join(dartSdkPath, 'lib', '_internal', 'ddc_sdk.sum');
+ // For building the SDK, we explicitly set the path to none.
+ if (dartSdkSummaryPath == 'build') dartSdkSummaryPath = null;
+ contextBuilderOptions.dartSdkSummaryPath = dartSdkSummaryPath;
return new AnalyzerOptions._(
contextBuilderOptions: contextBuilderOptions,
summaryPaths: summaryPaths ?? args['summary'] as List<String>,
- dartSdkPath: args['dart-sdk'],
+ dartSdkPath: dartSdkPath,
customUrlMappings: _parseUrlMappings(args['url-mapping']));
}
@@ -113,20 +111,8 @@
}
}
-/// Creates an analysis context that contains our restricted typing rules.
-AnalysisContextImpl createAnalysisContext() {
- var res = AnalysisEngine.instance.createAnalysisContext();
- res.analysisOptions = new AnalysisOptionsImpl()
- ..strongMode = true
- ..trackCacheDependencies = false;
- return res;
-}
-
/// Creates a SourceFactory configured by the [options].
///
-/// Use [options.useMockSdk] to specify the SDK mode, or use [sdkResolver]
-/// to entirely override the DartUriResolver.
-///
/// If supplied, [fileResolvers] will override the default `file:` and
/// `package:` URI resolvers.
SourceFactory createSourceFactory(AnalyzerOptions options,
@@ -168,20 +154,3 @@
return [new ResourceUriResolver(resourceProvider), packageResolver()];
}
-
-FolderBasedDartSdk _createFolderBasedDartSdk(String sdkPath) {
- var resourceProvider = PhysicalResourceProvider.INSTANCE;
- var sdk = new FolderBasedDartSdk(resourceProvider,
- resourceProvider.getFolder(sdkPath), /*useDart2jsPaths:*/ true);
- sdk.useSummary = true;
- sdk.analysisOptions = new AnalysisOptionsImpl()..strongMode = true;
- return sdk;
-}
-
-/// Creates a [DartUriResolver] that uses the SDK at the given [sdkPath].
-DartUriResolver createSdkPathResolver(String sdkSummaryPath, String sdkPath) {
- var sdk = (sdkSummaryPath != null)
- ? new SummaryBasedDartSdk(sdkSummaryPath, true)
- : _createFolderBasedDartSdk(sdkPath);
- return new DartUriResolver(sdk);
-}
diff --git a/pkg/dev_compiler/lib/src/compiler/command.dart b/pkg/dev_compiler/lib/src/compiler/command.dart
index 102f33a..ae46ce6 100644
--- a/pkg/dev_compiler/lib/src/compiler/command.dart
+++ b/pkg/dev_compiler/lib/src/compiler/command.dart
@@ -32,7 +32,7 @@
ArgResults argResults;
AnalyzerOptions analyzerOptions;
try {
- var parser = _argParser();
+ var parser = ddcArgParser();
if (args.contains('--$ignoreUnrecognizedFlagsFlag')) {
args = filterUnknownArguments(args, parser);
}
@@ -83,7 +83,7 @@
}
}
-ArgParser _argParser({bool hide: true}) {
+ArgParser ddcArgParser({bool hide: true}) {
var argParser = new ArgParser(allowTrailingOptions: true)
..addFlag('help',
abbr: 'h',
@@ -225,7 +225,7 @@
String get _usageMessage =>
'Dart Development Compiler compiles Dart into a JavaScript module.'
- '\n\n${_argParser(hide: !_verbose).usage}';
+ '\n\n${ddcArgParser(hide: !_verbose).usage}';
void _usageException(String message) {
throw new UsageException(message, _usageMessage);
diff --git a/pkg/dev_compiler/lib/src/compiler/compiler.dart b/pkg/dev_compiler/lib/src/compiler/compiler.dart
index 62921bd..5a84af3 100644
--- a/pkg/dev_compiler/lib/src/compiler/compiler.dart
+++ b/pkg/dev_compiler/lib/src/compiler/compiler.dart
@@ -9,9 +9,15 @@
import 'package:analyzer/analyzer.dart'
show AnalysisError, CompilationUnit, ErrorSeverity;
import 'package:analyzer/file_system/file_system.dart' show ResourceProvider;
+import 'package:analyzer/file_system/physical_file_system.dart'
+ show PhysicalResourceProvider;
+import 'package:analyzer/src/context/builder.dart' show ContextBuilder;
+import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl;
import 'package:analyzer/src/generated/engine.dart'
show AnalysisContext, AnalysisEngine;
-import 'package:analyzer/src/generated/source.dart' show DartUriResolver;
+import 'package:analyzer/src/generated/sdk.dart' show DartSdkManager;
+import 'package:analyzer/src/generated/source.dart'
+ show ContentCache, DartUriResolver;
import 'package:analyzer/src/generated/source_io.dart'
show Source, SourceKind, UriResolver;
import 'package:analyzer/src/summary/package_bundle_reader.dart'
@@ -23,12 +29,7 @@
import 'package:path/path.dart' as path;
import 'package:source_maps/source_maps.dart';
-import '../analyzer/context.dart'
- show
- AnalyzerOptions,
- createAnalysisContext,
- createSdkPathResolver,
- createSourceFactory;
+import '../analyzer/context.dart' show AnalyzerOptions, createSourceFactory;
import '../js_ast/js_ast.dart' as JS;
import 'code_generator.dart' show CodeGenerator;
import 'error_helpers.dart' show errorSeverity, formatError, sortErrors;
@@ -59,25 +60,28 @@
final SummaryDataStore summaryData;
final ExtensionTypeSet _extensionTypes;
- ModuleCompiler.withContext(AnalysisContext context, this.summaryData)
+ ModuleCompiler._(AnalysisContext context, this.summaryData)
: context = context,
- _extensionTypes = new ExtensionTypeSet(context) {
- if (!context.analysisOptions.strongMode) {
- throw new ArgumentError('AnalysisContext must be strong mode');
- }
- if (!context.sourceFactory.dartSdk.context.analysisOptions.strongMode) {
- throw new ArgumentError('AnalysisContext must have strong mode SDK');
- }
- }
+ _extensionTypes = new ExtensionTypeSet(context);
factory ModuleCompiler(AnalyzerOptions options,
- {DartUriResolver sdkResolver,
- ResourceProvider resourceProvider,
+ {ResourceProvider resourceProvider,
+ String analysisRoot,
List<UriResolver> fileResolvers}) {
+ // TODO(danrubel): refactor with analyzer CLI into analyzer common code
AnalysisEngine.instance.processRequiredPlugins();
- sdkResolver ??=
- createSdkPathResolver(options.dartSdkSummaryPath, options.dartSdkPath);
+ resourceProvider ??= PhysicalResourceProvider.INSTANCE;
+ analysisRoot ??= path.current;
+
+ var contextBuilder = new ContextBuilder(resourceProvider,
+ new DartSdkManager(options.dartSdkPath, true), new ContentCache(),
+ options: options.contextBuilderOptions);
+
+ var analysisOptions = contextBuilder.getAnalysisOptions(analysisRoot);
+ var sdk = contextBuilder.findSdk(null, analysisOptions);
+
+ var sdkResolver = new DartUriResolver(sdk);
// Read the summaries.
var summaryData =
@@ -89,7 +93,9 @@
summaryData: summaryData,
resourceProvider: resourceProvider);
- var context = createAnalysisContext();
+ var context =
+ AnalysisEngine.instance.createAnalysisContext() as AnalysisContextImpl;
+ context.analysisOptions = analysisOptions;
context.sourceFactory = srcFactory;
context.typeProvider = sdkResolver.dartSdk.context.typeProvider;
context.resultProvider =
@@ -101,7 +107,14 @@
context.declaredVariables.define('dart.library.html', 'true');
context.declaredVariables.define('dart.library.io', 'false');
- return new ModuleCompiler.withContext(context, summaryData);
+ if (!context.analysisOptions.strongMode) {
+ throw new ArgumentError('AnalysisContext must be strong mode');
+ }
+ if (!context.sourceFactory.dartSdk.context.analysisOptions.strongMode) {
+ throw new ArgumentError('AnalysisContext must have strong mode SDK');
+ }
+
+ return new ModuleCompiler._(context, summaryData);
}
bool _isFatalError(AnalysisError e, CompilerOptions options) {
diff --git a/pkg/dev_compiler/test/all_tests.dart b/pkg/dev_compiler/test/all_tests.dart
index 71d48ac..963e55c 100644
--- a/pkg/dev_compiler/test/all_tests.dart
+++ b/pkg/dev_compiler/test/all_tests.dart
@@ -11,9 +11,11 @@
import 'closure/closure_type_test.dart' as closure_type_test;
import 'codegen_test.dart' as codegen_test;
import 'js/builder_test.dart' as builder_test;
+import 'options/options_test.dart' as options_test;
import 'worker/worker_test.dart' as worker_test;
void main() {
+ group('options', options_test.main);
group('codegen', () => codegen_test.main([]));
group('closure', () {
closure_annotation_test.main();
diff --git a/pkg/dev_compiler/test/codegen_test.dart b/pkg/dev_compiler/test/codegen_test.dart
index 4c4446c..f33df56 100644
--- a/pkg/dev_compiler/test/codegen_test.dart
+++ b/pkg/dev_compiler/test/codegen_test.dart
@@ -79,8 +79,9 @@
.where((p) => p.endsWith('.sum'))
.toList();
- var sharedCompiler = new ModuleCompiler(new AnalyzerOptions.basic(
- dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths));
+ var sharedCompiler = new ModuleCompiler(
+ new AnalyzerOptions.basic(
+ dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths));
var testDirs = [
'language',
diff --git a/pkg/dev_compiler/test/options/analysis_options.yaml b/pkg/dev_compiler/test/options/analysis_options.yaml
new file mode 100644
index 0000000..983e534
--- /dev/null
+++ b/pkg/dev_compiler/test/options/analysis_options.yaml
@@ -0,0 +1,4 @@
+analyzer:
+ strong-mode: true
+ errors:
+ undefined_class: ignore
diff --git a/pkg/dev_compiler/test/options/analysis_options_2.yaml b/pkg/dev_compiler/test/options/analysis_options_2.yaml
new file mode 100644
index 0000000..d91a15a
--- /dev/null
+++ b/pkg/dev_compiler/test/options/analysis_options_2.yaml
@@ -0,0 +1,4 @@
+analyzer:
+ strong-mode: true
+ errors:
+ duplicate_definition: ignore
diff --git a/pkg/dev_compiler/test/options/options_test.dart b/pkg/dev_compiler/test/options/options_test.dart
new file mode 100644
index 0000000..5fff692
--- /dev/null
+++ b/pkg/dev_compiler/test/options/options_test.dart
@@ -0,0 +1,82 @@
+// Copyright (c) 2016, 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 file.
+
+import 'dart:io';
+import 'package:analyzer/analyzer.dart';
+import 'package:analyzer/src/command_line/arguments.dart';
+import 'package:analyzer/src/summary/summary_sdk.dart';
+import 'package:path/path.dart' as path;
+import 'package:test/test.dart';
+
+import '../../lib/src/analyzer/context.dart';
+import '../../lib/src/compiler/command.dart';
+import '../../lib/src/compiler/compiler.dart';
+import '../testing.dart' show repoDirectory, testDirectory;
+
+/// The `test/options` directory.
+final optionsDir = path.join(testDirectory, 'options');
+
+/// Summary file for testing.
+final sdkSummaryFile = path.join(repoDirectory, 'lib', 'sdk', 'ddc_sdk.sum');
+
+final sdkSummaryArgs = ['--$sdkSummaryPathOption', sdkSummaryFile];
+
+main() {
+ test('basic', () {
+ var options = new AnalyzerOptions.basic();
+ var compiler = new ModuleCompiler(options, analysisRoot: optionsDir);
+ var processors = compiler.context.analysisOptions.errorProcessors;
+ expect(processors, hasLength(1));
+ expect(processors[0].code, CompileTimeErrorCode.UNDEFINED_CLASS.name);
+ });
+
+ test('basic sdk summary', () {
+ expect(new File(sdkSummaryFile).existsSync(), isTrue);
+ var options = new AnalyzerOptions.basic(dartSdkSummaryPath: sdkSummaryFile);
+ var compiler = new ModuleCompiler(options, analysisRoot: optionsDir);
+ var context = compiler.context;
+ var sdk = context.sourceFactory.dartSdk;
+ expect(sdk, new isInstanceOf<SummaryBasedDartSdk>());
+ var processors = context.analysisOptions.errorProcessors;
+ expect(processors, hasLength(1));
+ expect(processors[0].code, CompileTimeErrorCode.UNDEFINED_CLASS.name);
+ });
+
+ test('fromArgs', () {
+ var args = <String>[];
+ //TODO(danrubel) remove sdkSummaryArgs once all SDKs have summary file
+ args.addAll(sdkSummaryArgs);
+ var argResults = ddcArgParser().parse(args);
+ var options = new AnalyzerOptions.fromArguments(argResults);
+ var compiler = new ModuleCompiler(options, analysisRoot: optionsDir);
+ var processors = compiler.context.analysisOptions.errorProcessors;
+ expect(processors, hasLength(1));
+ expect(processors[0].code, CompileTimeErrorCode.UNDEFINED_CLASS.name);
+ });
+
+ test('fromArgs options file 2', () {
+ var optionsFile2 = path.join(optionsDir, 'analysis_options_2.yaml');
+ expect(new File(optionsFile2).existsSync(), isTrue);
+ var args = <String>['--$analysisOptionsFileOption', optionsFile2];
+ //TODO(danrubel) remove sdkSummaryArgs once all SDKs have summary file
+ args.addAll(sdkSummaryArgs);
+ var argResults = ddcArgParser().parse(args);
+ var options = new AnalyzerOptions.fromArguments(argResults);
+ var compiler = new ModuleCompiler(options, analysisRoot: optionsDir);
+ var processors = compiler.context.analysisOptions.errorProcessors;
+ expect(processors, hasLength(1));
+ expect(processors[0].code, CompileTimeErrorCode.DUPLICATE_DEFINITION.name);
+ });
+
+ test('fromArgs options flag', () {
+ var args = <String>['--$enableStrictCallChecksFlag'];
+ //TODO(danrubel) remove sdkSummaryArgs once all SDKs have summary file
+ args.addAll(sdkSummaryArgs);
+ var argResults = ddcArgParser().parse(args);
+ var options = new AnalyzerOptions.fromArguments(argResults);
+ var compiler = new ModuleCompiler(options, analysisRoot: optionsDir);
+ var analysisOptions = compiler.context.analysisOptions;
+ expect(analysisOptions.enableStrictCallChecks, isTrue);
+ });
+}
diff --git a/pkg/dev_compiler/tool/input_sdk/lib/js/dart2js/js_dart2js.dart b/pkg/dev_compiler/tool/input_sdk/lib/js/dart2js/js_dart2js.dart
index 3fc25ad..ae590ad 100644
--- a/pkg/dev_compiler/tool/input_sdk/lib/js/dart2js/js_dart2js.dart
+++ b/pkg/dev_compiler/tool/input_sdk/lib/js/dart2js/js_dart2js.dart
@@ -431,7 +431,12 @@
}
}
+// Cross frame objects should not be considered browser types.
+// We include the the instanceof Object test to filter out cross frame objects
+// on FireFox. Surprisingly on FireFox the instanceof Window test succeeds for
+// cross frame windows while the instanceof Object test fails.
bool _isBrowserType(o) => JS('bool',
+ '# instanceof Object && ('
'# instanceof Blob || '
'# instanceof Event || '
'(window.KeyRange && # instanceof KeyRange) || '
@@ -440,7 +445,7 @@
'# instanceof Node || '
// Int8Array.__proto__ is TypedArray.
'(window.Int8Array && # instanceof Int8Array.__proto__) || '
- '# instanceof Window', o, o, o, o, o, o, o, o);
+ '# instanceof Window)', o, o, o, o, o, o, o, o, o);
class _DartObject {
final _dartObj;
diff --git a/pkg/dev_compiler/web/web_command.dart b/pkg/dev_compiler/web/web_command.dart
index 3462633..1af52ce 100644
--- a/pkg/dev_compiler/web/web_command.dart
+++ b/pkg/dev_compiler/web/web_command.dart
@@ -18,7 +18,6 @@
import 'package:analyzer/file_system/memory_file_system.dart'
show MemoryResourceProvider;
import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl;
-import 'package:analyzer/src/generated/source.dart' show DartUriResolver;
import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
import 'package:analyzer/src/summary/package_bundle_reader.dart'
show
@@ -27,7 +26,6 @@
InputPackagesResultProvider,
InSummarySource;
import 'package:analyzer/src/dart/resolver/scope.dart' show Scope;
-import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk;
import 'package:args/command_runner.dart';
@@ -95,13 +93,12 @@
CompileModule setUpCompile(List<int> sdkBytes, List<List<int>> summaryBytes,
List<String> summaryUrls) {
- var resourceProvider = new MemoryResourceProvider();
- var resourceUriResolver = new ResourceUriResolver(resourceProvider);
+ var dartSdkSummaryPath = '/dart-sdk/lib/_internal/web_sdk.sum';
- var packageBundle = new PackageBundle.fromBuffer(sdkBytes);
- var webDartSdk = new SummaryBasedDartSdk.fromBundle(
- true, packageBundle, resourceProvider);
- var sdkResolver = new DartUriResolver(webDartSdk);
+ var resourceProvider = new MemoryResourceProvider()
+ ..newFileWithBytes(dartSdkSummaryPath, sdkBytes);
+
+ var resourceUriResolver = new ResourceUriResolver(resourceProvider);
var summaryDataStore = new SummaryDataStore([]);
for (var i = 0; i < summaryBytes.length; i++) {
@@ -116,8 +113,9 @@
var fileResolvers = [summaryResolver, resourceUriResolver];
var compiler = new ModuleCompiler(
- new AnalyzerOptions.basic(dartSdkPath: '/dart-sdk'),
- sdkResolver: sdkResolver,
+ new AnalyzerOptions.basic(
+ dartSdkPath: '/dart-sdk', dartSdkSummaryPath: dartSdkSummaryPath),
+ analysisRoot: '/web-compile-root',
fileResolvers: fileResolvers,
resourceProvider: resourceProvider);
diff --git a/pkg/front_end/tool/perf.dart b/pkg/front_end/tool/perf.dart
index 7cd3a49..fb06d92 100644
--- a/pkg/front_end/tool/perf.dart
+++ b/pkg/front_end/tool/perf.dart
@@ -28,7 +28,7 @@
import 'package:front_end/src/scanner/reader.dart';
import 'package:front_end/src/scanner/scanner.dart';
import 'package:front_end/src/scanner/token.dart';
-import 'package:kernel/kernel.dart';
+import 'package:kernel/kernel.dart' hide Source;
import 'package:package_config/discovery.dart';
main(List<String> args) async {
diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md
index 71b7f33..a016fed 100644
--- a/pkg/kernel/binary.md
+++ b/pkg/kernel/binary.md
@@ -59,19 +59,20 @@
UInt index; // Index into the StringTable strings.
}
-type LineStarts {
+type Source {
+ String source;
// Line starts are delta-encoded (they are encoded as line lengths). The list
// [0, 10, 25, 32, 42] is encoded as [0, 10, 15, 7, 10].
List<Uint> lineStarts;
}
-type UriLineStarts {
+type UriSource {
List<String> uris;
- LineStarts[uris.length] lineStarts;
+ Source[uris.length] source;
}
type UriReference {
- UInt index; // Index into the UriLineStarts uris.
+ UInt index; // Index into the UriSource uris.
}
type FileOffset {
@@ -93,7 +94,7 @@
type ProgramFile {
MagicWord magic = 0x90ABCDEF;
StringTable strings;
- UriLineStarts lineStartsMap;
+ UriSource sourceMap;
List<Library> libraries;
LibraryProcedureReference mainMethod;
}
diff --git a/pkg/kernel/lib/analyzer/ast_from_analyzer.dart b/pkg/kernel/lib/analyzer/ast_from_analyzer.dart
index 25add69..e232b29 100644
--- a/pkg/kernel/lib/analyzer/ast_from_analyzer.dart
+++ b/pkg/kernel/lib/analyzer/ast_from_analyzer.dart
@@ -400,9 +400,10 @@
return _typeBuilder.buildList(node.arguments);
}
- List<ast.TypeParameter> buildOptionalTypeParameterList(
- TypeParameterList node) {
+ List<ast.TypeParameter> buildOptionalTypeParameterList(TypeParameterList node,
+ {bool strongModeOnly: false}) {
if (node == null) return <ast.TypeParameter>[];
+ if (strongModeOnly && !strongMode) return <ast.TypeParameter>[];
return node.typeParameters.map(buildTypeParameter).toList();
}
@@ -431,10 +432,12 @@
// Initialize type parameters in two passes: put them into scope,
// and compute the bounds afterwards while they are all in scope.
var typeParameters = <ast.TypeParameter>[];
- for (var parameter in element.typeParameters) {
- var parameterNode = new ast.TypeParameter(parameter.name);
- typeParameters.add(parameterNode);
- localTypeParameters[parameter] = parameterNode;
+ if (strongMode || element is ConstructorElement) {
+ for (var parameter in element.typeParameters) {
+ var parameterNode = new ast.TypeParameter(parameter.name);
+ typeParameters.add(parameterNode);
+ localTypeParameters[parameter] = parameterNode;
+ }
}
for (int i = 0; i < typeParameters.length; ++i) {
var parameter = element.typeParameters[i];
@@ -1280,8 +1283,9 @@
return new ast.FunctionDeclaration(
scope.makeVariableDeclaration(element),
scope.buildFunctionNode(expression.parameters, expression.body,
- typeParameters:
- scope.buildOptionalTypeParameterList(expression.typeParameters),
+ typeParameters: scope.buildOptionalTypeParameterList(
+ expression.typeParameters,
+ strongModeOnly: true),
returnType: declaration.returnType));
}
@@ -1475,8 +1479,9 @@
ast.Expression visitFunctionExpression(FunctionExpression node) {
return new ast.FunctionExpression(scope.buildFunctionNode(
node.parameters, node.body,
- typeParameters:
- scope.buildOptionalTypeParameterList(node.typeParameters),
+ typeParameters: scope.buildOptionalTypeParameterList(
+ node.typeParameters,
+ strongModeOnly: true),
inferredReturnType: scope.getInferredReturnType(node)));
}
@@ -1506,10 +1511,14 @@
}
ast.Arguments buildArgumentsForInvocation(InvocationExpression node) {
- return buildArguments(node.argumentList,
- explicitTypeArguments: node.typeArguments,
- inferTypeArguments: () =>
- scope.getInferredInvocationTypeArguments(node));
+ if (scope.strongMode) {
+ return buildArguments(node.argumentList,
+ explicitTypeArguments: node.typeArguments,
+ inferTypeArguments: () =>
+ scope.getInferredInvocationTypeArguments(node));
+ } else {
+ return buildArguments(node.argumentList);
+ }
}
static final ast.Name callName = new ast.Name('call');
@@ -2097,6 +2106,12 @@
return convertType(type, null);
}
+ /// True if [parameter] should not be reified, because spec mode does not
+ /// currently reify generic method type parameters.
+ bool isUnreifiedTypeParameter(TypeParameterElement parameter) {
+ return !scope.strongMode && parameter.enclosingElement is! ClassElement;
+ }
+
/// Converts [type] to an [ast.DartType], while replacing unbound type
/// variables with 'dynamic'.
///
@@ -2106,6 +2121,9 @@
ast.DartType convertType(
DartType type, List<TypeParameterElement> boundVariables) {
if (type is TypeParameterType) {
+ if (isUnreifiedTypeParameter(type.element)) {
+ return const ast.DynamicType();
+ }
if (boundVariables == null || boundVariables.contains(type)) {
var typeParameter = scope.getTypeParameterReference(type.element);
if (!scope.allowClassTypeParameters &&
@@ -2214,6 +2232,9 @@
typeParameter.parent is ast.Class) {
return const ast.InvalidType();
}
+ if (isUnreifiedTypeParameter(element)) {
+ return const ast.DynamicType();
+ }
return new ast.TypeParameterType(typeParameter);
case ElementKind.COMPILATION_UNIT:
@@ -2698,9 +2719,9 @@
returnType: node.returnType,
inferredReturnType: scope.buildType(
resolutionMap.elementDeclaredByMethodDeclaration(node).returnType),
- typeParameters:
- scope.buildOptionalTypeParameterList(node.typeParameters))
- ..parent = procedure;
+ typeParameters: scope.buildOptionalTypeParameterList(
+ node.typeParameters,
+ strongModeOnly: true))..parent = procedure;
handleNativeBody(node.body);
}
@@ -2725,9 +2746,9 @@
procedure.function = scope.buildFunctionNode(
function.parameters, function.body,
returnType: node.returnType,
- typeParameters:
- scope.buildOptionalTypeParameterList(function.typeParameters))
- ..parent = procedure;
+ typeParameters: scope.buildOptionalTypeParameterList(
+ function.typeParameters,
+ strongModeOnly: true))..parent = procedure;
handleNativeBody(function.body);
}
diff --git a/pkg/kernel/lib/analyzer/loader.dart b/pkg/kernel/lib/analyzer/loader.dart
index 4fb962e..43a1b3d 100644
--- a/pkg/kernel/lib/analyzer/loader.dart
+++ b/pkg/kernel/lib/analyzer/loader.dart
@@ -120,7 +120,7 @@
var uri = applicationRoot.relativeUri(element.source.uri);
return repository.getLibraryReference(uri)
..name ??= getLibraryName(element)
- ..fileUri = "file://${element.source.fullName}";
+ ..fileUri = '${element.source.uri}';
}
void _buildTopLevelMember(
@@ -268,7 +268,7 @@
_classes[element] = classNode = new ast.Class(
name: element.name,
isAbstract: element.isAbstract,
- fileUri: "file://${element.source.fullName}");
+ fileUri: '${element.source.uri}');
classNode.level = ast.ClassLevel.Temporary;
var library = getLibraryReference(element.library);
library.addClass(classNode);
@@ -332,7 +332,8 @@
isAbstract: true,
typeParameters: freshParameters.freshTypeParameters,
supertype: freshParameters.substituteSuper(supertype),
- mixedInType: freshParameters.substituteSuper(mixinType));
+ mixedInType: freshParameters.substituteSuper(mixinType),
+ fileUri: classNode.fileUri);
mixinClass.level = ast.ClassLevel.Type;
supertype = new ast.Supertype(mixinClass,
classNode.typeParameters.map(makeTypeParameterType).toList());
@@ -445,7 +446,7 @@
isStatic: true,
isExternal: constructor.isExternal,
isConst: constructor.isConst,
- fileUri: "file://${element.source.fullName}");
+ fileUri: '${element.source.uri}');
}
return new ast.Constructor(scope.buildFunctionInterface(constructor),
name: _nameOfMember(element),
@@ -460,8 +461,7 @@
isFinal: variable.isFinal,
isConst: variable.isConst,
type: scope.buildType(variable.type),
- fileUri: "file://${element.source.fullName}")
- ..fileOffset = element.nameOffset;
+ fileUri: '${element.source.uri}')..fileOffset = element.nameOffset;
case ElementKind.METHOD:
case ElementKind.GETTER:
@@ -480,7 +480,7 @@
isAbstract: executable.isAbstract,
isStatic: executable.isStatic,
isExternal: executable.isExternal,
- fileUri: "file://${element.source.fullName}");
+ fileUri: '${element.source.uri}');
default:
throw 'Unexpected member kind: $element';
@@ -586,7 +586,7 @@
typeParameters: fresh.freshTypeParameters,
supertype: new ast.Supertype(superclass, superArgs),
mixedInType: new ast.Supertype(mixedInClass, mixinArgs),
- fileUri: mixedInClass.fileUri);
+ fileUri: library.fileUri);
result.level = ast.ClassLevel.Type;
library.addClass(result);
return result;
@@ -694,9 +694,15 @@
in libraryElement.units) {
var source = compilationUnitElement.source;
LineInfo lineInfo = context.computeLineInfo(source);
- program.uriToLineStarts["file://${source.fullName}"] =
- new List<int>.generate(lineInfo.lineCount, lineInfo.getOffsetOfLine,
- growable: false);
+ String sourceCode;
+ try {
+ sourceCode = context.getContents(source).data;
+ } catch (e) {
+ // The source's contents could not be accessed.
+ sourceCode = '';
+ }
+ program.uriToSource['${source.uri}'] =
+ new ast.Source(lineInfo.lineStarts, sourceCode);
}
}
return program;
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 71316b5..aaf08707 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -3504,17 +3504,17 @@
class Program extends TreeNode {
final List<Library> libraries;
- /// Map from a source file uri to a line-starts table.
+ /// Map from a source file uri to a line-starts table and source code.
/// Given a source file uri and a offset in that file one can translate
/// it to a line:column position in that file.
- final Map<String, List<int>> uriToLineStarts;
+ final Map<String, Source> uriToSource;
/// Reference to the main method in one of the libraries.
Procedure mainMethod;
- Program([List<Library> libraries, Map<String, List<int>> uriToLineStarts])
+ Program([List<Library> libraries, Map<String, Source> uriToSource])
: libraries = libraries ?? <Library>[],
- uriToLineStarts = uriToLineStarts ?? {} {
+ uriToSource = uriToSource ?? <String, Source>{} {
setParents(libraries, this);
}
@@ -3533,7 +3533,7 @@
/// Translates an offset to line and column numbers in the given file.
Location getLocation(String file, int offset) {
- List<int> lines = uriToLineStarts[file];
+ List<int> lines = uriToSource[file].lineStarts;
int low = 0, high = lines.length - 1;
while (low < high) {
int mid = high - ((high - low) >> 1); // Get middle, rounding up.
@@ -3651,3 +3651,10 @@
}
}
}
+
+class Source {
+ final List<int> lineStarts;
+ final String source;
+
+ Source(this.lineStarts, this.source);
+}
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index 39b1b98..0dee08d 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -177,7 +177,7 @@
'Magic number was: ${magic.toRadixString(16)}');
}
readStringTable();
- Map<String, List<int>> uriToLineStarts = readUriToLineStarts();
+ Map<String, Source> uriToSource = readUriToSource();
importTable.length = readUInt();
for (int i = 0; i < importTable.length; ++i) {
importTable[i] = new Library(null);
@@ -187,15 +187,17 @@
readLibrary();
}
var mainMethod = readMemberReference(allowNull: true);
- return new Program(importTable, uriToLineStarts)..mainMethod = mainMethod;
+ return new Program(importTable, uriToSource)
+ ..mainMethod = mainMethod;
}
- Map<String, List<int>> readUriToLineStarts() {
+ Map<String, Source> readUriToSource() {
readSourceUriTable();
int length = _sourceUriTable.length;
- Map<String, List<int>> uriToLineStarts = {};
+ Map<String, Source> uriToLineStarts = <String, Source>{};
for (int i = 0; i < length; ++i) {
String uri = _sourceUriTable[i];
+ String sourceCode = readStringEntry();
int lineCount = readUInt();
List<int> lineStarts = new List<int>(lineCount);
int previousLineStart = 0;
@@ -204,7 +206,7 @@
lineStarts[j] = lineStart;
previousLineStart = lineStart;
}
- uriToLineStarts[uri] = lineStarts;
+ uriToLineStarts[uri] = new Source(lineStarts, sourceCode);
}
return uriToLineStarts;
}
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart
index 68f3687..37dd80e 100644
--- a/pkg/kernel/lib/binary/ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart
@@ -137,20 +137,23 @@
_importTable = new ProgramImportTable(program);
_stringIndexer.build(program);
writeStringTable(_stringIndexer);
- writeUriToLineStarts(program);
+ writeUriToSource(program);
writeList(program.libraries, writeNode);
writeMemberReference(program.mainMethod, allowNull: true);
_flush();
}
- void writeUriToLineStarts(Program program) {
- program.uriToLineStarts.keys.forEach((uri) {
+ void writeUriToSource(Program program) {
+ program.uriToSource.keys.forEach((uri) {
_sourceUriIndexer.put(uri);
});
writeStringTable(_sourceUriIndexer);
for (int i = 0; i < _sourceUriIndexer.entries.length; i++) {
String uri = _sourceUriIndexer.entries[i].value;
- List<int> lineStarts = program.uriToLineStarts[uri] ?? [];
+ Source source = program.uriToSource[uri] ?? new Source([], '');
+ String sourceCode = source.source;
+ writeStringTableEntry(sourceCode);
+ List<int> lineStarts = source.lineStarts;
writeUInt30(lineStarts.length);
int previousLineStart = 0;
lineStarts.forEach((lineStart) {
diff --git a/pkg/kernel/lib/transformations/closure/mock.dart b/pkg/kernel/lib/transformations/closure/mock.dart
index a948df2..be8847d 100644
--- a/pkg/kernel/lib/transformations/closure/mock.dart
+++ b/pkg/kernel/lib/transformations/closure/mock.dart
@@ -29,6 +29,7 @@
Program,
PropertyGet,
ReturnStatement,
+ Source,
Statement,
StaticInvocation,
Supertype,
@@ -183,6 +184,6 @@
name: "mock", classes: [contextClass])..fileUri = fileUri;
program.libraries.add(mock);
mock.parent = program;
- program.uriToLineStarts[mock.fileUri] = <int>[0];
+ program.uriToSource[mock.fileUri] = new Source(<int>[0], "");
return contextClass;
}
diff --git a/pkg/pkg.status b/pkg/pkg.status
index 0f28f5a..5d6b52b 100644
--- a/pkg/pkg.status
+++ b/pkg/pkg.status
@@ -31,6 +31,290 @@
[ $compiler == dart2analyzer ]
dev_compiler/gen/*: SkipByDesign
+dev_compiler/test/options/*: SkipByDesign
+
+# Issue #28236
+analysis_server/test/analysis/get_errors_test: StaticWarning
+analysis_server/test/analysis/get_hover_test: StaticWarning
+analysis_server/test/analysis/get_navigation_test: StaticWarning
+analysis_server/test/analysis/navigation_collector_test: StaticWarning
+analysis_server/test/analysis/notification_analysis_options_test: StaticWarning
+analysis_server/test/analysis/notification_analyzedFiles_test: StaticWarning
+analysis_server/test/analysis/notification_errors_test: StaticWarning
+analysis_server/test/analysis/notification_highlights_test: StaticWarning
+analysis_server/test/analysis/notification_implemented_test: StaticWarning
+analysis_server/test/analysis/notification_navigation_test: StaticWarning
+analysis_server/test/analysis/notification_occurrences_test: StaticWarning
+analysis_server/test/analysis/notification_outline_test: StaticWarning
+analysis_server/test/analysis/notification_overrides_test: StaticWarning
+analysis_server/test/analysis/reanalyze_test: StaticWarning
+analysis_server/test/analysis/set_priority_files_test: StaticWarning
+analysis_server/test/analysis/update_content_test: StaticWarning
+analysis_server/test/analysis_server_test: StaticWarning
+analysis_server/test/channel/byte_stream_channel_test: StaticWarning
+analysis_server/test/channel/web_socket_channel_test: StaticWarning
+analysis_server/test/completion_test: StaticWarning
+analysis_server/test/context_manager_test: StaticWarning
+analysis_server/test/domain_analysis_test: StaticWarning
+analysis_server/test/domain_completion_test: StaticWarning
+analysis_server/test/domain_diagnostic_test: StaticWarning
+analysis_server/test/domain_execution_test: StaticWarning
+analysis_server/test/domain_server_test: StaticWarning
+analysis_server/test/edit/assists_test: StaticWarning
+analysis_server/test/edit/fixes_test: StaticWarning
+analysis_server/test/edit/format_test: StaticWarning
+analysis_server/test/edit/organize_directives_test: StaticWarning
+analysis_server/test/edit/refactoring_test: StaticWarning
+analysis_server/test/edit/sort_members_test: StaticWarning
+analysis_server/test/integration/analysis/analysis_options_test: StaticWarning
+analysis_server/test/integration/analysis/error_test: StaticWarning
+analysis_server/test/integration/analysis/get_errors_after_analysis_test: StaticWarning
+analysis_server/test/integration/analysis/get_errors_before_analysis_test: StaticWarning
+analysis_server/test/integration/analysis/get_hover_test: StaticWarning
+analysis_server/test/integration/analysis/highlights_test: StaticWarning
+analysis_server/test/integration/analysis/lint_test: StaticWarning
+analysis_server/test/integration/analysis/navigation_test: StaticWarning
+analysis_server/test/integration/analysis/occurrences_test: StaticWarning
+analysis_server/test/integration/analysis/outline_test: StaticWarning
+analysis_server/test/integration/analysis/overrides_test: StaticWarning
+analysis_server/test/integration/analysis/package_root_test: StaticWarning
+analysis_server/test/integration/analysis/reanalyze_concurrent_test: StaticWarning
+analysis_server/test/integration/analysis/reanalyze_test: StaticWarning
+analysis_server/test/integration/analysis/update_content_list_test: StaticWarning
+analysis_server/test/integration/analysis/update_content_test: StaticWarning
+analysis_server/test/integration/completion/get_suggestions_test: StaticWarning
+analysis_server/test/integration/search/get_type_hierarchy_test: StaticWarning
+analysis_server/test/integration/server/get_version_test: StaticWarning
+analysis_server/test/integration/server/set_subscriptions_invalid_service_test: StaticWarning
+analysis_server/test/integration/server/set_subscriptions_test: StaticWarning
+analysis_server/test/integration/server/shutdown_test: StaticWarning
+analysis_server/test/integration/server/status_test: StaticWarning
+analysis_server/test/operation/operation_queue_test: StaticWarning
+analysis_server/test/operation/operation_test: StaticWarning
+analysis_server/test/plugin/protocol_dart_test: StaticWarning
+analysis_server/test/plugin/set_analysis_domain_test: StaticWarning
+analysis_server/test/protocol_server_test: StaticWarning
+analysis_server/test/protocol_test: StaticWarning
+analysis_server/test/search/element_references_test: StaticWarning
+analysis_server/test/search/member_declarations_test: StaticWarning
+analysis_server/test/search/member_references_test: StaticWarning
+analysis_server/test/search/search_result_test: StaticWarning
+analysis_server/test/search/top_level_declarations_test: StaticWarning
+analysis_server/test/search/type_hierarchy_test: StaticWarning
+analysis_server/test/server_options_test: StaticWarning
+analysis_server/test/services/completion/completion_target_test: StaticWarning
+analysis_server/test/services/completion/dart/arglist_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/combinator_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/common_usage_sorter_test: StaticWarning
+analysis_server/test/services/completion/dart/completion_manager_test: StaticWarning
+analysis_server/test/services/completion/dart/field_formal_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/imported_reference_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/inherited_reference_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/keyword_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/label_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/library_member_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/library_prefix_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/local_constructor_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/local_declaration_visitor_test: StaticWarning
+analysis_server/test/services/completion/dart/local_library_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/local_reference_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/named_constructor_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/optype_test: StaticWarning
+analysis_server/test/services/completion/dart/override_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/static_member_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/type_member_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/uri_contributor_test: StaticWarning
+analysis_server/test/services/completion/dart/variable_name_contributor_test: StaticWarning
+analysis_server/test/services/correction/assist_test: StaticWarning
+analysis_server/test/services/correction/change_test: StaticWarning
+analysis_server/test/services/correction/fix_test: StaticWarning
+analysis_server/test/services/correction/levenshtein_test: StaticWarning
+analysis_server/test/services/correction/name_suggestion_test: StaticWarning
+analysis_server/test/services/correction/organize_directives_test: StaticWarning
+analysis_server/test/services/correction/sort_members_test: StaticWarning
+analysis_server/test/services/correction/source_range_test: StaticWarning
+analysis_server/test/services/correction/status_test: StaticWarning
+analysis_server/test/services/correction/strings_test: StaticWarning
+analysis_server/test/services/correction/util_test: StaticWarning
+analysis_server/test/services/dependencies/library_dependencies_test: StaticWarning
+analysis_server/test/services/dependencies/reachable_source_collector_test: StaticWarning
+analysis_server/test/services/index/index_test: StaticWarning
+analysis_server/test/services/index/index_unit_test: StaticWarning
+analysis_server/test/services/linter/linter_test: StaticWarning
+analysis_server/test/services/refactoring/convert_getter_to_method_test: StaticWarning
+analysis_server/test/services/refactoring/convert_method_to_getter_test: StaticWarning
+analysis_server/test/services/refactoring/extract_local_test: StaticWarning
+analysis_server/test/services/refactoring/extract_method_test: StaticWarning
+analysis_server/test/services/refactoring/inline_local_test: StaticWarning
+analysis_server/test/services/refactoring/inline_method_test: StaticWarning
+analysis_server/test/services/refactoring/move_file_test: StaticWarning
+analysis_server/test/services/refactoring/naming_conventions_test: StaticWarning
+analysis_server/test/services/refactoring/rename_class_member_test: StaticWarning
+analysis_server/test/services/refactoring/rename_constructor_test: StaticWarning
+analysis_server/test/services/refactoring/rename_import_test: StaticWarning
+analysis_server/test/services/refactoring/rename_label_test: StaticWarning
+analysis_server/test/services/refactoring/rename_library_test: StaticWarning
+analysis_server/test/services/refactoring/rename_local_test: StaticWarning
+analysis_server/test/services/refactoring/rename_unit_member_test: StaticWarning
+analysis_server/test/services/search/hierarchy_test: StaticWarning
+analysis_server/test/services/search/search_engine2_test: StaticWarning
+analysis_server/test/services/search/search_engine_test: StaticWarning
+analysis_server/test/single_context_manager_test: StaticWarning
+analysis_server/test/socket_server_test: StaticWarning
+analysis_server/test/source/caching_put_package_map_provider_test: StaticWarning
+analysis_server/test/src/utilities/change_builder_core_test: StaticWarning
+analysis_server/test/src/utilities/change_builder_dart_test: StaticWarning
+analysis_server/test/src/watch_manager_test: StaticWarning
+analyzer/test/cancelable_future_test: StaticWarning
+analyzer/test/context/declared_variables_test: StaticWarning
+analyzer/test/dart/ast/ast_test: StaticWarning
+analyzer/test/dart/ast/visitor_test: StaticWarning
+analyzer/test/dart/element/builder_test: StaticWarning
+analyzer/test/dart/element/element_test: StaticWarning
+analyzer/test/file_system/memory_file_system_test: StaticWarning
+analyzer/test/file_system/physical_resource_provider_test: StaticWarning
+analyzer/test/file_system/resource_uri_resolver_test: StaticWarning
+analyzer/test/generated/all_the_rest_test: StaticWarning
+analyzer/test/generated/bazel_test: StaticWarning
+analyzer/test/generated/checked_mode_compile_time_error_code_test: StaticWarning
+analyzer/test/generated/compile_time_error_code_test: StaticWarning
+analyzer/test/generated/constant_test: StaticWarning
+analyzer/test/generated/declaration_resolver_test: StaticWarning
+analyzer/test/generated/element_resolver_test: StaticWarning
+analyzer/test/generated/engine_test: StaticWarning
+analyzer/test/generated/error_suppression_test: StaticWarning
+analyzer/test/generated/hint_code_test: StaticWarning
+analyzer/test/generated/incremental_resolver_test: StaticWarning
+analyzer/test/generated/inheritance_manager_test: StaticWarning
+analyzer/test/generated/java_core_test: StaticWarning
+analyzer/test/generated/java_io_test: StaticWarning
+analyzer/test/generated/non_error_resolver_test: StaticWarning
+analyzer/test/generated/non_hint_code_test: StaticWarning
+analyzer/test/generated/package_test: StaticWarning
+analyzer/test/generated/parser_test: StaticWarning
+analyzer/test/generated/resolver_test: StaticWarning
+analyzer/test/generated/scanner_test: StaticWarning
+analyzer/test/generated/sdk_test: StaticWarning
+analyzer/test/generated/simple_resolver_test: StaticWarning
+analyzer/test/generated/source_factory_test: StaticWarning
+analyzer/test/generated/static_type_analyzer_test: StaticWarning
+analyzer/test/generated/static_type_warning_code_test: StaticWarning
+analyzer/test/generated/static_warning_code_test: StaticWarning
+analyzer/test/generated/strong_mode_test: StaticWarning
+analyzer/test/generated/type_system_test: StaticWarning
+analyzer/test/generated/utilities_dart_test: StaticWarning
+analyzer/test/generated/utilities_test: StaticWarning
+analyzer/test/instrumentation/instrumentation_test: StaticWarning
+analyzer/test/parse_compilation_unit_test: StaticWarning
+analyzer/test/source/analysis_options_provider_test: StaticWarning
+analyzer/test/source/embedder_test: StaticWarning
+analyzer/test/source/error_processor_test: StaticWarning
+analyzer/test/source/package_map_provider_test: StaticWarning
+analyzer/test/source/package_map_resolver_test: StaticWarning
+analyzer/test/source/path_filter_test: StaticWarning
+analyzer/test/source/sdk_ext_test: StaticWarning
+analyzer/test/src/command_line/arguments_test: StaticWarning
+analyzer/test/src/context/builder_test: StaticWarning
+analyzer/test/src/context/cache_test: StaticWarning
+analyzer/test/src/context/context_test: StaticWarning
+analyzer/test/src/dart/analysis/byte_store_test: StaticWarning
+analyzer/test/src/dart/analysis/driver_test: StaticWarning
+analyzer/test/src/dart/analysis/file_state_test: StaticWarning
+analyzer/test/src/dart/analysis/index_test: StaticWarning
+analyzer/test/src/dart/analysis/referenced_names_test: StaticWarning
+analyzer/test/src/dart/analysis/search_test: StaticWarning
+analyzer/test/src/dart/ast/utilities_test: StaticWarning
+analyzer/test/src/dart/constant/evaluation_test: StaticWarning
+analyzer/test/src/dart/constant/utilities_test: StaticWarning
+analyzer/test/src/dart/constant/value_test: StaticWarning
+analyzer/test/src/dart/element/element_test: StaticWarning
+analyzer/test/src/dart/sdk/patch_test: StaticWarning
+analyzer/test/src/dart/sdk/sdk_test: StaticWarning
+analyzer/test/src/lint/config_test: StaticWarning
+analyzer/test/src/lint/io_test: StaticWarning
+analyzer/test/src/lint/project_test: StaticWarning
+analyzer/test/src/lint/pub_test: StaticWarning
+analyzer/test/src/source/source_resource_test: StaticWarning
+analyzer/test/src/summary/api_signature_test: StaticWarning
+analyzer/test/src/summary/bazel_summary_test: StaticWarning
+analyzer/test/src/summary/flat_buffers_test: StaticWarning
+analyzer/test/src/summary/in_summary_source_test: StaticWarning
+analyzer/test/src/summary/linker_test: StaticWarning
+analyzer/test/src/summary/name_filter_test: StaticWarning
+analyzer/test/src/summary/package_bundle_reader_test: StaticWarning
+analyzer/test/src/summary/prelinker_test: StaticWarning
+analyzer/test/src/summary/pub_summary_test: StaticWarning
+analyzer/test/src/summary/resynthesize_ast_test: StaticWarning
+analyzer/test/src/summary/summarize_ast_strong_test: StaticWarning
+analyzer/test/src/summary/summarize_ast_test: StaticWarning
+analyzer/test/src/task/dart_test: StaticWarning
+analyzer/test/src/task/dart_work_manager_test: StaticWarning
+analyzer/test/src/task/driver_test: StaticWarning
+analyzer/test/src/task/general_test: StaticWarning
+analyzer/test/src/task/html_test: StaticWarning
+analyzer/test/src/task/html_work_manager_test: StaticWarning
+analyzer/test/src/task/incremental_element_builder_test: StaticWarning
+analyzer/test/src/task/inputs_test: StaticWarning
+analyzer/test/src/task/manager_test: StaticWarning
+analyzer/test/src/task/model_test: StaticWarning
+analyzer/test/src/task/options_test: StaticWarning
+analyzer/test/src/task/options_work_manager_test: StaticWarning
+analyzer/test/src/task/strong/checker_test: StaticWarning
+analyzer/test/src/task/strong/inferred_type_test: StaticWarning
+analyzer/test/src/task/strong/non_null_checker_test: StaticWarning
+analyzer/test/src/task/strong_mode_test: StaticWarning
+analyzer/test/src/task/yaml_test: StaticWarning
+analyzer/test/src/util/absolute_path_test: StaticWarning
+analyzer/test/src/util/asserts_test: StaticWarning
+analyzer/test/src/util/fast_uri_test: StaticWarning
+analyzer/test/src/util/glob_test: StaticWarning
+analyzer/test/src/util/lru_map_test: StaticWarning
+analyzer/test/src/util/yaml_test: StaticWarning
+analyzer/tool/summary/check_test: StaticWarning
+analyzer/tool/task_dependency_graph/check_test: StaticWarning
+analyzer_cli/test/build_mode_test: StaticWarning
+analyzer_cli/test/driver_test: StaticWarning
+analyzer_cli/test/embedder_test: StaticWarning
+analyzer_cli/test/error_test: StaticWarning
+analyzer_cli/test/options_test: StaticWarning
+analyzer_cli/test/package_prefix_test: StaticWarning
+analyzer_cli/test/perf_report_test: StaticWarning
+analyzer_cli/test/reporter_test: StaticWarning
+analyzer_cli/test/sdk_ext_test: StaticWarning
+analyzer_cli/test/strong_mode_test: StaticWarning
+analyzer_cli/test/super_mixin_test: StaticWarning
+analyzer_cli/tool/perf_test: StaticWarning
+compiler/tool/perf_test: StaticWarning
+dev_compiler/test/closure/closure_annotation_test: StaticWarning
+dev_compiler/test/closure/closure_type_test: StaticWarning
+dev_compiler/test/codegen_test: StaticWarning
+dev_compiler/test/js/builder_test: StaticWarning
+dev_compiler/test/worker/worker_test: StaticWarning
+front_end/test/dependency_grapher_test: StaticWarning
+front_end/test/memory_file_system_test: StaticWarning
+front_end/test/physical_file_system_test: StaticWarning
+front_end/test/scanner_test: StaticWarning
+front_end/test/src/async_dependency_walker_test: StaticWarning
+front_end/test/src/base/libraries_reader_test: StaticWarning
+front_end/test/src/base/uri_resolver_test: StaticWarning
+front_end/test/src/dependency_walker_test: StaticWarning
+front_end/tool/perf_test: StaticWarning
+js_ast/test/printer_callback_test: StaticWarning
+js_ast/test/string_escape_test: StaticWarning
+kernel/test/baseline_spec_mode_test: StaticWarning
+kernel/test/baseline_strong_mode_test: StaticWarning
+kernel/test/baseline_type_propagation_test: StaticWarning
+kernel/test/type_hashcode_test: StaticWarning
+kernel/test/type_substitute_bounds_test: StaticWarning
+kernel/test/type_substitution_identity_test: StaticWarning
+kernel/test/type_subtype_test: StaticWarning
+kernel/test/type_unification_test: StaticWarning
+kernel/test/uint31_pair_map_test: StaticWarning
+kernel/test/verify_test: StaticWarning
+lookup_map/test/lookup_map_test: StaticWarning
+lookup_map/test/version_check_test: StaticWarning
+typed_mock/test/typed_mock_test: StaticWarning
+
[ $compiler == none && ($runtime == drt || $runtime == dartium) ]
mutation_observer: Skip # Issue 21149
@@ -50,6 +334,9 @@
analysis_server/test/integration/analysis/analysis_options_test: RuntimeError # Issue 24796
analyzer/test/generated/all_the_rest_test: Fail # Issue 21772
analyzer/test/generated/source_factory_test: RuntimeError # Issue 26828
+kernel/test/baseline_type_propagation_test: RuntimeError # Issue 28243
+kernel/test/baseline_spec_mode_test: RuntimeError # Issue 28243
+kernel/test/baseline_strong_mode_test: RuntimeError # Issue 28243
[ $compiler == dart2js ]
analysis_server/test/integration: SkipByDesign # Analysis server integration tests don't make sense to run under dart2js, since the code under test always runs in the Dart vm as a subprocess.
@@ -210,3 +497,6 @@
[ $compiler == dart2js && $cps_ir && $checked ]
*: Skip # `assert` not implemented, about 75% tests crash
+
+[ $compiler == none ]
+kernel/test/closures_test: Fail
diff --git a/pkg/pkgbuild.status b/pkg/pkgbuild.status
index a4ad40d..32dad8f 100644
--- a/pkg/pkgbuild.status
+++ b/pkg/pkgbuild.status
@@ -9,7 +9,7 @@
pkg/dev_compiler: SkipByDesign # we have relative paths to analyzer
pkg/analyzer: Fail # Issue 27654
pkg/front_end: Fail # Issue 27655
-pkg/kernel: Fail # Issue 27937
+pkg/kernel: SkipByDesign # Issue 27937
[ $use_repository_packages ]
third_party/pkg_tested/dart_style: Fail # Issue https://github.com/dart-lang/dart_style/issues/562
\ No newline at end of file
diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn
index 6008aec..e7c13da 100644
--- a/runtime/BUILD.gn
+++ b/runtime/BUILD.gn
@@ -168,8 +168,15 @@
cflags += [ "-O3" ]
}
+ ldflags = []
if (defined(is_asan) && is_asan) {
- ldflags = [ "-fsanitize=address" ]
+ ldflags += [ "-fsanitize=address" ]
+ }
+ if (defined(is_msan) && is_msan) {
+ ldflags += [ "-fsanitize=memory" ]
+ }
+ if (defined(is_tsan) && is_tsan) {
+ ldflags += [ "-fsanitize=thread" ]
}
}
}
diff --git a/runtime/bin/bin.gypi b/runtime/bin/bin.gypi
index f460a08..477cf08 100644
--- a/runtime/bin/bin.gypi
+++ b/runtime/bin/bin.gypi
@@ -1147,7 +1147,7 @@
},
},
}],
- ['OS == "linux" and asan == 0 and msan == 0', {
+ ['OS == "linux" and asan == 0 and msan == 0 and tsan == 0', {
'dependencies': [
'../third_party/tcmalloc/tcmalloc.gypi:tcmalloc',
],
@@ -1398,7 +1398,7 @@
'libraries': [ '-lws2_32.lib', '-lRpcrt4.lib', '-lwinmm.lib' ],
},
}],
- ['OS == "linux" and asan == 0 and msan == 0', {
+ ['OS == "linux" and asan == 0 and msan == 0 and tsan == 0', {
'dependencies': [
'../third_party/tcmalloc/tcmalloc.gypi:tcmalloc',
],
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index ee3255a..1abd906 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -256,7 +256,8 @@
ASSERT(buffer != NULL);
// Write all the data out into the file.
- bool success = file->WriteFully(buffer, length);
+ char* byte_buffer = reinterpret_cast<char*>(buffer);
+ bool success = file->WriteFully(byte_buffer + start, length);
// Release the direct pointer acquired above.
result = Dart_TypedDataReleaseData(buffer_obj);
diff --git a/runtime/bin/file_android.cc b/runtime/bin/file_android.cc
index 985fbf8..74aa81f 100644
--- a/runtime/bin/file_android.cc
+++ b/runtime/bin/file_android.cc
@@ -265,114 +265,136 @@
}
-bool File::Delete(const char* name) {
- File::Type type = File::GetType(name, true);
- if (type == kIsFile) {
- return NO_RETRY_EXPECTED(unlink(name)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
+File::Type File::GetType(const char* pathname, bool follow_links) {
+ struct stat entry_info;
+ int stat_success;
+ if (follow_links) {
+ stat_success = NO_RETRY_EXPECTED(stat(pathname, &entry_info));
} else {
- errno = ENOENT;
+ stat_success = NO_RETRY_EXPECTED(lstat(pathname, &entry_info));
+ }
+ if (stat_success == -1) {
+ return File::kDoesNotExist;
+ }
+ if (S_ISDIR(entry_info.st_mode)) {
+ return File::kIsDirectory;
+ }
+ if (S_ISREG(entry_info.st_mode)) {
+ return File::kIsFile;
+ }
+ if (S_ISLNK(entry_info.st_mode)) {
+ return File::kIsLink;
+ }
+ return File::kDoesNotExist;
+}
+
+
+static bool CheckTypeAndSetErrno(const char* name,
+ File::Type expected,
+ bool follow_links) {
+ File::Type actual = File::GetType(name, follow_links);
+ if (actual == expected) {
+ return true;
+ }
+ switch (actual) {
+ case File::kIsDirectory:
+ errno = EISDIR;
+ break;
+ case File::kDoesNotExist:
+ errno = ENOENT;
+ break;
+ default:
+ errno = EINVAL;
+ break;
}
return false;
}
+bool File::Delete(const char* name) {
+ return CheckTypeAndSetErrno(name, kIsFile, true) &&
+ (NO_RETRY_EXPECTED(unlink(name)) == 0);
+}
+
+
bool File::DeleteLink(const char* name) {
- File::Type type = File::GetType(name, false);
- if (type == kIsLink) {
- return NO_RETRY_EXPECTED(unlink(name)) == 0;
- }
- errno = EINVAL;
- return false;
+ return CheckTypeAndSetErrno(name, kIsLink, false) &&
+ (NO_RETRY_EXPECTED(unlink(name)) == 0);
}
bool File::Rename(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, true);
- if (type == kIsFile) {
- return NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = ENOENT;
- }
- return false;
+ return CheckTypeAndSetErrno(old_path, kIsFile, true) &&
+ (NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0);
}
bool File::RenameLink(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, false);
- if (type == kIsLink) {
- return NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = EINVAL;
- }
- return false;
+ return CheckTypeAndSetErrno(old_path, kIsLink, false) &&
+ (NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0);
}
bool File::Copy(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, true);
- if (type == kIsFile) {
- struct stat st;
- if (NO_RETRY_EXPECTED(stat(old_path, &st)) != 0) {
- return false;
- }
- int old_fd = TEMP_FAILURE_RETRY(open(old_path, O_RDONLY | O_CLOEXEC));
- if (old_fd < 0) {
- return false;
- }
- int new_fd = TEMP_FAILURE_RETRY(
- open(new_path, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, st.st_mode));
- if (new_fd < 0) {
- VOID_TEMP_FAILURE_RETRY(close(old_fd));
- return false;
- }
- off_t offset = 0;
- int result = 1;
- while (result > 0) {
- // Loop to ensure we copy everything, and not only up to 2GB.
- result = NO_RETRY_EXPECTED(sendfile(new_fd, old_fd, &offset, kMaxUint32));
- }
- // From sendfile man pages:
- // Applications may wish to fall back to read(2)/write(2) in the case
- // where sendfile() fails with EINVAL or ENOSYS.
- if ((result < 0) && ((errno == EINVAL) || (errno == ENOSYS))) {
- const intptr_t kBufferSize = 8 * KB;
- uint8_t buffer[kBufferSize];
- while ((result = TEMP_FAILURE_RETRY(read(old_fd, buffer, kBufferSize))) >
- 0) {
- int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result));
- if (wrote != result) {
- result = -1;
- break;
- }
+ if (!CheckTypeAndSetErrno(old_path, kIsFile, true)) {
+ return false;
+ }
+ struct stat st;
+ if (NO_RETRY_EXPECTED(stat(old_path, &st)) != 0) {
+ return false;
+ }
+ int old_fd = TEMP_FAILURE_RETRY(open(old_path, O_RDONLY | O_CLOEXEC));
+ if (old_fd < 0) {
+ return false;
+ }
+ int new_fd = TEMP_FAILURE_RETRY(
+ open(new_path, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, st.st_mode));
+ if (new_fd < 0) {
+ VOID_TEMP_FAILURE_RETRY(close(old_fd));
+ return false;
+ }
+ off_t offset = 0;
+ int result = 1;
+ while (result > 0) {
+ // Loop to ensure we copy everything, and not only up to 2GB.
+ result = NO_RETRY_EXPECTED(sendfile(new_fd, old_fd, &offset, kMaxUint32));
+ }
+ // From sendfile man pages:
+ // Applications may wish to fall back to read(2)/write(2) in the case
+ // where sendfile() fails with EINVAL or ENOSYS.
+ if ((result < 0) && ((errno == EINVAL) || (errno == ENOSYS))) {
+ const intptr_t kBufferSize = 8 * KB;
+ uint8_t buffer[kBufferSize];
+ while ((result = TEMP_FAILURE_RETRY(read(old_fd, buffer, kBufferSize))) >
+ 0) {
+ int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result));
+ if (wrote != result) {
+ result = -1;
+ break;
}
}
- int e = errno;
- VOID_TEMP_FAILURE_RETRY(close(old_fd));
- VOID_TEMP_FAILURE_RETRY(close(new_fd));
- if (result < 0) {
- VOID_NO_RETRY_EXPECTED(unlink(new_path));
- errno = e;
- return false;
- }
- return true;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = ENOENT;
}
- return false;
+ int e = errno;
+ VOID_TEMP_FAILURE_RETRY(close(old_fd));
+ VOID_TEMP_FAILURE_RETRY(close(new_fd));
+ if (result < 0) {
+ VOID_NO_RETRY_EXPECTED(unlink(new_path));
+ errno = e;
+ return false;
+ }
+ return true;
}
int64_t File::LengthFromPath(const char* name) {
struct stat st;
if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
+ // Signal an error if it's a directory.
+ if (S_ISDIR(st.st_mode)) {
+ errno = EISDIR;
+ return -1;
+ }
+ // Otherwise assume the caller knows what it's doing.
return st.st_size;
}
return -1;
@@ -405,6 +427,12 @@
time_t File::LastModified(const char* name) {
struct stat st;
if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
+ // Signal an error if it's a directory.
+ if (S_ISDIR(st.st_mode)) {
+ errno = EISDIR;
+ return -1;
+ }
+ // Otherwise assume the caller knows what it's doing.
return st.st_mtime;
}
return -1;
@@ -488,30 +516,6 @@
}
-File::Type File::GetType(const char* pathname, bool follow_links) {
- struct stat entry_info;
- int stat_success;
- if (follow_links) {
- stat_success = NO_RETRY_EXPECTED(stat(pathname, &entry_info));
- } else {
- stat_success = NO_RETRY_EXPECTED(lstat(pathname, &entry_info));
- }
- if (stat_success == -1) {
- return File::kDoesNotExist;
- }
- if (S_ISDIR(entry_info.st_mode)) {
- return File::kIsDirectory;
- }
- if (S_ISREG(entry_info.st_mode)) {
- return File::kIsFile;
- }
- if (S_ISLNK(entry_info.st_mode)) {
- return File::kIsLink;
- }
- return File::kDoesNotExist;
-}
-
-
File::Identical File::AreIdentical(const char* file_1, const char* file_2) {
struct stat file_1_info;
struct stat file_2_info;
diff --git a/runtime/bin/file_fuchsia.cc b/runtime/bin/file_fuchsia.cc
index ceea0c3..7175d55 100644
--- a/runtime/bin/file_fuchsia.cc
+++ b/runtime/bin/file_fuchsia.cc
@@ -248,105 +248,126 @@
}
-bool File::Delete(const char* name) {
- File::Type type = File::GetType(name, true);
- if (type == kIsFile) {
- return NO_RETRY_EXPECTED(unlink(name)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
+File::Type File::GetType(const char* pathname, bool follow_links) {
+ struct stat entry_info;
+ int stat_success;
+ if (follow_links) {
+ stat_success = NO_RETRY_EXPECTED(stat(pathname, &entry_info));
} else {
- errno = ENOENT;
+ stat_success = NO_RETRY_EXPECTED(lstat(pathname, &entry_info));
+ }
+ if (stat_success == -1) {
+ return File::kDoesNotExist;
+ }
+ if (S_ISDIR(entry_info.st_mode)) {
+ return File::kIsDirectory;
+ }
+ if (S_ISREG(entry_info.st_mode)) {
+ return File::kIsFile;
+ }
+ if (S_ISLNK(entry_info.st_mode)) {
+ return File::kIsLink;
+ }
+ return File::kDoesNotExist;
+}
+
+
+static bool CheckTypeAndSetErrno(const char* name,
+ File::Type expected,
+ bool follow_links) {
+ File::Type actual = File::GetType(name, follow_links);
+ if (actual == expected) {
+ return true;
+ }
+ switch (actual) {
+ case File::kIsDirectory:
+ errno = EISDIR;
+ break;
+ case File::kDoesNotExist:
+ errno = ENOENT;
+ break;
+ default:
+ errno = EINVAL;
+ break;
}
return false;
}
+bool File::Delete(const char* name) {
+ return CheckTypeAndSetErrno(name, kIsFile, true) &&
+ (NO_RETRY_EXPECTED(unlink(name)) == 0);
+}
+
+
bool File::DeleteLink(const char* name) {
- File::Type type = File::GetType(name, false);
- if (type == kIsLink) {
- return NO_RETRY_EXPECTED(unlink(name)) == 0;
- }
- errno = EINVAL;
- return false;
+ return CheckTypeAndSetErrno(name, kIsLink, false) &&
+ (NO_RETRY_EXPECTED(unlink(name)) == 0);
}
bool File::Rename(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, true);
- if (type == kIsFile) {
- return NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = ENOENT;
- }
- return false;
+ return CheckTypeAndSetErrno(old_path, kIsFile, true) &&
+ (NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0);
}
bool File::RenameLink(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, false);
- if (type == kIsLink) {
- return NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = EINVAL;
- }
- return false;
+ return CheckTypeAndSetErrno(old_path, kIsLink, false) &&
+ (NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0);
}
bool File::Copy(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, true);
- if (type == kIsFile) {
- struct stat64 st;
- if (NO_RETRY_EXPECTED(stat64(old_path, &st)) != 0) {
- return false;
- }
- int old_fd = NO_RETRY_EXPECTED(open64(old_path, O_RDONLY | O_CLOEXEC));
- if (old_fd < 0) {
- return false;
- }
- int new_fd = NO_RETRY_EXPECTED(
- open64(new_path, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, st.st_mode));
- if (new_fd < 0) {
- VOID_TEMP_FAILURE_RETRY(close(old_fd));
- return false;
- }
- // TODO(MG-429): Use sendfile/copyfile or equivalent when there is one.
- intptr_t result;
- const intptr_t kBufferSize = 8 * KB;
- uint8_t buffer[kBufferSize];
- while ((result = NO_RETRY_EXPECTED(read(old_fd, buffer, kBufferSize))) >
- 0) {
- int wrote = NO_RETRY_EXPECTED(write(new_fd, buffer, result));
- if (wrote != result) {
- result = -1;
- break;
- }
- }
- FDUtils::SaveErrorAndClose(old_fd);
- FDUtils::SaveErrorAndClose(new_fd);
- if (result < 0) {
- int e = errno;
- VOID_NO_RETRY_EXPECTED(unlink(new_path));
- errno = e;
- return false;
- }
- return true;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = ENOENT;
+ if (!CheckTypeAndSetErrno(old_path, kIsFile, true)) {
+ return false;
}
- return false;
+ struct stat64 st;
+ if (NO_RETRY_EXPECTED(stat64(old_path, &st)) != 0) {
+ return false;
+ }
+ int old_fd = NO_RETRY_EXPECTED(open64(old_path, O_RDONLY | O_CLOEXEC));
+ if (old_fd < 0) {
+ return false;
+ }
+ int new_fd = NO_RETRY_EXPECTED(
+ open64(new_path, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, st.st_mode));
+ if (new_fd < 0) {
+ VOID_TEMP_FAILURE_RETRY(close(old_fd));
+ return false;
+ }
+ // TODO(MG-429): Use sendfile/copyfile or equivalent when there is one.
+ intptr_t result;
+ const intptr_t kBufferSize = 8 * KB;
+ uint8_t buffer[kBufferSize];
+ while ((result = NO_RETRY_EXPECTED(read(old_fd, buffer, kBufferSize))) > 0) {
+ int wrote = NO_RETRY_EXPECTED(write(new_fd, buffer, result));
+ if (wrote != result) {
+ result = -1;
+ break;
+ }
+ }
+ FDUtils::SaveErrorAndClose(old_fd);
+ FDUtils::SaveErrorAndClose(new_fd);
+ if (result < 0) {
+ int e = errno;
+ VOID_NO_RETRY_EXPECTED(unlink(new_path));
+ errno = e;
+ return false;
+ }
+ return true;
}
int64_t File::LengthFromPath(const char* name) {
struct stat st;
if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
+ // Signal an error if it's a directory.
+ if (S_ISDIR(st.st_mode)) {
+ errno = EISDIR;
+ return -1;
+ }
+ // Otherwise assume the caller knows what it's doing.
return st.st_size;
}
return -1;
@@ -379,6 +400,12 @@
time_t File::LastModified(const char* name) {
struct stat st;
if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
+ // Signal an error if it's a directory.
+ if (S_ISDIR(st.st_mode)) {
+ errno = EISDIR;
+ return -1;
+ }
+ // Otherwise assume the caller knows what it's doing.
return st.st_mtime;
}
return -1;
@@ -467,30 +494,6 @@
}
-File::Type File::GetType(const char* pathname, bool follow_links) {
- struct stat entry_info;
- int stat_success;
- if (follow_links) {
- stat_success = NO_RETRY_EXPECTED(stat(pathname, &entry_info));
- } else {
- stat_success = NO_RETRY_EXPECTED(lstat(pathname, &entry_info));
- }
- if (stat_success == -1) {
- return File::kDoesNotExist;
- }
- if (S_ISDIR(entry_info.st_mode)) {
- return File::kIsDirectory;
- }
- if (S_ISREG(entry_info.st_mode)) {
- return File::kIsFile;
- }
- if (S_ISLNK(entry_info.st_mode)) {
- return File::kIsLink;
- }
- return File::kDoesNotExist;
-}
-
-
File::Identical File::AreIdentical(const char* file_1, const char* file_2) {
struct stat file_1_info;
struct stat file_2_info;
diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc
index 6664c67..fd2a3c2 100644
--- a/runtime/bin/file_linux.cc
+++ b/runtime/bin/file_linux.cc
@@ -266,115 +266,136 @@
}
-bool File::Delete(const char* name) {
- File::Type type = File::GetType(name, true);
- if (type == kIsFile) {
- return NO_RETRY_EXPECTED(unlink(name)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
+File::Type File::GetType(const char* pathname, bool follow_links) {
+ struct stat64 entry_info;
+ int stat_success;
+ if (follow_links) {
+ stat_success = TEMP_FAILURE_RETRY(stat64(pathname, &entry_info));
} else {
- errno = ENOENT;
+ stat_success = TEMP_FAILURE_RETRY(lstat64(pathname, &entry_info));
+ }
+ if (stat_success == -1) {
+ return File::kDoesNotExist;
+ }
+ if (S_ISDIR(entry_info.st_mode)) {
+ return File::kIsDirectory;
+ }
+ if (S_ISREG(entry_info.st_mode)) {
+ return File::kIsFile;
+ }
+ if (S_ISLNK(entry_info.st_mode)) {
+ return File::kIsLink;
+ }
+ return File::kDoesNotExist;
+}
+
+
+static bool CheckTypeAndSetErrno(const char* name,
+ File::Type expected,
+ bool follow_links) {
+ File::Type actual = File::GetType(name, follow_links);
+ if (actual == expected) {
+ return true;
+ }
+ switch (actual) {
+ case File::kIsDirectory:
+ errno = EISDIR;
+ break;
+ case File::kDoesNotExist:
+ errno = ENOENT;
+ break;
+ default:
+ errno = EINVAL;
+ break;
}
return false;
}
+bool File::Delete(const char* name) {
+ return CheckTypeAndSetErrno(name, kIsFile, true) &&
+ (NO_RETRY_EXPECTED(unlink(name)) == 0);
+}
+
+
bool File::DeleteLink(const char* name) {
- File::Type type = File::GetType(name, false);
- if (type == kIsLink) {
- return NO_RETRY_EXPECTED(unlink(name)) == 0;
- }
- errno = EINVAL;
- return false;
+ return CheckTypeAndSetErrno(name, kIsLink, false) &&
+ (NO_RETRY_EXPECTED(unlink(name)) == 0);
}
bool File::Rename(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, true);
- if (type == kIsFile) {
- return NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = ENOENT;
- }
- return false;
+ return CheckTypeAndSetErrno(old_path, kIsFile, true) &&
+ (NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0);
}
bool File::RenameLink(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, false);
- if (type == kIsLink) {
- return NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = EINVAL;
- }
- return false;
+ return CheckTypeAndSetErrno(old_path, kIsLink, false) &&
+ (NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0);
}
bool File::Copy(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, true);
- if (type == kIsFile) {
- struct stat64 st;
- if (TEMP_FAILURE_RETRY(stat64(old_path, &st)) != 0) {
- return false;
- }
- int old_fd = TEMP_FAILURE_RETRY(open64(old_path, O_RDONLY | O_CLOEXEC));
- if (old_fd < 0) {
- return false;
- }
- int new_fd = TEMP_FAILURE_RETRY(
- open64(new_path, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, st.st_mode));
- if (new_fd < 0) {
- VOID_TEMP_FAILURE_RETRY(close(old_fd));
- return false;
- }
- int64_t offset = 0;
- intptr_t result = 1;
- while (result > 0) {
- // Loop to ensure we copy everything, and not only up to 2GB.
- result =
- NO_RETRY_EXPECTED(sendfile64(new_fd, old_fd, &offset, kMaxUint32));
- }
- // From sendfile man pages:
- // Applications may wish to fall back to read(2)/write(2) in the case
- // where sendfile() fails with EINVAL or ENOSYS.
- if ((result < 0) && ((errno == EINVAL) || (errno == ENOSYS))) {
- const intptr_t kBufferSize = 8 * KB;
- uint8_t buffer[kBufferSize];
- while ((result = TEMP_FAILURE_RETRY(read(old_fd, buffer, kBufferSize))) >
- 0) {
- int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result));
- if (wrote != result) {
- result = -1;
- break;
- }
+ if (!CheckTypeAndSetErrno(old_path, kIsFile, true)) {
+ return false;
+ }
+ struct stat64 st;
+ if (TEMP_FAILURE_RETRY(stat64(old_path, &st)) != 0) {
+ return false;
+ }
+ int old_fd = TEMP_FAILURE_RETRY(open64(old_path, O_RDONLY | O_CLOEXEC));
+ if (old_fd < 0) {
+ return false;
+ }
+ int new_fd = TEMP_FAILURE_RETRY(
+ open64(new_path, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, st.st_mode));
+ if (new_fd < 0) {
+ VOID_TEMP_FAILURE_RETRY(close(old_fd));
+ return false;
+ }
+ int64_t offset = 0;
+ intptr_t result = 1;
+ while (result > 0) {
+ // Loop to ensure we copy everything, and not only up to 2GB.
+ result = NO_RETRY_EXPECTED(sendfile64(new_fd, old_fd, &offset, kMaxUint32));
+ }
+ // From sendfile man pages:
+ // Applications may wish to fall back to read(2)/write(2) in the case
+ // where sendfile() fails with EINVAL or ENOSYS.
+ if ((result < 0) && ((errno == EINVAL) || (errno == ENOSYS))) {
+ const intptr_t kBufferSize = 8 * KB;
+ uint8_t buffer[kBufferSize];
+ while ((result = TEMP_FAILURE_RETRY(read(old_fd, buffer, kBufferSize))) >
+ 0) {
+ int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result));
+ if (wrote != result) {
+ result = -1;
+ break;
}
}
- int e = errno;
- VOID_TEMP_FAILURE_RETRY(close(old_fd));
- VOID_TEMP_FAILURE_RETRY(close(new_fd));
- if (result < 0) {
- VOID_NO_RETRY_EXPECTED(unlink(new_path));
- errno = e;
- return false;
- }
- return true;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = ENOENT;
}
- return false;
+ int e = errno;
+ VOID_TEMP_FAILURE_RETRY(close(old_fd));
+ VOID_TEMP_FAILURE_RETRY(close(new_fd));
+ if (result < 0) {
+ VOID_NO_RETRY_EXPECTED(unlink(new_path));
+ errno = e;
+ return false;
+ }
+ return true;
}
int64_t File::LengthFromPath(const char* name) {
struct stat64 st;
if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) {
+ // Signal an error if it's a directory.
+ if (S_ISDIR(st.st_mode)) {
+ errno = EISDIR;
+ return -1;
+ }
+ // Otherwise assume the caller knows what it's doing.
return st.st_size;
}
return -1;
@@ -413,6 +434,12 @@
time_t File::LastModified(const char* name) {
struct stat64 st;
if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) {
+ // Signal an error if it's a directory.
+ if (S_ISDIR(st.st_mode)) {
+ errno = EISDIR;
+ return -1;
+ }
+ // Otherwise assume the caller knows what it's doing.
return st.st_mtime;
}
return -1;
@@ -502,30 +529,6 @@
}
-File::Type File::GetType(const char* pathname, bool follow_links) {
- struct stat64 entry_info;
- int stat_success;
- if (follow_links) {
- stat_success = TEMP_FAILURE_RETRY(stat64(pathname, &entry_info));
- } else {
- stat_success = TEMP_FAILURE_RETRY(lstat64(pathname, &entry_info));
- }
- if (stat_success == -1) {
- return File::kDoesNotExist;
- }
- if (S_ISDIR(entry_info.st_mode)) {
- return File::kIsDirectory;
- }
- if (S_ISREG(entry_info.st_mode)) {
- return File::kIsFile;
- }
- if (S_ISLNK(entry_info.st_mode)) {
- return File::kIsLink;
- }
- return File::kDoesNotExist;
-}
-
-
File::Identical File::AreIdentical(const char* file_1, const char* file_2) {
struct stat64 file_1_info;
struct stat64 file_2_info;
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc
index d1259f7..767908e 100644
--- a/runtime/bin/file_macos.cc
+++ b/runtime/bin/file_macos.cc
@@ -268,71 +268,91 @@
}
-bool File::Delete(const char* name) {
- File::Type type = File::GetType(name, true);
- if (type == kIsFile) {
- return NO_RETRY_EXPECTED(unlink(name)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
+File::Type File::GetType(const char* pathname, bool follow_links) {
+ struct stat entry_info;
+ int stat_success;
+ if (follow_links) {
+ stat_success = NO_RETRY_EXPECTED(stat(pathname, &entry_info));
} else {
- errno = ENOENT;
+ stat_success = NO_RETRY_EXPECTED(lstat(pathname, &entry_info));
+ }
+ if (stat_success == -1) {
+ return File::kDoesNotExist;
+ }
+ if (S_ISDIR(entry_info.st_mode)) {
+ return File::kIsDirectory;
+ }
+ if (S_ISREG(entry_info.st_mode)) {
+ return File::kIsFile;
+ }
+ if (S_ISLNK(entry_info.st_mode)) {
+ return File::kIsLink;
+ }
+ return File::kDoesNotExist;
+}
+
+
+static bool CheckTypeAndSetErrno(const char* name,
+ File::Type expected,
+ bool follow_links) {
+ File::Type actual = File::GetType(name, follow_links);
+ if (actual == expected) {
+ return true;
+ }
+ switch (actual) {
+ case File::kIsDirectory:
+ errno = EISDIR;
+ break;
+ case File::kDoesNotExist:
+ errno = ENOENT;
+ break;
+ default:
+ errno = EINVAL;
+ break;
}
return false;
}
+bool File::Delete(const char* name) {
+ return CheckTypeAndSetErrno(name, kIsFile, true) &&
+ (NO_RETRY_EXPECTED(unlink(name)) == 0);
+}
+
+
bool File::DeleteLink(const char* name) {
- File::Type type = File::GetType(name, false);
- if (type == kIsLink) {
- return NO_RETRY_EXPECTED(unlink(name)) == 0;
- }
- errno = EINVAL;
- return false;
+ return CheckTypeAndSetErrno(name, kIsLink, false) &&
+ (NO_RETRY_EXPECTED(unlink(name)) == 0);
}
bool File::Rename(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, true);
- if (type == kIsFile) {
- return NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = ENOENT;
- }
- return false;
+ return CheckTypeAndSetErrno(old_path, kIsFile, true) &&
+ (NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0);
}
bool File::RenameLink(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, false);
- if (type == kIsLink) {
- return NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = EINVAL;
- }
- return false;
+ return CheckTypeAndSetErrno(old_path, kIsLink, false) &&
+ (NO_RETRY_EXPECTED(rename(old_path, new_path)) == 0);
}
bool File::Copy(const char* old_path, const char* new_path) {
- File::Type type = File::GetType(old_path, true);
- if (type == kIsFile) {
- return copyfile(old_path, new_path, NULL, COPYFILE_ALL) == 0;
- } else if (type == kIsDirectory) {
- errno = EISDIR;
- } else {
- errno = ENOENT;
- }
- return false;
+ return CheckTypeAndSetErrno(old_path, kIsFile, true) &&
+ (copyfile(old_path, new_path, NULL, COPYFILE_ALL) == 0);
}
int64_t File::LengthFromPath(const char* name) {
struct stat st;
if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
+ // Signal an error if it's a directory.
+ if (S_ISDIR(st.st_mode)) {
+ errno = EISDIR;
+ return -1;
+ }
+ // Otherwise assume the caller knows what it's doing.
return st.st_size;
}
return -1;
@@ -374,6 +394,12 @@
time_t File::LastModified(const char* name) {
struct stat st;
if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
+ // Signal an error if it's a directory.
+ if (S_ISDIR(st.st_mode)) {
+ errno = EISDIR;
+ return -1;
+ }
+ // Otherwise assume the caller knows what it's doing.
return st.st_mtime;
}
return -1;
@@ -465,30 +491,6 @@
}
-File::Type File::GetType(const char* pathname, bool follow_links) {
- struct stat entry_info;
- int stat_success;
- if (follow_links) {
- stat_success = NO_RETRY_EXPECTED(stat(pathname, &entry_info));
- } else {
- stat_success = NO_RETRY_EXPECTED(lstat(pathname, &entry_info));
- }
- if (stat_success == -1) {
- return File::kDoesNotExist;
- }
- if (S_ISDIR(entry_info.st_mode)) {
- return File::kIsDirectory;
- }
- if (S_ISREG(entry_info.st_mode)) {
- return File::kIsFile;
- }
- if (S_ISLNK(entry_info.st_mode)) {
- return File::kIsLink;
- }
- return File::kDoesNotExist;
-}
-
-
File::Identical File::AreIdentical(const char* file_1, const char* file_2) {
struct stat file_1_info;
struct stat file_2_info;
diff --git a/runtime/bin/file_patch.dart b/runtime/bin/file_patch.dart
index 2fe1414..5e4b16a 100644
--- a/runtime/bin/file_patch.dart
+++ b/runtime/bin/file_patch.dart
@@ -77,14 +77,14 @@
@patch static Stream<FileSystemEvent> _watch(
String path, int events, bool recursive) {
if (Platform.isLinux) {
- return new _InotifyFileSystemWatcher(path, events, recursive).stream;
+ return new _InotifyFileSystemWatcher(path, events, recursive)._stream;
}
if (Platform.isWindows) {
- return new _Win32FileSystemWatcher(path, events, recursive).stream;
+ return new _Win32FileSystemWatcher(path, events, recursive)._stream;
}
if (Platform.isMacOS) {
return new _FSEventStreamFileSystemWatcher(
- path, events, recursive).stream;
+ path, events, recursive)._stream;
}
throw new FileSystemException(
"File system watching is not supported on this platform");
@@ -100,7 +100,7 @@
onCancel: _cancel);
}
- Stream get stream => _broadcastController.stream;
+ Stream get _stream => _broadcastController.stream;
void _listen() {
if (_id == null) {
diff --git a/runtime/bin/file_win.cc b/runtime/bin/file_win.cc
index 79272d3..3cfdf69 100644
--- a/runtime/bin/file_win.cc
+++ b/runtime/bin/file_win.cc
@@ -444,7 +444,12 @@
Utf8ToWideScope system_name(name);
int stat_status = _wstat64(system_name.wide(), &st);
if (stat_status == 0) {
- return st.st_size;
+ if ((st.st_mode & S_IFMT) == S_IFREG) {
+ return st.st_size;
+ } else {
+ // ERROR_DIRECTORY_NOT_SUPPORTED is not always in the message table.
+ SetLastError(ERROR_NOT_SUPPORTED);
+ }
}
return -1;
}
@@ -539,7 +544,12 @@
Utf8ToWideScope system_name(name);
int stat_status = _wstat64(system_name.wide(), &st);
if (stat_status == 0) {
- return st.st_mtime;
+ if ((st.st_mode & S_IFMT) == S_IFREG) {
+ return st.st_mtime;
+ } else {
+ // ERROR_DIRECTORY_NOT_SUPPORTED is not always in the message table.
+ SetLastError(ERROR_NOT_SUPPORTED);
+ }
}
return -1;
}
diff --git a/runtime/bin/process_android.cc b/runtime/bin/process_android.cc
index 550f680..11949ba 100644
--- a/runtime/bin/process_android.cc
+++ b/runtime/bin/process_android.cc
@@ -163,9 +163,12 @@
// monitor.
running_ = false;
- // Fork to wake up waitpid.
+ // Wake up the [ExitCodeHandler] thread which is blocked on `wait()` (see
+ // [ExitCodeHandlerEntry]).
if (TEMP_FAILURE_RETRY(fork()) == 0) {
- exit(0);
+ // We avoid running through registered atexit() handlers because that is
+ // unnecessary work.
+ _exit(0);
}
monitor_->Notify();
diff --git a/runtime/bin/process_linux.cc b/runtime/bin/process_linux.cc
index c8a2f7b..4197869 100644
--- a/runtime/bin/process_linux.cc
+++ b/runtime/bin/process_linux.cc
@@ -163,9 +163,12 @@
// monitor.
running_ = false;
- // Fork to wake up waitpid.
+ // Wake up the [ExitCodeHandler] thread which is blocked on `wait()` (see
+ // [ExitCodeHandlerEntry]).
if (TEMP_FAILURE_RETRY(fork()) == 0) {
- exit(0);
+ // We avoid running through registered atexit() handlers because that is
+ // unnecessary work.
+ _exit(0);
}
monitor_->Notify();
diff --git a/runtime/lib/array_patch.dart b/runtime/lib/array_patch.dart
index f834394..db4626a 100644
--- a/runtime/lib/array_patch.dart
+++ b/runtime/lib/array_patch.dart
@@ -11,14 +11,7 @@
const _GROWABLE_ARRAY_MARKER = const _GrowableArrayMarker();
@patch class List<E> {
- @patch factory List([int length = _GROWABLE_ARRAY_MARKER]) {
- if (identical(length, _GROWABLE_ARRAY_MARKER)) {
- return new _GrowableList<E>(0);
- }
- // All error handling on the length parameter is done at the implementation
- // of new _List.
- return new _List<E>(length);
- }
+ @patch factory List([int length]) = List<E>._internal;
@patch factory List.filled(int length, E fill, {bool growable: false}) {
// All error handling on the length parameter is done at the implementation
@@ -59,6 +52,17 @@
return makeFixedListUnmodifiable(result);
}
+ // The List factory constructor redirects to this one so that we can change
+ // length's default value from the one in the SDK's implementation.
+ factory List._internal([int length = _GROWABLE_ARRAY_MARKER]) {
+ if (identical(length, _GROWABLE_ARRAY_MARKER)) {
+ return new _GrowableList<E>(0);
+ }
+ // All error handling on the length parameter is done at the implementation
+ // of new _List.
+ return new _List<E>(length);
+ }
+
// Factory constructing a mutable List from a parser generated List literal.
// [elements] contains elements that are already type checked.
factory List._fromLiteral(List elements) {
diff --git a/runtime/lib/convert_patch.dart b/runtime/lib/convert_patch.dart
index 25a8dc5..9606568 100644
--- a/runtime/lib/convert_patch.dart
+++ b/runtime/lib/convert_patch.dart
@@ -6,7 +6,7 @@
// JSON conversion.
-@patch _parseJson(String json, reviver(var key, var value)) {
+@patch _parseJson(String source, reviver(key, value)) {
_BuildJsonListener listener;
if (reviver == null) {
listener = new _BuildJsonListener();
@@ -14,8 +14,8 @@
listener = new _ReviverJsonListener(reviver);
}
var parser = new _JsonStringParser(listener);
- parser.chunk = json;
- parser.chunkEnd = json.length;
+ parser.chunk = source;
+ parser.chunkEnd = source.length;
parser.parse(0);
parser.close();
return listener.result;
@@ -23,8 +23,8 @@
@patch class Utf8Decoder {
@patch
- Converter<List<int>, dynamic/*=T*/> fuse/*<T>*/(
- Converter<String, dynamic/*=T*/> next) {
+ Converter<List<int>, T> fuse<T>(
+ Converter<String, T> next) {
if (next is JsonDecoder) {
return new _JsonUtf8Decoder(next._reviver, this._allowMalformed)
as dynamic/*=Converter<List<int>, T>*/;
diff --git a/runtime/lib/double_patch.dart b/runtime/lib/double_patch.dart
index b0b7054..2b9fb28 100644
--- a/runtime/lib/double_patch.dart
+++ b/runtime/lib/double_patch.dart
@@ -101,12 +101,12 @@
return _nativeParse(str, start, end);
}
- @patch static double parse(String str,
- [double onError(String str)]) {
- var result = _parse(str);
+ @patch
+ static double parse(String source, [double onError(String source)]) {
+ var result = _parse(source);
if (result == null) {
- if (onError == null) throw new FormatException("Invalid double", str);
- return onError(str);
+ if (onError == null) throw new FormatException("Invalid double", source);
+ return onError(source);
}
return result;
}
diff --git a/runtime/lib/errors_patch.dart b/runtime/lib/errors_patch.dart
index af2293f..69ae219 100644
--- a/runtime/lib/errors_patch.dart
+++ b/runtime/lib/errors_patch.dart
@@ -212,13 +212,17 @@
final int _invocation_type;
@patch
- NoSuchMethodError(Object this._receiver,
- Symbol this._memberName,
- List this._arguments,
- Map<Symbol, dynamic> this._namedArguments,
+ NoSuchMethodError(Object receiver,
+ Symbol memberName,
+ List positionalArguments,
+ Map<Symbol, dynamic> namedArguments,
[List existingArgumentNames = null])
- : this._existingArgumentNames = existingArgumentNames,
- this._invocation_type = -1;
+ : _receiver = receiver,
+ _memberName = memberName,
+ _arguments = positionalArguments,
+ _namedArguments = namedArguments,
+ _existingArgumentNames = existingArgumentNames,
+ _invocation_type = -1;
// This constructor seems to be called with either strings or
// values read from another NoSuchMethodError.
diff --git a/runtime/lib/expando_patch.dart b/runtime/lib/expando_patch.dart
index ac5f706..af55a4d 100644
--- a/runtime/lib/expando_patch.dart
+++ b/runtime/lib/expando_patch.dart
@@ -3,8 +3,9 @@
// BSD-style license that can be found in the LICENSE file.
@patch class Expando<T> {
- @patch Expando([String this.name])
- : _data = new List(_minSize),
+ @patch Expando([String name])
+ : name = name,
+ _data = new List(_minSize),
_used = 0;
static const _minSize = 8;
diff --git a/runtime/lib/math_patch.dart b/runtime/lib/math_patch.dart
index 1be57ac..7d5e752 100644
--- a/runtime/lib/math_patch.dart
+++ b/runtime/lib/math_patch.dart
@@ -57,15 +57,15 @@
}
@patch double atan2(num a, num b) => _atan2(a.toDouble(), b.toDouble());
-@patch double sin(num value) => _sin(value.toDouble());
-@patch double cos(num value) => _cos(value.toDouble());
-@patch double tan(num value) => _tan(value.toDouble());
-@patch double acos(num value) => _acos(value.toDouble());
-@patch double asin(num value) => _asin(value.toDouble());
-@patch double atan(num value) => _atan(value.toDouble());
-@patch double sqrt(num value) => _sqrt(value.toDouble());
-@patch double exp(num value) => _exp(value.toDouble());
-@patch double log(num value) => _log(value.toDouble());
+@patch double sin(num x) => _sin(x.toDouble());
+@patch double cos(num x) => _cos(x.toDouble());
+@patch double tan(num x) => _tan(x.toDouble());
+@patch double acos(num x) => _acos(x.toDouble());
+@patch double asin(num x) => _asin(x.toDouble());
+@patch double atan(num x) => _atan(x.toDouble());
+@patch double sqrt(num x) => _sqrt(x.toDouble());
+@patch double exp(num x) => _exp(x.toDouble());
+@patch double log(num x) => _log(x.toDouble());
double _atan2(double a, double b) native "Math_atan2";
double _sin(double x) native "Math_sin";
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index 7a2efe0..f99b111 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -852,7 +852,7 @@
if (decl.IsClass()) {
klass ^= decl.raw();
library = klass.library();
- } else if (decl.IsFunction()) {
+ } else if (decl.IsFunction() && !Function::Cast(decl).IsSignatureFunction()) {
klass = Function::Cast(decl).origin();
library = klass.library();
} else if (decl.IsField()) {
@@ -1667,8 +1667,7 @@
Array::Handle(ArgumentsDescriptor::New(args.Length(), arg_names));
ArgumentsDescriptor args_descriptor(args_descriptor_array);
- if (!redirected_constructor.AreValidArguments(args_descriptor, NULL) ||
- !redirected_constructor.is_reflectable()) {
+ if (!redirected_constructor.AreValidArguments(args_descriptor, NULL)) {
external_constructor_name = redirected_constructor.name();
ThrowNoSuchMethod(AbstractType::Handle(klass.RareType()),
external_constructor_name, redirected_constructor,
diff --git a/runtime/lib/profiler.dart b/runtime/lib/profiler.dart
index b60760a..acf6f58 100644
--- a/runtime/lib/profiler.dart
+++ b/runtime/lib/profiler.dart
@@ -9,7 +9,6 @@
@patch static UserTag get defaultTag => _getDefaultTag();
}
-
class _UserTag implements UserTag {
factory _UserTag(String label) native "UserTag_new";
String get label native "UserTag_label";
diff --git a/runtime/lib/timeline.dart b/runtime/lib/timeline.dart
index b2aa165..55a40e8 100644
--- a/runtime/lib/timeline.dart
+++ b/runtime/lib/timeline.dart
@@ -22,7 +22,7 @@
@patch void _reportCompleteEvent(
int start,
- int end,
+ int startCpu,
String category,
String name,
String argumentsAsJson) native "Timeline_reportCompleteEvent";
diff --git a/runtime/lib/typed_data_patch.dart b/runtime/lib/typed_data_patch.dart
index 6ad50f3..ab055ee 100644
--- a/runtime/lib/typed_data_patch.dart
+++ b/runtime/lib/typed_data_patch.dart
@@ -731,8 +731,6 @@
}
class _Int8List extends _TypedList with _IntListMixin implements Int8List {
- Type get runtimeType => Int8List;
-
// Method(s) implementing List interface.
int operator [](int index) {
if (index < 0 || index >= length) {
@@ -772,8 +770,6 @@
}
class _Uint8List extends _TypedList with _IntListMixin implements Uint8List {
- Type get runtimeType => Uint8List;
-
// Methods implementing List interface.
int operator [](int index) {
if (index < 0 || index >= length) {
@@ -815,8 +811,6 @@
class _Uint8ClampedList extends _TypedList
with _IntListMixin
implements Uint8ClampedList {
- Type get runtimeType => Uint8ClampedList;
-
// Methods implementing List interface.
int operator [](int index) {
if (index < 0 || index >= length) {
@@ -856,8 +850,6 @@
}
class _Int16List extends _TypedList with _IntListMixin implements Int16List {
- Type get runtimeType => Int16List;
-
// Method(s) implementing List interface.
int operator [](int index) {
if (index < 0 || index >= length) {
@@ -916,8 +908,6 @@
}
class _Uint16List extends _TypedList with _IntListMixin implements Uint16List {
- Type get runtimeType => Uint16List;
-
// Method(s) implementing the List interface.
int operator [](int index) {
if (index < 0 || index >= length) {
@@ -976,8 +966,6 @@
}
class _Int32List extends _TypedList with _IntListMixin implements Int32List {
- Type get runtimeType => Int32List;
-
// Method(s) implementing the List interface.
int operator [](int index) {
if (index < 0 || index >= length) {
@@ -1025,8 +1013,6 @@
}
class _Uint32List extends _TypedList with _IntListMixin implements Uint32List {
- Type get runtimeType => Uint32List;
-
// Method(s) implementing the List interface.
int operator [](int index) {
if (index < 0 || index >= length) {
@@ -1074,8 +1060,6 @@
}
class _Int64List extends _TypedList with _IntListMixin implements Int64List {
- Type get runtimeType => Int64List;
-
// Method(s) implementing the List interface.
int operator [](int index) {
if (index < 0 || index >= length) {
@@ -1123,8 +1107,6 @@
}
class _Uint64List extends _TypedList with _IntListMixin implements Uint64List {
- Type get runtimeType => Uint64List;
-
// Method(s) implementing the List interface.
int operator [](int index) {
if (index < 0 || index >= length) {
@@ -1174,8 +1156,6 @@
class _Float32List extends _TypedList
with _DoubleListMixin
implements Float32List {
- Type get runtimeType => Float32List;
-
// Method(s) implementing the List interface.
double operator [](int index) {
if (index < 0 || index >= length) {
@@ -1225,8 +1205,6 @@
class _Float64List extends _TypedList
with _DoubleListMixin
implements Float64List {
- Type get runtimeType => Float64List;
-
// Method(s) implementing the List interface.
double operator [](int index) {
if (index < 0 || index >= length) {
@@ -1276,8 +1254,6 @@
class _Float32x4List extends _TypedList
with _Float32x4ListMixin
implements Float32x4List {
- Type get runtimeType => Float32x4List;
-
Float32x4 operator [](int index) {
if (index < 0 || index >= length) {
throw new RangeError.index(index, this, "index");
@@ -1326,8 +1302,6 @@
class _Int32x4List extends _TypedList
with _Int32x4ListMixin
implements Int32x4List {
- Type get runtimeType => Int32x4List;
-
Int32x4 operator [](int index) {
if (index < 0 || index >= length) {
throw new RangeError.index(index, this, "index");
@@ -1376,8 +1350,6 @@
class _Float64x2List extends _TypedList
with _Float64x2ListMixin
implements Float64x2List {
- Type get runtimeType => Float64x2List;
-
Float64x2 operator [](int index) {
if (index < 0 || index >= length) {
throw new RangeError.index(index, this, "index");
diff --git a/runtime/observatory/lib/src/elements/isolate_view.dart b/runtime/observatory/lib/src/elements/isolate_view.dart
index ef157c0..706de4c 100644
--- a/runtime/observatory/lib/src/elements/isolate_view.dart
+++ b/runtime/observatory/lib/src/elements/isolate_view.dart
@@ -269,6 +269,26 @@
..children = [
new DivElement()
..classes = ['memberName']
+ ..text = 'allocated zone handle count',
+ new DivElement()
+ ..classes = ['memberValue']
+ ..text = '${_isolate.numZoneHandles}'
+ ],
+ new DivElement()
+ ..classes = ['memberItem']
+ ..children = [
+ new DivElement()
+ ..classes = ['memberName']
+ ..text = 'allocated scoped handle count',
+ new DivElement()
+ ..classes = ['memberValue']
+ ..text = '${_isolate.numScopedHandles}'
+ ],
+ new DivElement()
+ ..classes = ['memberItem']
+ ..children = [
+ new DivElement()
+ ..classes = ['memberName']
..text = 'object store',
new DivElement()
..classes = ['memberValue']
diff --git a/runtime/observatory/lib/src/models/objects/isolate.dart b/runtime/observatory/lib/src/models/objects/isolate.dart
index 8cc5c79..02d436d 100644
--- a/runtime/observatory/lib/src/models/objects/isolate.dart
+++ b/runtime/observatory/lib/src/models/objects/isolate.dart
@@ -54,6 +54,12 @@
/// The list of threads associated with this isolate.
Iterable<Thread> get threads;
+ /// The number of zone handles currently held by this isolate.
+ int get numZoneHandles;
+
+ /// The number of scoped handles currently held by this isolate.
+ int get numScopedHandles;
+
/// The current pause on exception mode for this isolate.
//ExceptionPauseMode get exceptionPauseMode;
diff --git a/runtime/observatory/lib/src/service/object.dart b/runtime/observatory/lib/src/service/object.dart
index b9e0f6e..9ff8200 100644
--- a/runtime/observatory/lib/src/service/object.dart
+++ b/runtime/observatory/lib/src/service/object.dart
@@ -43,12 +43,12 @@
static const kIsolateMustBeRunnable = 105;
static const kIsolateMustBePaused = 106;
static const kCannotResume = 107;
- static const kIsolateIsReloading = 1000;
+ static const kIsolateIsReloading = 108;
+ static const kIsolateReloadBarred = 109;
+
static const kFileSystemAlreadyExists = 1001;
static const kFileSystemDoesNotExist = 1002;
static const kFileDoesNotExist = 1003;
- static const kIsolateReloadFailed = 1004;
- static const kIsolateReloadBarred = 1005;
int code;
Map data;
@@ -1507,6 +1507,12 @@
List<Thread> get threads => _threads;
final List<Thread> _threads = new List<Thread>();
+ int get numZoneHandles => _numZoneHandles;
+ int _numZoneHandles;
+
+ int get numScopedHandles => _numScopedHandles;
+ int _numScopedHandles;
+
void _loadHeapSnapshot(ServiceEvent event) {
if (_snapshotFetch == null || _snapshotFetch.isClosed) {
// No outstanding snapshot request. Presumably another client asked for a
@@ -1635,6 +1641,13 @@
if(map['threads'] != null) {
threads.addAll(map['threads']);
}
+
+ if (map['threads'] != null) {
+ threads.addAll(map['threads']);
+ }
+
+ _numZoneHandles = map['_numZoneHandles'];
+ _numScopedHandles = map['_numScopedHandles'];
}
Future<TagProfile> updateTagProfile() {
@@ -2551,33 +2564,33 @@
return M.InstanceKind.float64x2;
case 'Int32x4':
return M.InstanceKind.int32x4;
- case '_Uint8ClampedList':
+ case 'Uint8ClampedList':
return M.InstanceKind.uint8ClampedList;
- case '_Uint8List':
+ case 'Uint8List':
return M.InstanceKind.uint8List;
- case '_Uint16List':
+ case 'Uint16List':
return M.InstanceKind.uint16List;
- case '_Uint32List':
+ case 'Uint32List':
return M.InstanceKind.uint32List;
- case '_Uint64List':
+ case 'Uint64List':
return M.InstanceKind.uint64List;
- case '_Int8List':
+ case 'Int8List':
return M.InstanceKind.int8List;
- case '_Int16List':
+ case 'Int16List':
return M.InstanceKind.int16List;
- case '_Int32List':
+ case 'Int32List':
return M.InstanceKind.int32List;
- case '_Int64List':
+ case 'Int64List':
return M.InstanceKind.int64List;
- case '_Float32List':
+ case 'Float32List':
return M.InstanceKind.float32List;
- case '_Float64List':
+ case 'Float64List':
return M.InstanceKind.float64List;
- case '_Int32x4List':
+ case 'Int32x4List':
return M.InstanceKind.int32x4List;
- case '_Float32x4List':
+ case 'Float32x4List':
return M.InstanceKind.float32x4List;
- case '_Float64x2List':
+ case 'Float64x2List':
return M.InstanceKind.float64x2List;
case 'StackTrace':
return M.InstanceKind.stackTrace;
@@ -2791,46 +2804,46 @@
if (map['bytes'] != null) {
Uint8List bytes = BASE64.decode(map['bytes']);
switch (map['kind']) {
- case "_Uint8ClampedList":
+ case "Uint8ClampedList":
typedElements = bytes.buffer.asUint8ClampedList();
break;
- case "_Uint8List":
+ case "Uint8List":
typedElements = bytes.buffer.asUint8List();
break;
- case "_Uint16List":
+ case "Uint16List":
typedElements = bytes.buffer.asUint16List();
break;
- case "_Uint32List":
+ case "Uint32List":
typedElements = bytes.buffer.asUint32List();
break;
- case "_Uint64List":
+ case "Uint64List":
typedElements = bytes.buffer.asUint64List();
break;
- case "_Int8List":
+ case "Int8List":
typedElements = bytes.buffer.asInt8List();
break;
- case "_Int16List":
+ case "Int16List":
typedElements = bytes.buffer.asInt16List();
break;
- case "_Int32List":
+ case "Int32List":
typedElements = bytes.buffer.asInt32List();
break;
- case "_Int64List":
+ case "Int64List":
typedElements = bytes.buffer.asInt64List();
break;
- case "_Float32List":
+ case "Float32List":
typedElements = bytes.buffer.asFloat32List();
break;
- case "_Float64List":
+ case "Float64List":
typedElements = bytes.buffer.asFloat64List();
break;
- case "_Int32x4List":
+ case "Int32x4List":
typedElements = bytes.buffer.asInt32x4List();
break;
- case "_Float32x4List":
+ case "Float32x4List":
typedElements = bytes.buffer.asFloat32x4List();
break;
- case "_Float64x2List":
+ case "Float64x2List":
typedElements = bytes.buffer.asFloat64x2List();
break;
}
diff --git a/runtime/observatory/tests/service/get_isolate_rpc_test.dart b/runtime/observatory/tests/service/get_isolate_rpc_test.dart
index 840c705..74940c7 100644
--- a/runtime/observatory/tests/service/get_isolate_rpc_test.dart
+++ b/runtime/observatory/tests/service/get_isolate_rpc_test.dart
@@ -23,6 +23,8 @@
expect(result['pauseOnExit'], isFalse);
expect(result['pauseEvent']['type'], equals('Event'));
expect(result['error'], isNull);
+ expect(result['numZoneHandles'], isPositive);
+ expect(result['numScopedHandles'], isPositive);
expect(result['rootLib']['type'], equals('@Library'));
expect(result['libraries'].length, isPositive);
expect(result['libraries'][0]['type'], equals('@Library'));
diff --git a/runtime/observatory/tests/service/get_object_rpc_test.dart b/runtime/observatory/tests/service/get_object_rpc_test.dart
index 893ec84..e933d49 100644
--- a/runtime/observatory/tests/service/get_object_rpc_test.dart
+++ b/runtime/observatory/tests/service/get_object_rpc_test.dart
@@ -436,7 +436,7 @@
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
- expect(result['kind'], equals('_Uint8List'));
+ expect(result['kind'], equals('Uint8List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
@@ -462,7 +462,7 @@
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
- expect(result['kind'], equals('_Uint8List'));
+ expect(result['kind'], equals('Uint8List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
@@ -489,7 +489,7 @@
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
- expect(result['kind'], equals('_Uint8List'));
+ expect(result['kind'], equals('Uint8List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
@@ -516,7 +516,7 @@
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
- expect(result['kind'], equals('_Uint8List'));
+ expect(result['kind'], equals('Uint8List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
@@ -539,7 +539,7 @@
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
- expect(result['kind'], equals('_Uint64List'));
+ expect(result['kind'], equals('Uint64List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
@@ -565,7 +565,7 @@
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
- expect(result['kind'], equals('_Uint64List'));
+ expect(result['kind'], equals('Uint64List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
@@ -592,7 +592,7 @@
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
- expect(result['kind'], equals('_Uint64List'));
+ expect(result['kind'], equals('Uint64List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
@@ -619,7 +619,7 @@
};
var result = await isolate.invokeRpcNoUpgrade('getObject', params);
expect(result['type'], equals('Instance'));
- expect(result['kind'], equals('_Uint64List'));
+ expect(result['kind'], equals('Uint64List'));
expect(result['_vmType'], equals('TypedData'));
expect(result['id'], startsWith('objects/'));
expect(result['valueAsString'], isNull);
diff --git a/runtime/observatory/tests/service/service.status b/runtime/observatory/tests/service/service.status
index d39e46f..562604a 100644
--- a/runtime/observatory/tests/service/service.status
+++ b/runtime/observatory/tests/service/service.status
@@ -40,6 +40,126 @@
developer_extension_test: SkipByDesign
get_isolate_after_language_error_test: SkipByDesign
+# Issue #28236
+add_breakpoint_rpc_test: StaticWarning
+address_mapper_test: StaticWarning
+allocations_test: StaticWarning
+async_generator_breakpoint_test: StaticWarning
+async_next_test: StaticWarning
+async_scope_test: StaticWarning
+auth_token1_test: StaticWarning
+auth_token_test: StaticWarning
+bad_web_socket_address_test: StaticWarning
+break_on_activation_test: StaticWarning
+break_on_function_test: StaticWarning
+breakpoint_two_args_checked_test: StaticWarning
+caching_test: StaticWarning
+capture_stdio_test: StaticWarning
+code_test: StaticWarning
+command_test: StaticWarning
+complex_reload_test: StaticWarning
+contexts_test: StaticWarning
+crash_dump_test: StaticWarning
+debugger_inspect_test: StaticWarning
+debugger_location_second_test: StaticWarning
+debugger_location_test: StaticWarning
+debugging_inlined_finally_test: StaticWarning
+debugging_test: StaticWarning
+dev_fs_http_put_test: StaticWarning
+dev_fs_http_put_weird_char_test: StaticWarning
+dev_fs_spawn_test: StaticWarning
+dev_fs_test: StaticWarning
+dev_fs_weird_char_test: StaticWarning
+developer_server_control_test: StaticWarning
+developer_service_get_isolate_id_test: StaticWarning
+dominator_tree_user_test: StaticWarning
+dominator_tree_vm_test: StaticWarning
+echo_test: StaticWarning
+eval_internal_class_test: StaticWarning
+eval_test: StaticWarning
+evaluate_activation_test/instance: StaticWarning
+evaluate_activation_test/none: StaticWarning
+evaluate_activation_test/scope: StaticWarning
+evaluate_in_async_activation_test: StaticWarning
+evaluate_in_async_star_activation_test: StaticWarning
+evaluate_in_frame_rpc_test: StaticWarning
+evaluate_in_sync_star_activation_test: StaticWarning
+file_service_test: StaticWarning
+gc_test: StaticWarning
+get_allocation_profile_rpc_test: StaticWarning
+get_allocation_samples_test: StaticWarning
+get_cpu_profile_timeline_rpc_test: StaticWarning
+get_flag_list_rpc_test: StaticWarning
+get_heap_map_rpc_test: StaticWarning
+get_instances_rpc_test: StaticWarning
+get_isolate_after_async_error_test: StaticWarning
+get_isolate_after_stack_overflow_error_test: StaticWarning
+get_isolate_after_sync_error_test: StaticWarning
+get_isolate_rpc_test: StaticWarning
+get_object_rpc_test: StaticWarning
+get_object_store_rpc_test: StaticWarning
+get_ports_rpc_test: StaticWarning
+get_retained_size_rpc_test: StaticWarning
+get_retaining_path_rpc_test: StaticWarning
+get_source_report_test: StaticWarning
+get_stack_rpc_test: StaticWarning
+get_version_rpc_test: StaticWarning
+get_vm_rpc_test: StaticWarning
+get_vm_timeline_rpc_test: StaticWarning
+get_zone_memory_info_rpc_test: StaticWarning
+implicit_getter_setter_test: StaticWarning
+inbound_references_test: StaticWarning
+instance_field_order_rpc_test: StaticWarning
+isolate_lifecycle_test: StaticWarning
+issue_25465_test: StaticWarning
+issue_27238_test: StaticWarning
+issue_27287_test: StaticWarning
+library_dependency_test: StaticWarning
+local_variable_declaration_test: StaticWarning
+logging_test: StaticWarning
+malformed_test: StaticWarning
+metrics_test: StaticWarning
+mirror_references_test: StaticWarning
+native_metrics_test: StaticWarning
+object_graph_stack_reference_test: StaticWarning
+object_graph_user_test: StaticWarning
+object_graph_vm_test: StaticWarning
+observatory_assets_test: StaticWarning
+parameters_in_scope_at_entry_test: StaticWarning
+pause_idle_isolate_test: StaticWarning
+pause_on_exceptions_test: StaticWarning
+pause_on_start_and_exit_test: StaticWarning
+pause_on_start_then_step_test: StaticWarning
+pause_on_unhandled_exceptions_test: StaticWarning
+positive_token_pos_test: StaticWarning
+process_service_test: StaticWarning
+reachable_size_test: StaticWarning
+read_stream_test: StaticWarning
+regexp_function_test: StaticWarning
+reload_sources_test: StaticWarning
+rewind_optimized_out_test: StaticWarning
+rewind_test: StaticWarning
+set_library_debuggable_rpc_test: StaticWarning
+set_library_debuggable_test: StaticWarning
+set_name_rpc_test: StaticWarning
+set_vm_name_rpc_test: StaticWarning
+smart_next_test: StaticWarning
+steal_breakpoint_test: StaticWarning
+step_into_async_no_await_test: StaticWarning
+step_over_await_test: StaticWarning
+step_test: StaticWarning
+string_escaping_test: StaticWarning
+tcp_socket_closing_service_test: StaticWarning
+tcp_socket_service_test: StaticWarning
+type_arguments_test: StaticWarning
+typed_data_test: StaticWarning
+udp_socket_service_test: StaticWarning
+vm_restart_test: StaticWarning
+vm_test: StaticWarning
+vm_timeline_events_test: StaticWarning
+vm_timeline_flags_test: StaticWarning
+weak_properties_test: StaticWarning
+
[ $arch == arm ]
process_service_test: Pass, Fail # Issue 24344
@@ -62,7 +182,7 @@
set_name_rpc_test: RuntimeError # Issue 27806
vm_restart_test: CompileTimeError # Issue 27806
-debugger_location_second_test: RuntimeError, Crash # Issue 28180
+debugger_location_second_test: Skip # Issue 28180
[ $compiler == dart2analyzer ]
evaluate_activation_in_method_class_test: CompileTimeError # Issue 24478
diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status
index 7f7fe43..0a2934a 100644
--- a/runtime/tests/vm/vm.status
+++ b/runtime/tests/vm/vm.status
@@ -2,12 +2,13 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
-cc/IsolateReload_PendingUnqualifiedCall_InstanceToStatic: Fail, Crash
-cc/IsolateReload_PendingUnqualifiedCall_StaticToInstance: Fail, Crash
-cc/IsolateReload_PendingConstructorCall_AbstractToConcrete: Fail, Crash
-cc/IsolateReload_PendingConstructorCall_ConcreteToAbstract: Fail, Crash
-cc/IsolateReload_PendingStaticCall_DefinedToNSM: Fail, Crash
-cc/IsolateReload_PendingStaticCall_NSMToDefined: Fail, Crash
+# Issue 28198
+cc/IsolateReload_PendingUnqualifiedCall_InstanceToStatic: Fail, Crash, Timeout
+cc/IsolateReload_PendingUnqualifiedCall_StaticToInstance: Fail, Crash, Timeout
+cc/IsolateReload_PendingConstructorCall_AbstractToConcrete: Fail, Crash, Timeout
+cc/IsolateReload_PendingConstructorCall_ConcreteToAbstract: Fail, Crash, Timeout
+cc/IsolateReload_PendingStaticCall_DefinedToNSM: Fail, Crash, Timeout
+cc/IsolateReload_PendingStaticCall_NSMToDefined: Fail, Crash, Timeout
# These tests are expected to crash on all platforms.
cc/ArrayNew_Overflow_Crash: Crash, Timeout
diff --git a/runtime/tools/gyp/runtime-configurations.gypi b/runtime/tools/gyp/runtime-configurations.gypi
index 95168b0..2de3bf9 100644
--- a/runtime/tools/gyp/runtime-configurations.gypi
+++ b/runtime/tools/gyp/runtime-configurations.gypi
@@ -11,6 +11,7 @@
'dart_io_secure_socket%': 1,
'asan%': 0,
'msan%': 0,
+ 'tsan%': 0,
# Intel VTune related variables.
'dart_vtune_support%': 0,
'conditions': [
diff --git a/runtime/vm/BUILD.gn b/runtime/vm/BUILD.gn
index bc89894..1142e57 100644
--- a/runtime/vm/BUILD.gn
+++ b/runtime/vm/BUILD.gn
@@ -520,6 +520,11 @@
"../lib",
],
[
+ "typed_data",
+ processed_gypis.typed_data_runtime_sources,
+ "../lib",
+ ],
+ [
"vmservice",
processed_gypis.vmservice_runtime_sources,
"../lib",
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index f13d562..adf967e 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -549,11 +549,34 @@
// Resolve signature if function type.
if (type.IsFunctionType()) {
const Function& signature = Function::Handle(Type::Cast(type).signature());
- const Class& scope_class = Class::Handle(type.type_class());
- if (scope_class.IsTypedefClass()) {
- ResolveSignature(scope_class, signature);
+ Type& signature_type = Type::Handle(signature.SignatureType());
+ if (signature_type.raw() != type.raw()) {
+ ResolveType(cls, signature_type);
} else {
- ResolveSignature(cls, signature);
+ const Class& scope_class = Class::Handle(type.type_class());
+ if (scope_class.IsTypedefClass()) {
+ ResolveSignature(scope_class, signature);
+ } else {
+ ResolveSignature(cls, signature);
+ }
+ if (signature.IsSignatureFunction()) {
+ // Drop fields that are not necessary anymore after resolution.
+ // The parent function, owner, and token position of a shared
+ // canonical function type are meaningless, since the canonical
+ // representent is picked arbitrarily.
+ signature.set_parent_function(Function::Handle());
+ // TODO(regis): As long as we support metadata in typedef signatures,
+ // we cannot reset these fields used to reparse a typedef.
+ // Note that the scope class of a typedef function type is always
+ // preserved as the typedef class (not reset to _Closure class), thereby
+ // preventing sharing of canonical function types between typedefs.
+ // Not being shared, these fields are therefore always meaningful for
+ // typedefs.
+ if (!scope_class.IsTypedefClass()) {
+ signature.set_owner(Object::Handle());
+ signature.set_token_pos(TokenPosition::kNoSource);
+ }
+ }
}
}
}
@@ -2331,8 +2354,9 @@
cls.set_mixin(mixin_type);
}
if (cls.IsTypedefClass()) {
- const Function& signature = Function::Handle(cls.signature_function());
+ Function& signature = Function::Handle(cls.signature_function());
Type& type = Type::Handle(signature.SignatureType());
+ ASSERT(type.signature() == signature.raw());
// Check for illegal self references.
GrowableArray<intptr_t> visited_aliases;
@@ -2350,7 +2374,12 @@
// Resolve and finalize the signature type of this typedef.
type ^= FinalizeType(cls, type, kCanonicalizeWellFormed);
+
+ // If a different canonical signature type is returned, update the signature
+ // function of the typedef.
+ signature = type.signature();
signature.SetSignatureType(type);
+ cls.set_signature_function(signature);
// Closure instances do not refer to this typedef as their class, so there
// is no need to add this typedef class to the subclasses of _Closure.
diff --git a/runtime/vm/class_table.cc b/runtime/vm/class_table.cc
index 4ceeb60..0094cd5 100644
--- a/runtime/vm/class_table.cc
+++ b/runtime/vm/class_table.cc
@@ -124,9 +124,11 @@
// Add the vtable for this predefined class into the static vtable registry
// if it has not been setup yet.
cpp_vtable cls_vtable = cls.handle_vtable();
- AtomicOperations::CompareAndSwapWord(&(Object::builtin_vtables_[index]), 0,
- cls_vtable);
- ASSERT(Object::builtin_vtables_[index] == cls_vtable);
+ cpp_vtable old_cls_vtable = AtomicOperations::CompareAndSwapWord(
+ &(Object::builtin_vtables_[index]), 0, cls_vtable);
+ if (old_cls_vtable != 0) {
+ ASSERT(old_cls_vtable == cls_vtable);
+ }
} else {
if (top_ == capacity_) {
// Grow the capacity of the class table.
diff --git a/runtime/vm/class_table.h b/runtime/vm/class_table.h
index b1721ed..1edb248 100644
--- a/runtime/vm/class_table.h
+++ b/runtime/vm/class_table.h
@@ -6,6 +6,7 @@
#define RUNTIME_VM_CLASS_TABLE_H_
#include "platform/assert.h"
+#include "vm/atomic.h"
#include "vm/bitfield.h"
#include "vm/globals.h"
@@ -36,8 +37,8 @@
}
void AddNew(T size) {
- new_count++;
- new_size += size;
+ AtomicOperations::IncrementBy(&new_count, 1);
+ AtomicOperations::IncrementBy(&new_size, size);
}
void ResetOld() {
@@ -46,8 +47,8 @@
}
void AddOld(T size, T count = 1) {
- old_count += count;
- old_size += size;
+ AtomicOperations::IncrementBy(&old_count, count);
+ AtomicOperations::IncrementBy(&old_size, size);
}
void Reset() {
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
index 8f06434..fee4b89 100644
--- a/runtime/vm/compiler.cc
+++ b/runtime/vm/compiler.cc
@@ -1161,8 +1161,6 @@
// }
}
}
- // Mark that this isolate now has compiled code.
- isolate()->set_has_compiled_code(true);
// Exit the loop and the function with the correct result value.
is_compiled = true;
done = true;
@@ -1595,8 +1593,12 @@
// if state changed while compiling in background.
LongJumpScope jump;
if (setjmp(*jump.Set()) == 0) {
- Parser::ParseFunction(parsed_function);
- parsed_function->AllocateVariables();
+ if (function.kernel_function() == NULL) {
+ Parser::ParseFunction(parsed_function);
+ parsed_function->AllocateVariables();
+ } else {
+ parsed_function->EnsureKernelScopes();
+ }
const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle(
parsed_function->node_sequence()->scope()->GetVarDescriptors(function));
ASSERT(!var_descs.IsNull());
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 8304532..622f9c1 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -792,7 +792,6 @@
debugger_(NULL),
resume_request_(false),
last_resume_timestamp_(OS::GetCurrentTimeMillis()),
- has_compiled_code_(false),
random_(),
simulator_(NULL),
mutex_(new Mutex()),
@@ -2044,6 +2043,12 @@
jsobj.AddProperty("rootLib", lib);
}
+ intptr_t zone_handle_count = thread_registry_->CountZoneHandles();
+ intptr_t scoped_handle_count = thread_registry_->CountScopedHandles();
+
+ jsobj.AddProperty("_numZoneHandles", zone_handle_count);
+ jsobj.AddProperty("_numScopedHandles", scoped_handle_count);
+
if (FLAG_profiler) {
JSONObject tagCounters(&jsobj, "_tagCounters");
vm_tag_counters()->PrintToJSONObject(&tagCounters);
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index 88df144..10f44f0 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -313,9 +313,6 @@
return OFFSET_OF(Isolate, single_step_);
}
- void set_has_compiled_code(bool value) { has_compiled_code_ = value; }
- bool has_compiled_code() const { return has_compiled_code_; }
-
// Lets the embedder know that a service message resulted in a resume request.
void SetResumeRequest() {
resume_request_ = true;
@@ -730,7 +727,6 @@
Debugger* debugger_;
bool resume_request_;
int64_t last_resume_timestamp_;
- bool has_compiled_code_; // Can check that no compilation occured.
Random random_;
Simulator* simulator_;
Mutex* mutex_; // Protects compiler stats.
diff --git a/runtime/vm/isolate_reload.cc b/runtime/vm/isolate_reload.cc
index c375df3..08f33db 100644
--- a/runtime/vm/isolate_reload.cc
+++ b/runtime/vm/isolate_reload.cc
@@ -1596,6 +1596,9 @@
handle_ = obj;
if (handle_.IsFunction()) {
const Function& func = Function::Cast(handle_);
+ if (func.IsSignatureFunction()) {
+ return;
+ }
// Switch to unoptimized code or the lazy compilation stub.
func.SwitchToLazyCompiledUnoptimizedCode();
diff --git a/runtime/vm/isolate_reload_test.cc b/runtime/vm/isolate_reload_test.cc
index 287eb71..be2a2f3 100644
--- a/runtime/vm/isolate_reload_test.cc
+++ b/runtime/vm/isolate_reload_test.cc
@@ -16,6 +16,8 @@
#ifndef PRODUCT
+DECLARE_FLAG(bool, support_deprecated_tearoff_syntax);
+
// TODO(johnmccutchan):
// - Tests involving generics.
@@ -1434,19 +1436,19 @@
"main() {\n"
" var c = new C();\n"
" list[0] = c.foo;\n"
- " list[1] = c#foo;\n"
+ " list[1] = c.foo;\n"
" set.add(c.foo);\n"
- " set.add(c#foo);\n"
+ " set.add(c.foo);\n"
" int countBefore = set.length;\n"
" reloadTest();\n"
" list[1] = c.foo;\n"
" set.add(c.foo);\n"
- " set.add(c#foo);\n"
+ " set.add(c.foo);\n"
" int countAfter = set.length;\n"
" return '${list[0]()} ${list[1]()} ${list[0] == list[1]} '\n"
" '${countBefore == 1} ${countAfter == 1} ${(set.first)()} '\n"
- " '${set.first == c.foo} ${set.first == c#foo} '\n"
- " '${set.remove(c#foo)}';\n"
+ " '${set.first == c.foo} ${set.first == c.foo} '\n"
+ " '${set.remove(c.foo)}';\n"
"}\n";
Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
@@ -1462,19 +1464,19 @@
"main() {\n"
" var c = new C();\n"
" list[0] = c.foo;\n"
- " list[1] = c#foo;\n"
+ " list[1] = c.foo;\n"
" set.add(c.foo);\n"
- " set.add(c#foo);\n"
+ " set.add(c.foo);\n"
" int countBefore = set.length;\n"
" reloadTest();\n"
" list[1] = c.foo;\n"
" set.add(c.foo);\n"
- " set.add(c#foo);\n"
+ " set.add(c.foo);\n"
" int countAfter = set.length;\n"
" return '${list[0]()} ${list[1]()} ${list[0] == list[1]} '\n"
" '${countBefore == 1} ${countAfter == 1} ${(set.first)()} '\n"
- " '${set.first == c.foo} ${set.first == c#foo} '\n"
- " '${set.remove(c#foo)}';\n"
+ " '${set.first == c.foo} ${set.first == c.foo} '\n"
+ " '${set.remove(c.foo)}';\n"
"}\n";
TestCase::SetReloadTestScript(kReloadScript);
@@ -1503,7 +1505,7 @@
"}\n"
"main() {\n"
" var c = new C();\n"
- " var f = c#y;\n"
+ " var f = c.y;\n"
" var r1 = invoke(f);\n"
" reloadTest();\n"
" var r2 = invoke(f);\n"
@@ -1527,7 +1529,7 @@
"}\n"
"main() {\n"
" var c = new C();\n"
- " var f = c#y;\n"
+ " var f = c.y;\n"
" var r1 = invoke(f);\n"
" reloadTest();\n"
" var r2 = invoke(f);\n"
@@ -1536,8 +1538,10 @@
TestCase::SetReloadTestScript(kReloadScript);
- EXPECT_STREQ("4 NoSuchMethodError: Class 'C' has no instance getter 'y'.",
- SimpleInvokeStr(lib, "main"));
+ EXPECT_STREQ(
+ "NoSuchMethodError: Class 'int' has no instance method 'call'. "
+ "NoSuchMethodError: Class 'int' has no instance method 'call'.",
+ SimpleInvokeStr(lib, "main"));
lib = TestCase::GetReloadErrorOrRootLibrary();
EXPECT_VALID(lib);
@@ -1561,7 +1565,7 @@
"main() {\n"
" C.x = 3;\n"
" C.y = 4;\n"
- " var f = C#y;\n"
+ " var f = C.y;\n"
" var r1 = invoke(f);\n"
" reloadTest();\n"
" var r2 = invoke(f);\n"
@@ -1586,7 +1590,7 @@
"main() {\n"
" C.x = 3;\n"
" C.y = 4;\n"
- " var f = C#y;\n"
+ " var f = C.y;\n"
" var r1 = invoke(f);\n"
" reloadTest();\n"
" var r2 = invoke(f);\n"
@@ -1596,8 +1600,8 @@
TestCase::SetReloadTestScript(kReloadScript);
EXPECT_STREQ(
- "4 NoSuchMethodError: No static getter 'y' declared "
- "in class 'C'.",
+ "NoSuchMethodError: Class 'int' has no instance method 'call'. "
+ "NoSuchMethodError: Class 'int' has no instance method 'call'.",
SimpleInvokeStr(lib, "main"));
lib = TestCase::GetReloadErrorOrRootLibrary();
@@ -1648,6 +1652,7 @@
" return '$r1 $r2';\n"
"}\n";
+ FLAG_support_deprecated_tearoff_syntax = true;
Dart_Handle lib = TestCase::LoadTestScript(
kScript, IsolateReload_DanlingGetter_LibraryNativeResolver);
EXPECT_VALID(lib);
@@ -1659,6 +1664,7 @@
lib = TestCase::GetReloadErrorOrRootLibrary();
EXPECT_VALID(lib);
+ FLAG_support_deprecated_tearoff_syntax = false;
}
@@ -1685,6 +1691,7 @@
" return '$r1 $r2';\n"
"}\n";
+ FLAG_support_deprecated_tearoff_syntax = true;
Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
EXPECT_VALID(lib);
@@ -1716,6 +1723,7 @@
lib = TestCase::GetReloadErrorOrRootLibrary();
EXPECT_VALID(lib);
+ FLAG_support_deprecated_tearoff_syntax = false;
}
@@ -1743,6 +1751,7 @@
" return '$r1 $r2';\n"
"}\n";
+ FLAG_support_deprecated_tearoff_syntax = true;
Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
EXPECT_VALID(lib);
@@ -1777,6 +1786,7 @@
lib = TestCase::GetReloadErrorOrRootLibrary();
EXPECT_VALID(lib);
+ FLAG_support_deprecated_tearoff_syntax = false;
}
@@ -1823,6 +1833,7 @@
" return '$r1 $r2';\n"
"}\n";
+ FLAG_support_deprecated_tearoff_syntax = true;
Dart_Handle lib = TestCase::LoadTestScript(
kScript, IsolateReload_DanlingSetter_LibraryNativeResolver);
EXPECT_VALID(lib);
@@ -1834,6 +1845,7 @@
lib = TestCase::GetReloadErrorOrRootLibrary();
EXPECT_VALID(lib);
+ FLAG_support_deprecated_tearoff_syntax = false;
}
@@ -1852,7 +1864,7 @@
"}\n"
"main() {\n"
" var c = new C();\n"
- " var f = c#foo;\n"
+ " var f = c.foo;\n"
" var r1 = invoke(f, 1);\n"
" reloadTest();\n"
" var r2 = invoke(f, 1);\n"
@@ -1876,7 +1888,7 @@
"}\n"
"main() {\n"
" var c = new C();\n"
- " var f = c#foo;\n"
+ " var f = c.foo;\n"
" var r1 = invoke(f, 1);\n"
" reloadTest();\n"
" var r2 = invoke(f, 1);\n"
@@ -1909,7 +1921,7 @@
" }\n"
"}\n"
"main() {\n"
- " var f = C#foo;\n"
+ " var f = C.foo;\n"
" var r1 = invoke(f, 1);\n"
" reloadTest();\n"
" var r2 = invoke(f, 1);\n"
@@ -1932,7 +1944,7 @@
" }\n"
"}\n"
"main() {\n"
- " var f = C#foo;\n"
+ " var f = C.foo;\n"
" var r1 = invoke(f, 1);\n"
" reloadTest();\n"
" var r2 = invoke(f, 1);\n"
diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc
index 7bbdc6f..f098998 100644
--- a/runtime/vm/json_stream.cc
+++ b/runtime/vm/json_stream.cc
@@ -150,8 +150,8 @@
return "File system does not exist";
case kFileDoesNotExist:
return "File does not exist";
- case kIsolateReloadFailed:
- return "Isolate reload failed";
+ case kIsolateReloadBarred:
+ return "Isolate cannot be reloaded";
default:
return "Extension error";
}
diff --git a/runtime/vm/json_stream.h b/runtime/vm/json_stream.h
index e49b846..6f4e85a 100644
--- a/runtime/vm/json_stream.h
+++ b/runtime/vm/json_stream.h
@@ -56,14 +56,13 @@
kIsolateMustBeRunnable = 105,
kIsolateMustBePaused = 106,
kCannotResume = 107,
+ kIsolateIsReloading = 108,
+ kIsolateReloadBarred = 109,
// Experimental (used in private rpcs).
- kIsolateIsReloading = 1000,
kFileSystemAlreadyExists = 1001,
kFileSystemDoesNotExist = 1002,
kFileDoesNotExist = 1003,
- kIsolateReloadFailed = 1004,
- kIsolateReloadBarred = 1005,
};
// Expected that user_data is a JSONStream*.
diff --git a/runtime/vm/kernel.h b/runtime/vm/kernel.h
index 15bf633..998bc5e 100644
--- a/runtime/vm/kernel.h
+++ b/runtime/vm/kernel.h
@@ -311,29 +311,37 @@
};
-class LineStartingTable {
+class SourceTable {
public:
void ReadFrom(Reader* reader);
void WriteTo(Writer* writer);
- ~LineStartingTable() {
+ ~SourceTable() {
for (intptr_t i = 0; i < size_; ++i) {
- delete[] values_[i];
+ delete source_code_[i];
+ delete[] line_starts_[i];
}
- delete[] values_;
+ delete[] source_code_;
+ delete[] line_starts_;
+ delete[] line_count_;
}
intptr_t size() { return size_; }
- intptr_t* valuesFor(int i) { return values_[i]; }
+ String* SourceFor(intptr_t i) { return source_code_[i]; }
+ intptr_t* LineStartsFor(intptr_t i) { return line_starts_[i]; }
+ intptr_t LineCountFor(intptr_t i) { return line_count_[i]; }
private:
- LineStartingTable() : values_(NULL), size_(0) {}
+ SourceTable()
+ : source_code_(NULL), line_starts_(NULL), line_count_(NULL), size_(0) {}
friend class Program;
- intptr_t** values_;
+ String** source_code_;
+ intptr_t** line_starts_;
+ intptr_t* line_count_;
intptr_t size_;
- DISALLOW_COPY_AND_ASSIGN(LineStartingTable);
+ DISALLOW_COPY_AND_ASSIGN(SourceTable);
};
// Forward declare all classes.
@@ -2798,7 +2806,7 @@
StringTable& string_table() { return string_table_; }
StringTable& source_uri_table() { return source_uri_table_; }
- LineStartingTable& line_starting_table() { return line_starting_table_; }
+ SourceTable& source_table() { return source_table_; }
List<Library>& libraries() { return libraries_; }
Procedure* main_method() { return main_method_; }
@@ -2809,7 +2817,7 @@
Ref<Procedure> main_method_;
StringTable string_table_;
StringTable source_uri_table_;
- LineStartingTable line_starting_table_;
+ SourceTable source_table_;
DISALLOW_COPY_AND_ASSIGN(Program);
};
diff --git a/runtime/vm/kernel_binary.cc b/runtime/vm/kernel_binary.cc
index 25b8899..f204854 100644
--- a/runtime/vm/kernel_binary.cc
+++ b/runtime/vm/kernel_binary.cc
@@ -828,33 +828,37 @@
}
-void LineStartingTable::ReadFrom(Reader* reader) {
+void SourceTable::ReadFrom(Reader* reader) {
size_ = reader->helper()->program()->source_uri_table().strings().length();
- values_ = new intptr_t*[size_];
+ source_code_ = new String*[size_];
+ line_starts_ = new intptr_t*[size_];
+ line_count_ = new intptr_t[size_];
for (intptr_t i = 0; i < size_; ++i) {
+ source_code_[i] = StringImpl::ReadFrom(reader);
intptr_t line_count = reader->ReadUInt();
- intptr_t* line_starts = new intptr_t[line_count + 1];
- line_starts[0] = line_count;
+ intptr_t* line_starts = new intptr_t[line_count];
+ line_count_[i] = line_count;
intptr_t previous_line_start = 0;
for (intptr_t j = 0; j < line_count; ++j) {
intptr_t line_start = reader->ReadUInt() + previous_line_start;
- line_starts[j + 1] = line_start;
+ line_starts[j] = line_start;
previous_line_start = line_start;
}
- values_[i] = line_starts;
+ line_starts_[i] = line_starts;
}
}
-void LineStartingTable::WriteTo(Writer* writer) {
+void SourceTable::WriteTo(Writer* writer) {
for (intptr_t i = 0; i < size_; ++i) {
- intptr_t* line_starts = values_[i];
- intptr_t line_count = line_starts[0];
+ StringImpl::WriteTo(writer, source_code_[i]);
+ intptr_t* line_starts = line_starts_[i];
+ intptr_t line_count = line_count_[i];
writer->WriteUInt(line_count);
intptr_t previous_line_start = 0;
for (intptr_t j = 0; j < line_count; ++j) {
- intptr_t line_start = line_starts[j + 1];
+ intptr_t line_start = line_starts[j];
writer->WriteUInt(line_start - previous_line_start);
previous_line_start = line_start;
}
@@ -2828,7 +2832,7 @@
program->string_table_.ReadFrom(reader);
program->source_uri_table_.ReadFrom(reader);
- program->line_starting_table_.ReadFrom(reader);
+ program->source_table_.ReadFrom(reader);
int libraries = reader->ReadUInt();
program->libraries().EnsureInitialized(libraries);
@@ -2853,7 +2857,7 @@
// strings in nodes are present in [string_table_].
string_table_.WriteTo(writer);
source_uri_table_.WriteTo(writer);
- line_starting_table_.WriteTo(writer);
+ source_table_.WriteTo(writer);
libraries_.WriteTo(writer);
Reference::WriteMemberTo(writer, main_method_);
diff --git a/runtime/vm/kernel_reader.cc b/runtime/vm/kernel_reader.cc
index d11e931..5b76f17 100644
--- a/runtime/vm/kernel_reader.cc
+++ b/runtime/vm/kernel_reader.cc
@@ -103,7 +103,7 @@
type_translator_(&translation_helper_,
&active_class_,
/*finalize=*/false) {
- intptr_t source_file_count = program_->line_starting_table().size();
+ intptr_t source_file_count = program_->source_table().size();
scripts_ = Array::New(source_file_count, Heap::kOld);
}
@@ -158,7 +158,8 @@
}
// Setup toplevel class (which contains library fields/procedures).
- Script& script = ScriptAt(kernel_library->source_uri_index());
+ Script& script = ScriptAt(kernel_library->source_uri_index(),
+ kernel_library->import_uri());
dart::Class& toplevel_class = dart::Class::Handle(
Z, dart::Class::New(library, Symbols::TopLevel(), script,
TokenPosition::kNoSource));
@@ -293,6 +294,8 @@
const dart::String& name = H.DartFieldName(kernel_field->name());
const AbstractType& type =
T.TranslateTypeWithoutFinalization(kernel_field->type());
+ const Object& script_class =
+ ClassForScriptAt(klass, kernel_field->source_uri_index());
dart::Field& field = dart::Field::Handle(
Z, dart::Field::New(name, kernel_field->IsStatic(),
// In the VM all const fields are implicitly final
@@ -301,7 +304,7 @@
kernel_field->IsFinal() || kernel_field->IsConst(),
kernel_field->IsConst(),
false, // is_reflectable
- klass, type, kernel_field->position()));
+ script_class, type, kernel_field->position()));
field.set_kernel_field(kernel_field);
field.set_has_initializer(kernel_field->initializer() != NULL);
GenerateFieldAccessors(klass, field, kernel_field);
@@ -322,7 +325,8 @@
false, // is_abstract
kernel_constructor->IsExternal(),
false, // is_native
- klass, TokenPosition::kNoSource));
+ klass, TokenPosition::kMinSource));
+ function.set_end_token_pos(TokenPosition::kMinSource);
klass.AddFunction(function);
function.set_kernel_function(kernel_constructor);
function.set_result_type(T.ReceiverType(klass));
@@ -399,7 +403,8 @@
false, // is_const
is_abstract, is_external,
native_name != NULL, // is_native
- script_class, TokenPosition::kNoSource));
+ script_class, TokenPosition::kMinSource));
+ function.set_end_token_pos(TokenPosition::kMinSource);
owner.AddFunction(function);
function.set_kernel_function(kernel_procedure);
function.set_is_debuggable(false);
@@ -430,21 +435,30 @@
return klass;
}
-Script& KernelReader::ScriptAt(intptr_t source_uri_index) {
+Script& KernelReader::ScriptAt(intptr_t source_uri_index, String* import_uri) {
Script& script = Script::ZoneHandle(Z);
script ^= scripts_.At(source_uri_index);
if (script.IsNull()) {
+ // Create script with correct uri(s).
String* uri = program_->source_uri_table().strings()[source_uri_index];
- script = Script::New(H.DartString(uri, Heap::kOld),
- dart::String::ZoneHandle(Z), RawScript::kKernelTag);
+ dart::String& uri_string = H.DartString(uri, Heap::kOld);
+ dart::String& import_uri_string =
+ import_uri == NULL ? uri_string : H.DartString(import_uri, Heap::kOld);
+ dart::String& source_code = H.DartString(
+ program_->source_table().SourceFor(source_uri_index), Heap::kOld);
+ script = Script::New(import_uri_string, uri_string, source_code,
+ RawScript::kKernelTag);
scripts_.SetAt(source_uri_index, script);
+
+ // Create line_starts array for the script.
intptr_t* line_starts =
- program_->line_starting_table().valuesFor(source_uri_index);
- intptr_t line_count = line_starts[0];
+ program_->source_table().LineStartsFor(source_uri_index);
+ intptr_t line_count =
+ program_->source_table().LineCountFor(source_uri_index);
Array& array_object = Array::Handle(Z, Array::New(line_count, Heap::kOld));
Smi& value = Smi::Handle(Z);
for (intptr_t i = 0; i < line_count; ++i) {
- value = Smi::New(line_starts[i + 1]);
+ value = Smi::New(line_starts[i]);
array_object.SetAt(i, value);
}
script.set_line_starts(array_object);
diff --git a/runtime/vm/kernel_reader.h b/runtime/vm/kernel_reader.h
index f6b4ffd..a4c739d 100644
--- a/runtime/vm/kernel_reader.h
+++ b/runtime/vm/kernel_reader.h
@@ -84,7 +84,7 @@
// Otherwise return klass.
const Object& ClassForScriptAt(const dart::Class& klass,
intptr_t source_uri_index);
- Script& ScriptAt(intptr_t source_uri_index);
+ Script& ScriptAt(intptr_t source_uri_index, String* import_uri = NULL);
void GenerateFieldAccessors(const dart::Class& klass,
const dart::Field& field,
diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc
index 2f1b8f2..98f83f8 100644
--- a/runtime/vm/kernel_to_il.cc
+++ b/runtime/vm/kernel_to_il.cc
@@ -662,7 +662,7 @@
node->body()->AcceptStatementVisitor(this);
}
- // Ensure that :await_jump_var and :await_ctx_var are captured.
+ // Ensure that :await_jump_var, :await_ctx_var and :async_op are captured.
if (node->async_marker() == FunctionNode::kSyncYielding) {
{
LocalVariable* temp = NULL;
@@ -676,6 +676,13 @@
(depth_.function_ == 0) ? &result_->yield_context_variable : &temp,
Symbols::AwaitContextVar());
}
+ {
+ LocalVariable* temp =
+ scope_->LookupVariable(Symbols::AsyncOperation(), true);
+ if (temp != NULL) {
+ scope_->CaptureVariable(temp);
+ }
+ }
}
}
@@ -3953,7 +3960,7 @@
// So we convert malformed return/parameter types to `dynamic`.
TypeParameterScope scope(this, &node->type_parameters());
- const Function& signature_function = Function::ZoneHandle(
+ Function& signature_function = Function::ZoneHandle(
Z, Function::NewSignatureFunction(*active_class_->klass,
TokenPosition::kNoSource));
@@ -4008,8 +4015,10 @@
if (finalize_) {
signature_type ^= ClassFinalizer::FinalizeType(
*active_class_->klass, signature_type, ClassFinalizer::kCanonicalize);
+ // Do not refer to signature_function anymore, since it may have been
+ // replaced during canonicalization.
+ signature_function = Function::null();
}
- signature_function.SetSignatureType(signature_type);
result_ = signature_type.raw();
}
diff --git a/runtime/vm/method_recognizer.h b/runtime/vm/method_recognizer.h
index 14410a1..3a4dff1 100644
--- a/runtime/vm/method_recognizer.h
+++ b/runtime/vm/method_recognizer.h
@@ -47,8 +47,8 @@
V(_Double, _sub, DoubleSub, Double, 0x4f466391) \
V(_Double, _mul, DoubleMul, Double, 0x175e4f66) \
V(_Double, _div, DoubleDiv, Double, 0x0854181b) \
- V(::, min, MathMin, Dynamic, 0x4276561c) \
- V(::, max, MathMax, Dynamic, 0x54121d6a) \
+ V(::, min, MathMin, Dynamic, 0x0bee5d52) \
+ V(::, max, MathMax, Dynamic, 0x4f51acb6) \
V(::, _doublePow, MathDoublePow, Double, 0x01d7b09e) \
V(Float32x4, Float32x4., Float32x4Constructor, Float32x4, 0x05968999) \
V(Float32x4, Float32x4.zero, Float32x4Zero, Float32x4, 0x472a4c46) \
@@ -226,16 +226,16 @@
#define MATH_LIB_INTRINSIC_LIST(V) \
- V(::, sqrt, MathSqrt, Double, 0x0a683033) \
+ V(::, sqrt, MathSqrt, Double, 0x70482cf3) \
V(_Random, _nextState, Random_nextState, Dynamic, 0x24d91397) \
#define GRAPH_MATH_LIB_INTRINSIC_LIST(V) \
- V(::, sin, MathSin, Double, 0x595a044c) \
- V(::, cos, MathCos, Double, 0x337a20be) \
- V(::, tan, MathTan, Double, 0x29aba1ea) \
- V(::, asin, MathAsin, Double, 0x48ec330d) \
- V(::, acos, MathAcos, Double, 0x22ef2552) \
- V(::, atan, MathAtan, Double, 0x38473515) \
+ V(::, sin, MathSin, Double, 0x3f3a010c) \
+ V(::, cos, MathCos, Double, 0x195a1d7e) \
+ V(::, tan, MathTan, Double, 0x0f8b9eaa) \
+ V(::, asin, MathAsin, Double, 0x2ecc2fcd) \
+ V(::, acos, MathAcos, Double, 0x08cf2212) \
+ V(::, atan, MathAtan, Double, 0x1e2731d5) \
V(::, atan2, MathAtan2, Double, 0x39f1fa41) \
#define TYPED_DATA_LIB_INTRINSIC_LIST(V) \
@@ -407,10 +407,10 @@
V(_ByteDataView, getUint64, ByteDataViewGetUint64, 0x4dd4eedd) \
V(_ByteDataView, getFloat32, ByteDataViewGetFloat32, 0x474b4719) \
V(_ByteDataView, getFloat64, ByteDataViewGetFloat64, 0x47207cf7) \
- V(::, exp, MathExp, 0x4ccba23a) \
- V(::, log, MathLog, 0x3908fd3c) \
- V(::, max, MathMax, 0x54121d6a) \
- V(::, min, MathMin, 0x4276561c) \
+ V(::, exp, MathExp, 0x32ab9efa) \
+ V(::, log, MathLog, 0x1ee8f9fc) \
+ V(::, max, MathMax, 0x4f51acb6) \
+ V(::, min, MathMin, 0x0bee5d52) \
V(::, pow, MathPow, 0x443379a8) \
V(::, _classRangeCheck, ClassRangeCheck, 0x025e8d82) \
V(::, _classRangeCheckNegative, ClassRangeCheckNegated, 0x32451d73) \
@@ -431,14 +431,14 @@
// A list of core function that should never be inlined.
#define INLINE_BLACK_LIST(V) \
- V(::, asin, MathAsin, 0x48ec330d) \
- V(::, acos, MathAcos, 0x22ef2552) \
- V(::, atan, MathAtan, 0x38473515) \
+ V(::, asin, MathAsin, 0x2ecc2fcd) \
+ V(::, acos, MathAcos, 0x08cf2212) \
+ V(::, atan, MathAtan, 0x1e2731d5) \
V(::, atan2, MathAtan2, 0x39f1fa41) \
- V(::, cos, MathCos, 0x337a20be) \
- V(::, sin, MathSin, 0x595a044c) \
- V(::, sqrt, MathSqrt, 0x0a683033) \
- V(::, tan, MathTan, 0x29aba1ea) \
+ V(::, cos, MathCos, 0x195a1d7e) \
+ V(::, sin, MathSin, 0x3f3a010c) \
+ V(::, sqrt, MathSqrt, 0x70482cf3) \
+ V(::, tan, MathTan, 0x0f8b9eaa) \
V(_Bigint, _lsh, Bigint_lsh, 0x0619eb8a) \
V(_Bigint, _rsh, Bigint_rsh, 0x0e1b80df) \
V(_Bigint, _absAdd, Bigint_absAdd, 0x1a2b6326) \
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index fd81fee..7fa4c2f 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -1510,7 +1510,7 @@
ASSERT(lib.raw() == Library::TypedDataLibrary());
#define REGISTER_TYPED_DATA_CLASS(clazz) \
cls = Class::NewTypedDataClass(kTypedData##clazz##ArrayCid); \
- RegisterPrivateClass(cls, Symbols::clazz##List(), lib);
+ RegisterPrivateClass(cls, Symbols::_##clazz##List(), lib);
DART_CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS);
#undef REGISTER_TYPED_DATA_CLASS
@@ -3477,6 +3477,11 @@
Zone* zone = Thread::Current()->zone();
const Script& scr = Script::Handle(zone, script());
ASSERT(!scr.IsNull());
+
+ if (scr.kind() == RawScript::kKernelTag) {
+ return TokenPosition::kMinSource;
+ }
+
const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens());
if (tkns.IsNull()) {
ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT);
@@ -5563,6 +5568,7 @@
ASSERT(!obj.IsNull());
if (IsSignatureFunction()) {
SignatureData::Cast(obj).set_signature_type(value);
+ ASSERT(!value.IsCanonical() || (value.signature() == this->raw()));
} else {
ASSERT(IsClosureFunction());
ClosureData::Cast(obj).set_signature_type(value);
@@ -5722,7 +5728,7 @@
void Function::set_owner(const Object& value) const {
- ASSERT(!value.IsNull());
+ ASSERT(!value.IsNull() || IsSignatureFunction());
StorePointer(&raw_ptr()->owner_, value.raw());
}
@@ -6948,6 +6954,10 @@
RawClass* Function::Owner() const {
+ if (raw_ptr()->owner_ == Object::null()) {
+ ASSERT(IsSignatureFunction());
+ return Class::null();
+ }
if (raw_ptr()->owner_->IsClass()) {
return Class::RawCast(raw_ptr()->owner_);
}
@@ -6958,6 +6968,10 @@
RawClass* Function::origin() const {
+ if (raw_ptr()->owner_ == Object::null()) {
+ ASSERT(IsSignatureFunction());
+ return Class::null();
+ }
if (raw_ptr()->owner_->IsClass()) {
return Class::RawCast(raw_ptr()->owner_);
}
@@ -6982,6 +6996,10 @@
return Function::Handle(parent_function()).script();
}
const Object& obj = Object::Handle(raw_ptr()->owner_);
+ if (obj.IsNull()) {
+ ASSERT(IsSignatureFunction());
+ return Script::null();
+ }
if (obj.IsClass()) {
return Class::Cast(obj).script();
}
@@ -7299,21 +7317,6 @@
void SignatureData::set_signature_type(const Type& value) const {
StorePointer(&raw_ptr()->signature_type_, value.raw());
- // If the signature type is resolved, the parent function is not needed
- // anymore (type parameters may be declared by generic parent functions).
- // Keeping the parent function can unnecessarily pull more objects into a
- // snapshot. Also, the parent function is meaningless once the signature type
- // is canonicalized.
-
-// TODO(rmacnak): Keeping the parent function for unresolved signature types
-// is causing a tree shaking issue in AOT. Please, investigate.
-#if 0
- if (value.IsResolved()) {
- set_parent_function(Function::Handle());
- }
-#else
- set_parent_function(Function::Handle());
-#endif
}
@@ -7577,7 +7580,7 @@
bool is_final,
bool is_const,
bool is_reflectable,
- const Class& owner,
+ const Object& owner,
const AbstractType& type,
TokenPosition token_pos) {
ASSERT(!owner.IsNull());
@@ -8789,6 +8792,11 @@
RawString* Script::GenerateSource() const {
+ if (kind() == RawScript::kKernelTag) {
+ // In kernel it's embedded.
+ return raw_ptr()->source_;
+ }
+
const TokenStream& token_stream = TokenStream::Handle(tokens());
if (token_stream.IsNull()) {
ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT);
@@ -8810,8 +8818,32 @@
const String& source = String::Handle(zone, Source());
const String& key = Symbols::Empty();
const Object& line_separator = Object::Handle(zone);
- const TokenStream& tkns = TokenStream::Handle(zone, tokens());
Smi& value = Smi::Handle(zone);
+
+ if (kind() == RawScript::kKernelTag) {
+ const Array& line_starts_array = Array::Handle(line_starts());
+ if (line_starts_array.IsNull()) {
+ // Scripts in the AOT snapshot do not have a line starts array.
+ // A well-formed line number array has a leading null.
+ info.Add(line_separator); // New line.
+ return info.raw();
+ }
+ intptr_t line_count = line_starts_array.Length();
+ ASSERT(line_count > 0);
+
+ for (int i = 0; i < line_count; i++) {
+ info.Add(line_separator); // New line.
+ value = Smi::New(i + 1);
+ info.Add(value); // Line number.
+ value ^= line_starts_array.At(i);
+ info.Add(value); // Token position.
+ value = Smi::New(1);
+ info.Add(value); // Column.
+ }
+ return info.raw();
+ }
+
+ const TokenStream& tkns = TokenStream::Handle(zone, tokens());
String& tokenValue = String::Handle(zone);
ASSERT(!tkns.IsNull());
TokenStream::Iterator tkit(zone, tkns, TokenPosition::kMinSource,
@@ -8943,6 +8975,10 @@
void Script::Tokenize(const String& private_key, bool use_shared_tokens) const {
+ if (kind() == RawScript::kKernelTag) {
+ return;
+ }
+
Thread* thread = Thread::Current();
Zone* zone = thread->zone();
const TokenStream& tkns = TokenStream::Handle(zone, tokens());
@@ -9009,7 +9045,9 @@
}
*line = min + 1;
smi ^= line_starts_array.At(min);
- *column = offset - smi.Value() + 1;
+ if (column != NULL) {
+ *column = offset - smi.Value() + 1;
+ }
if (token_len != NULL) {
*token_len = 1;
}
@@ -9068,6 +9106,29 @@
TokenPosition* last_token_index) const {
ASSERT(first_token_index != NULL && last_token_index != NULL);
ASSERT(line_number > 0);
+
+ if (kind() == RawScript::kKernelTag) {
+ const Array& line_starts_array = Array::Handle(line_starts());
+ if (line_starts_array.IsNull()) {
+ // Scripts in the AOT snapshot do not have a line starts array.
+ *first_token_index = TokenPosition::kNoSource;
+ *last_token_index = TokenPosition::kNoSource;
+ return;
+ }
+ ASSERT(line_starts_array.Length() >= line_number);
+ Smi& value = Smi::Handle();
+ value ^= line_starts_array.At(line_number - 1);
+ *first_token_index = TokenPosition(value.Value());
+ if (line_starts_array.Length() > line_number) {
+ value ^= line_starts_array.At(line_number);
+ *last_token_index = TokenPosition(value.Value() - 1);
+ } else {
+ // Length of source is last possible token in this script.
+ *last_token_index = TokenPosition(String::Handle(Source()).Length());
+ }
+ return;
+ }
+
Zone* zone = Thread::Current()->zone();
*first_token_index = TokenPosition::kNoSource;
*last_token_index = TokenPosition::kNoSource;
@@ -13824,9 +13885,6 @@
if (v.IsNull()) {
ASSERT(!is_optimized());
const Function& f = Function::Handle(function());
- if (f.kernel_function() != NULL) {
- return v.raw();
- }
ASSERT(!f.IsIrregexpFunction()); // Not yet implemented.
Compiler::ComputeLocalVarDescriptors(*this);
}
@@ -17129,6 +17187,7 @@
const Class& owner = Class::Handle(zone, fun.Owner());
Function& fun_clone = Function::Handle(
zone, Function::NewSignatureFunction(owner, TokenPosition::kNoSource));
+ // TODO(regis): Handle cloning of a generic function type.
AbstractType& type = AbstractType::Handle(zone, fun.result_type());
type = type.CloneUnfinalized();
fun_clone.set_result_type(type);
@@ -17145,6 +17204,7 @@
}
fun_clone.set_parameter_names(Array::Handle(zone, fun.parameter_names()));
clone.set_signature(fun_clone);
+ fun_clone.SetSignatureType(clone);
}
clone.SetIsResolved();
return clone.raw();
@@ -17341,6 +17401,10 @@
}
sig_fun.set_parameter_names(Array::Handle(zone, fun.parameter_names()));
set_signature(sig_fun);
+ // Note that the signature type of the signature function may be
+ // different than the type being canonicalized.
+ // Consider F<int> being canonicalized, with F being a typedef and F<T>
+ // being its signature type.
}
}
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 2c62d62..2726cf5 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -2993,6 +2993,7 @@
// RawFunction::VisitFunctionPointers accesses the private constructor of
// Function.
friend class RawFunction;
+ friend class ClassFinalizer; // To reset parent_function.
};
@@ -3164,7 +3165,7 @@
bool is_final,
bool is_const,
bool is_reflectable,
- const Class& owner,
+ const Object& owner,
const AbstractType& type,
TokenPosition token_pos);
@@ -3549,8 +3550,6 @@
RawTokenStream* tokens() const { return raw_ptr()->tokens_; }
- RawArray* line_starts() const { return raw_ptr()->line_starts_; }
-
void set_line_starts(const Array& value) const;
void Tokenize(const String& private_key, bool use_shared_tokens = true) const;
@@ -3602,6 +3601,7 @@
void set_kind(RawScript::Kind value) const;
void set_load_timestamp(int64_t value) const;
void set_tokens(const TokenStream& value) const;
+ RawArray* line_starts() const { return raw_ptr()->line_starts_; }
static RawScript* New();
diff --git a/runtime/vm/object_service.cc b/runtime/vm/object_service.cc
index 99e1157..d4fc827 100644
--- a/runtime/vm/object_service.cc
+++ b/runtime/vm/object_service.cc
@@ -243,6 +243,11 @@
static void AddFunctionServiceId(const JSONObject& jsobj,
const Function& f,
const Class& cls) {
+ if (cls.IsNull()) {
+ ASSERT(f.IsSignatureFunction());
+ jsobj.AddServiceId(f);
+ return;
+ }
// Special kinds of functions use indices in their respective lists.
intptr_t id = -1;
const char* selector = NULL;
@@ -279,10 +284,13 @@
void Function::PrintJSONImpl(JSONStream* stream, bool ref) const {
Class& cls = Class::Handle(Owner());
- ASSERT(!cls.IsNull());
- Error& err = Error::Handle();
- err ^= cls.EnsureIsFinalized(Thread::Current());
- ASSERT(err.IsNull());
+ if (!cls.IsNull()) {
+ Error& err = Error::Handle();
+ err ^= cls.EnsureIsFinalized(Thread::Current());
+ ASSERT(err.IsNull());
+ } else {
+ ASSERT(IsSignatureFunction());
+ }
JSONObject jsobj(stream);
AddCommonObjectProperties(&jsobj, "Function", ref);
AddFunctionServiceId(jsobj, *this, cls);
@@ -292,11 +300,13 @@
const Function& parent = Function::Handle(parent_function());
if (!parent.IsNull()) {
jsobj.AddProperty("owner", parent);
- } else if (cls.IsTopLevel()) {
- const Library& library = Library::Handle(cls.library());
- jsobj.AddProperty("owner", library);
- } else {
- jsobj.AddProperty("owner", cls);
+ } else if (!cls.IsNull()) {
+ if (cls.IsTopLevel()) {
+ const Library& library = Library::Handle(cls.library());
+ jsobj.AddProperty("owner", library);
+ } else {
+ jsobj.AddProperty("owner", cls);
+ }
}
const char* kind_string = Function::KindToCString(kind());
@@ -1099,6 +1109,7 @@
void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
+ // TODO(regis): Function types are not handled properly.
JSONObject jsobj(stream);
PrintSharedInstanceJSON(&jsobj, ref);
jsobj.AddProperty("kind", "Type");
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 802c472..c8d2aa1 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -44,7 +44,10 @@
DEFINE_FLAG(bool, enable_debug_break, false, "Allow use of break \"message\".");
DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations.");
-DEFINE_FLAG(bool, warn_new_tearoff_syntax, true, "Warning on new tear off.");
+DEFINE_FLAG(bool,
+ support_deprecated_tearoff_syntax,
+ false,
+ "Support new tear-off syntax.");
// TODO(floitsch): remove the conditional-directive flag, once we publicly
// committed to the current version.
DEFINE_FLAG(bool,
@@ -2055,7 +2058,7 @@
// signature functions (except typedef signature functions), therefore
// we do not need to keep the correct script via a patch class. Use the
// actual current class as owner of the signature function.
- const Function& signature_function =
+ Function& signature_function =
Function::Handle(Z, Function::NewSignatureFunction(
current_class(), TokenPosition::kNoSource));
signature_function.set_parent_function(innermost_function());
@@ -2095,7 +2098,9 @@
if (!is_top_level_) {
signature_type ^= ClassFinalizer::FinalizeType(
current_class(), signature_type, ClassFinalizer::kCanonicalize);
- signature_function.SetSignatureType(signature_type);
+ // Do not refer to signature_function anymore, since it may have been
+ // replaced during canonicalization.
+ signature_function = Function::null();
}
ASSERT(is_top_level_ || signature_type.IsFinalized());
// A signature type itself cannot be malformed or malbounded, only its
@@ -11702,10 +11707,9 @@
// Closurization e#m of getter, setter, method or operator.
AstNode* Parser::ParseClosurization(AstNode* primary) {
- if (FLAG_warn_new_tearoff_syntax) {
- ReportWarning(
- "Tear-offs using the x#id syntax is a deprecated feature,"
- "it will not be supported in the next release");
+ if (!FLAG_support_deprecated_tearoff_syntax) {
+ ReportError("tear-off using the x#id syntax is a deprecated feature");
+ return NULL;
}
ExpectToken(Token::kHASH);
TokenPosition property_pos = TokenPos();
@@ -11747,7 +11751,7 @@
// a prefix, the name mangling does not help in hiding the private
// name, so we explicitly prevent lookup of private names here.
if (is_setter_name) {
- String& setter_name =
+ const String& setter_name =
String::Handle(Z, Field::SetterName(extractor_name));
obj = prefix.LookupObject(setter_name);
}
@@ -11770,11 +11774,13 @@
} else if (obj.IsField()) {
const Field& field = Field::Cast(obj);
if (is_setter_name && !field.is_final()) {
- Instance& setter_closure = Instance::ZoneHandle(field.SetterClosure());
+ const Instance& setter_closure =
+ Instance::ZoneHandle(field.SetterClosure());
return new (Z) LiteralNode(property_pos, setter_closure);
}
if (!is_setter_name) {
- Instance& getter_closure = Instance::ZoneHandle(field.GetterClosure());
+ const Instance& getter_closure =
+ Instance::ZoneHandle(field.GetterClosure());
return new (Z) LiteralNode(property_pos, getter_closure);
}
}
@@ -11893,6 +11899,8 @@
// Not all involved type classes may get resolved yet, but at least type
// parameters will get resolved, thereby relieving the class
// finalizer from resolving type parameters out of context.
+// TODO(regis): Refactor this code which is partially duplicated in the class
+// finalizer, paying attention to type parameter resolution and mixin library.
void Parser::ResolveType(ClassFinalizer::FinalizationKind finalization,
AbstractType* type) {
ASSERT(finalization >= ClassFinalizer::kResolveTypeParameters);
@@ -11970,6 +11978,12 @@
if (!resolved_type_class.IsNull()) {
// Replace unresolved class with resolved type class.
parameterized_type.set_type_class(resolved_type_class);
+ // Promote type to a function type in case its type class is a typedef.
+ if (resolved_type_class.IsTypedefClass()) {
+ ASSERT(!parameterized_type.IsFunctionType());
+ parameterized_type.set_signature(
+ Function::Handle(Z, resolved_type_class.signature_function()));
+ }
} else if (finalization >= ClassFinalizer::kCanonicalize) {
ClassFinalizer::FinalizeMalformedType(
Error::Handle(Z), // No previous error.
@@ -11978,6 +11992,9 @@
return;
}
}
+ if (finalization > ClassFinalizer::kResolveTypeParameters) {
+ type->SetIsResolved();
+ }
// Resolve type arguments, if any.
if (type->arguments() != TypeArguments::null()) {
const TypeArguments& arguments =
@@ -11990,6 +12007,45 @@
arguments.SetTypeAt(i, type_argument);
}
}
+ if (type->IsFunctionType()) {
+ const Function& signature =
+ Function::Handle(Z, Type::Cast(*type).signature());
+ Type& signature_type = Type::Handle(Z, signature.SignatureType());
+ if (signature_type.raw() != type->raw()) {
+ ResolveType(finalization, &signature_type);
+ } else {
+ AbstractType& type = AbstractType::Handle(signature.result_type());
+ ResolveType(finalization, &type);
+ signature.set_result_type(type);
+ const intptr_t num_parameters = signature.NumParameters();
+ for (intptr_t i = 0; i < num_parameters; i++) {
+ type = signature.ParameterTypeAt(i);
+ ResolveType(finalization, &type);
+ signature.SetParameterTypeAt(i, type);
+ }
+ if (signature.IsSignatureFunction()) {
+ // Drop fields that are not necessary anymore after resolution.
+ // The parent function, owner, and token position of a shared
+ // canonical function type are meaningless, since the canonical
+ // representent is picked arbitrarily.
+ signature.set_parent_function(Function::Handle(Z));
+ // TODO(regis): As long as we support metadata in typedef signatures,
+ // we cannot reset these fields used to reparse a typedef.
+ // Note that the scope class of a typedef function type is always
+ // preserved as the typedef class (not reset to _Closure class), thereby
+ // preventing sharing of canonical function types between typedefs.
+ // Not being shared, these fields are therefore always meaningful for
+ // typedefs.
+ if (type.HasResolvedTypeClass()) {
+ const Class& scope_class = Class::Handle(Z, type.type_class());
+ if (!scope_class.IsTypedefClass()) {
+ signature.set_owner(Object::Handle(Z));
+ signature.set_token_pos(TokenPosition::kNoSource);
+ }
+ }
+ }
+ }
+ }
}
@@ -13296,10 +13352,9 @@
// type that is loaded.
ASSERT(prefix.IsNull() || prefix.is_loaded());
ASSERT(!type.IsMalformed() && !type.IsTypeParameter());
- if (FLAG_warn_new_tearoff_syntax) {
- ReportWarning(
- "Tear-offs using the x#id syntax is a deprecated feature,"
- "it will not be supported in the next release");
+ if (!FLAG_support_deprecated_tearoff_syntax) {
+ ReportError("tear-off using the x#id syntax is a deprecated feature");
+ return;
}
ExpectToken(Token::kHASH);
String* named_constructor = NULL;
@@ -13396,14 +13451,12 @@
String* named_constructor = NULL;
const bool is_tearoff_expression = (CurrentToken() == Token::kHASH);
if (is_tearoff_expression) {
+ if (!FLAG_support_deprecated_tearoff_syntax) {
+ ReportError("tear-off using the x#id syntax is a deprecated feature");
+ }
if (is_const) {
ReportError("tear-off closure not allowed with const allocation");
}
- if (FLAG_warn_new_tearoff_syntax) {
- ReportWarning(
- "Tear-offs using the x#id syntax is a deprecated feature,"
- "and will not be supported in the next release");
- }
ConsumeToken();
if (IsIdentifier()) {
named_constructor = ExpectIdentifier("name of constructor expected");
@@ -13841,10 +13894,8 @@
const LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z, ParsePrefix());
if (!prefix.IsNull()) {
if (CurrentToken() == Token::kHASH) {
- if (FLAG_warn_new_tearoff_syntax) {
- ReportWarning(
- "Tear-offs using the x#id syntax is a deprecated feature,"
- "it will not be supported in the next release");
+ if (!FLAG_support_deprecated_tearoff_syntax) {
+ ReportError("tear-off using the x#id syntax is a deprecated feature");
}
// Closurization of top-level entity in prefix scope.
return new (Z) LiteralNode(qual_ident_pos, prefix);
diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc
index d190d5a..ff691d1 100644
--- a/runtime/vm/precompiler.cc
+++ b/runtime/vm/precompiler.cc
@@ -1002,6 +1002,8 @@
void Precompiler::AddTypesOf(const Function& function) {
if (function.IsNull()) return;
+ // We don't expect to see a reference to a redicting factory.
+ ASSERT(!function.IsRedirectingFactory());
if (functions_to_retain_.Lookup(&function) != NULL) return;
functions_to_retain_.Insert(&Function::ZoneHandle(Z, function.raw()));
@@ -3497,8 +3499,6 @@
ASSERT(thread()->IsMutatorThread());
FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
}
- // Mark that this isolate now has compiled code.
- isolate()->set_has_compiled_code(true);
// Exit the loop and the function with the correct result value.
is_compiled = true;
done = true;
diff --git a/runtime/vm/profiler_test.cc b/runtime/vm/profiler_test.cc
index dce810e..8e3af78 100644
--- a/runtime/vm/profiler_test.cc
+++ b/runtime/vm/profiler_test.cc
@@ -775,7 +775,7 @@
EXPECT(walker.Down());
EXPECT_STREQ("_List._List", walker.CurrentName());
EXPECT(walker.Down());
- EXPECT_STREQ("List.List", walker.CurrentName());
+ EXPECT_STREQ("List.List._internal", walker.CurrentName());
EXPECT(walker.Down());
EXPECT_STREQ("foo", walker.CurrentName());
EXPECT(!walker.Down());
@@ -829,7 +829,7 @@
EXPECT(walker.Down());
EXPECT_STREQ("_GrowableList._GrowableList", walker.CurrentName());
EXPECT(walker.Down());
- EXPECT_STREQ("List.List", walker.CurrentName());
+ EXPECT_STREQ("List.List._internal", walker.CurrentName());
EXPECT(walker.Down());
EXPECT_STREQ("bar", walker.CurrentName());
EXPECT(!walker.Down());
diff --git a/runtime/vm/service/service.md b/runtime/vm/service/service.md
index 7975456..d372c79 100644
--- a/runtime/vm/service/service.md
+++ b/runtime/vm/service/service.md
@@ -37,6 +37,7 @@
- [getVersion](#getversion)
- [getVM](#getvm)
- [pause](#pause)
+ - [reloadSources](#reloadSources)
- [removeBreakpoint](#removebreakpoint)
- [resume](#resume)
- [setExceptionPauseMode](#setexceptionpausemode)
@@ -73,6 +74,7 @@
- [Message](#message)
- [Null](#null)
- [Object](#object)
+ - [ReloadReport](#reloadreport)
- [Response](#response)
- [Sentinel](#sentinel)
- [SentinelKind](#sentinelkind)
@@ -183,7 +185,9 @@
104 | Stream not subscribed | The client is not subscribed to the specified _streamId_
105 | Isolate must be runnable | This operation cannot happen until the isolate is runnable
106 | Isolate must be paused | This operation is only valid when the isolate is paused
-
+107 | Cannot resume execution | The isolate could not be resumed
+108 | Isolate is reloading | The isolate is currently processing another reload request
+109 | Isolate cannot be reloaded | The isolate has an unhandled exception and can no longer be reloaded
@@ -651,6 +655,31 @@
See [Success](#success).
+### reloadSources
+
+
+```
+ReloadReport reloadSources(string isolateId,
+ bool force [optional],
+ bool pause [optional],
+ string rootLibUri [optional],
+ string packagesUri [optional])
+```
+
+The _reloadSources_ RPC is used to perform a hot reload of an Isolate's sources.
+
+if the _force_ parameter is provided, it indicates that all of the Isolate's
+sources should be reloaded regardless of modification time.
+
+if the _pause_ parameter is provided, the isolate will pause immediately
+after the reload.
+
+if the _rootLibUri_ parameter is provided, it indicates the new uri to the
+Isolate's root library.
+
+if the _packagesUri_ parameter is provided, it indicates the new uri to the
+Isolate's package map (.packages) file.
+
### removeBreakpoint
```
@@ -684,6 +713,7 @@
Into | Single step, entering function calls
Over | Single step, skipping over function calls
Out | Single step until the current function exits
+Rewind | Immediately exit the top frame(s) without executing any code. Isolate will be paused at the call of the last exited function.
See [Success](#success), [StepOption](#StepOption).
@@ -768,8 +798,8 @@
streamId | event types provided
-------- | -----------
VM | VMUpdate
-Isolate | IsolateStart, IsolateRunnable, IsolateExit, IsolateUpdate, ServiceExtensionAdded
-Debug | PauseStart, PauseExit, PauseBreakpoint, PauseInterrupted, PauseException, Resume, BreakpointAdded, BreakpointResolved, BreakpointRemoved, Inspect, None
+Isolate | IsolateStart, IsolateRunnable, IsolateExit, IsolateUpdate, IsolateReload, ServiceExtensionAdded
+Debug | PauseStart, PauseExit, PauseBreakpoint, PauseInterrupted, PauseException, PausePostRequest, Resume, BreakpointAdded, BreakpointResolved, BreakpointRemoved, Inspect, None
GC | GC
Extension | Extension
Timeline | TimelineEvents
@@ -1244,6 +1274,12 @@
// PauseBreakpoint
// PauseInterrupted
bool atAsyncSuspension [optional];
+
+ // The status (success or failure) related to the event.
+ // This is provided for the event kinds:
+ // IsolateReloaded
+ // IsolateSpawn
+ string status [optional];
}
```
@@ -1275,6 +1311,9 @@
// via setName.
IsolateUpdate,
+ // Notification that an isolate has been reloaded.
+ IsolateReload,
+
// Notification that an extension RPC was registered on an isolate.
ServiceExtensionAdded,
@@ -1293,6 +1332,9 @@
// An isolate has paused due to an exception.
PauseException,
+ // An isolate has paused after a service request.
+ PausePostRequest,
+
// An isolate has started or resumed execution.
Resume,
@@ -2129,6 +2171,15 @@
An _Object_ is a persistent object that is owned by some isolate.
+### ReloadReport
+
+```
+class ReloadReport extends Response {
+ // Did the reload succeed or fail?
+ bool status;
+}
+```
+
### Response
```
@@ -2383,7 +2434,8 @@
Into,
Over,
OverAsyncSuspension,
- Out
+ Out,
+ Rewind
}
```
@@ -2537,6 +2589,6 @@
3.3 | Pause event now indicates if the isolate is paused at an await, yield, or yield* suspension point via the 'atAsyncSuspension' field. Resume command now supports the step parameter 'OverAsyncSuspension'. A Breakpoint added synthetically by an 'OverAsyncSuspension' resume command identifies itself as such via the 'isSyntheticAsyncContinuation' field.
3.4 | Add the superType and mixin fields to Class. Added new pause event 'None'.
3.5 | Add the error field to SourceReportRange. Clarify definition of token position. Add "Isolate must be paused" error code.
-3.6 (unreleased) | Add 'scopeStartTokenPos', 'scopeEndTokenPos', and 'declarationTokenPos' to BoundVariable.
+3.6 (unreleased) | Add 'scopeStartTokenPos', 'scopeEndTokenPos', and 'declarationTokenPos' to BoundVariable. Add 'PausePostRequest' event kind. Add 'Rewind' StepOption. Add error code 107 (isolate cannot resume). Add 'reloadSources' RPC and related error codes.
[discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss
diff --git a/runtime/vm/stub_code_x64.cc b/runtime/vm/stub_code_x64.cc
index 0341f26..b3b18da 100644
--- a/runtime/vm/stub_code_x64.cc
+++ b/runtime/vm/stub_code_x64.cc
@@ -1006,8 +1006,8 @@
// RDX: Address being stored
Label reload;
__ Bind(&reload);
- __ movq(RCX, FieldAddress(RDX, Object::tags_offset()));
- __ testq(RCX, Immediate(1 << RawObject::kRememberedBit));
+ __ movq(RAX, FieldAddress(RDX, Object::tags_offset()));
+ __ testq(RAX, Immediate(1 << RawObject::kRememberedBit));
__ j(EQUAL, &add_to_buffer, Assembler::kNearJump);
__ popq(RCX);
__ popq(RAX);
diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h
index 30f7f90..c7f3a0c 100644
--- a/runtime/vm/symbols.h
+++ b/runtime/vm/symbols.h
@@ -221,20 +221,34 @@
V(_Float32x4, "_Float32x4") \
V(_Float64x2, "_Float64x2") \
V(_Int32x4, "_Int32x4") \
- V(Int8List, "_Int8List") \
- V(Uint8List, "_Uint8List") \
- V(Uint8ClampedList, "_Uint8ClampedList") \
- V(Int16List, "_Int16List") \
- V(Uint16List, "_Uint16List") \
- V(Int32List, "_Int32List") \
- V(Uint32List, "_Uint32List") \
- V(Int64List, "_Int64List") \
- V(Uint64List, "_Uint64List") \
- V(Float32x4List, "_Float32x4List") \
- V(Int32x4List, "_Int32x4List") \
- V(Float64x2List, "_Float64x2List") \
- V(Float32List, "_Float32List") \
- V(Float64List, "_Float64List") \
+ V(Int8List, "Int8List") \
+ V(Uint8List, "Uint8List") \
+ V(Uint8ClampedList, "Uint8ClampedList") \
+ V(Int16List, "Int16List") \
+ V(Uint16List, "Uint16List") \
+ V(Int32List, "Int32List") \
+ V(Uint32List, "Uint32List") \
+ V(Int64List, "Int64List") \
+ V(Uint64List, "Uint64List") \
+ V(Float32x4List, "Float32x4List") \
+ V(Int32x4List, "Int32x4List") \
+ V(Float64x2List, "Float64x2List") \
+ V(Float32List, "Float32List") \
+ V(Float64List, "Float64List") \
+ V(_Int8List, "_Int8List") \
+ V(_Uint8List, "_Uint8List") \
+ V(_Uint8ClampedList, "_Uint8ClampedList") \
+ V(_Int16List, "_Int16List") \
+ V(_Uint16List, "_Uint16List") \
+ V(_Int32List, "_Int32List") \
+ V(_Uint32List, "_Uint32List") \
+ V(_Int64List, "_Int64List") \
+ V(_Uint64List, "_Uint64List") \
+ V(_Float32x4List, "_Float32x4List") \
+ V(_Int32x4List, "_Int32x4List") \
+ V(_Float64x2List, "_Float64x2List") \
+ V(_Float32List, "_Float32List") \
+ V(_Float64List, "_Float64List") \
V(_Int8ArrayFactory, "Int8List.") \
V(_Uint8ArrayFactory, "Uint8List.") \
V(_Uint8ClampedArrayFactory, "Uint8ClampedList.") \
diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc
index 1b3428e..e938101 100644
--- a/runtime/vm/thread.cc
+++ b/runtime/vm/thread.cc
@@ -753,8 +753,8 @@
}
-int Thread::CountLocalHandles() const {
- int total = 0;
+intptr_t Thread::CountLocalHandles() const {
+ intptr_t total = 0;
ApiLocalScope* scope = api_top_scope_;
while (scope != NULL) {
total += scope->local_handles()->CountHandles();
@@ -764,6 +764,30 @@
}
+intptr_t Thread::CountZoneHandles() const {
+ intptr_t count = 0;
+ Zone* zone = zone_;
+ while (zone != NULL) {
+ count += zone->handles()->CountZoneHandles();
+ zone = zone->previous();
+ }
+ ASSERT(count >= 0);
+ return count;
+}
+
+
+intptr_t Thread::CountScopedHandles() const {
+ intptr_t count = 0;
+ Zone* zone = zone_;
+ while (zone != NULL) {
+ count += zone->handles()->CountScopedHandles();
+ zone = zone->previous();
+ }
+ ASSERT(count >= 0);
+ return count;
+}
+
+
int Thread::ZoneSizeInBytes() const {
int total = 0;
ApiLocalScope* scope = api_top_scope_;
diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h
index 576d57c..e73c44b 100644
--- a/runtime/vm/thread.h
+++ b/runtime/vm/thread.h
@@ -638,7 +638,9 @@
void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames);
bool IsValidLocalHandle(Dart_Handle object) const;
- int CountLocalHandles() const;
+ intptr_t CountLocalHandles() const;
+ intptr_t CountZoneHandles() const;
+ intptr_t CountScopedHandles() const;
int ZoneSizeInBytes() const;
void UnwindScopes(uword stack_marker);
diff --git a/runtime/vm/thread_registry.cc b/runtime/vm/thread_registry.cc
index eb39501..4694cc0 100644
--- a/runtime/vm/thread_registry.cc
+++ b/runtime/vm/thread_registry.cc
@@ -105,6 +105,30 @@
#endif
+intptr_t ThreadRegistry::CountZoneHandles() const {
+ MonitorLocker ml(threads_lock());
+ intptr_t count = 0;
+ Thread* current = active_list_;
+ while (current != NULL) {
+ count += current->CountZoneHandles();
+ current = current->next_;
+ }
+ return count;
+}
+
+
+intptr_t ThreadRegistry::CountScopedHandles() const {
+ MonitorLocker ml(threads_lock());
+ intptr_t count = 0;
+ Thread* current = active_list_;
+ while (current != NULL) {
+ count += current->CountScopedHandles();
+ current = current->next_;
+ }
+ return count;
+}
+
+
void ThreadRegistry::AddToActiveListLocked(Thread* thread) {
ASSERT(thread != NULL);
ASSERT(threads_lock()->IsOwnedByCurrentThread());
diff --git a/runtime/vm/thread_registry.h b/runtime/vm/thread_registry.h
index 881a4d0..0742d22 100644
--- a/runtime/vm/thread_registry.h
+++ b/runtime/vm/thread_registry.h
@@ -37,6 +37,9 @@
void PrintJSON(JSONStream* stream) const;
#endif
+ intptr_t CountZoneHandles() const;
+ intptr_t CountScopedHandles() const;
+
private:
Thread* active_list() const { return active_list_; }
Monitor* threads_lock() const { return threads_lock_; }
diff --git a/sdk/lib/_internal/js_runtime/lib/convert_patch.dart b/sdk/lib/_internal/js_runtime/lib/convert_patch.dart
index 9cac10e..65395a8 100644
--- a/sdk/lib/_internal/js_runtime/lib/convert_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/convert_patch.dart
@@ -397,7 +397,7 @@
@patch class Utf8Decoder {
@patch
- Converter<List<int>,dynamic> fuse(Converter<String, dynamic> next) {
+ Converter<List<int>, T> fuse<T>(Converter<String, T> next) {
return super.fuse(next);
}
diff --git a/sdk/lib/_internal/js_runtime/lib/developer_patch.dart b/sdk/lib/_internal/js_runtime/lib/developer_patch.dart
index 541658b..4cefe98 100644
--- a/sdk/lib/_internal/js_runtime/lib/developer_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/developer_patch.dart
@@ -46,7 +46,7 @@
}
@patch
-_postEvent(String eventKind, String eventData) {
+void _postEvent(String eventKind, String eventData) {
// TODO.
}
@@ -129,4 +129,51 @@
@patch
String _getIsolateIDFromSendPort(SendPort sendPort) {
return null;
-}
\ No newline at end of file
+}
+
+@patch
+class UserTag {
+ @patch
+ factory UserTag(String label) = _FakeUserTag;
+
+ @patch
+ static UserTag get defaultTag => _FakeUserTag._defaultTag;
+}
+
+class _FakeUserTag implements UserTag {
+ static Map _instances = {};
+
+ _FakeUserTag.real(this.label);
+
+ factory _FakeUserTag(String label) {
+ // Canonicalize by name.
+ var existingTag = _instances[label];
+ if (existingTag != null) {
+ return existingTag;
+ }
+ // Throw an exception if we've reached the maximum number of user tags.
+ if (_instances.length == UserTag.MAX_USER_TAGS) {
+ throw new UnsupportedError(
+ 'UserTag instance limit (${UserTag.MAX_USER_TAGS}) reached.');
+ }
+ // Create a new instance and add it to the instance map.
+ var instance = new _FakeUserTag.real(label);
+ _instances[label] = instance;
+ return instance;
+ }
+
+ final String label;
+
+ UserTag makeCurrent() {
+ var old = _currentTag;
+ _currentTag = this;
+ return old;
+ }
+
+ static final UserTag _defaultTag = new _FakeUserTag('Default');
+}
+
+var _currentTag = _FakeUserTag._defaultTag;
+
+@patch
+UserTag getCurrentTag() => _currentTag;
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index 07d1cbb..3be1e9d 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -679,11 +679,14 @@
if (JS('bool', 'typeof # == "number"', functionType)) {
return getType(functionType);
} else if (JS('bool', 'typeof # == "function"', functionType)) {
- var fakeInstance = JS('', 'new #()', jsConstructor);
- setRuntimeTypeInfo(
- fakeInstance, JS('JSExtendableArray', '#["<>"]', fakeInstance));
- return JS('=Object|Null', r'#.apply({$receiver:#})',
- functionType, fakeInstance);
+ if (jsConstructor != null) {
+ var fakeInstance = JS('', 'new #()', jsConstructor);
+ setRuntimeTypeInfo(
+ fakeInstance, JS('JSExtendableArray', '#["<>"]', fakeInstance));
+ return JS('=Object|Null', r'#.apply({$receiver:#})',
+ functionType, fakeInstance);
+ }
+ return functionType;
} else {
throw new RuntimeError('Unexpected function type');
}
diff --git a/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart b/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart
index b439338..0f59489 100644
--- a/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart
+++ b/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart
@@ -36,7 +36,6 @@
/// Mapping of "dart:" library name (e.g. "core") to information about that
/// library.
const Map<String, LibraryInfo> libraries = const {
-
"async": const LibraryInfo(
"async/async.dart",
categories: "Client,Server",
@@ -182,8 +181,7 @@
"internal/internal.dart",
categories: "",
documented: false,
- dart2jsPatchPath:
- "_internal/js_runtime/lib/internal_patch.dart"),
+ dart2jsPatchPath: "_internal/js_runtime/lib/internal_patch.dart"),
"_js_helper": const LibraryInfo(
"_internal/js_runtime/lib/js_helper.dart",
@@ -250,7 +248,6 @@
* Information about a "dart:" library.
*/
class LibraryInfo {
-
/**
* Path to the library's *.dart file relative to this file.
*/
@@ -336,8 +333,6 @@
}
}
-
-
/**
* Abstraction to capture the maturity of a library.
*/
@@ -351,28 +346,28 @@
String toString() => "$name: $level\n$description\n";
static const Maturity DEPRECATED = const Maturity(0, "Deprecated",
- "This library will be remove before next major release.");
+ "This library will be remove before next major release.");
static const Maturity EXPERIMENTAL = const Maturity(1, "Experimental",
- "This library is experimental and will likely change or be removed\n"
- "in future versions.");
+ "This library is experimental and will likely change or be removed\n"
+ "in future versions.");
static const Maturity UNSTABLE = const Maturity(2, "Unstable",
- "This library is in still changing and have not yet endured\n"
- "sufficient real-world testing.\n"
- "Backwards-compatibility is NOT guaranteed.");
+ "This library is in still changing and have not yet endured\n"
+ "sufficient real-world testing.\n"
+ "Backwards-compatibility is NOT guaranteed.");
static const Maturity WEB_STABLE = const Maturity(3, "Web Stable",
- "This library is tracking the DOM evolution as defined by WC3.\n"
- "Backwards-compatibility is NOT guaranteed.");
+ "This library is tracking the DOM evolution as defined by WC3.\n"
+ "Backwards-compatibility is NOT guaranteed.");
static const Maturity STABLE = const Maturity(4, "Stable",
- "The library is stable. API backwards-compatibility is guaranteed.\n"
- "However implementation details might change.");
+ "The library is stable. API backwards-compatibility is guaranteed.\n"
+ "However implementation details might change.");
static const Maturity LOCKED = const Maturity(5, "Locked",
- "This library will not change except when serious bugs are encountered.");
+ "This library will not change except when serious bugs are encountered.");
static const Maturity UNSPECIFIED = const Maturity(-1, "Unspecified",
- "The maturity for this library has not been specified.");
+ "The maturity for this library has not been specified.");
}
diff --git a/sdk/lib/async/async_error.dart b/sdk/lib/async/async_error.dart
index 2f3419e..62996c3 100644
--- a/sdk/lib/async/async_error.dart
+++ b/sdk/lib/async/async_error.dart
@@ -14,12 +14,12 @@
}
}
-Function _registerErrorHandler/*<R>*/(Function errorHandler, Zone zone) {
+Function _registerErrorHandler<R>(Function errorHandler, Zone zone) {
if (errorHandler is ZoneBinaryCallback) {
- return zone.registerBinaryCallback/*<R, dynamic, StackTrace>*/(
+ return zone.registerBinaryCallback<R, dynamic, StackTrace>(
errorHandler as dynamic/*=ZoneBinaryCallback<R, dynamic, StackTrace>*/);
} else {
- return zone.registerUnaryCallback/*<R, dynamic>*/(
+ return zone.registerUnaryCallback<R, dynamic>(
errorHandler as dynamic/*=ZoneUnaryCallback<R, dynamic>*/);
}
}
diff --git a/sdk/lib/async/broadcast_stream_controller.dart b/sdk/lib/async/broadcast_stream_controller.dart
index c34ec9f..22ed3e9 100644
--- a/sdk/lib/async/broadcast_stream_controller.dart
+++ b/sdk/lib/async/broadcast_stream_controller.dart
@@ -540,5 +540,5 @@
}
Future cancel() { return new _Future.immediate(null); }
bool get isPaused => _pauseCount > 0;
- Future/*<E>*/ asFuture/*<E>*/([Object/*=E*/ value]) => new _Future/*<E>*/();
+ Future<E> asFuture<E>([E value]) => new _Future<E>();
}
diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart
index 9d28ee6..674fffd 100644
--- a/sdk/lib/async/future.dart
+++ b/sdk/lib/async/future.dart
@@ -294,11 +294,11 @@
* The call to `cleanUp` should not throw. If it does, the error will be an
* uncaught asynchronous error.
*/
- static Future<List/*<T>*/> wait/*<T>*/(Iterable<Future/*<T>*/> futures,
+ static Future<List<T>> wait<T>(Iterable<Future<T>> futures,
{bool eagerError: false,
- void cleanUp(/*=T*/ successValue)}) {
- final _Future<List/*<T>*/> result = new _Future<List/*<T>*/>();
- List/*<T>*/ values; // Collects the values. Set to null on error.
+ void cleanUp(T successValue)}) {
+ final _Future<List<T>> result = new _Future<List<T>>();
+ List<T> values; // Collects the values. Set to null on error.
int remaining = 0; // How many futures are we waiting for.
var error; // The first error from a future.
StackTrace stackTrace; // The stackTrace that came with the error.
@@ -332,7 +332,7 @@
// position in the list of values.
for (Future future in futures) {
int pos = remaining;
- future.then((Object/*=T*/ value) {
+ future.then((T value) {
remaining--;
if (values != null) {
values[pos] = value;
@@ -357,7 +357,7 @@
if (remaining == 0) {
return new Future.value(const []);
}
- values = new List/*<T>*/(remaining);
+ values = new List<T>(remaining);
} catch (e, st) {
// The error must have been thrown while iterating over the futures
// list, or while installing a callback handler on the future.
@@ -390,9 +390,9 @@
* If [futures] is empty, or if none of its futures complete,
* the returned future never completes.
*/
- static Future/*<T>*/ any/*<T>*/(Iterable<Future/*<T>*/> futures) {
- var completer = new Completer/*<T>*/.sync();
- var onValue = (/*=T*/ value) {
+ static Future<T> any<T>(Iterable<Future<T>> futures) {
+ var completer = new Completer<T>.sync();
+ var onValue = (T value) {
if (!completer.isCompleted) completer.complete(value);
};
var onError = (error, stack) {
@@ -497,7 +497,7 @@
* with a `test` parameter, instead of handling both value and error in a
* single [then] call.
*/
- Future/*<S>*/ then/*<S>*/(onValue(T value), { Function onError });
+ Future<S> then<S>(onValue(T value), { Function onError });
/**
* Handles errors emitted by this [Future].
@@ -560,7 +560,7 @@
// `isCheck` we should also expect functions that take a specific argument.
// Note: making `catchError` return a `Future<T>` in non-strong mode could be
// a breaking change.
- Future/*<T>*/ catchError(Function onError,
+ Future<T> catchError(Function onError,
{bool test(Object error)});
/**
diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart
index dd07720..6e0b55b 100644
--- a/sdk/lib/async/future_impl.dart
+++ b/sdk/lib/async/future_impl.dart
@@ -128,14 +128,14 @@
}
dynamic/*T|Future<T>*/ handleValue(S sourceResult) {
- return _zone.runUnary/*<dynamic/*T|Future<T>*/, S>*/(
+ return _zone.runUnary<dynamic/*T|Future<T>*/, S>(
_onValue, sourceResult);
}
bool matchesErrorTest(AsyncError asyncError) {
if (!hasErrorTest) return true;
_FutureErrorTest test = _errorTest;
- return _zone.runUnary/*<bool, dynamic>*/(_errorTest, asyncError.error);
+ return _zone.runUnary<bool, dynamic>(_errorTest, asyncError.error);
}
dynamic/*T|Future<T>*/ handleError(AsyncError asyncError) {
@@ -147,7 +147,7 @@
asyncError.error,
asyncError.stackTrace);
} else {
- return _zone.runUnary/*<dynamic/*T|Future<T>*/, dynamic>*/(
+ return _zone.runUnary<dynamic/*T|Future<T>*/, dynamic>(
errorCallback, asyncError.error);
}
}
@@ -230,33 +230,33 @@
_resultOrListeners = source;
}
- Future/*<E>*/ then/*<E>*/(
- /*=dynamic/*E|Future<E>*/*/ f(T value), { Function onError }) {
+ Future<E> then<E>(
+ dynamic/*E|Future<E>*/ f(T value), { Function onError }) {
Zone currentZone = Zone.current;
ZoneUnaryCallback registered;
if (!identical(currentZone, _ROOT_ZONE)) {
- f = currentZone.registerUnaryCallback/*<dynamic, T>*/(f);
+ f = currentZone.registerUnaryCallback<dynamic, T>(f);
if (onError != null) {
- onError = _registerErrorHandler/*<T>*/(onError, currentZone);
+ onError = _registerErrorHandler<T>(onError, currentZone);
}
}
- return _thenNoZoneRegistration/*<E>*/(f, onError);
+ return _thenNoZoneRegistration<E>(f, onError);
}
// This method is used by async/await.
- Future/*<E>*/ _thenNoZoneRegistration/*<E>*/(f(T value), Function onError) {
- _Future/*<E>*/ result = new _Future/*<E>*/();
- _addListener(new _FutureListener/*<T, E>*/.then(result, f, onError));
+ Future<E> _thenNoZoneRegistration<E>(f(T value), Function onError) {
+ _Future<E> result = new _Future<E>();
+ _addListener(new _FutureListener<T, E>.then(result, f, onError));
return result;
}
- Future/*<T>*/ catchError(Function onError, { bool test(error) }) {
- _Future/*<T>*/ result = new _Future/*<T>*/();
+ Future<T> catchError(Function onError, { bool test(error) }) {
+ _Future<T> result = new _Future<T>();
if (!identical(result._zone, _ROOT_ZONE)) {
- onError = _registerErrorHandler/*<T>*/(onError, result._zone);
+ onError = _registerErrorHandler<T>(onError, result._zone);
if (test != null) test = result._zone.registerUnaryCallback(test);
}
- _addListener(new _FutureListener/*<T, T>*/.catchError(
+ _addListener(new _FutureListener<T, T>.catchError(
result, onError, test));
return result;
}
@@ -264,9 +264,9 @@
Future<T> whenComplete(action()) {
_Future<T> result = new _Future<T>();
if (!identical(result._zone, _ROOT_ZONE)) {
- action = result._zone.registerCallback/*<dynamic>*/(action);
+ action = result._zone.registerCallback<dynamic>(action);
}
- _addListener(new _FutureListener/*<T, T>*/.whenComplete(result, action));
+ _addListener(new _FutureListener<T, T>.whenComplete(result, action));
return result;
}
diff --git a/sdk/lib/async/stream.dart b/sdk/lib/async/stream.dart
index f114f8d..3608135 100644
--- a/sdk/lib/async/stream.dart
+++ b/sdk/lib/async/stream.dart
@@ -384,8 +384,8 @@
* If a broadcast stream is listened to more than once, each subscription
* will individually call [convert] on each data event.
*/
- Stream/*<S>*/ map/*<S>*/(/*=S*/ convert(T event)) {
- return new _MapStream<T, dynamic/*=S*/>(this, convert);
+ Stream<S> map<S>(S convert(T event)) {
+ return new _MapStream<T, S>(this, convert);
}
/**
@@ -398,15 +398,15 @@
*
* The returned stream is a broadcast stream if this stream is.
*/
- Stream/*<E>*/ asyncMap/*<E>*/(convert(T event)) {
- StreamController/*<E>*/ controller;
- StreamSubscription/*<T>*/ subscription;
+ Stream<E> asyncMap<E>(convert(T event)) {
+ StreamController<E> controller;
+ StreamSubscription<T> subscription;
void onListen() {
final add = controller.add;
assert(controller is _StreamController ||
controller is _BroadcastStreamController);
- final _EventSink/*<E>*/ eventSink =
+ final _EventSink<E> eventSink =
controller as Object /*=_EventSink<E>*/;
final addError = eventSink._addError;
subscription = this.listen(
@@ -432,13 +432,13 @@
}
if (this.isBroadcast) {
- controller = new StreamController/*<E>*/.broadcast(
+ controller = new StreamController<E>.broadcast(
onListen: onListen,
onCancel: () { subscription.cancel(); },
sync: true
);
} else {
- controller = new StreamController/*<E>*/(
+ controller = new StreamController<E>(
onListen: onListen,
onPause: () { subscription.pause(); },
onResume: () { subscription.resume(); },
@@ -462,17 +462,17 @@
*
* The returned stream is a broadcast stream if this stream is.
*/
- Stream/*<E>*/ asyncExpand/*<E>*/(Stream/*<E>*/ convert(T event)) {
- StreamController/*<E>*/ controller;
+ Stream<E> asyncExpand<E>(Stream<E> convert(T event)) {
+ StreamController<E> controller;
StreamSubscription<T> subscription;
void onListen() {
assert(controller is _StreamController ||
controller is _BroadcastStreamController);
- final _EventSink/*<E>*/ eventSink =
+ final _EventSink<E> eventSink =
controller as Object /*=_EventSink<E>*/;
subscription = this.listen(
(T event) {
- Stream/*<E>*/ newStream;
+ Stream<E> newStream;
try {
newStream = convert(event);
} catch (e, s) {
@@ -490,13 +490,13 @@
);
}
if (this.isBroadcast) {
- controller = new StreamController/*<E>*/.broadcast(
+ controller = new StreamController<E>.broadcast(
onListen: onListen,
onCancel: () { subscription.cancel(); },
sync: true
);
} else {
- controller = new StreamController/*<E>*/(
+ controller = new StreamController<E>(
onListen: onListen,
onPause: () { subscription.pause(); },
onResume: () { subscription.resume(); },
@@ -551,8 +551,8 @@
* If a broadcast stream is listened to more than once, each subscription
* will individually call `convert` and expand the events.
*/
- Stream/*<S>*/ expand/*<S>*/(Iterable/*<S>*/ convert(T value)) {
- return new _ExpandStream<T, dynamic/*=S*/>(this, convert);
+ Stream<S> expand<S>(Iterable<S> convert(T value)) {
+ return new _ExpandStream<T, S>(this, convert);
}
/**
@@ -585,8 +585,8 @@
* The `streamTransformer` can decide whether it wants to return a
* broadcast stream or not.
*/
- Stream/*<S>*/ transform/*<S>*/(
- StreamTransformer<T, dynamic/*=S*/ > streamTransformer) {
+ Stream<S> transform<S>(
+ StreamTransformer<T, S > streamTransformer) {
return streamTransformer.bind(this);
}
@@ -627,17 +627,17 @@
}
/** Reduces a sequence of values by repeatedly applying [combine]. */
- Future/*<S>*/ fold/*<S>*/(var/*=S*/ initialValue,
- /*=S*/ combine(var/*=S*/ previous, T element)) {
+ Future<S> fold<S>(S initialValue,
+ S combine(S previous, T element)) {
- _Future/*<S>*/ result = new _Future/*<S>*/();
- var/*=S*/ value = initialValue;
+ _Future<S> result = new _Future<S>();
+ S value = initialValue;
StreamSubscription subscription;
subscription = this.listen(
(T element) {
_runUserCode(
() => combine(value, element),
- (/*=S*/ newValue) { value = newValue; },
+ (S newValue) { value = newValue; },
_cancelAndErrorClosure(subscription, result)
);
},
@@ -899,8 +899,8 @@
* In case of a `done` event the future completes with the given
* [futureValue].
*/
- Future/*<E>*/ drain/*<E>*/([/*=E*/ futureValue])
- => listen(null, cancelOnError: true).asFuture/*<E>*/(futureValue);
+ Future<E> drain<E>([E futureValue])
+ => listen(null, cancelOnError: true).asFuture<E>(futureValue);
/**
* Provides at most the first [count] data events of this stream.
@@ -1351,7 +1351,7 @@
// TODO(floitsch): the return type should be 'void', and the type
// should be inferred.
var registeredOnTimeout =
- zone.registerUnaryCallback/*<dynamic, EventSink<T>>*/(onTimeout);
+ zone.registerUnaryCallback<dynamic, EventSink<T>>(onTimeout);
_ControllerEventSinkWrapper wrapper =
new _ControllerEventSinkWrapper(null);
timeout = () {
@@ -1498,7 +1498,7 @@
* In case of a `done` event the future completes with the given
* [futureValue].
*/
- Future/*<E>*/ asFuture/*<E>*/([var/*=E*/ futureValue]);
+ Future<E> asFuture<E>([E futureValue]);
}
diff --git a/sdk/lib/async/stream_controller.dart b/sdk/lib/async/stream_controller.dart
index 87b64e8..d29fae3 100644
--- a/sdk/lib/async/stream_controller.dart
+++ b/sdk/lib/async/stream_controller.dart
@@ -780,7 +780,7 @@
abstract class _AsyncStreamControllerDispatch<T>
implements _StreamController<T> {
void _sendData(T data) {
- _subscription._addPending(new _DelayedData<dynamic /*=T*/>(data));
+ _subscription._addPending(new _DelayedData<T>(data));
}
void _sendError(Object error, StackTrace stackTrace) {
diff --git a/sdk/lib/async/stream_impl.dart b/sdk/lib/async/stream_impl.dart
index 7f89464..29cfbd1 100644
--- a/sdk/lib/async/stream_impl.dart
+++ b/sdk/lib/async/stream_impl.dart
@@ -139,14 +139,14 @@
if (handleData == null) handleData = _nullDataHandler;
// TODO(floitsch): the return type should be 'void', and the type
// should be inferred.
- _onData = _zone.registerUnaryCallback/*<dynamic, T>*/(handleData);
+ _onData = _zone.registerUnaryCallback<dynamic, T>(handleData);
}
void onError(Function handleError) {
if (handleError == null) handleError = _nullErrorHandler;
// We are not allowed to use 'void' as type argument for the generic type,
// so we use 'dynamic' instead.
- _onError = _registerErrorHandler/*<dynamic>*/(handleError, _zone);
+ _onError = _registerErrorHandler<dynamic>(handleError, _zone);
}
void onDone(void handleDone()) {
@@ -193,8 +193,8 @@
return _cancelFuture ?? Future._nullFuture;
}
- Future/*<E>*/ asFuture/*<E>*/([var/*=E*/ futureValue]) {
- _Future/*<E>*/ result = new _Future/*<E>*/();
+ Future<E> asFuture<E>([E futureValue]) {
+ _Future<E> result = new _Future<E>();
// Overwrite the onDone and onError handlers.
_onDone = () { result._complete(futureValue); };
@@ -257,7 +257,7 @@
if (_canFire) {
_sendData(data);
} else {
- _addPending(new _DelayedData<dynamic /*=T*/>(data));
+ _addPending(new _DelayedData<T>(data));
}
}
@@ -309,7 +309,7 @@
void _addPending(_DelayedEvent event) {
_StreamImplEvents<T> pending = _pending;
if (_pending == null) {
- pending = _pending = new _StreamImplEvents<dynamic /*=T*/>();
+ pending = _pending = new _StreamImplEvents<T>();
}
pending.add(event);
if (!_hasPending) {
@@ -349,7 +349,7 @@
as Object /*=ZoneBinaryCallback<dynamic, Object, StackTrace>*/;
_zone.runBinaryGuarded(errorCallback, error, stackTrace);
} else {
- _zone.runUnaryGuarded/*<dynamic, dynamic>*/(
+ _zone.runUnaryGuarded<dynamic, dynamic>(
_onError as Object /*=ZoneUnaryCallback<dynamic, dynamic>*/, error);
}
_state &= ~_STATE_IN_CALLBACK;
@@ -760,8 +760,8 @@
Future cancel() => Future._nullFuture;
- Future/*<E>*/ asFuture/*<E>*/([var/*=E*/ futureValue]) {
- _Future/*<E>*/ result = new _Future/*<E>*/();
+ Future<E> asFuture<E>([E futureValue]) {
+ _Future<E> result = new _Future<E>();
_onDone = () { result._completeWithValue(null); };
return result;
}
@@ -789,9 +789,9 @@
// TODO(floitsch): the return type should be void and should be
// inferred.
: _onListenHandler = Zone.current.registerUnaryCallback
- /*<dynamic, StreamSubscription<T>>*/(onListenHandler),
+ <dynamic, StreamSubscription<T>>(onListenHandler),
_onCancelHandler = Zone.current.registerUnaryCallback
- /*<dynamic, StreamSubscription<T>>*/(onCancelHandler),
+ <dynamic, StreamSubscription<T>>(onCancelHandler),
_zone = Zone.current {
_controller = new _AsBroadcastStreamController<T>(_onListen, _onCancel);
}
@@ -903,7 +903,7 @@
return _stream._isSubscriptionPaused;
}
- Future/*<E>*/ asFuture/*<E>*/([var/*=E*/ futureValue]) {
+ Future<E> asFuture<E>([E futureValue]) {
throw new UnsupportedError(
"Cannot change handlers of asBroadcastStream source subscription.");
}
diff --git a/sdk/lib/async/timer.dart b/sdk/lib/async/timer.dart
index 1bbb65b..72206ff 100644
--- a/sdk/lib/async/timer.dart
+++ b/sdk/lib/async/timer.dart
@@ -78,7 +78,7 @@
}
// TODO(floitsch): the return type should be 'void', and the type
// should be inferred.
- var boundCallback = Zone.current.bindUnaryCallback/*<dynamic, Timer>*/(
+ var boundCallback = Zone.current.bindUnaryCallback<dynamic, Timer>(
callback, runGuarded: true);
return Zone.current.createPeriodicTimer(duration, boundCallback);
}
diff --git a/sdk/lib/async/zone.dart b/sdk/lib/async/zone.dart
index ea3f47f..ead5b0b 100644
--- a/sdk/lib/async/zone.dart
+++ b/sdk/lib/async/zone.dart
@@ -216,17 +216,17 @@
* to skip zones that would just delegate to their parents.
*/
abstract class ZoneDelegate {
- /*=R*/ handleUncaughtError/*<R>*/(
+ R handleUncaughtError<R>(
Zone zone, error, StackTrace stackTrace);
- /*=R*/ run/*<R>*/(Zone zone, /*=R*/ f());
- /*=R*/ runUnary/*<R, T>*/(Zone zone, /*=R*/ f(/*=T*/ arg), /*=T*/ arg);
- /*=R*/ runBinary/*<R, T1, T2>*/(Zone zone,
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2), /*=T1*/ arg1, /*=T2*/ arg2);
- ZoneCallback/*<R>*/ registerCallback/*<R>*/(Zone zone, /*=R*/ f());
- ZoneUnaryCallback/*<R, T>*/ registerUnaryCallback/*<R, T>*/(
- Zone zone, /*=R*/ f(/*=T*/ arg));
- ZoneBinaryCallback/*<R, T1, T2>*/ registerBinaryCallback/*<R, T1, T2>*/(
- Zone zone, /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2));
+ R run<R>(Zone zone, R f());
+ R runUnary<R, T>(Zone zone, R f(T arg), T arg);
+ R runBinary<R, T1, T2>(Zone zone,
+ R f(T1 arg1, T2 arg2), T1 arg1, T2 arg2);
+ ZoneCallback<R> registerCallback<R>(Zone zone, R f());
+ ZoneUnaryCallback<R, T> registerUnaryCallback<R, T>(
+ Zone zone, R f(T arg));
+ ZoneBinaryCallback<R, T1, T2> registerBinaryCallback<R, T1, T2>(
+ Zone zone, R f(T1 arg1, T2 arg2));
AsyncError errorCallback(Zone zone, Object error, StackTrace stackTrace);
void scheduleMicrotask(Zone zone, void f());
Timer createTimer(Zone zone, Duration duration, void f());
@@ -322,7 +322,7 @@
* By default, when handled by the root zone, uncaught asynchronous errors are
* treated like uncaught synchronous exceptions.
*/
- /*=R*/ handleUncaughtError/*<R>*/(error, StackTrace stackTrace);
+ R handleUncaughtError<R>(error, StackTrace stackTrace);
/**
* The parent zone of the this zone.
@@ -423,7 +423,7 @@
* [current], custom zones intercepting run should always delegate to their
* parent zone. They may take actions before and after the call.
*/
- /*=R*/ run/*<R>*/(/*=R*/ action());
+ R run<R>(R action());
/**
* Executes the given [action] with [argument] in this zone.
@@ -431,7 +431,7 @@
* As [run] except that [action] is called with one [argument] instead of
* none.
*/
- /*=R*/ runUnary/*<R, T>*/(/*=R*/ action(/*=T*/ argument), /*=T*/ argument);
+ R runUnary<R, T>(R action(T argument), T argument);
/**
* Executes the given [action] with [argument1] and [argument2] in this
@@ -439,9 +439,9 @@
*
* As [run] except that [action] is called with two arguments instead of none.
*/
- /*=R*/ runBinary/*<R, T1, T2>*/(
- /*=R*/ action(/*=T1*/ argument1, /*=T2*/ argument2), /*=T1*/ argument1,
- /*=T2*/ argument2);
+ R runBinary<R, T1, T2>(
+ R action(T1 argument1, T2 argument2), T1 argument1,
+ T2 argument2);
/**
* Executes the given [action] in this zone and catches synchronous
@@ -458,7 +458,7 @@
*
* See [run].
*/
- /*=R*/ runGuarded/*<R>*/(/*=R*/ action());
+ R runGuarded<R>(R action());
/**
* Executes the given [action] with [argument] in this zone and
@@ -466,8 +466,8 @@
*
* See [runGuarded].
*/
- /*=R*/ runUnaryGuarded/*<R, T>*/(/*=R*/ action(/*=T*/ argument),
- /*=T*/ argument);
+ R runUnaryGuarded<R, T>(R action(T argument),
+ T argument);
/**
* Executes the given [action] with [argument1] and [argument2] in this
@@ -475,9 +475,9 @@
*
* See [runGuarded].
*/
- /*=R*/ runBinaryGuarded/*<R, T1, T2>*/(
- /*=R*/ action(/*=T1*/ argument1, /*=T2*/ argument2), /*=T1*/ argument1,
- /*=T2*/ argument2);
+ R runBinaryGuarded<R, T1, T2>(
+ R action(T1 argument1, T2 argument2), T1 argument1,
+ T2 argument2);
/**
* Registers the given callback in this zone.
@@ -497,23 +497,23 @@
* Custom zones may intercept this operation. The default implementation in
* [Zone.ROOT] returns the original callback unchanged.
*/
- ZoneCallback/*<R>*/ registerCallback/*<R>*/(/*=R*/ callback());
+ ZoneCallback<R> registerCallback<R>(R callback());
/**
* Registers the given callback in this zone.
*
* Similar to [registerCallback] but with a unary callback.
*/
- ZoneUnaryCallback/*<R, T>*/ registerUnaryCallback/*<R, T>*/(
- /*=R*/ callback(/*=T*/ arg));
+ ZoneUnaryCallback<R, T> registerUnaryCallback<R, T>(
+ R callback(T arg));
/**
* Registers the given callback in this zone.
*
* Similar to [registerCallback] but with a unary callback.
*/
- ZoneBinaryCallback/*<R, T1, T2>*/ registerBinaryCallback/*<R, T1, T2>*/(
- /*=R*/ callback(/*=T1*/ arg1, /*=T2*/ arg2));
+ ZoneBinaryCallback<R, T1, T2> registerBinaryCallback<R, T1, T2>(
+ R callback(T1 arg1, T2 arg2));
/**
* Equivalent to:
@@ -523,8 +523,8 @@
* return () => this.run(registered);
*
*/
- ZoneCallback/*<R>*/ bindCallback/*<R>*/(
- /*=R*/ action(), { bool runGuarded: true });
+ ZoneCallback<R> bindCallback<R>(
+ R action(), { bool runGuarded: true });
/**
* Equivalent to:
@@ -533,8 +533,8 @@
* if (runGuarded) return (arg) => this.runUnaryGuarded(registered, arg);
* return (arg) => thin.runUnary(registered, arg);
*/
- ZoneUnaryCallback/*<R, T>*/ bindUnaryCallback/*<R, T>*/(
- /*=R*/ action(/*=T*/ argument), { bool runGuarded: true });
+ ZoneUnaryCallback<R, T> bindUnaryCallback<R, T>(
+ R action(T argument), { bool runGuarded: true });
/**
* Equivalent to:
@@ -545,8 +545,8 @@
* }
* return (arg1, arg2) => thin.runBinary(registered, arg1, arg2);
*/
- ZoneBinaryCallback/*<R, T1, T2>*/ bindBinaryCallback/*<R, T1, T2>*/(
- /*=R*/ action(/*=T1*/ argument1, /*=T2*/ argument2),
+ ZoneBinaryCallback<R, T1, T2> bindBinaryCallback<R, T1, T2>(
+ R action(T1 argument1, T2 argument2),
{ bool runGuarded: true });
/**
@@ -672,7 +672,7 @@
_ZoneDelegate(this._delegationTarget);
- /*=R*/ handleUncaughtError/*<R>*/(
+ R handleUncaughtError<R>(
Zone zone, error, StackTrace stackTrace) {
var implementation = _delegationTarget._handleUncaughtError;
_Zone implZone = implementation.zone;
@@ -684,7 +684,7 @@
as Object/*=R*/;
}
- /*=R*/ run/*<R>*/(Zone zone, /*=R*/ f()) {
+ R run<R>(Zone zone, R f()) {
var implementation = _delegationTarget._run;
_Zone implZone = implementation.zone;
RunHandler handler = implementation.function;
@@ -694,7 +694,7 @@
as Object/*=R*/;
}
- /*=R*/ runUnary/*<R, T>*/(Zone zone, /*=R*/ f(/*=T*/ arg), /*=T*/ arg) {
+ R runUnary<R, T>(Zone zone, R f(T arg), T arg) {
var implementation = _delegationTarget._runUnary;
_Zone implZone = implementation.zone;
RunUnaryHandler handler = implementation.function;
@@ -704,8 +704,8 @@
implZone, _parentDelegate(implZone), zone, f, arg) as Object/*=R*/;
}
- /*=R*/ runBinary/*<R, T1, T2>*/(Zone zone,
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2), /*=T1*/ arg1, /*=T2*/ arg2) {
+ R runBinary<R, T1, T2>(Zone zone,
+ R f(T1 arg1, T2 arg2), T1 arg1, T2 arg2) {
var implementation = _delegationTarget._runBinary;
_Zone implZone = implementation.zone;
RunBinaryHandler handler = implementation.function;
@@ -716,7 +716,7 @@
as Object/*=R*/;
}
- ZoneCallback/*<R>*/ registerCallback/*<R>*/(Zone zone, /*=R*/ f()) {
+ ZoneCallback<R> registerCallback<R>(Zone zone, R f()) {
var implementation = _delegationTarget._registerCallback;
_Zone implZone = implementation.zone;
RegisterCallbackHandler handler = implementation.function;
@@ -726,8 +726,8 @@
as Object/*=ZoneCallback<R>*/;
}
- ZoneUnaryCallback/*<R, T>*/ registerUnaryCallback/*<R, T>*/(
- Zone zone, /*=R*/ f(/*=T*/ arg)) {
+ ZoneUnaryCallback<R, T> registerUnaryCallback<R, T>(
+ Zone zone, R f(T arg)) {
var implementation = _delegationTarget._registerUnaryCallback;
_Zone implZone = implementation.zone;
RegisterUnaryCallbackHandler handler = implementation.function;
@@ -737,8 +737,8 @@
as Object/*=ZoneUnaryCallback<R, T>*/;
}
- ZoneBinaryCallback/*<R, T1, T2>*/ registerBinaryCallback/*<R, T1, T2>*/(
- Zone zone, /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2)) {
+ ZoneBinaryCallback<R, T1, T2> registerBinaryCallback<R, T1, T2>(
+ Zone zone, R f(T1 arg1, T2 arg2)) {
var implementation = _delegationTarget._registerBinaryCallback;
_Zone implZone = implementation.zone;
RegisterBinaryCallbackHandler handler = implementation.function;
@@ -919,7 +919,7 @@
*/
Zone get errorZone => _handleUncaughtError.zone;
- /*=R*/ runGuarded/*<R>*/(/*=R*/ f()) {
+ R runGuarded<R>(R f()) {
try {
return run(f);
} catch (e, s) {
@@ -927,7 +927,7 @@
}
}
- /*=R*/ runUnaryGuarded/*<R, T>*/(/*=R*/ f(/*=T*/ arg), /*=T*/ arg) {
+ R runUnaryGuarded<R, T>(R f(T arg), T arg) {
try {
return runUnary(f, arg);
} catch (e, s) {
@@ -935,8 +935,8 @@
}
}
- /*=R*/ runBinaryGuarded/*<R, T1, T2>*/(
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2), /*=T1*/ arg1, /*=T2*/ arg2) {
+ R runBinaryGuarded<R, T1, T2>(
+ R f(T1 arg1, T2 arg2), T1 arg1, T2 arg2) {
try {
return runBinary(f, arg1, arg2);
} catch (e, s) {
@@ -944,8 +944,8 @@
}
}
- ZoneCallback/*<R>*/ bindCallback/*<R>*/(
- /*=R*/ f(), { bool runGuarded: true }) {
+ ZoneCallback<R> bindCallback<R>(
+ R f(), { bool runGuarded: true }) {
var registered = registerCallback(f);
if (runGuarded) {
return () => this.runGuarded(registered);
@@ -954,8 +954,8 @@
}
}
- ZoneUnaryCallback/*<R, T>*/ bindUnaryCallback/*<R, T>*/(
- /*=R*/ f(/*=T*/ arg), { bool runGuarded: true }) {
+ ZoneUnaryCallback<R, T> bindUnaryCallback<R, T>(
+ R f(T arg), { bool runGuarded: true }) {
var registered = registerUnaryCallback(f);
if (runGuarded) {
return (arg) => this.runUnaryGuarded(registered, arg);
@@ -964,8 +964,8 @@
}
}
- ZoneBinaryCallback/*<R, T1, T2>*/ bindBinaryCallback/*<R, T1, T2>*/(
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2), { bool runGuarded: true }) {
+ ZoneBinaryCallback<R, T1, T2> bindBinaryCallback<R, T1, T2>(
+ R f(T1 arg1, T2 arg2), { bool runGuarded: true }) {
var registered = registerBinaryCallback(f);
if (runGuarded) {
return (arg1, arg2) => this.runBinaryGuarded(registered, arg1, arg2);
@@ -995,7 +995,7 @@
// Methods that can be customized by the zone specification.
- /*=R*/ handleUncaughtError/*<R>*/(error, StackTrace stackTrace) {
+ R handleUncaughtError<R>(error, StackTrace stackTrace) {
var implementation = this._handleUncaughtError;
assert(implementation != null);
ZoneDelegate parentDelegate = _parentDelegate(implementation.zone);
@@ -1016,7 +1016,7 @@
specification, zoneValues);
}
- /*=R*/ run/*<R>*/(/*=R*/ f()) {
+ R run<R>(R f()) {
var implementation = this._run;
assert(implementation != null);
ZoneDelegate parentDelegate = _parentDelegate(implementation.zone);
@@ -1027,7 +1027,7 @@
as Object/*=R*/;
}
- /*=R*/ runUnary/*<R, T>*/(/*=R*/ f(/*=T*/ arg), /*=T*/ arg) {
+ R runUnary<R, T>(R f(T arg), T arg) {
var implementation = this._runUnary;
assert(implementation != null);
ZoneDelegate parentDelegate = _parentDelegate(implementation.zone);
@@ -1038,8 +1038,8 @@
as Object/*=R*/;
}
- /*=R*/ runBinary/*<R, T1, T2>*/(
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2), /*=T1*/ arg1, /*=T2*/ arg2) {
+ R runBinary<R, T1, T2>(
+ R f(T1 arg1, T2 arg2), T1 arg1, T2 arg2) {
var implementation = this._runBinary;
assert(implementation != null);
ZoneDelegate parentDelegate = _parentDelegate(implementation.zone);
@@ -1051,7 +1051,7 @@
as Object/*=R*/;
}
- ZoneCallback/*<R>*/ registerCallback/*<R>*/(/*=R*/ callback()) {
+ ZoneCallback<R> registerCallback<R>(R callback()) {
var implementation = this._registerCallback;
assert(implementation != null);
ZoneDelegate parentDelegate = _parentDelegate(implementation.zone);
@@ -1062,8 +1062,8 @@
as Object/*=ZoneCallback<R>*/;
}
- ZoneUnaryCallback/*<R, T>*/ registerUnaryCallback/*<R, T>*/(
- /*=R*/ callback(/*=T*/ arg)) {
+ ZoneUnaryCallback<R, T> registerUnaryCallback<R, T>(
+ R callback(T arg)) {
var implementation = this._registerUnaryCallback;
assert(implementation != null);
ZoneDelegate parentDelegate = _parentDelegate(implementation.zone);
@@ -1074,8 +1074,8 @@
as Object/*=ZoneUnaryCallback<R, T>*/;
}
- ZoneBinaryCallback/*<R, T1, T2>*/ registerBinaryCallback/*<R, T1, T2>*/(
- /*=R*/ callback(/*=T1*/ arg1, /*=T2*/ arg2)) {
+ ZoneBinaryCallback<R, T1, T2> registerBinaryCallback<R, T1, T2>(
+ R callback(T1 arg1, T2 arg2)) {
var implementation = this._registerBinaryCallback;
assert(implementation != null);
ZoneDelegate parentDelegate = _parentDelegate(implementation.zone);
@@ -1131,7 +1131,7 @@
}
}
-/*=R*/ _rootHandleUncaughtError/*<R>*/(
+R _rootHandleUncaughtError<R>(
Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace) {
_schedulePriorityAsyncCallback(() {
if (error == null) error = new NullThrownError();
@@ -1142,7 +1142,7 @@
external void _rethrow(Object error, StackTrace stackTrace);
-/*=R*/ _rootRun/*<R>*/(Zone self, ZoneDelegate parent, Zone zone, /*=R*/ f()) {
+R _rootRun<R>(Zone self, ZoneDelegate parent, Zone zone, R f()) {
if (Zone._current == zone) return f();
Zone old = Zone._enter(zone);
@@ -1153,8 +1153,8 @@
}
}
-/*=R*/ _rootRunUnary/*<R, T>*/(Zone self, ZoneDelegate parent, Zone zone,
- /*=R*/ f(/*=T*/ arg), /*=T*/ arg) {
+R _rootRunUnary<R, T>(Zone self, ZoneDelegate parent, Zone zone,
+ R f(T arg), T arg) {
if (Zone._current == zone) return f(arg);
Zone old = Zone._enter(zone);
@@ -1165,8 +1165,8 @@
}
}
-/*=R*/ _rootRunBinary/*<R, T1, T2>*/(Zone self, ZoneDelegate parent, Zone zone,
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2), /*=T1*/ arg1, /*=T2*/ arg2) {
+R _rootRunBinary<R, T1, T2>(Zone self, ZoneDelegate parent, Zone zone,
+ R f(T1 arg1, T2 arg2), T1 arg1, T2 arg2) {
if (Zone._current == zone) return f(arg1, arg2);
Zone old = Zone._enter(zone);
@@ -1177,19 +1177,19 @@
}
}
-ZoneCallback/*<R>*/ _rootRegisterCallback/*<R>*/(
- Zone self, ZoneDelegate parent, Zone zone, /*=R*/ f()) {
+ZoneCallback<R> _rootRegisterCallback<R>(
+ Zone self, ZoneDelegate parent, Zone zone, R f()) {
return f;
}
-ZoneUnaryCallback/*<R, T>*/ _rootRegisterUnaryCallback/*<R, T>*/(
- Zone self, ZoneDelegate parent, Zone zone, /*=R*/ f(/*=T*/ arg)) {
+ZoneUnaryCallback<R, T> _rootRegisterUnaryCallback<R, T>(
+ Zone self, ZoneDelegate parent, Zone zone, R f(T arg)) {
return f;
}
-ZoneBinaryCallback/*<R, T1, T2>*/ _rootRegisterBinaryCallback/*<R, T1, T2>*/(
+ZoneBinaryCallback<R, T1, T2> _rootRegisterBinaryCallback<R, T1, T2>(
Zone self, ZoneDelegate parent, Zone zone,
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2)) {
+ R f(T1 arg1, T2 arg2)) {
return f;
}
@@ -1219,7 +1219,7 @@
Duration duration, void callback(Timer timer)) {
if (!identical(_ROOT_ZONE, zone)) {
// TODO(floitsch): the return type should be 'void'.
- callback = zone.bindUnaryCallback/*<dynamic, Timer>*/(callback);
+ callback = zone.bindUnaryCallback<dynamic, Timer>(callback);
}
return Timer._createPeriodicTimer(duration, callback);
}
@@ -1321,65 +1321,65 @@
// Zone interface.
- /*=R*/ runGuarded/*<R>*/(/*=R*/ f()) {
+ R runGuarded<R>(R f()) {
try {
if (identical(_ROOT_ZONE, Zone._current)) {
return f();
}
- return _rootRun/*<R>*/(null, null, this, f);
+ return _rootRun<R>(null, null, this, f);
} catch (e, s) {
- return handleUncaughtError/*<R>*/(e, s);
+ return handleUncaughtError<R>(e, s);
}
}
- /*=R*/ runUnaryGuarded/*<R, T>*/(/*=R*/ f(/*=T*/ arg), /*=T*/ arg) {
+ R runUnaryGuarded<R, T>(R f(T arg), T arg) {
try {
if (identical(_ROOT_ZONE, Zone._current)) {
return f(arg);
}
- return _rootRunUnary/*<R, T>*/(null, null, this, f, arg);
+ return _rootRunUnary<R, T>(null, null, this, f, arg);
} catch (e, s) {
- return handleUncaughtError/*<R>*/(e, s);
+ return handleUncaughtError<R>(e, s);
}
}
- /*=R*/ runBinaryGuarded/*<R, T1, T2>*/(
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2), /*=T1*/ arg1, /*=T2*/ arg2) {
+ R runBinaryGuarded<R, T1, T2>(
+ R f(T1 arg1, T2 arg2), T1 arg1, T2 arg2) {
try {
if (identical(_ROOT_ZONE, Zone._current)) {
return f(arg1, arg2);
}
- return _rootRunBinary/*<R, T1, T2>*/(null, null, this, f, arg1, arg2);
+ return _rootRunBinary<R, T1, T2>(null, null, this, f, arg1, arg2);
} catch (e, s) {
- return handleUncaughtError/*<R>*/(e, s);
+ return handleUncaughtError<R>(e, s);
}
}
- ZoneCallback/*<R>*/ bindCallback/*<R>*/(
- /*=R*/ f(), { bool runGuarded: true }) {
+ ZoneCallback<R> bindCallback<R>(
+ R f(), { bool runGuarded: true }) {
if (runGuarded) {
- return () => this.runGuarded/*<R>*/(f);
+ return () => this.runGuarded<R>(f);
} else {
- return () => this.run/*<R>*/(f);
+ return () => this.run<R>(f);
}
}
- ZoneUnaryCallback/*<R, T>*/ bindUnaryCallback/*<R, T>*/(
- /*=R*/ f(/*=T*/ arg), { bool runGuarded: true }) {
+ ZoneUnaryCallback<R, T> bindUnaryCallback<R, T>(
+ R f(T arg), { bool runGuarded: true }) {
if (runGuarded) {
- return (arg) => this.runUnaryGuarded/*<R, T>*/(f, arg);
+ return (arg) => this.runUnaryGuarded<R, T>(f, arg);
} else {
- return (arg) => this.runUnary/*<R, T>*/(f, arg);
+ return (arg) => this.runUnary<R, T>(f, arg);
}
}
- ZoneBinaryCallback/*<R, T1, T2>*/ bindBinaryCallback/*<R, T1, T2>*/(
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2), { bool runGuarded: true }) {
+ ZoneBinaryCallback<R, T1, T2> bindBinaryCallback<R, T1, T2>(
+ R f(T1 arg1, T2 arg2), { bool runGuarded: true }) {
if (runGuarded) {
return (arg1, arg2) =>
- this.runBinaryGuarded/*<R, T1, T2>*/(f, arg1, arg2);
+ this.runBinaryGuarded<R, T1, T2>(f, arg1, arg2);
} else {
- return (arg1, arg2) => this.runBinary/*<R, T1, T2>*/(f, arg1, arg2);
+ return (arg1, arg2) => this.runBinary<R, T1, T2>(f, arg1, arg2);
}
}
@@ -1387,7 +1387,7 @@
// Methods that can be customized by the zone specification.
- /*=R*/ handleUncaughtError/*<R>*/(error, StackTrace stackTrace) {
+ R handleUncaughtError<R>(error, StackTrace stackTrace) {
return _rootHandleUncaughtError(null, null, this, error, stackTrace);
}
@@ -1395,29 +1395,29 @@
return _rootFork(null, null, this, specification, zoneValues);
}
- /*=R*/ run/*<R>*/(/*=R*/ f()) {
+ R run<R>(R f()) {
if (identical(Zone._current, _ROOT_ZONE)) return f();
return _rootRun(null, null, this, f);
}
- /*=R*/ runUnary/*<R, T>*/(/*=R*/ f(/*=T*/ arg), /*=T*/ arg) {
+ R runUnary<R, T>(R f(T arg), T arg) {
if (identical(Zone._current, _ROOT_ZONE)) return f(arg);
return _rootRunUnary(null, null, this, f, arg);
}
- /*=R*/ runBinary/*<R, T1, T2>*/(
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2), /*=T1*/ arg1, /*=T2*/ arg2) {
+ R runBinary<R, T1, T2>(
+ R f(T1 arg1, T2 arg2), T1 arg1, T2 arg2) {
if (identical(Zone._current, _ROOT_ZONE)) return f(arg1, arg2);
return _rootRunBinary(null, null, this, f, arg1, arg2);
}
- ZoneCallback/*<R>*/ registerCallback/*<R>*/(/*=R*/ f()) => f;
+ ZoneCallback<R> registerCallback<R>(R f()) => f;
- ZoneUnaryCallback/*<R, T>*/ registerUnaryCallback/*<R, T>*/(
- /*=R*/ f(/*=T*/ arg)) => f;
+ ZoneUnaryCallback<R, T> registerUnaryCallback<R, T>(
+ R f(T arg)) => f;
- ZoneBinaryCallback/*<R, T1, T2>*/ registerBinaryCallback/*<R, T1, T2>*/(
- /*=R*/ f(/*=T1*/ arg1, /*=T2*/ arg2)) => f;
+ ZoneBinaryCallback<R, T1, T2> registerBinaryCallback<R, T1, T2>(
+ R f(T1 arg1, T2 arg2)) => f;
AsyncError errorCallback(Object error, StackTrace stackTrace) => null;
@@ -1465,7 +1465,7 @@
* new Future(() { throw "asynchronous error"; });
* }, onError: print); // Will print "asynchronous error".
*/
-/*=R*/ runZoned/*<R>*/(/*=R*/ body(),
+R runZoned<R>(R body(),
{ Map zoneValues,
ZoneSpecification zoneSpecification,
Function onError }) {
@@ -1474,7 +1474,7 @@
errorHandler = (Zone self, ZoneDelegate parent, Zone zone,
error, StackTrace stackTrace) {
try {
- if (onError is ZoneBinaryCallback<dynamic/*=R*/, dynamic, StackTrace>) {
+ if (onError is ZoneBinaryCallback<R, dynamic, StackTrace>) {
return self.parent.runBinary(onError, error, stackTrace);
}
return self.parent.runUnary(onError, error);
diff --git a/sdk/lib/collection/iterable.dart b/sdk/lib/collection/iterable.dart
index edfce85..c0fc812 100644
--- a/sdk/lib/collection/iterable.dart
+++ b/sdk/lib/collection/iterable.dart
@@ -15,13 +15,13 @@
// - SetMixin
// If changing a method here, also change the other copies.
- Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(E element)) =>
- new MappedIterable<E, dynamic/*=T*/>(this, f);
+ Iterable<T> map<T>(T f(E element)) =>
+ new MappedIterable<E, T>(this, f);
Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f);
- Iterable/*<T>*/ expand/*<T>*/(Iterable/*<T>*/ f(E element)) =>
- new ExpandIterable<E, dynamic/*=T*/>(this, f);
+ Iterable<T> expand<T>(Iterable<T> f(E element)) =>
+ new ExpandIterable<E, T>(this, f);
bool contains(Object element) {
for (E e in this) {
@@ -46,8 +46,8 @@
return value;
}
- dynamic/*=T*/ fold/*<T>*/(var/*=T*/ initialValue,
- dynamic/*=T*/ combine(var/*=T*/ previousValue, E element)) {
+ T fold<T>(T initialValue,
+ T combine(T previousValue, E element)) {
var value = initialValue;
for (E element in this) value = combine(value, element);
return value;
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart
index 8b6713a..b81b8dd 100644
--- a/sdk/lib/collection/list.dart
+++ b/sdk/lib/collection/list.dart
@@ -175,11 +175,11 @@
Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test);
- Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(E element)) =>
- new MappedListIterable/*<E, T>*/(this, f);
+ Iterable<T> map<T>(T f(E element)) =>
+ new MappedListIterable<E, T>(this, f);
- Iterable/*<T>*/ expand/*<T>*/(Iterable/*<T>*/ f(E element)) =>
- new ExpandIterable<E, dynamic/*=T*/>(this, f);
+ Iterable<T> expand<T>(Iterable<T> f(E element)) =>
+ new ExpandIterable<E, T>(this, f);
E reduce(E combine(E previousValue, E element)) {
int length = this.length;
@@ -194,8 +194,8 @@
return value;
}
- dynamic/*=T*/ fold/*<T>*/(var/*=T*/ initialValue,
- dynamic/*=T*/ combine(var/*=T*/ previousValue, E element)) {
+ T fold<T>(T initialValue,
+ T combine(T previousValue, E element)) {
var value = initialValue;
int length = this.length;
for (int i = 0; i < length; i++) {
@@ -371,7 +371,7 @@
List<E> otherList;
int otherStart;
// TODO(floitsch): Make this accept more.
- if (iterable is List/*<E>*/) {
+ if (iterable is List<E>) {
otherList = iterable;
otherStart = skipCount;
} else {
diff --git a/sdk/lib/collection/queue.dart b/sdk/lib/collection/queue.dart
index 69b18d2..70f7111 100644
--- a/sdk/lib/collection/queue.dart
+++ b/sdk/lib/collection/queue.dart
@@ -610,7 +610,7 @@
}
void addAll(Iterable<E> elements) {
- if (elements is List/*<E>*/) {
+ if (elements is List<E>) {
List<E> list = elements;
int addCount = list.length;
int length = this.length;
diff --git a/sdk/lib/collection/set.dart b/sdk/lib/collection/set.dart
index 499225d..75f2fcf 100644
--- a/sdk/lib/collection/set.dart
+++ b/sdk/lib/collection/set.dart
@@ -120,8 +120,8 @@
return result;
}
- Iterable/*<T>*/ map/*<T>*/(/*=T*/f(E element)) =>
- new EfficientLengthMappedIterable<E, dynamic/*=T*/>(this, f);
+ Iterable<T> map<T>(T f(E element)) =>
+ new EfficientLengthMappedIterable<E, T>(this, f);
E get single {
if (length > 1) throw IterableElementError.tooMany();
@@ -138,8 +138,8 @@
Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f);
- Iterable/*<T>*/ expand/*<T>*/(Iterable/*<T>*/ f(E element)) =>
- new ExpandIterable<E, dynamic/*=T*/>(this, f);
+ Iterable<T> expand<T>(Iterable<T> f(E element)) =>
+ new ExpandIterable<E, T>(this, f);
void forEach(void f(E element)) {
for (E element in this) f(element);
@@ -157,8 +157,8 @@
return value;
}
- dynamic/*=T*/ fold/*<T>*/(var/*=T*/ initialValue,
- dynamic/*=T*/ combine(var/*=T*/ previousValue, E element)) {
+ T fold<T>(T initialValue,
+ T combine(T previousValue, E element)) {
var value = initialValue;
for (E element in this) value = combine(value, element);
return value;
diff --git a/sdk/lib/convert/chunked_conversion.dart b/sdk/lib/convert/chunked_conversion.dart
index ee71f4f..d33afb7 100644
--- a/sdk/lib/convert/chunked_conversion.dart
+++ b/sdk/lib/convert/chunked_conversion.dart
@@ -84,7 +84,7 @@
final Sink<S> _chunkedSink;
_ConverterStreamEventSink(
- Converter/*=Converter<S, T>*/ converter,
+ Converter<S, T> converter,
EventSink<T> sink)
: this._eventSink = sink,
_chunkedSink = converter.startChunkedConversion(sink);
diff --git a/sdk/lib/convert/codec.dart b/sdk/lib/convert/codec.dart
index f4ff700..69028d0 100644
--- a/sdk/lib/convert/codec.dart
+++ b/sdk/lib/convert/codec.dart
@@ -60,8 +60,8 @@
*/
// TODO(floitsch): use better example with line-splitter once that one is
// in this library.
- Codec<S, dynamic/*=R*/> fuse/*<R>*/(Codec<T, dynamic/*=R*/> other) {
- return new _FusedCodec<S, T, dynamic/*=R*/>(this, other);
+ Codec<S, R> fuse<R>(Codec<T, R> other) {
+ return new _FusedCodec<S, T, R>(this, other);
}
/**
@@ -82,8 +82,8 @@
final Codec<S, M> _first;
final Codec<M, T> _second;
- Converter<S, T> get encoder => _first.encoder.fuse/*<T>*/(_second.encoder);
- Converter<T, S> get decoder => _second.decoder.fuse/*<S>*/(_first.decoder);
+ Converter<S, T> get encoder => _first.encoder.fuse<T>(_second.encoder);
+ Converter<T, S> get decoder => _second.decoder.fuse<S>(_first.decoder);
_FusedCodec(this._first, this._second);
}
diff --git a/sdk/lib/convert/converter.dart b/sdk/lib/convert/converter.dart
index 75d4cf0..dc0661c 100644
--- a/sdk/lib/convert/converter.dart
+++ b/sdk/lib/convert/converter.dart
@@ -10,7 +10,7 @@
* It is recommended that implementations of `Converter` extend this class,
* to inherit any further methods that may be added to the class.
*/
-abstract class Converter<S, T> implements StreamTransformer/*<S, T>*/ {
+abstract class Converter<S, T> implements StreamTransformer<S, T> {
const Converter();
/**
@@ -24,9 +24,8 @@
* Encoding with the resulting converter is equivalent to converting with
* `this` before converting with `other`.
*/
- Converter<S, dynamic/*=TT*/> fuse/*<TT>*/(
- Converter<T, dynamic/*=TT*/> other) {
- return new _FusedConverter<S, T, dynamic/*=TT*/>(this, other);
+ Converter<S, TT> fuse<TT>(Converter<T, TT> other) {
+ return new _FusedConverter<S, T, TT>(this, other);
}
/**
@@ -40,8 +39,8 @@
"This converter does not support chunked conversions: $this");
}
- Stream/*<T>*/ bind(Stream/*<S>*/ stream) {
- return new Stream/*<T>*/.eventTransformed(
+ Stream<T> bind(Stream<S> stream) {
+ return new Stream<T>.eventTransformed(
stream,
(EventSink sink) => new _ConverterStreamEventSink(this, sink));
}
diff --git a/sdk/lib/convert/json.dart b/sdk/lib/convert/json.dart
index 3d5ee82..712f094 100644
--- a/sdk/lib/convert/json.dart
+++ b/sdk/lib/convert/json.dart
@@ -268,13 +268,12 @@
// Override the base class's bind, to provide a better type.
Stream<String> bind(Stream<Object> stream) => super.bind(stream);
- Converter<Object, dynamic/*=T*/> fuse/*<T>*/(
- Converter<String, dynamic/*=T*/> other) {
+ Converter<Object, T> fuse<T>(Converter<String, T> other) {
if (other is Utf8Encoder) {
return new JsonUtf8Encoder(indent, _toEncodable)
as dynamic/*=Converter<Object, T>*/;
}
- return super.fuse/*<T>*/(other);
+ return super.fuse<T>(other);
}
}
diff --git a/sdk/lib/convert/line_splitter.dart b/sdk/lib/convert/line_splitter.dart
index 331527e..785ae8b 100644
--- a/sdk/lib/convert/line_splitter.dart
+++ b/sdk/lib/convert/line_splitter.dart
@@ -9,7 +9,7 @@
const int _CR = 13;
/**
- * A [Converter] that splits a [String] into individual lines.
+ * A [StreamTranformer] that splits a [String] into individual lines.
*
* A line is terminated by either a CR (U+000D), a LF (U+000A), a
* CR+LF sequence (DOS line ending),
@@ -17,6 +17,7 @@
*
* The returned lines do not contain the line terminators.
*/
+
class LineSplitter
extends Converter<String, List<String>>/*=Object*/
implements ChunkedConverter<String, List<String>, String, String>
@@ -83,7 +84,7 @@
return new _LineSplitterSink(sink);
}
- Stream/*<String>*/ bind(Stream/*<String>*/ stream) {
+ Stream/*<String>*/ bind(Stream<String> stream) {
return new Stream<String>.eventTransformed(
stream,
(EventSink<String> sink) => new _LineSplitterEventSink(sink));
diff --git a/sdk/lib/convert/utf.dart b/sdk/lib/convert/utf.dart
index 86763cb..0687bb1 100644
--- a/sdk/lib/convert/utf.dart
+++ b/sdk/lib/convert/utf.dart
@@ -370,8 +370,7 @@
// Override the base-classes bind, to provide a better type.
Stream<String> bind(Stream<List<int>> stream) => super.bind(stream);
- external Converter<List<int>, dynamic/*=T*/> fuse/*<T>*/(
- Converter<String, dynamic/*=T*/> next);
+ external Converter<List<int>, T> fuse<T>(Converter<String, T> next);
external static String _convertIntercepted(
bool allowMalformed, List<int> codeUnits, int start, int end);
diff --git a/sdk/lib/core/iterable.dart b/sdk/lib/core/iterable.dart
index 770465b..18ec4d1 100644
--- a/sdk/lib/core/iterable.dart
+++ b/sdk/lib/core/iterable.dart
@@ -154,8 +154,7 @@
* on any element where the result isn't needed.
* For example, [elementAt] may call `f` only once.
*/
- Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(E e)) =>
- new MappedIterable<E, dynamic/*=T*/>(this, f);
+ Iterable<T> map<T>(T f(E e)) => new MappedIterable<E, T>(this, f);
/**
* Returns a new lazy [Iterable] with all elements that satisfy the
@@ -193,8 +192,8 @@
* print(duplicated); // => [1, 1, 2, 2, 3, 3]
*
*/
- Iterable/*<T>*/ expand/*<T>*/(Iterable/*<T>*/ f(E element)) =>
- new ExpandIterable<E, dynamic/*=T*/>(this, f);
+ Iterable<T> expand<T>(Iterable<T> f(E element)) =>
+ new ExpandIterable<E, T>(this, f);
/**
* Returns true if the collection contains an element equal to [element].
@@ -280,8 +279,7 @@
* iterable.fold(0, (prev, element) => prev + element);
*
*/
- dynamic/*=T*/ fold/*<T>*/(var/*=T*/ initialValue,
- dynamic/*=T*/ combine(var/*=T*/ previousValue, E element)) {
+ T fold<T>(T initialValue, T combine(T previousValue, E element)) {
var value = initialValue;
for (E element in this) value = combine(value, element);
return value;
diff --git a/sdk/lib/developer/extension.dart b/sdk/lib/developer/extension.dart
index 5883fb5..e50a88d 100644
--- a/sdk/lib/developer/extension.dart
+++ b/sdk/lib/developer/extension.dart
@@ -166,7 +166,7 @@
_postEvent(eventKind, eventDataAsString);
}
-external _postEvent(String eventKind, String eventData);
+external void _postEvent(String eventKind, String eventData);
// Both of these functions are written inside C++ to avoid updating the data
// structures in Dart, getting an OOB, and observing stale state. Do not move
diff --git a/sdk/lib/developer/profiler.dart b/sdk/lib/developer/profiler.dart
index 566d015..127a48e 100644
--- a/sdk/lib/developer/profiler.dart
+++ b/sdk/lib/developer/profiler.dart
@@ -9,7 +9,7 @@
/// The maximum number of UserTag instances that can be created by a program.
static const MAX_USER_TAGS = 64;
- factory UserTag(String label) => new _FakeUserTag(label);
+ external factory UserTag(String label);
/// Label of [this].
String get label;
@@ -19,50 +19,11 @@
UserTag makeCurrent();
/// The default [UserTag] with label 'Default'.
- static UserTag get defaultTag => _FakeUserTag._defaultTag;
+ external static UserTag get defaultTag;
}
-// This is a fake implementation of UserTag so that code can compile and run
-// in dart2js.
-class _FakeUserTag implements UserTag {
- static Map _instances = {};
-
- _FakeUserTag.real(this.label);
-
- factory _FakeUserTag(String label) {
- // Canonicalize by name.
- var existingTag = _instances[label];
- if (existingTag != null) {
- return existingTag;
- }
- // Throw an exception if we've reached the maximum number of user tags.
- if (_instances.length == UserTag.MAX_USER_TAGS) {
- throw new UnsupportedError(
- 'UserTag instance limit (${UserTag.MAX_USER_TAGS}) reached.');
- }
- // Create a new instance and add it to the instance map.
- var instance = new _FakeUserTag.real(label);
- _instances[label] = instance;
- return instance;
- }
-
- final String label;
-
- UserTag makeCurrent() {
- var old = _currentTag;
- _currentTag = this;
- return old;
- }
-
- static final UserTag _defaultTag = new _FakeUserTag('Default');
-}
-
-var _currentTag = _FakeUserTag._defaultTag;
-
/// Returns the current [UserTag] for the isolate.
-UserTag getCurrentTag() {
- return _currentTag;
-}
+external UserTag getCurrentTag();
/// Abstract [Metric] class. Metric names must be unique, are hierarchical,
/// and use periods as separators. For example, 'a.b.c'. Uniqueness is only
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index ad4adaf..5480b2d 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -39644,6 +39644,7 @@
return value is String && _classListContains(_classListOf(_element), value);
}
+ @ForceInline()
static bool _add(Element _element, String value) {
DomTokenList list = _classListOf(_element);
// Compute returned result independently of action upon the set.
@@ -39652,6 +39653,7 @@
return added;
}
+ @ForceInline()
static bool _remove(Element _element, String value) {
DomTokenList list = _classListOf(_element);
bool removed = _classListContainsBeforeAddOrRemove(list, value);
diff --git a/sdk/lib/internal/iterable.dart b/sdk/lib/internal/iterable.dart
index 73b3669..637b021 100644
--- a/sdk/lib/internal/iterable.dart
+++ b/sdk/lib/internal/iterable.dart
@@ -172,8 +172,7 @@
Iterable<E> where(bool test(E element)) => super.where(test);
- Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(E element)) =>
- new MappedListIterable<E, dynamic/*=T*/ >(this, f);
+ Iterable<T> map<T>(T f(E element)) => new MappedListIterable<E, T>(this, f);
E reduce(E combine(var value, E element)) {
int length = this.length;
@@ -189,9 +188,7 @@
return value;
}
- /*=T*/ fold/*<T>*/(
- var/*=T*/ initialValue, /*=T*/ combine(
- var/*=T*/ previousValue, E element)) {
+ T fold<T>(T initialValue, T combine(T previousValue, E element)) {
var value = initialValue;
int length = this.length;
for (int i = 0; i < length; i++) {
@@ -428,8 +425,7 @@
Iterator<E> get iterator => new WhereIterator<E>(_iterable.iterator, _f);
// Specialization of [Iterable.map] to non-EfficientLengthIterable.
- Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(E element)) =>
- new MappedIterable<E, dynamic/*=T*/>._(this, f);
+ Iterable<T> map<T>(T f(E element)) => new MappedIterable<E, T>._(this, f);
}
class WhereIterator<E> extends Iterator<E> {
@@ -720,15 +716,13 @@
Iterable<E> where(bool test(E element)) => this;
- Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(E element)) => const EmptyIterable();
+ Iterable<T> map<T>(T f(E element)) => const EmptyIterable();
E reduce(E combine(E value, E element)) {
throw IterableElementError.noElement();
}
- /*=T*/ fold/*<T>*/(
- var/*=T*/ initialValue, /*=T*/ combine(
- var/*=T*/ previousValue, E element)) {
+ T fold<T>(T initialValue, T combine(T previousValue, E element)) {
return initialValue;
}
diff --git a/sdk/lib/internal/sort.dart b/sdk/lib/internal/sort.dart
index 63037ea..40a7d09 100644
--- a/sdk/lib/internal/sort.dart
+++ b/sdk/lib/internal/sort.dart
@@ -29,7 +29,7 @@
* The function's behavior must be consistent. It must not return different
* results for the same values.
*/
- static void sort/*<E>*/(List/*<E>*/ a, int compare(dynamic /*=E*/ a, dynamic /*=E*/ b)) {
+ static void sort<E>(List<E> a, int compare(E a, E b)) {
_doSort(a, 0, a.length - 1, compare);
}
@@ -42,7 +42,7 @@
*
* See [:sort:] for requirements of the [:compare:] function.
*/
- static void sortRange/*<E>*/(List/*<E>*/ a, int from, int to, int compare(dynamic /*=E*/ a, dynamic /*=E*/ b)) {
+ static void sortRange<E>(List<E> a, int from, int to, int compare(E a, E b)) {
if ((from < 0) || (to > a.length) || (to < from)) {
throw "OutOfRange";
}
@@ -52,7 +52,8 @@
/**
* Sorts the list in the interval [:left:] to [:right:] (both inclusive).
*/
- static void _doSort/*<E>*/(List/*<E>*/ a, int left, int right, int compare(dynamic /*=E*/ a, dynamic /*=E*/ b)) {
+ static void _doSort<E>(List<E> a, int left, int right,
+ int compare(E a, E b)) {
if ((right - left) <= _INSERTION_SORT_THRESHOLD) {
_insertionSort(a, left, right, compare);
} else {
@@ -60,7 +61,8 @@
}
}
- static void _insertionSort/*<E>*/(List/*<E>*/ a, int left, int right, int compare(dynamic /*=E*/ a, dynamic /*=E*/ b)) {
+ static void _insertionSort<E>(List<E> a, int left, int right,
+ int compare(E a, E b)) {
for (int i = left + 1; i <= right; i++) {
var el = a[i];
int j = i;
@@ -72,9 +74,8 @@
}
}
- static void _dualPivotQuicksort/*<E>*/(List/*<E>*/ a,
- int left, int right,
- int compare(dynamic /*=E*/ a, dynamic /*=E*/ b)) {
+ static void _dualPivotQuicksort<E>(List<E> a, int left, int right,
+ int compare(E a, E b)) {
assert(right - left > _INSERTION_SORT_THRESHOLD);
// Compute the two pivots by looking at 5 elements.
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
index 5b61fb3..dce4cbc 100644
--- a/sdk/lib/io/file_impl.dart
+++ b/sdk/lib/io/file_impl.dart
@@ -213,7 +213,7 @@
}
Future<File> close() =>
- _openFuture.then/*<File>*/((openedFile) => openedFile.close());
+ _openFuture.then<File>((openedFile) => openedFile.close());
}
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 96005c95..a965afa 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -764,11 +764,11 @@
if (response.redirects.length < maxRedirects) {
// Redirect and drain response.
future = response.drain()
- .then/*<HttpClientResponse>*/((_) => response.redirect());
+ .then<HttpClientResponse>((_) => response.redirect());
} else {
// End with exception, too many redirects.
future = response.drain()
- .then/*<HttpClientResponse>*/((_) {
+ .then<HttpClientResponse>((_) {
return new Future<HttpClientResponse>.error(
new RedirectException("Redirect limit exceeded",
response.redirects));
@@ -1391,7 +1391,7 @@
// data).
_httpParser.isHead = method == "HEAD";
_streamFuture = outgoing.done
- .then/*<Socket>*/((Socket s) {
+ .then<Socket>((Socket s) {
// Request sent, set up response completer.
_nextResponseCompleter = new Completer();
diff --git a/sdk/lib/io/http_parser.dart b/sdk/lib/io/http_parser.dart
index c2b08e4..a52c4b6 100644
--- a/sdk/lib/io/http_parser.dart
+++ b/sdk/lib/io/http_parser.dart
@@ -120,8 +120,8 @@
bool get isPaused => _subscription.isPaused;
- Future/*<T>*/ asFuture/*<T>*/([/*=T*/ futureValue]) =>
- _subscription.asFuture/*<T>*/(futureValue);
+ Future<T> asFuture<T>([T futureValue]) =>
+ _subscription.asFuture<T>(futureValue);
Future cancel() {
_isCanceled = true;
diff --git a/sdk/lib/io/link.dart b/sdk/lib/io/link.dart
index 7c93725..83940b4 100644
--- a/sdk/lib/io/link.dart
+++ b/sdk/lib/io/link.dart
@@ -223,7 +223,7 @@
// Atomically changing a link can be done by creating the new link, with
// a different name, and using the rename() posix call to move it to
// the old name atomically.
- return delete().then/*<Link>*/((_) => create(target));
+ return delete().then<Link>((_) => create(target));
}
Future<Link> _delete({bool recursive: false}) {
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart
index a2d6d78..a523f20 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -75,7 +75,7 @@
SecurityContext context,
bool onBadCertificate(X509Certificate certificate)}) {
return ((socket as dynamic/*_Socket*/)._detachRaw() as Future)
- .then/*<RawSecureSocket>*/((detachedRaw) {
+ .then<RawSecureSocket>((detachedRaw) {
return RawSecureSocket.secure(
detachedRaw[0] as RawSocket,
subscription: detachedRaw[1] as StreamSubscription<RawSocketEvent>,
@@ -83,7 +83,7 @@
context: context,
onBadCertificate: onBadCertificate);
})
- .then/*<SecureSocket>*/((raw) => new SecureSocket._(raw));
+ .then<SecureSocket>((raw) => new SecureSocket._(raw));
}
/**
@@ -115,7 +115,7 @@
bool requireClientCertificate: false,
List<String> supportedProtocols}) {
return ((socket as dynamic/*_Socket*/)._detachRaw() as Future)
- .then/*<RawSecureSocket>*/((detachedRaw) {
+ .then<RawSecureSocket>((detachedRaw) {
return RawSecureSocket.secureServer(
detachedRaw[0] as RawSocket,
context,
@@ -125,7 +125,7 @@
requireClientCertificate: requireClientCertificate,
supportedProtocols: supportedProtocols);
})
- .then/*<SecureSocket>*/((raw) => new SecureSocket._(raw));
+ .then<SecureSocket>((raw) => new SecureSocket._(raw));
}
/**
diff --git a/sdk/lib/io/websocket_impl.dart b/sdk/lib/io/websocket_impl.dart
index 047cf69..aa2a1e5 100644
--- a/sdk/lib/io/websocket_impl.dart
+++ b/sdk/lib/io/websocket_impl.dart
@@ -453,7 +453,7 @@
var deflate = _negotiateCompression(request, response, compression);
response.headers.contentLength = 0;
- return response.detachSocket().then/*<WebSocket>*/((socket) =>
+ return response.detachSocket().then<WebSocket>((socket) =>
new _WebSocketImpl._fromSocket(
socket, protocol, compression, true, deflate));
}
@@ -465,7 +465,7 @@
// the lists with ', ' and then tokenize.
protocols = _HttpParser._tokenizeFieldValue(protocols.join(', '));
return new Future<String>(() => _protocolSelector(protocols))
- .then/*<String>*/((protocol) {
+ .then<String>((protocol) {
if (protocols.indexOf(protocol) < 0) {
throw new WebSocketException(
"Selected protocol is not in the list of available protocols");
@@ -476,7 +476,7 @@
..statusCode = HttpStatus.INTERNAL_SERVER_ERROR
..close();
throw error;
- }).then/*<WebSocket>*/(upgrade);
+ }).then<WebSocket>(upgrade);
} else {
return upgrade(null);
}
@@ -1051,7 +1051,7 @@
_WebSocketPerMessageDeflate deflate =
negotiateClientCompression(response, compression);
- return response.detachSocket().then/*<WebSocket>*/((socket) =>
+ return response.detachSocket().then<WebSocket>((socket) =>
new _WebSocketImpl._fromSocket(
socket, protocol, compression, false, deflate));
});
diff --git a/sdk/lib/math/math.dart b/sdk/lib/math/math.dart
index 73768c9..46fe338 100644
--- a/sdk/lib/math/math.dart
+++ b/sdk/lib/math/math.dart
@@ -67,7 +67,7 @@
* same mathematical value) then it is unspecified which of the two arguments
* is returned.
*/
-num/*=T*/ min/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) {
+T min<T extends num>(T a, T b) {
// These partially redundant type checks improve code quality for dart2js.
// Most of the improvement is at call sites from the inferred non-null num
// return type.
@@ -102,7 +102,7 @@
* otherwise equal (including int and doubles with the same mathematical value)
* then it is unspecified which of the two arguments is returned.
*/
-num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) {
+T max<T extends num>(T a, T b) {
// These partially redundant type checks improve code quality for dart2js.
// Most of the improvement is at call sites from the inferred non-null num
// return type.
diff --git a/sdk/lib/math/rectangle.dart b/sdk/lib/math/rectangle.dart
index 6fe2075..2145cc7 100644
--- a/sdk/lib/math/rectangle.dart
+++ b/sdk/lib/math/rectangle.dart
@@ -209,8 +209,8 @@
* point `(left, top)`.
*/
MutableRectangle(this.left, this.top, T width, T height)
- : this._width = (width < 0) ? _clampToZero/*<T>*/(width) : width,
- this._height = (height < 0) ? _clampToZero/*<T>*/(height) : height;
+ : this._width = (width < 0) ? _clampToZero<T>(width) : width,
+ this._height = (height < 0) ? _clampToZero<T>(height) : height;
/**
* Create a mutable rectangle spanned by the points [a] and [b];
@@ -244,7 +244,7 @@
* but will not change [left].
*/
void set width(T width) {
- if (width < 0) width = _clampToZero/*<T>*/(width);
+ if (width < 0) width = _clampToZero<T>(width);
_width = width;
}
@@ -260,7 +260,7 @@
* but will not change [top].
*/
void set height(T height) {
- if (height < 0) height = _clampToZero/*<T>*/(height);
+ if (height < 0) height = _clampToZero<T>(height);
_height = height;
}
}
@@ -270,7 +270,7 @@
*
* Returns `0` if value is int, `0.0` if value is double.
*/
-num/*=T*/ _clampToZero/*<T extends num>*/(num/*=T*/ value) {
+T _clampToZero<T extends num>(T value) {
assert(value < 0);
return -value * 0;
}
diff --git a/tests/benchmark_smoke/benchmark_smoke.status b/tests/benchmark_smoke/benchmark_smoke.status
index de17765..69c792c 100644
--- a/tests/benchmark_smoke/benchmark_smoke.status
+++ b/tests/benchmark_smoke/benchmark_smoke.status
@@ -10,3 +10,7 @@
[ $compiler == dart2js && $cps_ir && $checked ]
*: Skip # Issue 25761
+
+[ $compiler == dart2analyzer ]
+# Issue #28236
+benchmark_smoke_test: StaticWarning
diff --git a/tests/co19/co19-dartium.status b/tests/co19/co19-dartium.status
index cfcf34d..b95e05b 100644
--- a/tests/co19/co19-dartium.status
+++ b/tests/co19/co19-dartium.status
@@ -2,6 +2,147 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
+###########################################################################
+# Tests that use the name#field tear offs syntax which has been deprecated.
+###########################################################################
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t12: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_list_assignment_t01: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t02: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t04: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t17: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_closurization_positional_params_t01: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t04: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t08: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t07: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t03: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_identical_t01: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_identical_t03: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t07: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t01: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t08: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t06: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t06: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t05: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_identical_t02: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t08: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t13: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t03: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t04: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t10: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t01: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_list_access_t01: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_closurization_named_params_t01: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t05: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t07: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t16: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_unary_bitwise_t01: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t14: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t11: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t02: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t05: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t06: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t01: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_closurization_positional_params_t02: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_closurization_named_params_t02: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t03: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t15: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t09: RuntimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t02: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/identical_t01: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/malformed_type_t01: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/positional_parameters_t01: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/identical_t03: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/identical_t02: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/named_parameters_t01: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/no_such_method_t02: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/no_such_method_t01: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/malbounded_type_t02: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/not_class_t01: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/malformed_type_t02: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/static_type_t02: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/closurization_t02: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/static_type_t01: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/malbounded_type_t01: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/static_type_t04: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/not_class_t02: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/deferred_type_t01: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/static_type_t03: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Closurization/identical_t01: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Closurization/identical_t02: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/not_class_t03: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/malbounded_type_t02: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/closurization_t01: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/malformed_type_t01: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Closurization/positional_parameters_t01: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/no_such_method_t02: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/malbounded_type_t01: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/not_class_t01: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/closurization_t02: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/static_type_t01: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/not_class_t02: RuntimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Closurization/named_parameters_t01: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/static_type_t03: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/malformed_type_t02: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/deferred_type_t01: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/closurization_t03: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/closurization_t01: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/not_class_t03: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/static_type_t02: RuntimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/no_such_method_t01: RuntimeError
+Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/expression_evaluation_t07: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t05: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t01: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t09: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t07: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t06: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/expression_evaluation_t03: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t08: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t04: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t09: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t06: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t04: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/expression_evaluation_t02: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t01: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t03: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t07: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t02: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t02: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t08: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t05: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t07: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t04: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t05: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t05: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t07: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t06: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t03: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t06: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t03: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t07: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t02: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t04: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t05: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t08: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t01: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t04: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t02: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t06: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t02: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t01: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t01: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/expression_evaluation_t01: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t03: RuntimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t03: RuntimeError
+Language/Classes/Setters/name_t12: RuntimeError
+Language/Classes/Setters/name_t08: RuntimeError
+Language/Classes/Setters/name_t14: RuntimeError
+Language/Classes/Setters/name_t13: RuntimeError
+Language/Classes/Setters/name_t11: RuntimeError
+Language/Classes/Setters/name_t09: RuntimeError
+Language/Classes/Setters/name_t15: RuntimeError
+Language/Classes/Setters/name_t10: RuntimeError
+###########################################################################
+
[ $compiler == none && $runtime == drt ]
*: Skip # running co19 tests on content_shell would make our dartium cycle-times very long
diff --git a/tests/co19/co19-kernel.status b/tests/co19/co19-kernel.status
index f931e86..bf9af78 100644
--- a/tests/co19/co19-kernel.status
+++ b/tests/co19/co19-kernel.status
@@ -346,4 +346,4 @@
# dartk: precompilation failures (debug)
[ $compiler == dartkp && $runtime == dart_precompiled && $mode == debug ]
-Language/Libraries_and_Scripts/Scripts/top_level_main_t05: Crash # !main_obj.IsNull()
+Language/Libraries_and_Scripts/Scripts/top_level_main_t05: Crash # !main_obj.IsNull()
\ No newline at end of file
diff --git a/tests/co19/co19-runtime.status b/tests/co19/co19-runtime.status
index 62b9ec17..9c4faf6 100644
--- a/tests/co19/co19-runtime.status
+++ b/tests/co19/co19-runtime.status
@@ -2,6 +2,146 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
+###########################################################################
+# Tests that use the name#field tear offs syntax which has been deprecated.
+###########################################################################
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t12: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_list_assignment_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t04: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t17: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_closurization_positional_params_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t04: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t08: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t07: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t03: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_identical_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_identical_t03: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t07: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t08: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t06: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t06: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t05: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_identical_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t08: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t13: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t03: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t04: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t10: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_list_access_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_closurization_named_params_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/getter_closurization_t05: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t07: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t16: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_unary_bitwise_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t14: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t11: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t05: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t06: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_closurization_positional_params_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/method_closurization_named_params_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t03: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t15: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/operator_closurization_t09: CompileTimeError
+Language/Expressions/Property_Extraction/Ordinary_Member_Closurization/setter_closurization_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/identical_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/malformed_type_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/positional_parameters_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/identical_t03: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/identical_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Closurization/named_parameters_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/no_such_method_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/no_such_method_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/malbounded_type_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/not_class_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/malformed_type_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/static_type_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/closurization_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/static_type_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/malbounded_type_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/static_type_t04: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/not_class_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/deferred_type_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/static_type_t03: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Closurization/identical_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Closurization/identical_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/not_class_t03: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/malbounded_type_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Extraction/closurization_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/malformed_type_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Closurization/positional_parameters_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/no_such_method_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/malbounded_type_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/not_class_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/closurization_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/static_type_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/not_class_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Named_Constructor_Closurization/named_parameters_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/static_type_t03: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/malformed_type_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/deferred_type_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/closurization_t03: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/closurization_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/not_class_t03: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/static_type_t02: CompileTimeError
+Language/Expressions/Property_Extraction/Anonymous_Constructor_Extraction/no_such_method_t01: CompileTimeError
+Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/expression_evaluation_t07: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t05: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t01: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t09: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t07: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t06: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/expression_evaluation_t03: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t08: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t04: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t09: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t06: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t04: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/expression_evaluation_t02: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t01: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t03: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t07: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t02: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t02: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t08: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t05: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t07: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t04: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t05: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t05: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t07: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t06: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t03: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t06: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t03: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t07: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t02: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t04: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t05: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/no_accessible_member_t08: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t01: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t04: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/static_type_t02: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t06: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t02: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/getter_lookup_t01: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t01: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/expression_evaluation_t01: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/method_lookup_t03: CompileTimeError
+Language/Expressions/Property_Extraction/General_Closurization/setter_lookup_t03: CompileTimeError
+Language/Classes/Setters/name_t12: CompileTimeError
+Language/Classes/Setters/name_t08: CompileTimeError
+Language/Classes/Setters/name_t14: CompileTimeError
+Language/Classes/Setters/name_t13: CompileTimeError
+Language/Classes/Setters/name_t11: CompileTimeError
+Language/Classes/Setters/name_t09: CompileTimeError
+Language/Classes/Setters/name_t15: CompileTimeError
+Language/Classes/Setters/name_t10: CompileTimeError
+###########################################################################
[ $runtime == vm || $runtime == dart_precompiled ]
@@ -48,6 +188,7 @@
[ ($runtime == vm || $runtime == dart_precompiled ) && $mode == debug ]
LibTest/core/List/List_class_A01_t02: Pass, Slow
+LibTest/isolate/Isolate/spawn_A04_t01: Pass, Fail # Issue 28269
[ ($runtime == dart_precompiled || $runtime == dart_app) && $mode == debug ]
Language/Libraries_and_Scripts/Imports/deferred_import_t02: Crash # Issue 27201
@@ -93,12 +234,6 @@
Language/Classes/Setters/type_object_t02: RuntimeError # Issue 23721
Language/Classes/Static_Methods/type_object_t01: RuntimeError # Issue 23721
Language/Classes/Static_Methods/type_object_t02: RuntimeError # Issue 23721
-Language/Expressions/Property_Extraction/General_Closurization/class_object_member_t01: MissingCompileTimeError # Issue 24472
-Language/Expressions/Property_Extraction/General_Closurization/class_object_member_t02: MissingCompileTimeError # Issue 24472
-Language/Expressions/Property_Extraction/General_Closurization/class_object_member_t03: MissingCompileTimeError # Issue 24472
-Language/Expressions/Property_Extraction/General_Closurization/class_object_member_t04: MissingCompileTimeError # Issue 24472
-Language/Expressions/Property_Extraction/General_Closurization/class_object_member_t05: MissingCompileTimeError # Issue 24472
-Language/Expressions/Property_Extraction/General_Closurization/class_object_member_t06: MissingCompileTimeError # Issue 24472
Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t01: MissingCompileTimeError # Issue 24472
Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t02: MissingCompileTimeError # Issue 24472
Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t03: MissingCompileTimeError # Issue 24472
diff --git a/tests/compiler/dart2js/analyze_dart2js_helpers_test.dart b/tests/compiler/dart2js/analyze_dart2js_helpers_test.dart
index c5cd57e..fe8672b 100644
--- a/tests/compiler/dart2js/analyze_dart2js_helpers_test.dart
+++ b/tests/compiler/dart2js/analyze_dart2js_helpers_test.dart
@@ -12,7 +12,8 @@
import 'package:compiler/src/commandline_options.dart';
import 'package:compiler/src/constants/expressions.dart'
show ConstructedConstantExpression;
-import 'package:compiler/src/dart_types.dart' show InterfaceType;
+import 'package:compiler/src/elements/resolution_types.dart'
+ show ResolutionInterfaceType;
import 'package:compiler/src/diagnostics/source_span.dart' show SourceSpan;
import 'package:compiler/src/elements/elements.dart';
import 'package:compiler/src/filenames.dart' show nativeToUriPath;
@@ -161,7 +162,7 @@
void visitGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
@@ -173,7 +174,7 @@
void visitRedirectingGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
@@ -185,7 +186,7 @@
void visitFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
_) {
@@ -197,9 +198,9 @@
void visitRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
ConstructorElement effectiveTarget,
- InterfaceType effectiveTargetType,
+ ResolutionInterfaceType effectiveTargetType,
NodeList arguments,
CallStructure callStructure,
_) {
diff --git a/tests/compiler/dart2js/flatten_test.dart b/tests/compiler/dart2js/flatten_test.dart
index 4b60d02..c624e48 100644
--- a/tests/compiler/dart2js/flatten_test.dart
+++ b/tests/compiler/dart2js/flatten_test.dart
@@ -7,7 +7,7 @@
import 'package:expect/expect.dart';
import "package:async_helper/async_helper.dart";
import 'type_test_helper.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import "package:compiler/src/elements/elements.dart" show Element, ClassElement;
void main() {
@@ -16,8 +16,9 @@
abstract class G<T> implements Future<G<T>> {}
abstract class H<T> implements Future<H<H<T>>> {}
""").then((env) {
- void check(DartType T, DartType expectedFlattenedType) {
- DartType flattenedType = env.flatten(T);
+ void check(
+ ResolutionDartType T, ResolutionDartType expectedFlattenedType) {
+ ResolutionDartType flattenedType = env.flatten(T);
Expect.equals(
expectedFlattenedType,
flattenedType,
@@ -29,13 +30,13 @@
ClassElement F = env.getElement('F');
ClassElement G = env.getElement('G');
ClassElement H = env.getElement('H');
- DartType int_ = env['int'];
- DartType dynamic_ = env['dynamic'];
- DartType Future_int = instantiate(Future_, [int_]);
- DartType F_int = instantiate(F, [int_]);
- DartType G_int = instantiate(G, [int_]);
- DartType H_int = instantiate(H, [int_]);
- DartType H_H_int = instantiate(H, [H_int]);
+ ResolutionDartType int_ = env['int'];
+ ResolutionDartType dynamic_ = env['dynamic'];
+ ResolutionDartType Future_int = instantiate(Future_, [int_]);
+ ResolutionDartType F_int = instantiate(F, [int_]);
+ ResolutionDartType G_int = instantiate(G, [int_]);
+ ResolutionDartType H_int = instantiate(H, [int_]);
+ ResolutionDartType H_H_int = instantiate(H, [H_int]);
// flatten(int) = int
check(int_, int_);
diff --git a/tests/compiler/dart2js/jsinterop/world_test.dart b/tests/compiler/dart2js/jsinterop/world_test.dart
index 1ddbd39..bed24f3 100644
--- a/tests/compiler/dart2js/jsinterop/world_test.dart
+++ b/tests/compiler/dart2js/jsinterop/world_test.dart
@@ -7,8 +7,10 @@
import 'package:expect/expect.dart';
import 'package:async_helper/async_helper.dart';
import 'package:compiler/src/common.dart';
-import 'package:compiler/src/elements/elements.dart' show Element, ClassElement;
+import 'package:compiler/src/elements/elements.dart'
+ show ClassElement, PublicName;
import 'package:compiler/src/js_backend/js_backend.dart';
+import 'package:compiler/src/universe/selector.dart';
import 'package:compiler/src/world.dart';
import '../type_test_helper.dart';
@@ -102,6 +104,8 @@
ClassElement E = registerClass(env.getElement('E'));
ClassElement F = registerClass(env.getElement('F'));
+ Selector nonExisting = new Selector.getter(const PublicName('nonExisting'));
+
Expect.equals(Interceptor.superclass, Object_);
Expect.equals(JavaScriptObject.superclass, Interceptor);
@@ -128,6 +132,15 @@
world.isAbstractlyInstantiated(cls),
"Expected $name to be abstractly instantiated in `${mainSource}`:"
"\n${world.dump(cls)}");
+ Expect.isTrue(
+ world.needsNoSuchMethod(cls, nonExisting, ClassQuery.EXACT),
+ "Expected $name to need noSuchMethod for $nonExisting.");
+ Expect.isTrue(
+ world.needsNoSuchMethod(cls, nonExisting, ClassQuery.SUBCLASS),
+ "Expected $name to need noSuchMethod for $nonExisting.");
+ Expect.isTrue(
+ world.needsNoSuchMethod(cls, nonExisting, ClassQuery.SUBTYPE),
+ "Expected $name to need noSuchMethod for $nonExisting.");
}
if (indirectlyInstantiated.contains(name)) {
isInstantiated = true;
diff --git a/tests/compiler/dart2js/kernel/class_hierarchy_test.dart b/tests/compiler/dart2js/kernel/class_hierarchy_test.dart
index 9b6aa08..bb90c67 100644
--- a/tests/compiler/dart2js/kernel/class_hierarchy_test.dart
+++ b/tests/compiler/dart2js/kernel/class_hierarchy_test.dart
@@ -31,12 +31,13 @@
'''
}, options: [
Flags.analyzeOnly,
- Flags.analyzeMain,
+ Flags.analyzeAll,
Flags.useKernel
]);
test('mixin', () async {
Uri mainUri = Uri.parse('memory:main.dart');
- LibraryElement library = await compiler.analyzeUri(mainUri);
+ await compiler.run(mainUri);
+ LibraryElement library = await compiler.libraryLoader.loadLibrary(mainUri);
JavaScriptBackend backend = compiler.backend;
ir.Program program = backend.kernelTask.buildProgram(library);
ClassHierarchy hierarchy = new ClassHierarchy(program);
diff --git a/tests/compiler/dart2js/kernel/closed_world_test.dart b/tests/compiler/dart2js/kernel/closed_world_test.dart
index c51d57c..8757183 100644
--- a/tests/compiler/dart2js/kernel/closed_world_test.dart
+++ b/tests/compiler/dart2js/kernel/closed_world_test.dart
@@ -11,7 +11,7 @@
import 'package:compiler/src/common.dart';
import 'package:compiler/src/common/resolution.dart';
import 'package:compiler/src/compiler.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/elements/elements.dart';
import 'package:compiler/src/enqueue.dart';
import 'package:compiler/src/js_backend/backend.dart';
@@ -117,7 +117,7 @@
ClosedWorld closedWorld = enqueuer.universe.closeWorld(compiler.reporter);
checkResolutionEnqueuers(compiler.enqueuer.resolution, enqueuer,
- typeEquivalence: (DartType a, DartType b) {
+ typeEquivalence: (ResolutionDartType a, ResolutionDartType b) {
return areTypesEquivalent(unalias(a), unalias(b));
}, elementFilter: (Element element) {
if (element is ConstructorElement && element.isRedirectingFactory) {
diff --git a/tests/compiler/dart2js/kernel/constructors_test.dart b/tests/compiler/dart2js/kernel/constructors_test.dart
index 1d30c1c..ba38190 100644
--- a/tests/compiler/dart2js/kernel/constructors_test.dart
+++ b/tests/compiler/dart2js/kernel/constructors_test.dart
@@ -33,6 +33,19 @@
}''';
return check(code, lookup: defaultConstructorFor('A'));
});
+
+ test('redirecting constructor with field', () {
+ String code = '''
+class Foo {
+ final int value;
+ const Foo({int number: 0}) : this.poodle(number * 2);
+ const Foo.poodle(this.value);
+}
+
+main() => new Foo(number: 3);
+''';
+ return check(code, lookup: defaultConstructorFor('Foo'));
+ });
}
defaultConstructorFor(String className) => (Compiler compiler) {
diff --git a/tests/compiler/dart2js/kernel/impact_test.dart b/tests/compiler/dart2js/kernel/impact_test.dart
index 90042ef..28487cd 100644
--- a/tests/compiler/dart2js/kernel/impact_test.dart
+++ b/tests/compiler/dart2js/kernel/impact_test.dart
@@ -11,7 +11,7 @@
import 'package:compiler/src/common/resolution.dart';
import 'package:compiler/src/compiler.dart';
import 'package:compiler/src/constants/expressions.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/elements/elements.dart';
import 'package:compiler/src/resolution/registry.dart';
import 'package:compiler/src/resolution/tree_elements.dart';
@@ -707,7 +707,7 @@
case StaticUseKind.CONST_CONSTRUCTOR_INVOKE:
ConstructorElement constructor = staticUse.element;
ConstructorElement effectiveTarget = constructor.effectiveTarget;
- DartType effectiveTargetType =
+ ResolutionDartType effectiveTargetType =
constructor.computeEffectiveTargetType(staticUse.type);
builder.registerStaticUse(
staticUse.kind == StaticUseKind.CONST_CONSTRUCTOR_INVOKE
@@ -791,31 +791,33 @@
}
/// Visitor the performers unaliasing of all typedefs nested within a
-/// [DartType].
-class Unaliaser extends BaseDartTypeVisitor<dynamic, DartType> {
+/// [ResolutionDartType].
+class Unaliaser extends BaseDartTypeVisitor<dynamic, ResolutionDartType> {
const Unaliaser();
@override
- DartType visit(DartType type, [_]) => type.accept(this, null);
+ ResolutionDartType visit(ResolutionDartType type, [_]) =>
+ type.accept(this, null);
@override
- DartType visitType(DartType type, _) => type;
+ ResolutionDartType visitType(ResolutionDartType type, _) => type;
- List<DartType> visitList(List<DartType> types) => types.map(visit).toList();
+ List<ResolutionDartType> visitList(List<ResolutionDartType> types) =>
+ types.map(visit).toList();
@override
- DartType visitInterfaceType(InterfaceType type, _) {
+ ResolutionDartType visitInterfaceType(ResolutionInterfaceType type, _) {
return type.createInstantiation(visitList(type.typeArguments));
}
@override
- DartType visitTypedefType(TypedefType type, _) {
+ ResolutionDartType visitTypedefType(ResolutionTypedefType type, _) {
return visit(type.unaliased);
}
@override
- DartType visitFunctionType(FunctionType type, _) {
- return new FunctionType.synthesized(
+ ResolutionDartType visitFunctionType(ResolutionFunctionType type, _) {
+ return new ResolutionFunctionType.synthesized(
visit(type.returnType),
visitList(type.parameterTypes),
visitList(type.optionalParameterTypes),
@@ -824,7 +826,7 @@
}
}
-/// Perform unaliasing of all typedefs nested within a [DartType].
-DartType unalias(DartType type) {
+/// Perform unaliasing of all typedefs nested within a [ResolutionDartType].
+ResolutionDartType unalias(ResolutionDartType type) {
return const Unaliaser().visit(type);
}
diff --git a/tests/compiler/dart2js/kernel/loops_test.dart b/tests/compiler/dart2js/kernel/loops_test.dart
index a619c36..78385c7 100644
--- a/tests/compiler/dart2js/kernel/loops_test.dart
+++ b/tests/compiler/dart2js/kernel/loops_test.dart
@@ -31,6 +31,18 @@
return check(code);
});
+ test('do-while loop', () {
+ String code = '''
+main() {
+ var a = 0;
+ do {
+ a *= 2;
+ } while (a < 100);
+ return a;
+}''';
+ return check(code);
+ });
+
test('for-in loop', () {
String code = '''
main() {
diff --git a/tests/compiler/dart2js/kernel/visitor_test.dart b/tests/compiler/dart2js/kernel/visitor_test.dart
index d632442..c66801f 100644
--- a/tests/compiler/dart2js/kernel/visitor_test.dart
+++ b/tests/compiler/dart2js/kernel/visitor_test.dart
@@ -6,6 +6,7 @@
/// defined by kernel spec-mode test files.
import 'dart:io';
+import 'dart:async';
import 'package:compiler/src/compiler.dart' show Compiler;
import 'package:compiler/src/elements/elements.dart';
import 'package:compiler/src/js_backend/backend.dart' show JavaScriptBackend;
@@ -26,9 +27,7 @@
'external',
];
-main(List<String> arguments) {
- Compiler compiler = compilerFor(
- options: [Flags.analyzeOnly, Flags.analyzeMain, Flags.useKernel]);
+main(List<String> arguments) async {
Directory directory = new Directory('${TESTCASE_DIR}/input');
for (FileSystemEntity file in directory.listSync()) {
if (file is File && file.path.endsWith('.dart')) {
@@ -40,7 +39,10 @@
}
test(name, () async {
- LibraryElement library = await compiler.analyzeUri(file.absolute.uri);
+ var compiler = await newCompiler();
+ await compiler.run(file.absolute.uri);
+ LibraryElement library =
+ await compiler.libraryLoader.loadLibrary(file.absolute.uri);
JavaScriptBackend backend = compiler.backend;
StringBuffer buffer = new StringBuffer();
Program program = backend.kernelTask.buildProgram(library);
@@ -68,3 +70,17 @@
}
}
}
+
+Future<Compiler> newCompiler() async {
+ var compiler = compilerFor(
+ options: [Flags.analyzeOnly, Flags.analyzeAll, Flags.useKernel]);
+ await compiler.setupSdk();
+
+ // The visitor no longer enqueues elements that are not reachable from the
+ // program. The mixin-full resolution transform run by the test expects to
+ // find dart.core::Iterator.
+ var core = await compiler.libraryLoader.loadLibrary(Uri.parse('dart:core'));
+ var cls = core.implementation.localLookup('Iterator');
+ cls.ensureResolved(compiler.resolution);
+ return compiler;
+}
diff --git a/tests/compiler/dart2js/least_upper_bound_test.dart b/tests/compiler/dart2js/least_upper_bound_test.dart
index c184635..dab1188 100644
--- a/tests/compiler/dart2js/least_upper_bound_test.dart
+++ b/tests/compiler/dart2js/least_upper_bound_test.dart
@@ -6,7 +6,7 @@
import 'package:expect/expect.dart';
import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/elements/elements.dart' show Element, ClassElement;
import 'type_test_helper.dart';
@@ -27,14 +27,15 @@
class I implements A, B {}
class J implements A, B {}
""").then((env) {
- DartType Object_ = env['Object'];
- DartType A = env['A'];
- DartType B = env['B'];
- DartType I = env['I'];
- DartType J = env['J'];
+ ResolutionDartType Object_ = env['Object'];
+ ResolutionDartType A = env['A'];
+ ResolutionDartType B = env['B'];
+ ResolutionDartType I = env['I'];
+ ResolutionDartType J = env['J'];
- checkLub(DartType a, DartType b, DartType expect) {
- DartType lub = env.computeLeastUpperBound(a, b);
+ checkLub(ResolutionDartType a, ResolutionDartType b,
+ ResolutionDartType expect) {
+ ResolutionDartType lub = env.computeLeastUpperBound(a, b);
Expect.equals(
expect, lub, 'Unexpected lub($a,$b) = $lub, expected $expect.');
}
@@ -79,15 +80,16 @@
class I implements A, C {}
class J implements A, C {}
""").then((env) {
- DartType Object_ = env['Object'];
- DartType A = env['A'];
- DartType B = env['B'];
- DartType C = env['C'];
- DartType I = env['I'];
- DartType J = env['J'];
+ ResolutionDartType Object_ = env['Object'];
+ ResolutionDartType A = env['A'];
+ ResolutionDartType B = env['B'];
+ ResolutionDartType C = env['C'];
+ ResolutionDartType I = env['I'];
+ ResolutionDartType J = env['J'];
- checkLub(DartType a, DartType b, DartType expectedLub) {
- DartType lub = env.computeLeastUpperBound(a, b);
+ checkLub(ResolutionDartType a, ResolutionDartType b,
+ ResolutionDartType expectedLub) {
+ ResolutionDartType lub = env.computeLeastUpperBound(a, b);
Expect.equals(expectedLub, lub,
'Unexpected lub($a,$b) = $lub, expected $expectedLub');
}
@@ -143,17 +145,18 @@
class C extends B {}
class I<T> {}
""").then((env) {
- DartType Object_ = env['Object'];
- DartType A = env['A'];
- DartType B = env['B'];
- DartType C = env['C'];
+ ResolutionDartType Object_ = env['Object'];
+ ResolutionDartType A = env['A'];
+ ResolutionDartType B = env['B'];
+ ResolutionDartType C = env['C'];
ClassElement I = env.getElement('I');
- DartType I_A = instantiate(I, [A]);
- DartType I_B = instantiate(I, [B]);
- DartType I_C = instantiate(I, [C]);
+ ResolutionDartType I_A = instantiate(I, [A]);
+ ResolutionDartType I_B = instantiate(I, [B]);
+ ResolutionDartType I_C = instantiate(I, [C]);
- checkLub(DartType a, DartType b, DartType expectedLub) {
- DartType lub = env.computeLeastUpperBound(a, b);
+ checkLub(ResolutionDartType a, ResolutionDartType b,
+ ResolutionDartType expectedLub) {
+ ResolutionDartType lub = env.computeLeastUpperBound(a, b);
Expect.equals(expectedLub, lub,
'Unexpected lub($a,$b) = $lub, expected $expectedLub');
}
@@ -226,17 +229,18 @@
class I2 extends Object with A, B implements A, D {}
class J extends Object with B, A implements A, D {}
""").then((env) {
- DartType Object_ = env['Object'];
- DartType A = env['A'];
- DartType B = env['B'];
- DartType C = env['C'];
- DartType D = env['D'];
- DartType I = env['I'];
- DartType I2 = env['I2'];
- DartType J = env['J'];
+ ResolutionDartType Object_ = env['Object'];
+ ResolutionDartType A = env['A'];
+ ResolutionDartType B = env['B'];
+ ResolutionDartType C = env['C'];
+ ResolutionDartType D = env['D'];
+ ResolutionDartType I = env['I'];
+ ResolutionDartType I2 = env['I2'];
+ ResolutionDartType J = env['J'];
- checkLub(DartType a, DartType b, DartType expectedLub) {
- DartType lub = env.computeLeastUpperBound(a, b);
+ checkLub(ResolutionDartType a, ResolutionDartType b,
+ ResolutionDartType expectedLub) {
+ ResolutionDartType lub = env.computeLeastUpperBound(a, b);
Expect.equals(expectedLub, lub,
'Unexpected lub($a,$b) = $lub, expected $expectedLub');
}
@@ -340,37 +344,41 @@
typedef void void____B_C({B a, C b});
typedef void void____C_C({C a, C b});
""").then((env) {
- DartType Object_ = env['Object'];
- DartType Function_ = env['Function'];
- DartType dynamic__ = env['dynamic__'];
- DartType void__ = env['void__'];
- DartType A__ = env['A__'];
- DartType B__ = env['B__'];
- DartType C__ = env['C__'];
- DartType void__A_B = env['void__A_B'];
- DartType void__A_C = env['void__A_C'];
- DartType void__B_A = env['void__B_A'];
- DartType void__B_C = env['void__B_C'];
- DartType void___B = env['void___B'];
- DartType void___B_C = env['void___B_C'];
- DartType void___C_C = env['void___C_C'];
- DartType void____B = env['void____B'];
- DartType void____B_C = env['void____B_C'];
- DartType void____C_C = env['void____C_C'];
+ ResolutionDartType Object_ = env['Object'];
+ ResolutionDartType Function_ = env['Function'];
+ ResolutionDartType dynamic__ = env['dynamic__'];
+ ResolutionDartType void__ = env['void__'];
+ ResolutionDartType A__ = env['A__'];
+ ResolutionDartType B__ = env['B__'];
+ ResolutionDartType C__ = env['C__'];
+ ResolutionDartType void__A_B = env['void__A_B'];
+ ResolutionDartType void__A_C = env['void__A_C'];
+ ResolutionDartType void__B_A = env['void__B_A'];
+ ResolutionDartType void__B_C = env['void__B_C'];
+ ResolutionDartType void___B = env['void___B'];
+ ResolutionDartType void___B_C = env['void___B_C'];
+ ResolutionDartType void___C_C = env['void___C_C'];
+ ResolutionDartType void____B = env['void____B'];
+ ResolutionDartType void____B_C = env['void____B_C'];
+ ResolutionDartType void____C_C = env['void____C_C'];
// Types used only for checking results.
- DartType void_ = env['void'];
- DartType B = env['B'];
- DartType C = env['C'];
- FunctionType Object__ = env.functionType(Object_, []);
- FunctionType void__Object_Object =
+ ResolutionDartType void_ = env['void'];
+ ResolutionDartType B = env['B'];
+ ResolutionDartType C = env['C'];
+ ResolutionFunctionType Object__ = env.functionType(Object_, []);
+ ResolutionFunctionType void__Object_Object =
env.functionType(void_, [Object_, Object_]);
- FunctionType void__Object_B = env.functionType(void_, [Object_, B]);
- FunctionType void__Object_C = env.functionType(void_, [Object_, C]);
- FunctionType void__B_Object = env.functionType(void_, [B, Object_]);
+ ResolutionFunctionType void__Object_B =
+ env.functionType(void_, [Object_, B]);
+ ResolutionFunctionType void__Object_C =
+ env.functionType(void_, [Object_, C]);
+ ResolutionFunctionType void__B_Object =
+ env.functionType(void_, [B, Object_]);
- checkLub(DartType a, DartType b, DartType expectedLub) {
- DartType lub = env.computeLeastUpperBound(a, b);
+ checkLub(ResolutionDartType a, ResolutionDartType b,
+ ResolutionDartType expectedLub) {
+ ResolutionDartType lub = env.computeLeastUpperBound(a, b);
if (a != b) {
expectedLub = expectedLub.unaliased;
lub = lub.unaliased;
@@ -711,20 +719,21 @@
// /
// W
- DartType Object_ = env['Object'];
- DartType A = env['A'];
- DartType B = env['B'];
- DartType C = env['C'];
+ ResolutionDartType Object_ = env['Object'];
+ ResolutionDartType A = env['A'];
+ ResolutionDartType B = env['B'];
+ ResolutionDartType C = env['C'];
ClassElement I = env.getElement('I');
- DartType S = I.typeVariables[0];
- DartType T = I.typeVariables[1];
- DartType U = I.typeVariables[2];
- DartType V = I.typeVariables[3];
- DartType W = I.typeVariables[4];
- DartType X = I.typeVariables[5];
+ ResolutionDartType S = I.typeVariables[0];
+ ResolutionDartType T = I.typeVariables[1];
+ ResolutionDartType U = I.typeVariables[2];
+ ResolutionDartType V = I.typeVariables[3];
+ ResolutionDartType W = I.typeVariables[4];
+ ResolutionDartType X = I.typeVariables[5];
- checkLub(DartType a, DartType b, DartType expectedLub) {
- DartType lub = env.computeLeastUpperBound(a, b);
+ checkLub(ResolutionDartType a, ResolutionDartType b,
+ ResolutionDartType expectedLub) {
+ ResolutionDartType lub = env.computeLeastUpperBound(a, b);
Expect.equals(expectedLub, lub,
'Unexpected lub($a,$b) = $lub, expected $expectedLub');
}
diff --git a/tests/compiler/dart2js/lookup_member_test.dart b/tests/compiler/dart2js/lookup_member_test.dart
index 27f49c7..386f58b 100644
--- a/tests/compiler/dart2js/lookup_member_test.dart
+++ b/tests/compiler/dart2js/lookup_member_test.dart
@@ -7,7 +7,7 @@
import 'package:expect/expect.dart';
import "package:async_helper/async_helper.dart";
import 'type_test_helper.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import "package:compiler/src/elements/elements.dart"
show Element, ClassElement, MemberSignature, PublicName;
@@ -30,46 +30,46 @@
V boz;
}
""").then((env) {
- void expect(InterfaceType receiverType, String memberName,
- DartType expectedType) {
+ void expect(ResolutionInterfaceType receiverType, String memberName,
+ ResolutionDartType expectedType) {
MemberSignature member =
receiverType.lookupInterfaceMember(new PublicName(memberName));
Expect.isNotNull(member);
- DartType memberType = member.type;
+ ResolutionDartType memberType = member.type;
Expect.equals(expectedType, memberType,
'Wrong member type for $receiverType.$memberName.');
}
- DartType int_ = env['int'];
- DartType String_ = env['String'];
+ ResolutionDartType int_ = env['int'];
+ ResolutionDartType String_ = env['String'];
ClassElement A = env.getElement('A');
- DartType T = A.typeVariables.first;
- DartType A_T = A.thisType;
+ ResolutionDartType T = A.typeVariables.first;
+ ResolutionDartType A_T = A.thisType;
expect(A_T, 'foo', T);
- DartType A_int = instantiate(A, [int_]);
+ ResolutionDartType A_int = instantiate(A, [int_]);
expect(A_int, 'foo', int_);
ClassElement B = env.getElement('B');
- DartType S = B.typeVariables.first;
- DartType B_S = B.thisType;
+ ResolutionDartType S = B.typeVariables.first;
+ ResolutionDartType B_S = B.thisType;
expect(B_S, 'foo', instantiate(A, [S]));
expect(B_S, 'bar', S);
- DartType B_int = instantiate(B, [int_]);
+ ResolutionDartType B_int = instantiate(B, [int_]);
expect(B_int, 'foo', A_int);
expect(B_int, 'bar', int_);
ClassElement C = env.getElement('C');
- DartType U = C.typeVariables.first;
- DartType C_U = C.thisType;
+ ResolutionDartType U = C.typeVariables.first;
+ ResolutionDartType C_U = C.thisType;
expect(C_U, 'foo', instantiate(A, [String_]));
expect(C_U, 'bar', String_);
expect(C_U, 'baz', U);
expect(C_U, 'boz', instantiate(B, [U]));
- DartType C_int = instantiate(C, [int_]);
+ ResolutionDartType C_int = instantiate(C, [int_]);
expect(C_int, 'foo', instantiate(A, [String_]));
expect(C_int, 'bar', String_);
expect(C_int, 'baz', int_);
diff --git a/tests/compiler/dart2js/members_test.dart b/tests/compiler/dart2js/members_test.dart
index c058761..5b6c69d 100644
--- a/tests/compiler/dart2js/members_test.dart
+++ b/tests/compiler/dart2js/members_test.dart
@@ -7,7 +7,7 @@
import 'package:expect/expect.dart';
import "package:async_helper/async_helper.dart";
import 'type_test_helper.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import "package:compiler/src/elements/elements.dart"
show Element, ClassElement, MemberSignature, Name, PublicName, Member;
import "package:compiler/src/resolution/class_members.dart"
@@ -21,7 +21,7 @@
testMixinMembersWithoutImplements();
}
-MemberSignature getMember(InterfaceType cls, String name,
+MemberSignature getMember(ResolutionInterfaceType cls, String name,
{bool isSetter: false, int checkType: CHECK_INTERFACE}) {
Name memberName = new Name(name, cls.element.library, isSetter: isSetter);
MemberSignature member = checkType == CHECK_CLASS
@@ -66,16 +66,16 @@
* If [isClassMember] is `true` it is checked that the member is also a class
* member.
*/
-MemberSignature checkMember(InterfaceType cls, String name,
+MemberSignature checkMember(ResolutionInterfaceType cls, String name,
{bool isStatic: false,
bool isSetter: false,
bool isGetter: false,
- InterfaceType declarer,
- DartType type,
- FunctionType functionType,
- InterfaceType inheritedFrom,
- List<InterfaceType> synthesizedFrom,
- List<InterfaceType> erroneousFrom,
+ ResolutionInterfaceType declarer,
+ ResolutionDartType type,
+ ResolutionFunctionType functionType,
+ ResolutionInterfaceType inheritedFrom,
+ List<ResolutionInterfaceType> synthesizedFrom,
+ List<ResolutionInterfaceType> erroneousFrom,
int checkType: ALSO_CLASS_MEMBER}) {
String memberKind = checkType == CHECK_CLASS ? 'class' : 'interface';
MemberSignature member =
@@ -113,7 +113,7 @@
}
Set<MemberSignature> members = new Set<MemberSignature>();
List from = synthesizedFrom != null ? synthesizedFrom : erroneousFrom;
- for (InterfaceType type in from) {
+ for (ResolutionInterfaceType type in from) {
DeclaredMember inheritedMember =
type.element.lookupInterfaceMember(memberName);
Expect.isNotNull(inheritedMember);
@@ -150,7 +150,7 @@
return member;
}
-void checkMemberCount(InterfaceType cls, int expectedCount,
+void checkMemberCount(ResolutionInterfaceType cls, int expectedCount,
{bool interfaceMembers: true}) {
int count = 0;
if (interfaceMembers) {
@@ -191,16 +191,16 @@
""",
useMockCompiler: false)
.then((env) {
- InterfaceType bool_ = env['bool'];
- InterfaceType String_ = env['String'];
- InterfaceType num_ = env['num'];
- InterfaceType int_ = env['int'];
- DynamicType dynamic_ = env['dynamic'];
- VoidType void_ = env['void'];
- InterfaceType Type_ = env['Type'];
- InterfaceType Invocation_ = env['Invocation'];
+ ResolutionInterfaceType bool_ = env['bool'];
+ ResolutionInterfaceType String_ = env['String'];
+ ResolutionInterfaceType num_ = env['num'];
+ ResolutionInterfaceType int_ = env['int'];
+ ResolutionDynamicType dynamic_ = env['dynamic'];
+ ResolutionVoidType void_ = env['void'];
+ ResolutionInterfaceType Type_ = env['Type'];
+ ResolutionInterfaceType Invocation_ = env['Invocation'];
- InterfaceType Object_ = env['Object'];
+ ResolutionInterfaceType Object_ = env['Object'];
checkMemberCount(Object_, 5 /*declared*/, interfaceMembers: true);
checkMemberCount(Object_, 5 /*declared*/, interfaceMembers: false);
@@ -219,7 +219,7 @@
checkMember(Object_, 'toString',
functionType: env.functionType(String_, []));
- InterfaceType A = env['A'];
+ ResolutionInterfaceType A = env['A'];
MembersCreator.computeAllClassMembers(env.resolution, A.element);
checkMemberCount(A, 5 /*inherited*/ + 9 /*non-static declared*/,
@@ -289,8 +289,8 @@
ClassElement B = env.getElement('B');
MembersCreator.computeAllClassMembers(env.resolution, B);
- InterfaceType B_this = B.thisType;
- TypeVariableType B_T = B_this.typeArguments.first;
+ ResolutionInterfaceType B_this = B.thisType;
+ ResolutionTypeVariableType B_T = B_this.typeArguments.first;
checkMemberCount(B_this, 4 /*inherited*/ + 4 /*non-static declared*/,
interfaceMembers: true);
checkMemberCount(B_this, 4 /*inherited*/ + 5 /*declared*/,
@@ -319,11 +319,11 @@
ClassElement C = env.getElement('C');
MembersCreator.computeAllClassMembers(env.resolution, C);
- InterfaceType C_this = C.thisType;
- TypeVariableType C_S = C_this.typeArguments.first;
+ ResolutionInterfaceType C_this = C.thisType;
+ ResolutionTypeVariableType C_S = C_this.typeArguments.first;
checkMemberCount(C_this, 8 /*inherited*/, interfaceMembers: true);
checkMemberCount(C_this, 8 /*inherited*/, interfaceMembers: false);
- InterfaceType B_S = instantiate(B, [C_S]);
+ ResolutionInterfaceType B_S = instantiate(B, [C_S]);
checkMember(C_this, '==', inheritedFrom: Object_);
checkMember(C_this, 'hashCode', inheritedFrom: Object_);
@@ -347,11 +347,11 @@
functionType:
env.functionType(dynamic_, [], optionalParameters: [C_S]));
- InterfaceType D = env['D'];
+ ResolutionInterfaceType D = env['D'];
MembersCreator.computeAllClassMembers(env.resolution, D.element);
checkMemberCount(D, 8 /*inherited*/, interfaceMembers: true);
checkMemberCount(D, 8 /*inherited*/, interfaceMembers: false);
- InterfaceType B_int = instantiate(B, [int_]);
+ ResolutionInterfaceType B_int = instantiate(B, [int_]);
checkMember(D, '==', inheritedFrom: Object_);
checkMember(D, 'hashCode', inheritedFrom: Object_);
@@ -375,7 +375,7 @@
functionType:
env.functionType(dynamic_, [], optionalParameters: [int_]));
- InterfaceType E = env['E'];
+ ResolutionInterfaceType E = env['E'];
MembersCreator.computeAllClassMembers(env.resolution, E.element);
checkMemberCount(E, 8 /*inherited*/, interfaceMembers: true);
checkMemberCount(E, 8 /*inherited*/, interfaceMembers: false);
@@ -450,15 +450,15 @@
}
abstract class D implements A, B, C {}
""").then((env) {
- DynamicType dynamic_ = env['dynamic'];
- VoidType void_ = env['void'];
- InterfaceType num_ = env['num'];
- InterfaceType int_ = env['int'];
+ ResolutionDynamicType dynamic_ = env['dynamic'];
+ ResolutionVoidType void_ = env['void'];
+ ResolutionInterfaceType num_ = env['num'];
+ ResolutionInterfaceType int_ = env['int'];
- InterfaceType A = env['A'];
- InterfaceType B = env['B'];
- InterfaceType C = env['C'];
- InterfaceType D = env['D'];
+ ResolutionInterfaceType A = env['A'];
+ ResolutionInterfaceType B = env['B'];
+ ResolutionInterfaceType C = env['C'];
+ ResolutionInterfaceType D = env['D'];
// Ensure that members have been computed on all classes.
MembersCreator.computeAllClassMembers(env.resolution, D.element);
@@ -620,14 +620,14 @@
}
abstract class C extends A implements B {}
""").then((env) {
- DynamicType dynamic_ = env['dynamic'];
- VoidType void_ = env['void'];
- InterfaceType num_ = env['num'];
- InterfaceType int_ = env['int'];
+ ResolutionDynamicType dynamic_ = env['dynamic'];
+ ResolutionVoidType void_ = env['void'];
+ ResolutionInterfaceType num_ = env['num'];
+ ResolutionInterfaceType int_ = env['int'];
- InterfaceType A = env['A'];
- InterfaceType B = env['B'];
- InterfaceType C = env['C'];
+ ResolutionInterfaceType A = env['A'];
+ ResolutionInterfaceType B = env['B'];
+ ResolutionInterfaceType C = env['C'];
// Ensure that members have been computed on all classes.
MembersCreator.computeAllClassMembers(env.resolution, C.element);
@@ -674,19 +674,19 @@
}
abstract class C<U, V> extends Object with A<U> implements B<V> {}
""").then((env) {
- DynamicType dynamic_ = env['dynamic'];
- VoidType void_ = env['void'];
- InterfaceType num_ = env['num'];
- InterfaceType int_ = env['int'];
+ ResolutionDynamicType dynamic_ = env['dynamic'];
+ ResolutionVoidType void_ = env['void'];
+ ResolutionInterfaceType num_ = env['num'];
+ ResolutionInterfaceType int_ = env['int'];
ClassElement A = env.getElement('A');
ClassElement B = env.getElement('B');
ClassElement C = env.getElement('C');
- InterfaceType C_this = C.thisType;
- TypeVariableType C_U = C_this.typeArguments[0];
- TypeVariableType C_V = C_this.typeArguments[1];
- InterfaceType A_U = instantiate(A, [C_U]);
- InterfaceType B_V = instantiate(B, [C_V]);
+ ResolutionInterfaceType C_this = C.thisType;
+ ResolutionTypeVariableType C_U = C_this.typeArguments[0];
+ ResolutionTypeVariableType C_V = C_this.typeArguments[1];
+ ResolutionInterfaceType A_U = instantiate(A, [C_U]);
+ ResolutionInterfaceType B_V = instantiate(B, [C_V]);
// Ensure that members have been computed on all classes.
MembersCreator.computeAllClassMembers(env.resolution, C);
@@ -746,14 +746,14 @@
}
abstract class C extends Object with B {}
""").then((env) {
- DynamicType dynamic_ = env['dynamic'];
- VoidType void_ = env['void'];
- InterfaceType num_ = env['num'];
- InterfaceType int_ = env['int'];
+ ResolutionDynamicType dynamic_ = env['dynamic'];
+ ResolutionVoidType void_ = env['void'];
+ ResolutionInterfaceType num_ = env['num'];
+ ResolutionInterfaceType int_ = env['int'];
- InterfaceType A = env['A'];
- InterfaceType B = env['B'];
- InterfaceType C = env['C'];
+ ResolutionInterfaceType A = env['A'];
+ ResolutionInterfaceType B = env['B'];
+ ResolutionInterfaceType C = env['C'];
// Ensure that members have been computed on all classes.
MembersCreator.computeAllClassMembers(env.resolution, C.element);
diff --git a/tests/compiler/dart2js/mixin_typevariable_test.dart b/tests/compiler/dart2js/mixin_typevariable_test.dart
index c57a6bb..deb26ab 100644
--- a/tests/compiler/dart2js/mixin_typevariable_test.dart
+++ b/tests/compiler/dart2js/mixin_typevariable_test.dart
@@ -7,7 +7,7 @@
import 'package:expect/expect.dart';
import "package:async_helper/async_helper.dart";
import 'type_test_helper.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import "package:compiler/src/elements/elements.dart" show Element, ClassElement;
void main() {
@@ -50,7 +50,8 @@
Expect.equals(
element, element.typeVariables.first.element.enclosingElement);
}
- for (InterfaceType supertype in element.allSupertypesAndSelf.types) {
+ for (ResolutionInterfaceType supertype
+ in element.allSupertypesAndSelf.types) {
if (!supertype.typeArguments.isEmpty) {
Expect.listEquals(element.typeVariables, supertype.typeArguments,
"Type argument mismatch on supertype $supertype of $element.");
@@ -96,8 +97,8 @@
""",
expectNoWarningsOrErrors: true)
.then((env) {
- DartType _dynamic = env['dynamic'];
- DartType _ = env['_'];
+ ResolutionDartType _dynamic = env['dynamic'];
+ ResolutionDartType _ = env['_'];
ClassElement Object = env.getElement('Object');
ClassElement A = env.getElement('A');
@@ -117,13 +118,14 @@
ClassElement F1_A_B = F1.superclass;
void testSupertypes(ClassElement element,
- Map<ClassElement, List<DartType>> typeArguments) {
+ Map<ClassElement, List<ResolutionDartType>> typeArguments) {
if (element != Object) {
Expect.isTrue(element.typeVariables.length == 1);
Expect.equals(
element, element.typeVariables.first.element.enclosingElement);
}
- for (InterfaceType supertype in element.allSupertypesAndSelf.types) {
+ for (ResolutionInterfaceType supertype
+ in element.allSupertypesAndSelf.types) {
if (typeArguments.containsKey(supertype.element)) {
Expect.listEquals(
typeArguments[supertype.element],
@@ -151,7 +153,7 @@
B: [_dynamic, _dynamic]
});
- DartType D1_T = D1.typeVariables.first;
+ ResolutionDartType D1_T = D1.typeVariables.first;
testSupertypes(D1, {
A: [D1_T],
B: [
@@ -159,7 +161,7 @@
instantiate(A, [D1_T])
]
});
- DartType D1_superclass_T = D1.superclass.typeVariables.first;
+ ResolutionDartType D1_superclass_T = D1.superclass.typeVariables.first;
testSupertypes(D1.superclass, {
A: [D1_superclass_T],
B: [
@@ -167,7 +169,7 @@
instantiate(A, [D1_superclass_T])
]
});
- DartType D2_T = D2.typeVariables.first;
+ ResolutionDartType D2_T = D2.typeVariables.first;
testSupertypes(D2, {
A: [D2_T],
B: [
@@ -198,7 +200,7 @@
]
});
- DartType F1_T = F1.typeVariables.first;
+ ResolutionDartType F1_T = F1.typeVariables.first;
testSupertypes(F1, {
A: [_],
B: [
@@ -206,7 +208,7 @@
instantiate(B, [F1_T, _])
]
});
- DartType F1_superclass_T = F1.superclass.typeVariables.first;
+ ResolutionDartType F1_superclass_T = F1.superclass.typeVariables.first;
testSupertypes(F1.superclass, {
A: [_],
B: [
@@ -214,7 +216,7 @@
instantiate(B, [F1_superclass_T, _])
]
});
- DartType F2_T = F2.typeVariables.first;
+ ResolutionDartType F2_T = F2.typeVariables.first;
testSupertypes(F2, {
A: [_],
B: [
diff --git a/tests/compiler/dart2js/mock_compiler.dart b/tests/compiler/dart2js/mock_compiler.dart
index f82aa5a..938449e 100644
--- a/tests/compiler/dart2js/mock_compiler.dart
+++ b/tests/compiler/dart2js/mock_compiler.dart
@@ -10,7 +10,8 @@
import 'package:compiler/compiler.dart' as api;
import 'package:compiler/src/common/names.dart' show Uris;
import 'package:compiler/src/constants/expressions.dart';
-import 'package:compiler/src/dart_types.dart' show DartType;
+import 'package:compiler/src/elements/resolution_types.dart'
+ show ResolutionDartType;
import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
import 'package:compiler/src/diagnostics/source_span.dart';
import 'package:compiler/src/diagnostics/spannable.dart';
@@ -321,7 +322,7 @@
class MockTypeVariablesScope extends TypeVariablesScope {
@override
- List<DartType> get typeVariables => <DartType>[];
+ List<ResolutionDartType> get typeVariables => <ResolutionDartType>[];
MockTypeVariablesScope(Scope parent) : super(parent);
String toString() => 'MockTypeVariablesScope($parent)';
}
diff --git a/tests/compiler/dart2js/patch_test.dart b/tests/compiler/dart2js/patch_test.dart
index 523f825..1c84bbe 100644
--- a/tests/compiler/dart2js/patch_test.dart
+++ b/tests/compiler/dart2js/patch_test.dart
@@ -994,7 +994,7 @@
Selector selector =
new Selector.call(const PublicName('method'), CallStructure.NO_ARGS);
TypeMask typeMask = new TypeMask.exact(cls, world);
- FunctionElement method = cls.implementation.lookupLocalMember('method');
+ MethodElement method = cls.implementation.lookupLocalMember('method');
method.computeType(compiler.resolution);
Expect.isTrue(selector.applies(method));
Expect.isTrue(typeMask.canHit(method, selector, world));
diff --git a/tests/compiler/dart2js/related_types.dart b/tests/compiler/dart2js/related_types.dart
index 2db7785..de75f5b 100644
--- a/tests/compiler/dart2js/related_types.dart
+++ b/tests/compiler/dart2js/related_types.dart
@@ -7,7 +7,7 @@
import 'package:compiler/src/commandline_options.dart';
import 'package:compiler/src/compiler.dart';
import 'package:compiler/src/core_types.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
import 'package:compiler/src/diagnostics/messages.dart';
import 'package:compiler/src/elements/elements.dart';
@@ -69,7 +69,8 @@
}
}
-class RelatedTypesChecker extends TraversalVisitor<DartType, dynamic> {
+class RelatedTypesChecker
+ extends TraversalVisitor<ResolutionDartType, dynamic> {
final Compiler compiler;
final ResolvedAst resolvedAst;
@@ -83,10 +84,11 @@
DiagnosticReporter get reporter => compiler.reporter;
- InterfaceType get thisType => resolvedAst.element.enclosingClass.thisType;
+ ResolutionInterfaceType get thisType =>
+ resolvedAst.element.enclosingClass.thisType;
/// Returns `true` if there exists no common subtype of [left] and [right].
- bool hasEmptyIntersection(DartType left, DartType right) {
+ bool hasEmptyIntersection(ResolutionDartType left, ResolutionDartType right) {
if (left == right) return false;
if (left == null || right == null) return false;
ClassElement leftClass = const ClassFinder().findClass(left);
@@ -99,7 +101,8 @@
/// Checks that there exists a common subtype of [left] and [right] or report
/// a hint otherwise.
- void checkRelated(Node node, DartType left, DartType right) {
+ void checkRelated(
+ Node node, ResolutionDartType left, ResolutionDartType right) {
if (hasEmptyIntersection(left, right)) {
reporter.reportHintMessage(
node, MessageKind.NO_COMMON_SUBTYPES, {'left': left, 'right': right});
@@ -108,39 +111,39 @@
/// Check weakly typed collection methods, like `Map.containsKey`,
/// `Map.containsValue` and `Iterable.contains`.
- void checkDynamicInvoke(Node node, DartType receiverType,
- List<DartType> argumentTypes, Selector selector) {
+ void checkDynamicInvoke(Node node, ResolutionDartType receiverType,
+ List<ResolutionDartType> argumentTypes, Selector selector) {
if (selector.name == 'containsKey' &&
selector.callStructure == CallStructure.ONE_ARG) {
- InterfaceType mapType = findMapType(receiverType);
+ ResolutionInterfaceType mapType = findMapType(receiverType);
if (mapType != null) {
- DartType keyType = findMapKeyType(mapType);
+ ResolutionDartType keyType = findMapKeyType(mapType);
checkRelated(node, keyType, argumentTypes.first);
}
} else if (selector.name == 'containsValue' &&
selector.callStructure == CallStructure.ONE_ARG) {
- InterfaceType mapType = findMapType(receiverType);
+ ResolutionInterfaceType mapType = findMapType(receiverType);
if (mapType != null) {
- DartType valueType = findMapValueType(mapType);
+ ResolutionDartType valueType = findMapValueType(mapType);
checkRelated(node, valueType, argumentTypes.first);
}
} else if (selector.name == 'contains' &&
selector.callStructure == CallStructure.ONE_ARG) {
- InterfaceType iterableType = findIterableType(receiverType);
+ ResolutionInterfaceType iterableType = findIterableType(receiverType);
if (iterableType != null) {
- DartType elementType = findIterableElementType(iterableType);
+ ResolutionDartType elementType = findIterableElementType(iterableType);
checkRelated(node, elementType, argumentTypes.first);
}
} else if (selector.name == 'remove' &&
selector.callStructure == CallStructure.ONE_ARG) {
- InterfaceType mapType = findMapType(receiverType);
+ ResolutionInterfaceType mapType = findMapType(receiverType);
if (mapType != null) {
- DartType keyType = findMapKeyType(mapType);
+ ResolutionDartType keyType = findMapKeyType(mapType);
checkRelated(node, keyType, argumentTypes.first);
}
- InterfaceType listType = findListType(receiverType);
+ ResolutionInterfaceType listType = findListType(receiverType);
if (listType != null) {
- DartType valueType = findListElementType(listType);
+ ResolutionDartType valueType = findListElementType(listType);
checkRelated(node, valueType, argumentTypes.first);
}
}
@@ -148,74 +151,76 @@
/// Return the interface type implemented by [type] or `null` if no interface
/// type is implied by [type].
- InterfaceType findInterfaceType(DartType type) {
+ ResolutionInterfaceType findInterfaceType(ResolutionDartType type) {
return Types.computeInterfaceType(compiler.resolution, type);
}
/// Returns the supertype of [receiver] that implements [cls], if any.
- InterfaceType findClassType(DartType receiver, ClassElement cls) {
- InterfaceType interfaceType = findInterfaceType(receiver);
+ ResolutionInterfaceType findClassType(
+ ResolutionDartType receiver, ClassElement cls) {
+ ResolutionInterfaceType interfaceType = findInterfaceType(receiver);
if (interfaceType == null) return null;
- InterfaceType mapType = interfaceType.asInstanceOf(cls);
+ ResolutionInterfaceType mapType = interfaceType.asInstanceOf(cls);
if (mapType == null) return null;
return mapType;
}
/// Returns the supertype of [receiver] that implements `Iterable`, if any.
- InterfaceType findIterableType(DartType receiver) {
+ ResolutionInterfaceType findIterableType(ResolutionDartType receiver) {
return findClassType(receiver, commonElements.iterableClass);
}
/// Returns the element type of the supertype of [receiver] that implements
/// `Iterable`, if any.
- DartType findIterableElementType(InterfaceType iterableType) {
+ ResolutionDartType findIterableElementType(
+ ResolutionInterfaceType iterableType) {
if (iterableType == null) return null;
return iterableType.typeArguments[0];
}
/// Returns the supertype of [receiver] that implements `Map`, if any.
- InterfaceType findMapType(DartType receiver) {
+ ResolutionInterfaceType findMapType(ResolutionDartType receiver) {
return findClassType(receiver, commonElements.mapClass);
}
/// Returns the key type of the supertype of [receiver] that implements
/// `Map`, if any.
- DartType findMapKeyType(InterfaceType mapType) {
+ ResolutionDartType findMapKeyType(ResolutionInterfaceType mapType) {
if (mapType == null) return null;
return mapType.typeArguments[0];
}
/// Returns the value type of the supertype of [receiver] that implements
/// `Map`, if any.
- DartType findMapValueType(InterfaceType mapType) {
+ ResolutionDartType findMapValueType(ResolutionInterfaceType mapType) {
if (mapType == null) return null;
return mapType.typeArguments[1];
}
/// Returns the supertype of [receiver] that implements `List`, if any.
- InterfaceType findListType(DartType receiver) {
+ ResolutionInterfaceType findListType(ResolutionDartType receiver) {
return findClassType(receiver, commonElements.listClass);
}
/// Returns the element type of the supertype of [receiver] that implements
/// `List`, if any.
- DartType findListElementType(InterfaceType listType) {
+ ResolutionDartType findListElementType(ResolutionInterfaceType listType) {
if (listType == null) return null;
return listType.typeArguments[0];
}
/// Returns the implied return type of [type] or `dynamic` if no return type
/// is implied.
- DartType findReturnType(DartType type) {
- if (type is FunctionType) {
+ ResolutionDartType findReturnType(ResolutionDartType type) {
+ if (type is ResolutionFunctionType) {
return type.returnType;
}
- return const DynamicType();
+ return const ResolutionDynamicType();
}
/// Visits [arguments] and returns the list of their corresponding types.
- List<DartType> findArgumentTypes(NodeList arguments) {
- List<DartType> argumentTypes = <DartType>[];
+ List<ResolutionDartType> findArgumentTypes(NodeList arguments) {
+ List<ResolutionDartType> argumentTypes = <ResolutionDartType>[];
for (Node argument in arguments) {
argumentTypes.add(apply(argument));
}
@@ -223,179 +228,193 @@
}
/// Finds the [MemberSignature] of the [name] property on [type], if any.
- MemberSignature lookupInterfaceMember(DartType type, Name name) {
- InterfaceType interfaceType = findInterfaceType(type);
+ MemberSignature lookupInterfaceMember(ResolutionDartType type, Name name) {
+ ResolutionInterfaceType interfaceType = findInterfaceType(type);
if (interfaceType == null) return null;
return interfaceType.lookupInterfaceMember(name);
}
/// Returns the type of an access of the [name] property on [type], or
/// `dynamic` if no property was found.
- DartType lookupInterfaceMemberAccessType(DartType type, Name name) {
+ ResolutionDartType lookupInterfaceMemberAccessType(
+ ResolutionDartType type, Name name) {
MemberSignature member = lookupInterfaceMember(type, name);
- if (member == null) return const DynamicType();
+ if (member == null) return const ResolutionDynamicType();
return member.type;
}
/// Returns the function type of the [name] property on [type], or
/// `dynamic` if no property was found.
- FunctionType lookupInterfaceMemberInvocationType(DartType type, Name name) {
+ ResolutionFunctionType lookupInterfaceMemberInvocationType(
+ ResolutionDartType type, Name name) {
MemberSignature member = lookupInterfaceMember(type, name);
if (member == null) return null;
return member.functionType;
}
- DartType apply(Node node, [_]) {
- DartType type = node.accept(this);
+ ResolutionDartType apply(Node node, [_]) {
+ ResolutionDartType type = node.accept(this);
if (type == null) {
- type = const DynamicType();
+ type = const ResolutionDynamicType();
}
return type;
}
@override
- DartType visitEquals(Send node, Node left, Node right, _) {
- DartType leftType = apply(left);
- DartType rightType = apply(right);
+ ResolutionDartType visitEquals(Send node, Node left, Node right, _) {
+ ResolutionDartType leftType = apply(left);
+ ResolutionDartType rightType = apply(right);
checkRelated(node, leftType, rightType);
return commonElements.boolType;
}
@override
- DartType visitNotEquals(Send node, Node left, Node right, _) {
- DartType leftType = apply(left);
- DartType rightType = apply(right);
+ ResolutionDartType visitNotEquals(Send node, Node left, Node right, _) {
+ ResolutionDartType leftType = apply(left);
+ ResolutionDartType rightType = apply(right);
checkRelated(node, leftType, rightType);
return commonElements.boolType;
}
@override
- DartType visitIndex(Send node, Node receiver, Node index, _) {
- DartType receiverType = apply(receiver);
- DartType indexType = apply(index);
- InterfaceType mapType = findMapType(receiverType);
- DartType keyType = findMapKeyType(mapType);
- DartType valueType = findMapValueType(mapType);
+ ResolutionDartType visitIndex(Send node, Node receiver, Node index, _) {
+ ResolutionDartType receiverType = apply(receiver);
+ ResolutionDartType indexType = apply(index);
+ ResolutionInterfaceType mapType = findMapType(receiverType);
+ ResolutionDartType keyType = findMapKeyType(mapType);
+ ResolutionDartType valueType = findMapValueType(mapType);
checkRelated(index, keyType, indexType);
return valueType;
}
@override
- DartType visitLiteralInt(LiteralInt node) {
+ ResolutionDartType visitLiteralInt(LiteralInt node) {
return commonElements.intType;
}
@override
- DartType visitLiteralString(LiteralString node) {
+ ResolutionDartType visitLiteralString(LiteralString node) {
return commonElements.stringType;
}
@override
- DartType visitLiteralBool(LiteralBool node) {
+ ResolutionDartType visitLiteralBool(LiteralBool node) {
return commonElements.boolType;
}
@override
- DartType visitLiteralMap(LiteralMap node) {
+ ResolutionDartType visitLiteralMap(LiteralMap node) {
return elements.getType(node);
}
@override
- DartType visitLiteralList(LiteralList node) {
+ ResolutionDartType visitLiteralList(LiteralList node) {
return elements.getType(node);
}
@override
- DartType visitLiteralNull(LiteralNull node) {
+ ResolutionDartType visitLiteralNull(LiteralNull node) {
return elements.getType(node);
}
@override
- DartType visitLocalVariableGet(Send node, LocalVariableElement variable, _) {
+ ResolutionDartType visitLocalVariableGet(
+ Send node, LocalVariableElement variable, _) {
return variable.type;
}
@override
- DartType visitLocalFunctionGet(Send node, LocalFunctionElement function, _) {
+ ResolutionDartType visitLocalFunctionGet(
+ Send node, LocalFunctionElement function, _) {
return function.type;
}
@override
- DartType visitParameterGet(Send node, ParameterElement parameter, _) {
+ ResolutionDartType visitParameterGet(
+ Send node, ParameterElement parameter, _) {
return parameter.type;
}
@override
- DartType visitThisPropertyGet(Send node, Name name, _) {
+ ResolutionDartType visitThisPropertyGet(Send node, Name name, _) {
return lookupInterfaceMemberAccessType(thisType, name);
}
@override
- DartType visitDynamicPropertyGet(Send node, Node receiver, Name name, _) {
- DartType receiverType = apply(receiver);
- return lookupInterfaceMemberAccessType(receiverType, name);
- }
-
- @override
- DartType visitIfNotNullDynamicPropertyGet(
+ ResolutionDartType visitDynamicPropertyGet(
Send node, Node receiver, Name name, _) {
- DartType receiverType = apply(receiver);
+ ResolutionDartType receiverType = apply(receiver);
return lookupInterfaceMemberAccessType(receiverType, name);
}
@override
- DartType visitStaticFieldGet(Send node, FieldElement field, _) {
+ ResolutionDartType visitIfNotNullDynamicPropertyGet(
+ Send node, Node receiver, Name name, _) {
+ ResolutionDartType receiverType = apply(receiver);
+ return lookupInterfaceMemberAccessType(receiverType, name);
+ }
+
+ @override
+ ResolutionDartType visitStaticFieldGet(Send node, FieldElement field, _) {
return field.type;
}
@override
- DartType visitTopLevelFieldGet(Send node, FieldElement field, _) {
+ ResolutionDartType visitTopLevelFieldGet(Send node, FieldElement field, _) {
return field.type;
}
@override
- DartType visitDynamicPropertyInvoke(
+ ResolutionDartType visitDynamicPropertyInvoke(
Send node, Node receiver, NodeList arguments, Selector selector, _) {
- DartType receiverType = apply(receiver);
- List<DartType> argumentTypes = findArgumentTypes(arguments);
- FunctionType methodType =
+ ResolutionDartType receiverType = apply(receiver);
+ List<ResolutionDartType> argumentTypes = findArgumentTypes(arguments);
+ ResolutionFunctionType methodType =
lookupInterfaceMemberInvocationType(receiverType, selector.memberName);
checkDynamicInvoke(node, receiverType, argumentTypes, selector);
return findReturnType(methodType);
}
@override
- DartType visitThisPropertyInvoke(
+ ResolutionDartType visitThisPropertyInvoke(
Send node, NodeList arguments, Selector selector, _) {
- DartType receiverType = thisType;
- List<DartType> argumentTypes = findArgumentTypes(arguments);
- FunctionType methodType =
+ ResolutionDartType receiverType = thisType;
+ List<ResolutionDartType> argumentTypes = findArgumentTypes(arguments);
+ ResolutionFunctionType methodType =
lookupInterfaceMemberInvocationType(receiverType, selector.memberName);
checkDynamicInvoke(node, receiverType, argumentTypes, selector);
return findReturnType(methodType);
}
@override
- DartType visitIfNotNullDynamicPropertyInvoke(
+ ResolutionDartType visitIfNotNullDynamicPropertyInvoke(
Send node, Node receiver, NodeList arguments, Selector selector, _) {
- DartType receiverType = apply(receiver);
- List<DartType> argumentTypes = findArgumentTypes(arguments);
- FunctionType methodType =
+ ResolutionDartType receiverType = apply(receiver);
+ List<ResolutionDartType> argumentTypes = findArgumentTypes(arguments);
+ ResolutionFunctionType methodType =
lookupInterfaceMemberInvocationType(receiverType, selector.memberName);
checkDynamicInvoke(node, receiverType, argumentTypes, selector);
return findReturnType(methodType);
}
@override
- DartType visitTopLevelFunctionInvoke(Send node, MethodElement function,
- NodeList arguments, CallStructure callStructure, _) {
+ ResolutionDartType visitTopLevelFunctionInvoke(
+ Send node,
+ MethodElement function,
+ NodeList arguments,
+ CallStructure callStructure,
+ _) {
apply(arguments);
return findReturnType(function.type);
}
@override
- DartType visitStaticFunctionInvoke(Send node, MethodElement function,
- NodeList arguments, CallStructure callStructure, _) {
+ ResolutionDartType visitStaticFunctionInvoke(
+ Send node,
+ MethodElement function,
+ NodeList arguments,
+ CallStructure callStructure,
+ _) {
apply(arguments);
return findReturnType(function.type);
}
@@ -406,13 +425,13 @@
class ClassFinder extends BaseDartTypeVisitor<ClassElement, dynamic> {
const ClassFinder();
- ClassElement findClass(DartType type) => type.accept(this, null);
+ ClassElement findClass(ResolutionDartType type) => type.accept(this, null);
@override
- ClassElement visitType(DartType type, _) => null;
+ ClassElement visitType(ResolutionDartType type, _) => null;
@override
- ClassElement visitInterfaceType(InterfaceType type, _) {
+ ClassElement visitInterfaceType(ResolutionInterfaceType type, _) {
return type.element;
}
}
diff --git a/tests/compiler/dart2js/resolver_test.dart b/tests/compiler/dart2js/resolver_test.dart
index f49f8e5..3035fbf 100644
--- a/tests/compiler/dart2js/resolver_test.dart
+++ b/tests/compiler/dart2js/resolver_test.dart
@@ -8,7 +8,7 @@
import 'package:async_helper/async_helper.dart';
import 'package:expect/expect.dart';
import 'package:compiler/src/constants/expressions.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/elements/modelx.dart';
import 'package:compiler/src/resolution/constructors.dart';
import 'package:compiler/src/resolution/members.dart';
@@ -147,11 +147,12 @@
matchResolvedTypes(visitor, text, name, expectedElements) {
VariableDefinitions definition = parseStatement(text);
visitor.visit(definition.type);
- InterfaceType type = visitor.registry.mapping.getType(definition.type);
+ ResolutionInterfaceType type =
+ visitor.registry.mapping.getType(definition.type);
Expect.equals(
definition.type.typeArguments.slowLength(), type.typeArguments.length);
int index = 0;
- for (DartType argument in type.typeArguments) {
+ for (ResolutionDartType argument in type.typeArguments) {
Expect.equals(true, index < expectedElements.length);
Expect.equals(expectedElements[index], argument.element);
index++;
@@ -803,7 +804,7 @@
Expect.equals(0, collector.warnings.length);
Expect.equals(0, collector.errors.length);
ClassElement aElement = compiler.mainApp.find("A");
- Link<DartType> supertypes = aElement.allSupertypes;
+ Link<ResolutionDartType> supertypes = aElement.allSupertypes;
Expect.equals(<String>['B', 'C', 'Object'].toString(),
asSortedStrings(supertypes).toString());
}),
@@ -820,7 +821,7 @@
Expect.equals(0, collector.warnings.length);
Expect.equals(0, collector.errors.length);
ClassElement aElement = compiler.mainApp.find("C");
- Link<DartType> supertypes = aElement.allSupertypes;
+ Link<ResolutionDartType> supertypes = aElement.allSupertypes;
// Object is once per inheritance path, that is from both A and I.
Expect.equals(
<String>[
@@ -842,7 +843,7 @@
Expect.equals(0, collector.warnings.length);
Expect.equals(0, collector.errors.length);
ClassElement aElement = compiler.mainApp.find("E");
- Link<DartType> supertypes = aElement.allSupertypes;
+ Link<ResolutionDartType> supertypes = aElement.allSupertypes;
Expect.equals(<String>['A<E>', 'D', 'Object'].toString(),
asSortedStrings(supertypes).toString());
}),
diff --git a/tests/compiler/dart2js/semantic_visitor_test.dart b/tests/compiler/dart2js/semantic_visitor_test.dart
index 615852b..1966a04 100644
--- a/tests/compiler/dart2js/semantic_visitor_test.dart
+++ b/tests/compiler/dart2js/semantic_visitor_test.dart
@@ -10,7 +10,7 @@
import 'package:expect/expect.dart';
import 'package:compiler/src/commandline_options.dart';
import 'package:compiler/src/constants/expressions.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/diagnostics/spannable.dart';
import 'package:compiler/src/diagnostics/messages.dart' show MessageKind;
import 'package:compiler/src/compiler.dart';
diff --git a/tests/compiler/dart2js/semantic_visitor_test_decl_visitor.dart b/tests/compiler/dart2js/semantic_visitor_test_decl_visitor.dart
index 86b1a3f..41055c6 100644
--- a/tests/compiler/dart2js/semantic_visitor_test_decl_visitor.dart
+++ b/tests/compiler/dart2js/semantic_visitor_test_decl_visitor.dart
@@ -91,7 +91,7 @@
FunctionExpression node,
ConstructorElement constructor,
NodeList parameters,
- InterfaceType redirectionType,
+ ResolutionInterfaceType redirectionType,
ConstructorElement redirectionTarget,
arg) {
visits.add(new Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
@@ -131,7 +131,7 @@
visitSuperConstructorInvoke(
Send node,
ConstructorElement superConstructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
arg) {
@@ -146,7 +146,7 @@
@override
visitImplicitSuperConstructorInvoke(FunctionExpression node,
- ConstructorElement superConstructor, InterfaceType type, arg) {
+ ConstructorElement superConstructor, ResolutionInterfaceType type, arg) {
visits.add(new Visit(VisitKind.VISIT_IMPLICIT_SUPER_CONSTRUCTOR_INVOKE,
element: superConstructor, type: type));
super
diff --git a/tests/compiler/dart2js/semantic_visitor_test_send_visitor.dart b/tests/compiler/dart2js/semantic_visitor_test_send_visitor.dart
index c16454e..4077d2d 100644
--- a/tests/compiler/dart2js/semantic_visitor_test_send_visitor.dart
+++ b/tests/compiler/dart2js/semantic_visitor_test_send_visitor.dart
@@ -8,7 +8,7 @@
SemanticSendTestVisitor(TreeElements elements) : super(elements);
@override
- visitAs(Send node, Node expression, DartType type, arg) {
+ visitAs(Send node, Node expression, ResolutionDartType type, arg) {
visits
.add(new Visit(VisitKind.VISIT_AS, expression: expression, type: type));
apply(expression, arg);
@@ -256,14 +256,14 @@
}
@override
- visitIs(Send node, Node expression, DartType type, arg) {
+ visitIs(Send node, Node expression, ResolutionDartType type, arg) {
visits
.add(new Visit(VisitKind.VISIT_IS, expression: expression, type: type));
apply(expression, arg);
}
@override
- visitIsNot(Send node, Node expression, DartType type, arg) {
+ visitIsNot(Send node, Node expression, ResolutionDartType type, arg) {
visits.add(
new Visit(VisitKind.VISIT_IS_NOT, expression: expression, type: type));
apply(expression, arg);
@@ -1697,7 +1697,7 @@
@override
visitUnresolvedClassConstructorInvoke(NewExpression node, Element constructor,
- DartType type, NodeList arguments, Selector selector, arg) {
+ ResolutionDartType type, NodeList arguments, Selector selector, arg) {
// TODO(johnniwinther): Test [type] when it is not `dynamic`.
visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_CLASS_CONSTRUCTOR_INVOKE,
arguments: arguments));
@@ -1706,7 +1706,7 @@
@override
visitUnresolvedConstructorInvoke(NewExpression node, Element constructor,
- DartType type, NodeList arguments, Selector selector, arg) {
+ ResolutionDartType type, NodeList arguments, Selector selector, arg) {
// TODO(johnniwinther): Test [type] when it is not `dynamic`.
visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_CONSTRUCTOR_INVOKE,
arguments: arguments));
@@ -1749,8 +1749,13 @@
}
@override
- errorNonConstantConstructorInvoke(NewExpression node, Element element,
- DartType type, NodeList arguments, CallStructure callStructure, arg) {
+ errorNonConstantConstructorInvoke(
+ NewExpression node,
+ Element element,
+ ResolutionDartType type,
+ NodeList arguments,
+ CallStructure callStructure,
+ arg) {
visits.add(new Visit(VisitKind.ERROR_NON_CONSTANT_CONSTRUCTOR_INVOKE,
element: element,
type: type,
@@ -1764,7 +1769,7 @@
visitConstructorIncompatibleInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
arg) {
@@ -1781,7 +1786,7 @@
visitFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
arg) {
@@ -1797,7 +1802,7 @@
visitGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
arg) {
@@ -1813,9 +1818,9 @@
visitRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
ConstructorElement effectiveTarget,
- InterfaceType effectiveTargetType,
+ ResolutionInterfaceType effectiveTargetType,
NodeList arguments,
CallStructure callStructure,
arg) {
@@ -1833,7 +1838,7 @@
visitRedirectingGenerativeConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
arg) {
@@ -1850,7 +1855,7 @@
visitAbstractClassConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
arg) {
@@ -1866,7 +1871,7 @@
visitUnresolvedRedirectingFactoryConstructorInvoke(
NewExpression node,
ConstructorElement constructor,
- InterfaceType type,
+ ResolutionInterfaceType type,
NodeList arguments,
CallStructure callStructure,
arg) {
diff --git a/tests/compiler/dart2js/serialization/model_test_helper.dart b/tests/compiler/dart2js/serialization/model_test_helper.dart
index 4ac1e1e..5e1c667 100644
--- a/tests/compiler/dart2js/serialization/model_test_helper.dart
+++ b/tests/compiler/dart2js/serialization/model_test_helper.dart
@@ -13,7 +13,7 @@
import 'package:compiler/src/common.dart';
import 'package:compiler/src/constants/values.dart';
import 'package:compiler/src/compiler.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/deferred_load.dart';
import 'package:compiler/src/elements/elements.dart';
import 'package:compiler/src/enqueue.dart';
@@ -107,7 +107,8 @@
void checkResolutionEnqueuers(
ResolutionEnqueuer enqueuer1, ResolutionEnqueuer enqueuer2,
- {bool typeEquivalence(DartType a, DartType b): areTypesEquivalent,
+ {bool typeEquivalence(ResolutionDartType a, ResolutionDartType b):
+ areTypesEquivalent,
bool elementFilter(Element element),
bool verbose: false}) {
checkSets(enqueuer1.processedEntities, enqueuer2.processedEntities,
@@ -424,8 +425,10 @@
(a, b) => areElementsEquivalent(a.declaration, b.declaration));
}
-bool areInstantiationInfosEquivalent(InstantiationInfo info1,
- InstantiationInfo info2, bool typeEquivalence(DartType a, DartType b)) {
+bool areInstantiationInfosEquivalent(
+ InstantiationInfo info1,
+ InstantiationInfo info2,
+ bool typeEquivalence(ResolutionDartType a, ResolutionDartType b)) {
checkMaps(
info1.instantiationMap,
info2.instantiationMap,
@@ -438,7 +441,7 @@
}
bool areInstancesEquivalent(Instance instance1, Instance instance2,
- bool typeEquivalence(DartType a, DartType b)) {
+ bool typeEquivalence(ResolutionDartType a, ResolutionDartType b)) {
return typeEquivalence(instance1.type, instance2.type) &&
instance1.kind == instance2.kind &&
instance1.isRedirection == instance2.isRedirection;
diff --git a/tests/compiler/dart2js/serialization/test_helper.dart b/tests/compiler/dart2js/serialization/test_helper.dart
index 1808b7f..a07dfe2 100644
--- a/tests/compiler/dart2js/serialization/test_helper.dart
+++ b/tests/compiler/dart2js/serialization/test_helper.dart
@@ -8,7 +8,7 @@
import 'package:compiler/src/common/resolution.dart';
import 'package:compiler/src/constants/expressions.dart';
import 'package:compiler/src/constants/values.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/compiler.dart';
import 'package:compiler/src/elements/elements.dart';
import 'package:compiler/src/serialization/equivalence.dart';
@@ -103,7 +103,7 @@
@override
bool testTypes(Object object1, Object object2, String property,
- DartType type1, DartType type2) {
+ ResolutionDartType type1, ResolutionDartType type2) {
return checkTypes(object1, object2, property, type1, type2);
}
@@ -121,7 +121,7 @@
@override
bool testTypeLists(Object object1, Object object2, String property,
- List<DartType> list1, List<DartType> list2) {
+ List<ResolutionDartType> list1, List<ResolutionDartType> list2) {
return checkTypeLists(object1, object2, property, list1, list2);
}
@@ -301,8 +301,8 @@
/// Checks the equivalence of [type1] and [type2].
///
/// Uses [object1], [object2] and [property] to provide context for failures.
-bool checkTypes(Object object1, Object object2, String property, DartType type1,
- DartType type2) {
+bool checkTypes(Object object1, Object object2, String property,
+ ResolutionDartType type1, ResolutionDartType type2) {
if (identical(type1, type2)) return true;
if (type1 == null || type2 == null) {
return check(object1, object2, property, type1, type2);
@@ -316,7 +316,7 @@
///
/// Uses [object1], [object2] and [property] to provide context for failures.
bool checkTypeLists(Object object1, Object object2, String property,
- List<DartType> list1, List<DartType> list2) {
+ List<ResolutionDartType> list1, List<ResolutionDartType> list2) {
return checkListEquivalence(
object1, object2, property, list1, list2, checkTypes);
}
diff --git a/tests/compiler/dart2js/subtype_test.dart b/tests/compiler/dart2js/subtype_test.dart
index bae104f..41e2003 100644
--- a/tests/compiler/dart2js/subtype_test.dart
+++ b/tests/compiler/dart2js/subtype_test.dart
@@ -7,7 +7,7 @@
import 'package:expect/expect.dart';
import "package:async_helper/async_helper.dart";
import 'type_test_helper.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import "package:compiler/src/elements/elements.dart" show Element, ClassElement;
void main() {
@@ -22,8 +22,8 @@
testTypeVariableSubtype();
}
-void testTypes(TypeEnvironment env, DartType subtype, DartType supertype,
- bool expectSubtype, bool expectMoreSpecific) {
+void testTypes(TypeEnvironment env, ResolutionDartType subtype,
+ ResolutionDartType supertype, bool expectSubtype, bool expectMoreSpecific) {
if (expectMoreSpecific == null) expectMoreSpecific = expectSubtype;
Expect.equals(expectSubtype, env.isSubtype(subtype, supertype),
'$subtype <: $supertype');
@@ -33,8 +33,8 @@
void testElementTypes(TypeEnvironment env, String subname, String supername,
bool expectSubtype, bool expectMoreSpecific) {
- DartType subtype = env.getElementType(subname);
- DartType supertype = env.getElementType(supername);
+ ResolutionDartType subtype = env.getElementType(subname);
+ ResolutionDartType supertype = env.getElementType(supername);
testTypes(env, subtype, supertype, expectSubtype, expectMoreSpecific);
}
@@ -46,7 +46,8 @@
// currently not supported by the implementation.
class C<T1, T2> extends B<T2, T1> /*implements A<A<T1>>*/ {}
""").then((env) {
- void expect(bool expectSubtype, DartType T, DartType S,
+ void expect(
+ bool expectSubtype, ResolutionDartType T, ResolutionDartType S,
{bool expectMoreSpecific}) {
testTypes(env, T, S, expectSubtype, expectMoreSpecific);
}
@@ -54,13 +55,13 @@
ClassElement A = env.getElement('A');
ClassElement B = env.getElement('B');
ClassElement C = env.getElement('C');
- DartType Object_ = env['Object'];
- DartType num_ = env['num'];
- DartType int_ = env['int'];
- DartType String_ = env['String'];
- DartType dynamic_ = env['dynamic'];
- DartType void_ = env['void'];
- DartType Null_ = env['Null'];
+ ResolutionDartType Object_ = env['Object'];
+ ResolutionDartType num_ = env['num'];
+ ResolutionDartType int_ = env['int'];
+ ResolutionDartType String_ = env['String'];
+ ResolutionDartType dynamic_ = env['dynamic'];
+ ResolutionDartType void_ = env['void'];
+ ResolutionDartType Null_ = env['Null'];
expect(true, void_, void_);
expect(true, void_, dynamic_);
@@ -112,12 +113,12 @@
expect(true, dynamic_, Null_, expectMoreSpecific: false);
expect(true, Null_, Null_);
- DartType A_Object = instantiate(A, [Object_]);
- DartType A_num = instantiate(A, [num_]);
- DartType A_int = instantiate(A, [int_]);
- DartType A_String = instantiate(A, [String_]);
- DartType A_dynamic = instantiate(A, [dynamic_]);
- DartType A_Null = instantiate(A, [Null_]);
+ ResolutionDartType A_Object = instantiate(A, [Object_]);
+ ResolutionDartType A_num = instantiate(A, [num_]);
+ ResolutionDartType A_int = instantiate(A, [int_]);
+ ResolutionDartType A_String = instantiate(A, [String_]);
+ ResolutionDartType A_dynamic = instantiate(A, [dynamic_]);
+ ResolutionDartType A_Null = instantiate(A, [Null_]);
expect(true, A_Object, Object_);
expect(false, A_Object, num_);
@@ -168,11 +169,13 @@
expect(true, A_dynamic, A_Null, expectMoreSpecific: false);
expect(true, A_Null, A_Null);
- DartType B_Object_Object = instantiate(B, [Object_, Object_]);
- DartType B_num_num = instantiate(B, [num_, num_]);
- DartType B_int_num = instantiate(B, [int_, num_]);
- DartType B_dynamic_dynamic = instantiate(B, [dynamic_, dynamic_]);
- DartType B_String_dynamic = instantiate(B, [String_, dynamic_]);
+ ResolutionDartType B_Object_Object = instantiate(B, [Object_, Object_]);
+ ResolutionDartType B_num_num = instantiate(B, [num_, num_]);
+ ResolutionDartType B_int_num = instantiate(B, [int_, num_]);
+ ResolutionDartType B_dynamic_dynamic =
+ instantiate(B, [dynamic_, dynamic_]);
+ ResolutionDartType B_String_dynamic =
+ instantiate(B, [String_, dynamic_]);
expect(true, B_Object_Object, Object_);
expect(true, B_Object_Object, A_Object);
@@ -242,10 +245,11 @@
expectMoreSpecific: false);
expect(true, B_String_dynamic, B_String_dynamic);
- DartType C_Object_Object = instantiate(C, [Object_, Object_]);
- DartType C_num_num = instantiate(C, [num_, num_]);
- DartType C_int_String = instantiate(C, [int_, String_]);
- DartType C_dynamic_dynamic = instantiate(C, [dynamic_, dynamic_]);
+ ResolutionDartType C_Object_Object = instantiate(C, [Object_, Object_]);
+ ResolutionDartType C_num_num = instantiate(C, [num_, num_]);
+ ResolutionDartType C_int_String = instantiate(C, [int_, String_]);
+ ResolutionDartType C_dynamic_dynamic =
+ instantiate(C, [dynamic_, dynamic_]);
expect(true, C_Object_Object, B_Object_Object);
expect(false, C_Object_Object, B_num_num);
@@ -297,20 +301,21 @@
void m5(V v, int i);
}
""").then((env) {
- void expect(bool expectSubtype, DartType T, DartType S,
+ void expect(
+ bool expectSubtype, ResolutionDartType T, ResolutionDartType S,
{bool expectMoreSpecific}) {
testTypes(env, T, S, expectSubtype, expectMoreSpecific);
}
ClassElement classA = env.getElement('A');
- DartType A = classA.rawType;
- DartType function = env['Function'];
- DartType call = env.getMemberType(classA, 'call');
- DartType m1 = env.getMemberType(classA, 'm1');
- DartType m2 = env.getMemberType(classA, 'm2');
- DartType m3 = env.getMemberType(classA, 'm3');
- DartType m4 = env.getMemberType(classA, 'm4');
- DartType m5 = env.getMemberType(classA, 'm5');
+ ResolutionDartType A = classA.rawType;
+ ResolutionDartType function = env['Function'];
+ ResolutionDartType call = env.getMemberType(classA, 'call');
+ ResolutionDartType m1 = env.getMemberType(classA, 'm1');
+ ResolutionDartType m2 = env.getMemberType(classA, 'm2');
+ ResolutionDartType m3 = env.getMemberType(classA, 'm3');
+ ResolutionDartType m4 = env.getMemberType(classA, 'm4');
+ ResolutionDartType m5 = env.getMemberType(classA, 'm5');
expect(true, A, function);
expect(true, A, call);
@@ -582,44 +587,45 @@
class I<T extends S, S extends U, U extends T> {}
class J<T extends S, S extends U, U extends S> {}
""").then((env) {
- void expect(bool expectSubtype, DartType T, DartType S,
+ void expect(
+ bool expectSubtype, ResolutionDartType T, ResolutionDartType S,
{bool expectMoreSpecific}) {
testTypes(env, T, S, expectSubtype, expectMoreSpecific);
}
ClassElement A = env.getElement('A');
- TypeVariableType A_T = A.thisType.typeArguments[0];
+ ResolutionTypeVariableType A_T = A.thisType.typeArguments[0];
ClassElement B = env.getElement('B');
- TypeVariableType B_T = B.thisType.typeArguments[0];
+ ResolutionTypeVariableType B_T = B.thisType.typeArguments[0];
ClassElement C = env.getElement('C');
- TypeVariableType C_T = C.thisType.typeArguments[0];
+ ResolutionTypeVariableType C_T = C.thisType.typeArguments[0];
ClassElement D = env.getElement('D');
- TypeVariableType D_T = D.thisType.typeArguments[0];
+ ResolutionTypeVariableType D_T = D.thisType.typeArguments[0];
ClassElement E = env.getElement('E');
- TypeVariableType E_T = E.thisType.typeArguments[0];
- TypeVariableType E_S = E.thisType.typeArguments[1];
+ ResolutionTypeVariableType E_T = E.thisType.typeArguments[0];
+ ResolutionTypeVariableType E_S = E.thisType.typeArguments[1];
ClassElement F = env.getElement('F');
- TypeVariableType F_T = F.thisType.typeArguments[0];
- TypeVariableType F_S = F.thisType.typeArguments[1];
+ ResolutionTypeVariableType F_T = F.thisType.typeArguments[0];
+ ResolutionTypeVariableType F_S = F.thisType.typeArguments[1];
ClassElement G = env.getElement('G');
- TypeVariableType G_T = G.thisType.typeArguments[0];
+ ResolutionTypeVariableType G_T = G.thisType.typeArguments[0];
ClassElement H = env.getElement('H');
- TypeVariableType H_T = H.thisType.typeArguments[0];
- TypeVariableType H_S = H.thisType.typeArguments[1];
+ ResolutionTypeVariableType H_T = H.thisType.typeArguments[0];
+ ResolutionTypeVariableType H_S = H.thisType.typeArguments[1];
ClassElement I = env.getElement('I');
- TypeVariableType I_T = I.thisType.typeArguments[0];
- TypeVariableType I_S = I.thisType.typeArguments[1];
- TypeVariableType I_U = I.thisType.typeArguments[2];
+ ResolutionTypeVariableType I_T = I.thisType.typeArguments[0];
+ ResolutionTypeVariableType I_S = I.thisType.typeArguments[1];
+ ResolutionTypeVariableType I_U = I.thisType.typeArguments[2];
ClassElement J = env.getElement('J');
- TypeVariableType J_T = J.thisType.typeArguments[0];
- TypeVariableType J_S = J.thisType.typeArguments[1];
- TypeVariableType J_U = J.thisType.typeArguments[2];
+ ResolutionTypeVariableType J_T = J.thisType.typeArguments[0];
+ ResolutionTypeVariableType J_S = J.thisType.typeArguments[1];
+ ResolutionTypeVariableType J_U = J.thisType.typeArguments[2];
- DartType Object_ = env['Object'];
- DartType num_ = env['num'];
- DartType int_ = env['int'];
- DartType String_ = env['String'];
- DartType dynamic_ = env['dynamic'];
+ ResolutionDartType Object_ = env['Object'];
+ ResolutionDartType num_ = env['num'];
+ ResolutionDartType int_ = env['int'];
+ ResolutionDartType String_ = env['String'];
+ ResolutionDartType dynamic_ = env['dynamic'];
// class A<T> {}
expect(true, A_T, Object_);
diff --git a/tests/compiler/dart2js/type_checker_test.dart b/tests/compiler/dart2js/type_checker_test.dart
index 0ca2865..10fb244 100644
--- a/tests/compiler/dart2js/type_checker_test.dart
+++ b/tests/compiler/dart2js/type_checker_test.dart
@@ -7,7 +7,7 @@
import 'package:async_helper/async_helper.dart';
import 'package:expect/expect.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/diagnostics/messages.dart';
import 'package:compiler/src/elements/elements.dart';
import 'package:compiler/src/elements/modelx.dart'
@@ -71,7 +71,7 @@
}
testSimpleTypes(MockCompiler compiler) {
- checkType(DartType type, String code) {
+ checkType(ResolutionDartType type, String code) {
Expect.equals(type, analyzeType(compiler, code));
}
@@ -2649,7 +2649,7 @@
return compiler.init("import 'dart:async';").then((_) => test(compiler));
}
-DartType analyzeType(MockCompiler compiler, String text) {
+ResolutionDartType analyzeType(MockCompiler compiler, String text) {
var node = parseExpression(text);
TypeCheckerVisitor visitor = new TypeCheckerVisitor(
compiler, new TreeElementMapping(null), compiler.types);
diff --git a/tests/compiler/dart2js/type_equals_test.dart b/tests/compiler/dart2js/type_equals_test.dart
index 3da5afe..4dab03e 100644
--- a/tests/compiler/dart2js/type_equals_test.dart
+++ b/tests/compiler/dart2js/type_equals_test.dart
@@ -4,7 +4,7 @@
import "package:expect/expect.dart";
import "package:async_helper/async_helper.dart";
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import "compiler_helper.dart";
bool test(compiler, String name1, String name2, {bool expect}) {
@@ -28,8 +28,8 @@
//
// Only a single type is used from each signature. That is, it is not the
// intention to check the whole signatures against eachother.
- DartType type1;
- DartType type2;
+ ResolutionDartType type1;
+ ResolutionDartType type2;
if (signature1.requiredParameterCount == 0) {
// If parameters is empty, use return type.
type1 = signature1.type.returnType;
diff --git a/tests/compiler/dart2js/type_order_test.dart b/tests/compiler/dart2js/type_order_test.dart
index 5fa8087..c74a0ff 100644
--- a/tests/compiler/dart2js/type_order_test.dart
+++ b/tests/compiler/dart2js/type_order_test.dart
@@ -7,7 +7,7 @@
import 'package:expect/expect.dart';
import 'package:async_helper/async_helper.dart';
import 'type_test_helper.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import "package:compiler/src/elements/elements.dart"
show Element, ClassElement, TypedefElement;
@@ -21,42 +21,43 @@
class Z {}
""").then((env) {
List types = [];
- DartType add(DartType type) {
+ ResolutionDartType add(ResolutionDartType type) {
types.add(type);
return type;
}
- DartType dynamic_ = add(env['dynamic']);
- DartType void_ = add(env['void']);
+ ResolutionDartType dynamic_ = add(env['dynamic']);
+ ResolutionDartType void_ = add(env['void']);
ClassElement A = env.getElement('A');
TypedefElement B = env.getElement('B');
ClassElement C = env.getElement('C');
- DartType X = add(env['X']);
- DartType Y = add(env['Y']);
- DartType Z = add(env['Z']);
+ ResolutionDartType X = add(env['X']);
+ ResolutionDartType Y = add(env['Y']);
+ ResolutionDartType Z = add(env['Z']);
- InterfaceType A_this = add(A.thisType);
- InterfaceType A_raw = add(A.rawType);
- TypeVariableType AT = add(A_this.typeArguments[0]);
- TypeVariableType AS = add(A_this.typeArguments[1]);
- InterfaceType A_X_Y = add(instantiate(A, [X, Y]));
- InterfaceType A_Y_X = add(instantiate(A, [Y, X]));
+ ResolutionInterfaceType A_this = add(A.thisType);
+ ResolutionInterfaceType A_raw = add(A.rawType);
+ ResolutionTypeVariableType AT = add(A_this.typeArguments[0]);
+ ResolutionTypeVariableType AS = add(A_this.typeArguments[1]);
+ ResolutionInterfaceType A_X_Y = add(instantiate(A, [X, Y]));
+ ResolutionInterfaceType A_Y_X = add(instantiate(A, [Y, X]));
- TypedefType B_this = add(B.computeType(env.compiler.resolution));
- TypedefType B_raw = add(B.rawType);
- TypeVariableType BT = add(B_this.typeArguments[0]);
- TypeVariableType BS = add(B_this.typeArguments[1]);
- FunctionType B_this_alias = add(B.alias);
- TypedefType B_X_Y = add(instantiate(B, [X, Y]));
- FunctionType B_X_Y_alias = add(B_X_Y.unaliased);
- TypedefType B_Y_X = add(instantiate(B, [Y, X]));
- FunctionType B_Y_X_alias = add(B_Y_X.unaliased);
+ ResolutionTypedefType B_this =
+ add(B.computeType(env.compiler.resolution));
+ ResolutionTypedefType B_raw = add(B.rawType);
+ ResolutionTypeVariableType BT = add(B_this.typeArguments[0]);
+ ResolutionTypeVariableType BS = add(B_this.typeArguments[1]);
+ ResolutionFunctionType B_this_alias = add(B.alias);
+ ResolutionTypedefType B_X_Y = add(instantiate(B, [X, Y]));
+ ResolutionFunctionType B_X_Y_alias = add(B_X_Y.unaliased);
+ ResolutionTypedefType B_Y_X = add(instantiate(B, [Y, X]));
+ ResolutionFunctionType B_Y_X_alias = add(B_Y_X.unaliased);
- InterfaceType C_this = add(C.thisType);
- InterfaceType C_raw = add(C.rawType);
- TypeVariableType CT = add(C_this.typeArguments[0]);
- TypeVariableType CS = add(C_this.typeArguments[1]);
+ ResolutionInterfaceType C_this = add(C.thisType);
+ ResolutionInterfaceType C_raw = add(C.rawType);
+ ResolutionTypeVariableType CT = add(C_this.typeArguments[0]);
+ ResolutionTypeVariableType CS = add(C_this.typeArguments[1]);
Expect.listEquals([
void_,
diff --git a/tests/compiler/dart2js/type_representation_test.dart b/tests/compiler/dart2js/type_representation_test.dart
index bb1280d..6fe0889 100644
--- a/tests/compiler/dart2js/type_representation_test.dart
+++ b/tests/compiler/dart2js/type_representation_test.dart
@@ -7,7 +7,7 @@
import 'package:expect/expect.dart';
import "package:async_helper/async_helper.dart";
import 'type_test_helper.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/js/js.dart';
import 'package:compiler/src/elements/elements.dart' show Element, ClassElement;
import 'package:compiler/src/js_backend/js_backend.dart'
@@ -46,7 +46,7 @@
TypeRepresentationGenerator typeRepresentation =
new TypeRepresentationGenerator(env.compiler);
- Expression onVariable(TypeVariableType variable) {
+ Expression onVariable(ResolutionTypeVariableType variable) {
return new VariableUse(variable.name);
}
@@ -54,7 +54,7 @@
return prettyPrint(expression, env.compiler);
}
- void expect(DartType type, String expectedRepresentation,
+ void expect(ResolutionDartType type, String expectedRepresentation,
[String expectedTypedefRepresentation]) {
bool encodeTypedefName = false;
Expression expression = typeRepresentation.getTypeRepresentation(
@@ -86,25 +86,25 @@
String typedefTag = backend.namer.typedefTag;
ClassElement List_ = env.getElement('List');
- TypeVariableType List_E = List_.typeVariables[0];
+ ResolutionTypeVariableType List_E = List_.typeVariables[0];
ClassElement Map_ = env.getElement('Map');
- TypeVariableType Map_K = Map_.typeVariables[0];
- TypeVariableType Map_V = Map_.typeVariables[1];
+ ResolutionTypeVariableType Map_K = Map_.typeVariables[0];
+ ResolutionTypeVariableType Map_V = Map_.typeVariables[1];
- DartType Object_ = env['Object'];
- DartType int_ = env['int'];
- DartType String_ = env['String'];
- DartType dynamic_ = env['dynamic'];
- DartType Typedef_ = env['Typedef'];
- DartType Typedef2_ = env['Typedef2'];
- DartType Typedef3_ = env['Typedef3'];
- DartType Typedef4_ = env['Typedef4'];
- DartType Typedef5_ = env['Typedef5'];
- DartType Typedef6_ = env['Typedef6'];
- DartType Typedef7_ = env['Typedef7'];
- DartType Typedef8_ = env['Typedef8'];
- DartType Typedef9_ = env['Typedef9'];
- DartType Typedef10_ = env['Typedef10'];
+ ResolutionDartType Object_ = env['Object'];
+ ResolutionDartType int_ = env['int'];
+ ResolutionDartType String_ = env['String'];
+ ResolutionDartType dynamic_ = env['dynamic'];
+ ResolutionDartType Typedef_ = env['Typedef'];
+ ResolutionDartType Typedef2_ = env['Typedef2'];
+ ResolutionDartType Typedef3_ = env['Typedef3'];
+ ResolutionDartType Typedef4_ = env['Typedef4'];
+ ResolutionDartType Typedef5_ = env['Typedef5'];
+ ResolutionDartType Typedef6_ = env['Typedef6'];
+ ResolutionDartType Typedef7_ = env['Typedef7'];
+ ResolutionDartType Typedef8_ = env['Typedef8'];
+ ResolutionDartType Typedef9_ = env['Typedef9'];
+ ResolutionDartType Typedef10_ = env['Typedef10'];
String List_rep = getJsName(List_);
String List_E_rep = stringify(onVariable(List_E));
diff --git a/tests/compiler/dart2js/type_substitution_test.dart b/tests/compiler/dart2js/type_substitution_test.dart
index 0114b32..2b537c4 100644
--- a/tests/compiler/dart2js/type_substitution_test.dart
+++ b/tests/compiler/dart2js/type_substitution_test.dart
@@ -6,11 +6,11 @@
import 'package:expect/expect.dart';
import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'compiler_helper.dart';
import 'type_test_helper.dart';
-DartType getType(compiler, String name) {
+ResolutionDartType getType(compiler, String name) {
var clazz = findElement(compiler, "Class");
clazz.ensureResolved(compiler.resolution);
var element = clazz.buildScope().lookup(name);
@@ -57,25 +57,26 @@
ClassElement E = env.getElement("E");
ClassElement F = env.getElement("F");
- DartType numType = env['num'];
- DartType intType = env['int'];
- DartType stringType = env['String'];
+ ResolutionDartType numType = env['num'];
+ ResolutionDartType intType = env['int'];
+ ResolutionDartType stringType = env['String'];
- InterfaceType C_int = instantiate(C, [intType]);
+ ResolutionInterfaceType C_int = instantiate(C, [intType]);
Expect.equals(instantiate(C, [intType]), C_int);
Expect.equals(instantiate(A, [intType]), C_int.asInstanceOf(A));
- InterfaceType D_int = instantiate(D, [stringType]);
+ ResolutionInterfaceType D_int = instantiate(D, [stringType]);
Expect.equals(instantiate(A, [intType]), D_int.asInstanceOf(A));
- InterfaceType E_int = instantiate(E, [intType]);
+ ResolutionInterfaceType E_int = instantiate(E, [intType]);
Expect.equals(
instantiate(A, [
instantiate(A, [intType])
]),
E_int.asInstanceOf(A));
- InterfaceType F_int_string = instantiate(F, [intType, stringType]);
+ ResolutionInterfaceType F_int_string =
+ instantiate(F, [intType, stringType]);
Expect.equals(
instantiate(B, [
instantiate(F, [intType, stringType])
@@ -98,9 +99,9 @@
*/
void testSubstitution(
compiler, arguments, parameters, String name1, String name2) {
- DartType type1 = getType(compiler, name1);
- DartType type2 = getType(compiler, name2);
- DartType subst = type1.subst(arguments, parameters);
+ ResolutionDartType type1 = getType(compiler, name1);
+ ResolutionDartType type2 = getType(compiler, name2);
+ ResolutionDartType subst = type1.subst(arguments, parameters);
Expect.equals(
type2, subst, "$type1.subst($arguments,$parameters)=$subst != $type2");
}
@@ -161,29 +162,33 @@
""").then((env) {
var compiler = env.compiler;
- InterfaceType Class_T_S = env["Class"];
+ ResolutionInterfaceType Class_T_S = env["Class"];
Expect.isNotNull(Class_T_S);
- Expect.identical(Class_T_S.kind, TypeKind.INTERFACE);
+ Expect.identical(Class_T_S.kind, ResolutionTypeKind.INTERFACE);
Expect.equals(2, Class_T_S.typeArguments.length);
- DartType T = Class_T_S.typeArguments[0];
+ ResolutionDartType T = Class_T_S.typeArguments[0];
Expect.isNotNull(T);
- Expect.identical(T.kind, TypeKind.TYPE_VARIABLE);
+ Expect.identical(T.kind, ResolutionTypeKind.TYPE_VARIABLE);
- DartType S = Class_T_S.typeArguments[1];
+ ResolutionDartType S = Class_T_S.typeArguments[1];
Expect.isNotNull(S);
- Expect.identical(S.kind, TypeKind.TYPE_VARIABLE);
+ Expect.identical(S.kind, ResolutionTypeKind.TYPE_VARIABLE);
- DartType intType = env['int']; //getType(compiler, "int1");
+ ResolutionDartType intType = env['int']; //getType(compiler, "int1");
Expect.isNotNull(intType);
- Expect.identical(intType.kind, TypeKind.INTERFACE);
+ Expect.identical(intType.kind, ResolutionTypeKind.INTERFACE);
- DartType StringType = env['String']; //getType(compiler, "String1");
+ ResolutionDartType StringType =
+ env['String']; //getType(compiler, "String1");
Expect.isNotNull(StringType);
- Expect.identical(StringType.kind, TypeKind.INTERFACE);
+ Expect.identical(StringType.kind, ResolutionTypeKind.INTERFACE);
- List<DartType> parameters = <DartType>[T, S];
- List<DartType> arguments = <DartType>[intType, StringType];
+ List<ResolutionDartType> parameters = <ResolutionDartType>[T, S];
+ List<ResolutionDartType> arguments = <ResolutionDartType>[
+ intType,
+ StringType
+ ];
// TODO(johnniwinther): Create types directly from strings to improve test
// readability.
@@ -231,19 +236,21 @@
compiler, arguments, parameters, "Typedef1e", "Typedef2e");
// Substitution in unalias.
- DartType Typedef2_int_String = getType(compiler, "Typedef2a");
+ ResolutionDartType Typedef2_int_String = getType(compiler, "Typedef2a");
Expect.isNotNull(Typedef2_int_String);
- DartType Function_int_String = getType(compiler, "Function2b");
+ ResolutionDartType Function_int_String =
+ getType(compiler, "Function2b");
Expect.isNotNull(Function_int_String);
- DartType unalias1 = Typedef2_int_String.unaliased;
+ ResolutionDartType unalias1 = Typedef2_int_String.unaliased;
Expect.equals(Function_int_String, unalias1,
'$Typedef2_int_String.unalias=$unalias1 != $Function_int_String');
- DartType Typedef1 = getType(compiler, "Typedef1c");
+ ResolutionDartType Typedef1 = getType(compiler, "Typedef1c");
Expect.isNotNull(Typedef1);
- DartType Function_dynamic_dynamic = getType(compiler, "Function1c");
+ ResolutionDartType Function_dynamic_dynamic =
+ getType(compiler, "Function1c");
Expect.isNotNull(Function_dynamic_dynamic);
- DartType unalias2 = Typedef1.unaliased;
+ ResolutionDartType unalias2 = Typedef1.unaliased;
Expect.equals(Function_dynamic_dynamic, unalias2,
'$Typedef1.unalias=$unalias2 != $Function_dynamic_dynamic');
}));
diff --git a/tests/compiler/dart2js/type_test_helper.dart b/tests/compiler/dart2js/type_test_helper.dart
index 0b215ac..c221dfe 100644
--- a/tests/compiler/dart2js/type_test_helper.dart
+++ b/tests/compiler/dart2js/type_test_helper.dart
@@ -10,19 +10,19 @@
import 'memory_compiler.dart' as memory;
import 'package:compiler/src/common/resolution.dart';
import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import 'package:compiler/src/compiler.dart' show Compiler;
import 'package:compiler/src/elements/elements.dart'
show Element, MemberElement, TypeDeclarationElement, ClassElement;
import 'package:compiler/src/world.dart' show ClosedWorld;
GenericType instantiate(
- TypeDeclarationElement element, List<DartType> arguments) {
+ TypeDeclarationElement element, List<ResolutionDartType> arguments) {
if (element.isClass) {
- return new InterfaceType(element, arguments);
+ return new ResolutionInterfaceType(element, arguments);
} else {
assert(element.isTypedef);
- return new TypedefType(element, arguments);
+ return new ResolutionTypedefType(element, arguments);
}
}
@@ -94,50 +94,53 @@
return element;
}
- DartType getElementType(String name) {
+ ResolutionDartType getElementType(String name) {
var element = getElement(name);
return element.computeType(compiler.resolution);
}
- DartType operator [](String name) {
- if (name == 'dynamic') return const DynamicType();
- if (name == 'void') return const VoidType();
+ ResolutionDartType operator [](String name) {
+ if (name == 'dynamic') return const ResolutionDynamicType();
+ if (name == 'void') return const ResolutionVoidType();
return getElementType(name);
}
- DartType getMemberType(ClassElement element, String name) {
+ ResolutionDartType getMemberType(ClassElement element, String name) {
MemberElement member = element.localLookup(name);
return member.computeType(compiler.resolution);
}
- bool isSubtype(DartType T, DartType S) {
+ bool isSubtype(ResolutionDartType T, ResolutionDartType S) {
return compiler.types.isSubtype(T, S);
}
- bool isMoreSpecific(DartType T, DartType S) {
+ bool isMoreSpecific(ResolutionDartType T, ResolutionDartType S) {
return compiler.types.isMoreSpecific(T, S);
}
- DartType computeLeastUpperBound(DartType T, DartType S) {
+ ResolutionDartType computeLeastUpperBound(
+ ResolutionDartType T, ResolutionDartType S) {
return compiler.types.computeLeastUpperBound(T, S);
}
- DartType flatten(DartType T) {
+ ResolutionDartType flatten(ResolutionDartType T) {
return compiler.types.flatten(T);
}
- FunctionType functionType(DartType returnType, List<DartType> parameters,
- {List<DartType> optionalParameters: const <DartType>[],
- Map<String, DartType> namedParameters}) {
+ ResolutionFunctionType functionType(
+ ResolutionDartType returnType, List<ResolutionDartType> parameters,
+ {List<ResolutionDartType> optionalParameters:
+ const <ResolutionDartType>[],
+ Map<String, ResolutionDartType> namedParameters}) {
List<String> namedParameterNames = <String>[];
- List<DartType> namedParameterTypes = <DartType>[];
+ List<ResolutionDartType> namedParameterTypes = <ResolutionDartType>[];
if (namedParameters != null) {
- namedParameters.forEach((String name, DartType type) {
+ namedParameters.forEach((String name, ResolutionDartType type) {
namedParameterNames.add(name);
namedParameterTypes.add(type);
});
}
- return new FunctionType.synthesized(returnType, parameters,
+ return new ResolutionFunctionType.synthesized(returnType, parameters,
optionalParameters, namedParameterNames, namedParameterTypes);
}
diff --git a/tests/compiler/dart2js/type_variable_occurrence_test.dart b/tests/compiler/dart2js/type_variable_occurrence_test.dart
index 6816288..04d3ffd 100644
--- a/tests/compiler/dart2js/type_variable_occurrence_test.dart
+++ b/tests/compiler/dart2js/type_variable_occurrence_test.dart
@@ -7,7 +7,7 @@
import 'package:expect/expect.dart';
import "package:async_helper/async_helper.dart";
import 'type_test_helper.dart';
-import 'package:compiler/src/dart_types.dart';
+import 'package:compiler/src/elements/resolution_types.dart';
import "package:compiler/src/elements/elements.dart" show Element, ClassElement;
void main() {
@@ -56,8 +56,9 @@
ClassElement A = env.getElement('A');
expect(bool expectResult, String memberName) {
- DartType memberType = env.getMemberType(A, memberName);
- TypeVariableType typeVariable = memberType.typeVariableOccurrence;
+ ResolutionDartType memberType = env.getMemberType(A, memberName);
+ ResolutionTypeVariableType typeVariable =
+ memberType.typeVariableOccurrence;
if (expectResult) {
Expect.isNotNull(typeVariable);
Expect.equals(A, Types.getClassContext(memberType));
diff --git a/tests/compiler/dart2js_extra/mirror_printer_test.dart b/tests/compiler/dart2js_extra/mirror_printer_test.dart
index bc40d4d..8d6c129 100644
--- a/tests/compiler/dart2js_extra/mirror_printer_test.dart
+++ b/tests/compiler/dart2js_extra/mirror_printer_test.dart
@@ -20,7 +20,7 @@
import 'crash_library_metadata.dart'; // This would crash dart2js.
// Importing dart:html to make things interesting.
-import 'dart:html';
+import 'dart:html'; /// 01: ok
class MirrorPrinter {
final StringBuffer buffer;
@@ -185,5 +185,5 @@
print(MirrorPrinter.stringify(currentMirrorSystem().libraries));
// Clear the nodes to avoid confusing the fine test framework (by "fine" I
// mean something else) -- ahe.
- document.body.nodes.clear();
+ document.body.nodes.clear(); /// 01: continued
}
diff --git a/tests/html/html.status b/tests/html/html.status
index 3b0d09c..c3df098 100644
--- a/tests/html/html.status
+++ b/tests/html/html.status
@@ -7,8 +7,6 @@
[ $compiler == none && ($runtime == dartium || $runtime == drt) ]
-canvas_pixel_array_type_alias_test/types2_runtimeTypeName: RuntimeError # Issue 28183
-
mirrors_js_typed_interop_test: Fail # Missing expected failure (Issue 25044)
js_typed_interop_side_cast_exp_test: Fail, OK # tests dart2js-specific behavior.
js_typed_interop_type1_test: Fail, OK # tests dart2js-specific behavior.
@@ -424,6 +422,163 @@
window_nosuchmethod_test: StaticWarning
js_typed_interop_default_arg_test/default_value: MissingCompileTimeError # Issue #25759
+# Issue #28236
+async_spawnuri_test: StaticWarning
+async_test: StaticWarning
+audiobuffersourcenode_test: StaticWarning
+audiocontext_test: StaticWarning
+audioelement_test: StaticWarning
+b_element_test: StaticWarning
+blob_constructor_test: StaticWarning
+cache_test: StaticWarning
+callbacks_test: StaticWarning
+canvas_pixel_array_type_alias_test: StaticWarning
+canvas_test: StaticWarning
+canvasrenderingcontext2d_test: StaticWarning
+cdata_test: StaticWarning
+client_rect_test: StaticWarning
+cross_domain_iframe_test: StaticWarning
+crypto_test: StaticWarning
+css_rule_list_test: StaticWarning
+css_test: StaticWarning
+cssstyledeclaration_test: StaticWarning
+custom/attribute_changed_callback_test: StaticWarning
+custom/constructor_calls_created_synchronously_test: StaticWarning
+custom/created_callback_test: StaticWarning
+custom/document_register_template_test: StaticWarning
+custom/document_register_type_extensions_test: StaticWarning
+custom/entered_left_view_test: StaticWarning
+custom/js_custom_test: StaticWarning
+custom/mirrors_test: StaticWarning
+custom/regress_194523002_test: StaticWarning
+custom_element_method_clash_test: StaticWarning
+custom_element_name_clash_test: StaticWarning
+custom_elements_23127_test: StaticWarning
+custom_elements_test: StaticWarning
+custom_tags_test: StaticWarning
+dart_object_local_storage_test: StaticWarning
+document_test: StaticWarning
+dom_constructors_test: StaticWarning
+domparser_test: StaticWarning
+element_animate_test: StaticWarning
+element_classes_svg_test: StaticWarning
+element_classes_test: StaticWarning
+element_constructor_1_test: StaticWarning
+element_dimensions_test: StaticWarning
+element_offset_test: StaticWarning
+element_types_constructors1_test: StaticWarning
+element_types_constructors2_test: StaticWarning
+element_types_constructors3_test: StaticWarning
+element_types_constructors4_test: StaticWarning
+element_types_constructors5_test: StaticWarning
+element_types_constructors6_test: StaticWarning
+element_types_test: StaticWarning
+event_customevent_test: StaticWarning
+event_test: StaticWarning
+exceptions_test: StaticWarning
+fileapi_test: StaticWarning
+filereader_test: StaticWarning
+filteredelementlist_test: StaticWarning
+fontface_loaded_test: StaticWarning
+fontface_test: StaticWarning
+form_data_test: StaticWarning
+form_element_test: StaticWarning
+gamepad_test: StaticWarning
+geolocation_test: StaticWarning
+hidden_dom_1_test: StaticWarning
+hidden_dom_2_test: StaticWarning
+history_test: StaticWarning
+htmlcollection_test: StaticWarning
+htmloptionscollection_test: StaticWarning
+indexeddb_1_test: StaticWarning
+indexeddb_2_test: StaticWarning
+indexeddb_3_test: StaticWarning
+indexeddb_4_test: StaticWarning
+indexeddb_5_test: StaticWarning
+input_element_test: StaticWarning
+instance_of_test: StaticWarning
+isolates_test: StaticWarning
+js_array_test: StaticWarning
+js_dart_to_string_test: StaticWarning
+js_dispatch_property_test: StaticWarning
+js_function_getter_test: StaticWarning
+js_interop_1_test: StaticWarning
+js_interop_constructor_name_test: StaticWarning
+js_test: StaticWarning
+js_type_test: StaticWarning
+js_typed_interop_anonymous2_exp_test: StaticWarning
+js_typed_interop_anonymous2_test: StaticWarning
+js_typed_interop_anonymous_exp_test: StaticWarning
+js_typed_interop_anonymous_test: StaticWarning
+js_typed_interop_anonymous_unreachable_exp_test: StaticWarning
+js_typed_interop_anonymous_unreachable_test: StaticWarning
+js_typed_interop_bind_this_test: StaticWarning
+js_typed_interop_callable_object_test: StaticWarning
+js_typed_interop_default_arg_test/explicit_argument: StaticWarning
+js_typed_interop_default_arg_test/none: StaticWarning
+js_typed_interop_side_cast_exp_test: StaticWarning
+js_typed_interop_side_cast_test: StaticWarning
+js_typed_interop_test: StaticWarning
+js_typed_interop_window_property_test: StaticWarning
+js_util_test: StaticWarning
+keyboard_event_test: StaticWarning
+location_test: StaticWarning
+media_stream_test: StaticWarning
+mediasource_test: StaticWarning
+messageevent_test: StaticWarning
+mirrors_js_typed_interop_test: StaticWarning
+mouse_event_test: StaticWarning
+native_gc_test: StaticWarning
+navigator_test: StaticWarning
+node_test: StaticWarning
+node_validator_important_if_you_suppress_make_the_bug_critical_test: StaticWarning
+non_instantiated_is_test: StaticWarning
+notification_test: StaticWarning
+performance_api_test: StaticWarning
+postmessage_structured_test: StaticWarning
+query_test: StaticWarning
+range_test: StaticWarning
+request_animation_frame_test: StaticWarning
+rtc_test: StaticWarning
+selectelement_test: StaticWarning
+serialized_script_value_test: StaticWarning
+shadow_dom_test: StaticWarning
+shadowroot_test: StaticWarning
+speechrecognition_test: StaticWarning
+storage_test: StaticWarning
+streams_test: StaticWarning
+svg_test: StaticWarning
+svgelement_test: StaticWarning
+table_test: StaticWarning
+text_event_test: StaticWarning
+touchevent_test: StaticWarning
+transition_event_test: StaticWarning
+trusted_html_tree_sanitizer_test: StaticWarning
+typed_arrays_1_test: StaticWarning
+typed_arrays_2_test: StaticWarning
+typed_arrays_3_test: StaticWarning
+typed_arrays_4_test: StaticWarning
+typed_arrays_5_test: StaticWarning
+typed_arrays_arraybuffer_test: StaticWarning
+typed_arrays_dataview_test: StaticWarning
+typed_arrays_simd_test: StaticWarning
+unknownelement_test: StaticWarning
+uri_test: StaticWarning
+url_test: StaticWarning
+webgl_extensions_test: StaticWarning
+websocket_test: StaticWarning
+websql_test: StaticWarning
+wheelevent_test: StaticWarning
+window_eq_test: StaticWarning
+window_mangling_test: StaticWarning
+window_test: StaticWarning
+worker_api_test: StaticWarning
+worker_test: StaticWarning
+wrapping_collections_test: StaticWarning
+xhr_cross_origin_test: StaticWarning
+xhr_test: StaticWarning
+xsltprocessor_test: StaticWarning
+
[ $compiler == dart2js && $fast_startup ]
custom/constructor_calls_created_synchronously_test: Fail # mirrors not supported
custom/js_custom_test: Fail # mirrors not supported
diff --git a/tests/isolate/isolate.status b/tests/isolate/isolate.status
index 22a15a1..7a921a0 100644
--- a/tests/isolate/isolate.status
+++ b/tests/isolate/isolate.status
@@ -160,6 +160,37 @@
browser/typed_data_message_test: StaticWarning
mint_maker_test: StaticWarning
+# Issue #28236
+browser/compute_this_script_browser_test: StaticWarning
+browser/package_resolve_browser_hook2_test: StaticWarning
+browser/package_resolve_browser_hook_test: StaticWarning
+browser/package_resolve_browser_test: StaticWarning
+count_test: StaticWarning
+cross_isolate_message_test: StaticWarning
+deferred_in_isolate2_test: StaticWarning
+illegal_msg_function_test: StaticWarning
+illegal_msg_mirror_test: StaticWarning
+isolate_complex_messages_test: StaticWarning
+mandel_isolate_test: StaticWarning
+message2_test: StaticWarning
+message_test: StaticWarning
+nested_spawn2_test: StaticWarning
+nested_spawn_test: StaticWarning
+raw_port_test: StaticWarning
+request_reply_test: StaticWarning
+spawn_function_custom_class_test: StaticWarning
+spawn_function_test: StaticWarning
+spawn_uri_multi_test/01: StaticWarning
+spawn_uri_multi_test/none: StaticWarning
+spawn_uri_nested_vm_test: StaticWarning
+spawn_uri_test: StaticWarning
+spawn_uri_vm_test: StaticWarning
+stacktrace_message_test: StaticWarning
+static_function_test: StaticWarning
+timer_isolate_test: StaticWarning
+unresolved_ports_test: StaticWarning
+
+
[ $compiler == none && $runtime == vm ]
scenarios/short_package/short_package_test: Fail, OK # We do not plan to support the tested behavior anyway.
diff --git a/tests/language/language.status b/tests/language/language.status
index 3fefdf6..8697ac4 100644
--- a/tests/language/language.status
+++ b/tests/language/language.status
@@ -9,9 +9,8 @@
null_is_bottom_test/22: RuntimeError # Issue 28025
null_is_bottom_test/34: RuntimeError # Issue 28025
-
[ $compiler == none || $compiler == precompiler || $compiler == app_jit ]
-tearoff_constructor_basic_test: Skip # Crashes in checked mode -- hausner investigating
+# Other issues:
generic_methods_type_expression_test: RuntimeError # Issue 25869
null_is_bottom_test/05: RuntimeError # Issue 28025
null_is_bottom_test/07: RuntimeError # Issue 28025
@@ -107,6 +106,7 @@
vm/type_vm_test: Fail # Issue 14651.
[ $compiler == none && ($runtime == dartium || $runtime == drt) ]
+# Other issues.
issue13474_test: Pass, Fail # Issue 14651.
config_import_test: Fail # Issue 14651.
vm/optimized_guarded_field_isolates_test: RuntimeError, OK # Uses Isolate.spawn.
@@ -205,6 +205,7 @@
super_call4_test: SkipByDesign
super_getter_setter_test: SkipByDesign
vm/reflect_core_vm_test: SkipByDesign
+regress_28255_test: SkipByDesign
[ $noopt ]
# Deferred loading happens eagerly. Issue #27587
@@ -214,7 +215,6 @@
deferred_load_constants_test/02: Fail
deferred_load_constants_test/03: Fail
deferred_load_constants_test/05: Fail
-tearoff_basic_test: Fail
regress_22443_test: Fail
deferred_not_loaded_check_test: Fail
vm/regress_27201_test: Fail
@@ -226,7 +226,6 @@
deferred_load_constants_test/02: Fail
deferred_load_constants_test/03: Fail
deferred_load_constants_test/05: Fail
-tearoff_basic_test: Fail
deferred_not_loaded_check_test: Fail
vm/regress_27201_test: Fail
@@ -314,7 +313,6 @@
issue_1751477_test: Crash # Requires deferred libraries
regress_23408_test: Crash # Requires deferred libraries
regress_22443_test: Crash # Requires deferred libraries
-tearoff_basic_test: Crash # Requires deferred libraries
conditional_import_test: Crash # Requires deferred libraries
conditional_import_string_test: Crash # Requires deferred libraries
override_field_method1_negative_test: Pass, Crash # Issue 27835
@@ -341,3 +339,19 @@
[$compiler == dart2analyzer]
vm/regress_27201_test: SkipByDesign # Loads bad library, so will always crash.
config_import_corelib_test: StaticWarning, OK
+
+null_bottom_test/none: StaticWarning, CompileTimeError # Issue 28025
+null_bottom_test/01: Pass, CompileTimeError # Issue 28025
+null_bottom_test/02: Pass, CompileTimeError # Issue 28025
+null_bottom_test/03: Pass, CompileTimeError # Issue 28025
+
+# Issue #28236
+async_await_test: StaticWarning
+async_star_pause_test: StaticWarning
+async_star_test: StaticWarning
+regress_18535_test: StaticWarning
+
+[ $runtime == dart_precompiled || $runtime == vm || $runtime == dartium]
+null_bottom_test/none: RuntimeError # Issue 28025
+null_bottom_test/01: RuntimeError # Issue 28025
+null_bottom_test/02: RuntimeError # Issue 28025
diff --git a/tests/language/language_analyzer2.status b/tests/language/language_analyzer2.status
index d164e71..272af1c 100644
--- a/tests/language/language_analyzer2.status
+++ b/tests/language/language_analyzer2.status
@@ -16,9 +16,6 @@
enum_syntax_test/05: Fail # 21649
enum_syntax_test/06: Fail # 21649
-tearoff_basic_test: Skip # Tear-off not supported
-tearoff_constructor_basic_test: Skip # Tear-off not supported
-
regress_17382_test: Skip # don't care about the static warning.
regress_23408_test: Skip # don't care about the static warning.
regress_25246_test: Skip
diff --git a/tests/language/language_dart2js.status b/tests/language/language_dart2js.status
index 0b2e449..dc59965 100644
--- a/tests/language/language_dart2js.status
+++ b/tests/language/language_dart2js.status
@@ -9,8 +9,6 @@
setter4_test: CompileTimeError # issue 13639
async_star_cancel_while_paused_test: RuntimeError # Issue 22853
-tearoff_basic_test: Skip # Tear-off not supported
-tearoff_constructor_basic_test: Skip # Tear-off not supported
try_catch_on_syntax_test/10: Fail # Issue 19823
try_catch_on_syntax_test/11: Fail # Issue 19823
diff --git a/tests/language/language_kernel.status b/tests/language/language_kernel.status
index 5d65a3b..98ed9bc 100644
--- a/tests/language/language_kernel.status
+++ b/tests/language/language_kernel.status
@@ -95,8 +95,6 @@
null_is_bottom_test/39: RuntimeError # Issue 28025
regress_27617_test/1: MissingCompileTimeError
super_call3_test/01: DartkCrash
-tearoff_basic_test: DartkCompileTimeError
-tearoff_constructor_basic_test: DartkCompileTimeError
type_variable_conflict2_test/02: MissingCompileTimeError
vm/debug_break_enabled_vm_test/01: DartkCompileTimeError
vm/debug_break_enabled_vm_test/none: DartkCompileTimeError
@@ -130,14 +128,14 @@
accessor_conflict_import_prefixed_test: RuntimeError
accessor_conflict_import_test: RuntimeError
assertion_test: RuntimeError
-async_await_test: RuntimeError
+async_await_test: Crash, RuntimeError
async_star_cancel_and_throw_in_finally_test: RuntimeError
async_star_cancel_while_paused_test: RuntimeError
-async_star_pause_test: RuntimeError
+async_star_pause_test: Crash, RuntimeError
async_star_regression_fisk_test: Timeout
async_star_stream_take_test: Timeout
async_star_take_reyield_test: Timeout
-async_star_test: Timeout
+async_star_test: Crash, Timeout
asyncstar_throw_in_catch_test: Timeout
asyncstar_yield_test: Timeout
asyncstar_yieldstar_test: Timeout
@@ -267,7 +265,6 @@
generic_field_mixin4_test: RuntimeError
generic_field_mixin5_test: RuntimeError
generic_inheritance_test: RuntimeError
-generic_local_functions_test: Crash
generic_method_types_test: Pass, RuntimeError
generic_methods_type_expression_test: RuntimeError
generic_test: RuntimeError
@@ -391,4 +388,3 @@
[ $compiler == dartkp && $runtime == dart_precompiled && $mode == debug ]
constructor_named_arguments_test/01: Crash
not_enough_positional_arguments_test/05: Crash
-enum_syntax_test/05: Crash
\ No newline at end of file
diff --git a/tests/language/null_bottom_test.dart b/tests/language/null_bottom_test.dart
new file mode 100644
index 0000000..bea4dab
--- /dev/null
+++ b/tests/language/null_bottom_test.dart
@@ -0,0 +1,137 @@
+// Copyright (c) 2016, 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 file.
+// Dart test for testing the ternary operator.
+
+import "package:expect/expect.dart";
+
+// Test that `Null` acts like the bottom type - less than any other type.
+
+bool isCheckedMode = () { bool c = false; assert(c = true); return c; } ();
+
+typedef R Fun<A, R>(A argument);
+
+class C<T> {
+ const C();
+ T returns() => null;
+ void accepts(T x) {}
+}
+
+class NullBound<T extends num> {}
+
+class ListBound<T extends Iterable<Null>> {}
+
+main() {
+ testClassTypes();
+ testFunctionTypes();
+}
+
+void testClassTypes() {
+ var cn = new C<Null>();
+
+ Expect.isTrue(cn is C<Null>, "C<Null> is C<Null>");
+ Expect.isTrue(cn is C<Object>, "C<Null> is C<Object>");
+ Expect.isTrue(cn is C<int>, "C<Null> is C<int>");
+
+ Expect.isNotNull(cn as C<Null>, "C<Null> as C<Null>");
+ Expect.isNotNull(cn as C<Object>, "C<Null> as C<Object>");
+ Expect.isNotNull(cn as C<int>, "C<Null> as C<int>");
+
+ var ccn = new C<C<Null>>();
+
+ Expect.isTrue(ccn is C<C<Null>>);
+ Expect.isTrue(ccn is C<C<Object>>);
+ Expect.isTrue(ccn is C<C<int>>);
+
+ Expect.isNotNull(ccn as C<C<Null>>);
+ Expect.isNotNull(ccn as C<C<Object>>);
+ Expect.isNotNull(ccn as C<C<int>>);
+
+ var ci = new C<int>();
+ Expect.isFalse(ci is C<Null>);
+
+ var co = new C<Object>();
+ Expect.isFalse(co is C<Null>);
+
+ if (!isCheckedMode) return;
+
+ List<int> li1 = const <Null>[];
+
+ C<Null> x1 = cn;
+ C<Object> x2 = cn;
+
+ Expect.identical(x1 , cn);
+ Expect.identical(x2 , cn);
+
+ const C<Null> cocn = const C<Null>();
+ const C<Object> coco = cocn;
+ const C<int> coci = cocn;
+
+ Expect.identical(cocn, coco);
+ Expect.identical(cocn, coci);
+
+ Expect.throws(() {
+ Null x = "string" as dynamic;
+ use(x); // Avoid "x unused" warning.
+ });
+
+ Expect.throws(() {
+ Null x = new Object();
+ use(x); // Avoid "x unused" warning.
+ });
+
+ NullBound<int> nb = new NullBound<Null>(); // Should not fail.
+ use(nb); // Avoid "nb unused" warning.
+ ListBound<List<Null>> lb = new ListBound<Null>(); // Should not fails
+ use(lb); // Avoid "nb unused" warning.
+}
+
+void testFunctionTypes() {
+ T1 t1 = new T1();
+ T2 t2 = new T2();
+ T1 t = t2;
+
+ Fun<int, Null> f1 = t1.foo;
+ Fun<Null, int> f2 = t.bar;
+ f1 = t1.baz;
+ f2 = t.qux;
+ use(f1);
+ use(f2);
+
+ var l = new List<Fun<Null, Null>>();
+ Expect.isTrue(l is List<Fun<Null, int>>);
+ l = new List<Fun<int, int>>();
+ Expect.isTrue(l is List<Fun<Null, num>>);
+
+ Expect.isTrue(((int _) => null) is Fun<int, Null>);
+
+ Null fun(int x) => null;
+ Fun<Null, int> fun2 = fun; // Safe assignment.
+ if (fun2 is Fun<int, Null>) {
+ // If int->Null is *subtype* of Null->int (which it should be),
+ // then type promotion succeeds.
+ // If type promotion succeeds, the static type is int->Null, otherwise
+ // it's Null->int.
+ fun2(42); // Should not give a warning after type promotion.
+ fun2(null).abs(); /// 03: static type warning, runtime error
+ }
+}
+
+class T1 {
+ Null foo(int x) => null;
+ int bar(Null x) => null;
+ Null baz(int x) => null;
+ int qux(Null x) => null;
+}
+
+class T2 extends T1 {
+ Null foo(Null x) => null; /// 01: static type warning
+ Null bar(Null x) => null;
+ int baz(int x) => x; /// 02: static type warning
+ int qux(int x) => x;
+}
+
+// Avoid "variable not used" warnings.
+use(x) {
+ return identical(x, x);
+}
diff --git a/tests/language/regress_28255_test.dart b/tests/language/regress_28255_test.dart
new file mode 100644
index 0000000..118fc6e
--- /dev/null
+++ b/tests/language/regress_28255_test.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2017, 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 file.
+
+// Regression test for issue 28255
+
+import 'dart:mirrors';
+import 'package:expect/expect.dart';
+
+class Class {
+ noSuchMethod(i) => true;
+
+ foo() {
+ var o = this;
+ Expect.isFalse(o.bar is Null);
+ Expect.isTrue(o.bar != null);
+ Expect.equals(true.runtimeType, o.bar.runtimeType);
+ }
+}
+
+main() {
+ reflectClass(Class).newInstance(const Symbol(''), []).reflectee.foo();
+}
diff --git a/tests/language/tearoff_basic_lib.dart b/tests/language/tearoff_basic_lib.dart
deleted file mode 100644
index fe9fc07..0000000
--- a/tests/language/tearoff_basic_lib.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 2015, 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 file.
-
-library tearoff_basic_lib;
-
-cfunc() => "cfunc";
-
-set cset(a) { cvar = a; }
-
-get cget => "cget";
-
-var cvar = 1+2+3;
-
-final cfinvar = "set in stone";
-
-class ZZ { }
diff --git a/tests/language/tearoff_basic_test.dart b/tests/language/tearoff_basic_test.dart
deleted file mode 100644
index 303d38e..0000000
--- a/tests/language/tearoff_basic_test.dart
+++ /dev/null
@@ -1,166 +0,0 @@
-// Copyright (c) 2015, 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 file.
-
-// Basic test for tear-off closures.
-
-import "package:expect/expect.dart";
-import "tearoff_basic_lib.dart" as P;
-import "tearoff_basic_lib.dart" deferred as D;
-
-class C {
- var v = 99;
- final fv = 444;
-
- operator + (a) { return v + a; }
- get sugus => "sugus";
- set frosch(a) { v = "ribbit $a"; }
- foo() => "kuh";
-
- static var st;
- static final stfin = 1000;
- static stfoo([p1 = 100]) => p1 * 10;
- static get stg => "stg";
- static set sts(x) { st = x; }
-}
-
-
-testStatic() {
- // Closurize static variable.
- var a = C#st=;
- a(100);
- Expect.equals(100, C.st);
- var b = C#st;
- Expect.equals(100, b());
-
- // Closurize static final variable.
- a = C#stfin;
- Expect.equals(1000, a());
- Expect.throws(() => C#stfin= ); // Final variable has no setter.
-
- // Closurize static method.
- a = C#stfoo;
- Expect.equals(1000, a());
- Expect.equals(90, a(9));
-
- // Closurize static getter.
- a = C#stg;
- Expect.equals("stg", a());
-
- // Closurize static setter.
- Expect.throws(() => C#sts); // No setter/method named sts exists.
- a = C#sts=;
- a("pflug");
- Expect.equals("pflug", C.st);
-
- // Can't closurize instance method via class literal.
- Expect.throws(() => C#foo);
-
- // Extracted closures must be equal.
- Expect.isTrue(C#st == C#st);
- Expect.isTrue(C#st= == C#st=);
- Expect.isTrue(C#stfin == C#stfin);
- Expect.isTrue(C#stfoo == C#stfoo);
- Expect.isTrue(C#stg == C#stg);
- Expect.isTrue(C#sts= == C#sts=);
-}
-
-testInstance() {
- var o = new C();
- var p = new C();
- var a, b;
-
- // Closurize instance variable.
- a = o#v;
- Expect.equals(99, a());
- b = p#v=;
- b(999);
- Expect.equals(999, p.v);
- Expect.equals(99, a());
-
- // Closurize final instance variable.
- Expect.throws(() => o#fv=); // Final variable has not setter.
- a = o#fv;
- Expect.equals(444, a());
-
- // Closurize instance method.
- a = o#foo;
- Expect.equals("kuh", a());
-
- // Closurize operator.
- a = o#+;
- Expect.equals(100, o + 1);
- Expect.equals(100, a(1));
-
- // Closurize instance getter.
- a = o#sugus;
- Expect.equals("sugus", a());
- Expect.throws(() => o#sugus=);
-
- // Closurize instance setter.
- a = o#frosch=;
- a("!");
- Expect.equals("ribbit !", o.v);
- Expect.throws(() => o#frosch);
-
- // Extracted closures must be equal.
- Expect.isTrue(o#v == o#v);
- Expect.isTrue(o#v= == o#v=);
- Expect.isTrue(o#fv == o#fv);
- Expect.isTrue(o#foo == o#foo);
- Expect.isTrue(o#+ == o#+);
- Expect.isTrue(o#sugus == o#sugus);
- Expect.isTrue(o#frosch= == o#frosch=);
-}
-
-testPrefix() {
- // Closurize top-level variable.
- var a = P#cvar;
- Expect.equals(6, a());
- var b = P#cvar=;
- b(7);
- Expect.equals(7, a());
-
- // Closurize final top-level variable.
- a = P#cfinvar;
- Expect.equals("set in stone", a());
- Expect.throws(() => P#cfinvar=);
-
- // Closurize top-level function.
- a = P#cfunc;
- Expect.equals("cfunc", a());
-
- // Closurize top-level getter.
- a = P#cget;
- Expect.equals("cget", a());
-
- // Closurize top-level getter.
- a = P#cset=;
- a(99);
- Expect.equals(99, P.cvar);
-
- Expect.throws(() => P#ZZ); // Cannot closurize class.
-
- // Extracted closures must be equal.
- Expect.isTrue(P#cvar == P#cvar);
- Expect.isTrue(P#cvar= == P#cvar=);
- Expect.isTrue(P#cfinvar == P#cfinvar);
- Expect.isTrue(P#cfunc == P#cfunc);
- Expect.isTrue(P#cget == P#cget);
- Expect.isTrue(P#cset= == P#cset=);
-}
-
-testDeferred() {
- Expect.throws(() => D#cfunc);
- D.loadLibrary().then((_) {
- var a = D#cfunc;
- Expect.equals("cfunc", a());
- });
-}
-
-main() {
- testStatic();
- testInstance();
- testPrefix();
- testDeferred();
-}
diff --git a/tests/language/tearoff_constructor_basic_test.dart b/tests/language/tearoff_constructor_basic_test.dart
deleted file mode 100644
index 27c34d9..0000000
--- a/tests/language/tearoff_constructor_basic_test.dart
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2015, 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 file.
-
-// Basic test for tear-off constructor closures.
-
-import "package:expect/expect.dart";
-
-class A {
- // Implicit constructor A();
- var f1 = "A.f1";
-}
-
-class P {
- var x, y;
- P(this.x, this.y);
- factory P.origin() { return new P(0,0); }
- factory P.ursprung() = P.origin;
- P.onXAxis(x) : this(x, 0);
-}
-
-class C<T> {
- T f1;
- C(T p) : f1 = p;
- C.n([T p]) : f1 = p;
- listMaker() { return new List<T>#; } // Closurize type parameter.
-}
-
-
-testMalformed() {
- Expect.throws(() => new NoSuchClass#);
- Expect.throws(() => new A#noSuchContstructor);
-}
-
-testA() {
- var cc = new A#; // Closurize implicit constructor.
- var o = cc();
- Expect.equals("A.f1", o.f1);
- Expect.equals("A.f1", (new A#)().f1);
- Expect.throws(() => new A#foo);
-}
-
-testP() {
- var cc = new P#origin;
- var o = cc();
- Expect.equals(0, o.x);
- cc = new P#ursprung;
- o = cc();
- Expect.equals(0, o.x);
- cc = new P#onXAxis;
- o = cc(5);
- Expect.equals(0, o.y);
- Expect.equals(5, o.x);
- Expect.throws(() => cc(1, 1)); // Too many arguments.
-}
-
-testC() {
- var cc = new C<int>#;
- var o = cc(5);
- Expect.equals("int", "${o.f1.runtimeType}");
- Expect.throws(() => cc()); // Missing constructor parameter.
-
- cc = new C<String>#n;
- o = cc("foo");
- Expect.equals("String", "${o.f1.runtimeType}");
- o = cc();
- Expect.equals(null, o.f1);
-
- cc = o.listMaker();
- Expect.isTrue(cc is Function);
- var l = cc();
- Expect.equals("List<String>", "${l.runtimeType}");
-}
-
-main() {
- testA();
- testC();
- testP();
- testMalformed();
-}
diff --git a/tests/language_strong/language_strong.status b/tests/language_strong/language_strong.status
index a3a7371..424f579 100644
--- a/tests/language_strong/language_strong.status
+++ b/tests/language_strong/language_strong.status
@@ -626,8 +626,6 @@
sync_generator1_test: Skip
sync_generator2_test: Skip
syntax_test: Skip
-tearoff_basic_test: Skip
-tearoff_constructor_basic_test: Skip
test_negative_test: Skip
third_test: Skip
this_conditional_operator_test: Skip
diff --git a/tests/language_strong/tearoff_basic_lib.dart b/tests/language_strong/tearoff_basic_lib.dart
deleted file mode 100644
index fe9fc07..0000000
--- a/tests/language_strong/tearoff_basic_lib.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 2015, 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 file.
-
-library tearoff_basic_lib;
-
-cfunc() => "cfunc";
-
-set cset(a) { cvar = a; }
-
-get cget => "cget";
-
-var cvar = 1+2+3;
-
-final cfinvar = "set in stone";
-
-class ZZ { }
diff --git a/tests/language_strong/tearoff_basic_test.dart b/tests/language_strong/tearoff_basic_test.dart
deleted file mode 100644
index 303d38e..0000000
--- a/tests/language_strong/tearoff_basic_test.dart
+++ /dev/null
@@ -1,166 +0,0 @@
-// Copyright (c) 2015, 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 file.
-
-// Basic test for tear-off closures.
-
-import "package:expect/expect.dart";
-import "tearoff_basic_lib.dart" as P;
-import "tearoff_basic_lib.dart" deferred as D;
-
-class C {
- var v = 99;
- final fv = 444;
-
- operator + (a) { return v + a; }
- get sugus => "sugus";
- set frosch(a) { v = "ribbit $a"; }
- foo() => "kuh";
-
- static var st;
- static final stfin = 1000;
- static stfoo([p1 = 100]) => p1 * 10;
- static get stg => "stg";
- static set sts(x) { st = x; }
-}
-
-
-testStatic() {
- // Closurize static variable.
- var a = C#st=;
- a(100);
- Expect.equals(100, C.st);
- var b = C#st;
- Expect.equals(100, b());
-
- // Closurize static final variable.
- a = C#stfin;
- Expect.equals(1000, a());
- Expect.throws(() => C#stfin= ); // Final variable has no setter.
-
- // Closurize static method.
- a = C#stfoo;
- Expect.equals(1000, a());
- Expect.equals(90, a(9));
-
- // Closurize static getter.
- a = C#stg;
- Expect.equals("stg", a());
-
- // Closurize static setter.
- Expect.throws(() => C#sts); // No setter/method named sts exists.
- a = C#sts=;
- a("pflug");
- Expect.equals("pflug", C.st);
-
- // Can't closurize instance method via class literal.
- Expect.throws(() => C#foo);
-
- // Extracted closures must be equal.
- Expect.isTrue(C#st == C#st);
- Expect.isTrue(C#st= == C#st=);
- Expect.isTrue(C#stfin == C#stfin);
- Expect.isTrue(C#stfoo == C#stfoo);
- Expect.isTrue(C#stg == C#stg);
- Expect.isTrue(C#sts= == C#sts=);
-}
-
-testInstance() {
- var o = new C();
- var p = new C();
- var a, b;
-
- // Closurize instance variable.
- a = o#v;
- Expect.equals(99, a());
- b = p#v=;
- b(999);
- Expect.equals(999, p.v);
- Expect.equals(99, a());
-
- // Closurize final instance variable.
- Expect.throws(() => o#fv=); // Final variable has not setter.
- a = o#fv;
- Expect.equals(444, a());
-
- // Closurize instance method.
- a = o#foo;
- Expect.equals("kuh", a());
-
- // Closurize operator.
- a = o#+;
- Expect.equals(100, o + 1);
- Expect.equals(100, a(1));
-
- // Closurize instance getter.
- a = o#sugus;
- Expect.equals("sugus", a());
- Expect.throws(() => o#sugus=);
-
- // Closurize instance setter.
- a = o#frosch=;
- a("!");
- Expect.equals("ribbit !", o.v);
- Expect.throws(() => o#frosch);
-
- // Extracted closures must be equal.
- Expect.isTrue(o#v == o#v);
- Expect.isTrue(o#v= == o#v=);
- Expect.isTrue(o#fv == o#fv);
- Expect.isTrue(o#foo == o#foo);
- Expect.isTrue(o#+ == o#+);
- Expect.isTrue(o#sugus == o#sugus);
- Expect.isTrue(o#frosch= == o#frosch=);
-}
-
-testPrefix() {
- // Closurize top-level variable.
- var a = P#cvar;
- Expect.equals(6, a());
- var b = P#cvar=;
- b(7);
- Expect.equals(7, a());
-
- // Closurize final top-level variable.
- a = P#cfinvar;
- Expect.equals("set in stone", a());
- Expect.throws(() => P#cfinvar=);
-
- // Closurize top-level function.
- a = P#cfunc;
- Expect.equals("cfunc", a());
-
- // Closurize top-level getter.
- a = P#cget;
- Expect.equals("cget", a());
-
- // Closurize top-level getter.
- a = P#cset=;
- a(99);
- Expect.equals(99, P.cvar);
-
- Expect.throws(() => P#ZZ); // Cannot closurize class.
-
- // Extracted closures must be equal.
- Expect.isTrue(P#cvar == P#cvar);
- Expect.isTrue(P#cvar= == P#cvar=);
- Expect.isTrue(P#cfinvar == P#cfinvar);
- Expect.isTrue(P#cfunc == P#cfunc);
- Expect.isTrue(P#cget == P#cget);
- Expect.isTrue(P#cset= == P#cset=);
-}
-
-testDeferred() {
- Expect.throws(() => D#cfunc);
- D.loadLibrary().then((_) {
- var a = D#cfunc;
- Expect.equals("cfunc", a());
- });
-}
-
-main() {
- testStatic();
- testInstance();
- testPrefix();
- testDeferred();
-}
diff --git a/tests/language_strong/tearoff_constructor_basic_test.dart b/tests/language_strong/tearoff_constructor_basic_test.dart
deleted file mode 100644
index 27c34d9..0000000
--- a/tests/language_strong/tearoff_constructor_basic_test.dart
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2015, 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 file.
-
-// Basic test for tear-off constructor closures.
-
-import "package:expect/expect.dart";
-
-class A {
- // Implicit constructor A();
- var f1 = "A.f1";
-}
-
-class P {
- var x, y;
- P(this.x, this.y);
- factory P.origin() { return new P(0,0); }
- factory P.ursprung() = P.origin;
- P.onXAxis(x) : this(x, 0);
-}
-
-class C<T> {
- T f1;
- C(T p) : f1 = p;
- C.n([T p]) : f1 = p;
- listMaker() { return new List<T>#; } // Closurize type parameter.
-}
-
-
-testMalformed() {
- Expect.throws(() => new NoSuchClass#);
- Expect.throws(() => new A#noSuchContstructor);
-}
-
-testA() {
- var cc = new A#; // Closurize implicit constructor.
- var o = cc();
- Expect.equals("A.f1", o.f1);
- Expect.equals("A.f1", (new A#)().f1);
- Expect.throws(() => new A#foo);
-}
-
-testP() {
- var cc = new P#origin;
- var o = cc();
- Expect.equals(0, o.x);
- cc = new P#ursprung;
- o = cc();
- Expect.equals(0, o.x);
- cc = new P#onXAxis;
- o = cc(5);
- Expect.equals(0, o.y);
- Expect.equals(5, o.x);
- Expect.throws(() => cc(1, 1)); // Too many arguments.
-}
-
-testC() {
- var cc = new C<int>#;
- var o = cc(5);
- Expect.equals("int", "${o.f1.runtimeType}");
- Expect.throws(() => cc()); // Missing constructor parameter.
-
- cc = new C<String>#n;
- o = cc("foo");
- Expect.equals("String", "${o.f1.runtimeType}");
- o = cc();
- Expect.equals(null, o.f1);
-
- cc = o.listMaker();
- Expect.isTrue(cc is Function);
- var l = cc();
- Expect.equals("List<String>", "${l.runtimeType}");
-}
-
-main() {
- testA();
- testC();
- testP();
- testMalformed();
-}
diff --git a/tests/lib/convert/chunked_conversion1_test.dart b/tests/lib/convert/chunked_conversion1_test.dart
index 0bbe44b..7aa24e3 100644
--- a/tests/lib/convert/chunked_conversion1_test.dart
+++ b/tests/lib/convert/chunked_conversion1_test.dart
@@ -54,8 +54,8 @@
specialB(o) => add(o);
}
-class IntBoolConverter1 extends Converter<List<int>, List<bool>> {
- List<bool> convert(List<int> input) => input.map((x) => x > 0).toList();
+class IntBoolConverter1 extends Converter<int, bool> {
+ bool convert(int input) => input > 0;
startChunkedConversion(sink) {
if (sink is! MyChunkedBoolSink) sink = new MyChunkedBoolSink.from(sink);
@@ -63,8 +63,8 @@
}
}
-class BoolIntConverter1 extends Converter<List<bool>, List<int>> {
- List<int> convert(List<bool> input) => input.map((x) => x ? 1 : 0).toList();
+class BoolIntConverter1 extends Converter<bool, int> {
+ int convert(bool input) => input ? 1 : 0;
startChunkedConversion(sink) {
if (sink is! MyChunkedIntSink) sink = new MyChunkedIntSink.from(sink);
@@ -125,7 +125,8 @@
// Test int->bool converter individually.
converter1 = new IntBoolConverter1();
- Expect.listEquals([true, false, true], converter1.convert([2, -2, 2]));
+ Expect.listEquals([true, false, true],
+ [2, -2, 2].map(converter1.convert).toList());
hasExecuted = false;
boolSink = new MyChunkedBoolSink.withCallback((value) {
hasExecuted = true;
@@ -143,7 +144,8 @@
// Test bool->int converter individually.
converter2 = new BoolIntConverter1();
- Expect.listEquals([1, 0, 1], converter2.convert([true, false, true]));
+ Expect.listEquals([1, 0, 1],
+ [true, false, true].map(converter2.convert).toList());
hasExecuted = false;
intSink = new MyChunkedIntSink.withCallback((value) {
hasExecuted = true;
@@ -174,7 +176,7 @@
// Test fused converters.
fused = converter1.fuse(converter2);
- Expect.listEquals([1, 0, 1], fused.convert([2, -2, 2]));
+ Expect.listEquals([1, 0, 1], [2, -2, 2].map(fused.convert).toList());
hasExecuted = false;
intSink2 = new MyChunkedIntSink.withCallback((value) {
hasExecuted = true;
@@ -234,7 +236,7 @@
// With identity between the two converters.
fused = converter1.fuse(converter3).fuse(converter2);
- Expect.listEquals([1, 0, 1], fused.convert([2, -2, 2]));
+ Expect.listEquals([1, 0, 1], [2, -2, 2].map(fused.convert).toList());
hasExecuted = false;
intSink2 = new MyChunkedIntSink.withCallback((value) {
hasExecuted = true;
diff --git a/tests/lib/lib.status b/tests/lib/lib.status
index 3d000bd..34a3a77 100644
--- a/tests/lib/lib.status
+++ b/tests/lib/lib.status
@@ -333,6 +333,48 @@
profiler/metrics_test: Fail # Issue 20309
profiler/metrics_num_test: Fail # Issue 20309
+# Issue #28236
+async/first_regression_test: StaticWarning
+async/future_timeout_test: StaticWarning
+async/multiple_timer_test: StaticWarning
+async/schedule_microtask2_test: StaticWarning
+async/schedule_microtask3_test: StaticWarning
+async/schedule_microtask5_test: StaticWarning
+async/stream_controller_async_test: StaticWarning
+async/stream_first_where_test: StaticWarning
+async/stream_from_iterable_test: StaticWarning
+async/stream_iterator_test: StaticWarning
+async/stream_join_test: StaticWarning
+async/stream_last_where_test: StaticWarning
+async/stream_periodic2_test: StaticWarning
+async/stream_periodic3_test: StaticWarning
+async/stream_periodic4_test: StaticWarning
+async/stream_periodic5_test: StaticWarning
+async/stream_periodic6_test: StaticWarning
+async/stream_periodic_test: StaticWarning
+async/stream_single_test: StaticWarning
+async/stream_single_to_multi_subscriber_test: StaticWarning
+async/stream_state_nonzero_timer_test: StaticWarning
+async/stream_state_test: StaticWarning
+async/stream_subscription_as_future_test: StaticWarning
+async/stream_subscription_cancel_test: StaticWarning
+async/stream_timeout_test: StaticWarning
+async/stream_transform_test: StaticWarning
+async/stream_transformation_broadcast_test: StaticWarning
+async/timer_cancel1_test: StaticWarning
+async/timer_cancel2_test: StaticWarning
+async/timer_cancel_test: StaticWarning
+async/timer_isActive_test: StaticWarning
+async/timer_repeat_test: StaticWarning
+async/timer_test: StaticWarning
+convert/json_lib_test: StaticWarning
+js/null_test: StaticWarning
+math/point_test: StaticWarning
+math/rectangle_test: StaticWarning
+mirrors/library_uri_io_test: StaticWarning
+mirrors/library_uri_package_test: StaticWarning
+
+
[ ($compiler == dartanalyzer || $compiler == dart2analyzer) && $checked ]
mirrors/regress_16321_test/01: MissingCompileTimeError # Issue 16391
@@ -343,8 +385,8 @@
[ $compiler == dart2js && $mode == debug ]
mirrors/native_class_test: Pass, Slow
-[ ($compiler == none || $compiler == precompiler || $compiler == app_jit) && $arch == mips ]
-async/timer_regress22626_test: Pass, RuntimeError # Issue 22626
+[ ($compiler == none || $compiler == precompiler || $compiler == app_jit) ]
+async/timer_regress22626_test: Pass, RuntimeError # Issue 28254
[ $arch == simarm || $arch == simarmv6 || $arch == simarmv5te ]
convert/chunked_conversion_utf88_test: Skip # Pass, Slow Issue 12644.
@@ -426,6 +468,5 @@
[ $hot_reload ]
mirrors/generic_bounded_test/02: Fail # Type equality - Issue 26869
-mirrors/typedef_reflected_type_test/01: Fail # Type equality - Issue 26869
mirrors/generic_bounded_by_type_parameter_test/02: Fail # Type equality - Issue 26869
async/timer_regress22626_test: Pass, RuntimeError # Timing dependent.
diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
index 8a8d681..7c3295d 100644
--- a/tests/standalone/io/file_test.dart
+++ b/tests/standalone/io/file_test.dart
@@ -584,6 +584,28 @@
});
}
+ static void testWriteFromOffset() {
+ Directory tmp;
+ RandomAccessFile raf;
+ try {
+ tmp = tempDirectory.createTempSync('write_from_offset_test_');
+ File f = new File('${tmp.path}/file')..createSync();
+ f.writeAsStringSync('pre-existing content\n', flush: true);
+ raf = f.openSync(mode: FileMode.APPEND);
+ String truth = "Hello world";
+ raf.writeFromSync(UTF8.encode('Hello world'), 2, 5);
+ raf.flushSync();
+ Expect.equals(f.readAsStringSync(), 'pre-existing content\nllo');
+ } finally {
+ if (raf != null) {
+ raf.closeSync();
+ }
+ if (tmp != null) {
+ tmp.deleteSync(recursive: true);
+ }
+ }
+ }
+
static void testDirectory() {
asyncTestStarted();
var tempDir = tempDirectory.path;
@@ -642,6 +664,23 @@
openedFile.closeSync();
}
+ static void testLengthSyncDirectory() {
+ Directory tmp = tempDirectory.createTempSync('file_length_test_');
+ String dirPath = '${tmp.path}/dir';
+ new Directory(dirPath).createSync();
+ try {
+ new File(dirPath).lengthSync();
+ Expect.fail('Expected operation to throw');
+ } catch (e) {
+ if (e is! FileSystemException) {
+ print(e);
+ }
+ Expect.isTrue(e is FileSystemException);
+ } finally {
+ tmp.deleteSync(recursive: true);
+ }
+ }
+
// Test for file position functionality.
static void testPosition() {
asyncTestStarted();
@@ -1251,6 +1290,23 @@
Expect.isTrue(modified.isBefore(new DateTime.now()));
}
+ static void testLastModifiedSyncDirectory() {
+ Directory tmp = tempDirectory.createTempSync('file_last_modified_test_');
+ String dirPath = '${tmp.path}/dir';
+ new Directory(dirPath).createSync();
+ try {
+ new File(dirPath).lastModifiedSync();
+ Expect.fail('Expected operation to throw');
+ } catch (e) {
+ if (e is! FileSystemException) {
+ print(e);
+ }
+ Expect.isTrue(e is FileSystemException);
+ } finally {
+ tmp.deleteSync(recursive: true);
+ }
+ }
+
// Test that opens the same file for writing then for appending to test
// that the file is not truncated when opened for appending.
static void testAppend() {
@@ -1428,6 +1484,7 @@
createTempDirectory(() {
testLength();
+ testLengthSyncDirectory();
testReadWrite();
testReadWriteSync();
testReadWriteNoArgsSync();
@@ -1457,6 +1514,7 @@
testOutputStreamWriteAppend();
testOutputStreamWriteString();
testWriteVariousLists();
+ testWriteFromOffset();
testDirectory();
testDirectorySync();
testWriteStringUtf8();
@@ -1466,6 +1524,7 @@
testRename(targetExists: true);
testRenameSync(targetExists: true);
testLastModified();
+ testLastModifiedSyncDirectory();
testDoubleAsyncOperation();
asyncEnd();
});
diff --git a/tests/standalone/io/socket_ipv6_test.dart b/tests/standalone/io/socket_ipv6_test.dart
index 6b91957..8eaa662 100644
--- a/tests/standalone/io/socket_ipv6_test.dart
+++ b/tests/standalone/io/socket_ipv6_test.dart
@@ -129,13 +129,13 @@
});
}
-void main() {
- testIPv6toIPv6(); /// 01: ok
- testIPv4toIPv6(); /// 02: ok
- testIPv4toIPv4(); /// 03: ok
- testIPv6Lookup(); /// 04: ok
- testIPv4Lookup(); /// 05: ok
+main() async {
+ await testIPv6toIPv6(); /// 01: ok
+ await testIPv4toIPv6(); /// 02: ok
+ await testIPv4toIPv4(); /// 03: ok
+ await testIPv6Lookup(); /// 04: ok
+ await testIPv4Lookup(); /// 05: ok
- retry(testIPv6toIPv4); /// 06: ok
- retry(testIPv4toIPv6_IPV6Only); /// 07: ok
+ await retry(testIPv6toIPv4); /// 06: ok
+ await retry(testIPv4toIPv6_IPV6Only); /// 07: ok
}
diff --git a/tests/standalone/io/test_utils.dart b/tests/standalone/io/test_utils.dart
index c8bf0ce..ace6603 100644
--- a/tests/standalone/io/test_utils.dart
+++ b/tests/standalone/io/test_utils.dart
@@ -13,15 +13,21 @@
return port;
}
+int lastRetryId = 0;
+
Future retry(Future fun(), {int maxCount: 10}) async {
+ final int id = lastRetryId++;
for (int i = 0; i < maxCount; i++) {
try {
// If there is no exception this will simply return, otherwise we keep
// trying.
return await fun();
- } catch (_) {}
- print("Failed to execute test closure in attempt $i "
- "(${maxCount - i} retries left).");
+ } catch (e, stack) {
+ print("Failed to execute test closure (retry id: ${id}) in attempt $i "
+ "(${maxCount - i} retries left).");
+ print("Exception: ${e}");
+ print("Stacktrace: ${stack}");
+ }
}
return await fun();
}
diff --git a/tests/standalone/standalone.status b/tests/standalone/standalone.status
index 1630b8e..eb4a550 100644
--- a/tests/standalone/standalone.status
+++ b/tests/standalone/standalone.status
@@ -86,6 +86,19 @@
# This is runtime test.
io/process_exit_negative_test: Skip
+# Issue #28236
+io/addlatexhash_test: StaticWarning
+io/http_auth_digest_test: StaticWarning
+io/http_auth_test: StaticWarning
+io/http_proxy_advanced_test: StaticWarning
+io/http_proxy_test: StaticWarning
+io/skipping_dart2js_compilations_test: StaticWarning
+io/sleep_test: StaticWarning
+io/test_harness_analyzer_test: StaticWarning
+io/test_runner_test: StaticWarning
+io/web_socket_compression_test: StaticWarning
+io/web_socket_test: StaticWarning
+
[ $compiler == dart2js ]
number_identity_test: Skip # Bigints and int/double diff. not supported.
typed_data_test: Skip # dart:typed_data support needed.
@@ -200,6 +213,7 @@
io/process_sync_test: Pass, Timeout # Issue 24596
io/sleep_test: Pass, Fail # Issue 25757
io/socket_info_ipv6_test: RuntimeError # Issue 27876
+io/http_server_early_client_close2_test: Pass, Crash # Issue 28197
[ ($runtime == vm || $runtime == dart_precompiled) && $mode == debug && $builder_tag == asan ]
io/file_lock_test: Skip # Timeout.
diff --git a/tests/utils/utils.status b/tests/utils/utils.status
index fde7eba..1af3a26 100644
--- a/tests/utils/utils.status
+++ b/tests/utils/utils.status
@@ -31,3 +31,9 @@
[ $builder_tag == asan ]
recursive_import_test: Skip # Issue 27441
+
+[ $compiler == dart2analyzer ]
+# Issue #28236
+dart2js_test: StaticWarning
+dummy_compiler_test: StaticWarning
+recursive_import_test: StaticWarning
diff --git a/tools/FAKE_COMMITS b/tools/FAKE_COMMITS
index 34df009..db84018 100644
--- a/tools/FAKE_COMMITS
+++ b/tools/FAKE_COMMITS
@@ -20,3 +20,4 @@
Trigger bots after master restart - switch dart2js bots to use downloaded sdk.
Trigger bots after master restart.
Trigger mirroring of github repository
+Trigger mirroring of github repository
diff --git a/tools/VERSION b/tools/VERSION
index 5e7c910..275af21 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 1
MINOR 22
PATCH 0
-PRERELEASE 4
+PRERELEASE 5
PRERELEASE_PATCH 0
diff --git a/tools/bots/ddc_tests.py b/tools/bots/ddc_tests.py
index fc6830f..c7fe10d 100644
--- a/tools/bots/ddc_tests.py
+++ b/tools/bots/ddc_tests.py
@@ -22,11 +22,12 @@
if __name__ == '__main__':
with utils.ChangedWorkingDirectory('pkg/dev_compiler'):
- with bot.BuildStep('npm install'):
- bot.RunProcess(['npm', 'install'])
+ dart_exe = utils.CheckedInSdkExecutable()
- with bot.BuildStep('Compile tests and run unit tests'):
- bot.RunProcess([utils.CheckedInSdkExecutable(), 'test/all_tests.dart'])
+ # These two calls mirror pkg/dev_compiler/tool/test.sh.
+ bot.RunProcess([dart_exe, 'tool/build_pkgs.dart', 'test'])
+ bot.RunProcess([dart_exe, 'test/all_tests.dart'])
- with bot.BuildStep('Execute compiled tests'):
- bot.RunProcess(['npm', 'test'])
+ # These mirror pkg/dev_compiler/tool/browser_test.sh.
+ bot.RunProcess(['npm', 'install'])
+ bot.RunProcess(['npm', 'test'])
diff --git a/tools/deps/dartium.deps/DEPS b/tools/deps/dartium.deps/DEPS
index 9192aaf..6b2e0f6 100644
--- a/tools/deps/dartium.deps/DEPS
+++ b/tools/deps/dartium.deps/DEPS
@@ -47,7 +47,7 @@
"oauth2_rev": "@1bff41f4d54505c36f2d1a001b83b8b745c452f5",
"observatory_pub_packages_rev": "@26aad88f1c1915d39bbcbff3cad589e2402fdcf1",
"package_config_rev": "@0.1.3",
- "package_resolver_tag": "@1.0.2",
+ "package_resolver_tag": "@1.0.2+1",
"path_rev": "@b657c0854d1cf41c014986fa9d2321f1173df805",
"plugin_tag": "@0.1.0",
"pool_rev": "@22e12aeb16ad0b626900dbe79e4a25391ddfb28c",
diff --git a/tools/dom/src/dart2js_CssClassSet.dart b/tools/dom/src/dart2js_CssClassSet.dart
index 087685f..758419d 100644
--- a/tools/dom/src/dart2js_CssClassSet.dart
+++ b/tools/dom/src/dart2js_CssClassSet.dart
@@ -140,6 +140,7 @@
return value is String && _classListContains(_classListOf(_element), value);
}
+ @ForceInline()
static bool _add(Element _element, String value) {
DomTokenList list = _classListOf(_element);
// Compute returned result independently of action upon the set.
@@ -148,6 +149,7 @@
return added;
}
+ @ForceInline()
static bool _remove(Element _element, String value) {
DomTokenList list = _classListOf(_element);
bool removed = _classListContainsBeforeAddOrRemove(list, value);
diff --git a/tools/gn.py b/tools/gn.py
index 93bbf1b..24e9380 100755
--- a/tools/gn.py
+++ b/tools/gn.py
@@ -90,14 +90,16 @@
gn_args['dart_zlib_path'] = "//runtime/bin/zlib"
# Use tcmalloc only when targeting Linux and when not using ASAN.
- gn_args['dart_use_tcmalloc'] = (gn_args['target_os'] == 'linux'
- and not args.asan)
+ gn_args['dart_use_tcmalloc'] = ((gn_args['target_os'] == 'linux')
+ and not args.asan
+ and not args.msan
+ and not args.tsan)
# Force -mfloat-abi=hard and -mfpu=neon on Linux as we're specifying
# a gnueabihf compiler in //build/toolchain/linux BUILD.gn.
# TODO(zra): This will likely need some adjustment to build for armv6 etc.
hard_float = (gn_args['target_cpu'].startswith('arm') and
- gn_args['target_os'] == 'linux')
+ (gn_args['target_os'] == 'linux'))
if hard_float:
gn_args['arm_float_abi'] = 'hard'
gn_args['arm_use_neon'] = True
@@ -114,17 +116,22 @@
# TODO(zra): Investigate using clang with these configurations.
# Clang compiles tcmalloc's inline assembly for ia32 on Linux wrong, so we
- # don't use clang in that configuration.
+ # don't use clang in that configuration. Thus, we use gcc for ia32 *unless*
+ # asan or tsan is specified.
has_clang = (host_os != 'win'
and args.os not in ['android']
- and not (gn_args['target_os'] == 'linux' and
- gn_args['host_cpu'] == 'x86' and
- not args.asan) # Use clang for asan builds.
and not gn_args['target_cpu'].startswith('arm')
- and not gn_args['target_cpu'].startswith('mips'))
+ and not gn_args['target_cpu'].startswith('mips')
+ and not ((gn_args['target_os'] == 'linux')
+ and (gn_args['host_cpu'] == 'x86')
+ and not args.asan
+ and not args.msan
+ and not args.tsan)) # Use clang for sanitizer builds.
gn_args['is_clang'] = args.clang and has_clang
gn_args['is_asan'] = args.asan and gn_args['is_clang']
+ gn_args['is_msan'] = args.msan and gn_args['is_clang']
+ gn_args['is_tsan'] = args.tsan and gn_args['is_clang']
# Setup the user-defined sysroot.
if gn_args['target_os'] == 'linux' and args.wheezy:
@@ -214,11 +221,18 @@
# Environment variables for default settings.
DART_USE_ASAN = "DART_USE_ASAN"
+DART_USE_MSAN = "DART_USE_MSAN"
+DART_USE_TSAN = "DART_USE_TSAN"
DART_USE_WHEEZY = "DART_USE_WHEEZY"
def use_asan():
return DART_USE_ASAN in os.environ
+def use_msan():
+ return DART_USE_MSAN in os.environ
+
+def use_tsan():
+ return DART_USE_TSAN in os.environ
def use_wheezy():
return DART_USE_WHEEZY in os.environ
@@ -226,70 +240,91 @@
def parse_args(args):
args = args[1:]
- parser = argparse.ArgumentParser(description='A script to run `gn gen`.')
+ parser = argparse.ArgumentParser(
+ description='A script to run `gn gen`.',
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+ common_group = parser.add_argument_group('Common Arguments')
+ other_group = parser.add_argument_group('Other Arguments')
- parser.add_argument("-v", "--verbose",
- help='Verbose output.',
- default=False, action="store_true")
- parser.add_argument('--mode', '-m',
- type=str,
- help='Build variants (comma-separated).',
- metavar='[all,debug,release,product]',
- default='debug')
- parser.add_argument('--os',
- type=str,
- help='Target OSs (comma-separated).',
- metavar='[all,host,android]',
- default='host')
- parser.add_argument('--arch', '-a',
+ common_group.add_argument('--arch', '-a',
type=str,
help='Target architectures (comma-separated).',
metavar='[all,ia32,x64,simarm,arm,simarmv6,armv6,simarmv5te,armv5te,'
'simmips,mips,simarm64,arm64,simdbc,armsimdbc]',
default='x64')
- parser.add_argument('--asan',
+ common_group.add_argument('--mode', '-m',
+ type=str,
+ help='Build variants (comma-separated).',
+ metavar='[all,debug,release,product]',
+ default='debug')
+ common_group.add_argument('--os',
+ type=str,
+ help='Target OSs (comma-separated).',
+ metavar='[all,host,android]',
+ default='host')
+ common_group.add_argument("-v", "--verbose",
+ help='Verbose output.',
+ default=False, action="store_true")
+
+ other_group.add_argument('--asan',
help='Build with ASAN',
default=use_asan(),
action='store_true')
- parser.add_argument('--no-asan',
+ other_group.add_argument('--no-asan',
help='Disable ASAN',
dest='asan',
action='store_false')
- parser.add_argument('--wheezy',
- help='Use the Debian wheezy sysroot on Linux',
- default=use_wheezy(),
- action='store_true')
- parser.add_argument('--no-wheezy',
- help='Disable the Debian wheezy sysroot on Linux',
- dest='wheezy',
- action='store_false')
- parser.add_argument('--goma',
- help='Use goma',
- default=True,
- action='store_true')
- parser.add_argument('--no-goma',
- help='Disable goma',
- dest='goma',
- action='store_false')
- parser.add_argument('--clang',
+ other_group.add_argument('--clang',
help='Use Clang',
default=True,
action='store_true')
- parser.add_argument('--no-clang',
+ other_group.add_argument('--no-clang',
help='Disable Clang',
dest='clang',
action='store_false')
- parser.add_argument('--ide',
+ other_group.add_argument('--goma',
+ help='Use goma',
+ default=True,
+ action='store_true')
+ other_group.add_argument('--no-goma',
+ help='Disable goma',
+ dest='goma',
+ action='store_false')
+ other_group.add_argument('--ide',
help='Generate an IDE file.',
default=os_has_ide(HOST_OS),
action='store_true')
- parser.add_argument('--target-sysroot', '-s',
+ other_group.add_argument('--msan',
+ help='Build with MSAN',
+ default=use_msan(),
+ action='store_true')
+ other_group.add_argument('--no-msan',
+ help='Disable MSAN',
+ dest='msan',
+ action='store_false')
+ other_group.add_argument('--target-sysroot', '-s',
type=str,
help='Path to the toolchain sysroot')
- parser.add_argument('--toolchain-prefix', '-t',
+ other_group.add_argument('--toolchain-prefix', '-t',
type=str,
help='Path to the toolchain prefix')
- parser.add_argument('--workers', '-w',
+ other_group.add_argument('--tsan',
+ help='Build with TSAN',
+ default=use_tsan(),
+ action='store_true')
+ other_group.add_argument('--no-tsan',
+ help='Disable TSAN',
+ dest='tsan',
+ action='store_false')
+ other_group.add_argument('--wheezy',
+ help='Use the Debian wheezy sysroot on Linux',
+ default=use_wheezy(),
+ action='store_true')
+ other_group.add_argument('--no-wheezy',
+ help='Disable the Debian wheezy sysroot on Linux',
+ dest='wheezy',
+ action='store_false')
+ other_group.add_argument('--workers', '-w',
type=int,
help='Number of simultaneous GN invocations',
dest='workers',
diff --git a/tools/gyp/all.gypi b/tools/gyp/all.gypi
index 980b5c5..1db7dea 100644
--- a/tools/gyp/all.gypi
+++ b/tools/gyp/all.gypi
@@ -16,6 +16,8 @@
'asan%': 0,
# Flag that tells us whether this is a MSAN build.
'msan%': 0,
+ # Flag that teslls us whether this is a TSAN build.
+ 'tsan%': 0,
},
'conditions': [
[ 'OS=="linux"', {
diff --git a/tools/task_kill.py b/tools/task_kill.py
index ab07e8a..ed8b555 100755
--- a/tools/task_kill.py
+++ b/tools/task_kill.py
@@ -63,6 +63,12 @@
'linux': POSIX_INFO,
}
+STACK_INFO_COMMAND = {
+ 'win32': None,
+ 'macos': '/usr/bin/sample %s 1 4000 -mayDie',
+ 'linux': '/usr/bin/eu-stack -p %s',
+}
+
def GetOptions():
parser = optparse.OptionParser("usage: %prog [options]")
parser.add_option("--kill_dart", default=True,
@@ -124,7 +130,26 @@
else:
return GetPidsPosix(process_name)
-def PrintPidInfo(pid):
+def PrintPidStackInfo(pid):
+ command_pattern = STACK_INFO_COMMAND.get(os_name, False)
+ if command_pattern:
+ p = subprocess.Popen(command_pattern % pid,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=True)
+ stdout, stderr = p.communicate()
+ stdout = stdout.splitlines()
+ stderr = stderr.splitlines()
+
+ print " Stack:"
+ for line in stdout:
+ print " %s" % line
+ if stderr:
+ print " Stack (stderr):"
+ for line in stderr:
+ print " %s" % line
+
+def PrintPidInfo(pid, dump_stacks):
# We assume that the list command will return lines in the format:
# EXECUTABLE_PATH ARGS
# There may be blank strings in the output
@@ -137,13 +162,15 @@
# Pop the header
lines.pop(0)
+
+ print "Hanging process info:"
+ print " PID: %s" % pid
for line in lines:
# wmic will output a bunch of empty strings, we ignore these
- if len(line) >= 1:
- print("Hanging process info:")
- print(" PID: %s" % pid)
- print(" Command line: %s" % line)
+ if line: print " Command line: %s" % line
+ if dump_stacks:
+ PrintPidStackInfo(pid)
def KillPosix(pid):
try:
@@ -161,14 +188,14 @@
shell=True)
p.communicate()
-def Kill(name):
+def Kill(name, dump_stacks=False):
if name not in EXECUTABLE_NAMES[os_name]:
return 0
print("***************** Killing %s *****************" % name)
platform_name = EXECUTABLE_NAMES[os_name][name]
pids = GetPids(platform_name)
for pid in pids:
- PrintPidInfo(pid)
+ PrintPidInfo(pid, dump_stacks)
if os_name == "win32":
KillWindows(pid)
else:
@@ -194,7 +221,7 @@
return status
def KillDart():
- status = Kill("dart")
+ status = Kill("dart", dump_stacks=True)
return status
def KillFletch():