Remove old_frontend and mirrors tests
Change-Id: I1e10d65c25298eb084619ed156daa3d2069f92e1
Reviewed-on: https://dart-review.googlesource.com/53741
Reviewed-by: Sigmund Cherem <sigmund@google.com>
diff --git a/pkg/compiler/testing.json b/pkg/compiler/testing.json
index e2ef599..d5fb717 100644
--- a/pkg/compiler/testing.json
+++ b/pkg/compiler/testing.json
@@ -14,9 +14,7 @@
],
"exclude": [
- "^tests/compiler/dart2js/inference/data/super_invoke\\.dart",
- "^tests/compiler/dart2js/old_frontend/data/.*",
- "^tests/compiler/dart2js/path with spaces/.*"
+ "^tests/compiler/dart2js/inference/data/super_invoke\\.dart"
]
}
}
diff --git a/pkg/compiler/testing_dart.json b/pkg/compiler/testing_dart.json
index f36c8ad..1b68d8b 100644
--- a/pkg/compiler/testing_dart.json
+++ b/pkg/compiler/testing_dart.json
@@ -38,23 +38,12 @@
"^tests/compiler/dart2js/kernel/closed_world_test\\.dart",
"^tests/compiler/dart2js/kernel/visitor_test\\.dart",
"^tests/compiler/dart2js/memory_compiler\\.dart",
- "^tests/compiler/dart2js/mirrors/data/mirrors_helper\\.dart",
- "^tests/compiler/dart2js/mirrors/deferred_mirrors_test\\.dart",
- "^tests/compiler/dart2js/mirrors/mirrors_used_test\\.dart",
"^tests/compiler/dart2js/mixin_typevariable_test\\.dart",
"^tests/compiler/dart2js/model/constant_expression_evaluate_test\\.dart",
"^tests/compiler/dart2js/model/constant_expression_test\\.dart",
"^tests/compiler/dart2js/needs_no_such_method_test\\.dart",
"^tests/compiler/dart2js/no_such_method_enabled_test\\.dart",
"^tests/compiler/dart2js/output_collector\\.dart",
- "^tests/compiler/dart2js/old_frontend/data/one_line_dart_program\\.dart",
- "^tests/compiler/dart2js/old_frontend/message_kind_helper\\.dart",
- "^tests/compiler/dart2js/old_frontend/metadata_test\\.dart",
- "^tests/compiler/dart2js/old_frontend/patch_test\\.dart",
- "^tests/compiler/dart2js/old_frontend/reexport_handled_test\\.dart",
- "^tests/compiler/dart2js/old_frontend/resolution_test\\.dart",
- "^tests/compiler/dart2js/quarantined/http_launch_data/http_launch_main_package\\.dart",
- "^tests/compiler/dart2js/quarantined/http_test\\.dart",
"^tests/compiler/dart2js/rti/data/future_or_future_or_generic_strong\\.dart",
"^tests/compiler/dart2js/rti/data/future_or_future_or_strong\\.dart",
"^tests/compiler/dart2js/rti/data/future_or_generic2_strong\\.dart",
@@ -78,9 +67,7 @@
"^tests/compiler/dart2js/token_naming_test\\.dart",
"^tests/compiler/dart2js/type_representation_test\\.dart",
"^tests/compiler/dart2js/type_variable_occurrence_test\\.dart",
- "^tests/compiler/dart2js/unused_empty_map_test\\.dart",
-
- "^tests/compiler/dart2js/path with spaces/.*"
+ "^tests/compiler/dart2js/unused_empty_map_test\\.dart"
]
}
}
diff --git a/tests/compiler/dart2js/dart2js.status b/tests/compiler/dart2js/dart2js.status
index d7f0004..66b9211 100644
--- a/tests/compiler/dart2js/dart2js.status
+++ b/tests/compiler/dart2js/dart2js.status
@@ -25,21 +25,9 @@
kernel/*: Slow, Pass
kernel/compile_from_dill_fast_startup_test: RuntimeError # Test must be updated to support FE with patching.
kernel/compile_from_dill_test: RuntimeError # Test must be updated to support FE with patching.
-mirrors/library_exports_hidden_test: Fail
-mirrors/library_exports_shown_test: Fail
-mirrors/library_imports_hidden_test: Fail
-mirrors/library_imports_prefixed_show_hide_test: Fail # Issue 32057
-mirrors/library_imports_prefixed_test: Fail
-mirrors/library_imports_shown_test: Fail
model/subtype_test: Pass, Slow
no_such_method_enabled_test: Pass, Slow
-old_frontend/bad_loop_test: RuntimeError
-old_frontend/check_elements_invariants_test: Skip # Times out even with Slow marker. Slow due to inlining in the CPS backend
-old_frontend/compile_with_empty_libraries_test: Fail # Issue 24223
-old_frontend/patch_test/bug: RuntimeError # Issue 21132
-old_frontend/resolver_test: RuntimeError # Test must be updated given new parser recovery
packages/*: Skip # Skip packages folder
-quarantined/http_test: RuntimeError # not supported with CFE, consider deleting.
rti/rti_emission_test: Pass, Slow
rti/rti_need0_test: Pass, Slow
rti/rti_need1_test: Pass, Slow
@@ -56,14 +44,6 @@
end_to_end/dart2js_batch_test: Pass, Slow
end_to_end/exit_code_test: Pass, Slow
in_user_code_test: Pass, Slow
-mirrors/deferred_mirrors_test: Pass, Slow
-mirrors/import_mirrors_test: Pass, Slow
-mirrors/mirror_final_field_inferrer2_test: Crash, Pass, Slow # Issue 15581
-old_frontend/analyze_api_test: Pass, Slow # DON'T CHANGE THIS LINE -- Don't mark these tests as failing. Instead, fix the errors/warnings that they report or update the whitelist in the test-files to temporarily allow digression.
-old_frontend/check_elements_invariants_test: Skip # Slow and only needs to be run in one configuration
-old_frontend/check_members_test: Pass, Slow
-old_frontend/duplicate_library_test: Pass, Slow
-old_frontend/message_kind_test: Pass, Slow
show_package_warnings_test: Pass, Slow
sourcemaps/source_map_pub_build_validity_test: Pass, Slow
@@ -78,12 +58,6 @@
jsinterop/interop_anonymous_unreachable_test: Pass, Slow
jsinterop/world_test: Pass, Slow
kernel/visitor_test: Pass, Slow
-mirrors/deferred_mirrors_test: Pass, Slow
-mirrors/import_mirrors_test: Slow, Pass
-mirrors/mirror_final_field_inferrer2_test: Pass, Slow
-mirrors/preserve_uris_test: Pass, Slow
-old_frontend/analyze_dart2js_helpers_test: Pass, Slow
-old_frontend/duplicate_library_test: Pass, Slow
output_type_test: Pass, Slow
sourcemaps/source_map_pub_build_validity_test: Pass, Slow
sourcemaps/stacktrace_test: Pass, Slow
diff --git a/tests/compiler/dart2js/mirrors/array_tracing_mirror_test.dart b/tests/compiler/dart2js/mirrors/array_tracing_mirror_test.dart
deleted file mode 100644
index bb819cb..0000000
--- a/tests/compiler/dart2js/mirrors/array_tracing_mirror_test.dart
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Make sure that limiting mirrors through @MirrorsUsed does not
-// affect optimizations done on arrays.
-
-import 'package:expect/expect.dart';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import '../memory_compiler.dart';
-
-const MEMORY_SOURCE_FILES = const {
- 'main.dart': '''
-
-@MirrorsUsed(targets: 'main')
-import 'dart:mirrors';
-class A {
- var field;
-}
-
-main() {
- var a = new A();
- var mirror = reflect(a);
- var array = [42, 42];
- a.field = array;
- var field = mirror.getField(#field);
- field.invoke(#clear, []);
- return array.length;
-}
-''',
-};
-
-main() {
- asyncTest(() async {
- var result = await runCompiler(
- memorySourceFiles: MEMORY_SOURCE_FILES,
- options: [Flags.useOldFrontend]);
- var compiler = result.compiler;
- var element = compiler.frontendStrategy.elementEnvironment.mainFunction;
- var code = compiler.backend.getGeneratedCode(element);
- Expect.isTrue(code.contains('return 2'), "Unexpected code:\n$code");
- });
-}
diff --git a/tests/compiler/dart2js/mirrors/data/mirrors_helper.dart b/tests/compiler/dart2js/mirrors/data/mirrors_helper.dart
deleted file mode 100644
index b8de0ac..0000000
--- a/tests/compiler/dart2js/mirrors/data/mirrors_helper.dart
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2012, 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.
-
-/**
- * This file is read by 'mirrors_test.dart'.
- */
-
-library mirrors_helper;
-
-typedef E Func<E, F extends Foo>(F f);
-
-main() {}
-
-/// Singleline doc comment.
-@Metadata(null)
-// Singleline comment 1.
-// Singleline comment 2.
-@Metadata(true)
-@Metadata(false)
-@Metadata(0)
-@Metadata(1.5)
-@Metadata("Foo")
-@Metadata(const ["Foo"])
-@Metadata(const {'foo': "Foo"})
-@metadata
-/** Multiline doc comment. */
-/* Multiline comment. */ class Foo {
- m(@metadata a) {}
-}
-
-abstract class Bar<E> {}
-
-class Baz<E, F extends Foo> implements Bar<E> {
- Baz();
- const Baz.named();
- factory Baz.factory() => new Baz<E, F>();
-
- static method1(e) {}
- void method2(E e, [F f = null]) {}
- Baz<E, F> method3(E func1(F f), Func<E, F> func2) => null;
-
- bool operator ==(Object other) => false;
- int operator -() => 0;
- operator$foo() {}
-}
-
-class Boz extends Foo {
- var field1;
- int _field2;
- final String field3 = "field3";
-
- int get field2 => _field2;
- void set field2(int value) {
- _field2 = value;
- }
-}
-
-// ignore: UNUSED_ELEMENT
-class _PrivateClass {
- var _privateField;
- // ignore: UNUSED_ELEMENT
- get _privateGetter => _privateField;
- // ignore: UNUSED_ELEMENT
- void set _privateSetter(value) => _privateField = value;
- // ignore: UNUSED_ELEMENT
- void _privateMethod() {}
- _PrivateClass._privateConstructor();
- factory _PrivateClass._privateFactoryConstructor() => null;
-}
-
-const metadata = const Metadata(null);
-
-class Metadata {
- final data;
- const Metadata(this.data);
-}
diff --git a/tests/compiler/dart2js/mirrors/deferred_mirrors_test.dart b/tests/compiler/dart2js/mirrors/deferred_mirrors_test.dart
deleted file mode 100644
index bfff8f1..0000000
--- a/tests/compiler/dart2js/mirrors/deferred_mirrors_test.dart
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright (c) 2014, 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.
-
-// Test of the graph segmentation algorithm used by deferred loading
-// to determine which elements can be deferred and which libraries
-// much be included in the initial download (loaded eagerly).
-
-import 'dart:async';
-import 'package:expect/expect.dart';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import '../memory_compiler.dart';
-
-Future runTest(String mainScript, test) async {
- CompilationResult result = await runCompiler(
- entryPoint: Uri.parse(mainScript),
- memorySourceFiles: MEMORY_SOURCE_FILES,
- options: [Flags.useOldFrontend]);
- test(result.compiler);
-}
-
-lookupLibrary(compiler, name) {
- return compiler.libraryLoader.lookupLibrary(Uri.parse(name));
-}
-
-void main() {
- asyncTest(runTests);
-}
-
-runTests() async {
- await runTest('memory:main.dart', (compiler) {
- var main = compiler.frontendStrategy.elementEnvironment.mainFunction;
- Expect.isNotNull(main, "Could not find 'main'");
- var outputUnitForEntity =
- compiler.backend.outputUnitData.outputUnitForEntity;
-
- var lib1 = lookupLibrary(compiler, "memory:lib1.dart");
- var lib2 = lookupLibrary(compiler, "memory:lib2.dart");
- var mathLib = lookupLibrary(compiler, "dart:math");
- var sin = mathLib.find('sin');
- var foo1 = lib1.find("foo1");
- var foo2 = lib2.find("foo2");
- var field2 = lib2.find("field2");
-
- Expect.notEquals(outputUnitForEntity(main), outputUnitForEntity(foo1));
- Expect.equals(outputUnitForEntity(main), outputUnitForEntity(sin));
- Expect.equals(outputUnitForEntity(foo2), outputUnitForEntity(field2));
- });
- await runTest('memory:main2.dart', (compiler) {
- // Just check that the compile runs.
- // This is a regression test.
- Expect.isTrue(true);
- });
- await runTest('memory:main3.dart', (compiler) {
- var main = compiler.frontendStrategy.elementEnvironment.mainFunction;
- Expect.isNotNull(main, "Could not find 'main'");
- var outputUnitForEntity =
- compiler.backend.outputUnitData.outputUnitForEntity;
-
- Expect.isFalse(compiler.backend.mirrorsData.hasInsufficientMirrorsUsed);
- var mainLib = lookupLibrary(compiler, "memory:main3.dart");
- var lib3 = lookupLibrary(compiler, "memory:lib3.dart");
- var C = mainLib.find("C");
- var foo = lib3.find("foo");
-
- Expect.notEquals(outputUnitForEntity(main), outputUnitForEntity(foo));
- Expect.equals(outputUnitForEntity(main), outputUnitForEntity(C));
- });
- await runTest('memory:main4.dart', (compiler) {
- var main = compiler.frontendStrategy.elementEnvironment.mainFunction;
- Expect.isNotNull(main, "Could not find 'main'");
- var outputUnitForEntity =
- compiler.backend.outputUnitData.outputUnitForEntity;
-
- lookupLibrary(compiler, "memory:main4.dart");
- lookupLibrary(compiler, "memory:lib4.dart");
- var lib5 = lookupLibrary(compiler, "memory:lib5.dart");
- var lib6 = lookupLibrary(compiler, "memory:lib6.dart");
- var foo5 = lib5.find("foo");
- var foo6 = lib6.find("foo");
-
- Expect.notEquals(outputUnitForEntity(main), outputUnitForEntity(foo5));
- Expect.equals(outputUnitForEntity(foo5), outputUnitForEntity(foo6));
- });
-}
-
-// "lib1.dart" uses mirrors without a MirrorsUsed annotation, so everything
-// should be put in the "lib1" output unit.
-const Map MEMORY_SOURCE_FILES = const {
- "main.dart": """
-import "dart:math";
-
-import 'lib1.dart' deferred as lib1;
-import 'lib2.dart' deferred as lib2;
-
-void main() {
- lib1.loadLibrary().then((_) {
- lib1.foo1();
- });
- lib2.loadLibrary().then((_) {
- lib2.foo2();
- });
-}
-""",
- "lib1.dart": """
-library lib1;
-import "dart:mirrors";
-
-const field1 = 42;
-
-void foo1() {
- var mirror = reflect(field1);
- mirror.invoke(null, null);
-}
-""",
- "lib2.dart": """
-library lib2;
-@MirrorsUsed(targets: "field2") import "dart:mirrors";
-
-const field2 = 42;
-
-void foo2() {
- var mirror = reflect(field2);
- mirror.invoke(null, null);
-}
-""",
-// The elements C and f are named as targets, but there is no actual use of
-// mirrors.
- "main2.dart": """
-import "lib.dart" deferred as lib;
-
-@MirrorsUsed(targets: const ["C", "f"])
-import "dart:mirrors";
-
-class C {}
-
-var f = 3;
-
-void main() {
-
-}
-""",
- "lib.dart": """ """,
-// Lib3 has a MirrorsUsed annotation with a library.
-// Check that that is handled correctly.
- "main3.dart": """
-library main3;
-
-import "lib3.dart" deferred as lib;
-
-class C {}
-
-class D {}
-
-f() {}
-
-void main() {
- lib.loadLibrary().then((_) {
- lib.foo();
- });
-}
-""",
- "lib3.dart": """
-@MirrorsUsed(targets: const ["main3.C"])
-import "dart:mirrors";
-
-foo() {
- currentMirrorSystem().findLibrary(#main3);
-}
-""",
-// Check that exports and imports are handled correctly with mirrors.
- "main4.dart": """
-library main3;
-
-@MirrorsUsed(targets: const ["lib5.foo","lib6.foo"])
-import "dart:mirrors";
-
-import "lib4.dart" deferred as lib;
-
-void main() {
- lib.loadLibrary().then((_) {
- currentMirrorSystem().findLibrary(#lib5);
- });
-}
-""",
- "lib4.dart": """
-import "lib5.dart";
-export "lib6.dart";
-
-""",
- "lib5.dart": """
-library lib5;
-
-foo() {}
-""",
- "lib6.dart": """
-library lib6;
-
-foo() {}
-""",
-};
diff --git a/tests/compiler/dart2js/mirrors/import_mirrors_test.dart b/tests/compiler/dart2js/mirrors/import_mirrors_test.dart
deleted file mode 100644
index 5a2017f..0000000
--- a/tests/compiler/dart2js/mirrors/import_mirrors_test.dart
+++ /dev/null
@@ -1,376 +0,0 @@
-// Copyright (c) 2014, 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.
-
-// Test that the compiler emits a warning on import of 'dart:mirrors' unless
-// the flag --enable-experimental-mirrors is used.
-
-library dart2js.test.import_mirrors;
-
-import 'dart:async';
-import 'package:expect/expect.dart';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/diagnostics/messages.dart'
- show MessageKind, MessageTemplate;
-import '../memory_compiler.dart';
-
-const DIRECT_IMPORT = const {
- '/main.dart': '''
-import 'dart:mirrors';
-
-main() {}
-''',
- 'paths': "main.dart => dart:mirrors",
-};
-
-const INDIRECT_IMPORT1 = const {
- '/main.dart': '''
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': "first.dart => dart:mirrors",
- 'verbosePaths': "main.dart => first.dart => dart:mirrors",
-};
-
-const INDIRECT_IMPORT2 = const {
- '/main.dart': '''
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'second.dart';
-''',
- '/second.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': "second.dart => dart:mirrors",
- 'verbosePaths': "main.dart => first.dart => second.dart => dart:mirrors",
-};
-
-const INDIRECT_PACKAGE_IMPORT1 = const {
- '/main.dart': '''
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'package:second/second.dart';
-''',
- '/pkg/second/second.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': "first.dart => package:second => dart:mirrors",
- 'verbosePaths':
- "main.dart => first.dart => package:second/second.dart => dart:mirrors",
-};
-
-const INDIRECT_PACKAGE_IMPORT2 = const {
- '/main.dart': '''
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'package:packagename/second.dart';
-''',
- '/pkg/packagename/second.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': "first.dart => package:packagename => dart:mirrors",
- 'verbosePaths': "main.dart => first.dart => package:packagename/second.dart "
- "=> dart:mirrors",
-};
-
-const INDIRECT_PACKAGE_IMPORT3 = const {
- '/main.dart': '''
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'package:package1/second.dart';
-''',
- '/pkg/package1/second.dart': '''
-import 'package:package2/third.dart';
-''',
- '/pkg/package2/third.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': "first.dart => package:package1 => package:package2 => dart:mirrors",
- 'verbosePaths': "main.dart => first.dart => package:package1/second.dart "
- "=> package:package2/third.dart => dart:mirrors",
-};
-
-const INDIRECT_PACKAGE_IMPORT4 = const {
- '/main.dart': '''
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'package:package1/second.dart';
-''',
- '/pkg/package1/second.dart': '''
-import 'sub/third.dart';
-''',
- '/pkg/package1/sub/third.dart': '''
-import 'package:package2/fourth.dart';
-''',
- '/pkg/package2/fourth.dart': '''
-import 'lib/src/fifth.dart';
-''',
- '/pkg/package2/lib/src/fifth.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': "first.dart => package:package1 => package:package2 => dart:mirrors",
- 'verbosePaths': "main.dart => first.dart => package:package1/second.dart "
- "=> package:package1/sub/third.dart => package:package2/fourth.dart "
- "=> package:package2/lib/src/fifth.dart => dart:mirrors",
-};
-
-const DUAL_DIRECT_IMPORT = const {
- '/main.dart': '''
-import 'dart:mirrors';
-import 'dart:mirrors';
-
-main() {}
-''',
- 'paths': "main.dart => dart:mirrors",
-};
-
-const DUAL_INDIRECT_IMPORT1 = const {
- '/main.dart': '''
-import 'dart:mirrors';
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': const ["main.dart => dart:mirrors", "first.dart => dart:mirrors"],
- 'verbosePaths': const [
- "main.dart => dart:mirrors",
- "main.dart => first.dart => dart:mirrors"
- ],
-};
-
-const DUAL_INDIRECT_IMPORT2 = const {
- '/main.dart': '''
-import 'first.dart';
-import 'second.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'dart:mirrors';
-''',
- '/second.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': const ["first.dart => dart:mirrors", "second.dart => dart:mirrors"],
- 'verbosePaths': const [
- "main.dart => first.dart => dart:mirrors",
- "main.dart => second.dart => dart:mirrors"
- ],
-};
-
-const DUAL_INDIRECT_IMPORT3 = const {
- '/main.dart': '''
-import 'first.dart';
-import 'second.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'third.dart';
-''',
- '/second.dart': '''
-import 'third.dart';
-''',
- '/third.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': "third.dart => dart:mirrors",
- 'verbosePaths': const [
- "main.dart => first.dart => third.dart => dart:mirrors",
- "main.dart => second.dart => third.dart => dart:mirrors"
- ],
-};
-
-const DUAL_INDIRECT_PACKAGE_IMPORT1 = const {
- '/main.dart': '''
-import 'package:package1/second.dart';
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'package:package2/third.dart';
-''',
- '/pkg/package1/second.dart': '''
-import 'dart:mirrors';
-''',
- '/pkg/package2/third.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': const [
- "main.dart => package:package1 => dart:mirrors",
- "first.dart => package:package2 => dart:mirrors"
- ],
- 'verbosePaths': const [
- "main.dart => package:package1/second.dart => dart:mirrors",
- "main.dart => first.dart => package:package2/third.dart => dart:mirrors"
- ]
-};
-
-const DIRECT_EXPORT = const {
- '/main.dart': '''
-export 'dart:mirrors';
-
-main() {}
-''',
- 'paths': "main.dart => dart:mirrors",
-};
-
-const INDIRECT_EXPORT1 = const {
- '/main.dart': '''
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-export 'dart:mirrors';
-''',
- 'paths': "first.dart => dart:mirrors",
- 'verbosePaths': "main.dart => first.dart => dart:mirrors",
-};
-
-const INDIRECT_EXPORT2 = const {
- '/main.dart': '''
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'second.dart';
-''',
- '/second.dart': '''
-export 'dart:mirrors';
-''',
- 'paths': "second.dart => dart:mirrors",
- 'verbosePaths': "main.dart => first.dart => second.dart => dart:mirrors",
-};
-
-const INDIRECT_PACKAGE_EXPORT1 = const {
- '/main.dart': '''
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-import 'package:packagename/second.dart';
-''',
- '/pkg/packagename/second.dart': '''
-export 'dart:mirrors';
-''',
- 'paths': "first.dart => package:packagename => dart:mirrors",
- 'verbosePaths': "main.dart => first.dart => package:packagename/second.dart "
- "=> dart:mirrors",
-};
-
-const INDIRECT_PACKAGE_EXPORT2 = const {
- '/main.dart': '''
-import 'first.dart';
-
-main() {}
-''',
- '/first.dart': '''
-export 'package:packagename/second.dart';
-''',
- '/pkg/packagename/second.dart': '''
-import 'dart:mirrors';
-''',
- 'paths': "first.dart => package:packagename => dart:mirrors",
- 'verbosePaths': "main.dart => first.dart => package:packagename/second.dart "
- "=> dart:mirrors",
-};
-
-Future test(Map sourceFiles,
- {expectedPaths,
- bool verbose: false,
- bool enableExperimentalMirrors: false}) async {
- if (expectedPaths is! List) {
- expectedPaths = [expectedPaths];
- }
- var collector = new DiagnosticCollector();
- var options = [Flags.useOldFrontend];
- if (verbose) {
- options.add('--verbose');
- }
- if (enableExperimentalMirrors) {
- options.add('--enable-experimental-mirrors');
- }
- await runCompiler(
- entryPoint: Uri.parse('memory:/main.dart'),
- memorySourceFiles: sourceFiles,
- diagnosticHandler: collector,
- packageRoot: Uri.parse('memory:/pkg/'),
- options: options);
- Expect.equals(0, collector.errors.length, 'Errors: ${collector.errors}');
- if (enableExperimentalMirrors) {
- Expect.equals(
- 0, collector.warnings.length, 'Warnings: ${collector.errors}');
- } else {
- Expect.equals(
- 1, collector.warnings.length, 'Warnings: ${collector.errors}');
- Expect.equals(MessageKind.IMPORT_EXPERIMENTAL_MIRRORS,
- collector.warnings.first.message.kind);
- Expect.equals(
- expectedPaths.join(MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING),
- collector.warnings.first.message.arguments['importChain']);
- }
-}
-
-Future checkPaths(Map sourceData) {
- Map sourceFiles = sourceData;
- var expectedPaths = sourceData['paths'];
- var expectedVerbosePaths = sourceData['verbosePaths'];
- if (expectedVerbosePaths == null) {
- expectedVerbosePaths = expectedPaths;
- }
- return test(sourceFiles, expectedPaths: expectedPaths).then((_) {
- return test(sourceFiles,
- expectedPaths: expectedVerbosePaths, verbose: true);
- }).then((_) {
- return test(sourceFiles, enableExperimentalMirrors: true);
- });
-}
-
-void main() {
- asyncTest(() => Future.forEach([
- DIRECT_IMPORT,
- INDIRECT_IMPORT1,
- INDIRECT_IMPORT2,
- INDIRECT_PACKAGE_IMPORT1,
- INDIRECT_PACKAGE_IMPORT2,
- INDIRECT_PACKAGE_IMPORT3,
- INDIRECT_PACKAGE_IMPORT4,
- DUAL_DIRECT_IMPORT,
- DUAL_INDIRECT_IMPORT1,
- DUAL_INDIRECT_IMPORT2,
- DUAL_INDIRECT_IMPORT3,
- DUAL_INDIRECT_PACKAGE_IMPORT1,
- DIRECT_EXPORT,
- INDIRECT_EXPORT1,
- INDIRECT_EXPORT2,
- INDIRECT_PACKAGE_EXPORT1,
- INDIRECT_PACKAGE_EXPORT2
- ], (map) => checkPaths(map)));
-}
diff --git a/tests/compiler/dart2js/mirrors/mirror_final_field_inferrer2_test.dart b/tests/compiler/dart2js/mirrors/mirror_final_field_inferrer2_test.dart
deleted file mode 100644
index 2126ac9..0000000
--- a/tests/compiler/dart2js/mirrors/mirror_final_field_inferrer2_test.dart
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that final fields in @MirrorsUsed are still inferred.
-
-import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import 'package:compiler/src/commandline_options.dart';
-import '../memory_compiler.dart' show runCompiler;
-import '../compiler_helper.dart' show findElement;
-import '../inference/type_mask_test_helper.dart';
-
-const MEMORY_SOURCE_FILES = const <String, String>{
- 'main.dart': """
-import 'dart:mirrors';
-
-const field = 42;
-
-main() {
- var mirror = reflect(field);
- mirror.invoke(null, null);
-}
-"""
-};
-
-void main() {
- asyncTest(() async {
- var result = await runCompiler(
- memorySourceFiles: MEMORY_SOURCE_FILES,
- options: [Flags.useOldFrontend]);
- var compiler = result.compiler;
- var element = findElement(compiler, 'field');
- var typesInferrer = compiler.globalInference.typesInferrerInternal;
- var closedWorld = typesInferrer.closedWorld;
- var commonMasks = closedWorld.commonMasks;
- Expect.equals(commonMasks.uint31Type,
- simplify(typesInferrer.getTypeOfMember(element), closedWorld), 'field');
- });
-}
diff --git a/tests/compiler/dart2js/mirrors/mirror_final_field_inferrer_test.dart b/tests/compiler/dart2js/mirrors/mirror_final_field_inferrer_test.dart
deleted file mode 100644
index 8583e11..0000000
--- a/tests/compiler/dart2js/mirrors/mirror_final_field_inferrer_test.dart
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that final fields in @MirrorsUsed are still inferred.
-
-import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import 'package:compiler/src/commandline_options.dart';
-import '../memory_compiler.dart' show runCompiler;
-import '../compiler_helper.dart' show findElement;
-import '../inference/type_mask_test_helper.dart';
-
-const MEMORY_SOURCE_FILES = const <String, String>{
- 'main.dart': """
-@MirrorsUsed(targets: 'field')
-import 'dart:mirrors';
-
-const field = 42;
-
-main() {
- return field;
-}
-"""
-};
-
-void main() {
- asyncTest(() async {
- var result = await runCompiler(
- memorySourceFiles: MEMORY_SOURCE_FILES,
- options: [Flags.useOldFrontend]);
- var compiler = result.compiler;
- var element = findElement(compiler, 'field');
- var typesInferrer = compiler.globalInference.typesInferrerInternal;
- var closedWorld = typesInferrer.closedWorld;
- var commonMasks = closedWorld.commonMasks;
- Expect.equals(commonMasks.uint31Type,
- simplify(typesInferrer.getTypeOfMember(element), closedWorld), 'field');
- });
-}
diff --git a/tests/compiler/dart2js/mirrors/mirror_private_name_inheritance_test.dart b/tests/compiler/dart2js/mirrors/mirror_private_name_inheritance_test.dart
deleted file mode 100644
index 830b3b7..0000000
--- a/tests/compiler/dart2js/mirrors/mirror_private_name_inheritance_test.dart
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that final fields in @MirrorsUsed are still inferred.
-
-import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import 'package:compiler/src/commandline_options.dart';
-import '../memory_compiler.dart' show runCompiler;
-import '../compiler_helper.dart' show findElement;
-
-const MEMORY_SOURCE_FILES = const <String, String>{
- 'main.dart': """
-@MirrorsUsed(targets: 'Super')
-import 'dart:mirrors';
-import 'lib.dart';
-
-
-class Subclass extends Super {
- int _private;
-
- int magic() => _private++;
-}
-
-main() {
- var objects = [new Super(), new Subclass()];
- reflect(objects[0]); // Trigger mirror usage.
-}
-""",
- 'lib.dart': """
-class Super {
- int _private;
-
- int magic() => _private++;
-}
-"""
-};
-
-void main() {
- asyncTest(() async {
- var result = await runCompiler(
- memorySourceFiles: MEMORY_SOURCE_FILES,
- options: [Flags.useOldFrontend]);
- var compiler = result.compiler;
-
- dynamic superclass =
- findElement(compiler, 'Super', Uri.parse('memory:lib.dart'));
- dynamic subclass = findElement(compiler, 'Subclass');
- var oracle = compiler.backend.mirrorsData.isMemberAccessibleByReflection;
- print(superclass.lookupMember('_private'));
- Expect.isTrue(oracle(superclass.lookupMember('_private')));
- Expect.isFalse(oracle(subclass.lookupMember('_private')));
- });
-}
diff --git a/tests/compiler/dart2js/mirrors/mirror_tree_shaking_test.dart b/tests/compiler/dart2js/mirrors/mirror_tree_shaking_test.dart
deleted file mode 100644
index 0afce8b..0000000
--- a/tests/compiler/dart2js/mirrors/mirror_tree_shaking_test.dart
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that tree-shaking hasn't been turned off.
-
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/compiler.dart';
-import 'package:compiler/src/js_backend/js_backend.dart' show JavaScriptBackend;
-import 'package:compiler/src/js_backend/mirrors_analysis.dart';
-import 'package:expect/expect.dart';
-import '../memory_compiler.dart';
-
-main() {
- DiagnosticCollector collector = new DiagnosticCollector();
- asyncTest(() async {
- CompilationResult result = await runCompiler(
- memorySourceFiles: MEMORY_SOURCE_FILES,
- diagnosticHandler: collector,
- options: [Flags.useOldFrontend]);
- Compiler compiler = result.compiler;
- JavaScriptBackend backend = compiler.backend;
- Expect.isTrue(collector.errors.isEmpty);
- Expect.isTrue(collector.infos.isEmpty);
- Expect.isFalse(compiler.compilationFailed);
- MirrorsResolutionAnalysisImpl mirrorsResolutionAnalysis =
- backend.mirrorsResolutionAnalysis;
- Expect.isFalse(
- mirrorsResolutionAnalysis.handler.hasEnqueuedReflectiveElements);
- Expect.isFalse(
- mirrorsResolutionAnalysis.handler.hasEnqueuedReflectiveStaticFields);
- MirrorsCodegenAnalysisImpl mirrorsCodegenAnalysis =
- backend.mirrorsCodegenAnalysis;
- Expect
- .isFalse(mirrorsCodegenAnalysis.handler.hasEnqueuedReflectiveElements);
- Expect.isFalse(
- mirrorsCodegenAnalysis.handler.hasEnqueuedReflectiveStaticFields);
- Expect.isFalse(compiler.disableTypeInference);
- Expect.isFalse(backend.mirrorsData.hasRetainedMetadata);
- });
-}
-
-const Map MEMORY_SOURCE_FILES = const {
- 'main.dart': r"""
-import 'dart:mirrors';
-
-class Foo {
- noSuchMethod(invocation) {
- print('Invoked ${MirrorSystem.getName(invocation.memberName)}');
- return reflect('foobar').delegate(invocation);
- }
-}
-
-void main() {
- print(new Foo().substring(3));
-}
-""",
-};
diff --git a/tests/compiler/dart2js/mirrors/mirrors_used_test.dart b/tests/compiler/dart2js/mirrors/mirrors_used_test.dart
deleted file mode 100644
index 63c6915..0000000
--- a/tests/compiler/dart2js/mirrors/mirrors_used_test.dart
+++ /dev/null
@@ -1,219 +0,0 @@
-// Copyright (c) 2013, 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.
-
-/// Test that the @MirrorsUsed annotation suppress hints and that only
-/// requested elements are retained for reflection.
-library dart2js.test.mirrors_used_test;
-
-import 'package:compiler/src/js/js.dart' as jsAst;
-
-import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-
-import '../memory_compiler.dart' show runCompiler;
-
-import 'package:compiler/src/apiimpl.dart' show CompilerImpl;
-import 'package:compiler/src/commandline_options.dart';
-
-import 'package:compiler/src/constants/values.dart'
- show ConstantValue, TypeConstantValue;
-
-import 'package:compiler/src/elements/elements.dart'
- show ClassElement, Elements;
-
-import 'package:compiler/src/js_backend/js_backend.dart' show JavaScriptBackend;
-import 'package:compiler/src/js_backend/mirrors_analysis.dart';
-
-import 'package:compiler/src/js_emitter/full_emitter/emitter.dart' as full
- show Emitter;
-
-import 'package:compiler/src/old_to_new_api.dart'
- show LegacyCompilerDiagnostics;
-
-import 'package:compiler/src/universe/world_builder.dart';
-
-void expectOnlyVerboseInfo(Uri uri, int begin, int end, String message, kind) {
- if (kind.name == 'verbose info') {
- print(message);
- return;
- }
- if (message.contains('methods retained for use by dart:mirrors out of')) {
- print(message);
- return;
- }
- if (kind.name == 'info') return;
-
- // TODO(aprelev@gmail.com): Remove once dartbug.com/13907 is fixed.
- if (message.contains("Warning: 'typedef' not allowed here")) return;
-
- throw '$uri:$begin:$end: $kind: $message';
-}
-
-void main() {
- asyncTest(() async {
- var result = await runCompiler(
- memorySourceFiles: MEMORY_SOURCE_FILES,
- diagnosticHandler: new LegacyCompilerDiagnostics(expectOnlyVerboseInfo),
- options: ['--enable-experimental-mirrors', Flags.useOldFrontend]);
- CompilerImpl compiler = result.compiler;
- JavaScriptBackend backend = compiler.backend;
- print('');
- List generatedCode =
- Elements.sortedByPosition(new List.from(backend.generatedCode.keys));
- for (var element in generatedCode) {
- print(element);
- }
- print('');
-
- // This assertion can fail for two reasons:
- // 1. Too many elements retained for reflection.
- // 2. Some code was refactored, and there are more methods.
- // Either situation could be problematic, but in situation 2, it is often
- // acceptable to increase [expectedMethodCount] a little.
- int expectedMethodCount = 490;
- Expect.isTrue(
- generatedCode.length <= expectedMethodCount,
- 'Too many compiled methods: '
- '${generatedCode.length} > $expectedMethodCount');
-
- // The following names should be retained:
- List<jsAst.Name> expectedNames = [
- 'Foo', // The name of class Foo.
- r'Foo$', // The name of class Foo's constructor.
- r'get$field' // The (getter) name of Foo.field.
- ].map(backend.namer.asName).toList();
- // TODO(ahe): Check for the following names, currently they are not being
- // recorded correctly, but are being emitted.
- [
- 'Foo_staticMethod', // The name of Foo.staticMethod.
- r'instanceMethod$0' // The name of Foo.instanceMethod.
- ];
-
- // We always include the names of some native classes.
- List<ClassElement> nativeClasses = [
- compiler.resolution.commonElements.intClass,
- compiler.resolution.commonElements.doubleClass,
- compiler.resolution.commonElements.numClass,
- compiler.resolution.commonElements.stringClass,
- compiler.resolution.commonElements.boolClass,
- compiler.resolution.commonElements.nullClass,
- compiler.resolution.commonElements.listClass
- ];
- Iterable<jsAst.Name> nativeNames =
- nativeClasses.map((c) => backend.namer.className(c));
- expectedNames.addAll(nativeNames);
-
- // Mirrors only work in the full emitter. We can thus be certain that the
- // emitter is the full emitter.
- full.Emitter fullEmitter = backend.emitter.emitter;
- Set<jsAst.Name> recordedNames = new Set()
- ..addAll(fullEmitter.recordedMangledNames)
- ..addAll(fullEmitter.mangledFieldNames.keys)
- ..addAll(fullEmitter.mangledGlobalFieldNames.keys);
- Expect.setEquals(new Set.from(expectedNames), recordedNames);
-
- for (dynamic library in compiler.libraryLoader.libraries) {
- library.forEachLocalMember((member) {
- if (member.isClass) {
- if (library ==
- compiler.frontendStrategy.elementEnvironment.mainLibrary &&
- member.name == 'Foo') {
- Expect.isTrue(
- compiler.backend.mirrorsData
- .isClassAccessibleByReflection(member),
- '$member');
- member.forEachLocalMember((classMember) {
- Expect.isTrue(
- compiler.backend.mirrorsData
- .isMemberAccessibleByReflection(classMember),
- '$classMember');
- });
- } else {
- Expect.isFalse(
- compiler.backend.mirrorsData
- .isClassAccessibleByReflection(member),
- '$member');
- }
- } else if (member.isTypedef) {
- Expect.isFalse(
- compiler.backend.mirrorsData
- .isTypedefAccessibleByReflection(member),
- '$member');
- } else {
- Expect.isFalse(
- compiler.backend.mirrorsData
- .isMemberAccessibleByReflection(member),
- '$member');
- }
- });
- }
-
- int metadataCount = 0;
- CodegenWorldBuilderImpl codegenWorldBuilder = compiler.codegenWorldBuilder;
- Set<ConstantValue> compiledConstants =
- codegenWorldBuilder.compiledConstants;
- // Make sure that most of the metadata constants aren't included in the
- // generated code.
- MirrorsResolutionAnalysisImpl mirrorsResolutionAnalysis =
- backend.mirrorsResolutionAnalysis;
- mirrorsResolutionAnalysis.processMetadata(
- compiler.enqueuer.resolution.processedEntities, (metadata) {
- ConstantValue constant =
- backend.constants.getConstantValueForMetadata(metadata);
- Expect.isFalse(
- compiledConstants.contains(constant), constant.toStructuredText());
- metadataCount++;
- });
-
- // There should at least be one metadata constant:
- // 1. The constructed constant for 'MirrorsUsed'.
- Expect.isTrue(metadataCount >= 1);
-
- // The type literal 'Foo' is both used as metadata, and as a plain value in
- // the program. Make sure that it isn't duplicated.
- int fooConstantCount = 0;
- for (ConstantValue constant in compiledConstants) {
- if (constant is TypeConstantValue &&
- '${constant.representedType}' == 'Foo') {
- fooConstantCount++;
- }
- }
- Expect.equals(1, fooConstantCount,
- "The type literal 'Foo' is duplicated or missing.");
- });
-}
-
-const MEMORY_SOURCE_FILES = const <String, String>{
- 'main.dart': """
-// The repeated constant value for symbols and targets used to crash dart2js in
-// host-checked mode, and could potentially lead to other problems.
-@MirrorsUsed(symbols: 'Foo', targets: 'Foo', override: '*')
-import 'dart:mirrors';
-
-import 'library.dart';
-
-class Foo {
- int field;
- instanceMethod() {}
- static staticMethod() {}
-}
-
-unusedFunction() {
-}
-
-main() {
- useReflect(Foo);
-}
-""",
- 'library.dart': """
-library lib;
-
-import 'dart:mirrors';
-
-useReflect(type) {
- print(new Symbol('Foo'));
- print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName));
-}
-""",
-};
diff --git a/tests/compiler/dart2js/old_frontend/analyze_all_test.dart b/tests/compiler/dart2js/old_frontend/analyze_all_test.dart
deleted file mode 100644
index 4936c1c..0000000
--- a/tests/compiler/dart2js/old_frontend/analyze_all_test.dart
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (c) 2012, 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:async';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/diagnostics/messages.dart';
-import 'package:expect/expect.dart';
-import '../memory_compiler.dart';
-
-const String SOURCE = """
-class Foo {
- // Deliberately not const to ensure compile error.
- Foo(_);
-}
-
-@Bar()
-class Bar {
- const Bar();
-}
-
-@Foo('x')
-typedef void VoidFunction();
-
-@Foo('y')
-class MyClass {}
-
-main() {
-}
-""";
-
-Future<DiagnosticCollector> run(String source,
- {bool analyzeAll, bool expectSuccess}) async {
- DiagnosticCollector collector = new DiagnosticCollector();
-
- List<String> options = [Flags.useOldFrontend];
- if (analyzeAll) {
- options.add(Flags.analyzeAll);
- } else {
- options.add(Flags.analyzeOnly);
- }
- CompilationResult result = await runCompiler(
- memorySourceFiles: {'main.dart': source},
- diagnosticHandler: collector,
- options: options);
- Expect.equals(expectSuccess, result.isSuccess);
- return collector;
-}
-
-test1() async {
- DiagnosticCollector collector =
- await run(SOURCE, analyzeAll: false, expectSuccess: true);
- Expect.isTrue(
- collector.warnings.isEmpty, 'Unexpected warnings: ${collector.warnings}');
- Expect.isTrue(
- collector.errors.isEmpty, 'Unexpected errors: ${collector.errors}');
-}
-
-test2() async {
- DiagnosticCollector collector =
- await run(SOURCE, analyzeAll: true, expectSuccess: false);
-
- Expect.isTrue(
- collector.warnings.isEmpty, 'unexpected warnings: ${collector.warnings}');
- Expect.equals(2, collector.errors.length,
- 'expected exactly two errors, but got ${collector.errors}');
-
- CollectedMessage first = collector.errors.first;
- Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, first.message.kind);
- Expect.equals("Foo", SOURCE.substring(first.begin, first.end));
-
- CollectedMessage second = collector.errors.elementAt(1);
- Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, second.message.kind);
- Expect.equals("Foo", SOURCE.substring(second.begin, second.end));
-}
-
-// This is a regression test, testing that we can handle annotations on
-// malformed elements. Depending on the order of analysis, annotations on such
-// elements might not be resolved which caused a crash when trying to detect
-// a `@NoInline()` annotation.
-test3() async {
- String source = '''
-import 'package:expect/expect.dart';
-
-class A {
- @NoInline
- m() {
- => print(0);
- }
-}
-
-@NoInline()
-main() => new A().m();
-''';
-
- DiagnosticCollector collector =
- await run(source, analyzeAll: true, expectSuccess: false);
-
- Expect.isTrue(
- collector.warnings.isEmpty, 'unexpected warnings: ${collector.warnings}');
- Expect.equals(1, collector.errors.length,
- 'expected exactly one error, but got ${collector.errors}');
-}
-
-main() {
- asyncTest(() async {
- await test1();
- await test2();
- await test3();
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/analyze_api_test.dart b/tests/compiler/dart2js/old_frontend/analyze_api_test.dart
deleted file mode 100644
index 678e798..0000000
--- a/tests/compiler/dart2js/old_frontend/analyze_api_test.dart
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2013, 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 analyze_api;
-
-import 'package:sdk_library_metadata/libraries.dart';
-import 'analyze_helper.dart';
-import 'package:async_helper/async_helper.dart';
-
-/**
- * Map of white-listed warnings and errors.
- *
- * Only add a white-listing together with a bug report to dartbug.com and add
- * the bug issue number as a comment on the white-listing.
- *
- * Use an identifiable suffix of the file uri as key. Use a fixed substring of
- * the error/warning message in the list of white-listings for each file.
- */
-// TODO(johnniwinther): Support canonical URIs as keys.
-const Map<String, List<String>> WHITE_LIST = const {
- "sdk/lib/io/file.dart": const [
- "'void' is not a subtype of bound 'Object' for type variable",
- ],
- "sdk/lib/io/file_impl.dart": const [
- "'void' is not a subtype of bound 'Object' for type variable",
- ],
-};
-
-void main() {
- var uriList = new List<Uri>();
- libraries.forEach((String name, LibraryInfo info) {
- if (info.documented) {
- uriList.add(new Uri(scheme: 'dart', path: name));
- }
- });
- asyncTest(() => analyze(uriList, WHITE_LIST, mode: AnalysisMode.ALL));
-}
diff --git a/tests/compiler/dart2js/old_frontend/analyze_dart2js_helpers_test.dart b/tests/compiler/dart2js/old_frontend/analyze_dart2js_helpers_test.dart
deleted file mode 100644
index 7ff112a..0000000
--- a/tests/compiler/dart2js/old_frontend/analyze_dart2js_helpers_test.dart
+++ /dev/null
@@ -1,219 +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 dart2js.analyze_helpers.test;
-
-import 'dart:io';
-
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/compiler_new.dart' show Diagnostic;
-import 'package:compiler/src/apiimpl.dart' show CompilerImpl;
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/constants/expressions.dart'
- show ConstructedConstantExpression;
-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;
-import 'package:compiler/src/resolution/semantic_visitor.dart';
-import 'package:compiler/src/resolution/tree_elements.dart' show TreeElements;
-import 'package:compiler/src/source_file_provider.dart'
- show FormattingDiagnosticHandler;
-import 'package:compiler/src/tree/tree.dart';
-import 'package:compiler/src/universe/call_structure.dart' show CallStructure;
-import 'package:expect/expect.dart';
-
-import '../memory_compiler.dart';
-
-main(List<String> arguments) {
- bool verbose = arguments.contains('-v');
-
- List<String> options = <String>[
- Flags.useOldFrontend,
- Flags.analyzeOnly,
- Flags.analyzeMain,
- '--categories=Client,Server'
- ];
- if (verbose) {
- options.add(Flags.verbose);
- }
- asyncTest(() async {
- CompilerImpl compiler =
- compilerFor(options: options, showDiagnostics: verbose);
- FormattingDiagnosticHandler diagnostics =
- new FormattingDiagnosticHandler(compiler.provider);
- Directory dir =
- new Directory.fromUri(Uri.base.resolve('pkg/compiler/lib/'));
- String helpersUriPrefix = dir.uri.resolve('src/helpers/').toString();
- HelperAnalyzer analyzer = new HelperAnalyzer(diagnostics, helpersUriPrefix);
- LibraryElement helperLibrary;
- for (FileSystemEntity entity in dir.listSync(recursive: true)) {
- if (entity is File && entity.path.endsWith('.dart')) {
- Uri file = Uri.base.resolve(nativeToUriPath(entity.path));
- if (verbose) {
- print('---- analyzing $file ----');
- }
- LibraryElement library = await compiler.analyzeUri(file);
- if (library != null) {
- if (library.libraryName == 'dart2js.helpers') {
- helperLibrary = library;
- }
- library.forEachLocalMember((Element element) {
- if (element is ClassElement) {
- element.forEachLocalMember((_member) {
- AstElement member = _member;
- analyzer.analyze(member.resolvedAst);
- });
- } else if (element is MemberElement) {
- analyzer.analyze(element.resolvedAst);
- }
- });
- }
- }
- }
- Expect.isNotNull(helperLibrary, 'Helper library not found');
- Expect.isTrue(analyzer.isHelper(helperLibrary),
- "Helper library $helperLibrary is not considered a helper.");
- Expect.isTrue(analyzer.errors.isEmpty, "Errors found.");
- });
-}
-
-class HelperAnalyzer extends TraversalVisitor {
- final FormattingDiagnosticHandler diagnostics;
- final String helpersUriPrefix;
- List<SourceSpan> errors = <SourceSpan>[];
-
- ResolvedAst resolvedAst;
-
- @override
- TreeElements get elements => resolvedAst.elements;
-
- AnalyzableElement get analyzedElement => resolvedAst.element;
-
- HelperAnalyzer(this.diagnostics, this.helpersUriPrefix) : super(null);
-
- @override
- void apply(Node node, [_]) {
- node.accept(this);
- }
-
- void analyze(ResolvedAst resolvedAst) {
- if (resolvedAst.kind != ResolvedAstKind.PARSED) {
- // Skip synthesized members.
- return;
- }
- this.resolvedAst = resolvedAst;
- apply(resolvedAst.node);
- this.resolvedAst = null;
- }
-
- bool isHelper(Element element) {
- Uri uri = element.library.canonicalUri;
- return '$uri'.startsWith(helpersUriPrefix);
- }
-
- void checkAccess(Node node, MemberElement element) {
- if (isHelper(element) && !isHelper(analyzedElement)) {
- Uri uri = analyzedElement.implementation.sourcePosition.uri;
- SourceSpan span = new SourceSpan.fromNode(uri, node);
- diagnostics.report(null, span.uri, span.begin, span.end,
- "Helper used in production code.", Diagnostic.ERROR);
- errors.add(span);
- }
- }
-
- @override
- void visitTopLevelFieldInvoke(Send node, FieldElement field,
- NodeList arguments, CallStructure callStructure, _) {
- checkAccess(node, field);
- apply(arguments);
- }
-
- @override
- void visitTopLevelGetterInvoke(Send node, GetterElement getter,
- NodeList arguments, CallStructure callStructure, _) {
- checkAccess(node, getter);
- apply(arguments);
- }
-
- @override
- void visitTopLevelFunctionInvoke(Send node, MethodElement method,
- NodeList arguments, CallStructure callStructure, _) {
- checkAccess(node, method);
- apply(arguments);
- }
-
- @override
- void visitTopLevelFieldGet(Send node, FieldElement field, _) {
- checkAccess(node, field);
- }
-
- @override
- void visitTopLevelGetterGet(Send node, GetterElement getter, _) {
- checkAccess(node, getter);
- }
-
- @override
- void visitTopLevelFunctionGet(Send node, MethodElement method, _) {
- checkAccess(node, method);
- }
-
- @override
- void visitGenerativeConstructorInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- NodeList arguments,
- CallStructure callStructure,
- _) {
- checkAccess(node, constructor);
- apply(arguments);
- }
-
- @override
- void visitRedirectingGenerativeConstructorInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- NodeList arguments,
- CallStructure callStructure,
- _) {
- checkAccess(node, constructor);
- apply(arguments);
- }
-
- @override
- void visitFactoryConstructorInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- NodeList arguments,
- CallStructure callStructure,
- _) {
- checkAccess(node, constructor);
- apply(arguments);
- }
-
- @override
- void visitRedirectingFactoryConstructorInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- ConstructorElement effectiveTarget,
- ResolutionInterfaceType effectiveTargetType,
- NodeList arguments,
- CallStructure callStructure,
- _) {
- checkAccess(node, constructor);
- apply(arguments);
- }
-
- @override
- void visitConstConstructorInvoke(
- NewExpression node, ConstructedConstantExpression constant, _) {
- ConstructorElement constructor = constant.target;
- checkAccess(node, constructor);
- }
-}
diff --git a/tests/compiler/dart2js/old_frontend/analyze_helper.dart b/tests/compiler/dart2js/old_frontend/analyze_helper.dart
deleted file mode 100644
index 84dc1c1..0000000
--- a/tests/compiler/dart2js/old_frontend/analyze_helper.dart
+++ /dev/null
@@ -1,298 +0,0 @@
-// 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.
-
-library analyze_helper;
-
-import 'dart:async';
-import 'dart:io';
-import 'package:compiler/compiler.dart' as api;
-import 'package:compiler/src/apiimpl.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/diagnostics/messages.dart'
- show Message, MessageKind;
-import 'package:compiler/src/filenames.dart';
-import 'package:compiler/src/options.dart' show CompilerOptions;
-import 'package:compiler/src/source_file_provider.dart';
-import 'package:compiler/src/util/uri_extras.dart';
-import '../diagnostic_helper.dart';
-
-/// Option for hiding whitelisted messages.
-const String HIDE_WHITELISTED = '--hide-whitelisted';
-
-/**
- * Map of whitelisted warnings and errors.
- *
- * Only add a whitelisting together with a bug report to dartbug.com and add
- * the bug issue number as a comment on the whitelisting.
- *
- * Use an identifiable suffix of the file uri as key. Use a fixed substring of
- * the error/warning message in the list of whitelistings for each file.
- */
-// TODO(johnniwinther): Support canonical URIs as keys and message kinds as
-// values.
-
-class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
- bool hasWarnings = false;
- bool hasHint = false;
- bool hasErrors = false;
- bool lastWasWhitelisted = false;
- bool showWhitelisted = true;
-
- Map<String, Map<dynamic /* String|MessageKind */, int>> whiteListMap =
- new Map<String, Map<dynamic /* String|MessageKind */, int>>();
- List<MessageKind> skipList;
- List<CollectedMessage> collectedMessages = <CollectedMessage>[];
-
- CollectingDiagnosticHandler(
- Map<String, List /* <String|MessageKind> */ > whiteList,
- this.skipList,
- SourceFileProvider provider)
- : super(provider) {
- whiteList
- .forEach((String file, List /* <String|MessageKind> */ messageParts) {
- var useMap = new Map<dynamic /* String|MessageKind */, int>();
- for (var messagePart in messageParts) {
- useMap[messagePart] = 0;
- }
- whiteListMap[file] = useMap;
- });
- }
-
- bool checkResults() {
- bool validWhiteListUse = checkWhiteListUse();
- reportWhiteListUse();
- reportCollectedMessages();
- return !hasWarnings && !hasHint && !hasErrors && validWhiteListUse;
- }
-
- bool checkWhiteListUse() {
- bool allUsed = true;
- for (String file in whiteListMap.keys) {
- for (var messagePart in whiteListMap[file].keys) {
- if (whiteListMap[file][messagePart] == 0) {
- print("Whitelisting '$messagePart' is unused in '$file'. "
- "Remove the whitelisting from the whitelist map.");
- allUsed = false;
- }
- }
- }
- return allUsed;
- }
-
- void reportCollectedMessages() {
- if (collectedMessages.isNotEmpty) {
- print('----------------------------------------------------------------');
- print('Unexpected messages:');
- print('----------------------------------------------------------------');
- for (CollectedMessage message in collectedMessages) {
- super.report(message.message, message.uri, message.begin, message.end,
- message.text, message.kind);
- }
- print('----------------------------------------------------------------');
- }
- }
-
- void reportWhiteListUse() {
- for (String file in whiteListMap.keys) {
- for (var messagePart in whiteListMap[file].keys) {
- int useCount = whiteListMap[file][messagePart];
- print("Whitelisted message '$messagePart' suppressed $useCount "
- "time(s) in '$file'.");
- }
- }
- }
-
- bool checkWhiteList(Uri uri, Message message, String text) {
- if (uri == null) {
- return false;
- }
- if (skipList.contains(message.kind)) {
- return true;
- }
- String path = uri.path;
- for (String file in whiteListMap.keys) {
- if (path.contains(file)) {
- for (var messagePart in whiteListMap[file].keys) {
- bool found = false;
- if (messagePart is String) {
- found = text.contains(messagePart);
- } else {
- assert(messagePart is MessageKind);
- found = message.kind == messagePart;
- }
- if (found) {
- whiteListMap[file][messagePart]++;
- return true;
- }
- }
- }
- }
- return false;
- }
-
- @override
- void report(covariant Message message, Uri uri, int begin, int end,
- String text, api.Diagnostic kind) {
- if (kind == api.Diagnostic.WARNING) {
- if (checkWhiteList(uri, message, text)) {
- // Suppress whitelisted warnings.
- lastWasWhitelisted = true;
- if (showWhitelisted || verbose) {
- print("*already whitelisted*");
- super.report(message, uri, begin, end, text, kind);
- }
- return;
- }
- print("*NOT WHITELISTED*");
- hasWarnings = true;
- }
- if (kind == api.Diagnostic.HINT) {
- if (checkWhiteList(uri, message, text)) {
- // Suppress whitelisted hints.
- lastWasWhitelisted = true;
- if (showWhitelisted || verbose) {
- print("*already whitelisted*");
- super.report(message, uri, begin, end, text, kind);
- }
- return;
- }
- print("*NOT WHITELISTED*");
- hasHint = true;
- }
- if (kind == api.Diagnostic.ERROR) {
- if (checkWhiteList(uri, message, text)) {
- // Suppress whitelisted errors.
- lastWasWhitelisted = true;
- if (showWhitelisted || verbose) {
- print("*already whitelisted*");
- super.report(message, uri, begin, end, text, kind);
- }
- return;
- }
- print("*NOT WHITELISTED*");
- hasErrors = true;
- }
- if (kind == api.Diagnostic.INFO && lastWasWhitelisted) {
- return;
- }
- lastWasWhitelisted = false;
- if (kind != api.Diagnostic.VERBOSE_INFO) {
- collectedMessages
- .add(new CollectedMessage(message, uri, begin, end, text, kind));
- }
- super.report(message, uri, begin, end, text, kind);
- }
-}
-
-typedef bool CheckResults(
- CompilerImpl compiler, CollectingDiagnosticHandler handler);
-
-enum AnalysisMode {
- /// Analyze all declarations in all libraries in one go.
- ALL,
-
- /// Analyze all declarations in the main library.
- MAIN,
-
- /// Analyze all declarations in the given URIs one at a time. This mode can
- /// handle URIs for parts (i.e. skips these).
- URI,
-
- /// Analyze all declarations reachable from the entry point.
- TREE_SHAKING,
-}
-
-/// Analyzes the file(s) in [uriList] using the provided [mode] and checks that
-/// no messages (errors, warnings or hints) are emitted.
-///
-/// Messages can be generally allowed using [skipList] or on a per-file basis
-/// using [whiteList].
-Future analyze(
- List<Uri> uriList, Map<String, List /* <String|MessageKind> */ > whiteList,
- {AnalysisMode mode: AnalysisMode.ALL,
- CheckResults checkResults,
- List<String> options: const <String>[],
- List<MessageKind> skipList: const <MessageKind>[]}) async {
- String testFileName =
- relativize(Uri.base, Platform.script, Platform.isWindows);
-
- print("""
-
-
-===
-=== NOTE: If this test fails, update [WHITE_LIST] in $testFileName
-===
-
-
-""");
-
- var libraryRoot = currentDirectory.resolve('sdk/');
- var packageConfig = currentDirectory.resolve('.packages');
- var provider = new CompilerSourceFileProvider();
- var handler = new CollectingDiagnosticHandler(whiteList, skipList, provider);
- options = <String>[
- Flags.useOldFrontend,
- Flags.analyzeOnly,
- '--categories=Client,Server',
- Flags.showPackageWarnings
- ]..addAll(options);
- switch (mode) {
- case AnalysisMode.URI:
- case AnalysisMode.MAIN:
- options.add(Flags.analyzeMain);
- break;
- case AnalysisMode.ALL:
- options.add(Flags.analyzeAll);
- break;
- case AnalysisMode.TREE_SHAKING:
- break;
- }
- if (options.contains(Flags.verbose)) {
- handler.verbose = true;
- }
- if (options.contains(HIDE_WHITELISTED)) {
- handler.showWhitelisted = false;
- }
- var compiler = new CompilerImpl(
- provider,
- null,
- handler,
- CompilerOptions.parse(options, libraryRoot: libraryRoot)
- ..packageConfig = packageConfig
- ..environment = {});
- String MESSAGE = """
-
-
-===
-=== ERROR: Unexpected result of analysis.
-===
-=== Please update [WHITE_LIST] in $testFileName
-===
-""";
-
- if (mode == AnalysisMode.URI) {
- for (Uri uri in uriList) {
- print('Analyzing uri: $uri');
- await compiler.analyzeUri(uri);
- }
- } else if (mode != AnalysisMode.TREE_SHAKING) {
- print('Analyzing libraries: $uriList');
- compiler.librariesToAnalyzeWhenRun = uriList;
- await compiler.run(null);
- } else {
- print('Analyzing entry point: ${uriList.single}');
- await compiler.run(uriList.single);
- }
-
- bool result;
- if (checkResults != null) {
- result = checkResults(compiler, handler);
- } else {
- result = handler.checkResults();
- }
- if (!result) {
- print(MESSAGE);
- exit(1);
- }
-}
diff --git a/tests/compiler/dart2js/old_frontend/analyze_only_test.dart b/tests/compiler/dart2js/old_frontend/analyze_only_test.dart
deleted file mode 100644
index e2e1f3b..0000000
--- a/tests/compiler/dart2js/old_frontend/analyze_only_test.dart
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright (c) 2012, 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.
-
-// Smoke test of the dart2js compiler API.
-library analyze_only;
-
-import 'dart:async';
-
-import 'package:async_helper/async_helper.dart';
-import 'package:expect/expect.dart';
-
-import 'package:compiler/compiler_new.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/diagnostics/messages.dart'
- show MessageKind, MessageTemplate;
-import 'package:compiler/src/old_to_new_api.dart';
-import 'package:compiler/src/options.dart';
-
-import '../../dart2js_extra/dummy_compiler_test.dart' as dummy;
-import '../output_collector.dart';
-
-runCompiler(String main, List<String> options,
- onValue(String code, List errors, List warnings)) {
- List errors = new List();
- List warnings = new List();
-
- Future<String> localProvider(Uri uri) {
- if (uri.scheme != 'main') return dummy.provider(uri);
- return new Future<String>.value(main);
- }
-
- void localHandler(
- Uri uri, int begin, int end, String message, Diagnostic kind) {
- dummy.handler(uri, begin, end, message, kind);
- if (kind == Diagnostic.ERROR) {
- errors.add(message);
- } else if (kind == Diagnostic.WARNING) {
- warnings.add(message);
- }
- }
-
- options = [Flags.useOldFrontend]..addAll(options);
- print('-----------------------------------------------');
- print('main source:\n$main');
- print('options: $options\n');
- asyncStart();
- OutputCollector outputCollector = new OutputCollector();
- Future<CompilationResult> result = compile(
- CompilerOptions.parse(options,
- libraryRoot: new Uri(scheme: 'lib', path: '/'))
- ..entryPoint = new Uri(scheme: 'main')
- ..packageRoot = new Uri(scheme: 'package', path: '/'),
- new LegacyCompilerInput(localProvider),
- new LegacyCompilerDiagnostics(localHandler),
- outputCollector);
- result
- .then((_) {
- onValue(outputCollector.getOutput('', OutputType.js), errors, warnings);
- }, onError: (e, st) {
- throw 'Compilation failed: ${e} ${st}';
- })
- .then(asyncSuccess)
- .catchError((error, stack) {
- print('\n\n-----------------------------------------------');
- print('main source:\n$main');
- print('options: $options\n');
- print('threw:\n $error\n$stack');
- print('-----------------------------------------------\n\n');
- throw error;
- });
-}
-
-main() {
- runCompiler("", [Flags.generateCodeWithCompileTimeErrors],
- (String code, List errors, List warnings) {
- Expect.isNotNull(code);
- Expect.isTrue(errors.isEmpty, 'errors is not empty: $errors');
- MessageTemplate template =
- MessageTemplate.TEMPLATES[MessageKind.MISSING_MAIN];
- Expect.equals("${template.message({'main': 'main'})}", warnings.single);
- });
-
- runCompiler("main() {}", [Flags.generateCodeWithCompileTimeErrors],
- (String code, List errors, List warnings) {
- Expect.isNotNull(code);
- Expect.isTrue(errors.isEmpty);
- Expect.isTrue(warnings.isEmpty);
- });
-
- runCompiler("", [Flags.analyzeOnly],
- (String code, List errors, List warnings) {
- Expect.isNull(code);
- Expect.isTrue(errors.isEmpty, 'errors is not empty: $errors');
- MessageTemplate template =
- MessageTemplate.TEMPLATES[MessageKind.CONSIDER_ANALYZE_ALL];
- Expect.equals("${template.message({'main': 'main'})}", warnings.single);
- });
-
- runCompiler("main() {}", [Flags.analyzeOnly],
- (String code, List errors, List warnings) {
- Expect.isNull(code);
- Expect.isTrue(errors.isEmpty);
- Expect.isTrue(warnings.isEmpty);
- });
-
- runCompiler("Foo foo; // Unresolved but not analyzed.", [Flags.analyzeOnly],
- (String code, List errors, List warnings) {
- Expect.isNull(code);
- Expect.isTrue(errors.isEmpty, 'errors is not empty: $errors');
- MessageTemplate template =
- MessageTemplate.TEMPLATES[MessageKind.CONSIDER_ANALYZE_ALL];
- Expect.equals("${template.message({'main': 'main'})}", warnings.single);
- });
-
- runCompiler("""main() {
- Foo foo; // Unresolved and analyzed.
- }""", [Flags.analyzeOnly], (String code, List errors, List warnings) {
- Expect.isNull(code);
- Expect.isTrue(errors.isEmpty);
- Expect.equals(1, warnings.length);
- Expect.equals("Cannot resolve type 'Foo'.", warnings[0].toString());
- });
-
- runCompiler("""main() {
- Foo foo; // Unresolved and analyzed.
- }""", [Flags.analyzeOnly, Flags.analyzeSignaturesOnly],
- (String code, List errors, List warnings) {
- Expect.isNull(code);
- Expect.isTrue(errors.isEmpty);
- Expect.isTrue(warnings.isEmpty);
- });
-
- runCompiler("Foo foo; // Unresolved and analyzed.", [
- Flags.analyzeOnly,
- Flags.analyzeAll
- ], (String code, List errors, List warnings) {
- Expect.isNull(code);
- Expect.isTrue(errors.isEmpty);
- Expect.equals("Cannot resolve type 'Foo'.", warnings[0].toString());
- });
-
- runCompiler("""Foo foo; // Unresolved and analyzed.
- main() {}""", [Flags.analyzeOnly, Flags.analyzeAll],
- (String code, List errors, List warnings) {
- Expect.isNull(code);
- Expect.isTrue(errors.isEmpty, 'Unexpected errors: $errors.');
- Expect.equals(1, warnings.length, 'Unexpected warning count: $warnings.');
- Expect.equals("Cannot resolve type 'Foo'.", warnings[0].toString());
- });
-
- runCompiler("", [Flags.analyzeOnly, Flags.analyzeAll],
- (String code, List errors, List warnings) {
- Expect.isNull(code);
- Expect.isTrue(errors.isEmpty);
- Expect.isTrue(warnings.isEmpty);
- });
-
- // --analyze-signatures-only implies --analyze-only
- runCompiler("", [Flags.analyzeSignaturesOnly, Flags.analyzeAll],
- (String code, List errors, List warnings) {
- Expect.isNull(code);
- Expect.isTrue(errors.isEmpty);
- Expect.isTrue(warnings.isEmpty);
- });
-
- runCompiler("""main() {}
- foo() native 'foo';""", [Flags.analyzeOnly],
- (String code, List errors, List warnings) {
- Expect.isNull(code);
- Expect.isTrue(
- errors.single.startsWith("'native' modifier is not supported."));
- Expect.isTrue(warnings.isEmpty);
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/analyze_test_test.dart b/tests/compiler/dart2js/old_frontend/analyze_test_test.dart
deleted file mode 100644
index 495ce73..0000000
--- a/tests/compiler/dart2js/old_frontend/analyze_test_test.dart
+++ /dev/null
@@ -1,99 +0,0 @@
-// 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.
-
-library dart2js.analyze_test.test;
-
-import 'dart:io';
-
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/filenames.dart' show nativeToUriPath;
-
-import 'analyze_helper.dart';
-
-/**
- * Map of white-listed warnings and errors.
- *
- * Use an identifiable suffix of the file uri as key. Use a fixed substring of
- * the error/warning message in the list of white-listings for each file.
- */
-// TODO(johnniwinther): Support canonical URIs as keys.
-const Map<String, List /* <String|MessageKind> */ > WHITE_LIST = const {
- "pkg/kernel/lib/transformations/closure/": const [
- "Duplicated library name 'kernel.transformations.closure.converter'",
- ],
-};
-
-const List<String> SKIP_LIST = const <String>[
- // Helper files:
- "/data/",
- "/emission/",
- "/side_effects/",
- "quarantined/http_launch_data/",
- "mirrors_helper.dart",
- "path%20with%20spaces/",
- // Broken tests:
- "quarantined/http_test.dart",
- // Package directory
- "packages/",
-];
-
-List<Uri> computeInputUris({String filter}) {
- List<Uri> uriList = <Uri>[];
- Directory dir =
- new Directory.fromUri(Uri.base.resolve('tests/compiler/dart2js/'));
- for (FileSystemEntity entity in dir.listSync(recursive: true)) {
- if (entity is File && entity.path.endsWith('.dart')) {
- Uri file = Uri.base.resolve(nativeToUriPath(entity.path));
- if (filter != null && !'$file'.contains(filter)) {
- continue;
- }
- if (!SKIP_LIST.any((skip) => file.path.contains(skip))) {
- uriList.add(file);
- }
- }
- }
- return uriList;
-}
-
-main(List<String> arguments) {
- List<String> options = <String>[];
- List<Uri> uriList = <Uri>[];
- String filter;
- bool first = true;
- for (String argument in arguments) {
- if (argument.startsWith('-')) {
- options.add(argument == '-v' ? Flags.verbose : argument);
- } else if (first) {
- File file = new File(argument);
- if (file.existsSync()) {
- // Read test files from [file].
- for (String line in file.readAsLinesSync()) {
- line = line.trim();
- if (line.startsWith('Analyzing uri: ')) {
- int filenameOffset = line.indexOf('tests/compiler/dart2js/');
- if (filenameOffset != -1) {
- uriList.add(Uri.base
- .resolve(nativeToUriPath(line.substring(filenameOffset))));
- }
- }
- }
- } else {
- // Use argument as filter on test files.
- filter = argument;
- }
- } else {
- throw new ArgumentError("Extra argument $argument in $arguments.");
- }
- first = false;
- }
-
- asyncTest(() async {
- if (uriList.isEmpty) {
- uriList = computeInputUris(filter: filter);
- }
- await analyze(uriList, WHITE_LIST,
- mode: AnalysisMode.URI, options: options);
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/async_await_syntax_test.dart b/tests/compiler/dart2js/old_frontend/async_await_syntax_test.dart
deleted file mode 100644
index 16be073..0000000
--- a/tests/compiler/dart2js/old_frontend/async_await_syntax_test.dart
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2014, 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.
-
-// Test that dart2js produces the expected static type warnings and
-// compile-time errors for these tests.
-
-import 'frontend_checker.dart';
-
-/// Map of test files to run together with their associated whitelist.
-///
-/// For instance
-/// 'language/async_await_syntax_test.dart': const ['a03b', 'a04b']
-/// includes the multitest in 'language/async_await_syntax_test.dart' but
-/// expects the subtests 'a03b' and 'a04c' to fail.
-const Map<String, List<String>> TESTS = const <String, List<String>>{
- 'language_2/async_await_syntax_test.dart': const [
- 'a10a',
- 'b10a',
- 'c10a',
- 'd08b',
- 'd10a',
- ],
-};
-
-void main(List<String> arguments) {
- check(TESTS, arguments: arguments, options: []);
-}
diff --git a/tests/compiler/dart2js/old_frontend/bad_loop_test.dart b/tests/compiler/dart2js/old_frontend/bad_loop_test.dart
deleted file mode 100644
index 69d2490..0000000
--- a/tests/compiler/dart2js/old_frontend/bad_loop_test.dart
+++ /dev/null
@@ -1,68 +0,0 @@
-// 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 'package:async_helper/async_helper.dart';
-import 'package:compiler/compiler.dart' show Diagnostic;
-import 'package:compiler/src/options.dart' show CompilerOptions;
-import 'package:compiler/src/old_to_new_api.dart';
-import 'package:expect/expect.dart';
-import '../memory_source_file_helper.dart';
-
-main() {
- Uri script = currentDirectory.resolveUri(Platform.script);
- Uri libraryRoot = script.resolve('../../../../sdk/');
- Uri packageRoot = script.resolve('./packages/');
-
- var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
- int warningCount = 0;
- int errorCount = 0;
- void diagnosticHandler(
- Uri uri, int begin, int end, String message, Diagnostic kind) {
- if (kind == Diagnostic.VERBOSE_INFO) {
- return;
- }
- if (kind == Diagnostic.ERROR) {
- errorCount++;
- } else if (kind == Diagnostic.WARNING) {
- warningCount++;
- } else {
- throw 'unexpected diagnostic $kind: $message';
- }
- }
-
- CompilerImpl compiler = new CompilerImpl(
- provider,
- new LegacyCompilerOutput(),
- new LegacyCompilerDiagnostics(diagnosticHandler),
- new CompilerOptions()
- ..libraryRoot = libraryRoot
- ..useKernel = false
- ..packageRoot = packageRoot);
- asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) {
- Expect.isTrue(compiler.compilationFailed);
- Expect.equals(5, errorCount);
- Expect.equals(1, warningCount);
- }));
-}
-
-const Map MEMORY_SOURCE_FILES = const {
- 'main.dart': """
-main() {
- for (var x, y in []) {
- }
-
- for (var x = 10 in []) {
- }
-
- for (x.y in []) { // Also causes a warning "x unresolved".
- }
-
- for ((){}() in []) {
- }
-
- for (1 in []) {
- }
-}
-"""
-};
diff --git a/tests/compiler/dart2js/old_frontend/begin_end_token_test.dart b/tests/compiler/dart2js/old_frontend/begin_end_token_test.dart
deleted file mode 100644
index 0a0ce7a..0000000
--- a/tests/compiler/dart2js/old_frontend/begin_end_token_test.dart
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2011, 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 'package:compiler/src/tree/tree.dart';
-import 'package:expect/expect.dart';
-import 'parser_helper.dart';
-
-void testNode(Node node, String expected, String text, [bool hard = true]) {
- var debug = 'text=$text,expected=$expected,node:${node}';
- Expect.isNotNull(node, debug);
-
- Token beginToken = node.getBeginToken();
- Expect.isNotNull(beginToken, debug);
- Token endToken = node.getEndToken();
- Expect.isNotNull(endToken, debug);
-
- int begin = beginToken.charOffset;
- int end = endToken.charOffset + endToken.charCount;
- Expect.isTrue(begin <= end, debug);
-
- if (hard) {
- Expect.stringEquals(expected, text.substring(begin, end), debug);
- }
-}
-
-Node testExpression(String text, [String alternate]) {
- ExpressionStatement statement = parseStatement('$text;');
- Expression node = statement.expression;
- testNode(node, alternate == null ? text : alternate, text);
- return node;
-}
-
-void testUnaryExpression() {
- testExpression('x++');
- testExpression('++x');
-}
-
-void testAssignment() {
- Expression node;
- SendSet sendSet;
- String text;
-
- text = "a = b";
- node = testExpression(text);
-
- text = "a = b = c";
- node = testExpression(text);
- // Should parse as: a = (b = c).
- Expect.isNotNull(sendSet = node.asSendSet());
- testNode(sendSet.arguments.head.asSendSet(), 'b = c', text);
-
- text = "a = b = c = d";
- node = testExpression(text);
- // Should parse as: a = (b = (c = d)).
- Expect.isNotNull(sendSet = node.asSendSet());
- testNode(sendSet = sendSet.arguments.head.asSendSet(), 'b = c = d', text);
- testNode(sendSet = sendSet.arguments.head.asSendSet(), 'c = d', text);
-
- text = "a.b = c";
- node = testExpression(text);
- // Should parse as: receiver = a, selector = b, arguments = c.
- Expect.isNotNull(sendSet = node.asSendSet());
- testNode(sendSet.receiver, "a", "a.b = c");
- testNode(sendSet.selector, "b", "a.b = c");
- testNode(sendSet.arguments.head, "c", "a.b = c");
-
- text = "a.b = c.d";
- node = testExpression(text);
- // Should parse as: a.b = (c.d).
- Expect.isNotNull(sendSet = node.asSendSet());
- Expect.stringEquals("a", sendSet.receiver.toString());
- Expect.stringEquals("b", sendSet.selector.toString());
- Expect.stringEquals("c.d", sendSet.arguments.head.toString());
-
- text = "a.b = c.d = e.f";
- node = testExpression(text);
- // Should parse as: a.b = (c.d = (e.f)).
- Expect.isNotNull(sendSet = node.asSendSet());
- testNode(sendSet.receiver, "a", text);
- testNode(sendSet.selector, "b", text);
- Expect.isNotNull(sendSet = sendSet.arguments.head.asSendSet());
- testNode(sendSet.receiver, "c", text);
- testNode(sendSet.selector, "d", text);
- testNode(sendSet.arguments.head, "e.f", text);
-}
-
-void testIndex() {
- Expression node;
- Send send;
- SendSet sendSet;
- String text;
-
- text = "a[b]";
- node = testExpression(text);
- // Should parse as: (a)[b].
- Expect.isNotNull(send = node.asSend());
- testNode(send.receiver, "a", text);
- // TODO(johnniwinther): [selector] is the synthetic [] Operator which doesn't
- // return the right begin/end tokens. In the next line we should have expected
- // "[b]" instead of "[b".
- testNode(send.selector, "[b", text);
- testNode(send.arguments.head, "b", text);
-
- text = "a[b] = c";
- node = testExpression(text);
- // Should parse as: (a)[b] = c.
- Expect.isNotNull(sendSet = node.asSendSet());
- testNode(sendSet.receiver, "a", text);
- testNode(sendSet.selector, "[]", text, false); // Operator token is synthetic.
- testNode(sendSet.assignmentOperator, "=", text);
- testNode(sendSet.arguments.head, "b", text);
- testNode(sendSet.arguments.tail.head, "c", text);
-
- text = "a.b[c]";
- node = testExpression(text);
- // Should parse as: (a.b)[c].
- Expect.isNotNull(send = node.asSend());
- testNode(send.receiver, "a.b", text);
- testNode(send.selector, "[]", text, false); // Operator token is synthetic.
- testNode(send.arguments.head, "c", text);
-
- text = "a.b[c] = d";
- node = testExpression(text);
- // Should parse as: (a.b)[] = (c, d).
- Expect.isNotNull(sendSet = node.asSendSet());
- Expect.isNotNull(send = sendSet.receiver.asSend());
- testNode(send, "a.b", text);
- testNode(sendSet.selector, "[]", text, false); // Operator token is synthetic.
- testNode(sendSet.assignmentOperator, "=", text);
- testNode(sendSet.arguments.head, "c", text);
- testNode(sendSet.arguments.tail.head, "d", text);
-}
-
-void testPostfix() {
- Expression node;
- SendSet sendSet;
- String text;
-
- text = "a.b++";
- node = testExpression(text);
- // Should parse as: (a.b)++.
- Expect.isNotNull(sendSet = node.asSendSet());
- testNode(sendSet.receiver, "a", text);
- testNode(sendSet.selector, "b", text);
- testNode(sendSet.assignmentOperator, "++", text);
- Expect.isTrue(sendSet.arguments.isEmpty);
-
- text = "++a[b]";
- // TODO(johnniwinther): SendSet generates the wrong end token in the following
- // line. We should have [:testExpression(text):] instead of
- // [:testExpression(text, "++a"):].
- node = testExpression(text, "++a");
- Expect.isNotNull(sendSet = node.asSendSet());
- testNode(sendSet.receiver, "a", text);
- testNode(sendSet.selector, "[]", text, false); // Operator token is synthetic.
- testNode(sendSet.assignmentOperator, "++", text);
- testNode(sendSet.arguments.head, "b", text);
-
- text = "a[b]++";
- node = testExpression(text);
- Expect.isNotNull(sendSet = node.asSendSet());
- testNode(sendSet.receiver, "a", text);
- testNode(sendSet.selector, "[]", text, false); // Operator token is synthetic.
- testNode(sendSet.assignmentOperator, "++", text);
- testNode(sendSet.arguments.head, "b", text);
-}
-
-void main() {
- testUnaryExpression();
- testAssignment();
- testIndex();
- testPostfix();
-}
diff --git a/tests/compiler/dart2js/old_frontend/benign_error_test.dart b/tests/compiler/dart2js/old_frontend/benign_error_test.dart
deleted file mode 100644
index a94a5aa..0000000
--- a/tests/compiler/dart2js/old_frontend/benign_error_test.dart
+++ /dev/null
@@ -1,43 +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.
-
-// Test that benign error do not prevent compilation.
-
-import '../memory_compiler.dart';
-
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/compiler.dart';
-import 'package:compiler/src/diagnostics/messages.dart';
-import 'package:compiler/src/js_backend/js_backend.dart';
-import 'package:expect/expect.dart';
-
-main() {
- asyncTest(() async {
- for (MessageKind kind in Compiler.BENIGN_ERRORS) {
- await testExamples(kind);
- }
- });
-}
-
-testExamples(MessageKind kind) async {
- MessageTemplate template = MessageTemplate.TEMPLATES[kind];
- for (var example in template.examples) {
- if (example is! Map) {
- example = {'main.dart': example};
- }
- DiagnosticCollector collector = new DiagnosticCollector();
- CompilationResult result = await runCompiler(
- memorySourceFiles: example,
- diagnosticHandler: collector,
- options: [Flags.useOldFrontend]);
- Expect.isTrue(result.isSuccess);
- Expect
- .isTrue(collector.errors.any((message) => message.messageKind == kind));
- Compiler compiler = result.compiler;
- JavaScriptBackend backend = compiler.backend;
- Expect.isNotNull(backend.generatedCode[
- compiler.frontendStrategy.elementEnvironment.mainFunction]);
- }
-}
diff --git a/tests/compiler/dart2js/old_frontend/categories_test.dart b/tests/compiler/dart2js/old_frontend/categories_test.dart
deleted file mode 100644
index 6b4317c..0000000
--- a/tests/compiler/dart2js/old_frontend/categories_test.dart
+++ /dev/null
@@ -1,33 +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.
-
-import "package:expect/expect.dart";
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-
-import "../memory_compiler.dart";
-
-runTest(String source, String categories, int expectedErrors) async {
- var collector = new DiagnosticCollector();
- await runCompiler(
- memorySourceFiles: {"main.dart": source},
- options: ["--categories=$categories", Flags.useOldFrontend],
- diagnosticHandler: collector);
- Expect.equals(expectedErrors, collector.errors.length);
- Expect.equals(0, collector.warnings.length);
-}
-
-void main() {
- asyncTest(() async {
- await runTest("import 'dart:async'; main() {}", "Client", 0);
- await runTest("import 'dart:async'; main() {}", "Server", 0);
- await runTest("import 'dart:html'; main() {}", "Client", 0);
- await runTest("import 'dart:html'; main() {}", "Server", 1);
- // Importing dart:io is temporarily allowed as a stopgap measure for the
- // lack of config specific imports. Once that is added, this will be
- // disallowed again.
- await runTest("import 'dart:io'; main() {}", "Client", 0);
- await runTest("import 'dart:io'; main() {}", "Server", 0);
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/check_elements_invariants_test.dart b/tests/compiler/dart2js/old_frontend/check_elements_invariants_test.dart
deleted file mode 100644
index f394e6d..0000000
--- a/tests/compiler/dart2js/old_frontend/check_elements_invariants_test.dart
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2014, 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:async';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/apiimpl.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:expect/expect.dart';
-import 'package:compiler/src/elements/entities.dart' show ClassEntity;
-import 'package:compiler/src/resolution/class_members.dart'
- show ClassMemberMixin;
-import '../memory_compiler.dart';
-
-const String DART2JS_SOURCE = 'pkg/compiler/lib/src/dart2js.dart';
-const List<String> DART2JS_OPTIONS = const <String>[
- '--categories=Client,Server',
- '--disable-type-inference',
- Flags.useOldFrontend
-];
-
-Iterable<ClassEntity> computeLiveClasses(CompilerImpl compiler) {
- return new Set<ClassEntity>()
- ..addAll(compiler.resolutionWorldBuilder.directlyInstantiatedClasses)
- ..addAll(compiler.codegenWorldBuilder.directlyInstantiatedClasses);
-}
-
-void checkClassInvariants(ClassEntity cls) {
- ClassMemberMixin impl = cls;
- Expect.isTrue(impl.areAllMembersComputed(),
- "Not all members have been computed for $cls.");
-}
-
-Future checkElementInvariantsAfterCompiling(Uri uri) async {
- CompilationResult result =
- await runCompiler(entryPoint: uri, options: DART2JS_OPTIONS);
- Expect.isTrue(result.isSuccess, "Compilation of dart2js failed.");
-
- computeLiveClasses(result.compiler).forEach(checkClassInvariants);
-}
-
-void main() {
- var uri = Uri.base.resolve(DART2JS_SOURCE);
- asyncTest(() => checkElementInvariantsAfterCompiling(uri));
-}
diff --git a/tests/compiler/dart2js/old_frontend/check_members_test.dart b/tests/compiler/dart2js/old_frontend/check_members_test.dart
deleted file mode 100644
index 26a5a53..0000000
--- a/tests/compiler/dart2js/old_frontend/check_members_test.dart
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that dart2js produces the expected static type warnings for least upper
-// bound language tests. This ensures that the analyzer and dart2js agrees
-// on these tests.
-
-import 'warnings_checker.dart';
-
-/// Map from test files to a map of their expected status. If the status map is
-/// `null` no warnings must be missing or unexpected, otherwise the status map
-/// can contain a list of line numbers for keys 'missing' and 'unexpected' for
-/// the warnings of each category.
-const Map<String, dynamic> TESTS = const {
- // Instance methods.
- 'language/check_method_override_test.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_more_parameters_t01.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_more_parameters_t02.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_fewer_parameters_t01.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_fewer_parameters_t02.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_named_parameters_t01.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_named_parameters_t02.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_named_parameters_t03.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_named_parameters_t04.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_named_parameters_t05.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_named_parameters_t06.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_subtype_t01.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_subtype_t02.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_subtype_t03.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_subtype_t04.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_subtype_t05.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'override_subtype_t06.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'same_name_static_member_in_superclass_t01.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'same_name_static_member_in_superclass_t02.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'same_name_static_member_in_superclass_t04.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'same_name_static_member_in_superclass_t05.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'same_name_static_member_in_superclass_t06.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'same_name_static_member_in_superclass_t07.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'same_name_static_member_in_superclass_t08.dart': null,
- 'co19/src/Language/Classes/Instance_Methods/'
- 'same_name_static_member_in_superclass_t09.dart': null,
-
- // Getters.
- 'co19/src/Language/Classes/Getters/override_t01.dart': null,
- 'co19/src/Language/Classes/Getters/override_t02.dart': null,
- 'co19/src/Language/Classes/Getters/override_t03.dart': null,
- 'co19/src/Language/Classes/Getters/override_t04.dart': null,
-};
-
-void main() {
- checkWarnings(TESTS);
-}
diff --git a/tests/compiler/dart2js/old_frontend/combinator_hint_test.dart b/tests/compiler/dart2js/old_frontend/combinator_hint_test.dart
deleted file mode 100644
index 3ff105c..0000000
--- a/tests/compiler/dart2js/old_frontend/combinator_hint_test.dart
+++ /dev/null
@@ -1,110 +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.
-
-// Test that the hint on empty combinators works as intended.
-
-import 'dart:async';
-import 'package:async_helper/async_helper.dart';
-import 'package:expect/expect.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/compiler.dart';
-import '../memory_compiler.dart';
-
-const SOURCE = const {
- 'show_local.dart': """
-import 'lib.dart' show Foo;
-
-main() {}
-""",
- 'hide_local.dart': """
-import 'lib.dart' hide Foo;
-
-main() {}
-""",
- 'show_package.dart': """
-import 'package:pkg/pkg.dart' show Foo;
-
-main() {}
-""",
- 'hide_package.dart': """
-import 'package:pkg/pkg.dart' hide Foo;
-
-main() {}
-""",
- 'lib.dart': '',
- 'pkg/pkg/pkg.dart': '',
-};
-
-Future<Compiler> test(Uri entryPoint,
- {bool showPackageWarnings: false,
- bool suppressHints: false,
- int hints: 0,
- Compiler cachedCompiler}) async {
- print('==================================================================');
- print('test: $entryPoint showPackageWarnings=$showPackageWarnings '
- 'suppressHints=$suppressHints');
- var options = [Flags.analyzeOnly, Flags.useOldFrontend];
- if (showPackageWarnings) {
- options.add(Flags.showPackageWarnings);
- }
- if (suppressHints) {
- options.add(Flags.suppressHints);
- }
- var collector = new DiagnosticCollector();
- CompilationResult result = await runCompiler(
- entryPoint: entryPoint,
- memorySourceFiles: SOURCE,
- options: options,
- packageRoot: Uri.parse('memory:pkg/'),
- diagnosticHandler: collector,
- cachedCompiler: cachedCompiler);
- Expect.equals(
- 0, collector.errors.length, 'Unexpected errors: ${collector.errors}');
- Expect.equals(0, collector.warnings.length,
- 'Unexpected warnings: ${collector.warnings}');
- Expect.equals(
- hints, collector.hints.length, 'Unexpected hints: ${collector.hints}');
- Expect.equals(
- 0, collector.infos.length, 'Unexpected infos: ${collector.infos}');
- print('==================================================================');
- return result.compiler;
-}
-
-Future<Compiler> testUri(Uri entrypoint,
- {bool suppressed: false, Compiler cachedCompiler}) async {
- cachedCompiler = await test(entrypoint,
- showPackageWarnings: true,
- suppressHints: false,
- hints: 1,
- cachedCompiler: cachedCompiler);
- cachedCompiler = await test(entrypoint,
- showPackageWarnings: false,
- suppressHints: false,
- hints: suppressed ? 0 : 1,
- cachedCompiler: cachedCompiler);
- cachedCompiler = await test(entrypoint,
- showPackageWarnings: true,
- suppressHints: true,
- hints: 0,
- cachedCompiler: cachedCompiler);
- cachedCompiler = await test(entrypoint,
- showPackageWarnings: false,
- suppressHints: true,
- hints: 0,
- cachedCompiler: cachedCompiler);
- return cachedCompiler;
-}
-
-void main() {
- asyncTest(() async {
- Compiler cachedCompiler =
- await testUri(Uri.parse('memory:show_local.dart'));
- cachedCompiler = await testUri(Uri.parse('memory:hide_local.dart'),
- cachedCompiler: cachedCompiler);
- cachedCompiler = await testUri(Uri.parse('memory:show_package.dart'),
- cachedCompiler: cachedCompiler);
- cachedCompiler = await testUri(Uri.parse('memory:hide_package.dart'),
- suppressed: true, cachedCompiler: cachedCompiler);
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/compile_with_empty_libraries_test.dart b/tests/compiler/dart2js/old_frontend/compile_with_empty_libraries_test.dart
deleted file mode 100644
index d16fe9e..0000000
--- a/tests/compiler/dart2js/old_frontend/compile_with_empty_libraries_test.dart
+++ /dev/null
@@ -1,18 +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.
-
-/// Test that the dart2js compiler can compile an empty script without
-/// references to core library definitions.
-
-import 'package:async_helper/async_helper.dart';
-import 'mock_compiler.dart';
-
-const String TEST = r"main() {}";
-
-main() {
- Uri uri = new Uri(scheme: 'source');
- MockCompiler compiler =
- new MockCompiler.internal(librariesOverride: (_) => '');
- asyncTest(() => compiler.run(uri));
-}
diff --git a/tests/compiler/dart2js/old_frontend/compiler_test.dart b/tests/compiler/dart2js/old_frontend/compiler_test.dart
deleted file mode 100644
index 82db42a..0000000
--- a/tests/compiler/dart2js/old_frontend/compiler_test.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2012, 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:async";
-
-import "package:async_helper/async_helper.dart";
-import 'package:compiler/compiler.dart';
-import "package:compiler/src/elements/elements.dart";
-import "package:compiler/src/old_to_new_api.dart";
-import "package:expect/expect.dart";
-
-import "mock_compiler.dart";
-
-Future testErrorHandling() {
- // Test that compiler.currentElement is set correctly when
- // reporting errors/warnings.
- MockCompiler compiler = new MockCompiler.internal();
- return compiler.init().then((_) {
- compiler.parseScript('NoSuchPrefix.NoSuchType foo() {}');
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement foo = mainApp.find('foo');
- compiler.diagnosticHandler = new LegacyCompilerDiagnostics(
- (Uri uri, int begin, int end, String message, Diagnostic kind) {
- if (kind == Diagnostic.WARNING) {
- Expect.equals(foo, compiler.currentElement);
- }
- });
- foo.computeType(compiler.resolution);
- Expect.equals(1, compiler.diagnosticCollector.warnings.length);
- });
-}
-
-main() {
- asyncTest(() => testErrorHandling());
-}
diff --git a/tests/compiler/dart2js/old_frontend/data/one_line_dart_program.dart b/tests/compiler/dart2js/old_frontend/data/one_line_dart_program.dart
deleted file mode 100644
index 24a0c96..0000000
--- a/tests/compiler/dart2js/old_frontend/data/one_line_dart_program.dart
+++ /dev/null
@@ -1 +0,0 @@
-String main() => 499
\ No newline at end of file
diff --git a/tests/compiler/dart2js/old_frontend/diagnose_ambiguous_test.dart b/tests/compiler/dart2js/old_frontend/diagnose_ambiguous_test.dart
deleted file mode 100644
index 6e8708b..0000000
--- a/tests/compiler/dart2js/old_frontend/diagnose_ambiguous_test.dart
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (c) 2013, 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 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/compiler_new.dart' show Diagnostic;
-import 'package:expect/expect.dart';
-import '../memory_compiler.dart';
-
-void main() {
- DiagnosticCollector collector = new DiagnosticCollector();
- asyncTest(() async {
- CompilationResult result = await runCompiler(
- memorySourceFiles: MEMORY_SOURCE_FILES,
- diagnosticHandler: collector,
- options: ['--analyze-all', Flags.useOldFrontend]);
-
- List<String> diagnostics = <String>[];
- collector.messages.forEach((CollectedMessage message) {
- if (message.kind == Diagnostic.VERBOSE_INFO) return;
- diagnostics.add(message.toString());
- });
- diagnostics.sort();
- var expected = [
- "MessageKind.AMBIGUOUS_LOCATION:"
- "memory:exporter.dart:43:49:'hest' is defined here.:info",
- "MessageKind.AMBIGUOUS_LOCATION:"
- "memory:library.dart:41:47:'hest' is defined here.:info",
- "MessageKind.DUPLICATE_IMPORT:"
- "memory:main.dart:86:92:Duplicate import of 'hest'.:warning",
- "MessageKind.IMPORTED_HERE:"
- "memory:main.dart:0:22:'hest' is imported here.:info",
- "MessageKind.IMPORTED_HERE:"
- "memory:main.dart:23:46:'hest' is imported here.:info",
- ];
- print(">>\n$diagnostics\n<<");
- Expect.listEquals(expected, diagnostics);
- Expect.isTrue(result.isSuccess);
- });
-}
-
-const Map MEMORY_SOURCE_FILES = const {
- 'main.dart': """
-import 'library.dart';
-import 'exporter.dart';
-
-main() {
- Fisk x = null;
- fisk();
- hest();
-}
-""",
- 'library.dart': """
-library lib;
-
-class Fisk {
-}
-
-fisk() {}
-
-hest() {}
-""",
- 'exporter.dart': """
-library exporter;
-
-export 'library.dart';
-
-hest() {}
-""",
-};
diff --git a/tests/compiler/dart2js/old_frontend/duplicate_library_test.dart b/tests/compiler/dart2js/old_frontend/duplicate_library_test.dart
deleted file mode 100644
index ea030a3..0000000
--- a/tests/compiler/dart2js/old_frontend/duplicate_library_test.dart
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) 2014, 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.
-
-// Test that duplicate library names result in different messages depending
-// on whether the libraries are based on the same resource.
-
-import 'dart:async';
-import 'package:async_helper/async_helper.dart';
-import 'package:expect/expect.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/diagnostics/messages.dart' show MessageKind;
-import '../memory_compiler.dart';
-
-void check(String kind, Iterable<CollectedMessage> messages,
- List<MessageKind> expectedMessageKinds) {
- Expect.equals(expectedMessageKinds.length, messages.length,
- "Unexpected $kind count: $messages");
- int i = 0;
- messages.forEach((CollectedMessage message) {
- Expect.equals(expectedMessageKinds[i++], message.messageKind);
- });
-}
-
-Future test(Map<String, String> source,
- {List<MessageKind> warnings: const <MessageKind>[],
- List<MessageKind> hints: const <MessageKind>[]}) async {
- DiagnosticCollector collector = new DiagnosticCollector();
- await runCompiler(
- memorySourceFiles: source,
- diagnosticHandler: collector,
- showDiagnostics: true,
- options: [Flags.analyzeOnly, Flags.analyzeAll, Flags.useOldFrontend],
- packageRoot: Uri.parse('memory:pkg/'));
-
- Expect.isTrue(collector.errors.isEmpty);
- check('warning', collector.warnings, warnings);
- check('hint', collector.hints, hints);
- Expect.isTrue(collector.infos.isEmpty);
-}
-
-void main() {
- asyncTest(runTests);
-}
-
-Future runTests() async {
- await test({
- 'main.dart': """
-library main;
-
-import 'package:lib/foo.dart';
-import 'pkg/lib/foo.dart';
-""",
- 'pkg/lib/foo.dart': """
-library lib.foo;
-"""
- }, warnings: [
- MessageKind.DUPLICATED_LIBRARY_RESOURCE
- ], hints: []);
-
- await test({
- 'main.dart': """
-library main;
-
-import 'package:lib/bar.dart';
-import 'pkg/foo.dart';
-""",
- 'pkg/foo.dart': """
-library foo;
-
-import 'lib/bar.dart';
-""",
- 'pkg/lib/bar.dart': """
-library lib.bar;
-"""
- }, warnings: [
- MessageKind.DUPLICATED_LIBRARY_RESOURCE
- ], hints: []);
-
- await test({
- 'main.dart': """
-library main;
-
-import 'foo.dart';
-import 'pkg/lib/baz.dart';
-""",
- 'foo.dart': """
-library foo;
-
-import 'package:lib/baz.dart';
-""",
- 'pkg/lib/baz.dart': """
-library lib.baz;
-"""
- }, warnings: [
- MessageKind.DUPLICATED_LIBRARY_RESOURCE
- ], hints: []);
-
- await test({
- 'main.dart': """
-library main;
-
-import 'foo.dart';
-import 'pkg/bar.dart';
-""",
- 'foo.dart': """
-library foo;
-
-import 'package:lib/boz.dart';
-""",
- 'pkg/bar.dart': """
-library bar;
-
-import 'lib/boz.dart';
-""",
- 'pkg/lib/boz.dart': """
-library lib.boz;
-"""
- }, warnings: [
- MessageKind.DUPLICATED_LIBRARY_RESOURCE
- ], hints: []);
-
- await test({
- 'main.dart': """
-library main;
-
-import 'package:lib/qux.dart';
-import 'pkg/lib/qux.dart';
-""",
- 'pkg/lib/qux.dart': """
-// No library tag.
-"""
- }, hints: [
- MessageKind.DUPLICATED_RESOURCE,
- ]);
-
- await test({
- 'main.dart': """
-library main;
-
-import 'foo.dart';
-import 'bar.dart';
-""",
- 'foo.dart': """
-library lib;
-""",
- 'bar.dart': """
-library lib;
-"""
- }, warnings: [
- MessageKind.DUPLICATED_LIBRARY_NAME,
- MessageKind.DUPLICATED_LIBRARY_NAME
- ], hints: []);
-}
diff --git a/tests/compiler/dart2js/old_frontend/embedded_category_api_boundary_test.dart b/tests/compiler/dart2js/old_frontend/embedded_category_api_boundary_test.dart
deleted file mode 100644
index 8fcf124..0000000
--- a/tests/compiler/dart2js/old_frontend/embedded_category_api_boundary_test.dart
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE.md file.
-
-/// Tests that analyzing everything from the libraries that are public from the
-/// embedded category does not cause elements from other libraries to be
-/// processed.
-library embedded_category_boundary_test;
-
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/compiler.dart';
-import 'package:compiler/src/elements/elements.dart';
-import 'package:sdk_library_metadata/libraries.dart';
-
-import 'analyze_helper.dart';
-
-main() async {
- List<Uri> uriList = new List<Uri>();
- libraries.forEach((String name, LibraryInfo info) {
- if (info.categories.contains(Category.embedded)) {
- uriList.add(new Uri(scheme: 'dart', path: name));
- }
- });
- asyncTest(() async {
- await analyze(uriList, {},
- checkResults: checkResults, mode: AnalysisMode.MAIN);
- });
-}
-
-/// These elements are currently escaping from dart:async via
-/// `core._Resource#_readAsStream`.
-Set<String> whiteList = new Set.from([
- "function(StreamController#addError)",
- "getter(StreamController#stream)",
- "setter(StreamController#onListen)"
-]);
-
-bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) {
- return compiler.enqueuer.resolution.processedEntities.every((_element) {
- MemberElement element = _element;
- if (whiteList.contains("$element")) return true;
- LibraryInfo info = libraries[element.library.canonicalUri.path];
- bool isAllowedInEmbedded =
- info.isInternal || info.categories.contains(Category.embedded);
- if (!isAllowedInEmbedded) {
- print(
- 'Disallowed element: $element from ${element.library.canonicalUri}');
- }
- return isAllowedInEmbedded;
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/erroneous_element_test.dart b/tests/compiler/dart2js/old_frontend/erroneous_element_test.dart
deleted file mode 100644
index 0fee336..0000000
--- a/tests/compiler/dart2js/old_frontend/erroneous_element_test.dart
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2012, 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 'package:expect/expect.dart';
-
-import 'package:compiler/src/diagnostics/messages.dart' show MessageKind;
-import 'package:compiler/src/elements/elements.dart';
-import 'package:compiler/src/elements/modelx.dart' show ErroneousElementX;
-
-void main() {
- ErroneousElement e = new ErroneousElementX(
- MessageKind.GENERIC, {'text': 'error'}, 'foo', null);
- Expect.stringEquals('<foo: error>', '$e');
-}
diff --git a/tests/compiler/dart2js/old_frontend/error_token_test.dart b/tests/compiler/dart2js/old_frontend/error_token_test.dart
deleted file mode 100644
index fb0854e..0000000
--- a/tests/compiler/dart2js/old_frontend/error_token_test.dart
+++ /dev/null
@@ -1,54 +0,0 @@
-// 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.
-
-// Test that we don't report invalid modifier on error tokens.
-
-library dart2js.test.error_token;
-
-import 'dart:async';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import "package:compiler/src/diagnostics/messages.dart";
-import 'package:expect/expect.dart';
-import '../memory_compiler.dart';
-
-Future runTest(String code,
- {MessageKind error, int expectedWarningCount: 0}) async {
- DiagnosticCollector diagnostics = new DiagnosticCollector();
- OutputCollector output = new OutputCollector();
- await runCompiler(
- entryPoint: Uri.parse('memory:main.dart'),
- memorySourceFiles: {'main.dart': code},
- diagnosticHandler: diagnostics,
- outputProvider: output,
- options: [Flags.useOldFrontend]);
-
- Expect.equals(error != null ? 1 : 0, diagnostics.errors.length);
- if (error != null)
- Expect.equals(error, diagnostics.errors.first.message.kind);
- Expect.equals(expectedWarningCount, diagnostics.warnings.length);
- Expect.equals(0, diagnostics.hints.length);
- Expect.equals(0, diagnostics.infos.length);
-}
-
-void main() {
- asyncTest(() async {
- await runTest('''
-main() {Foo.bar();}
-class Foo {
- static void bar() {
- baz());
- }
-}
-''', error: MessageKind.MISSING_TOKEN_AFTER_THIS, expectedWarningCount: 1);
-
- await runTest('''
-main() {new C(v);}
-class C {
- C(v) {
- throw '');
- }
-}''', error: MessageKind.MISSING_TOKEN_AFTER_THIS, expectedWarningCount: 1);
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/find_my_name_test.dart b/tests/compiler/dart2js/old_frontend/find_my_name_test.dart
deleted file mode 100644
index 72063ed..0000000
--- a/tests/compiler/dart2js/old_frontend/find_my_name_test.dart
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2012, 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 "package:expect/expect.dart";
-import "package:async_helper/async_helper.dart";
-import "package:compiler/src/elements/elements.dart";
-import 'package:compiler/src/elements/entity_utils.dart' as utils;
-import "mock_compiler.dart";
-import "parser_helper.dart";
-import 'package:compiler/src/elements/modelx.dart';
-
-String TEST_0 = '''
-class Foo {
- Foo();
- Foo.named();
- factory Foo._internal() => null;
- operator+(other) => null;
-}
-''';
-
-String TEST_1 = '''
-class Bar {
- const Bar();
- const Bar.named();
- Map<int, List<int>> baz() => null;
-}
-''';
-
-main() {
- asyncTest(() => MockCompiler.create((MockCompiler compiler) {
- testClass(TEST_0, compiler);
- testClass(TEST_1, compiler);
- }));
-}
-
-testClass(String code, MockCompiler compiler) {
- int skip = code.indexOf('{');
- ClassElementX cls = parseUnit(code, compiler, compiler.mainApp).head;
- cls.parseNode(compiler.parsingContext);
- cls.forEachLocalMember((Element e) {
- String name = e.name;
- if (e.isConstructor) {
- ConstructorElement c = e;
- name = utils.reconstructConstructorName(c).replaceFirst(r'$', '.');
- }
- Expect.equals(code.indexOf(name, skip), e.position.charOffset);
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/flatten_test.dart b/tests/compiler/dart2js/old_frontend/flatten_test.dart
deleted file mode 100644
index 5e08375..0000000
--- a/tests/compiler/dart2js/old_frontend/flatten_test.dart
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) 2013, 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 flatten_test;
-
-import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import '../type_test_helper.dart';
-import 'package:compiler/src/elements/resolution_types.dart';
-import "package:compiler/src/elements/elements.dart" show ClassElement;
-
-void main() {
- asyncTest(() => TypeEnvironment.create(r"""
- abstract class F<T> implements Future<T> {}
- abstract class G<T> implements Future<G<T>> {}
- abstract class H<T> implements Future<H<H<T>>> {}
- """).then((env) {
- void check(
- ResolutionDartType T, ResolutionDartType expectedFlattenedType) {
- ResolutionDartType flattenedType = env.flatten(T);
- Expect.equals(
- expectedFlattenedType,
- flattenedType,
- "Unexpected flattening of '$T' = '$flattenedType',"
- "expected '$expectedFlattenedType'.");
- }
-
- ClassElement Future_ = env.getElement('Future');
- ClassElement F = env.getElement('F');
- ClassElement G = env.getElement('G');
- ClassElement H = env.getElement('H');
- 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_);
-
- // flatten(Future) = dynamic
- check(Future_.rawType, dynamic_);
-
- // flatten(Future<int>) = int
- check(Future_int, int_);
-
- // flatten(Future<Future<int>>) = int
- check(instantiate(Future_, [Future_int]), int_);
-
- // flatten(F) = dynamic
- check(F.rawType, dynamic_);
-
- // flatten(F<int>) = int
- check(F_int, int_);
-
- // flatten(F<Future<int>>) = Future<int>
- check(instantiate(F, [Future_int]), Future_int);
-
- // flatten(G) = G
- check(G.rawType, G.rawType);
-
- // flatten(G<int>) = G<int>
- check(G_int, G_int);
-
- // flatten(H) = H<H>
- check(H.rawType, instantiate(H, [H.rawType]));
-
- // flatten(H<int>) = H<H<int>>
- check(H_int, H_H_int);
-
- // flatten(Future<F<int>>) = int
- check(instantiate(Future_, [F_int]), int_);
-
- // flatten(Future<G<int>>) = int
- check(instantiate(Future_, [G_int]), G_int);
-
- // flatten(Future<H<int>>) = int
- check(instantiate(Future_, [H_int]), H_H_int);
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/frontend_checker.dart b/tests/compiler/dart2js/old_frontend/frontend_checker.dart
deleted file mode 100644
index 7fc1552..0000000
--- a/tests/compiler/dart2js/old_frontend/frontend_checker.dart
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright (c) 2014, 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.
-
-// Checks that dart2js produces the expected static type warnings and
-// compile-time errors for the provided multitests.
-
-import 'dart:async';
-import 'dart:io';
-
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/util/uri_extras.dart' show relativize;
-import '../memory_compiler.dart';
-
-import '../../../../tools/testing/dart/multitest.dart'
- show extractTestsFromMultitest;
-import '../../../../tools/testing/dart/path.dart' show Path;
-
-/// Check the analysis of the multitests in [testFiles] to result in the
-/// expected static warnings and compile-time errors.
-///
-/// [testFiles] is a map of the test files to be checked together with their
-/// associated white listing.
-///
-/// For instance if [testFiles] contain the mapping
-/// 'language/async_await_syntax_test.dart': const ['a03b', 'a04b']
-/// the multitests in 'language/async_await_syntax_test.dart' are checked but
-/// the subtests 'a03b' and 'a04c' are expected to fail.
-void check(Map<String, List<String>> testFiles,
- {List<String> arguments: const <String>[],
- List<String> options: const <String>[]}) {
- bool outcomeMismatch = false;
- bool verbose = arguments.contains('-v');
- var cachedCompiler;
- asyncTest(() => Future.forEach(testFiles.keys, (String testFile) {
- Map<String, String> testSources = {};
- Map<String, Set<String>> testOutcomes = {};
- String fileName = 'tests/$testFile';
- extractTestsFromMultitest(
- new Path(fileName), testSources, testOutcomes);
- return Future.forEach(testSources.keys, (String testName) async {
- String testFileName = '$fileName/$testName';
- Set<String> expectedOutcome = testOutcomes[testName];
- bool expectFailure = testFiles[testFile].contains(testName);
- DiagnosticCollector collector = new DiagnosticCollector();
- CompilationResult result = await runCompiler(
- entryPoint: Uri.parse('memory:$testFileName'),
- memorySourceFiles: {testFileName: testSources[testName]},
- diagnosticHandler: collector,
- options: [Flags.analyzeOnly, Flags.useOldFrontend]
- ..addAll(options),
- showDiagnostics: verbose,
- cachedCompiler: cachedCompiler);
- var compiler = result.compiler;
- bool unexpectedResult = false;
- if (expectedOutcome.contains('compile-time error') ||
- expectedOutcome.contains('syntax error')) {
- if (collector.errors.isEmpty) {
- print('$testFileName: Missing compile-time error.');
- unexpectedResult = true;
- }
- } else if (expectedOutcome.contains('static type warning')) {
- if (collector.warnings.isEmpty) {
- print('$testFileName: Missing static type warning.');
- unexpectedResult = true;
- }
- } else {
- // Expect ok.
- if (!collector.errors.isEmpty || !collector.warnings.isEmpty) {
- collector.errors.forEach((message) {
- print('$testFileName: Unexpected error: ${message.message}');
- });
- collector.warnings.forEach((message) {
- print('$testFileName: Unexpected warning: ${message.message}');
- });
- unexpectedResult = true;
- }
- }
- if (expectFailure) {
- if (unexpectedResult) {
- unexpectedResult = false;
- } else {
- print('$testFileName: The test is white-listed '
- 'and therefore expected to fail.');
- unexpectedResult = true;
- }
- }
- if (unexpectedResult) {
- outcomeMismatch = true;
- }
- cachedCompiler = compiler;
- });
- }).then((_) {
- if (outcomeMismatch) {
- String testFileName =
- relativize(Uri.base, Platform.script, Platform.isWindows);
- print('''
-
-===
-=== ERROR: Unexpected result of analysis.
-===
-=== Please update the white-listing in $testFileName
-===
-
-''');
- exit(1);
- }
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/generic_method_type_usage_test.dart b/tests/compiler/dart2js/old_frontend/generic_method_type_usage_test.dart
deleted file mode 100644
index 7d352c0..0000000
--- a/tests/compiler/dart2js/old_frontend/generic_method_type_usage_test.dart
+++ /dev/null
@@ -1,127 +0,0 @@
-// 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 verifying that method type variables are considered to denote
-/// the type `dynamic`.
-///
-/// NB: This test is intended to succeed with a `dart2js` with the option
-/// '--generic-method-syntax', but it should fail with a full implementation
-/// of generic method support, and it should fail with every other tool than
-/// `dart2js`.
-
-library dart2js.test.generic_method_type_usage;
-
-import 'dart:async';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import "package:compiler/src/diagnostics/messages.dart";
-import 'package:expect/expect.dart';
-import '../memory_compiler.dart';
-
-const MEMORY_SOURCE_FILES = const {
- 'type_variable_is_dynamic.dart': '''
-class C {
- bool aMethod<X>(X x) {
- // `dynamic` is assignable to both `int` and `String`: no warnings.
- int i = x;
- String s = x;
- try {
- // Only `dynamic` allows unknown member lookup without a warning.
- var y = x.undefinedMember;
- } on NoSuchMethodError catch (_) {
- return true;
- }
- return false;
- }
-}
-
-bool aFunction<X>(X x) {
- // `dynamic` is assignable to both `int` and `String`: no warnings.
- int i = x;
- String s = x;
- try {
- // Only `dynamic` allows unknown member lookup without a warning.
- var y = x.undefinedMember;
- } on NoSuchMethodError catch (_) {
- return true;
- }
- return false;
-}
-
-main() {
- print(new C().aMethod<Set>(null));
- print(aFunction<Set>(null));
-}
-''',
- 'cannot_new_method_type_variable.dart': '''
-class C {
- X aMethod<X>() => new X();
-}
-
-main() {
- new C().aMethod<Set>();
-}
-''',
- 'cannot_new_function_type_variable.dart': '''
-X aFunction<X>() => new X(42);
-
-main() {
- aFunction<Set>();
-}
-''',
- 'dynamic_as_type_argument.dart': '''
-main() {
- method<dynamic>();
-}
-method<T>() {}
-''',
- 'malformed_type_argument.dart': '''
-main() {
- method<Unresolved>();
-}
-method<T>() {}
-''',
-};
-
-Future runTest(Uri main, {MessageKind warning, MessageKind info}) async {
- print("----\nentry-point: $main\n");
-
- DiagnosticCollector diagnostics = new DiagnosticCollector();
- OutputCollector output = new OutputCollector();
- await runCompiler(
- entryPoint: main,
- options: const <String>["--generic-method-syntax", Flags.useOldFrontend],
- memorySourceFiles: MEMORY_SOURCE_FILES,
- diagnosticHandler: diagnostics,
- outputProvider: output);
-
- Expect.isFalse(output.hasExtraOutput);
- Expect.equals(0, diagnostics.errors.length, "Unexpected errors.");
- Expect.equals(warning != null ? 1 : 0, diagnostics.warnings.length);
- if (warning != null) {
- Expect.equals(warning, diagnostics.warnings.first.message.kind);
- }
- Expect.equals(info != null ? 1 : 0, diagnostics.infos.length);
- if (info != null) {
- Expect.equals(info, diagnostics.infos.first.message.kind);
- }
- Expect.equals(0, diagnostics.hints.length);
-}
-
-void main() {
- asyncTest(() async {
- await runTest(Uri.parse('memory:type_variable_is_dynamic.dart'));
-
- await runTest(Uri.parse('memory:cannot_new_method_type_variable.dart'),
- warning: MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE);
-
- await runTest(Uri.parse('memory:cannot_new_function_type_variable.dart'),
- warning: MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE);
-
- await runTest(Uri.parse('memory:dynamic_as_type_argument.dart'));
-
- await runTest(Uri.parse('memory:malformed_type_argument.dart'),
- warning: MessageKind.CANNOT_RESOLVE_TYPE);
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/import_test.dart b/tests/compiler/dart2js/old_frontend/import_test.dart
deleted file mode 100644
index 59f5362..0000000
--- a/tests/compiler/dart2js/old_frontend/import_test.dart
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that the compiler can handle missing files used in imports, exports,
-// part tags or as the main source file.
-
-library dart2js.test.import;
-
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/diagnostics/messages.dart';
-import '../memory_compiler.dart';
-
-const MEMORY_SOURCE_FILES = const {
- 'main.dart': '''
-
-library main;
-
-import 'dart:thisLibraryShouldNotExist';
-import 'package:thisPackageShouldNotExist/thisPackageShouldNotExist.dart';
-export 'foo.dart';
-
-part 'bar.dart';
-
-main() {
- int i = "";
-}
-''',
- 'part.dart': '''
-part of lib;
-
-main() {}
-''',
- 'lib.dart': '''
-library lib;
-
-import 'part.dart';
-
-part 'part.dart';
-''',
-};
-
-testEntryPointIsPart() async {
- var collector = new DiagnosticCollector();
- await runCompiler(
- entryPoint: Uri.parse('memory:part.dart'),
- memorySourceFiles: MEMORY_SOURCE_FILES,
- diagnosticHandler: collector,
- options: [Flags.useOldFrontend]);
-
- collector.checkMessages([const Expected.error(MessageKind.MAIN_HAS_PART_OF)]);
-}
-
-testImportPart() async {
- var collector = new DiagnosticCollector();
- await runCompiler(
- entryPoint: Uri.parse('memory:lib.dart'),
- memorySourceFiles: MEMORY_SOURCE_FILES,
- diagnosticHandler: collector,
- options: [Flags.useOldFrontend]);
-
- collector.checkMessages([
- const Expected.error(MessageKind.IMPORT_PART_OF),
- const Expected.info(MessageKind.IMPORT_PART_OF_HERE)
- ]);
-}
-
-testMissingImports() async {
- var collector = new DiagnosticCollector();
- await runCompiler(
- memorySourceFiles: MEMORY_SOURCE_FILES,
- diagnosticHandler: collector,
- options: [Flags.useOldFrontend]);
-
- collector.checkMessages([
- const Expected.error(MessageKind.READ_URI_ERROR),
- const Expected.error(MessageKind.LIBRARY_NOT_FOUND),
- const Expected.error(MessageKind.LIBRARY_NOT_FOUND),
- const Expected.error(MessageKind.READ_URI_ERROR),
- const Expected.warning(MessageKind.NOT_ASSIGNABLE)
- ]);
-}
-
-testMissingMain() async {
- var collector = new DiagnosticCollector();
- await runCompiler(
- entryPoint: Uri.parse('memory:missing.dart'),
- diagnosticHandler: collector,
- options: [Flags.useOldFrontend]);
- collector.checkMessages([const Expected.error(MessageKind.READ_SELF_ERROR)]);
-}
-
-void main() {
- asyncTest(() async {
- await testEntryPointIsPart();
- await testImportPart();
- await testMissingImports();
- await testMissingMain();
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/least_upper_bound_language_test.dart b/tests/compiler/dart2js/old_frontend/least_upper_bound_language_test.dart
deleted file mode 100644
index 53d5900..0000000
--- a/tests/compiler/dart2js/old_frontend/least_upper_bound_language_test.dart
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that dart2js produces the expected static type warnings for least upper
-// bound language tests. This ensures that the analyzer and dart2js agrees
-// on these tests.
-
-import 'warnings_checker.dart';
-
-/// Map from test files to a map of their expected status. If the status map is
-/// `null` no warnings must be missing or unexpected, otherwise the status map
-/// can contain a list of line numbers for keys 'missing' and 'unexpected' for
-/// the warnings of each category.
-const Map<String, dynamic> TESTS = const {
- 'language/least_upper_bound_test.dart': null,
- 'language/least_upper_bound_expansive_test.dart': null,
-};
-
-void main() {
- checkWarnings(TESTS);
-}
diff --git a/tests/compiler/dart2js/old_frontend/least_upper_bound_test.dart b/tests/compiler/dart2js/old_frontend/least_upper_bound_test.dart
deleted file mode 100644
index bb2f12d..0000000
--- a/tests/compiler/dart2js/old_frontend/least_upper_bound_test.dart
+++ /dev/null
@@ -1,851 +0,0 @@
-// Copyright (c) 2013, 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 least_upper_bound_test;
-
-import 'package:expect/expect.dart';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/elements/resolution_types.dart';
-import 'package:compiler/src/elements/elements.dart' show ClassElement;
-
-import '../type_test_helper.dart';
-
-void main() {
- testInterface1();
- testInterface2();
- testGeneric();
- testMixin();
- testFunction();
- testTypeVariable();
-}
-
-void testInterface1() {
- asyncTest(() => TypeEnvironment.create(r"""
- class A {} // A and B have equal depth.
- class B {}
- class I implements A, B {}
- class J implements A, B {}
- """).then((env) {
- ResolutionDartType Object_ = env['Object'];
- ResolutionDartType A = env['A'];
- ResolutionDartType B = env['B'];
- ResolutionDartType I = env['I'];
- ResolutionDartType J = env['J'];
-
- checkLub(ResolutionDartType a, ResolutionDartType b,
- ResolutionDartType expect) {
- ResolutionDartType lub = env.computeLeastUpperBound(a, b);
- Expect.equals(
- expect, lub, 'Unexpected lub($a,$b) = $lub, expected $expect.');
- }
-
- checkLub(Object_, Object_, Object_);
- checkLub(Object_, A, Object_);
- checkLub(Object_, B, Object_);
- checkLub(Object_, I, Object_);
- checkLub(Object_, J, Object_);
-
- checkLub(A, Object_, Object_);
- checkLub(A, A, A);
- checkLub(A, B, Object_);
- checkLub(A, I, A);
- checkLub(A, J, A);
-
- checkLub(B, Object_, Object_);
- checkLub(B, A, Object_);
- checkLub(B, B, B);
- checkLub(B, I, B);
- checkLub(B, J, B);
-
- checkLub(I, Object_, Object_);
- checkLub(I, A, A);
- checkLub(I, B, B);
- checkLub(I, I, I);
- checkLub(I, J, Object_);
-
- checkLub(J, Object_, Object_);
- checkLub(J, A, A);
- checkLub(J, B, B);
- checkLub(J, I, Object_);
- checkLub(J, J, J);
- }));
-}
-
-void testInterface2() {
- asyncTest(() => TypeEnvironment.create(r"""
- class A {}
- class B {}
- class C extends B {} // This makes C have higher depth than A.
- class I implements A, C {}
- class J implements A, C {}
- """).then((env) {
- 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(ResolutionDartType a, ResolutionDartType b,
- ResolutionDartType expectedLub) {
- ResolutionDartType lub = env.computeLeastUpperBound(a, b);
- Expect.equals(expectedLub, lub,
- 'Unexpected lub($a,$b) = $lub, expected $expectedLub');
- }
-
- checkLub(Object_, Object_, Object_);
- checkLub(Object_, A, Object_);
- checkLub(Object_, B, Object_);
- checkLub(Object_, C, Object_);
- checkLub(Object_, I, Object_);
- checkLub(Object_, J, Object_);
-
- checkLub(A, Object_, Object_);
- checkLub(A, A, A);
- checkLub(A, B, Object_);
- checkLub(A, C, Object_);
- checkLub(A, I, A);
- checkLub(A, J, A);
-
- checkLub(B, Object_, Object_);
- checkLub(B, A, Object_);
- checkLub(B, B, B);
- checkLub(B, C, B);
- checkLub(B, I, B);
- checkLub(B, J, B);
-
- checkLub(C, Object_, Object_);
- checkLub(C, A, Object_);
- checkLub(C, B, B);
- checkLub(C, C, C);
- checkLub(C, I, C);
- checkLub(C, J, C);
-
- checkLub(I, Object_, Object_);
- checkLub(I, A, A);
- checkLub(I, B, B);
- checkLub(I, C, C);
- checkLub(I, I, I);
- checkLub(I, J, C);
-
- checkLub(J, Object_, Object_);
- checkLub(J, A, A);
- checkLub(J, B, B);
- checkLub(J, C, C);
- checkLub(J, I, C);
- checkLub(J, J, J);
- }));
-}
-
-void testGeneric() {
- asyncTest(() => TypeEnvironment.create(r"""
- class A {}
- class B {}
- class C extends B {}
- class I<T> {}
- """).then((env) {
- ResolutionDartType Object_ = env['Object'];
- ResolutionDartType A = env['A'];
- ResolutionDartType B = env['B'];
- ResolutionDartType C = env['C'];
- ClassElement I = env.getElement('I');
- ResolutionDartType I_A = instantiate(I, [A]);
- ResolutionDartType I_B = instantiate(I, [B]);
- ResolutionDartType I_C = instantiate(I, [C]);
-
- checkLub(ResolutionDartType a, ResolutionDartType b,
- ResolutionDartType expectedLub) {
- ResolutionDartType lub = env.computeLeastUpperBound(a, b);
- Expect.equals(expectedLub, lub,
- 'Unexpected lub($a,$b) = $lub, expected $expectedLub');
- }
-
- checkLub(Object_, Object_, Object_);
- checkLub(Object_, A, Object_);
- checkLub(Object_, B, Object_);
- checkLub(Object_, C, Object_);
- checkLub(Object_, I_A, Object_);
- checkLub(Object_, I_B, Object_);
- checkLub(Object_, I_C, Object_);
-
- checkLub(A, Object_, Object_);
- checkLub(A, A, A);
- checkLub(A, B, Object_);
- checkLub(A, C, Object_);
- checkLub(A, I_A, Object_);
- checkLub(A, I_B, Object_);
- checkLub(A, I_C, Object_);
-
- checkLub(B, Object_, Object_);
- checkLub(B, A, Object_);
- checkLub(B, B, B);
- checkLub(B, C, B);
- checkLub(B, I_A, Object_);
- checkLub(B, I_B, Object_);
- checkLub(B, I_C, Object_);
-
- checkLub(C, Object_, Object_);
- checkLub(C, A, Object_);
- checkLub(C, B, B);
- checkLub(C, C, C);
- checkLub(C, I_A, Object_);
- checkLub(C, I_B, Object_);
- checkLub(C, I_C, Object_);
-
- checkLub(I_A, Object_, Object_);
- checkLub(I_A, A, Object_);
- checkLub(I_A, B, Object_);
- checkLub(I_A, C, Object_);
- checkLub(I_A, I_A, I_A);
- checkLub(I_A, I_B, Object_);
- checkLub(I_A, I_C, Object_);
-
- checkLub(I_B, Object_, Object_);
- checkLub(I_B, A, Object_);
- checkLub(I_B, B, Object_);
- checkLub(I_B, C, Object_);
- checkLub(I_B, I_A, Object_);
- checkLub(I_B, I_B, I_B);
- checkLub(I_B, I_C, Object_);
-
- checkLub(I_C, Object_, Object_);
- checkLub(I_C, A, Object_);
- checkLub(I_C, B, Object_);
- checkLub(I_C, C, Object_);
- checkLub(I_C, I_A, Object_);
- checkLub(I_C, I_B, Object_);
- checkLub(I_C, I_C, I_C);
- }));
-}
-
-void testMixin() {
- asyncTest(() => TypeEnvironment.create(r"""
- class A {}
- class B {}
- class C extends B {}
- class D extends C {} // This makes D have higher depth than Object+A.
- class I extends Object with A, B implements A, D {}
- class I2 extends Object with A, B implements A, D {}
- class J extends Object with B, A implements A, D {}
- """).then((env) {
- 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(ResolutionDartType a, ResolutionDartType b,
- ResolutionDartType expectedLub) {
- ResolutionDartType lub = env.computeLeastUpperBound(a, b);
- Expect.equals(expectedLub, lub,
- 'Unexpected lub($a,$b) = $lub, expected $expectedLub');
- }
-
- checkLub(Object_, Object_, Object_);
- checkLub(Object_, A, Object_);
- checkLub(Object_, B, Object_);
- checkLub(Object_, C, Object_);
- checkLub(Object_, D, Object_);
- checkLub(Object_, I, Object_);
- checkLub(Object_, I2, Object_);
- checkLub(Object_, J, Object_);
-
- checkLub(A, Object_, Object_);
- checkLub(A, A, A);
- checkLub(A, B, Object_);
- checkLub(A, C, Object_);
- checkLub(A, D, Object_);
- checkLub(A, I, A);
- checkLub(A, I2, A);
- checkLub(A, J, A);
-
- checkLub(B, Object_, Object_);
- checkLub(B, A, Object_);
- checkLub(B, B, B);
- checkLub(B, C, B);
- checkLub(B, D, B);
- checkLub(B, I, B);
- checkLub(B, I2, B);
- checkLub(B, J, B);
-
- checkLub(C, Object_, Object_);
- checkLub(C, A, Object_);
- checkLub(C, B, B);
- checkLub(C, C, C);
- checkLub(C, D, C);
- checkLub(C, I, C);
- checkLub(C, I2, C);
- checkLub(C, J, C);
-
- checkLub(D, Object_, Object_);
- checkLub(D, A, Object_);
- checkLub(D, B, B);
- checkLub(D, C, C);
- checkLub(D, D, D);
- checkLub(D, I, D);
- checkLub(D, I2, D);
- checkLub(D, J, D);
-
- checkLub(I, Object_, Object_);
- checkLub(I, A, A);
- checkLub(I, B, B);
- checkLub(I, C, C);
- checkLub(I, D, D);
- checkLub(I, I, I);
- checkLub(I, I2, D);
- checkLub(I, J, D);
-
- checkLub(I2, Object_, Object_);
- checkLub(I2, A, A);
- checkLub(I2, B, B);
- checkLub(I2, C, C);
- checkLub(I2, D, D);
- checkLub(I2, I, D);
- checkLub(I2, I2, I2);
- checkLub(I2, J, D);
-
- checkLub(J, Object_, Object_);
- checkLub(J, A, A);
- checkLub(J, B, B);
- checkLub(J, C, C);
- checkLub(J, D, D);
- checkLub(J, I, D);
- checkLub(J, I2, D);
- checkLub(J, J, J);
- }));
-}
-
-void testFunction() {
- asyncTest(() => TypeEnvironment.create(r"""
- class A {}
- class B {}
- class C extends B {}
-
- typedef dynamic__();
- typedef void void__();
- typedef A A__();
- typedef B B__();
- typedef C C__();
-
- typedef void void__A_B(A a, B b);
- typedef void void__A_C(A a, C b);
- typedef void void__B_A(B a, A b);
- typedef void void__B_C(B a, C b);
-
- typedef void void___B([B a]);
- typedef void void___B_C([B a, C b]);
- typedef void void___C_C([C a, C b]);
-
- typedef void void____B({B a});
- typedef void void____B_C({B a, C b});
- typedef void void____C_C({C a, C b});
- """).then((env) {
- 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.
- 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_]);
- 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(ResolutionDartType a, ResolutionDartType b,
- ResolutionDartType expectedLub) {
- ResolutionDartType lub = env.computeLeastUpperBound(a, b);
- if (a != b) {
- expectedLub = expectedLub.unaliased;
- lub = lub.unaliased;
- }
- Expect.equals(
- expectedLub,
- lub,
- 'Unexpected lub(${a.unaliased},'
- '${b.unaliased} = '
- '${lub}, expected ${expectedLub}');
- }
-
- checkLub(Object_, Object_, Object_);
- checkLub(Object_, Function_, Object_);
- checkLub(Object_, dynamic__, Object_);
- checkLub(Object_, void__, Object_);
- checkLub(Object_, A__, Object_);
- checkLub(Object_, B__, Object_);
- checkLub(Object_, C__, Object_);
- checkLub(Object_, void__A_B, Object_);
- checkLub(Object_, void__A_C, Object_);
- checkLub(Object_, void__B_A, Object_);
- checkLub(Object_, void__B_C, Object_);
- checkLub(Object_, void___B, Object_);
- checkLub(Object_, void___B_C, Object_);
- checkLub(Object_, void___C_C, Object_);
- checkLub(Object_, void____B, Object_);
- checkLub(Object_, void____B_C, Object_);
- checkLub(Object_, void____C_C, Object_);
-
- checkLub(Function_, Object_, Object_);
- checkLub(Function_, Function_, Function_);
- checkLub(Function_, dynamic__, Function_);
- checkLub(Function_, void__, Function_);
- checkLub(Function_, A__, Function_);
- checkLub(Function_, B__, Function_);
- checkLub(Function_, C__, Function_);
- checkLub(Function_, void__A_B, Function_);
- checkLub(Function_, void__A_C, Function_);
- checkLub(Function_, void__B_A, Function_);
- checkLub(Function_, void__B_C, Function_);
- checkLub(Function_, void___B, Function_);
- checkLub(Function_, void___B_C, Function_);
- checkLub(Function_, void___C_C, Function_);
- checkLub(Function_, void____B, Function_);
- checkLub(Function_, void____B_C, Function_);
- checkLub(Function_, void____C_C, Function_);
-
- checkLub(dynamic__, Object_, Object_);
- checkLub(dynamic__, Function_, Function_);
- checkLub(dynamic__, dynamic__, dynamic__);
- checkLub(dynamic__, void__, dynamic__);
- checkLub(dynamic__, A__, dynamic__);
- checkLub(dynamic__, B__, dynamic__);
- checkLub(dynamic__, C__, dynamic__);
- checkLub(dynamic__, void__A_B, Function_);
- checkLub(dynamic__, void__A_C, Function_);
- checkLub(dynamic__, void__B_A, Function_);
- checkLub(dynamic__, void__B_C, Function_);
- checkLub(dynamic__, void___B, dynamic__);
- checkLub(dynamic__, void___B_C, dynamic__);
- checkLub(dynamic__, void___C_C, dynamic__);
- checkLub(dynamic__, void____B, dynamic__);
- checkLub(dynamic__, void____B_C, dynamic__);
- checkLub(dynamic__, void____C_C, dynamic__);
-
- checkLub(void__, Object_, Object_);
- checkLub(void__, Function_, Function_);
- checkLub(void__, dynamic__, dynamic__);
- checkLub(void__, void__, void__);
- checkLub(void__, A__, void__);
- checkLub(void__, B__, void__);
- checkLub(void__, C__, void__);
- checkLub(void__, void__A_B, Function_);
- checkLub(void__, void__A_C, Function_);
- checkLub(void__, void__B_A, Function_);
- checkLub(void__, void__B_C, Function_);
- checkLub(void__, void___B, void__);
- checkLub(void__, void___B_C, void__);
- checkLub(void__, void___C_C, void__);
- checkLub(void__, void____B, void__);
- checkLub(void__, void____B_C, void__);
- checkLub(void__, void____C_C, void__);
-
- checkLub(A__, Object_, Object_);
- checkLub(A__, Function_, Function_);
- checkLub(A__, dynamic__, dynamic__);
- checkLub(A__, void__, void__);
- checkLub(A__, A__, A__);
- checkLub(A__, B__, Object__);
- checkLub(A__, C__, Object__);
- checkLub(A__, void__A_B, Function_);
- checkLub(A__, void__A_C, Function_);
- checkLub(A__, void__B_A, Function_);
- checkLub(A__, void__B_C, Function_);
- checkLub(A__, void___B, void__);
- checkLub(A__, void___B_C, void__);
- checkLub(A__, void___C_C, void__);
- checkLub(A__, void____B, void__);
- checkLub(A__, void____B_C, void__);
- checkLub(A__, void____C_C, void__);
-
- checkLub(B__, Object_, Object_);
- checkLub(B__, Function_, Function_);
- checkLub(B__, dynamic__, dynamic__);
- checkLub(B__, void__, void__);
- checkLub(B__, A__, Object__);
- checkLub(B__, B__, B__);
- checkLub(B__, C__, B__);
- checkLub(B__, void__A_B, Function_);
- checkLub(B__, void__A_C, Function_);
- checkLub(B__, void__B_A, Function_);
- checkLub(B__, void__B_C, Function_);
- checkLub(B__, void___B, void__);
- checkLub(B__, void___B_C, void__);
- checkLub(B__, void___C_C, void__);
- checkLub(B__, void____B, void__);
- checkLub(B__, void____B_C, void__);
- checkLub(B__, void____C_C, void__);
-
- checkLub(C__, Object_, Object_);
- checkLub(C__, Function_, Function_);
- checkLub(C__, dynamic__, dynamic__);
- checkLub(C__, void__, void__);
- checkLub(C__, A__, Object__);
- checkLub(C__, B__, B__);
- checkLub(C__, C__, C__);
- checkLub(C__, void__A_B, Function_);
- checkLub(C__, void__A_C, Function_);
- checkLub(C__, void__B_A, Function_);
- checkLub(C__, void__B_C, Function_);
- checkLub(C__, void___B, void__);
- checkLub(C__, void___B_C, void__);
- checkLub(C__, void___C_C, void__);
- checkLub(C__, void____B, void__);
- checkLub(C__, void____B_C, void__);
- checkLub(C__, void____C_C, void__);
-
- checkLub(void__A_B, Object_, Object_);
- checkLub(void__A_B, Function_, Function_);
- checkLub(void__A_B, dynamic__, Function_);
- checkLub(void__A_B, void__, Function_);
- checkLub(void__A_B, A__, Function_);
- checkLub(void__A_B, B__, Function_);
- checkLub(void__A_B, C__, Function_);
- checkLub(void__A_B, void__A_B, void__A_B);
- checkLub(void__A_B, void__A_C, void__A_B);
- checkLub(void__A_B, void__B_A, void__Object_Object);
- checkLub(void__A_B, void__B_C, void__Object_B);
- checkLub(void__A_B, void___B, Function_);
- checkLub(void__A_B, void___B_C, Function_);
- checkLub(void__A_B, void___C_C, Function_);
- checkLub(void__A_B, void____B, Function_);
- checkLub(void__A_B, void____B_C, Function_);
- checkLub(void__A_B, void____C_C, Function_);
-
- checkLub(void__A_C, Object_, Object_);
- checkLub(void__A_C, Function_, Function_);
- checkLub(void__A_C, dynamic__, Function_);
- checkLub(void__A_C, void__, Function_);
- checkLub(void__A_C, A__, Function_);
- checkLub(void__A_C, B__, Function_);
- checkLub(void__A_C, C__, Function_);
- checkLub(void__A_C, void__A_B, void__A_B);
- checkLub(void__A_C, void__A_C, void__A_C);
- checkLub(void__A_C, void__B_A, void__Object_Object);
- checkLub(void__A_C, void__B_C, void__Object_C);
- checkLub(void__A_C, void___B, Function_);
- checkLub(void__A_C, void___B_C, Function_);
- checkLub(void__A_C, void___C_C, Function_);
- checkLub(void__A_C, void____B, Function_);
- checkLub(void__A_C, void____B_C, Function_);
- checkLub(void__A_C, void____C_C, Function_);
-
- checkLub(void__B_A, Object_, Object_);
- checkLub(void__B_A, Function_, Function_);
- checkLub(void__B_A, dynamic__, Function_);
- checkLub(void__B_A, void__, Function_);
- checkLub(void__B_A, A__, Function_);
- checkLub(void__B_A, B__, Function_);
- checkLub(void__B_A, C__, Function_);
- checkLub(void__B_A, void__A_B, void__Object_Object);
- checkLub(void__B_A, void__A_C, void__Object_Object);
- checkLub(void__B_A, void__B_A, void__B_A);
- checkLub(void__B_A, void__B_C, void__B_Object);
- checkLub(void__B_A, void___B, Function_);
- checkLub(void__B_A, void___B_C, Function_);
- checkLub(void__B_A, void___C_C, Function_);
- checkLub(void__B_A, void____B, Function_);
- checkLub(void__B_A, void____B_C, Function_);
- checkLub(void__B_A, void____C_C, Function_);
-
- checkLub(void__B_C, Object_, Object_);
- checkLub(void__B_C, Function_, Function_);
- checkLub(void__B_C, dynamic__, Function_);
- checkLub(void__B_C, void__, Function_);
- checkLub(void__B_C, A__, Function_);
- checkLub(void__B_C, B__, Function_);
- checkLub(void__B_C, C__, Function_);
- checkLub(void__B_C, void__A_B, void__Object_B);
- checkLub(void__B_C, void__A_C, void__Object_C);
- checkLub(void__B_C, void__B_A, void__B_Object);
- checkLub(void__B_C, void__B_C, void__B_C);
- checkLub(void__B_C, void___B, Function_);
- checkLub(void__B_C, void___B_C, Function_);
- checkLub(void__B_C, void___C_C, Function_);
- checkLub(void__B_C, void____B, Function_);
- checkLub(void__B_C, void____B_C, Function_);
- checkLub(void__B_C, void____C_C, Function_);
-
- checkLub(void___B, Object_, Object_);
- checkLub(void___B, Function_, Function_);
- checkLub(void___B, dynamic__, dynamic__);
- checkLub(void___B, void__, void__);
- checkLub(void___B, A__, void__);
- checkLub(void___B, B__, void__);
- checkLub(void___B, C__, void__);
- checkLub(void___B, void__A_B, Function_);
- checkLub(void___B, void__A_C, Function_);
- checkLub(void___B, void__B_A, Function_);
- checkLub(void___B, void__B_C, Function_);
- checkLub(void___B, void___B, void___B);
- checkLub(void___B, void___B_C, void___B);
- checkLub(void___B, void___C_C, void___B);
- checkLub(void___B, void____B, void__);
- checkLub(void___B, void____B_C, void__);
- checkLub(void___B, void____C_C, void__);
-
- checkLub(void___B_C, Object_, Object_);
- checkLub(void___B_C, Function_, Function_);
- checkLub(void___B_C, dynamic__, dynamic__);
- checkLub(void___B_C, void__, void__);
- checkLub(void___B_C, A__, void__);
- checkLub(void___B_C, B__, void__);
- checkLub(void___B_C, C__, void__);
- checkLub(void___B_C, void__A_B, Function_);
- checkLub(void___B_C, void__A_C, Function_);
- checkLub(void___B_C, void__B_A, Function_);
- checkLub(void___B_C, void__B_C, Function_);
- checkLub(void___B_C, void___B, void___B);
- checkLub(void___B_C, void___B_C, void___B_C);
- checkLub(void___B_C, void___C_C, void___B_C);
- checkLub(void___B_C, void____B, void__);
- checkLub(void___B_C, void____B_C, void__);
- checkLub(void___B_C, void____C_C, void__);
-
- checkLub(void___C_C, Object_, Object_);
- checkLub(void___C_C, Function_, Function_);
- checkLub(void___C_C, dynamic__, dynamic__);
- checkLub(void___C_C, void__, void__);
- checkLub(void___C_C, A__, void__);
- checkLub(void___C_C, B__, void__);
- checkLub(void___C_C, C__, void__);
- checkLub(void___C_C, void__A_B, Function_);
- checkLub(void___C_C, void__A_C, Function_);
- checkLub(void___C_C, void__B_A, Function_);
- checkLub(void___C_C, void__B_C, Function_);
- checkLub(void___C_C, void___B, void___B);
- checkLub(void___C_C, void___B_C, void___B_C);
- checkLub(void___C_C, void___C_C, void___C_C);
- checkLub(void___C_C, void____B, void__);
- checkLub(void___C_C, void____B_C, void__);
- checkLub(void___C_C, void____C_C, void__);
-
- checkLub(void____B, Object_, Object_);
- checkLub(void____B, Function_, Function_);
- checkLub(void____B, dynamic__, dynamic__);
- checkLub(void____B, void__, void__);
- checkLub(void____B, A__, void__);
- checkLub(void____B, B__, void__);
- checkLub(void____B, C__, void__);
- checkLub(void____B, void__A_B, Function_);
- checkLub(void____B, void__A_C, Function_);
- checkLub(void____B, void__B_A, Function_);
- checkLub(void____B, void__B_C, Function_);
- checkLub(void____B, void___B, void__);
- checkLub(void____B, void___B_C, void__);
- checkLub(void____B, void___C_C, void__);
- checkLub(void____B, void____B, void____B);
- checkLub(void____B, void____B_C, void____B);
- checkLub(void____B, void____C_C, void____B);
-
- checkLub(void____B_C, Object_, Object_);
- checkLub(void____B_C, Function_, Function_);
- checkLub(void____B_C, dynamic__, dynamic__);
- checkLub(void____B_C, void__, void__);
- checkLub(void____B_C, A__, void__);
- checkLub(void____B_C, B__, void__);
- checkLub(void____B_C, C__, void__);
- checkLub(void____B_C, void__A_B, Function_);
- checkLub(void____B_C, void__A_C, Function_);
- checkLub(void____B_C, void__B_A, Function_);
- checkLub(void____B_C, void__B_C, Function_);
- checkLub(void____B_C, void___B, void__);
- checkLub(void____B_C, void___B_C, void__);
- checkLub(void____B_C, void___C_C, void__);
- checkLub(void____B_C, void____B, void____B);
- checkLub(void____B_C, void____B_C, void____B_C);
- checkLub(void____B_C, void____C_C, void____B_C);
-
- checkLub(void____C_C, Object_, Object_);
- checkLub(void____C_C, Function_, Function_);
- checkLub(void____C_C, dynamic__, dynamic__);
- checkLub(void____C_C, void__, void__);
- checkLub(void____C_C, A__, void__);
- checkLub(void____C_C, B__, void__);
- checkLub(void____C_C, C__, void__);
- checkLub(void____C_C, void__A_B, Function_);
- checkLub(void____C_C, void__A_C, Function_);
- checkLub(void____C_C, void__B_A, Function_);
- checkLub(void____C_C, void__B_C, Function_);
- checkLub(void____C_C, void___B, void__);
- checkLub(void____C_C, void___B_C, void__);
- checkLub(void____C_C, void___C_C, void__);
- checkLub(void____C_C, void____B, void____B);
- checkLub(void____C_C, void____B_C, void____B_C);
- checkLub(void____C_C, void____C_C, void____C_C);
- }));
-}
-
-void testTypeVariable() {
- asyncTest(() => TypeEnvironment.create(r"""
- class A {}
- class B {}
- class C extends B {}
- class I<S extends A,
- T extends B,
- U extends C,
- V extends T,
- W extends V,
- X extends T> {}
- """).then((env) {
- // A B
- // | / \
- // S T C
- // / \ \
- // V X U
- // /
- // W
-
- ResolutionDartType Object_ = env['Object'];
- ResolutionDartType A = env['A'];
- ResolutionDartType B = env['B'];
- ResolutionDartType C = env['C'];
- ClassElement I = env.getElement('I');
- 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(ResolutionDartType a, ResolutionDartType b,
- ResolutionDartType expectedLub) {
- ResolutionDartType lub = env.computeLeastUpperBound(a, b);
- Expect.equals(expectedLub, lub,
- 'Unexpected lub($a,$b) = $lub, expected $expectedLub');
- }
-
- checkLub(Object_, Object_, Object_);
- checkLub(Object_, A, Object_);
- checkLub(Object_, B, Object_);
- checkLub(Object_, C, Object_);
- checkLub(Object_, S, Object_);
- checkLub(Object_, T, Object_);
- checkLub(Object_, U, Object_);
- checkLub(Object_, V, Object_);
- checkLub(Object_, W, Object_);
- checkLub(Object_, X, Object_);
-
- checkLub(A, Object_, Object_);
- checkLub(A, A, A);
- checkLub(A, B, Object_);
- checkLub(A, C, Object_);
- checkLub(A, S, A);
- checkLub(A, T, Object_);
- checkLub(A, U, Object_);
- checkLub(A, V, Object_);
- checkLub(A, W, Object_);
- checkLub(A, X, Object_);
-
- checkLub(B, Object_, Object_);
- checkLub(B, A, Object_);
- checkLub(B, B, B);
- checkLub(B, C, B);
- checkLub(B, S, Object_);
- checkLub(B, T, B);
- checkLub(B, U, B);
- checkLub(B, V, B);
- checkLub(B, W, B);
- checkLub(B, X, B);
-
- checkLub(C, Object_, Object_);
- checkLub(C, A, Object_);
- checkLub(C, B, B);
- checkLub(C, C, C);
- checkLub(C, S, Object_);
- checkLub(C, T, B);
- checkLub(C, U, C);
- checkLub(C, V, B);
- checkLub(C, W, B);
- checkLub(C, X, B);
-
- checkLub(S, Object_, Object_);
- checkLub(S, A, A);
- checkLub(S, B, Object_);
- checkLub(S, C, Object_);
- checkLub(S, S, S);
- checkLub(S, T, Object_);
- checkLub(S, U, Object_);
- checkLub(S, V, Object_);
- checkLub(S, W, Object_);
- checkLub(S, X, Object_);
-
- checkLub(T, Object_, Object_);
- checkLub(T, A, Object_);
- checkLub(T, B, B);
- checkLub(T, C, B);
- checkLub(T, S, Object_);
- checkLub(T, T, T);
- checkLub(T, U, B);
- checkLub(T, V, T);
- checkLub(T, W, T);
- checkLub(T, X, T);
-
- checkLub(U, Object_, Object_);
- checkLub(U, A, Object_);
- checkLub(U, B, B);
- checkLub(U, C, C);
- checkLub(U, S, Object_);
- checkLub(U, T, B);
- checkLub(U, U, U);
- checkLub(U, V, B);
- checkLub(U, W, B);
- checkLub(U, X, B);
-
- checkLub(V, Object_, Object_);
- checkLub(V, A, Object_);
- checkLub(V, B, B);
- checkLub(V, C, B);
- checkLub(V, S, Object_);
- checkLub(V, T, T);
- checkLub(V, U, B);
- checkLub(V, V, V);
- checkLub(V, W, V);
- checkLub(V, X, T);
-
- checkLub(W, Object_, Object_);
- checkLub(W, A, Object_);
- checkLub(W, B, B);
- checkLub(W, C, B);
- checkLub(W, S, Object_);
- checkLub(W, T, T);
- checkLub(W, U, B);
- checkLub(W, V, V);
- checkLub(W, W, W);
- checkLub(W, X, T);
-
- checkLub(X, Object_, Object_);
- checkLub(X, A, Object_);
- checkLub(X, B, B);
- checkLub(X, C, B);
- checkLub(X, S, Object_);
- checkLub(X, T, T);
- checkLub(X, U, B);
- checkLub(X, V, T);
- checkLub(X, W, T);
- checkLub(X, X, X);
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/library_resolution_test.dart b/tests/compiler/dart2js/old_frontend/library_resolution_test.dart
deleted file mode 100644
index 86250d2..0000000
--- a/tests/compiler/dart2js/old_frontend/library_resolution_test.dart
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (c) 2014, 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.
-
-/// Check that relative URIs are resolved against the canonical name of a
-/// library. This only matters for dart:-libraries, so this test mocks up two
-/// dart:-libraries.
-
-import "dart:async";
-
-import "../memory_source_file_helper.dart";
-
-import "package:async_helper/async_helper.dart";
-
-import 'package:expect/expect.dart' show Expect;
-
-import 'package:compiler/compiler_new.dart';
-
-import 'package:compiler/src/diagnostics/messages.dart'
- show MessageKind, MessageTemplate;
-
-import 'package:compiler/src/library_loader.dart' show LoadedLibraries;
-
-import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput;
-
-import 'package:compiler/src/old_to_new_api.dart'
- show LegacyCompilerDiagnostics, LegacyCompilerInput;
-import 'package:compiler/src/options.dart' show CompilerOptions;
-
-Uri sdkRoot = Uri.base.resolve("sdk/");
-Uri mock1LibraryUri = sdkRoot.resolve("lib/mock1.dart");
-Uri mock2LibraryUri = sdkRoot.resolve("lib/mock2.dart");
-
-class CustomCompiler extends CompilerImpl {
- CustomCompiler(provider, handler, libraryRoot, packageConfig)
- : super(
- provider,
- const NullCompilerOutput(),
- handler,
- new CompilerOptions()
- ..libraryRoot = libraryRoot
- ..useKernel = false
- ..packageConfig = packageConfig);
-}
-
-main() async {
- Uri packageConfig = Uri.base.resolve('.packages');
-
- var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
- var handler = new FormattingDiagnosticHandler(provider);
-
- Future wrappedProvider(Uri uri) async {
- if (uri == mock1LibraryUri) {
- uri = Uri.parse('memory:mock1.dart');
- }
- if (uri == mock2LibraryUri) {
- uri = Uri.parse('memory:mock2.dart');
- }
- Input input = await provider.readBytesFromUri(uri, InputKind.UTF8);
- return input.data;
- }
-
- String expectedMessage = MessageTemplate
- .TEMPLATES[MessageKind.LIBRARY_NOT_FOUND]
- .message({'resolvedUri': 'dart:mock2.dart'}).computeMessage();
-
- int actualMessageCount = 0;
-
- wrappedHandler(Uri uri, int begin, int end, String message, kind) {
- if (message == expectedMessage) {
- actualMessageCount++;
- } else {
- return handler(uri, begin, end, message, kind);
- }
- }
-
- checkLibraries(LoadedLibraries libraries) {
- Expect.equals(1, actualMessageCount);
- }
-
- CompilerImpl compiler = new CustomCompiler(
- new LegacyCompilerInput(wrappedProvider),
- new LegacyCompilerDiagnostics(wrappedHandler),
- sdkRoot,
- packageConfig);
-
- asyncStart();
- await compiler.setupSdk();
- // TODO(het): Find cleaner way to do this
- compiler.resolvedUriTranslator.sdkLibraries['m_o_c_k_1'] = mock1LibraryUri;
- compiler.resolvedUriTranslator.sdkLibraries['m_o_c_k_2'] = mock2LibraryUri;
- var libraries =
- await compiler.libraryLoader.loadLibrary(Uri.parse("dart:m_o_c_k_1"));
- await checkLibraries(libraries);
- asyncSuccess(null);
-}
-
-const Map MEMORY_SOURCE_FILES = const {
- "mock1.dart": "library mock1; import 'mock2.dart';",
- "mock2.dart": "library mock2;",
-};
diff --git a/tests/compiler/dart2js/old_frontend/lookup_member_test.dart b/tests/compiler/dart2js/old_frontend/lookup_member_test.dart
deleted file mode 100644
index 30d58c7..0000000
--- a/tests/compiler/dart2js/old_frontend/lookup_member_test.dart
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) 2013, 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 lookup_member_test;
-
-import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import '../type_test_helper.dart';
-import 'package:compiler/src/elements/resolution_types.dart';
-import "package:compiler/src/elements/elements.dart"
- show ClassElement, MemberSignature;
-import "package:compiler/src/elements/names.dart";
-
-void main() {
- test();
-}
-
-void test() {
- asyncTest(() => TypeEnvironment.create(r"""
- class A<T> {
- T foo;
- }
- class B<S> extends A<A<S>> {
- S bar;
- }
- class C<U> extends B<String> with D<B<U>> {
- U baz;
- }
- class D<V> {
- V boz;
- }
- """).then((env) {
- void expect(ResolutionInterfaceType receiverType, String memberName,
- ResolutionDartType expectedType) {
- MemberSignature member =
- receiverType.lookupInterfaceMember(new PublicName(memberName));
- Expect.isNotNull(member);
- ResolutionDartType memberType = member.type;
- Expect.equals(expectedType, memberType,
- 'Wrong member type for $receiverType.$memberName.');
- }
-
- ResolutionDartType int_ = env['int'];
- ResolutionDartType String_ = env['String'];
-
- ClassElement A = env.getElement('A');
- ResolutionDartType T = A.typeVariables.first;
- ResolutionDartType A_T = A.thisType;
- expect(A_T, 'foo', T);
-
- ResolutionDartType A_int = instantiate(A, [int_]);
- expect(A_int, 'foo', int_);
-
- ClassElement B = env.getElement('B');
- ResolutionDartType S = B.typeVariables.first;
- ResolutionDartType B_S = B.thisType;
- expect(B_S, 'foo', instantiate(A, [S]));
- expect(B_S, 'bar', S);
-
- ResolutionDartType B_int = instantiate(B, [int_]);
- expect(B_int, 'foo', A_int);
- expect(B_int, 'bar', int_);
-
- ClassElement C = env.getElement('C');
- 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]));
-
- ResolutionDartType C_int = instantiate(C, [int_]);
- expect(C_int, 'foo', instantiate(A, [String_]));
- expect(C_int, 'bar', String_);
- expect(C_int, 'baz', int_);
- expect(C_int, 'boz', instantiate(B, [int_]));
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/malformed_uri_test.dart b/tests/compiler/dart2js/old_frontend/malformed_uri_test.dart
deleted file mode 100644
index d5affd7..0000000
--- a/tests/compiler/dart2js/old_frontend/malformed_uri_test.dart
+++ /dev/null
@@ -1,36 +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.
-
-// Test that the compiler can handle missing files used in imports, exports,
-// part tags or as the main source file.
-
-library dart2js.test.malformed_uri;
-
-import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import 'package:compiler/src/commandline_options.dart';
-import '../memory_compiler.dart';
-
-const MEMORY_SOURCE_FILES = const {
- 'main.dart': '''
-import '../../Udyn[mic ils/expect.dart';
-
-main () { print("Hi"); }
-''',
-};
-
-testMalformedUri() {
- asyncTest(() async {
- var collector = new DiagnosticCollector();
- await runCompiler(
- memorySourceFiles: MEMORY_SOURCE_FILES,
- diagnosticHandler: collector,
- options: [Flags.useOldFrontend]);
- Expect.equals(1, collector.errors.length);
- });
-}
-
-void main() {
- testMalformedUri();
-}
diff --git a/tests/compiler/dart2js/old_frontend/members_test.dart b/tests/compiler/dart2js/old_frontend/members_test.dart
deleted file mode 100644
index 2ca4b90..0000000
--- a/tests/compiler/dart2js/old_frontend/members_test.dart
+++ /dev/null
@@ -1,754 +0,0 @@
-// Copyright (c) 2014, 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 members_test;
-
-import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import '../type_test_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/elements/resolution_types.dart';
-import "package:compiler/src/elements/elements.dart"
- show ClassElement, MemberSignature;
-import "package:compiler/src/elements/names.dart";
-import "package:compiler/src/resolution/class_members.dart"
- show MembersCreator, DeclaredMember, ErroneousMember, SyntheticMember;
-
-void main() {
- testClassMembers();
- testInterfaceMembers();
- testClassVsInterfaceMembers();
- testMixinMembers();
- testMixinMembersWithoutImplements();
-}
-
-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
- ? cls.element.lookupClassMember(memberName)
- : cls.element.lookupInterfaceMember(memberName);
- if (member != null) {
- Expect.equals(memberName, member.name);
- }
- return member;
-}
-
-/// Check interface member only.
-const int CHECK_INTERFACE = 0;
-
-/// Check class member only.
-const int CHECK_CLASS = 1;
-
-/// Check that there is no class member for the interface member.
-const int NO_CLASS_MEMBER = 2;
-
-/// Check that the interface member is also a class member.
-const int ALSO_CLASS_MEMBER = 3;
-
-/**
- * Checks [member] or interface member [name] of the declaration of [cls].
- *
- * If [inheritFrom] is set, the member from [cls] must be identical to the
- * member from [inheritedFrom].
- *
- * Otherwise, the properties of member are checked against the values of
- * [isStatic], [isSetter], [isGetter], [declarer], [type] and
- * [functionType].
- *
- * If [synthesizedFrom] or [erroneousFrom] is not `null`, the member is checked
- * to be synthesized for the corresponding members found on the type is
- * [synthesizedFrom] or or [erroneousFrom], respectively.
- * Otherwise, if [declarer] is `null`, the declarer is checked to be [cls], and
- * if [declarer] is not `null`, the declarer is checked to be [declarer].
- * If [type] is `null` it is checked that the type of the member is also the
- * member type, otherwise the type is checked to be [type].
- *
- * If [isClassMember] is `true` it is checked that the member is also a class
- * member.
- */
-MemberSignature checkMember(ResolutionInterfaceType cls, String name,
- {bool isStatic: false,
- bool isSetter: false,
- bool isGetter: false,
- 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 =
- getMember(cls, name, isSetter: isSetter, checkType: checkType);
- Expect.isNotNull(member, "No $memberKind member '$name' in $cls.");
- Name memberName = member.name;
- if (checkType == ALSO_CLASS_MEMBER) {
- MemberSignature classMember = cls.element.lookupClassMember(memberName);
- Expect.isNotNull(classMember, "No class member '$memberName' in $cls.");
- Expect.equals(member, classMember);
- } else if (checkType == NO_CLASS_MEMBER) {
- Expect.isNull(cls.element.lookupClassMember(memberName));
- }
-
- if (inheritedFrom != null) {
- DeclaredMember inherited = checkType == CHECK_CLASS
- ? inheritedFrom.element.lookupClassMember(memberName)
- : inheritedFrom.element.lookupInterfaceMember(memberName);
- Expect.isNotNull(
- inherited, "No $memberKind member '$memberName' in $inheritedFrom.");
- Expect.equals(inherited.inheritFrom(inheritedFrom), member);
- } else {
- if (erroneousFrom != null || synthesizedFrom != null) {
- Expect.notEquals(
- checkType,
- CHECK_CLASS,
- "Arguments 'erroneousFrom' and 'synthesizedFrom' only apply "
- "to interface members.");
- if (synthesizedFrom != null) {
- Expect.isTrue(
- member is SyntheticMember, "Member '$member' is not synthesized.");
- } else {
- Expect.isTrue(
- member is ErroneousMember, "Member '$member' is not erroneous.");
- }
- Set<MemberSignature> members = new Set<MemberSignature>();
- List from = synthesizedFrom != null ? synthesizedFrom : erroneousFrom;
- for (ResolutionInterfaceType type in from) {
- DeclaredMember inheritedMember =
- type.element.lookupInterfaceMember(memberName);
- Expect.isNotNull(inheritedMember);
- members.add(inheritedMember.inheritFrom(type));
- }
- Expect.setEquals(members, member.declarations);
- } else if (declarer != null) {
- DeclaredMember declared = member;
- Expect.equals(
- declarer,
- declared.declarer,
- "Unexpected declarer '${declared.declarer}' of $memberKind member "
- "'$member'. Expected '${declarer}'.");
- } else {
- DeclaredMember declared = member;
- Expect.equals(cls.element, declared.element.enclosingClass);
- Expect.equals(cls, declared.declarer);
- }
- Expect.equals(isSetter, member.isSetter);
- Expect.equals(isGetter, member.isGetter);
- if (type != null) {
- Expect.equals(type, member.type,
- "Unexpected type of $memberKind member '$member'.");
- }
- if (functionType != null) {
- if (type == null) {
- Expect.equals(member.type, member.functionType,
- "Unexpected type of $memberKind member '$member'.");
- }
- Expect.equals(functionType, member.functionType,
- "Unexpected member type of $memberKind member '$member'.");
- }
- }
- return member;
-}
-
-void checkMemberCount(ResolutionInterfaceType cls, int expectedCount,
- {bool interfaceMembers: true}) {
- int count = 0;
- if (interfaceMembers) {
- cls.element.forEachInterfaceMember((_) => count++);
- } else {
- cls.element.forEachClassMember((_) => count++);
- }
- Expect.equals(expectedCount, count);
-}
-
-void testClassMembers() {
- asyncTest(() => TypeEnvironment.create(r"""
- abstract class A {
- int field;
- final finalField = 0;
- static var staticField;
-
- int get getter => 0;
- get abstractGetter;
- void set setter(int _) {}
- set abstractSetter(_);
-
- method() {}
- abstractMethod();
- static staticMethod() {}
- }
- class B<T> {
- T field;
- void method(T t) {}
- static staticMethod() {}
- toString([T t]) {}
- }
- class C<S> extends B<S> {}
- class D extends C<int> {}
- class E extends D {}
- """,
- options: [Flags.useOldFrontend],
- compileMode: CompileMode.memory).then((env) {
- ResolutionInterfaceType bool_ = env['bool'];
- ResolutionInterfaceType String_ = env['String'];
- ResolutionInterfaceType int_ = env['int'];
- ResolutionDynamicType dynamic_ = env['dynamic'];
- ResolutionVoidType void_ = env['void'];
- ResolutionInterfaceType Type_ = env['Type'];
- ResolutionInterfaceType Invocation_ = env['Invocation'];
-
- ResolutionInterfaceType Object_ = env['Object'];
- checkMemberCount(Object_, 5 /*declared*/, interfaceMembers: true);
- checkMemberCount(Object_, 5 /*declared*/, interfaceMembers: false);
-
- checkMember(Object_, '==',
- functionType: env.functionType(bool_, [dynamic_]));
- checkMember(Object_, 'hashCode',
- isGetter: true,
- type: int_,
- functionType: env.functionType(int_, []));
- checkMember(Object_, 'noSuchMethod',
- functionType: env.functionType(dynamic_, [Invocation_]));
- checkMember(Object_, 'runtimeType',
- isGetter: true,
- type: Type_,
- functionType: env.functionType(Type_, []));
- checkMember(Object_, 'toString',
- functionType: env.functionType(String_, []));
-
- ResolutionInterfaceType A = env['A'];
- MembersCreator.computeAllClassMembers(env.resolution, A.element);
-
- checkMemberCount(A, 5 /*inherited*/ + 9 /*non-static declared*/,
- interfaceMembers: true);
- checkMemberCount(
- A,
- 5 /*inherited*/ +
- 9 /*non-abstract declared*/ +
- 3 /* abstract declared */,
- interfaceMembers: false);
-
- checkMember(A, '==', inheritedFrom: Object_);
- checkMember(A, 'hashCode', inheritedFrom: Object_);
- checkMember(A, 'noSuchMethod', inheritedFrom: Object_);
- checkMember(A, 'runtimeType', inheritedFrom: Object_);
- checkMember(A, 'toString', inheritedFrom: Object_);
-
- checkMember(A, 'field',
- isGetter: true,
- type: int_,
- functionType: env.functionType(int_, []));
- checkMember(A, 'field',
- isSetter: true,
- type: int_,
- functionType: env.functionType(void_, [int_]));
- checkMember(A, 'finalField',
- isGetter: true,
- type: dynamic_,
- functionType: env.functionType(dynamic_, []));
- checkMember(A, 'staticField',
- isGetter: true,
- isStatic: true,
- checkType: CHECK_CLASS,
- type: dynamic_,
- functionType: env.functionType(dynamic_, []));
- checkMember(A, 'staticField',
- isSetter: true,
- isStatic: true,
- checkType: CHECK_CLASS,
- type: dynamic_,
- functionType: env.functionType(void_, [dynamic_]));
-
- checkMember(A, 'getter',
- isGetter: true,
- type: int_,
- functionType: env.functionType(int_, []));
- checkMember(A, 'abstractGetter',
- isGetter: true,
- type: dynamic_,
- functionType: env.functionType(dynamic_, []));
- checkMember(A, 'setter',
- isSetter: true,
- type: int_,
- functionType: env.functionType(void_, [int_]));
- checkMember(A, 'abstractSetter',
- isSetter: true,
- type: dynamic_,
- functionType: env.functionType(dynamic_, [dynamic_]));
-
- checkMember(A, 'method', functionType: env.functionType(dynamic_, []));
- checkMember(A, 'abstractMethod',
- functionType: env.functionType(dynamic_, []));
- checkMember(A, 'staticMethod',
- checkType: CHECK_CLASS,
- isStatic: true,
- functionType: env.functionType(dynamic_, []));
-
- ClassElement B = env.getElement('B');
- MembersCreator.computeAllClassMembers(env.resolution, B);
- 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*/,
- interfaceMembers: false);
-
- checkMember(B_this, '==', inheritedFrom: Object_);
- checkMember(B_this, 'hashCode', inheritedFrom: Object_);
- checkMember(B_this, 'noSuchMethod', inheritedFrom: Object_);
- checkMember(B_this, 'runtimeType', inheritedFrom: Object_);
-
- checkMember(B_this, 'field',
- isGetter: true, type: B_T, functionType: env.functionType(B_T, []));
- checkMember(B_this, 'field',
- isSetter: true,
- type: B_T,
- functionType: env.functionType(void_, [B_T]));
- checkMember(B_this, 'method',
- functionType: env.functionType(void_, [B_T]));
- checkMember(B_this, 'staticMethod',
- checkType: CHECK_CLASS,
- isStatic: true,
- functionType: env.functionType(dynamic_, []));
- checkMember(B_this, 'toString',
- functionType:
- env.functionType(dynamic_, [], optionalParameters: [B_T]));
-
- ClassElement C = env.getElement('C');
- MembersCreator.computeAllClassMembers(env.resolution, C);
- 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);
- ResolutionInterfaceType B_S = instantiate(B, [C_S]);
-
- checkMember(C_this, '==', inheritedFrom: Object_);
- checkMember(C_this, 'hashCode', inheritedFrom: Object_);
- checkMember(C_this, 'noSuchMethod', inheritedFrom: Object_);
- checkMember(C_this, 'runtimeType', inheritedFrom: Object_);
-
- checkMember(C_this, 'field',
- isGetter: true,
- declarer: B_S,
- type: C_S,
- functionType: env.functionType(C_S, []));
- checkMember(C_this, 'field',
- isSetter: true,
- declarer: B_S,
- type: C_S,
- functionType: env.functionType(void_, [C_S]));
- checkMember(C_this, 'method',
- declarer: B_S, functionType: env.functionType(void_, [C_S]));
- checkMember(C_this, 'toString',
- declarer: B_S,
- functionType:
- env.functionType(dynamic_, [], optionalParameters: [C_S]));
-
- ResolutionInterfaceType D = env['D'];
- MembersCreator.computeAllClassMembers(env.resolution, D.element);
- checkMemberCount(D, 8 /*inherited*/, interfaceMembers: true);
- checkMemberCount(D, 8 /*inherited*/, interfaceMembers: false);
- ResolutionInterfaceType B_int = instantiate(B, [int_]);
-
- checkMember(D, '==', inheritedFrom: Object_);
- checkMember(D, 'hashCode', inheritedFrom: Object_);
- checkMember(D, 'noSuchMethod', inheritedFrom: Object_);
- checkMember(D, 'runtimeType', inheritedFrom: Object_);
-
- checkMember(D, 'field',
- isGetter: true,
- declarer: B_int,
- type: int_,
- functionType: env.functionType(int_, []));
- checkMember(D, 'field',
- isSetter: true,
- declarer: B_int,
- type: int_,
- functionType: env.functionType(void_, [int_]));
- checkMember(D, 'method',
- declarer: B_int, functionType: env.functionType(void_, [int_]));
- checkMember(D, 'toString',
- declarer: B_int,
- functionType:
- env.functionType(dynamic_, [], optionalParameters: [int_]));
-
- ResolutionInterfaceType E = env['E'];
- MembersCreator.computeAllClassMembers(env.resolution, E.element);
- checkMemberCount(E, 8 /*inherited*/, interfaceMembers: true);
- checkMemberCount(E, 8 /*inherited*/, interfaceMembers: false);
-
- checkMember(E, '==', inheritedFrom: Object_);
- checkMember(E, 'hashCode', inheritedFrom: Object_);
- checkMember(E, 'noSuchMethod', inheritedFrom: Object_);
- checkMember(E, 'runtimeType', inheritedFrom: Object_);
-
- checkMember(E, 'field',
- isGetter: true,
- declarer: B_int,
- type: int_,
- functionType: env.functionType(int_, []));
- checkMember(E, 'field',
- isSetter: true,
- declarer: B_int,
- type: int_,
- functionType: env.functionType(void_, [int_]));
- checkMember(E, 'method',
- declarer: B_int, functionType: env.functionType(void_, [int_]));
- checkMember(E, 'toString',
- declarer: B_int,
- functionType:
- env.functionType(dynamic_, [], optionalParameters: [int_]));
- }));
-}
-
-void testInterfaceMembers() {
- asyncTest(() => TypeEnvironment.create(r"""
- abstract class A {
- num method1();
- void method2();
- void method3();
- void method4();
- method5(a);
- method6(a);
- method7(a);
- method8(a, b);
- method9(a, b, c);
- method10(a, {b, c});
- method11(a, {b, c});
- num get getter1;
- num get getter2;
- void set setter1(num _);
- void set setter2(num _);
- void set setter3(num _);
- get getterAndMethod;
- }
- abstract class B {
- int method1();
- int method2();
- num method3();
- num method4();
- method5([a]);
- method6([a, b]);
- method7(a, [b]);
- method8([a]);
- method9(a, [b]);
- method10(a, {c, d});
- method11(a, b, {c, d});
- num get getter1;
- int get getter2;
- void set setter1(num _);
- set setter2(num _);
- void set setter3(int _);
- getterAndMethod();
- }
- abstract class C {
- int method3();
- num method4();
- }
- abstract class D implements A, B, C {}
- """, options: [Flags.useOldFrontend]).then((env) {
- ResolutionDynamicType dynamic_ = env['dynamic'];
- ResolutionVoidType void_ = env['void'];
- ResolutionInterfaceType num_ = env['num'];
-
- 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);
-
- // A: num method1()
- // B: int method1()
- // D: dynamic method1() -- synthesized from A and B.
- checkMember(D, 'method1',
- synthesizedFrom: [A, B],
- functionType: env.functionType(dynamic_, []),
- checkType: NO_CLASS_MEMBER);
-
- // A: void method2()
- // B: int method2()
- // D: int method2() -- inherited from B
- checkMember(D, 'method2', inheritedFrom: B, checkType: NO_CLASS_MEMBER);
-
- // A: void method3()
- // B: num method3()
- // C: int method3()
- // D: dynamic method3() -- synthesized from A, B, and C.
- checkMember(D, 'method3',
- synthesizedFrom: [A, B, C],
- functionType: env.functionType(dynamic_, []),
- checkType: NO_CLASS_MEMBER);
-
- // A: void method4()
- // B: num method4()
- // C: num method4()
- // D: num method4() -- synthesized from B and C.
- checkMember(D, 'method4',
- synthesizedFrom: [B, C],
- functionType: env.functionType(num_, []),
- checkType: NO_CLASS_MEMBER);
-
- // A: method5(a)
- // B: method5([a])
- // D: method5([a]) -- inherited from B
- checkMember(D, 'method5', inheritedFrom: B, checkType: NO_CLASS_MEMBER);
-
- // A: method6(a)
- // B: method6([a, b])
- // D: method6([a, b]) -- inherited from B
- checkMember(D, 'method6', inheritedFrom: B, checkType: NO_CLASS_MEMBER);
-
- // A: method7(a)
- // B: method7(a, [b])
- // D: method7(a, [b]) -- inherited from B
- checkMember(D, 'method7', inheritedFrom: B, checkType: NO_CLASS_MEMBER);
-
- // A: method8(a, b)
- // B: method8([a])
- // D: method8([a, b]) -- synthesized from A and B.
- checkMember(D, 'method8',
- synthesizedFrom: [A, B],
- functionType: env.functionType(dynamic_, [],
- optionalParameters: [dynamic_, dynamic_]),
- checkType: NO_CLASS_MEMBER);
-
- // A: method9(a, b, c)
- // B: method9(a, [b])
- // D: method9(a, [b, c]) -- synthesized from A and B.
- checkMember(D, 'method9',
- synthesizedFrom: [A, B],
- functionType: env.functionType(dynamic_, [dynamic_],
- optionalParameters: [dynamic_, dynamic_]),
- checkType: NO_CLASS_MEMBER);
-
- // A: method10(a, {b, c})
- // B: method10(a, {c, d})
- // D: method10(a, {b, c, d}) -- synthesized from A and B.
- checkMember(D, 'method10',
- synthesizedFrom: [A, B],
- functionType: env.functionType(dynamic_, [dynamic_],
- namedParameters: {'b': dynamic_, 'c': dynamic_, 'd': dynamic_}),
- checkType: NO_CLASS_MEMBER);
-
- // A: method11(a, {b, c})
- // B: method11(a, b, {c, d})
- // D: method11(a, [b], {c, d}) -- synthesized from A and B.
- // TODO(johnniwinther): Change to check synthesized member when function
- // types with both optional and named parameters are supported.
- Expect.isNull(getMember(D, 'method11'));
- /*checkMember(D, 'method11',
- synthesizedFrom: [A, B],
- functionType: env.functionType(dynamic_, [dynamic_],
- optionalParameters: [dynamic_],
- namedParameters: {'c': dynamic_,
- 'd': dynamic_,}),
- checkType: NO_CLASS_MEMBER);*/
-
- // A: num get getter1
- // B: num get getter1
- // D: num get getter1 -- synthesized from A and B.
- checkMember(D, 'getter1',
- isGetter: true,
- synthesizedFrom: [A, B],
- type: num_,
- functionType: env.functionType(num_, []),
- checkType: NO_CLASS_MEMBER);
-
- // A: num get getter2
- // B: int get getter2
- // D: dynamic get getter2 -- synthesized from A and B.
- checkMember(D, 'getter2',
- isGetter: true,
- synthesizedFrom: [A, B],
- type: dynamic_,
- functionType: env.functionType(dynamic_, []),
- checkType: NO_CLASS_MEMBER);
-
- // A: void set setter1(num _)
- // B: void set setter1(num _)
- // D: void set setter1(num _) -- synthesized from A and B.
- checkMember(D, 'setter1',
- isSetter: true,
- synthesizedFrom: [A, B],
- type: num_,
- functionType: env.functionType(void_, [num_]),
- checkType: NO_CLASS_MEMBER);
-
- // A: void set setter2(num _)
- // B: set setter2(num _)
- // D: dynamic set setter2(dynamic _) -- synthesized from A and B.
- checkMember(D, 'setter2',
- isSetter: true,
- synthesizedFrom: [A, B],
- type: dynamic_,
- functionType: env.functionType(dynamic_, [dynamic_]),
- checkType: NO_CLASS_MEMBER);
-
- // A: void set setter3(num _)
- // B: void set setter3(int _)
- // D: dynamic set setter3(dynamic _) -- synthesized from A and B.
- checkMember(D, 'setter3',
- isSetter: true,
- synthesizedFrom: [A, B],
- type: dynamic_,
- functionType: env.functionType(dynamic_, [dynamic_]),
- checkType: NO_CLASS_MEMBER);
-
- // A: get getterAndMethod
- // B: getterAndMethod()
- // D: nothing inherited
- checkMember(D, 'getterAndMethod',
- erroneousFrom: [A, B], checkType: NO_CLASS_MEMBER);
- }));
-}
-
-void testClassVsInterfaceMembers() {
- asyncTest(() => TypeEnvironment.create(r"""
- class A {
- method1() {}
- method2() {}
- }
- abstract class B {
- method1();
- method2(a);
- }
- abstract class C extends A implements B {}
- """, options: [Flags.useOldFrontend]).then((env) {
- ResolutionDynamicType dynamic_ = env['dynamic'];
-
- 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);
-
- // A: method1()
- // B: method1()
- // C class: method1() -- inherited from A.
- // C interface: dynamic method1() -- synthesized from A and B.
- MemberSignature interfaceMember = checkMember(C, 'method1',
- checkType: CHECK_INTERFACE,
- synthesizedFrom: [A, B],
- functionType: env.functionType(dynamic_, []));
- MemberSignature classMember =
- checkMember(C, 'method1', checkType: CHECK_CLASS, inheritedFrom: A);
- Expect.notEquals(interfaceMember, classMember);
-
- // A: method2()
- // B: method2(a)
- // C class: method2() -- inherited from A.
- // C interface: dynamic method2([a]) -- synthesized from A and B.
- interfaceMember = checkMember(C, 'method2',
- checkType: CHECK_INTERFACE,
- synthesizedFrom: [A, B],
- functionType:
- env.functionType(dynamic_, [], optionalParameters: [dynamic_]));
- classMember =
- checkMember(C, 'method2', checkType: CHECK_CLASS, inheritedFrom: A);
- Expect.notEquals(interfaceMember, classMember);
- }));
-}
-
-void testMixinMembers() {
- asyncTest(() => TypeEnvironment.create(r"""
- class A<T> {
- method1() {}
- method2() {}
- method3(T a) {}
- method4(T a) {}
- }
- abstract class B<S> {
- method1();
- method2(a);
- method3(S a) {}
- }
- abstract class C<U, V> extends Object with A<U> implements B<V> {}
- """, options: [Flags.useOldFrontend]).then((env) {
- ResolutionDynamicType dynamic_ = env['dynamic'];
-
- ClassElement A = env.getElement('A');
- ClassElement B = env.getElement('B');
- ClassElement C = env.getElement('C');
- 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);
-
- // A: method1()
- // B: method1()
- // C class: method1() -- inherited from A.
- // C interface: dynamic method1() -- synthesized from A and B.
- MemberSignature interfaceMember = checkMember(C_this, 'method1',
- checkType: CHECK_INTERFACE,
- synthesizedFrom: [A_U, B_V],
- functionType: env.functionType(dynamic_, []));
- MemberSignature classMember = checkMember(C_this, 'method1',
- checkType: CHECK_CLASS, inheritedFrom: A_U);
- Expect.notEquals(interfaceMember, classMember);
-
- // A: method2()
- // B: method2(a)
- // C class: method2() -- inherited from A.
- // C interface: dynamic method2([a]) -- synthesized from A and B.
- interfaceMember = checkMember(C_this, 'method2',
- checkType: CHECK_INTERFACE,
- synthesizedFrom: [A_U, B_V],
- functionType:
- env.functionType(dynamic_, [], optionalParameters: [dynamic_]));
- classMember = checkMember(C_this, 'method2',
- checkType: CHECK_CLASS, inheritedFrom: A_U);
- Expect.notEquals(interfaceMember, classMember);
-
- // A: method3(U a)
- // B: method3(V a)
- // C class: method3(U a) -- inherited from A.
- // C interface: dynamic method3(a) -- synthesized from A and B.
- interfaceMember = checkMember(C_this, 'method3',
- checkType: CHECK_INTERFACE,
- synthesizedFrom: [A_U, B_V],
- functionType: env.functionType(dynamic_, [dynamic_]));
- classMember = checkMember(C_this, 'method3',
- checkType: CHECK_CLASS, inheritedFrom: A_U);
- Expect.notEquals(interfaceMember, classMember);
-
- // A: method4(U a)
- // B: --
- // C class: method4(U a) -- inherited from A.
- // C interface: method4(U a) -- inherited from A.
- checkMember(C_this, 'method4',
- checkType: ALSO_CLASS_MEMBER, inheritedFrom: A_U);
- }));
-}
-
-void testMixinMembersWithoutImplements() {
- asyncTest(() => TypeEnvironment.create(r"""
- abstract class A {
- m();
- }
- abstract class B implements A {
- }
- abstract class C extends Object with B {}
- """, options: [Flags.useOldFrontend]).then((env) {
- ResolutionDynamicType dynamic_ = env['dynamic'];
-
- ResolutionInterfaceType A = env['A'];
- ResolutionInterfaceType C = env['C'];
-
- // Ensure that members have been computed on all classes.
- MembersCreator.computeAllClassMembers(env.resolution, C.element);
-
- checkMember(C, 'm',
- checkType: NO_CLASS_MEMBER,
- inheritedFrom: A,
- functionType: env.functionType(dynamic_, []));
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/message_kind_helper.dart b/tests/compiler/dart2js/old_frontend/message_kind_helper.dart
deleted file mode 100644
index f869e39..0000000
--- a/tests/compiler/dart2js/old_frontend/message_kind_helper.dart
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright (c) 2013, 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 dart2js.test.message_kind_helper;
-
-import 'package:expect/expect.dart';
-import 'dart:async';
-
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/compiler.dart' show Compiler;
-import 'package:compiler/src/diagnostics/messages.dart'
- show MessageKind, MessageTemplate;
-import 'package:compiler/compiler_new.dart' show Diagnostic;
-
-import '../memory_compiler.dart';
-
-const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]';
-
-/// Most examples generate a single diagnostic.
-/// Add an exception here if a single diagnostic cannot be produced.
-/// However, consider that a single concise diagnostic is easier to understand,
-/// so try to change error reporting logic before adding an exception.
-final Set<MessageKind> kindsWithExtraMessages = new Set<MessageKind>.from([
- // See http://dartbug.com/18361:
- MessageKind.CANNOT_EXTEND_MALFORMED,
- MessageKind.CANNOT_IMPLEMENT_MALFORMED,
- MessageKind.CANNOT_MIXIN,
- MessageKind.CANNOT_MIXIN_MALFORMED,
- MessageKind.CANNOT_INSTANTIATE_ENUM,
- MessageKind.CYCLIC_TYPEDEF_ONE,
- MessageKind.DUPLICATE_DEFINITION,
- MessageKind.EQUAL_MAP_ENTRY_KEY,
- MessageKind.FINAL_FUNCTION_TYPE_PARAMETER,
- MessageKind.FORMAL_DECLARED_CONST,
- MessageKind.FORMAL_DECLARED_STATIC,
- MessageKind.FUNCTION_TYPE_FORMAL_WITH_DEFAULT,
- MessageKind.HIDDEN_IMPLICIT_IMPORT,
- MessageKind.HIDDEN_IMPORT,
- MessageKind.INHERIT_GETTER_AND_METHOD,
- MessageKind.UNIMPLEMENTED_METHOD,
- MessageKind.UNIMPLEMENTED_METHOD_ONE,
- MessageKind.VAR_FUNCTION_TYPE_PARAMETER,
- MessageKind.UNMATCHED_TOKEN,
-]);
-
-/// Most messages can be tested without causing a fatal error. Add an exception
-/// here if a fatal error is unavoidable and leads to pending classes.
-/// Try to avoid adding exceptions here; a fatal error causes the compiler to
-/// stop before analyzing all input, and it isn't safe to reuse it.
-final Set<MessageKind> kindsWithPendingClasses = new Set<MessageKind>.from([
- // If you add something here, please file a *new* bug report.
-]);
-
-Future<Compiler> check(MessageTemplate template, Compiler cachedCompiler) {
- Expect.isFalse(template.examples.isEmpty);
-
- return Future.forEach(template.examples, (example) {
- if (example is String) {
- example = {'main.dart': example};
- } else {
- Expect.isTrue(
- example is Map, "Example must be either a String or a Map.");
- Expect.isTrue(example.containsKey('main.dart'),
- "Example map must contain a 'main.dart' entry.");
- }
- DiagnosticCollector collector = new DiagnosticCollector();
-
- Compiler compiler = compilerFor(
- memorySourceFiles: example,
- diagnosticHandler: collector,
- options: [
- Flags.analyzeOnly,
- Flags.enableExperimentalMirrors,
- Flags.useOldFrontend
- ]..addAll(template.options),
- cachedCompiler: cachedCompiler);
-
- return compiler.run(Uri.parse('memory:main.dart')).then((_) {
- Iterable<CollectedMessage> messages = collector.filterMessagesByKinds([
- Diagnostic.ERROR,
- Diagnostic.WARNING,
- Diagnostic.HINT,
- Diagnostic.CRASH
- ]);
-
- Expect.isFalse(messages.isEmpty, 'No messages in """$example"""');
-
- String expectedText = !template.hasHowToFix
- ? template.template
- : '${template.template}\n${template.howToFix}';
- String pattern = expectedText.replaceAllMapped(
- new RegExp(ESCAPE_REGEXP), (m) => '\\${m[0]}');
- pattern = pattern.replaceAll(new RegExp(r'#\\\{[^}]*\\\}'), '.*');
-
- bool checkMessage(CollectedMessage message) {
- if (message.message.kind != MessageKind.GENERIC) {
- return message.message.kind == template.kind;
- } else {
- return new RegExp('^$pattern\$').hasMatch(message.text);
- }
- }
-
- // TODO(johnniwinther): Extend MessageKind to contain information on
- // where info messages are expected.
- bool messageFound = false;
- List unexpectedMessages = [];
- for (CollectedMessage message in messages) {
- if (!messageFound && checkMessage(message)) {
- messageFound = true;
- } else {
- unexpectedMessages.add(message);
- }
- }
- Expect.isTrue(
- messageFound,
- '${template.kind}} does not match any in\n '
- '${messages.join('\n ')}\n'
- 'Consider searching for ${template.kind} in\n'
- ' pkg/compiler/lib/src/diagnostics/messages.dart\n'
- 'and removing the associated example');
- dynamic reporter = compiler.reporter;
- Expect.isFalse(reporter.hasCrashed);
- if (!unexpectedMessages.isEmpty) {
- for (CollectedMessage message in unexpectedMessages) {
- print("Unexpected message: $message");
- }
- if (!kindsWithExtraMessages.contains(template.kind)) {
- // Try changing the error reporting logic before adding an exception
- // to [kindsWithExtraMessages].
- throw 'Unexpected messages found.';
- }
- }
-
- bool pendingStuff = false;
- for (var e in compiler.resolver.pendingClassesToBePostProcessed) {
- pendingStuff = true;
- compiler.reporter.reportInfo(e, MessageKind.GENERIC,
- {'text': 'Pending class to be post-processed.'});
- }
- for (var e in compiler.resolver.pendingClassesToBeResolved) {
- pendingStuff = true;
- compiler.reporter.reportInfo(
- e, MessageKind.GENERIC, {'text': 'Pending class to be resolved.'});
- }
- Expect
- .isTrue(!pendingStuff || kindsWithPendingClasses.contains(template));
-
- if (!pendingStuff) {
- // If there is pending stuff, or the compiler was cancelled, we
- // shouldn't reuse the compiler.
- cachedCompiler = compiler;
- }
- });
- }).then((_) => cachedCompiler);
-}
diff --git a/tests/compiler/dart2js/old_frontend/message_kind_test.dart b/tests/compiler/dart2js/old_frontend/message_kind_test.dart
deleted file mode 100644
index c397ede..0000000
--- a/tests/compiler/dart2js/old_frontend/message_kind_test.dart
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2013, 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 'package:expect/expect.dart';
-import 'dart:async';
-import "package:async_helper/async_helper.dart";
-import 'package:compiler/src/diagnostics/messages.dart'
- show MessageKind, MessageTemplate;
-
-import 'message_kind_helper.dart';
-
-main(List<String> arguments) {
- List<MessageTemplate> examples = <MessageTemplate>[];
- for (var kind in MessageKind.values) {
- MessageTemplate template = MessageTemplate.TEMPLATES[kind];
- Expect.isNotNull(template, "No template for $kind.");
- Expect.equals(kind, template.kind,
- "Invalid MessageTemplate.kind for $kind, found ${template.kind}.");
-
- String name = '${kind.toString()}'.substring('MessageKind.'.length);
- if (!arguments.isEmpty && !arguments.contains(name)) continue;
- if (name == 'GENERIC' // Shouldn't be used.
- // We can't provoke a crash.
- ||
- name == 'COMPILER_CRASHED' ||
- name == 'PLEASE_REPORT_THE_CRASH'
- // We cannot provide examples for patch errors.
- ||
- name.startsWith('PATCH_') ||
- name == 'LIBRARY_NOT_SUPPORTED'
- // TODO(johnniwinther): Remove these when [Compiler.reportUnusedCode] is
- // reenabled.
- ||
- name == 'UNUSED_METHOD' ||
- name == 'UNUSED_CLASS' ||
- name == 'UNUSED_TYPEDEF' ||
-
- // Fasta no longer generates EXTRANEOUS_MODIFIER_REPLACE.
- name == 'EXTRANEOUS_MODIFIER_REPLACE' ||
-
- // Fasta just reports EXTRANEOUS_MODIFIER.
- name == 'FORMAL_DECLARED_STATIC' ||
-
- // Additional warning from dart2js.
- name == 'VOID_NOT_ALLOWED') continue;
- if (template.examples != null) {
- examples.add(template);
- } else {
- print("No example in '$name'");
- }
- }
- ;
- var cachedCompiler;
- asyncTest(() => Future.forEach(examples, (MessageTemplate template) {
- print("Checking '${template.kind}'.");
- Stopwatch sw = new Stopwatch()..start();
- return check(template, cachedCompiler).then((var compiler) {
- cachedCompiler = compiler;
- sw.stop();
- print("Checked '${template.kind}' in ${sw.elapsedMilliseconds}ms.");
- });
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/message_span_test.dart b/tests/compiler/dart2js/old_frontend/message_span_test.dart
deleted file mode 100644
index 6d774bc..0000000
--- a/tests/compiler/dart2js/old_frontend/message_span_test.dart
+++ /dev/null
@@ -1,184 +0,0 @@
-// 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:convert' show json, utf8;
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/diagnostics/messages.dart';
-import 'package:compiler/src/io/source_file.dart';
-import 'package:expect/expect.dart';
-import '../memory_compiler.dart';
-import '../memory_source_file_helper.dart';
-
-const List<Test> TESTS = const <Test>[
- const Test('''
-class A { A(b); }
-class B extends A {
- a() {}
-
- lot() {}
-
- of() {}
-
- var members;
-}
-main() => new B();''', const {
- MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
-class B extends A {
-^^^^^^^^^^^^^^^^^'''
- }),
- const Test('''
-class I {}
-class A { A(b); }
-class B extends A implements I {
- a() {}
-
- lot() {}
-
- of() {}
-
- var members;
-}
-main() => new B();''', const {
- MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
-class B extends A implements I {
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'''
- }),
- const Test('''
-class M<T> {}
-class A { A(b); }
-class B extends A with M<int> {
- a() {}
-
- lot() {}
-
- of() {}
-
- var members;
-}
-main() => new B();''', const {
- MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
-class B extends A with M<int> {
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'''
- }),
- const Test('''
-class A { A(b); }
-class B
- extends A {
- a() {}
-
- lot() {}
-
- of() {}
-
- var members;
-}
-main() => new B();''', const {
- MessageKind.NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT: '''
-class B
- extends A {
-'''
- }),
- const Test('''
-void foo(int a) {
- // a
- // non-empty
- // body
-}
-main() => foo('');''', const {
- MessageKind.THIS_IS_THE_METHOD: '''
-void foo(int a) {
-^^^^^^^^^^^^^^^'''
- }),
- const Test('''
-void foo(int a,
- int b) {
- // a
- // non-empty
- // body
-}
-main() => foo('', 0);''', const {
- MessageKind.THIS_IS_THE_METHOD: '''
-void foo(int a,
- int b) {
-'''
- }),
- const Test('''
-class A {
- int foo() {
- // a
- // non-empty
- // body
- }
-}
-class B extends A {
- int get foo {
- // a
- // non-empty
- // body
- return 0;
- }
-}
-main() => new B();''', const {
- MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER: '''
- int get foo {
- ^^^^^^^^^^^''',
- MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT: '''
- int foo() {
- ^^^^^^^^^'''
- }),
-];
-
-class Test {
- final String code;
- final Map<MessageKind, String> kindToSpan;
-
- const Test(this.code, this.kindToSpan);
-}
-
-const String MARKER = '---marker---';
-
-main() {
- asyncTest(() async {
- var cachedCompiler;
- for (Test test in TESTS) {
- DiagnosticCollector collector = new DiagnosticCollector();
- CompilationResult result = await runCompiler(
- memorySourceFiles: {'main.dart': test.code},
- options: [Flags.analyzeOnly, Flags.useOldFrontend],
- diagnosticHandler: collector,
- cachedCompiler: cachedCompiler);
- cachedCompiler = result.compiler;
- MemorySourceFileProvider provider = cachedCompiler.provider;
- Map<MessageKind, String> kindToSpan =
- new Map<MessageKind, String>.from(test.kindToSpan);
- for (CollectedMessage message in collector.messages) {
- String expectedSpanText = kindToSpan[message.messageKind];
- if (expectedSpanText != null) {
- SourceFile sourceFile = provider.getUtf8SourceFile(message.uri);
- String locationMessage =
- sourceFile.getLocationMessage(MARKER, message.begin, message.end);
- // Remove `filename:line:column:` and message.
- String strippedLocationMessage = locationMessage
- .substring(locationMessage.indexOf(MARKER) + MARKER.length + 1);
- // Using jsonEncode to add string quotes and backslashes.
- String expected = json.encode(
- utf8.decode(expectedSpanText.codeUnits, allowMalformed: true));
- String actual = json.encode(utf8
- .decode(strippedLocationMessage.codeUnits, allowMalformed: true));
- Expect.equals(
- expectedSpanText,
- strippedLocationMessage,
- "Unexpected span for ${message.messageKind} in\n${test.code}"
- "\nExpected: $expected"
- "\nActual : $actual");
- kindToSpan.remove(message.messageKind);
- }
- }
- kindToSpan.forEach((MessageKind kind, _) {
- Expect.fail("Missing message kin $kind in\n${test.code}");
- });
- }
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/metadata_test.dart b/tests/compiler/dart2js/old_frontend/metadata_test.dart
deleted file mode 100644
index f24dcf22..0000000
--- a/tests/compiler/dart2js/old_frontend/metadata_test.dart
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright (c) 2012, 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 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/constants/values.dart'
- show ConstantValue, StringConstantValue;
-import 'package:expect/expect.dart';
-import '../compiler_helper.dart';
-import 'package:compiler/src/parser/partial_elements.dart'
- show PartialMetadataAnnotation;
-import 'package:compiler/src/diagnostics/diagnostic_listener.dart'
- show DiagnosticReporter;
-
-void checkPosition(Spannable spannable, Node node, String source,
- DiagnosticReporter reporter) {
- SourceSpan span = reporter.spanFromSpannable(spannable);
- Expect.isTrue(
- span.begin < span.end, 'begin = ${span.begin}; end = ${span.end}');
- Expect.isTrue(
- span.end < source.length, 'end = ${span.end}; length = ${source.length}');
- String yield = source.substring(span.begin, span.end);
-
- // TODO(ahe): The node does not include "@". Fix that.
- Expect.stringEquals('@$node', yield);
-}
-
-void checkAnnotation(String name, String declaration,
- {bool isTopLevelOnly: false}) {
- // Ensure that a compile-time constant can be resolved from an
- // annotation.
- var source1 = """const native = 'xyz';
- @native
- $declaration
- main() {}""";
-
- analyzeAndCheck(source1, name, (compiler, element) {
- compiler.enqueuer.resolution.queueIsClosed = false;
- Expect.equals(
- 1, element.metadata.length, 'Unexpected metadata count on $element.');
- PartialMetadataAnnotation annotation = element.metadata.first;
- annotation.ensureResolved(compiler.resolution);
- ConstantValue value =
- compiler.constants.getConstantValue(annotation.constant);
- Expect.isTrue(value is StringConstantValue);
- Expect.stringEquals('xyz', (value as StringConstantValue).stringValue);
-
- checkPosition(
- annotation, annotation.cachedNode, source1, compiler.reporter);
- });
-
- // Ensure that each repeated annotation has a unique instance of
- // [MetadataAnnotation].
- var source2 = """const native = 'xyz';
- @native @native
- $declaration
- main() {}""";
-
- analyzeAndCheck(source2, name, (compiler, element) {
- compiler.enqueuer.resolution.queueIsClosed = false;
- Expect.equals(2, element.metadata.length);
- PartialMetadataAnnotation annotation1 = element.metadata.elementAt(0);
- PartialMetadataAnnotation annotation2 = element.metadata.elementAt(1);
- annotation1.ensureResolved(compiler.resolution);
- annotation2.ensureResolved(compiler.resolution);
- Expect.isFalse(
- identical(annotation1, annotation2), 'expected unique instances');
- Expect.notEquals(annotation1, annotation2, 'expected unequal instances');
- ConstantValue value1 =
- compiler.constants.getConstantValue(annotation1.constant);
- ConstantValue value2 =
- compiler.constants.getConstantValue(annotation2.constant);
- Expect.identical(value1, value2, 'expected same compile-time constant');
- Expect.isTrue(value1 is StringConstantValue);
- Expect.isTrue(value2 is StringConstantValue);
- Expect.stringEquals('xyz', (value1 as StringConstantValue).stringValue);
- Expect.stringEquals('xyz', (value2 as StringConstantValue).stringValue);
-
- checkPosition(
- annotation1, annotation1.cachedNode, source2, compiler.reporter);
- checkPosition(
- annotation2, annotation2.cachedNode, source2, compiler.reporter);
- });
-
- if (isTopLevelOnly) return;
-
- // Ensure that a compile-time constant can be resolved from an
- // annotation.
- var source3 = """const native = 'xyz';
- class Foo {
- @native
- $declaration
- }
- main() {}""";
-
- analyzeAndCheck(source3, 'Foo', (compiler, dynamic element) {
- compiler.enqueuer.resolution.queueIsClosed = false;
- Expect.equals(0, element.metadata.length);
- element.ensureResolved(compiler.resolution);
- Expect.equals(0, element.metadata.length);
- element = element.lookupLocalMember(name);
- Expect.equals(1, element.metadata.length);
- PartialMetadataAnnotation annotation = element.metadata.first;
- annotation.ensureResolved(compiler.resolution);
- ConstantValue value =
- compiler.constants.getConstantValue(annotation.constant);
- Expect.isTrue(value is StringConstantValue);
- Expect.stringEquals('xyz', (value as StringConstantValue).stringValue);
-
- checkPosition(
- annotation, annotation.cachedNode, source3, compiler.reporter);
- });
-
- // Ensure that each repeated annotation has a unique instance of
- // [MetadataAnnotation].
- var source4 = """const native = 'xyz';
- class Foo {
- @native @native
- $declaration
- }
- main() {}""";
-
- analyzeAndCheck(source4, 'Foo', (compiler, dynamic element) {
- compiler.enqueuer.resolution.queueIsClosed = false;
- Expect.equals(0, element.metadata.length);
- element.ensureResolved(compiler.resolution);
- Expect.equals(0, element.metadata.length);
- element = element.lookupLocalMember(name);
- Expect.equals(2, element.metadata.length);
- PartialMetadataAnnotation annotation1 = element.metadata.elementAt(0);
- PartialMetadataAnnotation annotation2 = element.metadata.elementAt(1);
- annotation1.ensureResolved(compiler.resolution);
- annotation2.ensureResolved(compiler.resolution);
- Expect.isFalse(
- identical(annotation1, annotation2), 'expected unique instances');
- Expect.notEquals(annotation1, annotation2, 'expected unequal instances');
- ConstantValue value1 =
- compiler.constants.getConstantValue(annotation1.constant);
- ConstantValue value2 =
- compiler.constants.getConstantValue(annotation2.constant);
- Expect.identical(value1, value2, 'expected same compile-time constant');
- Expect.isTrue(value1 is StringConstantValue);
- Expect.isTrue(value2 is StringConstantValue);
- Expect.stringEquals('xyz', (value1 as StringConstantValue).stringValue);
- Expect.stringEquals('xyz', (value2 as StringConstantValue).stringValue);
-
- checkPosition(
- annotation1, annotation1.cachedNode, source4, compiler.reporter);
- checkPosition(
- annotation1, annotation2.cachedNode, source4, compiler.reporter);
- });
-}
-
-void testClassMetadata() {
- checkAnnotation('Foo', 'class Foo {}', isTopLevelOnly: true);
-}
-
-void testTopLevelMethodMetadata() {
- checkAnnotation('foo', 'foo() {}');
-}
-
-void testTopLevelFieldMetadata() {
- checkAnnotation('foo', 'var foo;');
- checkAnnotation('bar', 'var foo, bar;');
-}
-
-void testLibraryTags() {
- void compileAndCheckLibrary(String source,
- List<MetadataAnnotation> extractMetadata(LibraryElement element)) {
- Uri partUri = new Uri(scheme: 'source', path: 'part.dart');
- String partSource = '@native part of foo;';
-
- Uri libUri = new Uri(scheme: 'source', path: 'lib.dart');
- String libSource = 'library lib;';
-
- Uri uri = new Uri(scheme: 'source', path: 'main.dart');
-
- var compiler = mockCompilerFor(source, uri, analyzeOnly: true)
- ..registerSource(partUri, partSource)
- ..registerSource(libUri, libSource);
-
- asyncTest(() => compiler.run(uri).then((_) {
- compiler.enqueuer.resolution.queueIsClosed = false;
- LibraryElement element = compiler.libraryLoader.lookupLibrary(uri);
- Expect.isNotNull(element, 'Cannot find $uri');
-
- List<MetadataAnnotation> metadata = extractMetadata(element);
- Expect.equals(1, metadata.length);
-
- PartialMetadataAnnotation annotation = metadata.first;
- annotation.ensureResolved(compiler.resolution);
- ConstantValue value =
- compiler.constants.getConstantValue(annotation.constant);
- Expect.isTrue(value is StringConstantValue);
- Expect.stringEquals(
- 'xyz', (value as StringConstantValue).stringValue);
-
- checkPosition(
- annotation, annotation.cachedNode, source, compiler.reporter);
- }));
- }
-
- var source;
-
- source = """@native
- library foo;
- const native = 'xyz';
- main() {}""";
- compileAndCheckLibrary(source, (dynamic e) => e.libraryTag.metadata);
-
- source = """@native
- import 'lib.dart';
- const native = 'xyz';
- main() {}""";
- compileAndCheckLibrary(source, (dynamic e) => e.tags.single.metadata);
-
- source = """@native
- export 'lib.dart';
- const native = 'xyz';
- main() {}""";
- compileAndCheckLibrary(source, (dynamic e) => e.tags.single.metadata);
-
- source = """@native
- part 'part.dart';
- const native = 'xyz';
- main() {}""";
- compileAndCheckLibrary(source, (dynamic e) => e.tags.single.metadata);
-
- source = """@native
- part 'part.dart';
- const native = 'xyz';
- main() {}""";
- compileAndCheckLibrary(
- source, (dynamic e) => e.compilationUnits.first.partTag.metadata);
-}
-
-void main() {
- testClassMetadata();
- testTopLevelMethodMetadata();
- testTopLevelFieldMetadata();
- testLibraryTags();
-}
diff --git a/tests/compiler/dart2js/old_frontend/method_type_variable_test.dart b/tests/compiler/dart2js/old_frontend/method_type_variable_test.dart
deleted file mode 100644
index 00a037a..0000000
--- a/tests/compiler/dart2js/old_frontend/method_type_variable_test.dart
+++ /dev/null
@@ -1,144 +0,0 @@
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/diagnostics/messages.dart';
-import 'package:expect/expect.dart';
-import '../memory_compiler.dart';
-
-runTest(String code,
- {List<MessageKind> expectedWarnings: const <MessageKind>[],
- List<MessageKind> expectedHints: const <MessageKind>[]}) async {
- print('--test--------------------------------------------------------------');
- print(code);
- DiagnosticCollector collector = new DiagnosticCollector();
- await runCompiler(
- memorySourceFiles: {'main.dart': code},
- diagnosticHandler: collector,
- options: [Flags.useOldFrontend]);
- Expect.equals(0, collector.errors.length, "Unexpected errors.");
- Expect.listEquals(
- expectedWarnings,
- collector.warnings.map((m) => m.messageKind).toList(),
- "Unexpected warnings.");
- Expect.listEquals(expectedHints,
- collector.hints.map((m) => m.messageKind).toList(), "Unexpected hints.");
-}
-
-class Test {
- final String code;
- final List<MessageKind> warnings;
- final List<MessageKind> hints;
-
- const Test(this.code,
- {this.warnings: const <MessageKind>[],
- this.hints: const <MessageKind>[]});
-}
-
-const List<Test> tests = const <Test>[
- /// Is-test on method type variable in unused static method.
- const Test('''
-method<T>(T t) => t is T;
-main() {}
-'''),
-
- /// Is-test on method type variable in used static method.
- const Test('''
-method<T>(T t) => t is T;
-main() => method<int>(0);
-''', warnings: const <MessageKind>[
- MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED
- ]),
-
- /// Is-test on method type variable in unused instance method.
- const Test('''
-class C {
- method<T>(T t) => t is T;
-}
-main() => new C();
-'''),
-
- /// Is-test on method type variable in used instance method.
- const Test('''
-class C {
- method<T>(T t) => t is T;
-}
-main() => new C().method<int>(0);
-''', warnings: const <MessageKind>[
- MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED
- ]),
-
- /// As-cast on method type variable in unused static method.
- const Test('''
-method<T>(T t) => t as T;
-main() {}
-'''),
-
- /// As-cast on method type variable in used static method.
- const Test('''
-method<T>(T t) => t as T;
-main() => method<int>(0);
-''', hints: const <MessageKind>[
- MessageKind.TYPE_VARIABLE_FROM_METHOD_CONSIDERED_DYNAMIC
- ]),
-
- /// As-cast on method type variable in unused instance method.
- const Test('''
-class C {
- method<T>(T t) => t as T;
-}
-main() => new C();
-'''),
-
- /// As-cast on method type variable in used instance method.
- const Test('''
-class C {
- method<T>(T t) => t as T;
-}
-main() => new C().method<int>(0);
-''', hints: const <MessageKind>[
- MessageKind.TYPE_VARIABLE_FROM_METHOD_CONSIDERED_DYNAMIC
- ]),
-
- /// Method type variable literal in unused static method.
- const Test('''
-method<T>() => T;
-main() {}
-'''),
-
- /// Method type variable literal in used static method.
- const Test('''
-method<T>() => T;
-main() => method<int>();
-''', warnings: const <MessageKind>[
- MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED
- ]),
-
- /// Method type variable literal in unused instance method.
- const Test('''
-class C {
- method<T>() => T;
-}
-main() => new C();
-'''),
-
- /// Method type variable literal in used instance method.
- const Test('''
-class C {
- method<T>() => T;
-}
-main() => new C().method<int>();
-''', warnings: const <MessageKind>[
- MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED
- ]),
-];
-
-main() {
- asyncTest(() async {
- for (Test test in tests) {
- await runTest(
- test.code,
- expectedWarnings: test.warnings,
- expectedHints: test.hints,
- );
- }
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/minimal_resolution_test.dart b/tests/compiler/dart2js/old_frontend/minimal_resolution_test.dart
deleted file mode 100644
index c266e93..0000000
--- a/tests/compiler/dart2js/old_frontend/minimal_resolution_test.dart
+++ /dev/null
@@ -1,63 +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.
-
-// Test that elements are not needlessly required by dart2js.
-
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/common/names.dart';
-import 'package:compiler/src/compiler.dart';
-import 'package:compiler/src/elements/elements.dart';
-import 'package:compiler/src/enqueue.dart';
-import 'package:expect/expect.dart';
-import '../memory_compiler.dart';
-
-main() {
- asyncTest(() async {
- await analyze('main() {}');
- await analyze('main() => proxy;', proxyConstantComputed: true);
- await analyze('@deprecated main() {}');
- await analyze('@deprecated main() => deprecated;', deprecatedClass: true);
- await analyze('main() => deprecated;', deprecatedClass: true);
- });
-}
-
-void checkInstantiated(Compiler compiler, ClassElement cls, bool expected) {
- ResolutionEnqueuer enqueuer = compiler.enqueuer.resolution;
- bool isInstantiated =
- enqueuer.worldBuilder.directlyInstantiatedClasses.contains(cls);
- bool isProcessed = enqueuer.processedClasses.contains(cls);
- Expect.equals(expected, isInstantiated,
- 'Unexpected instantiation state of class $cls.');
- Expect.equals(
- expected, isProcessed, 'Unexpected processing state of class $cls.');
-}
-
-analyze(String code,
- {bool proxyConstantComputed: false, bool deprecatedClass: false}) async {
- CompilationResult result = await runCompiler(
- memorySourceFiles: {'main.dart': code},
- options: ['--analyze-only', Flags.useOldFrontend]);
- Expect.isTrue(result.isSuccess);
- Compiler compiler = result.compiler;
- Expect.equals(
- proxyConstantComputed,
- compiler.resolution.wasProxyConstantComputedTestingOnly,
- "Unexpected computation of proxy constant.");
-
- LibraryElement coreLibrary =
- compiler.frontendStrategy.commonElements.coreLibrary;
- checkInstantiated(
- compiler, coreLibrary.find('_Proxy'), proxyConstantComputed);
- checkInstantiated(compiler, coreLibrary.find('Deprecated'), deprecatedClass);
-
- LibraryElement jsHelperLibrary =
- compiler.libraryLoader.lookupLibrary(Uris.dart__js_helper);
- jsHelperLibrary.forEachLocalMember((Element element) {
- Uri uri = element.compilationUnit.script.resourceUri;
- if (element.isClass && uri.path.endsWith('annotations.dart')) {
- checkInstantiated(compiler, element, false);
- }
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/missing_file_test.dart b/tests/compiler/dart2js/old_frontend/missing_file_test.dart
deleted file mode 100644
index 5fdbb8a..0000000
--- a/tests/compiler/dart2js/old_frontend/missing_file_test.dart
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that the compiler can handle imports when package root has not been set.
-
-library dart2js.test.missing_file;
-
-import 'dart:async';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import "package:compiler/src/diagnostics/messages.dart";
-import 'package:expect/expect.dart';
-import '../memory_compiler.dart';
-
-const MEMORY_SOURCE_FILES = const {
- 'main.dart': '''
-import 'foo.dart';
-main() {}
-''',
- 'bar.dart': '''
-import 'dart:foo';
-main() {}
-''',
- 'baz.dart': '''
-import 'dart:io';
-main() {}
-''',
-};
-
-Future runTest(Uri main, {MessageKind error, MessageKind info}) async {
- print("----\nentry-point: $main\n");
-
- DiagnosticCollector diagnostics = new DiagnosticCollector();
- OutputCollector output = new OutputCollector();
- await runCompiler(
- entryPoint: main,
- memorySourceFiles: MEMORY_SOURCE_FILES,
- diagnosticHandler: diagnostics,
- outputProvider: output,
- options: [Flags.useOldFrontend]);
-
- Expect.isFalse(output.hasExtraOutput);
- Expect.equals(error != null ? 1 : 0, diagnostics.errors.length);
- if (error != null) {
- Expect.equals(error, diagnostics.errors.first.message.kind);
- }
- Expect.equals(info != null ? 1 : 0, diagnostics.infos.length);
- if (info != null) {
- Expect.equals(info, diagnostics.infos.first.message.kind);
- }
- Expect.equals(0, diagnostics.warnings.length);
- Expect.equals(0, diagnostics.hints.length);
-}
-
-void main() {
- asyncTest(() async {
- await runTest(Uri.parse('memory:main.dart'),
- error: MessageKind.READ_URI_ERROR);
-
- await runTest(Uri.parse('memory:foo.dart'),
- error: MessageKind.READ_SELF_ERROR);
-
- await runTest(Uri.parse('dart:foo'), error: MessageKind.LIBRARY_NOT_FOUND);
-
- await runTest(Uri.parse('dart:_mirror_helper'),
- error: MessageKind.INTERNAL_LIBRARY,
- info: MessageKind.DISALLOWED_LIBRARY_IMPORT);
-
- await runTest(Uri.parse('memory:bar.dart'),
- error: MessageKind.LIBRARY_NOT_FOUND);
-
- // Importing dart:io is temporarily allowed as a stopgap measure for the
- // lack of config specific imports. Once that is added, this will be
- // disallowed again.
-
- //await runTest(Uri.parse('dart:io'),
- // error: MessageKind.LIBRARY_NOT_SUPPORTED,
- // info: MessageKind.DISALLOWED_LIBRARY_IMPORT);
-
- //await runTest(Uri.parse('memory:baz.dart'),
- // error: MessageKind.LIBRARY_NOT_SUPPORTED,
- // info: MessageKind.DISALLOWED_LIBRARY_IMPORT);
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/mixin_language_test.dart b/tests/compiler/dart2js/old_frontend/mixin_language_test.dart
deleted file mode 100644
index 89b4e0f..0000000
--- a/tests/compiler/dart2js/old_frontend/mixin_language_test.dart
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that dart2js produces the expected static type warnings for these
-// language tests. This ensures that the analyzer and dart2js agrees on the
-// tests.
-
-import 'warnings_checker.dart';
-
-/// Map from test files to a map of their expected status. If the status map is
-/// `null` no warnings must be missing or unexpected, otherwise the status map
-/// can contain a list of line numbers for keys 'missing' and 'unexpected' for
-/// the warnings of each category.
-const Map<String, dynamic> TESTS = const {
- 'language_2/typevariable_substitution2_test.dart': null,
-};
-
-void main(List<String> arguments) {
- checkWarnings(TESTS, arguments);
-}
diff --git a/tests/compiler/dart2js/old_frontend/no_such_method_codegen_test.dart b/tests/compiler/dart2js/old_frontend/no_such_method_codegen_test.dart
deleted file mode 100644
index 4c531f5..0000000
--- a/tests/compiler/dart2js/old_frontend/no_such_method_codegen_test.dart
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// The mock compiler of dart2js used to make the compiler crash on
-// this program.
-//
-// The SSA backend generates a call to a throwNoSuchMethod helper for
-// the access to `foo`, and we used to not infer return types of
-// helpers, so we did not know throwNoSuchMethod was not returning.
-// As a consequence, all operator[] had to be compiled, and due to
-// missing backend dependencies, some of them were not resolved.
-
-import '../compiler_helper.dart';
-
-const String TEST = '''
-main() => foo[42];
-''';
-
-main() {
- Uri uri = new Uri(scheme: 'source');
- var compiler = mockCompilerFor(TEST, uri);
- compiler.run(uri);
-}
diff --git a/tests/compiler/dart2js/old_frontend/null_is_bottom_test.dart b/tests/compiler/dart2js/old_frontend/null_is_bottom_test.dart
deleted file mode 100644
index 4d2ca6b..0000000
--- a/tests/compiler/dart2js/old_frontend/null_is_bottom_test.dart
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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.
-
-// Test that dart2js produces the expected static type warnings for proxy
-// language tests. This ensures that the analyzer and dart2js agrees on these
-// tests.
-
-import 'warnings_checker.dart';
-
-/// Map from test files to a map of their expected status. If the status map is
-/// `null` no warnings must be missing or unexpected, otherwise the status map
-/// can contain a list of line numbers for keys 'missing' and 'unexpected' for
-/// the warnings of each category.
-const Map<String, dynamic> TESTS = const {
- 'language/null_is_bottom_type_test.dart': null,
-};
-
-void main(List<String> args) {
- checkWarnings(TESTS, args);
-}
diff --git a/tests/compiler/dart2js/old_frontend/override_inheritance_test.dart b/tests/compiler/dart2js/old_frontend/override_inheritance_test.dart
deleted file mode 100644
index 271b498..0000000
--- a/tests/compiler/dart2js/old_frontend/override_inheritance_test.dart
+++ /dev/null
@@ -1,1610 +0,0 @@
-// Copyright (c) 2014, 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:async';
-import 'package:async_helper/async_helper.dart';
-import '../compiler_helper.dart';
-import 'package:compiler/src/resolution/class_members.dart' show MembersCreator;
-
-main() {
- asyncTest(() => Future.wait([
- testRequiredParameters(),
- testPositionalParameters(),
- testNamedParameters(),
- testNotSubtype(),
- testGetterNotSubtype(),
- testSetterNotSubtype(),
- testGenericNotSubtype(),
- testFieldNotSubtype(),
- testMixedOverride(),
- testAbstractMethods(),
- testNoSuchMethod(),
- ]));
-}
-
-Future check(String source, {errors, warnings, hints, infos}) {
- return MockCompiler.create((MockCompiler compiler) {
- compiler.diagnosticHandler = createHandler(compiler, source);
- compiler.parseScript(source);
- dynamic mainApp = compiler.mainApp;
- var cls = mainApp.find('Class');
- cls.ensureResolved(compiler.resolution);
- MembersCreator.computeAllClassMembers(compiler.resolution, cls);
-
- toList(o) => o == null ? [] : o is List ? o : [o];
-
- compareMessageKinds(
- source, toList(errors), compiler.diagnosticCollector.errors, 'error');
-
- compareMessageKinds(source, toList(warnings),
- compiler.diagnosticCollector.warnings, 'warning');
-
- if (infos != null) {
- compareMessageKinds(
- source, toList(infos), compiler.diagnosticCollector.infos, 'info');
- }
-
- if (hints != null) {
- compareMessageKinds(
- source, toList(hints), compiler.diagnosticCollector.hints, 'hint');
- }
- });
-}
-
-Future testRequiredParameters() {
- return Future.wait([
- check("""
- class A {
- method() => null; // testRequiredParameters:0
- }
- class Class extends A {
- method() => null; // testRequiredParameters:1
- }
- """),
- check("""
- class A {
- method(a) => null; // testRequiredParameters:2
- }
- class Class extends A {
- method(b) => null; // testRequiredParameters:3
- }
- """),
- check("""
- class A {
- method(a, b, c, d) => null; // testRequiredParameters:3
- }
- class Class extends A {
- method(b, a, d, c) => null; // testRequiredParameters:4
- }
- """),
- check("""
- class A {
- method() => null; // testRequiredParameters:5
- }
- class Class extends A {
- method(a) => null; // testRequiredParameters:6
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
- check("""
- class A {
- method() => null; // testRequiredParameters:7
- }
- class Class implements A {
- method(a) => null; // testRequiredParameters:8
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
- check("""
- class A {
- method(a, b, c) => null; // testRequiredParameters:9
- }
- class Class extends A {
- method(a, b, c, d) => null; // testRequiredParameters:10
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
- ]);
-}
-
-Future testPositionalParameters() {
- return Future.wait([
- check("""
- class A {
- method([a]) => null; // testPositionalParameters:1
- }
- class Class extends A {
- method([a]) => null; // testPositionalParameters:2
- }
- """),
- check("""
- class A {
- method([a, b]) => null; // testPositionalParameters:3
- }
- class Class extends A {
- method([b, a]) => null; // testPositionalParameters:4
- }
- """),
- check("""
- class A {
- method([a, b, c]) => null; // testPositionalParameters:5
- }
- class Class extends A {
- method([b, d, a, c]) => null; // testPositionalParameters:6
- }
- """),
- check("""
- class A {
- method([a]) => null; // testPositionalParameters:7
- }
- class Class extends A {
- method([a]) => null; // testPositionalParameters:8
- }
- """),
- check("""
- class A {
- method(a) => null; // testPositionalParameters:9
- }
- class Class extends A {
- method() => null; // testPositionalParameters:10
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
- check("""
- class A {
- method(a, [b]) => null; // testPositionalParameters:11
- }
- class Class extends A {
- method(a) => null; // testPositionalParameters:12
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
- check("""
- class A {
- method(a, [b]) => null; // testPositionalParameters:13
- }
- class Class extends A {
- method([a]) => null; // testPositionalParameters:14
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
- check("""
- class A {
- method(a, b, [c, d, e]) => null; // testPositionalParameters:15
- }
- class Class extends A {
- method([a, b, c, d]) => null; // testPositionalParameters:16
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
- ]);
-}
-
-Future testNamedParameters() {
- return Future.wait([
- check("""
- class A {
- method({a}) => null; // testNamedParameters:1
- }
- class Class extends A {
- method({a}) => null; // testNamedParameters:2
- }
- """),
- check("""
- class A {
- method({a, b}) => null; // testNamedParameters:3
- }
- class Class extends A {
- method({b, a}) => null; // testNamedParameters:4
- }
- """),
- check("""
- class A {
- method({a, b, c}) => null; // testNamedParameters:5
- }
- class Class extends A {
- method({b, c, a, d}) => null; // testNamedParameters:6
- }
- """),
- check("""
- class A {
- method(d, {a, b, c}) => null; // testNamedParameters:7
- }
- class Class extends A {
- method(e, {b, c, a, d}) => null; // testNamedParameters:8
- }
- """),
- check("""
- class A {
- method({a}) => null; // testNamedParameters:9
- }
- class Class extends A {
- method() => null; // testNamedParameters:10
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
- check("""
- class A {
- method({a, b}) => null; // testNamedParameters:11
- }
- class Class extends A {
- method({b}) => null; // testNamedParameters:12
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
- check("""
- class A {
- method({a, b, c, d}) => null; // testNamedParameters:13
- }
- class Class extends A {
- method({a, e, d, c}) => null; // testNamedParameters:14
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
- ]);
-}
-
-Future testNotSubtype() {
- return Future.wait([
- check("""
- class A {
- method(int a) => null; // testNotSubtype:1
- }
- class Class extends A {
- method(int a) => null; // testNotSubtype:2
- }
- """),
-
- check("""
- class A {
- method(int a) => null; // testNotSubtype:3
- }
- class Class extends A {
- method(num a) => null; // testNotSubtype:4
- }
- """),
-
- check("""
- class A {
- void method() {} // testNotSubtype:5
- }
- class Class extends A {
- method() => null; // testNotSubtype:6
- }
- """),
-
- check("""
- class A {
- method() => null; // testNotSubtype:7
- }
- class Class extends A {
- void method() {} // testNotSubtype:8
- }
- """),
-
- check("""
- class A {
- void method() {} // testNotSubtype:9
- }
- class Class extends A {
- int method() => null; // testNotSubtype:10
- }
- """),
-
- check("""
- class A {
- int method() => null; // testNotSubtype:11
- }
- class Class extends A {
- void method() {} // testNotSubtype:12
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
-
- check("""
- class A {
- method(int a) => null; // testNotSubtype:13
- }
- class B extends A {
- method(num a) => null; // testNotSubtype:14
- }
- class Class extends B {
- method(double a) => null; // testNotSubtype:15
- }
- """),
-
- check("""
- class A {
- method(int a) => null; // testNotSubtype:16
- }
- class B extends A {
- method(a) => null; // testNotSubtype:17
- }
- class Class extends B {
- method(String a) => null; // testNotSubtype:18
- }
- """),
-
- check("""
- class A {
- method(int a) => null; // testNotSubtype:19
- }
- class Class extends A {
- method(String a) => null; // testNotSubtype:20
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
-
- // TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
- check("""
- class A {
- method(int a) => null; // testNotSubtype:23
- }
- class B {
- method(num a) => null; // testNotSubtype:24
- }
- abstract class C implements A, B {
- }
- class Class implements C {
- method(double a) => null; // testNotSubtype:25
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
-
- check("""
- class A {
- method(num a) => null; // testNotSubtype:29
- }
- class B {
- method(int a) => null; // testNotSubtype:30
- }
- abstract class C implements A, B {
- }
- class Class implements C {
- method(double a) => null; // testNotSubtype:31
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
-
- check("""
- class A {
- method(int a) => null; // testNotSubtype:26
- }
- class B {
- method(num a) => null; // testNotSubtype:27
- }
- abstract class C implements A, B {
- }
- class Class implements C {
- method(String a) => null; // testNotSubtype:28
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_METHOD,
- MessageKind.INVALID_OVERRIDE_METHOD
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_METHOD,
- MessageKind.INVALID_OVERRIDDEN_METHOD
- ]),
- ]);
-}
-
-Future testGetterNotSubtype() {
- return Future.wait([
- check("""
- class A {
- get getter => null; // testGetterNotSubtype:1
- }
- class Class extends A {
- get getter => null; // testGetterNotSubtype:2
- }
- """),
-
- check("""
- class A {
- num get getter => null; // testGetterNotSubtype:3
- }
- class Class extends A {
- num get getter => null; // testGetterNotSubtype:4
- }
- """),
-
- check("""
- class A {
- num get getter => null; // testGetterNotSubtype:5
- }
- class Class extends A {
- int get getter => null; // testGetterNotSubtype:6
- }
- """),
-
- check("""
- class A {
- int get getter => null; // testGetterNotSubtype:7
- }
- class Class extends A {
- num get getter => null; // testGetterNotSubtype:8
- }
- """),
-
- check("""
- class A {
- int get getter => null; // testGetterNotSubtype:9
- }
- class Class extends A {
- double get getter => null; // testGetterNotSubtype:10
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_GETTER,
- infos: MessageKind.INVALID_OVERRIDDEN_GETTER),
-
- check("""
- class A {
- int get getter => null; // testGetterNotSubtype:11
- }
- class B extends A {
- num get getter => null; // testGetterNotSubtype:12
- }
- class Class extends B {
- double get getter => null; // testGetterNotSubtype:13
- }
- """),
-
- check("""
- class A {
- int get getter => null; // testGetterNotSubtype:14
- }
- class B {
- num get getter => null; // testGetterNotSubtype:15
- }
- class Class extends A implements B {
- double get getter => null; // testGetterNotSubtype:16
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_GETTER,
- infos: MessageKind.INVALID_OVERRIDDEN_GETTER),
-
- check("""
- class A {
- int get getter => null; // testGetterNotSubtype:17
- }
- class B {
- String get getter => null; // testGetterNotSubtype:18
- }
- class Class extends A implements B {
- double get getter => null; // testGetterNotSubtype:19
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_GETTER,
- MessageKind.INVALID_OVERRIDE_GETTER
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_GETTER,
- MessageKind.INVALID_OVERRIDDEN_GETTER
- ]),
-
- check("""
- class A {
- int get getter => null; // testGetterNotSubtype:20
- }
- class B {
- String get getter => null; // testGetterNotSubtype:21
- }
- class Class implements A, B {
- double get getter => null; // testGetterNotSubtype:22
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_GETTER,
- MessageKind.INVALID_OVERRIDE_GETTER
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_GETTER,
- MessageKind.INVALID_OVERRIDDEN_GETTER
- ]),
-
- // TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
- check("""
- class A {
- int get getter => null; // testGetterNotSubtype:23
- }
- class B {
- num get getter => null; // testGetterNotSubtype:24
- }
- abstract class C implements A, B {
- }
- class Class implements C {
- double get getter => null; // testGetterNotSubtype:25
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_GETTER,
- infos: MessageKind.INVALID_OVERRIDDEN_GETTER),
-
- check("""
- class A {
- int get getter => null; // testGetterNotSubtype:26
- }
- class B {
- num get getter => null; // testGetterNotSubtype:27
- }
- abstract class C implements A, B {
- }
- class Class implements C {
- String get getter => null; // testGetterNotSubtype:28
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_GETTER,
- MessageKind.INVALID_OVERRIDE_GETTER
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_GETTER,
- MessageKind.INVALID_OVERRIDDEN_GETTER
- ]),
- ]);
-}
-
-Future testGenericNotSubtype() {
- return Future.wait([
- check("""
- class A<T> {
- method(T t) => null; // testGenericNotSubtype:1
- }
- class Class<S> extends A<S> {
- method(S s) => null; // testGenericNotSubtype:2
- }
- """),
-
- check("""
- class A<T> {
- method(T t) => null; // testGenericNotSubtype:3
- }
- class Class extends A<num> {
- method(int i) => null; // testGenericNotSubtype:4
- }
- """),
-
- check("""
- class A<T> {
- method(T t) => null; // testGenericNotSubtype:5
- }
- class B<S> {
- method(S s) => null; // testGenericNotSubtype:6
- }
- class Class extends A<double> implements B<int> {
- method(num i) => null; // testGenericNotSubtype:7
- }
- """),
-
- check("""
- class A<T> {
- method(T t) => null; // testGenericNotSubtype:8
- }
- class Class<S> extends A<S> {
- method(int i) => null; // testGenericNotSubtype:9
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
-
- check("""
- class A<T> {
- method(T t) => null; // testGenericNotSubtype:10
- }
- class B<S> extends A<S> {
-
- }
- class Class<U> extends B<U> {
- method(U u) => null; // testGenericNotSubtype:11
- }
- """),
-
- check("""
- class A<T> {
- method(T t) => null; // testGenericNotSubtype:12
- }
- class B<S> {
- method(S s) => null; // testGenericNotSubtype:13
- }
- class Class<U> extends A<U> implements B<num> {
- method(int i) => null; // testGenericNotSubtype:14
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
-
- check("""
- class A<T> {
- method(T t) => null; // testGenericNotSubtype:15
- }
- class B<S> {
- method(S s) => null; // testGenericNotSubtype:16
- }
- class Class extends A<int> implements B<String> {
- method(double d) => null; // testGenericNotSubtype:17
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_METHOD,
- MessageKind.INVALID_OVERRIDE_METHOD
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_METHOD,
- MessageKind.INVALID_OVERRIDDEN_METHOD
- ]),
-
- check("""
- class A<T> {
- method(T t) => null; // testGenericNotSubtype:18
- }
- class B<S> {
- method(S s) => null; // testGenericNotSubtype:19
- }
- class Class implements A<int>, B<String> {
- method(double d) => null; // testGenericNotSubtype:20
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_METHOD,
- MessageKind.INVALID_OVERRIDE_METHOD
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_METHOD,
- MessageKind.INVALID_OVERRIDDEN_METHOD
- ]),
-
- // TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
- check("""
- class A<T> {
- method(T t) => null; // testGenericNotSubtype:21
- }
- class B<S> {
- method(S s) => null; // testGenericNotSubtype:22
- }
- abstract class C implements A<int>, B<num> {
- }
- class Class implements C {
- method(double d) => null; // testGenericNotSubtype:23
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_METHOD,
- infos: MessageKind.INVALID_OVERRIDDEN_METHOD),
-
- check("""
- class A<T> {
- method(T t) => null; // testGenericNotSubtype:24
- }
- class B<S> {
- method(S s) => null; // testGenericNotSubtype:25
- }
- abstract class C implements A<int>, B<num> {
- }
- class Class implements C {
- method(String s) => null; // testGenericNotSubtype:26
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_METHOD,
- MessageKind.INVALID_OVERRIDE_METHOD
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_METHOD,
- MessageKind.INVALID_OVERRIDDEN_METHOD
- ]),
- ]);
-}
-
-Future testSetterNotSubtype() {
- return Future.wait([
- check("""
- class A {
- set setter(_) => null; // testSetterNotSubtype:1
- }
- class Class extends A {
- set setter(_) => null; // testSetterNotSubtype:2
- }
- """),
-
- check("""
- class A {
- void set setter(_) {} // testSetterNotSubtype:3
- }
- class Class extends A {
- set setter(_) => null; // testSetterNotSubtype:4
- }
- """),
-
- check("""
- class A {
- set setter(_) => null; // testSetterNotSubtype:5
- }
- class Class extends A {
- void set setter(_) {} // testSetterNotSubtype:6
- }
- """),
-
- check("""
- class A {
- set setter(_) => null; // testSetterNotSubtype:7
- }
- class Class extends A {
- void set setter(_) {} // testSetterNotSubtype:8
- }
- """),
-
- check("""
- class A {
- set setter(num _) => null; // testSetterNotSubtype:9
- }
- class Class extends A {
- set setter(num _) => null; // testSetterNotSubtype:10
- }
- """),
-
- check("""
- class A {
- set setter(num _) => null; // testSetterNotSubtype:11
- }
- class Class extends A {
- set setter(int _) => null; // testSetterNotSubtype:12
- }
- """),
-
- check("""
- class A {
- set setter(int _) => null; // testSetterNotSubtype:13
- }
- class Class extends A {
- set setter(num _) => null; // testSetterNotSubtype:14
- }
- """),
-
- check("""
- class A {
- set setter(int _) => null; // testSetterNotSubtype:15
- }
- class Class extends A {
- set setter(double _) => null; // testSetterNotSubtype:16
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_SETTER,
- infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
-
- check("""
- class A {
- set setter(int _) => null; // testSetterNotSubtype:17
- }
- class B extends A {
- set setter(num _) => null; // testSetterNotSubtype:18
- }
- class Class extends B {
- set setter(double _) => null; // testSetterNotSubtype:19
- }
- """),
-
- check("""
- class A {
- set setter(int _) => null; // testSetterNotSubtype:20
- }
- class B {
- set setter(num _) => null; // testSetterNotSubtype:21
- }
- class Class extends A implements B {
- set setter(double _) => null; // testSetterNotSubtype:22
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_SETTER,
- infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
-
- check("""
- class A {
- set setter(int _) => null; // testSetterNotSubtype:23
- }
- class B {
- set setter(String _) => null; // testSetterNotSubtype:24
- }
- class Class extends A implements B {
- set setter(double _) => null; // testSetterNotSubtype:25
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_SETTER,
- MessageKind.INVALID_OVERRIDE_SETTER
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_SETTER,
- MessageKind.INVALID_OVERRIDDEN_SETTER
- ]),
-
- check("""
- class A {
- set setter(int _) => null; // testSetterNotSubtype:26
- }
- class B {
- set setter(String _) => null; // testSetterNotSubtype:27
- }
- class Class implements A, B {
- set setter(double _) => null; // testSetterNotSubtype:28
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_SETTER,
- MessageKind.INVALID_OVERRIDE_SETTER
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_SETTER,
- MessageKind.INVALID_OVERRIDDEN_SETTER
- ]),
-
- // TODO(johnniwinther): These are unclear. Issue 16443 has been filed.
- check("""
- class A {
- set setter(int _) => null; // testSetterNotSubtype:29
- }
- class B {
- set setter(num _) => null; // testSetterNotSubtype:30
- }
- abstract class C implements A, B {
- }
- class Class implements C {
- set setter(double _) => null; // testSetterNotSubtype:31
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_SETTER,
- infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
-
- check("""
- class A {
- set setter(int _) => null; // testSetterNotSubtype:32
- }
- class B {
- set setter(num _) => null; // testSetterNotSubtype:33
- }
- abstract class C implements A, B {
- }
- class Class implements C {
- set setter(String _) => null; // testSetterNotSubtype:34
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_SETTER,
- MessageKind.INVALID_OVERRIDE_SETTER
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_SETTER,
- MessageKind.INVALID_OVERRIDDEN_SETTER
- ]),
- ]);
-}
-
-Future testFieldNotSubtype() {
- return Future.wait([
- check("""
- class A {
- int field; // testFieldNotSubtype:1
- }
- class Class extends A {
- int field; // testFieldNotSubtype:2
- }
- """),
- check("""
- class A {
- num field; // testFieldNotSubtype:3
- }
- class Class extends A {
- int field; // testFieldNotSubtype:4
- }
- """),
- check("""
- class A {
- int field; // testFieldNotSubtype:5
- }
- class Class extends A {
- num field; // testFieldNotSubtype:6
- }
- """),
- check("""
- class A {
- int field; // testFieldNotSubtype:7
- }
- class Class extends A {
- double field; // testFieldNotSubtype:8
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_FIELD,
- infos: MessageKind.INVALID_OVERRIDDEN_FIELD),
- check("""
- class A {
- int field; // testFieldNotSubtype:9
- }
- class B extends A {
- num field; // testFieldNotSubtype:10
- }
- class Class extends B {
- double field; // testFieldNotSubtype:11
- }
- """),
- check("""
- class A {
- num field; // testFieldNotSubtype:12
- }
- class Class extends A {
- int get field => null; // testFieldNotSubtype:13
- }
- """),
- check("""
- class A {
- num field; // testFieldNotSubtype:14
- }
- class Class extends A {
- String get field => null; // testFieldNotSubtype:15
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER,
- infos: MessageKind.INVALID_OVERRIDDEN_FIELD),
- check("""
- class A {
- num get field => null; // testFieldNotSubtype:16
- }
- class Class extends A {
- String field; // testFieldNotSubtype:17
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_GETTER_WITH_FIELD,
- infos: MessageKind.INVALID_OVERRIDDEN_GETTER),
- check("""
- class A {
- num field; // testFieldNotSubtype:18
- }
- class Class extends A {
- set field(int _) {} // testFieldNotSubtype:19
- }
- """),
- check("""
- class A {
- num field; // testFieldNotSubtype:19
- }
- class Class extends A {
- void set field(int _) {} // testFieldNotSubtype:20
- }
- """),
- check("""
- class A {
- set field(int _) {} // testFieldNotSubtype:21
- }
- class Class extends A {
- num field; // testFieldNotSubtype:22
- }
- """),
- check("""
- class A {
- void set field(int _) {} // testFieldNotSubtype:23
- }
- class Class extends A {
- num field; // testFieldNotSubtype:24
- }
- """),
- check("""
- class A {
- num field; // testFieldNotSubtype:25
- }
- class Class extends A {
- set field(String _) {} // testFieldNotSubtype:26
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER,
- infos: MessageKind.INVALID_OVERRIDDEN_FIELD),
- check("""
- class A {
- set field(num _) {} // testFieldNotSubtype:27
- }
- class Class extends A {
- String field; // testFieldNotSubtype:28
- }
- """,
- warnings: MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD,
- infos: MessageKind.INVALID_OVERRIDDEN_SETTER),
- check("""
- class A {
- int field; // testFieldNotSubtype:29
- }
- class Class implements A {
- String get field => null; // testFieldNotSubtype:30
- void set field(String s) {} // testFieldNotSubtype:31
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_FIELD_WITH_GETTER,
- MessageKind.INVALID_OVERRIDE_FIELD_WITH_SETTER
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_FIELD,
- MessageKind.INVALID_OVERRIDDEN_FIELD
- ]),
- check("""
- class A {
- String get field => null; // testFieldNotSubtype:32
- void set field(String s) {} // testFieldNotSubtype:33
- }
- class Class implements A {
- int field; // testFieldNotSubtype:34
- }
- """, warnings: [
- MessageKind.INVALID_OVERRIDE_GETTER_WITH_FIELD,
- MessageKind.INVALID_OVERRIDE_SETTER_WITH_FIELD
- ], infos: [
- MessageKind.INVALID_OVERRIDDEN_GETTER,
- MessageKind.INVALID_OVERRIDDEN_SETTER
- ]),
- ]);
-}
-
-Future testMixedOverride() {
- return Future.wait([
- check("""
- class A {
- var member; // testMixedOverride:1
- }
- class Class extends A {
- member() {} // testMixedOverride:2
- }
- """,
- errors: MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD,
- infos: MessageKind.CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT),
- check("""
- class A {
- member() {} // testMixedOverride:3
- }
- class Class extends A {
- var member; // testMixedOverride:4
- }
- """,
- errors: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD,
- infos: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT),
- check("""
- class A {
- get member => null; // testMixedOverride:5
- }
- class Class extends A {
- member() {} // testMixedOverride:6
- }
- """,
- errors: MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD,
- infos: MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT),
- check("""
- class A {
- member() {} // testMixedOverride:7
- }
- class Class extends A {
- get member => null; // testMixedOverride:8
- }
- """,
- errors: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER,
- infos: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT),
- check("""
- abstract class A {
- var member; // testMixedOverride:9
- }
- abstract class B {
- get member; // testMixedOverride:10
- }
- abstract class Class implements A, B {
- }
- """),
- check(
- """
- abstract class A {
- var member; // testMixedOverride:11
- }
- abstract class B {
- member() {} // testMixedOverride:12
- }
- abstract class Class implements A, B {
- }
- """,
- warnings: MessageKind.INHERIT_GETTER_AND_METHOD,
- infos: [
- MessageKind.INHERITED_METHOD,
- MessageKind.INHERITED_IMPLICIT_GETTER
- ]),
- check(
- """
- abstract class A {
- get member; // testMixedOverride:13
- }
- abstract class B {
- member() {} // testMixedOverride:14
- }
- abstract class Class implements A, B {
- }
- """,
- warnings: MessageKind.INHERIT_GETTER_AND_METHOD,
- infos: [
- MessageKind.INHERITED_METHOD,
- MessageKind.INHERITED_EXPLICIT_GETTER
- ]),
- check(
- """
- abstract class A {
- get member; // testMixedOverride:15
- }
- abstract class B {
- member() {} // testMixedOverride:16
- }
- abstract class C {
- var member; // testMixedOverride:17
- }
- abstract class D {
- member() {} // testMixedOverride:18
- }
- abstract class E {
- get member; // testMixedOverride:19
- }
- abstract class Class implements A, B, C, D, E {
- }
- """,
- warnings: MessageKind.INHERIT_GETTER_AND_METHOD,
- infos: [
- MessageKind.INHERITED_EXPLICIT_GETTER,
- MessageKind.INHERITED_METHOD,
- MessageKind.INHERITED_IMPLICIT_GETTER,
- MessageKind.INHERITED_METHOD,
- MessageKind.INHERITED_EXPLICIT_GETTER
- ]),
- check(
- """
- abstract class A {
- get member; // testMixedOverride:20
- }
- abstract class B {
- member() {} // testMixedOverride:21
- }
- abstract class C implements A, B {
- }
- class Class extends C {
- member() {} // testMixedOverride:22
- }
- """,
- errors: MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD,
- warnings: MessageKind.INHERIT_GETTER_AND_METHOD,
- infos: [
- MessageKind.INHERITED_METHOD,
- MessageKind.INHERITED_EXPLICIT_GETTER,
- MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT
- ]),
- check(
- """
- abstract class A {
- get member; // testMixedOverride:23
- }
- abstract class B {
- member() {} // testMixedOverride:24
- }
- abstract class C implements A, B {
- }
- class Class extends C {
- get member => null; // testMixedOverride:25
- }
- """,
- errors: MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER,
- warnings: MessageKind.INHERIT_GETTER_AND_METHOD,
- infos: [
- MessageKind.INHERITED_METHOD,
- MessageKind.INHERITED_EXPLICIT_GETTER,
- MessageKind.CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT
- ]),
- ]);
-}
-
-Future testAbstractMethods() {
- return Future.wait([
- check("""
- abstract class Class {
- method(); // testAbstractMethod:1
- }
- """),
- check(
- """
- class Class {
- method(); // testAbstractMethod:2
- }
- """,
- warnings: MessageKind.ABSTRACT_METHOD,
- infos: []),
- check(
- """
- class Class {
- get getter; // testAbstractMethod:3
- }
- """,
- warnings: MessageKind.ABSTRACT_GETTER,
- infos: []),
- check(
- """
- class Class {
- set setter(_); // testAbstractMethod:4
- }
- """,
- warnings: MessageKind.ABSTRACT_SETTER,
- infos: []),
- check("""
- abstract class A {
- method(); // testAbstractMethod:5
- }
- class Class extends A {
- method() {} // testAbstractMethod:6
- }
- """),
- check("""
- abstract class A {
- method(); // testAbstractMethod:7
- }
- class Class extends A {
- method([a]) {} // testAbstractMethod:8
- }
- """),
- check("""
- abstract class A {
- method(); // testAbstractMethod:9
- }
- class Class extends A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
- infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
- check("""
- abstract class A {
- get getter; // testAbstractMethod:10
- }
- class Class extends A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE,
- infos: MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER),
- check("""
- abstract class A {
- set setter(_); // testAbstractMethod:11
- }
- class Class extends A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
- infos: MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER),
- check(
- """
- abstract class A {
- method(); // testAbstractMethod:12
- }
- class B {
- method() {} // testAbstractMethod:13
- }
- class Class extends A implements B {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_METHOD,
- infos: [
- MessageKind.UNIMPLEMENTED_METHOD_CONT,
- MessageKind.UNIMPLEMENTED_METHOD_CONT
- ]),
- check(
- """
- class Class implements Function {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
- infos: []),
- check(
- """
- abstract class A {
- get getter; // testAbstractMethod:14
- }
- class B {
- get getter => 0; // testAbstractMethod:15
- }
- class Class extends A implements B {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_GETTER,
- infos: [
- MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER,
- MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER
- ]),
- check(
- """
- abstract class A {
- set setter(_); // testAbstractMethod:16
- }
- class B {
- set setter(_) {} // testAbstractMethod:17
- }
- class Class extends A implements B {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_SETTER,
- infos: [
- MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER,
- MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER
- ]),
- check(
- """
- abstract class A {
- get field; // testAbstractMethod:18
- }
- class B {
- var field; // testAbstractMethod:19
- }
- class Class extends A implements B {
- set field(_) {} // testAbstractMethod:20
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_GETTER,
- infos: [
- MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER,
- MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER
- ]),
- check(
- """
- abstract class A {
- set field(_); // testAbstractMethod:21
- }
- class B {
- var field; // testAbstractMethod:22
- }
- class Class extends A implements B {
- get field => 0; // testAbstractMethod:23
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_SETTER,
- infos: [
- MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER,
- MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
- ]),
- check("""
- class A {
- method() {} // testAbstractMethod:24
- }
- class Class implements A {
- method() {} // testAbstractMethod:25
- }
- """),
- check("""
- class A {
- method() {} // testAbstractMethod:26
- }
- class Class implements A {
- method([a]) {} // testAbstractMethod:27
- }
- """),
- check("""
- class A {
- method() {} // testAbstractMethod:28
- }
- class Class implements A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
- infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
- check("""
- class A {
- method() {} // testAbstractMethod:29
- }
- class B {
- method() {} // testAbstractMethod:30
- }
- class Class extends A implements B {
- }
- """),
- check("""
- class A {
- var member; // testAbstractMethod:31
- }
- class Class implements A {
- }
- """, warnings: [
- MessageKind.UNIMPLEMENTED_GETTER_ONE,
- MessageKind.UNIMPLEMENTED_SETTER_ONE
- ], infos: [
- MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
- MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
- ]),
- check("""
- class A {
- var member; // testAbstractMethod:32
- }
- class B {
- get member => null; // testAbstractMethod:33
- set member(_) {} // testAbstractMethod:34
- }
- class Class implements A, B {
- }
- """, warnings: [
- MessageKind.UNIMPLEMENTED_GETTER,
- MessageKind.UNIMPLEMENTED_SETTER
- ], infos: [
- MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER,
- MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
- MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER,
- MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
- ]),
- check("""
- class A {
- var member; // testAbstractMethod:35
- }
- class B {
- var member; // testAbstractMethod:36
- }
- class Class implements A, B {
- }
- """, warnings: [
- MessageKind.UNIMPLEMENTED_GETTER,
- MessageKind.UNIMPLEMENTED_SETTER
- ], infos: [
- MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
- MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER,
- MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER,
- MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER
- ]),
- check("""
- class A {
- get member => 0; // testAbstractMethod:37
- }
- class Class implements A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE,
- infos: MessageKind.UNIMPLEMENTED_EXPLICIT_GETTER),
- check("""
- class A {
- set member(_) {} // testAbstractMethod:38
- }
- class Class implements A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
- infos: MessageKind.UNIMPLEMENTED_EXPLICIT_SETTER),
- check("""
- class A {
- var member; // testAbstractMethod:39
- }
- class Class implements A {
- get member => 0;
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
- infos: MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER),
- check("""
- class A {
- var field; // testAbstractMethod:40
- }
- class Class implements A {
- final field = 0; // testAbstractMethod:41
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_SETTER_ONE,
- infos: MessageKind.UNIMPLEMENTED_IMPLICIT_SETTER),
- check("""
- class A {
- var member; // testAbstractMethod:42
- }
- class Class implements A {
- set member(_) {}
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_GETTER_ONE,
- infos: MessageKind.UNIMPLEMENTED_IMPLICIT_GETTER),
- check("""
- abstract class A {
- method() {} // testAbstractMethod:43
- }
- class Class extends A {
- method();
- }
- """),
- ]);
-}
-
-Future testNoSuchMethod() {
- return Future.wait([
- check(
- """
- class Class {
- method(); // testNoSuchMethod:1
- }
- """,
- warnings: MessageKind.ABSTRACT_METHOD,
- infos: []),
- check(
- """
- @proxy
- class Class {
- method(); // testNoSuchMethod:2
- }
- """,
- warnings: MessageKind.ABSTRACT_METHOD,
- infos: []),
- check("""
- class Class {
- noSuchMethod(_) => null;
- method(); // testNoSuchMethod:3
- }
- """),
- check("""
- class Class {
- noSuchMethod(_, [__]) => null;
- method(); // testNoSuchMethod:4
- }
- """),
- check("""
- class Class {
- noSuchMethod(_);
- method(); // testNoSuchMethod:5
- }
- """),
- check("""
- abstract class A {
- method(); // testNoSuchMethod:6
- }
- class Class extends A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
- infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
- check("""
- abstract class A {
- method(); // testNoSuchMethod:7
- }
- @proxy
- class Class extends A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
- infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
- check("""
- abstract class A {
- method(); // testNoSuchMethod:8
- }
- class Class extends A {
- noSuchMethod(_) => null;
- }
- """),
- check("""
- class A {
- method() {} // testNoSuchMethod:9
- }
- class Class implements A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
- infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
- check("""
- class A {
- method() {} // testNoSuchMethod:10
- }
- class Class implements A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
- infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
- check("""
- class A {
- method() {} // testNoSuchMethod:11
- }
- @proxy
- class Class implements A {
- }
- """,
- warnings: MessageKind.UNIMPLEMENTED_METHOD_ONE,
- infos: MessageKind.UNIMPLEMENTED_METHOD_CONT),
- check("""
- class A {
- method() {} // testNoSuchMethod:12
- }
- class Class implements A {
- noSuchMethod(_) => null;
- }
- """),
- check("""
- class A {
- noSuchMethod(_) => null;
- method(); // testNoSuchMethod:13
- }
- class Class extends A {
- }
- """),
- ]);
-}
diff --git a/tests/compiler/dart2js/old_frontend/package_root_test.dart b/tests/compiler/dart2js/old_frontend/package_root_test.dart
deleted file mode 100644
index 793d17f..0000000
--- a/tests/compiler/dart2js/old_frontend/package_root_test.dart
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that the compiler can handle imports when package root has not been set.
-
-library dart2js.test.package_root;
-
-import 'dart:async';
-
-import 'package:async_helper/async_helper.dart';
-import 'package:expect/expect.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/compiler.dart' show PackagesDiscoveryProvider;
-import 'package:compiler/src/diagnostics/messages.dart' show MessageKind;
-import 'package:package_config/packages.dart';
-
-import '../memory_compiler.dart';
-import '../memory_source_file_helper.dart';
-
-const MEMORY_SOURCE_FILES = const {
- 'main.dart': '''
-
-import 'package:foo/foo.dart';
-
-main() {}
-''',
- 'package.config': '''
-''',
-};
-
-final Uri PACKAGE_CONFIG_URI = Uri.parse('memory:package.config');
-
-Future runTest(Uri main, MessageKind expectedMessageKind,
- {Uri packageRoot,
- Uri packageConfig,
- PackagesDiscoveryProvider packagesDiscoveryProvider}) async {
- DiagnosticCollector collector = new DiagnosticCollector();
- await runCompiler(
- entryPoint: main,
- memorySourceFiles: MEMORY_SOURCE_FILES,
- diagnosticHandler: collector,
- packageRoot: packageRoot,
- packageConfig: packageConfig,
- packagesDiscoveryProvider: packagesDiscoveryProvider,
- options: [Flags.useOldFrontend]);
- Expect.equals(
- 1, collector.errors.length, "Unexpected errors: ${collector.errors}");
- Expect.equals(expectedMessageKind, collector.errors.first.message.kind,
- "Unexpected error: ${collector.errors.first}");
-}
-
-void main() {
- asyncTest(() async {
- Uri script = currentDirectory.resolveUri(Platform.script);
- Uri packageRoot = script.resolve('./packages/');
-
- PackagesDiscoveryProvider noPackagesDiscovery = (Uri uri) {
- return new Future.value(Packages.noPackages);
- };
-
- await runTest(Uri.parse('memory:main.dart'), MessageKind.READ_URI_ERROR,
- packageRoot: packageRoot);
- await runTest(Uri.parse('memory:main.dart'), MessageKind.LIBRARY_NOT_FOUND,
- packageConfig: PACKAGE_CONFIG_URI);
- await runTest(Uri.parse('memory:main.dart'), MessageKind.LIBRARY_NOT_FOUND,
- packagesDiscoveryProvider: noPackagesDiscovery);
-
- await runTest(
- Uri.parse('package:foo/foo.dart'), MessageKind.READ_SELF_ERROR,
- packageRoot: packageRoot);
- await runTest(
- Uri.parse('package:foo/foo.dart'), MessageKind.LIBRARY_NOT_FOUND,
- packageConfig: PACKAGE_CONFIG_URI);
- await runTest(
- Uri.parse('package:foo/foo.dart'), MessageKind.LIBRARY_NOT_FOUND,
- packagesDiscoveryProvider: noPackagesDiscovery);
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/parser_test.dart b/tests/compiler/dart2js/old_frontend/parser_test.dart
deleted file mode 100644
index c4f9881..0000000
--- a/tests/compiler/dart2js/old_frontend/parser_test.dart
+++ /dev/null
@@ -1,381 +0,0 @@
-// Copyright (c) 2011, 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 "package:expect/expect.dart";
-import 'parser_helper.dart';
-import 'package:compiler/src/tree/tree.dart';
-
-void testStatement(String statement) {
- Node node = parseStatement(statement);
- Expect.isNotNull(node.toString());
-}
-
-void testGenericTypes() {
- testStatement('List<T> t;');
- testStatement('List<List<T>> t;');
- testStatement('List<List<List<T>>> t;');
- testStatement('List<List<List<List<T>>>> t;');
- testStatement('List<List<List<List<List<T>>>>> t;');
-
- testStatement('List<List<T> > t;');
- testStatement('List<List<List<T> >> t;');
- testStatement('List<List<List<List<T> >>> t;');
- testStatement('List<List<List<List<List<T> >>>> t;');
-
- testStatement('List<List<List<T> > > t;');
- testStatement('List<List<List<List<T> > >> t;');
- testStatement('List<List<List<List<List<T> > >>> t;');
-
- testStatement('List<List<List<List<T> > > > t;');
- testStatement('List<List<List<List<List<T> > > >> t;');
-
- testStatement('List<List<List<List<List<T> > > > > t;');
-
- testStatement('List<List<List<List<List<T> >> >> t;');
-
- testStatement('List<List<List<List<List<T> >>> > t;');
-
- testStatement('List<List<List<List<List<T >>> >> t;');
-
- testStatement('List<T> t;');
- testStatement('List<List<T>> t;');
- testStatement('List<List<List<T>>> t;');
- testStatement('List<List<List<List<T>>>> t;');
- testStatement('List<List<List<List<List<T>>>>> t;');
-}
-
-void testPrefixedGenericTypes() {
- testStatement('lib.List<List<T> > t;');
- testStatement('lib.List<List<List<T> >> t;');
- testStatement('lib.List<List<List<List<T> >>> t;');
- testStatement('lib.List<List<List<List<List<T> >>>> t;');
-
- testStatement('lib.List<List<List<T> > > t;');
- testStatement('lib.List<List<List<List<T> > >> t;');
- testStatement('lib.List<List<List<List<List<T> > >>> t;');
-
- testStatement('lib.List<List<List<List<T> > > > t;');
- testStatement('lib.List<List<List<List<List<T> > > >> t;');
-
- testStatement('lib.List<List<List<List<List<T> > > > > t;');
-
- testStatement('lib.List<List<List<List<List<T> >> >> t;');
-
- testStatement('lib.List<List<List<List<List<T> >>> > t;');
-
- testStatement('lib.List<List<List<List<List<T >>> >> t;');
-}
-
-void testUnaryExpression() {
- testStatement('x++;');
- // TODO(ahe): reenable following test.
- // testStatement('++x++;');
- testStatement('++x;');
- testStatement('print(x++);');
- // TODO(ahe): reenable following test.
- // testStatement('print(++x++);'); // Accepted by parser, rejected later.
- testStatement('print(++x);');
-}
-
-void testChainedMethodCalls() {
- testStatement('MyClass.foo().bar().baz();');
- // TODO(ahe): reenable following test.
- // testStatement('MyClass.foo().-x;'); // Accepted by parser, rejected later.
- testStatement('a.b.c.d();');
-}
-
-void testFunctionStatement() {
- testStatement('int f() {}');
- testStatement('void f() {}');
-}
-
-void testDoStatement() {
- testStatement('do fisk(); while (hest());');
- testStatement('do { fisk(); } while (hest());');
-}
-
-void testWhileStatement() {
- testStatement('while (fisk()) hest();');
- testStatement('while (fisk()) { hest(); }');
-}
-
-void testConditionalExpression() {
- ExpressionStatement node = parseStatement("a ? b : c;");
- Conditional conditional = node.expression;
-
- node = parseStatement("a ? b ? c : d : e;");
- // Should parse as: a ? ( b ? c : d ) : e.
- conditional = node.expression;
- Expect.isNotNull(conditional.thenExpression.asConditional());
- Expect.isNotNull(conditional.elseExpression.asSend());
-
- node = parseStatement("a ? b : c ? d : e;");
- // Should parse as: a ? b : (c ? d : e).
- conditional = node.expression;
- Expect.isNotNull(conditional.thenExpression.asSend());
- Expect.isNotNull(conditional.elseExpression.asConditional());
-
- node = parseStatement("a ? b ? c : d : e ? f : g;");
- // Should parse as: a ? (b ? c : d) : (e ? f : g).
- conditional = node.expression;
- Expect.isNotNull(conditional.thenExpression.asConditional());
- Expect.isNotNull(conditional.elseExpression.asConditional());
-
- node = parseStatement("a = b ? c : d;");
- // Should parse as: a = (b ? c : d).
- SendSet sendSet = node.expression;
- Expect.isNotNull(sendSet.arguments.head.asConditional());
-
- node = parseStatement("a ? b : c = d;");
- // Should parse as: a ? b : (c = d).
- conditional = node.expression;
- Expect.isNull(conditional.thenExpression.asSendSet());
- Expect.isNotNull(conditional.elseExpression.asSendSet());
-
- node = parseStatement("a ? b = c : d;");
- // Should parse as: a ? (b = c) : d.
- conditional = node.expression;
- Expect.isNotNull(conditional.thenExpression.asSendSet());
- Expect.isNull(conditional.elseExpression.asSendSet());
-
- node = parseStatement("a ? b = c : d = e;");
- // Should parse as: a ? (b = c) : (d = e).
- conditional = node.expression;
- Expect.isNotNull(conditional.thenExpression.asSendSet());
- Expect.isNotNull(conditional.elseExpression.asSendSet());
-
- node = parseStatement("a ?? b ? c : d;");
- // Should parse as: (a ?? b) ? c : d;
- conditional = node.expression;
- Expect.isNotNull(conditional.condition.asSend());
- Expect.isTrue(conditional.condition.asSend().isIfNull);
- Expect.isNotNull(conditional.thenExpression.asSend());
- Expect.isNotNull(conditional.elseExpression.asSend());
-}
-
-void testNullOperators() {
- ExpressionStatement statement = parseStatement("a ?? b;");
- Expression node = statement.expression;
- Expect.isNotNull(node.asSend());
- Expect.isTrue(node.asSend().isIfNull);
-
- statement = parseStatement("a ??= b;");
- node = statement.expression;
- Expect.isNotNull(node.asSendSet());
- Expect.isTrue(node.asSendSet().isIfNullAssignment);
-
- statement = parseStatement("a?.b;");
- node = statement.expression;
- Expect.isNotNull(node.asSend());
- Expect.isTrue(node.asSend().isConditional);
-
- statement = parseStatement("a?.m();");
- node = statement.expression;
- Expect.isNotNull(node.asSend());
- Expect.isTrue(node.asSend().isConditional);
-}
-
-void testAssignment() {
- ExpressionStatement node;
- Expression expression;
- SendSet sendSet;
-
- node = parseStatement("a = b;");
- expression = node.expression;
- Expect.isNotNull(expression.asSendSet());
-
- node = parseStatement("a = b = c;");
- // Should parse as: a = (b = c).
- expression = node.expression;
- Expect.isNotNull(sendSet = expression.asSendSet());
- Expect.isNotNull(sendSet.arguments.head.asSendSet());
-
- node = parseStatement("a = b = c = d;");
- // Should parse as: a = (b = (c = d)).
- expression = node.expression;
- Expect.isNotNull(sendSet = expression.asSendSet());
- Expect.isNotNull(sendSet = sendSet.arguments.head.asSendSet());
- Expect.isNotNull(sendSet = sendSet.arguments.head.asSendSet());
-
- node = parseStatement("a.b = c;");
- // Should parse as: receiver = a, selector = b, arguments = c.
- expression = node.expression;
- Expect.isNotNull(sendSet = expression.asSendSet());
- Expect.stringEquals("a", sendSet.receiver.toString());
- Expect.stringEquals("b", sendSet.selector.toString());
- Expect.stringEquals("c", sendSet.arguments.head.toString());
-
- node = parseStatement("a.b = c.d;");
- // Should parse as: a.b = (c.d).
- expression = node.expression;
- Expect.isNotNull(sendSet = expression.asSendSet());
- Expect.stringEquals("a", sendSet.receiver.toString());
- Expect.stringEquals("b", sendSet.selector.toString());
- Expect.stringEquals("c.d", sendSet.arguments.head.toString());
-
- node = parseStatement("a.b = c.d = e.f;");
- // Should parse as: a.b = (c.d = (e.f)).
- expression = node.expression;
- Expect.isNotNull(sendSet = expression.asSendSet());
- Expect.stringEquals("a", sendSet.receiver.toString());
- Expect.stringEquals("b", sendSet.selector.toString());
- Expect.isNotNull(sendSet = sendSet.arguments.head.asSendSet());
- Expect.stringEquals("c", sendSet.receiver.toString());
- Expect.stringEquals("d", sendSet.selector.toString());
- Expect.stringEquals("e.f", sendSet.arguments.head.toString());
-}
-
-void testIndex() {
- ExpressionStatement node;
- Expression expression;
- Send send;
- SendSet sendSet;
-
- node = parseStatement("a[b];");
- // Should parse as: (a)[b].
- expression = node.expression;
- Expect.isNotNull(send = expression.asSend());
- Expect.stringEquals("a", send.receiver.toString());
- Expect.stringEquals("[]", send.selector.toString());
- Expect.stringEquals("b", send.arguments.head.toString());
-
- node = parseStatement("a[b] = c;");
- // Should parse as: (a)[b] = c.
- expression = node.expression;
- Expect.isNotNull(sendSet = expression.asSendSet());
- Expect.stringEquals("a", sendSet.receiver.toString());
- Expect.stringEquals("[]", sendSet.selector.toString());
- Expect.stringEquals("=", sendSet.assignmentOperator.toString());
- Expect.stringEquals("b", sendSet.arguments.head.toString());
- Expect.stringEquals("c", sendSet.arguments.tail.head.toString());
-
- node = parseStatement("a.b[c];");
- // Should parse as: (a.b)[c].
- expression = node.expression;
- Expect.isNotNull(send = expression.asSend());
- Expect.stringEquals("a.b", send.receiver.toString());
- Expect.stringEquals("[]", send.selector.toString());
- Expect.stringEquals("c", send.arguments.head.toString());
-
- node = parseStatement("a.b[c] = d;");
- // Should parse as: (a.b)[] = (c, d).
- expression = node.expression;
- Expect.isNotNull(sendSet = expression.asSendSet());
- Expect.isNotNull(send = sendSet.receiver.asSend());
- Expect.stringEquals("a.b", send.toString());
- Expect.stringEquals("[]", sendSet.selector.toString());
- Expect.stringEquals("=", sendSet.assignmentOperator.toString());
- Expect.stringEquals("c", sendSet.arguments.head.toString());
- Expect.stringEquals("d", sendSet.arguments.tail.head.toString());
-}
-
-void testPostfix() {
- ExpressionStatement node;
- Expression expression;
- SendSet sendSet;
-
- node = parseStatement("a.b++;");
- // Should parse as: (a.b)++.
- expression = node.expression;
- Expect.isNotNull(sendSet = expression.asSendSet());
- Expect.stringEquals("a", sendSet.receiver.toString());
- Expect.stringEquals("b", sendSet.selector.toString());
- Expect.stringEquals("++", sendSet.assignmentOperator.toString());
- Expect.isTrue(sendSet.arguments.isEmpty);
-}
-
-void testOperatorParse() {
- FunctionExpression function = parseMember('operator -() => null;');
- Send name = function.name.asSend();
- Expect.isNotNull(name);
- Expect.stringEquals('operator', name.receiver.toString());
- Expect.stringEquals('-', name.selector.toString());
- Expect.isTrue(function.parameters.isEmpty);
- Expect.isNull(function.returnType);
- Expect.isNull(function.getOrSet);
-}
-
-class Collector extends DiagnosticReporter {
- int token = -1;
-
- void reportFatalError(Token token) {
- this.token = token.kind;
- throw this;
- }
-
- void reportError(DiagnosticMessage message,
- [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]) {
- assert(token != -1);
- throw this;
- }
-
- spanFromToken(Token token) {
- this.token = token.kind;
- }
-
- void log(message) {
- print(message);
- }
-
- noSuchMethod(Invocation invocation) {
- throw 'unsupported operation';
- }
-
- @override
- DiagnosticMessage createMessage(spannable, messageKind,
- [arguments = const {}]) {
- return new DiagnosticMessage(null, spannable, null);
- }
-}
-
-void testMissingCloseParen() {
- final String source = '''foo(x { // <= missing closing ")"
- return x;
-}''';
- parse() {
- parseMember(source, reporter: new Collector());
- }
-
- check(exn) {
- Collector c = exn;
- Expect.equals(OPEN_CURLY_BRACKET_TOKEN, c.token);
- return true;
- }
-
- Expect.throws(parse, check);
-}
-
-void testMissingCloseBraceInClass() {
- final String source = 'class Foo {'; // Missing close '}'.
- parse() {
- fullParseUnit(source, reporter: new Collector());
- }
-
- check(exn) {
- Collector c = exn;
- Expect.equals(BAD_INPUT_TOKEN, c.token);
- return true;
- }
-
- Expect.throws(parse, check);
-}
-
-void main() {
- testGenericTypes();
- // TODO(ahe): Enable this test when we handle library prefixes.
- // testPrefixedGenericTypes();
- testUnaryExpression();
- testChainedMethodCalls();
- testFunctionStatement();
- testDoStatement();
- testWhileStatement();
- testConditionalExpression();
- testNullOperators();
- testAssignment();
- testIndex();
- testPostfix();
- testOperatorParse();
- testMissingCloseParen();
- testMissingCloseBraceInClass();
-}
diff --git a/tests/compiler/dart2js/old_frontend/part_of_test.dart b/tests/compiler/dart2js/old_frontend/part_of_test.dart
deleted file mode 100644
index 9c7bfee..0000000
--- a/tests/compiler/dart2js/old_frontend/part_of_test.dart
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2013, 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 part_of_test;
-
-import "package:expect/expect.dart";
-import "package:async_helper/async_helper.dart";
-import 'package:compiler/src/diagnostics/messages.dart' show MessageKind;
-import 'mock_compiler.dart';
-
-final libraryUri = Uri.parse('test:library.dart');
-const String LIBRARY_SOURCE = '''
-library foo;
-part 'part.dart';
-''';
-
-final partUri = Uri.parse('test:part.dart');
-const String PART_SOURCE = '''
-part of bar;
-''';
-
-void main() {
- MockCompiler compiler = new MockCompiler.internal();
- compiler.registerSource(libraryUri, LIBRARY_SOURCE);
- compiler.registerSource(partUri, PART_SOURCE);
-
- asyncTest(
- () => compiler.libraryLoader.loadLibrary(libraryUri).then((libraries) {
- compiler.processLoadedLibraries(libraries);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- print('errors: ${collector.errors}');
- print('warnings: ${collector.warnings}');
- Expect.isTrue(collector.errors.isEmpty);
- Expect.equals(1, collector.warnings.length);
- Expect.equals(MessageKind.LIBRARY_NAME_MISMATCH,
- collector.warnings.first.messageKind);
- Expect.equals(
- 'foo',
- collector.warnings.first.message.arguments['libraryName']
- .toString());
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/partial_parser_test.dart b/tests/compiler/dart2js/old_frontend/partial_parser_test.dart
deleted file mode 100644
index ec8f619..0000000
--- a/tests/compiler/dart2js/old_frontend/partial_parser_test.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2011, 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 "package:expect/expect.dart";
-import 'parser_helper.dart';
-
-void main() {
- testSkipExpression();
-}
-
-void testSkipExpression() {
- PartialParser parser = new PartialParser(new Listener());
- Token token = scan('a < b;');
- token = parser.skipExpression(parser.syntheticPreviousToken(token)).next;
- Expect.equals(';', token.lexeme);
-
- token = scan('[a < b]');
- token = parser.skipExpression(token).next;
- Expect.equals(']', token.lexeme);
-
- token = scan('a < b,');
- token = parser.skipExpression(parser.syntheticPreviousToken(token)).next;
- Expect.equals(',', token.lexeme);
-}
diff --git a/tests/compiler/dart2js/old_frontend/patch_test.dart b/tests/compiler/dart2js/old_frontend/patch_test.dart
deleted file mode 100644
index 2c8dbfd..0000000
--- a/tests/compiler/dart2js/old_frontend/patch_test.dart
+++ /dev/null
@@ -1,1068 +0,0 @@
-// Copyright (c) 2012, 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:async';
-import 'package:expect/expect.dart';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/compiler.dart';
-import 'package:compiler/src/diagnostics/messages.dart' show MessageKind;
-import 'package:compiler/src/elements/elements.dart';
-import 'package:compiler/src/elements/modelx.dart';
-import 'package:compiler/src/elements/names.dart';
-import 'package:compiler/src/tree/tree.dart';
-import 'package:compiler/src/types/types.dart';
-import 'package:compiler/src/universe/call_structure.dart' show CallStructure;
-import 'package:compiler/src/universe/selector.dart' show Selector;
-import 'package:compiler/src/world.dart';
-
-import 'mock_compiler.dart';
-import 'mock_libraries.dart';
-
-Future<Compiler> applyPatch(String script, String patch,
- {bool analyzeAll: false,
- bool analyzeOnly: false,
- bool runCompiler: false,
- String main: ""}) async {
- Map<String, String> core = <String, String>{'script': script};
- MockCompiler compiler = new MockCompiler.internal(
- coreSource: core, analyzeAll: analyzeAll, analyzeOnly: analyzeOnly);
- compiler.diagnosticHandler = createHandler(compiler, '');
- var uri = Uri.parse("patch:core");
- compiler.registerSource(uri, "$DEFAULT_PATCH_CORE_SOURCE\n$patch");
- if (runCompiler) {
- await compiler.run(null, main);
- } else {
- await compiler.init(main);
- }
- return compiler;
-}
-
-void expectHasBody(compiler, ElementX element) {
- dynamic node = element.parseNode(compiler.parsingContext);
- Expect.isNotNull(node, "Element isn't parseable, when a body was expected");
- Expect.isNotNull(node.body);
- // If the element has a body it is either a Block or a Return statement,
- // both with different begin and end tokens.
- Expect.isTrue(node.body is Block || node.body is Return);
- Expect.notEquals(node.body.getBeginToken(), node.body.getEndToken());
-}
-
-void expectHasNoBody(compiler, ElementX element) {
- dynamic node = element.parseNode(compiler.parsingContext);
- Expect.isNotNull(node, "Element isn't parseable, when a body was expected");
- Expect.isFalse(node.hasBody);
-}
-
-Element ensure(compiler, String name, Element lookup(String name),
- {bool expectIsPatched: false,
- bool expectIsPatch: false,
- bool checkHasBody: false,
- bool expectIsGetter: false,
- bool expectIsFound: true,
- bool expectIsRegular: false}) {
- dynamic element = lookup(name);
- if (!expectIsFound) {
- Expect.isNull(element);
- return element;
- }
- Expect.isNotNull(element);
- if (expectIsGetter) {
- Expect.isTrue(element is AbstractFieldElement);
- Expect.isNotNull(element.getter);
- element = element.getter;
- }
- Expect.equals(expectIsPatched, element.isPatched,
- 'Unexpected: $element.isPatched = ${element.isPatched}');
- if (expectIsPatched) {
- Expect.isNull(element.origin);
- Expect.isNotNull(element.patch);
-
- Expect.equals(element, element.declaration);
- Expect.equals(element.patch, element.implementation);
-
- if (checkHasBody) {
- expectHasNoBody(compiler, element);
- expectHasBody(compiler, element.patch);
- }
- } else {
- Expect.isTrue(element.isImplementation);
- }
- Expect.equals(expectIsPatch, element.isPatch);
- if (expectIsPatch) {
- Expect.isNotNull(element.origin);
- Expect.isNull(element.patch);
-
- Expect.equals(element.origin, element.declaration);
- Expect.equals(element, element.implementation);
-
- if (checkHasBody) {
- expectHasBody(compiler, element);
- expectHasNoBody(compiler, element.origin);
- }
- } else {
- Expect.isTrue(element.isDeclaration);
- }
- if (expectIsRegular) {
- Expect.isNull(element.origin);
- Expect.isNull(element.patch);
-
- Expect.equals(element, element.declaration);
- Expect.equals(element, element.implementation);
-
- if (checkHasBody) {
- expectHasBody(compiler, element);
- }
- }
- Expect.isFalse(element.isPatched && element.isPatch);
- return element;
-}
-
-Future testPatchFunction() async {
- dynamic compiler = await applyPatch(
- "external test();", "@patch test() { return 'string'; } ");
- ensure(compiler, "test", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true, checkHasBody: true);
- ensure(compiler, "test",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true, checkHasBody: true);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.isTrue(
- collector.errors.isEmpty, "Unexpected errors: ${collector.errors}");
-}
-
-Future testPatchFunctionMetadata() async {
- dynamic compiler = await applyPatch("""
- const a = 0;
- @a external test();
- """, """
- const _b = 1;
- @patch @_b test() {}
- """);
- Element origin = ensure(
- compiler, "test", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true, checkHasBody: true);
- Element patch = ensure(compiler, "test",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true, checkHasBody: true);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.isTrue(
- collector.errors.isEmpty, "Unexpected errors: ${collector.errors}");
-
- Expect.equals(1, origin.metadata.length,
- "Unexpected origin metadata: ${origin.metadata}.");
- Expect.equals(3, patch.metadata.length,
- "Unexpected patch metadata: ${patch.metadata}.");
-}
-
-Future testPatchFunctionGeneric() async {
- dynamic compiler = await applyPatch(
- "external T test<T>();", "@patch T test<T>() { return null; } ");
- Element origin = ensure(
- compiler, "test", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true, checkHasBody: true);
- ensure(compiler, "test",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true, checkHasBody: true);
- compiler.resolver.resolve(origin);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.isTrue(
- collector.errors.isEmpty, "Unexpected errors: ${collector.errors}");
-}
-
-Future testPatchFunctionGenericExtraTypeVariable() async {
- dynamic compiler = await applyPatch(
- "external T test<T>();", "@patch T test<T, S>() { return null; } ");
- Element origin = ensure(
- compiler, "test", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true, checkHasBody: true);
- ensure(compiler, "test",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true, checkHasBody: true);
- compiler.resolver.resolve(origin);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(collector.errors.first.message.kind ==
- MessageKind.PATCH_TYPE_VARIABLES_MISMATCH);
-}
-
-Future testPatchFunctionGenericDifferentNames() async {
- dynamic compiler = await applyPatch(
- "external T test<T, S>();", "@patch T test<S, T>() { return null; } ");
- Element origin = ensure(
- compiler, "test", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true, checkHasBody: true);
- ensure(compiler, "test",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true, checkHasBody: true);
- compiler.resolver.resolve(origin);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(collector.errors.first.message.kind ==
- MessageKind.PATCH_TYPE_VARIABLES_MISMATCH);
-}
-
-Future testPatchConstructor() async {
- dynamic compiler = await applyPatch("""
- class Class {
- external Class();
- }
- """, """
- @patch class Class {
- @patch Class();
- }
- """);
- dynamic classOrigin = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- classOrigin.ensureResolved(compiler.resolution);
- dynamic classPatch = ensure(compiler, "Class",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true);
-
- Expect.equals(classPatch, classOrigin.patch);
- Expect.equals(classOrigin, classPatch.origin);
-
- dynamic constructorOrigin = ensure(
- compiler, "", (name) => classOrigin.localLookup(name),
- expectIsPatched: true);
- dynamic constructorPatch = ensure(
- compiler, "", (name) => classPatch.localLookup(name),
- expectIsPatch: true);
-
- Expect.equals(constructorPatch, constructorOrigin.patch);
- Expect.equals(constructorOrigin, constructorPatch.origin);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.isTrue(
- collector.errors.isEmpty, "Unexpected errors: ${collector.errors}");
-}
-
-Future testPatchRedirectingConstructor() async {
- dynamic compiler = await applyPatch("""
- class Class {
- Class(x) : this._(x, false);
-
- external Class._(x, y);
- }
- """, r"""
- @patch class Class {
- @patch Class._(x, y) { print('$x,$y'); }
- }
- """);
- dynamic classOrigin = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- classOrigin.ensureResolved(compiler.resolution);
-
- dynamic classPatch = ensure(compiler, "Class",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true);
-
- Expect.equals(classOrigin, classPatch.origin);
- Expect.equals(classPatch, classOrigin.patch);
-
- dynamic constructorRedirecting =
- ensure(compiler, "", (name) => classOrigin.localLookup(name));
- dynamic constructorOrigin = ensure(
- compiler, "_", (name) => classOrigin.localLookup(name),
- expectIsPatched: true);
- dynamic constructorPatch = ensure(
- compiler, "_", (name) => classPatch.localLookup(name),
- expectIsPatch: true);
- Expect.equals(constructorOrigin, constructorPatch.origin);
- Expect.equals(constructorPatch, constructorOrigin.patch);
-
- compiler.resolver.resolve(constructorRedirecting);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.isTrue(
- collector.errors.isEmpty, "Unexpected errors: ${collector.errors}");
-}
-
-Future testPatchMember() async {
- dynamic compiler = await applyPatch("""
- class Class {
- external String toString();
- }
- """, """
- @patch class Class {
- @patch String toString() => 'string';
- }
- """);
- dynamic container = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- container.parseNode(compiler.parsingContext);
- ensure(compiler, "Class",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true);
-
- ensure(compiler, "toString", container.lookupLocalMember,
- expectIsPatched: true, checkHasBody: true);
- ensure(compiler, "toString", container.patch.lookupLocalMember,
- expectIsPatch: true, checkHasBody: true);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.isTrue(
- collector.errors.isEmpty, "Unexpected errors: ${collector.errors}");
-}
-
-Future testPatchGetter() async {
- dynamic compiler = await applyPatch("""
- class Class {
- external int get field;
- }
- """, """
- @patch class Class {
- @patch int get field => 5;
- }
- """);
- dynamic container = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- container.parseNode(compiler.parsingContext);
- ensure(compiler, "field", container.lookupLocalMember,
- expectIsGetter: true, expectIsPatched: true, checkHasBody: true);
- ensure(compiler, "field", container.patch.lookupLocalMember,
- expectIsGetter: true, expectIsPatch: true, checkHasBody: true);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.isTrue(
- collector.errors.isEmpty, "Unexpected errors: ${collector.errors}");
-}
-
-Future testRegularMember() async {
- dynamic compiler = await applyPatch("""
- class Class {
- void regular() {}
- }
- """, """
- @patch class Class {
- }
- """);
- dynamic container = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- container.parseNode(compiler.parsingContext);
- ensure(compiler, "Class",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true);
-
- ensure(compiler, "regular", container.lookupLocalMember,
- checkHasBody: true, expectIsRegular: true);
- ensure(compiler, "regular", container.patch.lookupLocalMember,
- checkHasBody: true, expectIsRegular: true);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.isTrue(
- collector.errors.isEmpty, "Unexpected errors: ${collector.errors}");
-}
-
-Future testInjectedMember() async {
- dynamic compiler = await applyPatch("""
- class Class {
- }
- """, """
- @patch class Class {
- void _injected() {}
- }
- """);
- dynamic container = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- container.parseNode(compiler.parsingContext);
- ensure(compiler, "Class",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true);
-
- ensure(compiler, "_injected", container.lookupLocalMember,
- expectIsFound: false);
- ensure(compiler, "_injected", container.patch.lookupLocalMember,
- checkHasBody: true, expectIsRegular: true);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.isTrue(
- collector.errors.isEmpty, "Unexpected errors: ${collector.errors}");
-}
-
-Future testInjectedPublicMember() async {
- dynamic compiler = await applyPatch("""
- class Class {
- }
- """, """
- @patch class Class {
- void injected() {}
- }
- """);
- dynamic container = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- container.parseNode(compiler.parsingContext);
- ensure(compiler, "Class",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- expectIsPatch: true);
-
- ensure(compiler, "injected", container.lookupLocalMember,
- expectIsFound: false);
- ensure(compiler, "injected", container.patch.lookupLocalMember,
- checkHasBody: true, expectIsRegular: true);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.equals(
- 1, collector.errors.length, "Unexpected errors: ${collector.errors}");
- Expect.isTrue(collector.errors.first.message.kind ==
- MessageKind.INJECTED_PUBLIC_MEMBER);
-}
-
-Future testInjectedFunction() async {
- dynamic compiler = await applyPatch("", "int _function() => 5;");
- ensure(compiler, "_function",
- compiler.resolution.commonElements.coreLibrary.find,
- expectIsFound: false);
- ensure(compiler, "_function",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- checkHasBody: true, expectIsRegular: true);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.isTrue(
- collector.errors.isEmpty, "Unexpected errors: ${collector.errors}");
-}
-
-Future testInjectedPublicFunction() async {
- dynamic compiler = await applyPatch("", "int function() => 5;");
- ensure(
- compiler, "function", compiler.resolution.commonElements.coreLibrary.find,
- expectIsFound: false);
- ensure(compiler, "function",
- compiler.resolution.commonElements.coreLibrary.patch.find,
- checkHasBody: true, expectIsRegular: true);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- Expect.equals(
- 1, collector.errors.length, "Unexpected errors: ${collector.errors}");
- Expect.isTrue(collector.errors.first.message.kind ==
- MessageKind.INJECTED_PUBLIC_MEMBER);
-}
-
-Future testPatchSignatureCheck() async {
- dynamic compiler = await applyPatch("""
- class Class {
- external String method1();
- external void method2(String str);
- external void method3(String s1);
- external void method4([String str]);
- external void method5({String str});
- external void method6({String str});
- external void method7([String s1]);
- external void method8({String s1});
- external void method9(String str);
- external void method10([String str]);
- external void method11({String str});
- }
- """, """
- @patch class Class {
- @patch int method1() => 0;
- @patch void method2() {}
- @patch void method3(String s2) {}
- @patch void method4([String str, int i]) {}
- @patch void method5() {}
- @patch void method6([String str]) {}
- @patch void method7([String s2]) {}
- @patch void method8({String s2}) {}
- @patch void method9(int str) {}
- @patch void method10([int str]) {}
- @patch void method11({int str}) {}
- }
- """);
- dynamic container = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- container.ensureResolved(compiler.resolution);
- container.parseNode(compiler.parsingContext);
- DiagnosticCollector collector = compiler.diagnosticCollector;
-
- void expect(String methodName, List infos, List errors) {
- collector.clear();
- compiler.resolver.resolveMethodElement(ensure(
- compiler, methodName, container.lookupLocalMember,
- expectIsPatched: true, checkHasBody: true));
- Expect.equals(0, collector.warnings.length);
- Expect.equals(infos.length, collector.infos.length,
- "Unexpected infos: ${collector.infos} on $methodName");
- for (int i = 0; i < infos.length; i++) {
- Expect.equals(infos[i], collector.infos.elementAt(i).message.kind);
- }
- Expect.equals(errors.length, collector.errors.length,
- "Unexpected errors: ${collector.errors} on $methodName");
- for (int i = 0; i < errors.length; i++) {
- Expect.equals(errors[i], collector.errors.elementAt(i).message.kind);
- }
- }
-
- expect("method1", [], [MessageKind.PATCH_RETURN_TYPE_MISMATCH]);
- expect("method2", [], [MessageKind.PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH]);
- expect("method3", [MessageKind.PATCH_POINT_TO_PARAMETER],
- [MessageKind.PATCH_PARAMETER_MISMATCH]);
- expect("method4", [], [MessageKind.PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH]);
- expect("method5", [], [MessageKind.PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH]);
- expect("method6", [], [MessageKind.PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH]);
- expect("method7", [MessageKind.PATCH_POINT_TO_PARAMETER],
- [MessageKind.PATCH_PARAMETER_MISMATCH]);
- expect("method8", [MessageKind.PATCH_POINT_TO_PARAMETER],
- [MessageKind.PATCH_PARAMETER_MISMATCH]);
- expect("method9", [MessageKind.PATCH_POINT_TO_PARAMETER],
- [MessageKind.PATCH_PARAMETER_TYPE_MISMATCH]);
- expect("method10", [MessageKind.PATCH_POINT_TO_PARAMETER],
- [MessageKind.PATCH_PARAMETER_TYPE_MISMATCH]);
- expect("method11", [MessageKind.PATCH_POINT_TO_PARAMETER],
- [MessageKind.PATCH_PARAMETER_TYPE_MISMATCH]);
-}
-
-Future testExternalWithoutImplementationTopLevel() async {
- dynamic compiler = await applyPatch("""
- external void foo();
- """, """
- // @patch void foo() {}
- """);
- dynamic function = ensure(
- compiler, "foo", compiler.resolution.commonElements.coreLibrary.find);
- compiler.resolver.resolve(function);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- print('testExternalWithoutImplementationTopLevel:${collector.errors}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(collector.errors.first.message.kind ==
- MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION);
- Expect.stringEquals('External method without an implementation.',
- collector.errors.first.message.toString());
-}
-
-Future testExternalWithoutImplementationMember() async {
- dynamic compiler = await applyPatch("""
- class Class {
- external void foo();
- }
- """, """
- @patch class Class {
- // @patch void foo() {}
- }
- """);
- dynamic container = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- container.parseNode(compiler.parsingContext);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- collector.clear();
- compiler.resolver.resolveMethodElement(
- ensure(compiler, "foo", container.lookupLocalMember));
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- print('testExternalWithoutImplementationMember:${collector.errors}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(collector.errors.first.message.kind ==
- MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION);
- Expect.stringEquals('External method without an implementation.',
- collector.errors.first.message.toString());
-}
-
-Future testIsSubclass() async {
- dynamic compiler = await applyPatch("""
- class A {}
- """, """
- @patch class A {}
- """);
- ClassElement cls = ensure(
- compiler, "A", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- ClassElement patch = cls.patch;
- Expect.isTrue(cls != patch);
- Expect.isTrue(cls.isSubclassOf(patch));
- Expect.isTrue(patch.isSubclassOf(cls));
-}
-
-Future testPatchNonExistingTopLevel() async {
- dynamic compiler = await applyPatch("""
- // class Class {}
- """, """
- @patch class Class {}
- """);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- print('testPatchNonExistingTopLevel:${collector.errors}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NON_EXISTING);
-}
-
-Future testPatchNonExistingMember() async {
- dynamic compiler = await applyPatch("""
- class Class {}
- """, """
- @patch class Class {
- @patch void foo() {}
- }
- """);
- dynamic container = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- container.parseNode(compiler.parsingContext);
- DiagnosticCollector collector = compiler.diagnosticCollector;
-
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- print('testPatchNonExistingMember:${collector.errors}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NON_EXISTING);
-}
-
-Future testPatchNonPatchablePatch() async {
- dynamic compiler = await applyPatch("""
- external get foo;
- """, """
- @patch var foo;
- """);
- ensure(compiler, "foo", compiler.resolution.commonElements.coreLibrary.find);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- print('testPatchNonPatchablePatch:${collector.errors}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NONPATCHABLE);
-}
-
-Future testPatchNonPatchableOrigin() async {
- dynamic compiler = await applyPatch("""
- external var foo;
- """, """
- @patch get foo => 0;
- """);
- ensure(compiler, "foo", compiler.resolution.commonElements.coreLibrary.find);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isTrue(
- collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}");
- print('testPatchNonPatchableOrigin:${collector.errors}');
- Expect.equals(2, collector.errors.length);
- Expect.equals(
- MessageKind.EXTRANEOUS_MODIFIER, collector.errors.first.message.kind);
- Expect.equals(
- // TODO(ahe): Eventually, this error should be removed as it will be
- // handled by the regular parser.
- MessageKind.PATCH_NONPATCHABLE,
- collector.errors.elementAt(1).message.kind);
-}
-
-Future testPatchNonExternalTopLevel() async {
- dynamic compiler = await applyPatch("""
- void foo() {}
- """, """
- @patch void foo() {}
- """);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- print('testPatchNonExternalTopLevel.errors:${collector.errors}');
- print('testPatchNonExternalTopLevel.warnings:${collector.warnings}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NON_EXTERNAL);
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.infos.length);
- Expect.isTrue(collector.infos.first.message.kind ==
- MessageKind.PATCH_POINT_TO_FUNCTION);
-}
-
-Future testPatchNonExternalMember() async {
- dynamic compiler = await applyPatch("""
- class Class {
- void foo() {}
- }
- """, """
- @patch class Class {
- @patch void foo() {}
- }
- """);
- dynamic container = ensure(
- compiler, "Class", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- container.parseNode(compiler.parsingContext);
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- print('testPatchNonExternalMember.errors:${collector.errors}');
- print('testPatchNonExternalMember.warnings:${collector.warnings}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NON_EXTERNAL);
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.infos.length);
- Expect.isTrue(collector.infos.first.message.kind ==
- MessageKind.PATCH_POINT_TO_FUNCTION);
-}
-
-Future testPatchNonClass() async {
- dynamic compiler = await applyPatch("""
- external void Class() {}
- """, """
- @patch class Class {}
- """);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- print('testPatchNonClass.errors:${collector.errors}');
- print('testPatchNonClass.warnings:${collector.warnings}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NON_CLASS);
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.infos.length);
- Expect.isTrue(
- collector.infos.first.message.kind == MessageKind.PATCH_POINT_TO_CLASS);
-}
-
-Future testPatchNonGetter() async {
- dynamic compiler = await applyPatch("""
- external void foo() {}
- """, """
- @patch get foo => 0;
- """);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- print('testPatchNonClass.errors:${collector.errors}');
- print('testPatchNonClass.warnings:${collector.warnings}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NON_GETTER);
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.infos.length);
- Expect.isTrue(
- collector.infos.first.message.kind == MessageKind.PATCH_POINT_TO_GETTER);
-}
-
-Future testPatchNoGetter() async {
- dynamic compiler = await applyPatch("""
- external set foo(var value) {}
- """, """
- @patch get foo => 0;
- """);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- print('testPatchNonClass.errors:${collector.errors}');
- print('testPatchNonClass.warnings:${collector.warnings}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NO_GETTER);
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.infos.length);
- Expect.isTrue(
- collector.infos.first.message.kind == MessageKind.PATCH_POINT_TO_GETTER);
-}
-
-Future testPatchNonSetter() async {
- dynamic compiler = await applyPatch("""
- external void foo() {}
- """, """
- @patch set foo(var value) {}
- """);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- print('testPatchNonClass.errors:${collector.errors}');
- print('testPatchNonClass.warnings:${collector.warnings}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NON_SETTER);
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.infos.length);
- Expect.isTrue(
- collector.infos.first.message.kind == MessageKind.PATCH_POINT_TO_SETTER);
-}
-
-Future testPatchNoSetter() async {
- dynamic compiler = await applyPatch("""
- external get foo;
- """, """
- @patch set foo(var value) {}
- """);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- print('testPatchNonClass.errors:${collector.errors}');
- print('testPatchNonClass.warnings:${collector.warnings}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NO_SETTER);
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.infos.length);
- Expect.isTrue(
- collector.infos.first.message.kind == MessageKind.PATCH_POINT_TO_SETTER);
-}
-
-Future testPatchNonFunction() async {
- dynamic compiler = await applyPatch("""
- external get foo;
- """, """
- @patch void foo() {}
- """);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- print('testPatchNonClass.errors:${collector.errors}');
- print('testPatchNonClass.warnings:${collector.warnings}');
- Expect.equals(1, collector.errors.length);
- Expect.isTrue(
- collector.errors.first.message.kind == MessageKind.PATCH_NON_FUNCTION);
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.infos.length);
- Expect.isTrue(collector.infos.first.message.kind ==
- MessageKind.PATCH_POINT_TO_FUNCTION);
-}
-
-Future testPatchAndSelector() async {
- dynamic compiler = await applyPatch("""
- class A {
- external void clear();
- }
- class B extends A {
- }
- """, """
- @patch class A {
- int method() => 0;
- @patch void clear() {}
- }
- """, main: """
- main () {
- new A(); // ensure A and B are instantiated
- new B();
- }
- """, runCompiler: true, analyzeOnly: true);
- compiler.closeResolution(
- compiler.frontendStrategy.elementEnvironment.mainFunction);
- ClosedWorld world = compiler.resolutionWorldBuilder.closedWorldForTesting;
-
- ClassElement cls = ensure(
- compiler, "A", compiler.resolution.commonElements.coreLibrary.find,
- expectIsPatched: true);
- cls.ensureResolved(compiler.resolution);
-
- ensure(compiler, "method", cls.patch.lookupLocalMember,
- checkHasBody: true, expectIsRegular: true);
-
- ensure(compiler, "clear", cls.lookupLocalMember,
- checkHasBody: true, expectIsPatched: true);
-
- compiler.phase = Compiler.PHASE_DONE_RESOLVING;
-
- // Check that a method just in the patch class is a target for a
- // typed selector.
- Selector selector =
- new Selector.call(const PublicName('method'), CallStructure.NO_ARGS);
- TypeMask typeMask = new TypeMask.exact(cls, world);
- MethodElement method = cls.implementation.lookupLocalMember('method');
- method.computeType(compiler.resolution);
- Expect.isTrue(selector.applies(method));
- Expect.isTrue(typeMask.canHit(method, selector, world));
-
- // Check that the declaration method in the declaration class is a target
- // for a typed selector.
- selector =
- new Selector.call(const PublicName('clear'), CallStructure.NO_ARGS);
- typeMask = new TypeMask.exact(cls, world);
- method = cls.lookupLocalMember('clear');
- method.computeType(compiler.resolution);
- Expect.isTrue(selector.applies(method));
- Expect.isTrue(typeMask.canHit(method, selector, world));
-
- // Check that the declaration method in the declaration class is a target
- // for a typed selector on a subclass.
- cls = ensure(
- compiler, "B", compiler.resolution.commonElements.coreLibrary.find);
- cls.ensureResolved(compiler.resolution);
- typeMask = new TypeMask.exact(cls, world);
- Expect.isTrue(selector.applies(method));
- Expect.isTrue(typeMask.canHit(method, selector, world));
-}
-
-Future testAnalyzeAllInjectedMembers() async {
- Future expect(String patchText, [expectedWarnings]) async {
- if (expectedWarnings == null) expectedWarnings = [];
- if (expectedWarnings is! List) {
- expectedWarnings = <MessageKind>[expectedWarnings];
- }
-
- dynamic compiler =
- await applyPatch('', patchText, analyzeAll: true, analyzeOnly: true);
- compiler.librariesToAnalyzeWhenRun = [Uri.parse('dart:core')];
- await compiler.run(null);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- compareWarningKinds(patchText, expectedWarnings, collector.warnings);
- }
-
- await expect('String s = 0;', MessageKind.NOT_ASSIGNABLE);
- await expect('void method() { String s = 0; }', MessageKind.NOT_ASSIGNABLE);
- await expect('''
- class Class {
- String s = 0;
- }
- ''', MessageKind.NOT_ASSIGNABLE);
- await expect('''
- class Class {
- void method() {
- String s = 0;
- }
- }
- ''', MessageKind.NOT_ASSIGNABLE);
-}
-
-Future testEffectiveTarget() async {
- String origin = """
- class A {
- A() : super();
- factory A.forward() = B.patchTarget;
- factory A.forwardOne() = B.patchFactory;
- factory A.forwardTwo() = B.reflectBack;
- factory A.forwardThree() = B.patchInjected;
- }
- class B extends A {
- B() : super();
- external B.patchTarget();
- external factory B.patchFactory();
- external factory B.reflectBack();
- B.originTarget() : super();
- external factory B.patchInjected();
- }
- """;
- String patch = """
- @patch class B {
- @patch
- B.patchTarget() : super();
- @patch
- factory B.patchFactory() => new B.patchTarget();
- @patch
- factory B.reflectBack() = B.originTarget;
- @patch
- factory B.patchInjected() = _C.injected;
- }
- class _C extends B {
- _C.injected() : super.patchTarget();
- }
- """;
-
- dynamic compiler = await applyPatch(origin, patch,
- analyzeAll: true, analyzeOnly: true, runCompiler: true);
- ClassElement clsA = compiler.resolution.commonElements.coreLibrary.find("A");
- ClassElement clsB = compiler.resolution.commonElements.coreLibrary.find("B");
- Expect.isNotNull(clsB);
-
- ConstructorElement forward = clsA.lookupConstructor("forward");
- ConstructorElement target = forward.effectiveTarget;
- Expect.isTrue(target.isPatched, "Unexpected target $target for $forward");
- Expect.isFalse(target.isPatch, "Unexpected target $target for $forward");
- Expect.equals("patchTarget", target.name);
-
- ConstructorElement forwardOne = clsA.lookupConstructor("forwardOne");
- target = forwardOne.effectiveTarget;
- Expect.isFalse(forwardOne.isMalformed);
- Expect.isFalse(target.isPatch, "Unexpected target $target for $forwardOne");
- Expect.equals("patchFactory", target.name);
-
- ConstructorElement forwardTwo = clsA.lookupConstructor("forwardTwo");
- target = forwardTwo.effectiveTarget;
- Expect.isFalse(forwardTwo.isMalformed);
- Expect.isFalse(target.isPatch, "Unexpected target $target for $forwardTwo");
- Expect.equals("originTarget", target.name);
-
- ConstructorElement forwardThree = clsA.lookupConstructor("forwardThree");
- target = forwardThree.effectiveTarget;
- Expect.isFalse(forwardThree.isMalformed);
- Expect.isTrue(
- target.isInjected, "Unexpected target $target for $forwardThree");
- Expect.equals("injected", target.name);
-}
-
-Future testTypecheckPatchedMembers() async {
- String originText = "external void method();";
- String patchText = """
- @patch void method() {
- String s = 0;
- }
- """;
- dynamic compiler = await applyPatch(originText, patchText,
- analyzeAll: true, analyzeOnly: true);
- compiler.librariesToAnalyzeWhenRun = [Uri.parse('dart:core')];
- await compiler.run(null);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- compareWarningKinds(
- patchText, [MessageKind.NOT_ASSIGNABLE], collector.warnings);
-}
-
-main() {
- asyncTest(() async {
- await testPatchConstructor();
- await testPatchRedirectingConstructor();
- await testPatchFunction();
- await testPatchFunctionMetadata();
- await testPatchFunctionGeneric();
- await testPatchFunctionGenericExtraTypeVariable();
- await testPatchFunctionGenericDifferentNames();
- await testPatchMember();
- await testPatchGetter();
- await testRegularMember();
- await testInjectedMember();
- await testInjectedPublicMember();
- await testInjectedFunction();
- await testInjectedPublicFunction();
- await testPatchSignatureCheck();
-
- await testExternalWithoutImplementationTopLevel();
- await testExternalWithoutImplementationMember();
-
- await testIsSubclass();
-
- await testPatchNonExistingTopLevel();
- await testPatchNonExistingMember();
- await testPatchNonPatchablePatch();
- await testPatchNonPatchableOrigin();
- await testPatchNonExternalTopLevel();
- await testPatchNonExternalMember();
- await testPatchNonClass();
- await testPatchNonGetter();
- await testPatchNoGetter();
- await testPatchNonSetter();
- await testPatchNoSetter();
- await testPatchNonFunction();
-
- await testPatchAndSelector();
-
- await testEffectiveTarget();
-
- await testAnalyzeAllInjectedMembers();
- await testTypecheckPatchedMembers();
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/platform_consistency_test.dart b/tests/compiler/dart2js/old_frontend/platform_consistency_test.dart
deleted file mode 100644
index 59b257c..0000000
--- a/tests/compiler/dart2js/old_frontend/platform_consistency_test.dart
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE.md file.
-
-import "package:compiler/src/platform_configuration.dart";
-import "package:compiler/src/source_file_provider.dart";
-import "package:compiler/compiler_new.dart";
-import "package:expect/expect.dart";
-
-main() async {
- CompilerInput input = new CompilerSourceFileProvider();
- Map<String, Uri> client =
- await load(Uri.base.resolve("sdk/lib/dart_client.platform"), input);
- Map<String, Uri> server =
- await load(Uri.base.resolve("sdk/lib/dart_server.platform"), input);
- Map<String, Uri> shared =
- await load(Uri.base.resolve("sdk/lib/dart_shared.platform"), input);
- Expect.setEquals(new Set.from(shared.keys), new Set.from(client.keys));
- Expect.setEquals(new Set.from(shared.keys), new Set.from(server.keys));
-
- for (String libraryName in shared.keys) {
- test(Map<String, Uri> m) {
- if (m[libraryName].scheme != 'unsupported' &&
- shared[libraryName].scheme != 'unsupported') {
- Expect.equals(shared[libraryName], m[libraryName]);
- }
- }
-
- test(client);
- test(server);
- }
-}
diff --git a/tests/compiler/dart2js/old_frontend/private_test.dart b/tests/compiler/dart2js/old_frontend/private_test.dart
deleted file mode 100644
index 569485d..0000000
--- a/tests/compiler/dart2js/old_frontend/private_test.dart
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright (c) 2012, 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:async';
-
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/diagnostics/messages.dart' show MessageKind;
-import 'package:compiler/src/io/source_file.dart';
-import 'package:compiler/src/old_to_new_api.dart';
-
-import 'mock_compiler.dart';
-
-const String PRIVATE_SOURCE_URI = 'src:private';
-const String PRIVATE_SOURCE = '''
-
-var _privateVariable;
-void _privateFunction() {}
-
-class _PrivateClass {
- _PrivateClass();
- _PrivateClass.publicConstructor();
- _PrivateClass._privateConstructor();
-
- var _privateField;
- get _privateGetter => null;
- void set _privateSetter(var value) {}
- void _privateMethod() {}
-
- var publicField;
- get publicGetter => null;
- void set publicSetter(var value) {}
- void publicMethod() {}
-}
-
-class PublicClass extends _PrivateClass {
- PublicClass() : super();
- PublicClass.publicConstructor() : super.publicConstructor();
- PublicClass._privateConstructor() : super._privateConstructor();
-
- _PrivateClass get private => this;
-}
-''';
-
-analyze(String text, [expectedWarnings]) {
- return () {
- if (expectedWarnings == null) expectedWarnings = [];
- if (expectedWarnings is! List) expectedWarnings = [expectedWarnings];
-
- MockCompiler compiler = new MockCompiler.internal(analyzeOnly: true);
- compiler.registerSource(Uri.parse(PRIVATE_SOURCE_URI), PRIVATE_SOURCE);
- compiler.diagnosticHandler = new LegacyCompilerDiagnostics(
- (uri, int begin, int end, String message, kind) {
- SourceFile sourceFile = compiler.sourceFiles[uri.toString()];
- if (sourceFile != null) {
- print(sourceFile.getLocationMessage(message, begin, end));
- } else {
- print(message);
- }
- });
-
- String source = '''
- library public;
-
- import '$PRIVATE_SOURCE_URI';
-
- void main() {
- PublicClass publicClass;
- $text
- }
- ''';
- Uri uri = Uri.parse('src:public');
- compiler.registerSource(uri, source);
- return compiler.run(uri).then((_) {
- DiagnosticCollector collector = compiler.diagnosticCollector;
- compareWarningKinds(text, expectedWarnings, collector.warnings);
- });
- };
-}
-
-void main() {
- asyncTest(() => Future.forEach([
- // Read from private variable.
- analyze('var value = _privateVariable;', MessageKind.CANNOT_RESOLVE),
- // Write to private variable.
- analyze('_privateVariable = 0;', MessageKind.CANNOT_RESOLVE),
- // Access private function.
- analyze('var value = _privateFunction;', MessageKind.CANNOT_RESOLVE),
- // Call private function.
- analyze('_privateFunction();', MessageKind.CANNOT_RESOLVE),
-
- // Call unnamed (public) constructor on private class.
- analyze('new _PrivateClass();', MessageKind.CANNOT_RESOLVE),
- // Call public constructor on private class.
- analyze('new _PrivateClass.publicConstructor();',
- MessageKind.CANNOT_RESOLVE),
- // Call private constructor on private class.
- analyze('new _PrivateClass._privateConstructor();',
- MessageKind.CANNOT_RESOLVE),
- // Call public getter of private type.
- analyze('var value = publicClass.private;'),
- // Read from private field on private class.
- analyze('var value = publicClass.private._privateField;',
- MessageKind.PRIVATE_ACCESS),
- // Write to private field on private class.
- analyze('publicClass.private._privateField = 0;',
- MessageKind.PRIVATE_ACCESS),
- // Call private getter on private class.
- analyze('var value = publicClass.private._privateGetter;',
- MessageKind.PRIVATE_ACCESS),
- // Call private setter on private class.
- analyze('publicClass.private._privateSetter = 0;',
- MessageKind.PRIVATE_ACCESS),
- // Access private method on private class.
- analyze('var value = publicClass.private._privateMethod;',
- MessageKind.PRIVATE_ACCESS),
- // Call private method on private class.
- analyze('publicClass.private._privateMethod();',
- MessageKind.PRIVATE_ACCESS),
-
- // Read from public field on private class.
- analyze('var value = publicClass.private.publicField;'),
- // Write to public field on private class.
- analyze('publicClass.private.publicField = 0;'),
- // Call public getter on private class.
- analyze('var value = publicClass.private.publicGetter;'),
- // Call public setter on private class.
- analyze('publicClass.private.publicSetter = 0;'),
- // Access public method on private class.
- analyze('var value = publicClass.private.publicMethod;'),
- // Call public method on private class.
- analyze('publicClass.private.publicMethod();'),
-
- // Call unnamed (public) constructor on public class.
- analyze('publicClass = new PublicClass();'),
- // Call public constructor on public class.
- analyze('publicClass = new PublicClass.publicConstructor();'),
- // Call private constructor on public class.
- analyze('publicClass = new PublicClass._privateConstructor();',
- MessageKind.CANNOT_FIND_CONSTRUCTOR),
- // Read from private field on public class.
- analyze('var value = publicClass._privateField;',
- MessageKind.PRIVATE_ACCESS),
- // Write to private field on public class.
- analyze('publicClass._privateField = 0;', MessageKind.PRIVATE_ACCESS),
- // Call private getter on public class.
- analyze('var value = publicClass._privateGetter;',
- MessageKind.PRIVATE_ACCESS),
- // Call private setter on public class.
- analyze('publicClass._privateSetter = 0;', MessageKind.PRIVATE_ACCESS),
- // Access private method on public class.
- analyze('var value = publicClass._privateMethod;',
- MessageKind.PRIVATE_ACCESS),
- // Call private method on public class.
- analyze('publicClass._privateMethod();', MessageKind.PRIVATE_ACCESS),
-
- // Read from public field on public class.
- analyze('var value = publicClass.publicField;'),
- // Write to public field on public class.
- analyze('publicClass.publicField = 0;'),
- // Call public getter on public class.
- analyze('var value = publicClass.publicGetter;'),
- // Call public setter on public class.
- analyze('publicClass.publicSetter = 0;'),
- // Access public method on public class.
- analyze('var value = publicClass.publicMethod;'),
- // Call public method on public class.
- analyze('publicClass.publicMethod();'),
- ], (f) => f()));
-}
diff --git a/tests/compiler/dart2js/old_frontend/proxy_test.dart b/tests/compiler/dart2js/old_frontend/proxy_test.dart
deleted file mode 100644
index 0131db9..0000000
--- a/tests/compiler/dart2js/old_frontend/proxy_test.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that dart2js produces the expected static type warnings for proxy
-// language tests. This ensures that the analyzer and dart2js agrees on these
-// tests.
-
-import 'warnings_checker.dart';
-
-/// Map from test files to a map of their expected status. If the status map is
-/// `null` no warnings must be missing or unexpected, otherwise the status map
-/// can contain a list of line numbers for keys 'missing' and 'unexpected' for
-/// the warnings of each category.
-const Map<String, dynamic> TESTS = const {
- 'language/proxy_test.dart': null,
- 'language/proxy2_test.dart': null,
- 'language/proxy3_test.dart': null,
- 'language/proxy4_test.dart': null,
- 'language/proxy5_test.dart': null,
-};
-
-void main(List<String> args) {
- checkWarnings(TESTS, args);
-}
diff --git a/tests/compiler/dart2js/old_frontend/reexport_handled_test.dart b/tests/compiler/dart2js/old_frontend/reexport_handled_test.dart
deleted file mode 100644
index c8c0ad4..0000000
--- a/tests/compiler/dart2js/old_frontend/reexport_handled_test.dart
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2013, 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 reexport_handled_test;
-
-import "package:expect/expect.dart";
-import "package:async_helper/async_helper.dart";
-import 'package:compiler/src/elements/elements.dart' show LibraryElement;
-import 'mock_compiler.dart';
-
-final exportingLibraryUri = Uri.parse('exporting.dart');
-const String EXPORTING_LIBRARY_SOURCE = '''
-library exporting;
-var foo;
-''';
-
-final reexportingLibraryUri = Uri.parse('reexporting.dart');
-const String REEXPORTING_LIBRARY_SOURCE = '''
-library reexporting;
-export 'exporting.dart';
-''';
-
-void main() {
- MockCompiler compiler;
- asyncTest(() => MockCompiler.create((MockCompiler c) {
- compiler = c;
- compiler.registerSource(exportingLibraryUri, EXPORTING_LIBRARY_SOURCE);
- compiler.registerSource(
- reexportingLibraryUri, REEXPORTING_LIBRARY_SOURCE);
- return compiler.libraryLoader.loadLibrary(exportingLibraryUri);
- }).then((loadedLibraries) {
- compiler.processLoadedLibraries(loadedLibraries);
- LibraryElement exportingLibrary = loadedLibraries.rootLibrary;
- Expect.isTrue(exportingLibrary.exportsHandled);
- var foo = exportingLibrary.findExported('foo');
- Expect.isNotNull(foo);
- Expect.isTrue(foo.isField);
-
- // Load reexporting library when exports are handled on the exporting library.
- return compiler.libraryLoader.loadLibrary(reexportingLibraryUri);
- }).then((dynamic loadedLibraries) {
- compiler.processLoadedLibraries(loadedLibraries);
- var foo = loadedLibraries.rootLibrary.findExported('foo');
- Expect.isNotNull(foo);
- Expect.isTrue(foo.isField);
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/related_types.dart b/tests/compiler/dart2js/old_frontend/related_types.dart
deleted file mode 100644
index 26f9607..0000000
--- a/tests/compiler/dart2js/old_frontend/related_types.dart
+++ /dev/null
@@ -1,445 +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 related_types;
-
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/compiler.dart';
-import 'package:compiler/src/common_elements.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';
-import 'package:compiler/src/elements/names.dart';
-import 'package:compiler/src/filenames.dart';
-import 'package:compiler/src/resolution/semantic_visitor.dart';
-import 'package:compiler/src/tree/tree.dart';
-import 'package:compiler/src/universe/call_structure.dart';
-import 'package:compiler/src/universe/selector.dart';
-import 'package:compiler/src/world.dart';
-import '../memory_compiler.dart';
-
-main(List<String> arguments) async {
- if (arguments.isNotEmpty) {
- Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.last));
- CompilationResult result = await runCompiler(
- entryPoint: entryPoint,
- options: [
- Flags.analyzeOnly,
- '--categories=Client,Server',
- Flags.useOldFrontend
- ]);
- if (result.isSuccess) {
- checkRelatedTypes(result.compiler);
- }
- } else {
- print('Usage dart related_types.dart <entry-point>');
- }
-}
-
-/// Check all loaded libraries in [compiler] for unrelated types.
-void checkRelatedTypes(Compiler compiler) {
- compiler.closeResolution(
- compiler.frontendStrategy.elementEnvironment.mainFunction);
- for (LibraryElement library in compiler.libraryLoader.libraries) {
- checkLibraryElement(compiler, library);
- }
-}
-
-/// Check [library] for unrelated types.
-void checkLibraryElement(Compiler compiler, LibraryElement library) {
- library.forEachLocalMember((Element element) {
- if (element.isClass) {
- ClassElement cls = element;
- cls.forEachLocalMember((_member) {
- MemberElement member = _member;
- checkMemberElement(compiler, member);
- });
- } else if (!element.isTypedef) {
- checkMemberElement(compiler, element);
- }
- });
-}
-
-/// Check [member] for unrelated types.
-void checkMemberElement(Compiler compiler, MemberElement member) {
- if (!compiler.resolution.hasBeenResolved(member)) return;
-
- ResolvedAst resolvedAst = member.resolvedAst;
- if (resolvedAst.kind == ResolvedAstKind.PARSED) {
- RelatedTypesChecker relatedTypesChecker =
- new RelatedTypesChecker(compiler, resolvedAst);
- compiler.reporter.withCurrentElement(member.implementation, () {
- relatedTypesChecker.apply(resolvedAst.node);
- });
- }
-}
-
-class RelatedTypesChecker
- extends TraversalVisitor<ResolutionDartType, dynamic> {
- final Compiler compiler;
- final ResolvedAst resolvedAst;
-
- RelatedTypesChecker(this.compiler, ResolvedAst resolvedAst)
- : this.resolvedAst = resolvedAst,
- super(resolvedAst.elements);
-
- ClosedWorld get world =>
- compiler.resolutionWorldBuilder.closedWorldForTesting;
-
- CommonElements get commonElements => compiler.resolution.commonElements;
-
- DiagnosticReporter get reporter => compiler.reporter;
-
- ResolutionInterfaceType get thisType =>
- resolvedAst.element.enclosingClass.thisType;
-
- /// Returns `true` if there exists no common subtype of [left] and [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);
- ClassElement rightClass = const ClassFinder().findClass(right);
- if (leftClass != null && rightClass != null) {
- return !world.haveAnyCommonSubtypes(leftClass, rightClass);
- }
- return false;
- }
-
- /// Checks that there exists a common subtype of [left] and [right] or report
- /// a hint otherwise.
- void checkRelated(
- Node node, ResolutionDartType left, ResolutionDartType right) {
- if (hasEmptyIntersection(left, right)) {
- reporter.reportHintMessage(
- node, MessageKind.NO_COMMON_SUBTYPES, {'left': left, 'right': right});
- }
- }
-
- /// Check weakly typed collection methods, like `Map.containsKey`,
- /// `Map.containsValue` and `Iterable.contains`.
- void checkDynamicInvoke(Node node, ResolutionDartType receiverType,
- List<ResolutionDartType> argumentTypes, Selector selector) {
- if (selector.name == 'containsKey' &&
- selector.callStructure == CallStructure.ONE_ARG) {
- ResolutionInterfaceType mapType = findMapType(receiverType);
- if (mapType != null) {
- ResolutionDartType keyType = findMapKeyType(mapType);
- checkRelated(node, keyType, argumentTypes.first);
- }
- } else if (selector.name == 'containsValue' &&
- selector.callStructure == CallStructure.ONE_ARG) {
- ResolutionInterfaceType mapType = findMapType(receiverType);
- if (mapType != null) {
- ResolutionDartType valueType = findMapValueType(mapType);
- checkRelated(node, valueType, argumentTypes.first);
- }
- } else if (selector.name == 'contains' &&
- selector.callStructure == CallStructure.ONE_ARG) {
- ResolutionInterfaceType iterableType = findIterableType(receiverType);
- if (iterableType != null) {
- ResolutionDartType elementType = findIterableElementType(iterableType);
- checkRelated(node, elementType, argumentTypes.first);
- }
- } else if (selector.name == 'remove' &&
- selector.callStructure == CallStructure.ONE_ARG) {
- ResolutionInterfaceType mapType = findMapType(receiverType);
- if (mapType != null) {
- ResolutionDartType keyType = findMapKeyType(mapType);
- checkRelated(node, keyType, argumentTypes.first);
- }
- ResolutionInterfaceType listType = findListType(receiverType);
- if (listType != null) {
- ResolutionDartType valueType = findListElementType(listType);
- checkRelated(node, valueType, argumentTypes.first);
- }
- }
- }
-
- /// Return the interface type implemented by [type] or `null` if no interface
- /// type is implied by [type].
- ResolutionInterfaceType findInterfaceType(ResolutionDartType type) {
- return Types.computeInterfaceType(compiler.resolution, type);
- }
-
- /// Returns the supertype of [receiver] that implements [cls], if any.
- ResolutionInterfaceType findClassType(
- ResolutionDartType receiver, ClassElement cls) {
- ResolutionInterfaceType interfaceType = findInterfaceType(receiver);
- if (interfaceType == null) return null;
- ResolutionInterfaceType mapType = interfaceType.asInstanceOf(cls);
- if (mapType == null) return null;
- return mapType;
- }
-
- /// Returns the supertype of [receiver] that implements `Iterable`, if any.
- ResolutionInterfaceType findIterableType(ResolutionDartType receiver) {
- return findClassType(receiver, commonElements.iterableClass);
- }
-
- /// Returns the element type of the supertype of [receiver] that implements
- /// `Iterable`, if any.
- ResolutionDartType findIterableElementType(
- ResolutionInterfaceType iterableType) {
- if (iterableType == null) return null;
- return iterableType.typeArguments[0];
- }
-
- /// Returns the supertype of [receiver] that implements `Map`, if any.
- ResolutionInterfaceType findMapType(ResolutionDartType receiver) {
- return findClassType(receiver, commonElements.mapClass);
- }
-
- /// Returns the key type of the supertype of [receiver] that implements
- /// `Map`, if any.
- 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.
- ResolutionDartType findMapValueType(ResolutionInterfaceType mapType) {
- if (mapType == null) return null;
- return mapType.typeArguments[1];
- }
-
- /// Returns the supertype of [receiver] that implements `List`, if any.
- ResolutionInterfaceType findListType(ResolutionDartType receiver) {
- return findClassType(receiver, commonElements.listClass);
- }
-
- /// Returns the element type of the supertype of [receiver] that implements
- /// `List`, if any.
- 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.
- ResolutionDartType findReturnType(ResolutionDartType type) {
- if (type is ResolutionFunctionType) {
- return type.returnType;
- }
- return const ResolutionDynamicType();
- }
-
- /// Visits [arguments] and returns the list of their corresponding types.
- List<ResolutionDartType> findArgumentTypes(NodeList arguments) {
- List<ResolutionDartType> argumentTypes = <ResolutionDartType>[];
- for (Node argument in arguments) {
- argumentTypes.add(apply(argument));
- }
- return argumentTypes;
- }
-
- /// Finds the [MemberSignature] of the [name] property on [type], if any.
- 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.
- ResolutionDartType lookupInterfaceMemberAccessType(
- ResolutionDartType type, Name name) {
- MemberSignature member = lookupInterfaceMember(type, name);
- 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.
- ResolutionFunctionType lookupInterfaceMemberInvocationType(
- ResolutionDartType type, Name name) {
- MemberSignature member = lookupInterfaceMember(type, name);
- if (member == null) return null;
- return member.functionType;
- }
-
- ResolutionDartType apply(Node node, [_]) {
- ResolutionDartType type = node.accept(this);
- if (type == null) {
- type = const ResolutionDynamicType();
- }
- return type;
- }
-
- @override
- ResolutionInterfaceType visitEquals(Send node, Node left, Node right, _) {
- ResolutionDartType leftType = apply(left);
- ResolutionDartType rightType = apply(right);
- checkRelated(node, leftType, rightType);
- return commonElements.boolType;
- }
-
- @override
- ResolutionInterfaceType visitNotEquals(Send node, Node left, Node right, _) {
- ResolutionDartType leftType = apply(left);
- ResolutionDartType rightType = apply(right);
- checkRelated(node, leftType, rightType);
- return commonElements.boolType;
- }
-
- @override
- 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
- ResolutionInterfaceType visitLiteralInt(LiteralInt node) {
- return commonElements.intType;
- }
-
- @override
- ResolutionInterfaceType visitLiteralString(LiteralString node) {
- return commonElements.stringType;
- }
-
- @override
- ResolutionInterfaceType visitLiteralBool(LiteralBool node) {
- return commonElements.boolType;
- }
-
- @override
- ResolutionDartType visitLiteralMap(LiteralMap node) {
- return elements.getType(node);
- }
-
- @override
- ResolutionDartType visitLiteralList(LiteralList node) {
- return elements.getType(node);
- }
-
- @override
- ResolutionDartType visitLiteralNull(LiteralNull node) {
- return elements.getType(node);
- }
-
- @override
- ResolutionDartType visitLocalVariableGet(
- Send node, LocalVariableElement variable, _) {
- return variable.type;
- }
-
- @override
- ResolutionDartType visitLocalFunctionGet(
- Send node, LocalFunctionElement function, _) {
- return function.type;
- }
-
- @override
- ResolutionDartType visitParameterGet(
- Send node, ParameterElement parameter, _) {
- return parameter.type;
- }
-
- @override
- ResolutionDartType visitThisPropertyGet(Send node, Name name, _) {
- return lookupInterfaceMemberAccessType(thisType, name);
- }
-
- @override
- ResolutionDartType visitDynamicPropertyGet(
- Send node, Node receiver, Name name, _) {
- ResolutionDartType receiverType = apply(receiver);
- return lookupInterfaceMemberAccessType(receiverType, name);
- }
-
- @override
- 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
- ResolutionDartType visitTopLevelFieldGet(Send node, FieldElement field, _) {
- return field.type;
- }
-
- @override
- ResolutionDartType visitDynamicPropertyInvoke(
- Send node, Node receiver, NodeList arguments, Selector selector, _) {
- ResolutionDartType receiverType = apply(receiver);
- List<ResolutionDartType> argumentTypes = findArgumentTypes(arguments);
- ResolutionFunctionType methodType =
- lookupInterfaceMemberInvocationType(receiverType, selector.memberName);
- checkDynamicInvoke(node, receiverType, argumentTypes, selector);
- return findReturnType(methodType);
- }
-
- @override
- ResolutionDartType visitThisPropertyInvoke(
- Send node, NodeList arguments, Selector selector, _) {
- ResolutionDartType receiverType = thisType;
- List<ResolutionDartType> argumentTypes = findArgumentTypes(arguments);
- ResolutionFunctionType methodType =
- lookupInterfaceMemberInvocationType(receiverType, selector.memberName);
- checkDynamicInvoke(node, receiverType, argumentTypes, selector);
- return findReturnType(methodType);
- }
-
- @override
- ResolutionDartType visitIfNotNullDynamicPropertyInvoke(
- Send node, Node receiver, NodeList arguments, Selector selector, _) {
- ResolutionDartType receiverType = apply(receiver);
- List<ResolutionDartType> argumentTypes = findArgumentTypes(arguments);
- ResolutionFunctionType methodType =
- lookupInterfaceMemberInvocationType(receiverType, selector.memberName);
- checkDynamicInvoke(node, receiverType, argumentTypes, selector);
- return findReturnType(methodType);
- }
-
- @override
- ResolutionDartType visitTopLevelFunctionInvoke(
- Send node,
- MethodElement function,
- NodeList arguments,
- CallStructure callStructure,
- _) {
- apply(arguments);
- return findReturnType(function.type);
- }
-
- @override
- ResolutionDartType visitStaticFunctionInvoke(
- Send node,
- MethodElement function,
- NodeList arguments,
- CallStructure callStructure,
- _) {
- apply(arguments);
- return findReturnType(function.type);
- }
-}
-
-/// Computes the [ClassElement] implied by a type.
-// TODO(johnniwinther): Handle type variables, function types and typedefs.
-class ClassFinder extends BaseResolutionDartTypeVisitor<ClassElement, dynamic> {
- const ClassFinder();
-
- ClassElement findClass(ResolutionDartType type) => type.accept(this, null);
-
- @override
- ClassElement visitType(ResolutionDartType type, _) => null;
-
- @override
- ClassElement visitInterfaceType(ResolutionInterfaceType type, _) {
- return type.element;
- }
-}
diff --git a/tests/compiler/dart2js/old_frontend/related_types_test.dart b/tests/compiler/dart2js/old_frontend/related_types_test.dart
deleted file mode 100644
index 963afa2..0000000
--- a/tests/compiler/dart2js/old_frontend/related_types_test.dart
+++ /dev/null
@@ -1,300 +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 related_types.test;
-
-import 'package:async_helper/async_helper.dart';
-import 'package:expect/expect.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/common_elements.dart';
-import 'package:compiler/src/compiler.dart';
-import 'package:compiler/src/diagnostics/messages.dart';
-import 'package:compiler/src/elements/elements.dart';
-import '../memory_compiler.dart';
-
-import 'related_types.dart';
-
-const String CODE = '''
-Map<String, int> topLevelMap;
-List<String> topLevelList;
-
-Map<String, int> getTopLevelMap() => null;
-List<String> getTopLevelList() => null;
-
-class Class {
- Map<String, int> instanceMap;
- List<String> instanceList;
-
- Map<String, int> getInstanceMap() => null;
- List<String> getInstanceList() => null;
-
- static Map<String, int> staticMap;
- static List<String> staticList;
-
- static Map<String, int> getStaticMap() => null;
- static List<String> getStaticList() => null;
-
- test_instanceMapIndex() {
- instanceMap[0];
- }
- test_instanceMapContainsKey() {
- instanceMap.containsKey(0);
- }
- test_instanceMapContainsValue() {
- instanceMap.containsValue('');
- }
- test_instanceMapRemove() {
- instanceMap.remove(0);
- }
- test_instanceListContains() {
- instanceList.contains(0);
- }
- test_instanceListRemove() {
- instanceList.remove(0);
- }
-
- test_getInstanceMapIndex() {
- getInstanceMap()[0];
- }
- test_getInstanceMapContainsKey() {
- getInstanceMap().containsKey(0);
- }
- test_getInstanceMapContainsValue() {
- getInstanceMap().containsValue('');
- }
- test_getInstanceMapRemove() {
- getInstanceMap().remove(0);
- }
- test_getInstanceListContains() {
- getInstanceList().contains(0);
- }
- test_getInstanceListRemove() {
- getInstanceList().remove(0);
- }
-
- static test_staticMapIndex() {
- staticMap[0];
- }
- static test_staticMapContainsKey() {
- staticMap.containsKey(0);
- }
- static test_staticMapContainsValue() {
- staticMap.containsValue('');
- }
- static test_staticMapRemove() {
- staticMap.remove(0);
- }
- static test_staticListContains() {
- staticList.contains(0);
- }
- static test_staticListRemove() {
- staticList.remove(0);
- }
-
- static test_getStaticMapIndex() {
- getStaticMap()[0];
- }
- static test_getStaticMapContainsKey() {
- getStaticMap().containsKey(0);
- }
- static test_getStaticMapContainsValue() {
- getStaticMap().containsValue('');
- }
- static test_getStaticMapRemove() {
- getStaticMap().remove(0);
- }
- static test_getStaticListContains() {
- getStaticList().contains(0);
- }
- static test_getStaticListRemove() {
- getStaticList().remove(0);
- }
-}
-
-main() {}
-
-test_equals() => 0 == '';
-test_notEquals() => 0 != '';
-test_index() => <String, int>{}[0];
-
-test_localMapIndex() {
- Map<String, int> map;
- map[0];
-}
-test_localMapContainsKey() {
- Map<String, int> map;
- map.containsKey(0);
-}
-test_localMapContainsValue() {
- Map<String, int> map;
- map.containsValue('');
-}
-test_localMapRemove() {
- Map<String, int> map;
- map.remove(0);
-}
-test_localListContains() {
- List<String> list;
- list.contains(0);
-}
-test_localListRemove() {
- List<String> list;
- list.remove(0);
-}
-
-test_topLevelMapIndex() {
- topLevelMap[0];
-}
-test_topLevelMapContainsKey() {
- topLevelMap.containsKey(0);
-}
-test_topLevelMapContainsValue() {
- topLevelMap.containsValue('');
-}
-test_topLevelMapRemove() {
- topLevelMap.remove(0);
-}
-test_topLevelListContains() {
- topLevelList.contains(0);
-}
-test_topLevelListRemove() {
- topLevelList.remove(0);
-}
-
-test_getTopLevelMapIndex() {
- getTopLevelMap()[0];
-}
-test_getTopLevelMapContainsKey() {
- getTopLevelMap().containsKey(0);
-}
-test_getTopLevelMapContainsValue() {
- getTopLevelMap().containsValue('');
-}
-test_getTopLevelMapRemove() {
- getTopLevelMap().remove(0);
-}
-test_getTopLevelListContains() {
- getTopLevelList().contains(0);
-}
-test_getTopLevelListRemove() {
- getTopLevelList().remove(0);
-}
-
-test_staticMapIndex() {
- Class.staticMap[0];
-}
-test_staticMapContainsKey() {
- Class.staticMap.containsKey(0);
-}
-test_staticMapContainsValue() {
- Class.staticMap.containsValue('');
-}
-test_staticMapRemove() {
- Class.staticMap.remove(0);
-}
-test_staticListContains() {
- Class.staticList.contains(0);
-}
-test_staticListRemove() {
- Class.staticList.remove(0);
-}
-
-test_getStaticMapIndex() {
- Class.getStaticMap()[0];
-}
-test_getStaticMapContainsKey() {
- Class.getStaticMap().containsKey(0);
-}
-test_getStaticMapContainsValue() {
- Class.getStaticMap().containsValue('');
-}
-test_getStaticMapRemove() {
- Class.getStaticMap().remove(0);
-}
-test_getStaticListContains() {
- Class.getStaticList().contains(0);
-}
-test_getStaticListRemove() {
- Class.getStaticList().remove(0);
-}
-
-test_instanceMapIndex(Class c) {
- c.instanceMap[0];
-}
-test_instanceMapContainsKey(Class c) {
- c.instanceMap.containsKey(0);
-}
-test_instanceMapContainsValue(Class c) {
- c.instanceMap.containsValue('');
-}
-test_instanceMapRemove(Class c) {
- c.instanceMap.remove(0);
-}
-test_instanceListContains(Class c) {
- c.instanceList.contains(0);
-}
-test_instanceListRemove(Class c) {
- c.instanceList.remove(0);
-}
-
-test_getInstanceMapIndex(Class c) {
- c.getInstanceMap()[0];
-}
-test_getInstanceMapContainsKey(Class c) {
- c.getInstanceMap().containsKey(0);
-}
-test_getInstanceMapContainsValue(Class c) {
- c.getInstanceMap().containsValue('');
-}
-test_getInstanceMapRemove(Class c) {
- c.getInstanceMap().remove(0);
-}
-test_getInstanceListContains(Class c) {
- c.getInstanceList().contains(0);
-}
-test_getInstanceListRemove(Class c) {
- c.getInstanceList().remove(0);
-}
-''';
-
-main(List<String> arguments) {
- asyncTest(() async {
- DiagnosticCollector collector = new DiagnosticCollector();
- CompilationResult result = await runCompiler(
- memorySourceFiles: {'main.dart': CODE},
- options: [Flags.analyzeOnly, Flags.analyzeMain, Flags.useOldFrontend],
- diagnosticHandler: collector);
- Expect.isFalse(
- collector.hasRegularMessages, "Unexpected analysis messages.");
- Compiler compiler = result.compiler;
- ElementEnvironment elementEnvironment =
- compiler.frontendStrategy.elementEnvironment;
- compiler.closeResolution(elementEnvironment.mainFunction);
-
- void checkMember(Element element) {
- MemberElement member = element;
- if (!member.name.startsWith('test_')) return;
-
- collector.clear();
- checkMemberElement(compiler, member);
- Expect.equals(
- 1, collector.hints.length, "Unexpected hint count for $member.");
- Expect.equals(
- MessageKind.NO_COMMON_SUBTYPES,
- collector.hints.first.message.kind,
- "Unexpected message kind ${collector.hints.first.message.kind} "
- "for $member.");
- }
-
- LibraryElement mainApp = elementEnvironment.mainLibrary;
- mainApp.forEachLocalMember((Element element) {
- if (element.isClass) {
- ClassElement cls = element;
- cls.forEachLocalMember(checkMember);
- } else {
- checkMember(element);
- }
- });
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/resolution_test.dart b/tests/compiler/dart2js/old_frontend/resolution_test.dart
deleted file mode 100644
index ed0c2c9..0000000
--- a/tests/compiler/dart2js/old_frontend/resolution_test.dart
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that resolution does not resolve things we know will not be
-// needed by the backend.
-
-import 'package:async_helper/async_helper.dart';
-import 'package:expect/expect.dart';
-import 'package:compiler/src/apiimpl.dart';
-import '../compiler_helper.dart';
-
-const String NO_RUNTIME_TYPE = r"""
-import 'dart:core' as prefix;
-class A {
- A();
- A.z();
- static var bar;
- static foo() {}
-}
-main() {
- var print = prefix.print;
- // Check when accessing a static field.
- print(A.bar);
- print(A.bar());
- // Check when calling a static method.
- print(A.foo());
- print(A.foo);
- // Check when using a constructor.
- print(new A());
- // Check when using a named constructor.
- print(new A.z());
- // Check when using a type annotation.
- A a = new A();
- // Check when using a prefix.
- print(prefix.double.nan);
- print(prefix.double.nan());
- print(prefix.double.parse(''));
- print(prefix.double.parse);
- print(new prefix.DateTime(0));
- print(new prefix.DateTime.utc(0));
- prefix.DateTime c = new prefix.DateTime(0);
- A.bar = 0;
-}
-""";
-
-const String HAS_RUNTIME_TYPE_1 = r"""
-class A {
-}
-main() {
- print(A);
-}
-""";
-
-const String HAS_RUNTIME_TYPE_2 = r"""
-class A {
-}
-main() {
- print(2 + A);
-}
-""";
-
-const String HAS_RUNTIME_TYPE_3 = r"""
-class A {
-}
-main() {
- print(A[0]);
-}
-""";
-
-const String HAS_RUNTIME_TYPE_4 = r"""
-class A {
-}
-main() {
- var c = A;
-}
-""";
-
-const String HAS_RUNTIME_TYPE_5 = r"""
-import 'dart:core' as prefix;
-main() {
- prefix.print(prefix.Object);
-}
-""";
-
-const String HAS_RUNTIME_TYPE_6 = r"""
-class A {
- static var foo;
-}
-main() {
- (A).foo;
-}
-""";
-
-void test(String code, void check(CompilerImpl compiler)) {
- Uri uri = new Uri(scheme: 'source');
- dynamic compiler = mockCompilerFor(code, uri);
- asyncTest(() => compiler.run(uri).then((_) {
- check(compiler);
- }));
-}
-
-void testHasRuntimeType(String code) {
- test(code, (compiler) {
- var element = compiler.resolution.commonElements.createRuntimeType;
- Expect.isTrue(
- compiler.enqueuer.resolution.processedEntities.contains(element));
- });
-}
-
-main() {
- test(NO_RUNTIME_TYPE, (compiler) {
- var element = compiler.resolution.commonElements.createRuntimeType;
- Expect.isFalse(
- compiler.enqueuer.resolution.processedEntities.contains(element));
- });
-
- testHasRuntimeType(HAS_RUNTIME_TYPE_1);
- testHasRuntimeType(HAS_RUNTIME_TYPE_2);
- testHasRuntimeType(HAS_RUNTIME_TYPE_3);
- testHasRuntimeType(HAS_RUNTIME_TYPE_4);
- testHasRuntimeType(HAS_RUNTIME_TYPE_5);
- testHasRuntimeType(HAS_RUNTIME_TYPE_6);
-}
diff --git a/tests/compiler/dart2js/old_frontend/resolver_test.dart b/tests/compiler/dart2js/old_frontend/resolver_test.dart
deleted file mode 100644
index 41a7f81..0000000
--- a/tests/compiler/dart2js/old_frontend/resolver_test.dart
+++ /dev/null
@@ -1,1530 +0,0 @@
-// Copyright (c) 2012, 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:async';
-import 'dart:collection';
-
-import 'package:async_helper/async_helper.dart';
-import 'package:expect/expect.dart';
-import 'package:compiler/src/constants/expressions.dart';
-import 'package:compiler/src/elements/modelx.dart';
-import 'package:compiler/src/elements/resolution_types.dart';
-import 'package:compiler/src/elements/types.dart';
-import 'package:compiler/src/resolution/constructors.dart';
-import 'package:compiler/src/resolution/members.dart';
-import 'package:compiler/src/resolution/registry.dart';
-import 'package:compiler/src/resolution/resolution_result.dart';
-import 'package:compiler/src/resolution/scope.dart';
-import 'package:compiler/src/resolution/tree_elements.dart';
-import 'package:compiler/src/universe/use.dart';
-import 'package:compiler/src/universe/world_impact.dart';
-
-import '../compiler_helper.dart';
-import '../link_helper.dart';
-import 'parser_helper.dart';
-
-Node buildIdentifier(String name) => new Identifier(scan(name));
-
-Node buildInitialization(String name) => parseBodyCode(
- '$name = 1',
- (parser, tokens) => parser.parseOptionallyInitializedIdentifier(
- parser.syntheticPreviousToken(tokens)));
-
-createLocals(List variables) {
- var locals = <Node>[];
- for (final variable in variables) {
- String name = variable[0];
- bool init = variable[1];
- if (init) {
- locals.add(buildInitialization(name));
- } else {
- locals.add(buildIdentifier(name));
- }
- }
- var definitions = new NodeList(null, LinkFromList(locals), null, null);
- return new VariableDefinitions(null, Modifiers.EMPTY, definitions);
-}
-
-Future<MockCompiler> testLocals(List variables) {
- return MockCompiler.create((MockCompiler compiler) {
- ResolverVisitor visitor = compiler.resolverVisitor();
- ResolutionResult result = visitor.visit(createLocals(variables));
- // A VariableDefinitions does not have an element.
- Expect.equals(const NoneResult(), result);
- Expect.equals(variables.length, map(visitor).length);
-
- for (final variable in variables) {
- final name = variable[0];
- Identifier id = buildIdentifier(name);
- ResolutionResult result = visitor.visit(id);
- final VariableElement variableElement = result.element;
- MethodScope scope = visitor.scope;
- Expect.equals(variableElement, scope.elements[name]);
- }
- return compiler;
- });
-}
-
-main() {
- asyncTest(() => Future.forEach([
- testLocalsOne,
- testLocalsTwo,
- testLocalsThree,
- testLocalsFour,
- testLocalsFive,
- testParametersOne,
- testFor,
- testTypeAnnotation,
- testSuperclass,
- // testVarSuperclass, // The parser crashes with 'class Foo extends var'.
- // testOneInterface, // Generates unexpected error message.
- // testTwoInterfaces, // Generates unexpected error message.
- testFunctionExpression,
- testNewExpression,
- testTopLevelFields,
- testClassHierarchy,
- testEnumDeclaration,
- testInitializers,
- testThis,
- testSuperCalls,
- testSwitch,
- testTypeVariables,
- testToString,
- testIndexedOperator,
- testIncrementsAndDecrements,
- testOverrideHashCodeCheck,
- testSupertypeOrder,
- testConstConstructorAndNonFinalFields,
- testCantAssignMethods,
- testCantAssignFinalAndConsts,
- testAwaitHint,
- testConstantExpressions,
- ], (f) => f()));
-}
-
-Future testSupertypeOrder() {
- return Future.wait([
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""
-class I1 {}
-class I2 {}
-class J1 extends K1 {}
-class J2 implements K2 {}
-class K1 {}
-class K2 {}
-class L1 {}
-class A implements I1, I2 {}
-class B extends A implements J1, J2 {}
-class C extends B implements L1 {}
-""");
- compiler.resolveStatement("C c;");
- LibraryElement mainApp = compiler.mainApp;
- ClassElement classA = mainApp.find("A");
- ClassElement classB = mainApp.find("B");
- ClassElement classC = mainApp.find("C");
- Expect.equals('[ I2, I1, Object ]', classA.allSupertypes.toString());
- Expect.equals('[ A, J2, J1, I2, I1, K2, K1, Object ]',
- classB.allSupertypes.toString());
- Expect.equals('[ B, L1, A, J2, J1, I2, I1, K2, K1, Object ]',
- classC.allSupertypes.toString());
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""
-class X<T> {}
-class Foo extends X<Foo> {}
-class Bar extends Foo implements X<Bar> {}
-""");
- compiler.resolveStatement("Bar bar;");
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.errors.length);
- Expect.equals(
- MessageKind.MULTI_INHERITANCE, collector.errors.first.message.kind);
- Expect.equals(0, collector.crashes.length);
- }),
- ]);
-}
-
-Future testTypeVariables() {
- matchResolvedTypes(visitor, text, name, expectedElements) {
- VariableDefinitions definition = parseStatement(text);
- visitor.visit(definition.type);
- ResolutionInterfaceType type =
- visitor.registry.mapping.getType(definition.type);
- NominalTypeAnnotation annotation = definition.type;
- Expect.equals(
- annotation.typeArguments.slowLength(), type.typeArguments.length);
- int index = 0;
- for (ResolutionDartType argument in type.typeArguments) {
- Expect.equals(true, index < expectedElements.length);
- Expect.equals(expectedElements[index], argument.element);
- index++;
- }
- Expect.equals(index, expectedElements.length);
- }
-
- return Future.wait([
- MockCompiler.create((MockCompiler compiler) {
- ResolverVisitor visitor = compiler.resolverVisitor();
- compiler.parseScript('class Foo<T, U> {}');
- LibraryElement mainApp = compiler.mainApp;
- ClassElement foo = mainApp.find('Foo');
- matchResolvedTypes(visitor, 'Foo<int, String> x;', 'Foo', [
- compiler.resolution.commonElements.intClass,
- compiler.resolution.commonElements.stringClass
- ]);
- matchResolvedTypes(visitor, 'Foo<Foo, Foo> x;', 'Foo', [foo, foo]);
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript('class Foo<T, U> {}');
- compiler.resolveStatement('Foo<notype, int> x;');
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(1, collector.warnings.length);
- Expect.equals(MessageKind.CANNOT_RESOLVE_TYPE,
- collector.warnings.first.message.kind);
- Expect.equals(0, collector.errors.length);
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript('class Foo<T, U> {}');
- compiler.resolveStatement('var x = new Foo<notype, int>();');
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(1, collector.warnings.length);
- Expect.equals(0, collector.errors.length);
- Expect.equals(MessageKind.CANNOT_RESOLVE_TYPE,
- collector.warnings.first.message.kind);
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript('class Foo<T> {'
- ' Foo<T> t;'
- ' foo(Foo<T> f) {}'
- ' bar() { g(Foo<T> f) {}; g(); }'
- '}');
- LibraryElement mainApp = compiler.mainApp;
- ClassElement foo = mainApp.find('Foo');
- foo.ensureResolved(compiler.resolution);
- MemberElement tMember = foo.lookupLocalMember('t');
- tMember.computeType(compiler.resolution);
- MemberElement fooMember = foo.lookupLocalMember('foo');
- fooMember.computeType(compiler.resolution);
- compiler.resolver.resolve(foo.lookupLocalMember('bar'));
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(0, collector.errors.length);
- }),
- ]);
-}
-
-Future testSuperCalls() {
- return MockCompiler.create((MockCompiler compiler) {
- String script = """class A { foo() {} }
- class B extends A { foo() => super.foo(); }""";
- compiler.parseScript(script);
- compiler.resolveStatement("B b;");
-
- LibraryElement mainApp = compiler.mainApp;
- ClassElement classB = mainApp.find("B");
- FunctionElement fooB = classB.lookupLocalMember("foo");
- ClassElement classA = mainApp.find("A");
- FunctionElement fooA = classA.lookupLocalMember("foo");
-
- ResolverVisitor visitor = new ResolverVisitor(
- compiler.resolution,
- fooB,
- new ResolutionRegistry(
- compiler.backend.target, new CollectingTreeElements(fooB)),
- scope: new MockTypeVariablesScope(classB.buildScope()));
- FunctionExpression node =
- (fooB as FunctionElementX).parseNode(compiler.parsingContext);
- visitor.visit(node.body);
- Map mapping = map(visitor);
-
- Send superCall = node.body.asReturn().expression;
- FunctionElement called = mapping[superCall];
- Expect.isNotNull(called);
- Expect.equals(fooA, called);
- });
-}
-
-Future testSwitch() {
- return MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("class Foo { foo() {"
- "switch (null) { case '': break; case 2: break; } } }");
- compiler.resolveStatement("Foo foo;");
- LibraryElement mainApp = compiler.mainApp;
- ClassElement fooElement = mainApp.find("Foo");
- MethodElement funElement = fooElement.lookupLocalMember("foo");
- compiler.enqueuer.resolution.applyImpact(new WorldImpactBuilderImpl()
- ..registerStaticUse(new StaticUse.implicitInvoke(funElement)));
- compiler.processQueue(compiler.frontendStrategy.elementEnvironment,
- compiler.enqueuer.resolution, null, compiler.libraryLoader.libraries);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.errors.length);
- Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL,
- collector.errors.first.message.kind);
- Expect.equals(2, collector.infos.length);
- Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE,
- collector.infos.first.message.kind);
- Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE,
- collector.infos.elementAt(1).message.kind);
- });
-}
-
-Future testThis() {
- return Future.wait([
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("class Foo { foo() { return this; } }");
- compiler.resolveStatement("Foo foo;");
- LibraryElement mainApp = compiler.mainApp;
- ClassElement fooElement = mainApp.find("Foo");
- FunctionElement funElement = fooElement.lookupLocalMember("foo");
- ResolverVisitor visitor = new ResolverVisitor(
- compiler.resolution,
- funElement,
- new ResolutionRegistry(
- compiler.backend.target, new CollectingTreeElements(funElement)),
- scope: new MockTypeVariablesScope(fooElement.buildScope()));
- FunctionExpression function =
- (funElement as FunctionElementX).parseNode(compiler.parsingContext);
- visitor.visit(function.body);
- Map mapping = map(visitor);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, mapping.length);
- Expect.equals(0, collector.warnings.length);
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.resolveStatement("main() { return this; }");
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.errors.length);
- Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE,
- collector.errors.first.message.kind);
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("class Foo { static foo() { return this; } }");
- compiler.resolveStatement("Foo foo;");
- LibraryElement mainApp = compiler.mainApp;
- ClassElement fooElement = mainApp.find("Foo");
- FunctionElement funElement = fooElement.lookupLocalMember("foo");
- ResolverVisitor visitor = new ResolverVisitor(
- compiler.resolution,
- funElement,
- new ResolutionRegistry(
- compiler.backend.target, new CollectingTreeElements(funElement)),
- scope: new MockTypeVariablesScope(fooElement.buildScope()));
- FunctionExpression function =
- (funElement as FunctionElementX).parseNode(compiler.parsingContext);
- visitor.visit(function.body);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.errors.length);
- Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE,
- collector.errors.first.message.kind);
- }),
- ]);
-}
-
-Future testLocalsOne() {
- return Future.forEach([
- () => testLocals([
- ["foo", false]
- ]),
- () => testLocals([
- ["foo", false],
- ["bar", false]
- ]),
- () => testLocals([
- ["foo", false],
- ["bar", false],
- ["foobar", false]
- ]),
- () => testLocals([
- ["foo", true]
- ]),
- () => testLocals([
- ["foo", false],
- ["bar", true]
- ]),
- () => testLocals([
- ["foo", true],
- ["bar", true]
- ]),
- () => testLocals([
- ["foo", false],
- ["bar", false],
- ["foobar", true]
- ]),
- () => testLocals([
- ["foo", false],
- ["bar", true],
- ["foobar", true]
- ]),
- () => testLocals([
- ["foo", true],
- ["bar", true],
- ["foobar", true]
- ]),
- () => testLocals([
- ["foo", false],
- ["foo", false]
- ]).then((MockCompiler compiler) {
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(1, collector.errors.length);
- Expect.equals(
- new Message(
- MessageTemplate.TEMPLATES[MessageKind.DUPLICATE_DEFINITION],
- {'name': 'foo'},
- false),
- collector.errors.first.message);
- })
- ], (f) => f());
-}
-
-Future testLocalsTwo() {
- return MockCompiler.create((MockCompiler compiler) {
- ResolverVisitor visitor = compiler.resolverVisitor();
- Node tree = parseStatement("if (true) { var a = 1; var b = 2; }");
- ResolutionResult result = visitor.visit(tree);
- Expect.equals(const NoneResult(), result);
- MethodScope scope = visitor.scope;
- Expect.equals(0, scope.elements.length);
- Expect.equals(2, map(visitor).length);
-
- List<Element> elements = new List<Element>.from(map(visitor).values);
- Expect.notEquals(elements[0], elements[1]);
- });
-}
-
-Future testLocalsThree() {
- return MockCompiler.create((MockCompiler compiler) {
- ResolverVisitor visitor = compiler.resolverVisitor();
- Node tree = parseStatement("{ var a = 1; if (true) { a; } }");
- ResolutionResult result = visitor.visit(tree);
- Expect.equals(const NoneResult(), result);
- MethodScope scope = visitor.scope;
- Expect.equals(0, scope.elements.length);
- Expect.equals(2, map(visitor).length);
- List<Element> elements = map(visitor).values.toList();
- Expect.equals(elements[0], elements[1]);
- });
-}
-
-Future testLocalsFour() {
- return MockCompiler.create((MockCompiler compiler) {
- ResolverVisitor visitor = compiler.resolverVisitor();
- Node tree = parseStatement("{ var a = 1; if (true) { var a = 1; } }");
- ResolutionResult result = visitor.visit(tree);
- Expect.equals(const NoneResult(), result);
- MethodScope scope = visitor.scope;
- Expect.equals(0, scope.elements.length);
- Expect.equals(2, map(visitor).length);
- List<Element> elements = map(visitor).values.toList();
- Expect.notEquals(elements[0], elements[1]);
- });
-}
-
-Future testLocalsFive() {
- return MockCompiler.create((MockCompiler compiler) {
- ResolverVisitor visitor = compiler.resolverVisitor();
- If tree =
- parseStatement("if (true) { var a = 1; a; } else { var a = 2; a;}");
- ResolutionResult result = visitor.visit(tree);
- Expect.equals(const NoneResult(), result);
- MethodScope scope = visitor.scope;
- Expect.equals(0, scope.elements.length);
- Expect.equals(4, map(visitor).length);
-
- Block thenPart = tree.thenPart;
- List statements1 = thenPart.statements.nodes.toList();
- Node def1 = statements1[0].definitions.nodes.head;
- Node id1 = statements1[1].expression;
- Expect.equals(
- visitor.registry.mapping[def1], visitor.registry.mapping[id1]);
-
- Block elsePart = tree.elsePart;
- List statements2 = elsePart.statements.nodes.toList();
- Node def2 = statements2[0].definitions.nodes.head;
- Node id2 = statements2[1].expression;
- Expect.equals(
- visitor.registry.mapping[def2], visitor.registry.mapping[id2]);
-
- Expect.notEquals(
- visitor.registry.mapping[def1], visitor.registry.mapping[def2]);
- Expect.notEquals(
- visitor.registry.mapping[id1], visitor.registry.mapping[id2]);
- });
-}
-
-Future testParametersOne() {
- return MockCompiler.create((MockCompiler compiler) {
- ResolverVisitor visitor = compiler.resolverVisitor();
- FunctionExpression tree =
- parseFunction("void foo(int a) { return a; }", compiler);
- visitor.visit(tree);
-
- // Check that an element has been created for the parameter.
- VariableDefinitions vardef = tree.parameters.nodes.head;
- Node param = vardef.definitions.nodes.head;
- Expect.equals(ElementKind.PARAMETER, visitor.registry.mapping[param].kind);
-
- // Check that 'a' in 'return a' is resolved to the parameter.
- Block body = tree.body;
- Return ret = body.statements.nodes.head;
- Send use = ret.expression;
- Expect.equals(ElementKind.PARAMETER, visitor.registry.mapping[use].kind);
- Expect.equals(
- visitor.registry.mapping[param], visitor.registry.mapping[use]);
- });
-}
-
-Future testFor() {
- return MockCompiler.create((MockCompiler compiler) {
- ResolverVisitor visitor = compiler.resolverVisitor();
- For tree = parseStatement("for (int i = 0; i < 10; i = i + 1) { i = 5; }");
- visitor.visit(tree);
-
- MethodScope scope = visitor.scope;
- Expect.equals(0, scope.elements.length);
- Expect.equals(5, map(visitor).length);
-
- VariableDefinitions initializer = tree.initializer;
- Node iNode = initializer.definitions.nodes.head;
- Element iElement = visitor.registry.mapping[iNode];
-
- // Check that we have the expected nodes. This test relies on the mapping
- // field to be a linked hash map (preserving insertion order).
- Expect.isTrue(map(visitor) is LinkedHashMap);
- List<Node> nodes = map(visitor).keys.toList();
- List<Element> elements = map(visitor).values.toList();
-
- // for (int i = 0; i < 10; i = i + 1) { i = 5; };
- // ^^^^^
- checkSendSet(iElement, nodes[0], elements[0]);
-
- // for (int i = 0; i < 10; i = i + 1) { i = 5; };
- // ^
- checkSend(iElement, nodes[1], elements[1]);
-
- // for (int i = 0; i < 10; i = i + 1) { i = 5; };
- // ^
- checkSend(iElement, nodes[2], elements[2]);
-
- // for (int i = 0; i < 10; i = i + 1) { i = 5; };
- // ^^^^^^^^^
- checkSendSet(iElement, nodes[3], elements[3]);
-
- // for (int i = 0; i < 10; i = i + 1) { i = 5; };
- // ^^^^^
- checkSendSet(iElement, nodes[4], elements[4]);
- });
-}
-
-checkIdentifier(Element expected, Node node, Element actual) {
- Expect.isTrue(node is Identifier, node.toDebugString());
- Expect.equals(expected, actual);
-}
-
-checkSend(Element expected, Node node, Element actual) {
- Expect.isTrue(node is Send, node.toDebugString());
- Expect.isTrue(node is! SendSet, node.toDebugString());
- Expect.equals(expected, actual);
-}
-
-checkSendSet(Element expected, Node node, Element actual) {
- Expect.isTrue(node is SendSet, node.toDebugString());
- Expect.equals(expected, actual);
-}
-
-Future testTypeAnnotation() {
- return MockCompiler.create((MockCompiler compiler) {
- String statement = "Foo bar;";
-
- // Test that we get a warning when Foo is not defined.
- Map mapping = compiler.resolveStatement(statement).map;
-
- Expect.equals(1, mapping.length); // Only [bar] has an element.
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(1, collector.warnings.length);
-
- Expect.equals(
- new Message(MessageTemplate.TEMPLATES[MessageKind.CANNOT_RESOLVE_TYPE],
- {'typeName': 'Foo'}, false),
- collector.warnings.first.message);
- collector.clear();
-
- // Test that there is no warning after defining Foo.
- compiler.parseScript("class Foo {}");
- mapping = compiler.resolveStatement(statement).map;
- Expect.equals(1, mapping.length);
- Expect.equals(0, collector.warnings.length);
-
- // Test that 'var' does not create a warning.
- mapping = compiler.resolveStatement("var foo;").map;
- Expect.equals(1, mapping.length);
- Expect.equals(0, collector.warnings.length);
- });
-}
-
-Future testSuperclass() {
- return Future.wait([
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("class Foo extends Bar {}");
- compiler.resolveStatement("Foo bar;");
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(1, collector.errors.length);
- var cannotResolveBar = new Message(
- MessageTemplate.TEMPLATES[MessageKind.CANNOT_EXTEND_MALFORMED],
- {'className': 'Foo', 'malformedType': 'Bar'},
- false);
- Expect.equals(cannotResolveBar, collector.errors.first.message);
- collector.clear();
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("class Foo extends Bar {}");
- compiler.parseScript("class Bar {}");
- Map mapping = compiler.resolveStatement("Foo bar;").map;
- Expect.equals(1, mapping.length);
-
- LibraryElement mainApp = compiler.mainApp;
- ClassElement fooElement = mainApp.find('Foo');
- ClassElement barElement = mainApp.find('Bar');
- Expect.equals(
- barElement.computeType(compiler.resolution), fooElement.supertype);
- Expect.isTrue(fooElement.interfaces.isEmpty);
- Expect.isTrue(barElement.interfaces.isEmpty);
- }),
- ]);
-}
-
-Future testVarSuperclass() {
- return MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("class Foo extends var {}");
- compiler.resolveStatement("Foo bar;");
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(1, collector.errors.length);
- Expect.equals(
- new Message(MessageTemplate.TEMPLATES[MessageKind.CANNOT_RESOLVE_TYPE],
- {'typeName': 'var'}, false),
- collector.errors.first.message);
- collector.clear();
- });
-}
-
-Future testOneInterface() {
- return MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("class Foo implements Bar {}");
- compiler.resolveStatement("Foo bar;");
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(1, collector.errors.length);
- Expect.equals(
- new Message(MessageTemplate.TEMPLATES[MessageKind.CANNOT_RESOLVE_TYPE],
- {'typeName': 'bar'}, false),
- collector.errors.first.message);
- collector.clear();
-
- // Add the abstract class to the world and make sure everything is setup
- // correctly.
- compiler.parseScript("abstract class Bar {}");
-
- compiler.resolveStatement("Foo bar;");
-
- LibraryElement mainApp = compiler.mainApp;
- ClassElement fooElement = mainApp.find('Foo');
- ClassElement barElement = mainApp.find('Bar');
-
- Expect.equals(null, barElement.supertype);
- Expect.isTrue(barElement.interfaces.isEmpty);
-
- Expect.equals(barElement.computeType(compiler.resolution),
- fooElement.interfaces.head);
- Expect.equals(1, length(fooElement.interfaces));
- });
-}
-
-Future testTwoInterfaces() {
- return MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""abstract class I1 {}
- abstract class I2 {}
- class C implements I1, I2 {}""");
- compiler.resolveStatement("Foo bar;");
-
- LibraryElement mainApp = compiler.mainApp;
- ClassElement c = mainApp.find('C');
- ClassElement i1 = mainApp.find('I1');
- ClassElement i2 = mainApp.find('I2');
-
- Expect.equals(2, length(c.interfaces));
- Expect.equals(i1.computeType(compiler.resolution), at(c.interfaces, 0));
- Expect.equals(i2.computeType(compiler.resolution), at(c.interfaces, 1));
- });
-}
-
-Future testFunctionExpression() {
- return MockCompiler.create((MockCompiler compiler) {
- var mapping = compiler.resolveStatement("int f() {}").map;
- Expect.equals(2, mapping.length);
- Element element;
- Node node;
- mapping.forEach((Node n, Element e) {
- if (n is FunctionExpression) {
- element = e;
- node = n;
- }
- });
- Expect.equals(ElementKind.FUNCTION, element.kind);
- Expect.equals('f', element.name);
- Expect.equals((element as FunctionElement).node, node);
- });
-}
-
-Future testNewExpression() {
- return MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("class A {} foo() { print(new A()); }");
- LibraryElement mainApp = compiler.mainApp;
- ClassElement aElement = mainApp.find('A');
-
- FunctionElement fooElement = mainApp.find('foo');
- compiler.resolver.resolve(fooElement);
-
- Expect.isNotNull(aElement);
- Expect.isNotNull(fooElement);
-
- fooElement.node;
- compiler.resolver.resolve(fooElement);
-
- TreeElements elements = compiler.resolveStatement("new A();");
- NewExpression expression =
- compiler.parsedTree.asExpressionStatement().expression;
- Element element = elements[expression.send];
- Expect.equals(ElementKind.GENERATIVE_CONSTRUCTOR, element.kind);
- Expect.isTrue(element.isSynthesized);
- });
-}
-
-Future testTopLevelFields() {
- return MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("int a;");
- LibraryElement mainApp = compiler.mainApp;
- VariableElementX element = mainApp.find("a");
- Expect.equals(ElementKind.FIELD, element.kind);
- VariableDefinitions node =
- element.variables.parseNode(element, compiler.parsingContext);
- NominalTypeAnnotation annotation = node.type;
- Identifier typeName = annotation.typeName;
- Expect.equals(typeName.source, 'int');
-
- compiler.parseScript("var b, c;");
- VariableElementX bElement = mainApp.find("b");
- VariableElementX cElement = mainApp.find("c");
- Expect.equals(ElementKind.FIELD, bElement.kind);
- Expect.equals(ElementKind.FIELD, cElement.kind);
- Expect.isTrue(bElement != cElement);
-
- VariableDefinitions bNode =
- bElement.variables.parseNode(bElement, compiler.parsingContext);
- VariableDefinitions cNode =
- cElement.variables.parseNode(cElement, compiler.parsingContext);
- Expect.equals(bNode, cNode);
- Expect.isNull(bNode.type);
- Expect.isTrue(bNode.modifiers.isVar);
- });
-}
-
-Future resolveConstructor(String script, String statement, String className,
- String constructor, int expectedElementCount,
- {List expectedWarnings: const [],
- List expectedErrors: const [],
- List expectedInfos: const [],
- Map<String, String> corelib}) {
- MockCompiler compiler = new MockCompiler.internal(coreSource: corelib);
- return compiler.init().then((_) {
- compiler.parseScript(script);
- compiler.resolveStatement(statement);
- LibraryElement mainApp = compiler.mainApp;
- ClassElement classElement = mainApp.find(className);
- Element element;
- element = classElement.lookupConstructor(constructor);
- FunctionExpression tree = (element as FunctionElement).node;
- ResolverVisitor visitor = new ResolverVisitor(
- compiler.resolution,
- element,
- new ResolutionRegistry(
- compiler.backend.target, new CollectingTreeElements(element)),
- scope: classElement.buildScope());
- new InitializerResolver(visitor, element, tree).resolveInitializers();
- visitor.visit(tree.body);
- Expect.equals(expectedElementCount, map(visitor).length,
- "${map(visitor).values} for '$statement' in context of `$script`");
-
- DiagnosticCollector collector = compiler.diagnosticCollector;
- compareWarningKinds(script, expectedWarnings, collector.warnings);
- compareWarningKinds(script, expectedErrors, collector.errors);
- compareWarningKinds(script, expectedInfos, collector.infos);
- });
-}
-
-Future testClassHierarchy() {
- final MAIN = "main";
- return Future.wait([
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""class A extends A {}
- main() { return new A(); }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.errors.length);
- Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY,
- collector.errors.first.message.kind);
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""class A extends B {}
- class B extends A {}
- main() { return new A(); }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(2, collector.errors.length);
- Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY,
- collector.errors.first.message.kind);
- Expect.equals(MessageKind.CANNOT_FIND_UNNAMED_CONSTRUCTOR,
- collector.errors.elementAt(1).message.kind);
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""abstract class A extends B {}
- abstract class B extends A {}
- class C implements A {}
- main() { return new C(); }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.errors.length);
- Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY,
- collector.errors.first.message.kind);
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""class A extends B {}
- class B extends C {}
- class C {}
- main() { return new A(); }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(0, collector.errors.length);
- ClassElement aElement = mainApp.find("A");
- Link<InterfaceType> supertypes = aElement.allSupertypes;
- Expect.equals(<String>['B', 'C', 'Object'].toString(),
- asSortedStrings(supertypes).toString());
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""class A<T> {}
- class B<Z,W> extends A<int>
- implements I<Z,List<W>> {}
- class I<X,Y> {}
- class C extends B<bool,String> {}
- main() { return new C(); }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(0, collector.errors.length);
- ClassElement aElement = mainApp.find("C");
- Link<InterfaceType> supertypes = aElement.allSupertypes;
- // Object is once per inheritance path, that is from both A and I.
- Expect.equals(
- <String>[
- 'A<int>',
- 'B<bool, String>',
- 'I<bool, List<String>>',
- 'Object'
- ].toString(),
- asSortedStrings(supertypes).toString());
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""class A<T> {}
- class D extends A<E> {}
- class E extends D {}
- main() { return new E(); }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(0, collector.errors.length);
- ClassElement aElement = mainApp.find("E");
- Link<InterfaceType> supertypes = aElement.allSupertypes;
- Expect.equals(<String>['A<E>', 'D', 'Object'].toString(),
- asSortedStrings(supertypes).toString());
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""class A<T> {}
- class D extends A<int> implements A<double> {}
- main() { return new D(); }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(1, collector.errors.length);
- Expect.equals(
- MessageKind.MULTI_INHERITANCE, collector.errors.first.message.kind);
- Expect.equals(0, collector.crashes.length);
- }),
- ]);
-}
-
-Future testEnumDeclaration() {
- final MAIN = "main";
- return Future.wait([
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""enum Enum {}
- main() { Enum e; }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length,
- 'Unexpected warnings: ${collector.warnings}');
- Expect.equals(
- 1, collector.errors.length, 'Unexpected errors: ${collector.errors}');
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""enum Enum { A }
- main() { Enum e = Enum.A; }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length,
- 'Unexpected warnings: ${collector.warnings}');
- Expect.equals(
- 0, collector.errors.length, 'Unexpected errors: ${collector.errors}');
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""enum Enum { A }
- main() { Enum e = Enum.B; }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(1, collector.warnings.length,
- 'Unexpected warnings: ${collector.warnings}');
- Expect.equals(
- MessageKind.UNDEFINED_GETTER, collector.warnings.first.message.kind);
- Expect.equals(
- 0, collector.errors.length, 'Unexpected errors: ${collector.errors}');
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""enum Enum { A }
- main() { List values = Enum.values; }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length,
- 'Unexpected warnings: ${collector.warnings}');
- Expect.equals(
- 0, collector.errors.length, 'Unexpected errors: ${collector.errors}');
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""enum Enum { A }
- main() { new Enum(0, ''); }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length,
- 'Unexpected warnings: ${collector.warnings}');
- Expect.equals(
- 1, collector.errors.length, 'Unexpected errors: ${collector.errors}');
- Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM,
- collector.errors.first.message.kind);
- }),
- MockCompiler.create((MockCompiler compiler) {
- compiler.parseScript("""enum Enum { A }
- main() { const Enum(0, ''); }""");
- LibraryElement mainApp = compiler.mainApp;
- FunctionElement mainElement = mainApp.find(MAIN);
- compiler.resolver.resolve(mainElement);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length,
- 'Unexpected warnings: ${collector.warnings}');
- Expect.equals(
- 1, collector.errors.length, 'Unexpected errors: ${collector.errors}');
- Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM,
- collector.errors.first.message.kind);
- }),
- ]);
-}
-
-Future testInitializers() {
- return Future.forEach([
- () {
- String script = """class A {
- int foo; int bar;
- A() : this.foo = 1, bar = 2;
- }""";
- return resolveConstructor(script, "A a = new A();", "A", "", 2);
- },
- () {
- String script = """class A {
- int foo; A a;
- A() : a.foo = 1;
- }""";
- return resolveConstructor(script, "A a = new A();", "A", "", 0,
- expectedWarnings: [],
- expectedErrors: [MessageKind.INVALID_RECEIVER_IN_INITIALIZER]);
- },
- () {
- String script = """class A {
- int foo;
- A() : this.foo = 1, this.foo = 2;
- }""";
- return resolveConstructor(script, "A a = new A();", "A", "", 2,
- expectedInfos: [MessageKind.ALREADY_INITIALIZED],
- expectedErrors: [MessageKind.DUPLICATE_INITIALIZER]);
- },
- () {
- String script = """class A {
- A() : this.foo = 1;
- }""";
- return resolveConstructor(script, "A a = new A();", "A", "", 1,
- expectedWarnings: [], expectedErrors: [MessageKind.CANNOT_RESOLVE]);
- },
- () {
- String script = """class A {
- int foo;
- int bar;
- A() : this.foo = bar;
- }""";
- return resolveConstructor(script, "A a = new A();", "A", "", 2,
- expectedWarnings: [],
- expectedErrors: [MessageKind.NO_INSTANCE_AVAILABLE]);
- },
- () {
- String script = """class A {
- int foo() => 42;
- A() : foo();
- }""";
- return resolveConstructor(script, "A a = new A();", "A", "", 0,
- expectedWarnings: [],
- expectedErrors: [MessageKind.CONSTRUCTOR_CALL_EXPECTED]);
- },
- () {
- String script = """class A {
- int i;
- A.a() : this.b(0);
- A.b(int i);
- }""";
- return resolveConstructor(script, "A a = new A.a();", "A", "a", 1);
- },
- () {
- String script = """class A {
- int i;
- A.a() : i = 42, this(0);
- A(int i);
- }""";
- return resolveConstructor(script, "A a = new A.a();", "A", "a", 2,
- expectedWarnings: [],
- expectedErrors: [
- MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER
- ]);
- },
- () {
- String script = """class A {
- int i;
- A(i);
- }
- class B extends A {
- B() : super(0);
- }""";
- return resolveConstructor(script, "B a = new B();", "B", "", 1);
- },
- () {
- String script = """class A {
- int i;
- A(i);
- }
- class B extends A {
- B() : super(0), super(1);
- }""";
- return resolveConstructor(script, "B b = new B();", "B", "", 2,
- expectedWarnings: [],
- expectedErrors: [MessageKind.DUPLICATE_SUPER_INITIALIZER]);
- },
- () {
- String script = "";
- final INVALID_OBJECT = const {
- 'Object': 'class Object { Object() : super(); }'
- };
- return resolveConstructor(
- script, "Object o = new Object();", "Object", "", 1,
- expectedWarnings: [],
- expectedErrors: [MessageKind.SUPER_INITIALIZER_IN_OBJECT],
- corelib: INVALID_OBJECT);
- },
- ], (f) => f());
-}
-
-Future testConstantExpressions() {
- const Map<String, List<String>> testedConstants = const {
- 'null': const ['null'],
- 'true': const ['true'],
- '0': const ['0'],
- '0.0': const ['0.0'],
- '"foo"': const ['"foo"'],
- '#a': const ['#a'],
- '0 + 1': const ['0', '1', '0 + 1'],
- '0 * 1': const ['0', '1', '0 * 1'],
- '0 * 1 + 2': const ['0', '1', '0 * 1', '2', '0 * 1 + 2'],
- '0 + 1 * 2': const ['0', '1', '2', '1 * 2', '0 + 1 * 2'],
- '-(1)': const ['1', '-1'],
- '-(1 * 4)': const ['1', '4', '1 * 4', '-(1 * 4)'],
- 'true ? 0 : 1': const ['true', '0', '1', 'true ? 0 : 1'],
- '"a" "b"': const ['"a"', '"b"', '"ab"'],
- '"a" "b" "c"': const ['"a"', '"b"', '"c"', '"bc"', r'"a${"bc"}"'],
- r'"a${0}b"': const ['"a"', '0', '"b"', r'"a${0}b"'],
- r'"a${0}b${1}"': const ['"a"', '0', '"b"', '1', '""', r'"a${0}b${1}"'],
- 'true || false': const ['true', 'false', 'true || false'],
- 'true && false': const ['true', 'false', 'true && false'],
- '!true': const ['true', '!true'],
- 'const []': const ['const []'],
- 'const <int>[]': const ['const <int>[]'],
- 'const [0, 1, 2]': const ['0', '1', '2', 'const [0, 1, 2]'],
- 'const <int>[0, 1, 2]': const ['0', '1', '2', 'const <int>[0, 1, 2]'],
- 'const {}': const ['const {}'],
- 'const <String, int>{}': const ['const <String, int>{}'],
- 'const {"a": 0, "b": 1, "c": 2}': const [
- '"a"',
- '0',
- '"b"',
- '1',
- '"c"',
- '2',
- 'const {"a": 0, "b": 1, "c": 2}'
- ],
- 'const <String, int>{"a": 0, "b": 1, "c": 2}': const [
- '"a"',
- '0',
- '"b"',
- '1',
- '"c"',
- '2',
- 'const <String, int>{"a": 0, "b": 1, "c": 2}'
- ],
- };
- return Future.forEach(testedConstants.keys, (String constant) {
- return MockCompiler.create((MockCompiler compiler) {
- CollectingTreeElements elements =
- compiler.resolveStatement("main() => $constant;");
- List<String> expectedConstants = testedConstants[constant];
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(0, collector.errors.length);
- List<ConstantExpression> constants = elements.constants;
- String constantsText =
- '[${constants.map((c) => c.toDartText()).join(', ')}]';
- Expect.equals(
- expectedConstants.length,
- constants.length,
- "Expected ${expectedConstants.length} constants for `${constant}` "
- "found $constantsText.");
- for (int index = 0; index < expectedConstants.length; index++) {
- Expect.equals(
- expectedConstants[index],
- constants[index].toDartText(),
- "Expected ${expectedConstants} for `$constant`, "
- "found $constantsText.");
- }
- });
- });
-}
-
-map(ResolverVisitor visitor) {
- CollectingTreeElements elements = visitor.registry.mapping;
- return elements.map;
-}
-
-at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1);
-
-List<String> asSortedStrings(Link link) {
- List<String> result = <String>[];
- for (; !link.isEmpty; link = link.tail) result.add(link.head.toString());
- result.sort((s1, s2) => s1.compareTo(s2));
- return result;
-}
-
-Future compileScript(String source) {
- Uri uri = new Uri(scheme: 'source');
- MockCompiler compiler = mockCompilerFor(source, uri);
- compiler.diagnosticHandler = createHandler(compiler, source);
- return compiler.run(uri).then((_) {
- return compiler;
- });
-}
-
-checkMemberResolved(compiler, className, memberName) {
- ClassElement cls = findElement(compiler, className);
- MemberElement memberElement = cls.lookupLocalMember(memberName);
- Expect.isNotNull(memberElement);
- Expect.isTrue(compiler.resolutionWorldBuilder.isMemberUsed(memberElement));
-}
-
-testToString() {
- final script = r"class C { toString() => 'C'; } main() { '${new C()}'; }";
- asyncTest(() => compileScript(script).then((compiler) {
- checkMemberResolved(compiler, 'C', 'toString');
- }));
-}
-
-operatorName(op, isUnary) {
- return Elements.constructOperatorName(op, isUnary);
-}
-
-testIndexedOperator() {
- final script = r"""
- class C {
- operator[](ix) => ix;
- operator[]=(ix, v) {}
- }
- main() { var c = new C(); c[0]++; }""";
- asyncTest(() => compileScript(script).then((compiler) {
- checkMemberResolved(compiler, 'C', operatorName('[]', false));
- checkMemberResolved(compiler, 'C', operatorName('[]=', false));
- }));
-}
-
-testIncrementsAndDecrements() {
- final script = r"""
- class A { operator+(o)=>null; }
- class B { operator+(o)=>null; }
- class C { operator-(o)=>null; }
- class D { operator-(o)=>null; }
- main() {
- var a = new A();
- a++;
- var b = new B();
- ++b;
- var c = new C();
- c--;
- var d = new D();
- --d;
- }""";
- asyncTest(() => compileScript(script).then((compiler) {
- checkMemberResolved(compiler, 'A', operatorName('+', false));
- checkMemberResolved(compiler, 'B', operatorName('+', false));
- checkMemberResolved(compiler, 'C', operatorName('-', false));
- checkMemberResolved(compiler, 'D', operatorName('-', false));
- }));
-}
-
-testOverrideHashCodeCheck() {
- final script = r"""
- class A {
- operator==(other) => true;
- }
- class B {
- operator==(other) => true;
- get hashCode => 0;
- }
- main() {
- new A() == new B();
- }""";
- asyncTest(() => compileScript(script).then((compiler) {
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.warnings.length);
- Expect.equals(0, collector.infos.length);
- Expect.equals(1, collector.hints.length);
- Expect.equals(MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE,
- collector.hints.first.message.kind);
- Expect.equals(0, collector.errors.length);
- }));
-}
-
-testConstConstructorAndNonFinalFields() {
- void expect(compiler, List errors, List infos) {
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(errors.length, collector.errors.length);
- for (int i = 0; i < errors.length; i++) {
- Expect.equals(errors[i], collector.errors.elementAt(i).message.kind);
- }
- Expect.equals(0, collector.warnings.length);
- Expect.equals(infos.length, collector.infos.length);
- for (int i = 0; i < infos.length; i++) {
- Expect.equals(infos[i], collector.infos.elementAt(i).message.kind);
- }
- }
-
- final script1 = r"""
- class A {
- var a;
- const A(this.a);
- }
- main() {
- new A(0);
- }""";
- asyncTest(() => compileScript(script1).then((compiler) {
- expect(compiler, [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS],
- [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]);
- }));
-
- final script2 = r"""
- class A {
- var a;
- var b;
- const A(this.a, this.b);
- const A.named(this.a, this.b);
- }
- main() {
- new A(0, 1);
- }""";
- asyncTest(() => compileScript(script2).then((compiler) {
- expect(compiler, [
- MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS
- ], [
- MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
- MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
- MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD,
- MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD
- ]);
- }));
-}
-
-testCantAssignMethods() {
- // Can't override local functions
- checkWarningOn('''
- main() {
- mname() { mname = 2; };
- mname();
- }
- ''', [MessageKind.ASSIGNING_METHOD]);
-
- checkWarningOn('''
- main() {
- mname() { };
- mname = 3;
- }
- ''', [MessageKind.ASSIGNING_METHOD]);
-
- // Can't override top-level functions
- checkWarningOn('''
- m() {}
- main() { m = 4; }
- ''', [
- MessageKind.ASSIGNING_METHOD,
- // TODO(johnniwinther): Avoid duplicate warnings.
- MessageKind.NOT_ASSIGNABLE
- ]);
-
- // Can't override instance methods
- checkWarningOn('''
- main() { new B().bar(); }
- class B {
- mname() {}
- bar() {
- mname = () => null;
- }
- }
- ''', [MessageKind.UNDEFINED_SETTER]);
- checkWarningOn('''
- main() { new B().bar(); }
- class B {
- mname() {}
- bar() {
- this.mname = () => null;
- }
- }
- ''', [MessageKind.UNDEFINED_SETTER]);
-
- // Can't override super methods
- checkWarningOn('''
- main() { new B().bar(); }
- class A {
- mname() {}
- }
- class B extends A {
- bar() {
- super.mname = () => 6;
- }
- }
- ''', [
- MessageKind.ASSIGNING_METHOD_IN_SUPER,
- // TODO(johnniwinther): Avoid duplicate warnings.
- MessageKind.UNDEFINED_SETTER
- ]);
-
- // But index operators should be OK
- checkWarningOn('''
- main() { new B().bar(); }
- class B {
- operator[]=(x, y) {}
- bar() {
- this[1] = 3; // This is OK
- }
- }
- ''', []);
- checkWarningOn('''
- main() { new B().bar(); }
- class A {
- operator[]=(x, y) {}
- }
- class B extends A {
- bar() {
- super[1] = 3; // This is OK
- }
- }
- ''', []);
-}
-
-testCantAssignFinalAndConsts() {
- // Can't write final or const locals.
- checkWarningOn('''
- main() {
- final x = 1;
- x = 2;
- }
- ''', [MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
- checkWarningOn('''
- main() {
- const x = 1;
- x = 2;
- }
- ''', [MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
- checkWarningOn('''
- final x = 1;
- main() { x = 3; }
- ''', [MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
-
- checkWarningOn('''
- const x = 1;
- main() { x = 3; }
- ''', [MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER]);
-
- // Detect assignments to final fields:
- checkWarningOn('''
- main() => new B().m();
- class B {
- final x = 1;
- m() { x = 2; }
- }
- ''', [MessageKind.UNDEFINED_SETTER]);
-
- // ... even if 'this' is explicit:
- checkWarningOn('''
- main() => new B().m();
- class B {
- final x = 1;
- m() { this.x = 2; }
- }
- ''', [MessageKind.UNDEFINED_SETTER]);
-
- // ... and in super class:
- checkWarningOn('''
- main() => new B().m();
- class A {
- final x = 1;
- }
- class B extends A {
- m() { super.x = 2; }
- }
- ''', [
- MessageKind.ASSIGNING_FINAL_FIELD_IN_SUPER,
- // TODO(johnniwinther): Avoid duplicate warnings.
- MessageKind.UNDEFINED_SETTER
- ]);
-
- // But non-final fields are OK:
- checkWarningOn('''
- main() => new B().m();
- class A {
- int x = 1;
- }
- class B extends A {
- m() { super.x = 2; }
- }
- ''', []);
-
- // Check getter without setter.
- checkWarningOn('''
- main() => new B().m();
- class A {
- get x => 1;
- }
- class B extends A {
- m() { super.x = 2; }
- }
- ''', [
- MessageKind.UNDEFINED_SUPER_SETTER,
- // TODO(johnniwinther): Avoid duplicate warnings.
- MessageKind.UNDEFINED_SETTER
- ]);
-}
-
-/// Helper to test that [script] produces all the given [warnings].
-checkWarningOn(String script, List<MessageKind> warnings) {
- Expect.isTrue(warnings.length >= 0 && warnings.length <= 2);
- asyncTest(() => compileScript(script).then((compiler) {
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.errors.length,
- 'Unexpected errors in\n$script\n${collector.errors}');
- Expect.equals(
- warnings.length,
- collector.warnings.length,
- 'Unexpected warnings in\n$script\n'
- 'Expected:$warnings\nFound:${collector.warnings}');
- for (int i = 0; i < warnings.length; i++) {
- Expect.equals(
- warnings[i], collector.warnings.elementAt(i).message.kind);
- }
- }));
-}
-
-testAwaitHint() {
- check(String script, {String className, String functionName}) {
- var prefix = className == null
- ? "Cannot resolve 'await'"
- : "No member named 'await' in class '$className'";
- var where =
- functionName == null ? 'the enclosing function' : "'$functionName'";
- asyncTest(() => compileScript(script).then((compiler) {
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(0, collector.errors.length);
- Expect.equals(1, collector.warnings.length);
- Expect.equals(
- "$prefix.\n"
- "Did you mean to add the 'async' marker to $where?",
- '${collector.warnings.first.message}');
- }));
- }
-
- check('main() { await -3; }', functionName: 'main');
- check('main() { () => await -3; }');
- check('foo() => await -3; main() => foo();', functionName: 'foo');
- check('''
- class A {
- m() => await - 3;
- }
- main() => new A().m();
- ''', className: 'A', functionName: 'm');
- check('''
- class A {
- static m() => await - 3;
- }
- main() => A.m();
- ''', functionName: 'm');
- check('''
- class A {
- m() => () => await - 3;
- }
- main() => new A().m();
- ''', className: 'A');
-}
diff --git a/tests/compiler/dart2js/old_frontend/scanner_offset_length_test.dart b/tests/compiler/dart2js/old_frontend/scanner_offset_length_test.dart
deleted file mode 100644
index fe30615..0000000
--- a/tests/compiler/dart2js/old_frontend/scanner_offset_length_test.dart
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2012, 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 "package:expect/expect.dart";
-import 'package:front_end/src/fasta/scanner.dart';
-
-Token scan(String text) =>
- new StringScanner(text, includeComments: true).tokenize();
-
-check(String text) {
- Token token = scan(text);
- while (token.kind != EOF_TOKEN) {
- Expect.equals(token.lexeme.length, token.charCount);
-
- var start = token.charOffset;
- var end = token.charOffset + token.charCount;
-
- Expect.isTrue(start < text.length,
- 'start=$start < text.length=${text.length}: $text');
-
- Expect.isTrue(
- end <= text.length, 'end=$end <= text.length=${text.length}: $text');
-
- Expect.isTrue(start <= end, 'start=$end <= end=$end: $text');
-
- var substring = text.substring(start, end);
-
- Expect.stringEquals(
- token.lexeme,
- substring,
- 'token.value=${token.lexeme} == '
- 'text.substring(start,end)=${substring}: $text');
-
- print('$text: [$start,$end]:$token');
-
- token = token.next;
- }
-}
-
-main() {
- check('foo'); // identifier
- check('\'\''); // empty string
- check('\'foo\''); // simple string
- check('\'\$foo\''); // interpolation, identifier
- check('\'\${foo}\''); // interpolation, expression
-
- check('//'); // single line comment
- check('/**/'); // multi line comment
-}
diff --git a/tests/compiler/dart2js/old_frontend/scanner_test.dart b/tests/compiler/dart2js/old_frontend/scanner_test.dart
deleted file mode 100644
index 9cd8ba1..0000000
--- a/tests/compiler/dart2js/old_frontend/scanner_test.dart
+++ /dev/null
@@ -1,210 +0,0 @@
-// Copyright (c) 2012, 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 "package:expect/expect.dart";
-import 'package:front_end/src/fasta/scanner.dart';
-import 'package:front_end/src/fasta/scanner/characters.dart';
-import 'package:front_end/src/scanner/token.dart' show TokenType;
-import 'dart:typed_data';
-
-Token scan(List<int> bytes) {
- List<int> zeroTerminated = new Uint8List(bytes.length + 1);
- zeroTerminated.setRange(0, bytes.length, bytes);
- zeroTerminated[bytes.length] = 0;
- return new Utf8BytesScanner(zeroTerminated).tokenize();
-}
-
-Token scanUTF8(List<int> bytes) {
- int l = bytes.length;
- List<int> stringLiteral = new Uint8List(l + 3);
- stringLiteral[0] = 0x27; // single quote
- stringLiteral[l + 1] = 0x27; // single quote
- // The bytes given to the scanner must be 0-terminated.
- stringLiteral[l + 2] = $EOF;
- for (int i = 0; i < l; i++) {
- stringLiteral[i + 1] = bytes[i];
- }
- return new Utf8BytesScanner(stringLiteral).tokenize();
-}
-
-bool isRunningOnJavaScript() => identical(1, 1.0);
-
-main() {
- // Google favorite: "Îñţérñåţîöñåļîžåţîờñ".
- Token token = scanUTF8([
- 0xc3,
- 0x8e,
- 0xc3,
- 0xb1,
- 0xc5,
- 0xa3,
- 0xc3,
- 0xa9,
- 0x72,
- 0xc3,
- 0xb1,
- 0xc3,
- 0xa5,
- 0xc5,
- 0xa3,
- 0xc3,
- 0xae,
- 0xc3,
- 0xb6,
- 0xc3,
- 0xb1,
- 0xc3,
- 0xa5,
- 0xc4,
- 0xbc,
- 0xc3,
- 0xae,
- 0xc5,
- 0xbe,
- 0xc3,
- 0xa5,
- 0xc5,
- 0xa3,
- 0xc3,
- 0xae,
- 0xe1,
- 0xbb,
- 0x9d,
- 0xc3,
- 0xb1
- ]);
- Expect.stringEquals("'Îñţérñåţîöñåļîžåţîờñ'", token.lexeme);
-
- // Blueberry porridge in Danish: "blåbærgrød".
- token = scanUTF8([
- 0x62,
- 0x6c,
- 0xc3,
- 0xa5,
- 0x62,
- 0xc3,
- 0xa6,
- 0x72,
- 0x67,
- 0x72,
- 0xc3,
- 0xb8,
- 0x64
- ]);
- Expect.stringEquals("'blåbærgrød'", token.lexeme);
-
- // "சிவா அணாமாைல", that is "Siva Annamalai" in Tamil.
- token = scanUTF8([
- 0xe0,
- 0xae,
- 0x9a,
- 0xe0,
- 0xae,
- 0xbf,
- 0xe0,
- 0xae,
- 0xb5,
- 0xe0,
- 0xae,
- 0xbe,
- 0x20,
- 0xe0,
- 0xae,
- 0x85,
- 0xe0,
- 0xae,
- 0xa3,
- 0xe0,
- 0xae,
- 0xbe,
- 0xe0,
- 0xae,
- 0xae,
- 0xe0,
- 0xae,
- 0xbe,
- 0xe0,
- 0xaf,
- 0x88,
- 0xe0,
- 0xae,
- 0xb2
- ]);
- Expect.stringEquals("'சிவா அணாமாைல'", token.lexeme);
-
- // "िसवा अणामालै", that is "Siva Annamalai" in Devanagari.
- token = scanUTF8([
- 0xe0,
- 0xa4,
- 0xbf,
- 0xe0,
- 0xa4,
- 0xb8,
- 0xe0,
- 0xa4,
- 0xb5,
- 0xe0,
- 0xa4,
- 0xbe,
- 0x20,
- 0xe0,
- 0xa4,
- 0x85,
- 0xe0,
- 0xa4,
- 0xa3,
- 0xe0,
- 0xa4,
- 0xbe,
- 0xe0,
- 0xa4,
- 0xae,
- 0xe0,
- 0xa4,
- 0xbe,
- 0xe0,
- 0xa4,
- 0xb2,
- 0xe0,
- 0xa5,
- 0x88
- ]);
- Expect.stringEquals("'िसवा अणामालै'", token.lexeme);
-
- if (!isRunningOnJavaScript()) {
- // DESERET CAPITAL LETTER BEE, unicode 0x10412(0xD801+0xDC12)
- // UTF-8: F0 90 90 92
- token = scanUTF8([0xf0, 0x90, 0x90, 0x92]);
- Expect.stringEquals("'𐐒'", token.lexeme);
- } else {
- print('Skipping non-BMP character test');
- }
-
- // Regression test for issue 1761.
- // "#!"
- token = scan([0x23, 0x21]);
- Expect.equals(token.type, TokenType.SCRIPT_TAG); // Treated as a comment.
-
- // Regression test for issue 1761.
- // "#! Hello, World!"
- token = scan([
- 0x23,
- 0x21,
- 0x20,
- 0x48,
- 0x65,
- 0x6c,
- 0x6c,
- 0x6f,
- 0x2c,
- 0x20,
- 0x57,
- 0x6f,
- 0x72,
- 0x6c,
- 0x64,
- 0x21
- ]);
- Expect.equals(token.type, TokenType.SCRIPT_TAG); // Treated as a comment.
-}
diff --git a/tests/compiler/dart2js/old_frontend/semantic_visitor_test.dart b/tests/compiler/dart2js/old_frontend/semantic_visitor_test.dart
deleted file mode 100644
index 3ce95aa..0000000
--- a/tests/compiler/dart2js/old_frontend/semantic_visitor_test.dart
+++ /dev/null
@@ -1,732 +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 dart2js.semantics_visitor_test;
-
-import 'dart:async';
-import 'dart:mirrors';
-import 'package:async_helper/async_helper.dart';
-import 'package:expect/expect.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/constants/expressions.dart';
-import 'package:compiler/src/diagnostics/spannable.dart';
-import 'package:compiler/src/diagnostics/messages.dart' show MessageKind;
-import 'package:compiler/src/compiler.dart';
-import 'package:compiler/src/elements/elements.dart';
-import 'package:compiler/src/elements/names.dart';
-import 'package:compiler/src/elements/operators.dart';
-import 'package:compiler/src/elements/resolution_types.dart';
-import 'package:compiler/src/resolution/semantic_visitor.dart';
-import 'package:compiler/src/resolution/tree_elements.dart';
-import 'package:compiler/src/tree/tree.dart';
-import 'package:compiler/src/universe/call_structure.dart' show CallStructure;
-import 'package:compiler/src/universe/selector.dart' show Selector;
-import '../memory_compiler.dart';
-
-part 'semantic_visitor_test_send_data.dart';
-part 'semantic_visitor_test_send_visitor.dart';
-part 'semantic_visitor_test_decl_data.dart';
-part 'semantic_visitor_test_decl_visitor.dart';
-
-class Visit {
- final VisitKind method;
- final element;
- final rhs;
- final arguments;
- final receiver;
- final name;
- final expression;
- final left;
- final right;
- final type;
- final operator;
- final index;
- final getter;
- final setter;
- final constant;
- final selector;
- final parameters;
- final body;
- final target;
- final targetType;
- final initializers;
- final error;
-
- const Visit(this.method,
- {this.element,
- this.rhs,
- this.arguments,
- this.receiver,
- this.name,
- this.expression,
- this.left,
- this.right,
- this.type,
- this.operator,
- this.index,
- this.getter,
- this.setter,
- this.constant,
- this.selector,
- this.parameters,
- this.body,
- this.target,
- this.targetType,
- this.initializers,
- this.error});
-
- int get hashCode => toString().hashCode;
-
- bool operator ==(other) => '$this' == '$other';
-
- String toString() {
- StringBuffer sb = new StringBuffer();
- sb.write('method=$method');
- if (element != null) {
- sb.write(',element=$element');
- }
- if (rhs != null) {
- sb.write(',rhs=$rhs');
- }
- if (arguments != null) {
- sb.write(',arguments=$arguments');
- }
- if (receiver != null) {
- sb.write(',receiver=$receiver');
- }
- if (name != null) {
- sb.write(',name=$name');
- }
- if (expression != null) {
- sb.write(',expression=$expression');
- }
- if (left != null) {
- sb.write(',left=$left');
- }
- if (right != null) {
- sb.write(',right=$right');
- }
- if (type != null) {
- sb.write(',type=$type');
- }
- if (operator != null) {
- sb.write(',operator=$operator');
- }
- if (index != null) {
- sb.write(',index=$index');
- }
- if (getter != null) {
- sb.write(',getter=$getter');
- }
- if (setter != null) {
- sb.write(',setter=$setter');
- }
- if (constant != null) {
- sb.write(',constant=$constant');
- }
- if (selector != null) {
- sb.write(',selector=$selector');
- }
- if (parameters != null) {
- sb.write(',parameters=$parameters');
- }
- if (body != null) {
- sb.write(',body=$body');
- }
- if (target != null) {
- sb.write(',target=$target');
- }
- if (targetType != null) {
- sb.write(',targetType=$targetType');
- }
- if (initializers != null) {
- sb.write(',initializers=$initializers');
- }
- if (error != null) {
- sb.write(',error=$error');
- }
- return sb.toString();
- }
-}
-
-class Test {
- final String codeByPrefix;
- final bool isDeferred;
- final String code;
- final /*Visit | List<Visit>*/ expectedVisits;
- final String cls;
- final String method;
-
- const Test(this.code, this.expectedVisits)
- : cls = null,
- method = 'm',
- codeByPrefix = null,
- isDeferred = false;
- const Test.clazz(this.code, this.expectedVisits,
- {this.cls: 'C', this.method: 'm'})
- : codeByPrefix = null,
- isDeferred = false;
- const Test.prefix(this.codeByPrefix, this.code, this.expectedVisits,
- {this.isDeferred: false})
- : cls = null,
- method = 'm';
-
- String toString() {
- StringBuffer sb = new StringBuffer();
- sb.writeln();
- sb.writeln(code);
- if (codeByPrefix != null) {
- sb.writeln('imported by prefix:');
- sb.writeln(codeByPrefix);
- }
- return sb.toString();
- }
-}
-
-const List<VisitKind> UNTESTABLE_KINDS = const <VisitKind>[
- // A final field shadowing a non-final field is currently not supported in
- // resolution.
- VisitKind.VISIT_SUPER_FIELD_FIELD_COMPOUND,
- VisitKind.VISIT_SUPER_FIELD_FIELD_SET_IF_NULL,
- VisitKind.VISIT_SUPER_FIELD_FIELD_PREFIX,
- VisitKind.VISIT_SUPER_FIELD_FIELD_POSTFIX,
- // Combination of method and setter with the same name is currently not
- // supported by the element model.
- VisitKind.VISIT_STATIC_METHOD_SETTER_COMPOUND,
- VisitKind.VISIT_STATIC_METHOD_SETTER_SET_IF_NULL,
- VisitKind.VISIT_STATIC_METHOD_SETTER_PREFIX,
- VisitKind.VISIT_STATIC_METHOD_SETTER_POSTFIX,
- VisitKind.VISIT_TOP_LEVEL_METHOD_SETTER_COMPOUND,
- VisitKind.VISIT_TOP_LEVEL_METHOD_SETTER_SET_IF_NULL,
- VisitKind.VISIT_TOP_LEVEL_METHOD_SETTER_PREFIX,
- VisitKind.VISIT_TOP_LEVEL_METHOD_SETTER_POSTFIX,
- VisitKind.VISIT_SUPER_METHOD_SETTER_COMPOUND,
- VisitKind.VISIT_SUPER_METHOD_SETTER_SET_IF_NULL,
- VisitKind.VISIT_SUPER_METHOD_SETTER_PREFIX,
- VisitKind.VISIT_SUPER_METHOD_SETTER_POSTFIX,
- // The only undefined unary, `+`, is currently handled and skipped in the
- // parser.
- VisitKind.ERROR_UNDEFINED_UNARY_EXPRESSION,
- // Constant expression are currently not computed during resolution.
- VisitKind.VISIT_CONSTANT_GET,
- VisitKind.VISIT_CONSTANT_INVOKE,
-];
-
-main(List<String> arguments) {
- Set<VisitKind> kinds = new Set<VisitKind>.from(VisitKind.values);
- asyncTest(() => Future.forEach([
- () {
- return test(kinds, arguments, SEND_TESTS,
- (elements) => new SemanticSendTestVisitor(elements));
- },
- () {
- return test(kinds, arguments, DECL_TESTS,
- (elements) => new SemanticDeclarationTestVisitor(elements));
- },
- () {
- Set<VisitKind> unvisitedKindSet = kinds.toSet()
- ..removeAll(UNTESTABLE_KINDS);
- List<VisitKind> unvisitedKindList = unvisitedKindSet.toList();
- unvisitedKindList..sort((a, b) => a.index.compareTo(b.index));
-
- Expect.isTrue(unvisitedKindList.isEmpty,
- "Untested visit kinds:\n ${unvisitedKindList.join(',\n ')},\n");
-
- Set<VisitKind> testedUntestableKinds = UNTESTABLE_KINDS.toSet()
- ..removeAll(kinds);
- Expect.isTrue(
- testedUntestableKinds.isEmpty,
- "Tested untestable visit kinds (remove from UNTESTABLE_KINDS):\n "
- "${testedUntestableKinds.join(',\n ')},\n");
- },
- () {
- ClassMirror mirror1 = reflectType(SemanticSendTestVisitor);
- Set<Symbol> symbols1 = mirror1.declarations.keys.toSet();
- ClassMirror mirror2 = reflectType(SemanticSendVisitor);
- Set<Symbol> symbols2 = mirror2.declarations.values
- .where((m) =>
- m is MethodMirror &&
- !m.isConstructor &&
- m.simpleName != #apply)
- .map((m) => m.simpleName)
- .toSet();
- symbols2.removeAll(symbols1);
- Expect.isTrue(symbols2.isEmpty,
- "Untested visit methods:\n ${symbols2.join(',\n ')},\n");
- }
- ], (f) => f()));
-}
-
-Future test(
- Set<VisitKind> unvisitedKinds,
- List<String> arguments,
- Map<String, List<Test>> TESTS,
- SemanticTestVisitor createVisitor(TreeElements elements)) async {
- Map<String, String> sourceFiles = {};
- Map<String, Test> testMap = {};
- StringBuffer mainSource = new StringBuffer();
- int index = 0;
- TESTS.forEach((String group, List<Test> tests) {
- if (arguments.isNotEmpty && !arguments.contains(group)) return;
-
- tests.forEach((Test test) {
- StringBuffer testSource = new StringBuffer();
- if (test.codeByPrefix != null) {
- String prefixFilename = 'pre$index.dart';
- sourceFiles[prefixFilename] = test.codeByPrefix;
- if (test.isDeferred) {
- testSource.writeln("import '$prefixFilename' deferred as p;");
- } else {
- testSource.writeln("import '$prefixFilename' as p;");
- }
- }
-
- String filename = 'lib$index.dart';
- testSource.writeln(test.code);
- sourceFiles[filename] = testSource.toString();
- mainSource.writeln("import '$filename';");
- testMap[filename] = test;
- index++;
- });
- });
- mainSource.writeln("main() {}");
- sourceFiles['main.dart'] = mainSource.toString();
-
- CompilationResult result = await runCompiler(
- memorySourceFiles: sourceFiles,
- options: [Flags.analyzeAll, Flags.analyzeOnly, Flags.useOldFrontend]);
- Compiler compiler = result.compiler;
- testMap.forEach((String filename, Test test) {
- LibraryElement library =
- compiler.libraryLoader.lookupLibrary(Uri.parse('memory:$filename'));
- Element element;
- String cls = test.cls;
- String method = test.method;
- if (cls == null) {
- element = library.find(method);
- } else {
- ClassElement classElement = library.find(cls);
- Expect.isNotNull(
- classElement,
- "Class '$cls' not found in:\n"
- "${library.compilationUnit.script.text}");
- element = classElement.localLookup(method);
- }
- var expectedVisits = test.expectedVisits;
- if (expectedVisits == null) {
- Expect.isTrue(
- element.isMalformed,
- "Element '$method' expected to be have parse errors in:\n"
- "${library.compilationUnit.script.text}");
- return;
- } else if (expectedVisits is! List) {
- expectedVisits = [expectedVisits];
- }
- Expect.isFalse(
- element.isMalformed,
- "Element '$method' is not expected to be have parse errors in:\n"
- "${library.compilationUnit.script.text}");
-
- void testAstElement(AstElement astElement) {
- Expect.isNotNull(
- astElement,
- "Element '$method' not found in:\n"
- "${library.compilationUnit.script.text}");
- ResolvedAst resolvedAst = astElement.resolvedAst;
- SemanticTestVisitor visitor = createVisitor(resolvedAst.elements);
- try {
- compiler.reporter.withCurrentElement(resolvedAst.element, () {
- //print(resolvedAst.node.toDebugString());
- resolvedAst.node.accept(visitor);
- });
- } catch (e, s) {
- Expect.fail("$e:\n$s\nIn test:\n"
- "${library.compilationUnit.script.text}");
- }
- Expect.listEquals(
- expectedVisits,
- visitor.visits,
- "In test:\n"
- "${library.compilationUnit.script.text}\n\n"
- "Expected: $expectedVisits\n"
- "Found: ${visitor.visits}");
- unvisitedKinds.removeAll(visitor.visits.map((visit) => visit.method));
- }
-
- if (element.isAbstractField) {
- AbstractFieldElement abstractFieldElement = element;
- if (abstractFieldElement.getter != null) {
- testAstElement(abstractFieldElement.getter);
- } else if (abstractFieldElement.setter != null) {
- testAstElement(abstractFieldElement.setter);
- }
- } else {
- testAstElement(element);
- }
- });
-}
-
-abstract class SemanticTestVisitor extends TraversalVisitor {
- List<Visit> visits = <Visit>[];
-
- SemanticTestVisitor(TreeElements elements) : super(elements);
-
- apply(Node node, arg) => node.accept(this);
-
- internalError(Spannable spannable, String message) {
- throw new SpannableAssertionFailure(spannable, message);
- }
-}
-
-enum VisitKind {
- VISIT_PARAMETER_GET,
- VISIT_PARAMETER_SET,
- VISIT_PARAMETER_INVOKE,
- VISIT_PARAMETER_COMPOUND,
- VISIT_PARAMETER_SET_IF_NULL,
- VISIT_PARAMETER_PREFIX,
- VISIT_PARAMETER_POSTFIX,
- VISIT_FINAL_PARAMETER_SET,
- VISIT_FINAL_PARAMETER_COMPOUND,
- VISIT_FINAL_PARAMETER_SET_IF_NULL,
- VISIT_FINAL_PARAMETER_PREFIX,
- VISIT_FINAL_PARAMETER_POSTFIX,
- VISIT_LOCAL_VARIABLE_GET,
- VISIT_LOCAL_VARIABLE_SET,
- VISIT_LOCAL_VARIABLE_INVOKE,
- VISIT_LOCAL_VARIABLE_COMPOUND,
- VISIT_LOCAL_VARIABLE_SET_IF_NULL,
- VISIT_LOCAL_VARIABLE_PREFIX,
- VISIT_LOCAL_VARIABLE_POSTFIX,
- VISIT_LOCAL_VARIABLE_DECL,
- VISIT_LOCAL_CONSTANT_DECL,
- VISIT_FINAL_LOCAL_VARIABLE_SET,
- VISIT_FINAL_LOCAL_VARIABLE_COMPOUND,
- VISIT_FINAL_LOCAL_VARIABLE_SET_IF_NULL,
- VISIT_FINAL_LOCAL_VARIABLE_PREFIX,
- VISIT_FINAL_LOCAL_VARIABLE_POSTFIX,
- VISIT_LOCAL_FUNCTION_GET,
- VISIT_LOCAL_FUNCTION_INVOKE,
- VISIT_LOCAL_FUNCTION_INCOMPATIBLE_INVOKE,
- VISIT_LOCAL_FUNCTION_DECL,
- VISIT_CLOSURE_DECL,
- VISIT_LOCAL_FUNCTION_SET,
- VISIT_LOCAL_FUNCTION_COMPOUND,
- VISIT_LOCAL_FUNCTION_SET_IF_NULL,
- VISIT_LOCAL_FUNCTION_PREFIX,
- VISIT_LOCAL_FUNCTION_POSTFIX,
- VISIT_STATIC_FIELD_GET,
- VISIT_STATIC_FIELD_SET,
- VISIT_STATIC_FIELD_INVOKE,
- VISIT_STATIC_FIELD_COMPOUND,
- VISIT_STATIC_FIELD_SET_IF_NULL,
- VISIT_STATIC_FIELD_PREFIX,
- VISIT_STATIC_FIELD_POSTFIX,
- VISIT_STATIC_FIELD_DECL,
- VISIT_STATIC_CONSTANT_DECL,
- VISIT_STATIC_GETTER_GET,
- VISIT_STATIC_GETTER_SET,
- VISIT_STATIC_GETTER_INVOKE,
- VISIT_STATIC_SETTER_GET,
- VISIT_STATIC_SETTER_SET,
- VISIT_STATIC_SETTER_INVOKE,
- VISIT_STATIC_GETTER_SETTER_COMPOUND,
- VISIT_STATIC_GETTER_SETTER_SET_IF_NULL,
- VISIT_STATIC_METHOD_SETTER_COMPOUND,
- VISIT_STATIC_METHOD_SETTER_SET_IF_NULL,
- VISIT_STATIC_GETTER_SETTER_PREFIX,
- VISIT_STATIC_GETTER_SETTER_POSTFIX,
- VISIT_STATIC_GETTER_DECL,
- VISIT_STATIC_SETTER_DECL,
- VISIT_FINAL_STATIC_FIELD_SET,
- VISIT_STATIC_FINAL_FIELD_COMPOUND,
- VISIT_STATIC_FINAL_FIELD_SET_IF_NULL,
- VISIT_STATIC_FINAL_FIELD_POSTFIX,
- VISIT_STATIC_FINAL_FIELD_PREFIX,
- VISIT_STATIC_FUNCTION_GET,
- VISIT_STATIC_FUNCTION_SET,
- VISIT_STATIC_FUNCTION_INVOKE,
- VISIT_STATIC_FUNCTION_INCOMPATIBLE_INVOKE,
- VISIT_STATIC_FUNCTION_DECL,
- VISIT_STATIC_METHOD_SETTER_PREFIX,
- VISIT_STATIC_METHOD_SETTER_POSTFIX,
- VISIT_UNRESOLVED_STATIC_GETTER_COMPOUND,
- VISIT_UNRESOLVED_STATIC_GETTER_SET_IF_NULL,
- VISIT_UNRESOLVED_STATIC_SETTER_COMPOUND,
- VISIT_UNRESOLVED_STATIC_SETTER_SET_IF_NULL,
- VISIT_STATIC_METHOD_COMPOUND,
- VISIT_STATIC_METHOD_SET_IF_NULL,
- VISIT_UNRESOLVED_STATIC_GETTER_PREFIX,
- VISIT_UNRESOLVED_STATIC_SETTER_PREFIX,
- VISIT_STATIC_METHOD_PREFIX,
- VISIT_UNRESOLVED_STATIC_GETTER_POSTFIX,
- VISIT_UNRESOLVED_STATIC_SETTER_POSTFIX,
- VISIT_STATIC_METHOD_POSTFIX,
- VISIT_TOP_LEVEL_FIELD_GET,
- VISIT_TOP_LEVEL_FIELD_SET,
- VISIT_TOP_LEVEL_FIELD_INVOKE,
- VISIT_FINAL_TOP_LEVEL_FIELD_SET,
- VISIT_TOP_LEVEL_FIELD_COMPOUND,
- VISIT_TOP_LEVEL_FIELD_SET_IF_NULL,
- VISIT_TOP_LEVEL_FIELD_PREFIX,
- VISIT_TOP_LEVEL_FIELD_POSTFIX,
- VISIT_TOP_LEVEL_FIELD_DECL,
- VISIT_TOP_LEVEL_CONSTANT_DECL,
- VISIT_TOP_LEVEL_FINAL_FIELD_COMPOUND,
- VISIT_TOP_LEVEL_FINAL_FIELD_SET_IF_NULL,
- VISIT_TOP_LEVEL_FINAL_FIELD_POSTFIX,
- VISIT_TOP_LEVEL_FINAL_FIELD_PREFIX,
- VISIT_TOP_LEVEL_GETTER_GET,
- VISIT_TOP_LEVEL_GETTER_SET,
- VISIT_TOP_LEVEL_GETTER_INVOKE,
- VISIT_TOP_LEVEL_SETTER_GET,
- VISIT_TOP_LEVEL_SETTER_SET,
- VISIT_TOP_LEVEL_SETTER_INVOKE,
- VISIT_TOP_LEVEL_GETTER_SETTER_COMPOUND,
- VISIT_TOP_LEVEL_GETTER_SETTER_SET_IF_NULL,
- VISIT_TOP_LEVEL_GETTER_SETTER_PREFIX,
- VISIT_TOP_LEVEL_GETTER_SETTER_POSTFIX,
- VISIT_TOP_LEVEL_GETTER_DECL,
- VISIT_TOP_LEVEL_SETTER_DECL,
- VISIT_TOP_LEVEL_FUNCTION_GET,
- VISIT_TOP_LEVEL_FUNCTION_SET,
- VISIT_TOP_LEVEL_FUNCTION_INVOKE,
- VISIT_TOP_LEVEL_FUNCTION_INCOMPATIBLE_INVOKE,
- VISIT_TOP_LEVEL_FUNCTION_DECL,
- VISIT_TOP_LEVEL_METHOD_SETTER_COMPOUND,
- VISIT_TOP_LEVEL_METHOD_SETTER_SET_IF_NULL,
- VISIT_TOP_LEVEL_METHOD_SETTER_PREFIX,
- VISIT_TOP_LEVEL_METHOD_SETTER_POSTFIX,
- VISIT_UNRESOLVED_TOP_LEVEL_GETTER_COMPOUND,
- VISIT_UNRESOLVED_TOP_LEVEL_GETTER_SET_IF_NULL,
- VISIT_UNRESOLVED_TOP_LEVEL_SETTER_COMPOUND,
- VISIT_UNRESOLVED_TOP_LEVEL_SETTER_SET_IF_NULL,
- VISIT_TOP_LEVEL_METHOD_COMPOUND,
- VISIT_TOP_LEVEL_METHOD_SET_IF_NULL,
- VISIT_UNRESOLVED_TOP_LEVEL_GETTER_PREFIX,
- VISIT_UNRESOLVED_TOP_LEVEL_SETTER_PREFIX,
- VISIT_TOP_LEVEL_METHOD_PREFIX,
- VISIT_UNRESOLVED_TOP_LEVEL_GETTER_POSTFIX,
- VISIT_UNRESOLVED_TOP_LEVEL_SETTER_POSTFIX,
- VISIT_TOP_LEVEL_METHOD_POSTFIX,
- VISIT_DYNAMIC_PROPERTY_GET,
- VISIT_DYNAMIC_PROPERTY_SET,
- VISIT_DYNAMIC_PROPERTY_INVOKE,
- VISIT_DYNAMIC_PROPERTY_COMPOUND,
- VISIT_DYNAMIC_PROPERTY_SET_IF_NULL,
- VISIT_DYNAMIC_PROPERTY_PREFIX,
- VISIT_DYNAMIC_PROPERTY_POSTFIX,
- VISIT_THIS_GET,
- VISIT_THIS_INVOKE,
- VISIT_THIS_PROPERTY_GET,
- VISIT_THIS_PROPERTY_SET,
- VISIT_THIS_PROPERTY_INVOKE,
- VISIT_THIS_PROPERTY_COMPOUND,
- VISIT_THIS_PROPERTY_SET_IF_NULL,
- VISIT_THIS_PROPERTY_PREFIX,
- VISIT_THIS_PROPERTY_POSTFIX,
- VISIT_SUPER_FIELD_GET,
- VISIT_SUPER_FIELD_SET,
- VISIT_FINAL_SUPER_FIELD_SET,
- VISIT_SUPER_FIELD_INVOKE,
- VISIT_SUPER_FIELD_COMPOUND,
- VISIT_SUPER_FIELD_SET_IF_NULL,
- VISIT_SUPER_FIELD_PREFIX,
- VISIT_SUPER_FIELD_POSTFIX,
- VISIT_SUPER_FINAL_FIELD_COMPOUND,
- VISIT_SUPER_FINAL_FIELD_SET_IF_NULL,
- VISIT_SUPER_FINAL_FIELD_PREFIX,
- VISIT_SUPER_FINAL_FIELD_POSTFIX,
- VISIT_SUPER_FIELD_FIELD_COMPOUND,
- VISIT_SUPER_FIELD_FIELD_SET_IF_NULL,
- VISIT_SUPER_FIELD_FIELD_PREFIX,
- VISIT_SUPER_FIELD_FIELD_POSTFIX,
- VISIT_SUPER_GETTER_GET,
- VISIT_SUPER_GETTER_SET,
- VISIT_SUPER_GETTER_INVOKE,
- VISIT_SUPER_SETTER_GET,
- VISIT_SUPER_SETTER_SET,
- VISIT_SUPER_SETTER_INVOKE,
- VISIT_SUPER_GETTER_SETTER_COMPOUND,
- VISIT_SUPER_GETTER_SETTER_SET_IF_NULL,
- VISIT_SUPER_GETTER_FIELD_COMPOUND,
- VISIT_SUPER_GETTER_FIELD_SET_IF_NULL,
- VISIT_SUPER_FIELD_SETTER_COMPOUND,
- VISIT_SUPER_FIELD_SETTER_SET_IF_NULL,
- VISIT_SUPER_GETTER_SETTER_PREFIX,
- VISIT_SUPER_GETTER_FIELD_PREFIX,
- VISIT_SUPER_FIELD_SETTER_PREFIX,
- VISIT_SUPER_GETTER_SETTER_POSTFIX,
- VISIT_SUPER_GETTER_FIELD_POSTFIX,
- VISIT_SUPER_FIELD_SETTER_POSTFIX,
- VISIT_SUPER_METHOD_GET,
- VISIT_SUPER_METHOD_SET,
- VISIT_SUPER_METHOD_INVOKE,
- VISIT_SUPER_METHOD_INCOMPATIBLE_INVOKE,
- VISIT_SUPER_METHOD_SETTER_COMPOUND,
- VISIT_SUPER_METHOD_SETTER_SET_IF_NULL,
- VISIT_SUPER_METHOD_SETTER_PREFIX,
- VISIT_SUPER_METHOD_SETTER_POSTFIX,
- VISIT_SUPER_METHOD_COMPOUND,
- VISIT_SUPER_METHOD_SET_IF_NULL,
- VISIT_SUPER_METHOD_PREFIX,
- VISIT_SUPER_METHOD_POSTFIX,
- VISIT_UNRESOLVED_GET,
- VISIT_UNRESOLVED_SET,
- VISIT_UNRESOLVED_INVOKE,
- VISIT_UNRESOLVED_SUPER_GET,
- VISIT_UNRESOLVED_SUPER_INVOKE,
- VISIT_UNRESOLVED_SUPER_SET,
- VISIT_BINARY,
- VISIT_INDEX,
- VISIT_EQUALS,
- VISIT_NOT_EQUALS,
- VISIT_INDEX_PREFIX,
- VISIT_INDEX_POSTFIX,
- VISIT_SUPER_BINARY,
- VISIT_UNRESOLVED_SUPER_BINARY,
- VISIT_SUPER_INDEX,
- VISIT_UNRESOLVED_SUPER_INDEX,
- VISIT_SUPER_EQUALS,
- VISIT_SUPER_NOT_EQUALS,
- VISIT_SUPER_INDEX_PREFIX,
- VISIT_UNRESOLVED_SUPER_GETTER_COMPOUND,
- VISIT_UNRESOLVED_SUPER_GETTER_SET_IF_NULL,
- VISIT_UNRESOLVED_SUPER_SETTER_COMPOUND,
- VISIT_UNRESOLVED_SUPER_SETTER_SET_IF_NULL,
- VISIT_UNRESOLVED_SUPER_GETTER_PREFIX,
- VISIT_UNRESOLVED_SUPER_SETTER_PREFIX,
- VISIT_UNRESOLVED_SUPER_INDEX_PREFIX,
- VISIT_UNRESOLVED_SUPER_GETTER_INDEX_PREFIX,
- VISIT_UNRESOLVED_SUPER_SETTER_INDEX_PREFIX,
- VISIT_SUPER_INDEX_POSTFIX,
- VISIT_UNRESOLVED_SUPER_GETTER_POSTFIX,
- VISIT_UNRESOLVED_SUPER_SETTER_POSTFIX,
- VISIT_UNRESOLVED_SUPER_INDEX_POSTFIX,
- VISIT_UNRESOLVED_SUPER_GETTER_INDEX_POSTFIX,
- VISIT_UNRESOLVED_SUPER_SETTER_INDEX_POSTFIX,
- VISIT_UNRESOLVED_SUPER_COMPOUND,
- VISIT_UNRESOLVED_SUPER_SET_IF_NULL,
- VISIT_UNRESOLVED_SUPER_PREFIX,
- VISIT_UNRESOLVED_SUPER_POSTFIX,
- VISIT_UNARY,
- VISIT_SUPER_UNARY,
- VISIT_UNRESOLVED_SUPER_UNARY,
- VISIT_NOT,
- VISIT_EXPRESSION_INVOKE,
- VISIT_CLASS_TYPE_LITERAL_GET,
- VISIT_CLASS_TYPE_LITERAL_SET,
- VISIT_CLASS_TYPE_LITERAL_INVOKE,
- VISIT_CLASS_TYPE_LITERAL_COMPOUND,
- VISIT_CLASS_TYPE_LITERAL_SET_IF_NULL,
- VISIT_CLASS_TYPE_LITERAL_PREFIX,
- VISIT_CLASS_TYPE_LITERAL_POSTFIX,
- VISIT_TYPEDEF_TYPE_LITERAL_GET,
- VISIT_TYPEDEF_TYPE_LITERAL_SET,
- VISIT_TYPEDEF_TYPE_LITERAL_INVOKE,
- VISIT_TYPEDEF_TYPE_LITERAL_COMPOUND,
- VISIT_TYPEDEF_TYPE_LITERAL_SET_IF_NULL,
- VISIT_TYPEDEF_TYPE_LITERAL_PREFIX,
- VISIT_TYPEDEF_TYPE_LITERAL_POSTFIX,
- VISIT_TYPE_VARIABLE_TYPE_LITERAL_GET,
- VISIT_TYPE_VARIABLE_TYPE_LITERAL_SET,
- VISIT_TYPE_VARIABLE_TYPE_LITERAL_INVOKE,
- VISIT_TYPE_VARIABLE_TYPE_LITERAL_COMPOUND,
- VISIT_TYPE_VARIABLE_TYPE_LITERAL_SET_IF_NULL,
- VISIT_TYPE_VARIABLE_TYPE_LITERAL_PREFIX,
- VISIT_TYPE_VARIABLE_TYPE_LITERAL_POSTFIX,
- VISIT_DYNAMIC_TYPE_LITERAL_GET,
- VISIT_DYNAMIC_TYPE_LITERAL_SET,
- VISIT_DYNAMIC_TYPE_LITERAL_INVOKE,
- VISIT_DYNAMIC_TYPE_LITERAL_COMPOUND,
- VISIT_DYNAMIC_TYPE_LITERAL_SET_IF_NULL,
- VISIT_DYNAMIC_TYPE_LITERAL_PREFIX,
- VISIT_DYNAMIC_TYPE_LITERAL_POSTFIX,
- VISIT_INDEX_SET,
- VISIT_COMPOUND_INDEX_SET,
- VISIT_SUPER_INDEX_SET,
- VISIT_UNRESOLVED_SUPER_INDEX_SET,
- VISIT_SUPER_COMPOUND_INDEX_SET,
- VISIT_UNRESOLVED_SUPER_COMPOUND_INDEX_SET,
- VISIT_UNRESOLVED_SUPER_GETTER_COMPOUND_INDEX_SET,
- VISIT_UNRESOLVED_SUPER_SETTER_COMPOUND_INDEX_SET,
- VISIT_INDEX_SET_IF_NULL,
- VISIT_SUPER_INDEX_SET_IF_NULL,
- VISIT_UNRESOLVED_SUPER_INDEX_SET_IF_NULL,
- VISIT_UNRESOLVED_SUPER_GETTER_INDEX_SET_IF_NULL,
- VISIT_UNRESOLVED_SUPER_SETTER_INDEX_SET_IF_NULL,
- VISIT_LOGICAL_AND,
- VISIT_LOGICAL_OR,
- VISIT_IS,
- VISIT_IS_NOT,
- VISIT_AS,
- VISIT_CONST_CONSTRUCTOR_INVOKE,
- VISIT_BOOL_FROM_ENVIRONMENT_CONSTRUCTOR_INVOKE,
- VISIT_INT_FROM_ENVIRONMENT_CONSTRUCTOR_INVOKE,
- VISIT_STRING_FROM_ENVIRONMENT_CONSTRUCTOR_INVOKE,
- VISIT_GENERATIVE_CONSTRUCTOR_INVOKE,
- VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_INVOKE,
- VISIT_FACTORY_CONSTRUCTOR_INVOKE,
- VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- VISIT_CONSTRUCTOR_INCOMPATIBLE_INVOKE,
- ERROR_NON_CONSTANT_CONSTRUCTOR_INVOKE,
- VISIT_SUPER_CONSTRUCTOR_INVOKE,
- VISIT_IMPLICIT_SUPER_CONSTRUCTOR_INVOKE,
- VISIT_THIS_CONSTRUCTOR_INVOKE,
- VISIT_FIELD_INITIALIZER,
- VISIT_UNRESOLVED_CLASS_CONSTRUCTOR_INVOKE,
- VISIT_UNRESOLVED_CONSTRUCTOR_INVOKE,
- VISIT_ABSTRACT_CLASS_CONSTRUCTOR_INVOKE,
- VISIT_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- VISIT_INSTANCE_GETTER_DECL,
- VISIT_INSTANCE_SETTER_DECL,
- VISIT_INSTANCE_METHOD_DECL,
- VISIT_ABSTRACT_GETTER_DECL,
- VISIT_ABSTRACT_SETTER_DECL,
- VISIT_ABSTRACT_METHOD_DECL,
- VISIT_INSTANCE_FIELD_DECL,
- VISIT_GENERATIVE_CONSTRUCTOR_DECL,
- VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_DECL,
- VISIT_FACTORY_CONSTRUCTOR_DECL,
- VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
- VISIT_REQUIRED_PARAMETER_DECL,
- VISIT_OPTIONAL_PARAMETER_DECL,
- VISIT_NAMED_PARAMETER_DECL,
- VISIT_REQUIRED_INITIALIZING_FORMAL_DECL,
- VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL,
- VISIT_NAMED_INITIALIZING_FORMAL_DECL,
- VISIT_UNRESOLVED_COMPOUND,
- VISIT_UNRESOLVED_SET_IF_NULL,
- VISIT_UNRESOLVED_PREFIX,
- VISIT_UNRESOLVED_POSTFIX,
- VISIT_IF_NULL,
- VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_GET,
- VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET,
- VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_INVOKE,
- VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_COMPOUND,
- VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET_IF_NULL,
- VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_PREFIX,
- VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_POSTFIX,
- ERROR_UNDEFINED_UNARY_EXPRESSION,
- ERROR_UNDEFINED_BINARY_EXPRESSION,
- ERROR_INVALID_GET,
- ERROR_INVALID_INVOKE,
- ERROR_INVALID_SET,
- ERROR_INVALID_PREFIX,
- ERROR_INVALID_POSTFIX,
- ERROR_INVALID_COMPOUND,
- ERROR_INVALID_SET_IF_NULL,
- ERROR_INVALID_UNARY,
- ERROR_INVALID_EQUALS,
- ERROR_INVALID_NOT_EQUALS,
- ERROR_INVALID_BINARY,
- ERROR_INVALID_INDEX,
- ERROR_INVALID_INDEX_SET,
- ERROR_INVALID_COMPOUND_INDEX_SET,
- ERROR_INVALID_INDEX_PREFIX,
- ERROR_INVALID_INDEX_POSTFIX,
- VISIT_CONSTANT_GET,
- VISIT_CONSTANT_INVOKE,
- PREVISIT_DEFERRED_ACCESS,
-}
diff --git a/tests/compiler/dart2js/old_frontend/semantic_visitor_test_decl_data.dart b/tests/compiler/dart2js/old_frontend/semantic_visitor_test_decl_data.dart
deleted file mode 100644
index 6a51b43..0000000
--- a/tests/compiler/dart2js/old_frontend/semantic_visitor_test_decl_data.dart
+++ /dev/null
@@ -1,625 +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.
-
-part of dart2js.semantics_visitor_test;
-
-const Map<String, List<Test>> DECL_TESTS = const {
- 'Function declarations': const [
- const Test('''
- m(a, b) {}
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '(a,b)', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#b)', index: 1),
- ]),
- const Test('''
- m(a, [b]) {}
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '(a,[b])', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
- element: 'parameter(m#b)', index: 1, constant: 'null'),
- ]),
- const Test('''
- m(a, [b = null]) {}
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '(a,[b=null])', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
- element: 'parameter(m#b)', constant: 'null', index: 1),
- ]),
- const Test('''
- m(a, [b = 42]) {}
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '(a,[b=42])', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
- element: 'parameter(m#b)', constant: 42, index: 1),
- ]),
- const Test('''
- m(a, {b}) {}
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '(a,{b})', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
- element: 'parameter(m#b)', constant: 'null'),
- ]),
- const Test('''
- m(a, {b: null}) {}
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '(a,{b: null})', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
- element: 'parameter(m#b)', constant: 'null'),
- ]),
- const Test('''
- m(a, {b:42}) {}
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '(a,{b: 42})', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
- element: 'parameter(m#b)', constant: 42),
- ]),
- const Test('''
- get m => null;
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_DECL,
- element: 'getter(m)', body: '=>null;'),
- ]),
- const Test('''
- set m(a) {}
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_DECL,
- element: 'setter(m)', parameters: '(a)', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- ]),
- const Test.clazz('''
- class C {
- static m(a, b) {}
- }
- ''', const [
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_DECL,
- element: 'function(C#m)', parameters: '(a,b)', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#b)', index: 1),
- ]),
- const Test.clazz('''
- class C {
- static get m => null;
- }
- ''', const [
- const Visit(VisitKind.VISIT_STATIC_GETTER_DECL,
- element: 'getter(C#m)', body: '=>null;'),
- ]),
- const Test.clazz('''
- class C {
- static set m(a) {}
- }
- ''', const [
- const Visit(VisitKind.VISIT_STATIC_SETTER_DECL,
- element: 'setter(C#m)', parameters: '(a)', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- ]),
- const Test.clazz('''
- class C {
- m(a, b) {}
- }
- ''', const [
- const Visit(VisitKind.VISIT_INSTANCE_METHOD_DECL,
- element: 'function(C#m)', parameters: '(a,b)', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#b)', index: 1),
- ]),
- const Test.clazz('''
- class C {
- get m => null;
- }
- ''', const [
- const Visit(VisitKind.VISIT_INSTANCE_GETTER_DECL,
- element: 'getter(C#m)', body: '=>null;'),
- ]),
- const Test.clazz('''
- class C {
- set m(a) {}
- }
- ''', const [
- const Visit(VisitKind.VISIT_INSTANCE_SETTER_DECL,
- element: 'setter(C#m)', parameters: '(a)', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- ]),
- const Test.clazz('''
- abstract class C {
- m(a, b);
- }
- ''', const [
- const Visit(VisitKind.VISIT_ABSTRACT_METHOD_DECL,
- element: 'function(C#m)', parameters: '(a,b)'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#b)', index: 1),
- ]),
- const Test.clazz('''
- abstract class C {
- get m;
- }
- ''', const [
- const Visit(VisitKind.VISIT_ABSTRACT_GETTER_DECL, element: 'getter(C#m)'),
- ]),
- const Test.clazz('''
- abstract class C {
- set m(a);
- }
- ''', const [
- const Visit(VisitKind.VISIT_ABSTRACT_SETTER_DECL,
- element: 'setter(C#m)', parameters: '(a)'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- ]),
- const Test('''
- m(a, b) {}
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '(a,b)', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(m#b)', index: 1),
- ]),
- const Test('''
- m() {
- local(a, b) {}
- }
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '()', body: '{local(a,b){}}'),
- const Visit(VisitKind.VISIT_LOCAL_FUNCTION_DECL,
- element: 'function(m#local)', parameters: '(a,b)', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(local#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(local#b)', index: 1),
- ]),
- const Test('''
- m() => (a, b) {};
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '()', body: '=>(a,b){};'),
- const Visit(VisitKind.VISIT_CLOSURE_DECL,
- element: 'function(m#)', parameters: '(a,b)', body: '{}'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- ]),
- ],
- 'Constructor declarations': const [
- const Test.clazz('''
- class C {
- C(a, b);
- }
- ''', const [
- const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
- element: 'generative_constructor(C#)',
- parameters: '(a,b)',
- body: ';'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- const Visit(VisitKind.VISIT_IMPLICIT_SUPER_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Object#)', type: 'Object'),
- ], method: ''),
- const Test.clazz('''
- class C {
- var b;
- C(a, this.b);
- }
- ''', const [
- const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
- element: 'generative_constructor(C#)',
- parameters: '(a,this.b)',
- body: ';'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_INITIALIZING_FORMAL_DECL,
- element: 'initializing_formal(#b)', index: 1),
- const Visit(VisitKind.VISIT_IMPLICIT_SUPER_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Object#)', type: 'Object'),
- ], method: ''),
- const Test.clazz('''
- class C {
- var b;
- C(a, [this.b = 42]);
- }
- ''', const [
- const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
- element: 'generative_constructor(C#)',
- parameters: '(a,[this.b=42])',
- body: ';'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL,
- element: 'initializing_formal(#b)', constant: 42, index: 1),
- const Visit(VisitKind.VISIT_IMPLICIT_SUPER_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Object#)', type: 'Object'),
- ], method: ''),
- const Test.clazz('''
- class C {
- var b;
- C(a, {this.b: 42});
- }
- ''', const [
- const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
- element: 'generative_constructor(C#)',
- parameters: '(a,{this.b: 42})',
- body: ';'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_NAMED_INITIALIZING_FORMAL_DECL,
- element: 'initializing_formal(#b)', constant: 42),
- const Visit(VisitKind.VISIT_IMPLICIT_SUPER_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Object#)', type: 'Object'),
- ], method: ''),
- const Test.clazz('''
- class C {
- C(a, b) : super();
- }
- ''', const [
- const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
- element: 'generative_constructor(C#)',
- parameters: '(a,b)',
- body: ';'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- const Visit(VisitKind.VISIT_SUPER_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Object#)',
- type: 'Object',
- arguments: '()',
- selector: 'CallStructure(arity=0)'),
- ], method: ''),
- const Test.clazz('''
- class C {
- var field;
- C(a, b) : this.field = a;
- }
- ''', const [
- const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
- element: 'generative_constructor(C#)',
- parameters: '(a,b)',
- body: ';'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- const Visit(VisitKind.VISIT_FIELD_INITIALIZER,
- element: 'field(C#field)', rhs: 'a'),
- const Visit(VisitKind.VISIT_IMPLICIT_SUPER_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Object#)', type: 'Object'),
- ], method: ''),
- const Test.clazz('''
- class C {
- var field1;
- var field2;
- C(a, b) : this.field1 = a, this.field2 = b;
- }
- ''', const [
- const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
- element: 'generative_constructor(C#)',
- parameters: '(a,b)',
- body: ';'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- const Visit(VisitKind.VISIT_FIELD_INITIALIZER,
- element: 'field(C#field1)', rhs: 'a'),
- const Visit(VisitKind.VISIT_FIELD_INITIALIZER,
- element: 'field(C#field2)', rhs: 'b'),
- const Visit(VisitKind.VISIT_IMPLICIT_SUPER_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Object#)', type: 'Object'),
- ], method: ''),
- const Test.clazz('''
- class C {
- C(a, b) : this._(a, b);
- C._(a, b);
- }
- ''', const [
- const Visit(VisitKind.VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_DECL,
- element: 'generative_constructor(C#)',
- parameters: '(a,b)',
- initializers: ':this._(a,b)'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- const Visit(VisitKind.VISIT_THIS_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(C#_)',
- arguments: '(a,b)',
- selector: 'CallStructure(arity=2)'),
- ], method: ''),
- const Test.clazz('''
- class C {
- factory C(a, b) => null;
- }
- ''', const [
- const Visit(VisitKind.VISIT_FACTORY_CONSTRUCTOR_DECL,
- element: 'factory_constructor(C#)',
- parameters: '(a,b)',
- body: '=>null;'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- ], method: ''),
- const Test.clazz('''
- class C {
- factory C(a, b) = C._;
- C._(a, b);
- }
- ''', const [
- const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
- element: 'factory_constructor(C#)',
- parameters: '(a,b)',
- target: 'generative_constructor(C#_)',
- type: 'C'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- ], method: ''),
- const Test.clazz('''
- class C {
- factory C(a, b) = D;
- }
- class D<T> {
- D(a, b);
- }
- ''', const [
- const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
- element: 'factory_constructor(C#)',
- parameters: '(a,b)',
- target: 'generative_constructor(D#)',
- type: 'D'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- ], method: ''),
- const Test.clazz('''
- class C {
- factory C(a, b) = D<int>;
- }
- class D<T> {
- D(a, b);
- }
- ''', const [
- const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
- element: 'factory_constructor(C#)',
- parameters: '(a,b)',
- target: 'generative_constructor(D#)',
- type: 'D<int>'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- ], method: ''),
- const Test.clazz('''
- class C {
- factory C(a, b) = D<int>;
- }
- class D<T> {
- factory D(a, b) = E<D<T>>;
- }
- class E<S> {
- E(a, b);
- }
- ''', const [
- const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
- element: 'factory_constructor(C#)',
- parameters: '(a,b)',
- target: 'factory_constructor(D#)',
- type: 'D<int>'),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#a)', index: 0),
- const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: 'parameter(#b)', index: 1),
- ], method: ''),
- ],
- "Field declarations": const [
- const Test.clazz('''
- class C {
- var m;
- }
- ''', const [
- const Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL, element: 'field(C#m)'),
- ]),
- const Test.clazz('''
- class C {
- var m, n;
- }
- ''', const [
- const Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL, element: 'field(C#m)'),
- const Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL, element: 'field(C#n)'),
- ]),
- const Test.clazz('''
- class C {
- var m = 42;
- }
- ''', const [
- const Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL,
- element: 'field(C#m)', rhs: 42),
- ]),
- const Test('''
- m() {
- var local;
- }
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '()', body: '{var local;}'),
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
- element: 'variable(m#local)'),
- ]),
- const Test('''
- m() {
- var local = 42;
- }
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '()', body: '{var local=42;}'),
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
- element: 'variable(m#local)', rhs: 42),
- ]),
- const Test('''
- m() {
- const local = 42;
- }
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)', parameters: '()', body: '{const local=42;}'),
- const Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
- element: 'variable(m#local)', constant: 42),
- ]),
- const Test('''
- m() {
- var local1, local2;
- }
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)',
- parameters: '()',
- body: '{var local1,local2;}'),
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
- element: 'variable(m#local1)'),
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
- element: 'variable(m#local2)'),
- ]),
- const Test('''
- m() {
- var local1 = 42, local2 = true;
- }
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)',
- parameters: '()',
- body: '{var local1=42,local2=true;}'),
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
- element: 'variable(m#local1)', rhs: 42),
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
- element: 'variable(m#local2)', rhs: true),
- ]),
- const Test('''
- m() {
- const local1 = 42, local2 = true;
- }
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: 'function(m)',
- parameters: '()',
- body: '{const local1=42,local2=true;}'),
- const Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
- element: 'variable(m#local1)', constant: 42),
- const Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
- element: 'variable(m#local2)', constant: true),
- ]),
- const Test.clazz('''
- class C {
- static var m;
- }
- ''', const [
- const Visit(VisitKind.VISIT_STATIC_FIELD_DECL, element: 'field(C#m)'),
- ]),
- const Test.clazz('''
- class C {
- static var m, n;
- }
- ''', const [
- const Visit(VisitKind.VISIT_STATIC_FIELD_DECL, element: 'field(C#m)'),
- const Visit(VisitKind.VISIT_STATIC_FIELD_DECL, element: 'field(C#n)'),
- ]),
- const Test.clazz('''
- class C {
- static var k, l, m, n;
- }
- ''', const [
- const Visit(VisitKind.VISIT_STATIC_FIELD_DECL, element: 'field(C#k)'),
- const Visit(VisitKind.VISIT_STATIC_FIELD_DECL, element: 'field(C#l)'),
- const Visit(VisitKind.VISIT_STATIC_FIELD_DECL, element: 'field(C#m)'),
- const Visit(VisitKind.VISIT_STATIC_FIELD_DECL, element: 'field(C#n)'),
- ]),
- const Test.clazz('''
- class C {
- static var m = 42;
- }
- ''', const [
- const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
- element: 'field(C#m)', rhs: 42),
- ]),
- const Test.clazz('''
- class C {
- static var m = 42, n = true;
- }
- ''', const [
- const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
- element: 'field(C#m)', rhs: 42),
- const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
- element: 'field(C#n)', rhs: true),
- ]),
- const Test.clazz('''
- class C {
- static const m = 42;
- }
- ''', const [
- const Visit(VisitKind.VISIT_STATIC_CONSTANT_DECL,
- element: 'field(C#m)', constant: 42),
- ]),
- const Test('''
- var m;
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL, element: 'field(m)'),
- ]),
- const Test('''
- var m, n;
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL, element: 'field(m)'),
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL, element: 'field(n)'),
- ]),
- const Test('''
- var m = 42;
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL,
- element: 'field(m)', rhs: 42),
- ]),
- const Test('''
- const m = 42;
- ''', const [
- const Visit(VisitKind.VISIT_TOP_LEVEL_CONSTANT_DECL,
- element: 'field(m)', constant: 42),
- ]),
- ],
-};
diff --git a/tests/compiler/dart2js/old_frontend/semantic_visitor_test_decl_visitor.dart b/tests/compiler/dart2js/old_frontend/semantic_visitor_test_decl_visitor.dart
deleted file mode 100644
index 41055c6..0000000
--- a/tests/compiler/dart2js/old_frontend/semantic_visitor_test_decl_visitor.dart
+++ /dev/null
@@ -1,370 +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.
-
-part of dart2js.semantics_visitor_test;
-
-class SemanticDeclarationTestVisitor extends SemanticTestVisitor {
- SemanticDeclarationTestVisitor(TreeElements elements) : super(elements);
-
- @override
- errorUnresolvedSuperConstructorInvoke(
- Send node, Element element, NodeList arguments, Selector selector, arg) {
- // TODO: implement errorUnresolvedSuperConstructorInvoke
- }
-
- @override
- errorUnresolvedThisConstructorInvoke(
- Send node, Element element, NodeList arguments, Selector selector, arg) {
- // TODO: implement errorUnresolvedThisConstructorInvoke
- }
-
- @override
- visitAbstractMethodDeclaration(
- FunctionExpression node, MethodElement method, NodeList parameters, arg) {
- visits.add(new Visit(VisitKind.VISIT_ABSTRACT_METHOD_DECL,
- element: method, parameters: parameters));
- applyParameters(parameters, arg);
- }
-
- @override
- visitClosureDeclaration(FunctionExpression node,
- LocalFunctionElement function, NodeList parameters, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_CLOSURE_DECL,
- element: function, parameters: parameters, body: body));
- applyParameters(parameters, arg);
- apply(body, arg);
- }
-
- @override
- visitFactoryConstructorDeclaration(FunctionExpression node,
- ConstructorElement constructor, NodeList parameters, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_FACTORY_CONSTRUCTOR_DECL,
- element: constructor, parameters: parameters, body: body));
- applyParameters(parameters, arg);
- apply(body, arg);
- }
-
- @override
- visitFieldInitializer(
- SendSet node, FieldElement field, Node initializer, arg) {
- visits.add(new Visit(VisitKind.VISIT_FIELD_INITIALIZER,
- element: field, rhs: initializer));
- apply(initializer, arg);
- }
-
- @override
- visitGenerativeConstructorDeclaration(
- FunctionExpression node,
- ConstructorElement constructor,
- NodeList parameters,
- NodeList initializers,
- Node body,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
- element: constructor, parameters: parameters, body: body));
- applyParameters(parameters, arg);
- applyInitializers(node, arg);
- apply(body, arg);
- }
-
- @override
- visitInstanceMethodDeclaration(FunctionExpression node, MethodElement method,
- NodeList parameters, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_INSTANCE_METHOD_DECL,
- element: method, parameters: parameters, body: body));
- applyParameters(parameters, arg);
- apply(body, arg);
- }
-
- @override
- visitLocalFunctionDeclaration(FunctionExpression node,
- LocalFunctionElement function, NodeList parameters, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_DECL,
- element: function, parameters: parameters, body: body));
- applyParameters(parameters, arg);
- apply(body, arg);
- }
-
- @override
- visitRedirectingFactoryConstructorDeclaration(
- FunctionExpression node,
- ConstructorElement constructor,
- NodeList parameters,
- ResolutionInterfaceType redirectionType,
- ConstructorElement redirectionTarget,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
- element: constructor,
- parameters: parameters,
- target: redirectionTarget,
- type: redirectionType));
- applyParameters(parameters, arg);
- }
-
- @override
- visitRedirectingGenerativeConstructorDeclaration(
- FunctionExpression node,
- ConstructorElement constructor,
- NodeList parameters,
- NodeList initializers,
- arg) {
- visits.add(new Visit(
- VisitKind.VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_DECL,
- element: constructor,
- parameters: parameters,
- initializers: initializers));
- applyParameters(parameters, arg);
- applyInitializers(node, arg);
- }
-
- @override
- visitStaticFunctionDeclaration(FunctionExpression node,
- MethodElement function, NodeList parameters, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FUNCTION_DECL,
- element: function, parameters: parameters, body: body));
- applyParameters(parameters, arg);
- apply(body, arg);
- }
-
- @override
- visitSuperConstructorInvoke(
- Send node,
- ConstructorElement superConstructor,
- ResolutionInterfaceType type,
- NodeList arguments,
- CallStructure callStructure,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_CONSTRUCTOR_INVOKE,
- element: superConstructor,
- type: type,
- arguments: arguments,
- selector: callStructure));
- super.visitSuperConstructorInvoke(
- node, superConstructor, type, arguments, callStructure, arg);
- }
-
- @override
- visitImplicitSuperConstructorInvoke(FunctionExpression node,
- ConstructorElement superConstructor, ResolutionInterfaceType type, arg) {
- visits.add(new Visit(VisitKind.VISIT_IMPLICIT_SUPER_CONSTRUCTOR_INVOKE,
- element: superConstructor, type: type));
- super
- .visitImplicitSuperConstructorInvoke(node, superConstructor, type, arg);
- }
-
- @override
- visitThisConstructorInvoke(Send node, ConstructorElement thisConstructor,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_THIS_CONSTRUCTOR_INVOKE,
- element: thisConstructor,
- arguments: arguments,
- selector: callStructure));
- super.visitThisConstructorInvoke(
- node, thisConstructor, arguments, callStructure, arg);
- }
-
- @override
- visitTopLevelFunctionDeclaration(FunctionExpression node,
- MethodElement function, NodeList parameters, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
- element: function, parameters: parameters, body: body));
- applyParameters(parameters, arg);
- apply(body, arg);
- }
-
- @override
- errorUnresolvedFieldInitializer(
- SendSet node, Element element, Node initializer, arg) {
- // TODO: implement errorUnresolvedFieldInitializer
- }
-
- @override
- visitOptionalParameterDeclaration(
- VariableDefinitions node,
- Node definition,
- ParameterElement parameter,
- ConstantExpression defaultValue,
- int index,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
- element: parameter,
- constant: defaultValue != null ? defaultValue.toDartText() : null,
- index: index));
- }
-
- @override
- visitParameterDeclaration(VariableDefinitions node, Node definition,
- ParameterElement parameter, int index, arg) {
- visits.add(new Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
- element: parameter, index: index));
- }
-
- @override
- visitInitializingFormalDeclaration(VariableDefinitions node, Node definition,
- InitializingFormalElement initializingFormal, int index, arg) {
- visits.add(new Visit(VisitKind.VISIT_REQUIRED_INITIALIZING_FORMAL_DECL,
- element: initializingFormal, index: index));
- }
-
- @override
- visitLocalVariableDeclaration(VariableDefinitions node, Node definition,
- LocalVariableElement variable, Node initializer, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
- element: variable, rhs: initializer));
- if (initializer != null) {
- apply(initializer, arg);
- }
- }
-
- @override
- visitLocalConstantDeclaration(VariableDefinitions node, Node definition,
- LocalVariableElement variable, ConstantExpression constant, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
- element: variable, constant: constant.toDartText()));
- }
-
- @override
- visitNamedInitializingFormalDeclaration(
- VariableDefinitions node,
- Node definition,
- InitializingFormalElement initializingFormal,
- ConstantExpression defaultValue,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_NAMED_INITIALIZING_FORMAL_DECL,
- element: initializingFormal,
- constant: defaultValue != null ? defaultValue.toDartText() : null));
- }
-
- @override
- visitNamedParameterDeclaration(VariableDefinitions node, Node definition,
- ParameterElement parameter, ConstantExpression defaultValue, arg) {
- visits.add(new Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
- element: parameter,
- constant: defaultValue != null ? defaultValue.toDartText() : null));
- }
-
- @override
- visitOptionalInitializingFormalDeclaration(
- VariableDefinitions node,
- Node definition,
- InitializingFormalElement initializingFormal,
- ConstantExpression defaultValue,
- int index,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL,
- element: initializingFormal,
- constant: defaultValue != null ? defaultValue.toDartText() : null,
- index: index));
- }
-
- @override
- visitInstanceFieldDeclaration(VariableDefinitions node, Node definition,
- FieldElement field, Node initializer, arg) {
- visits.add(new Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL,
- element: field, rhs: initializer));
- if (initializer != null) {
- apply(initializer, arg);
- }
- }
-
- @override
- visitStaticConstantDeclaration(VariableDefinitions node, Node definition,
- FieldElement field, ConstantExpression constant, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_CONSTANT_DECL,
- element: field, constant: constant.toDartText()));
- }
-
- @override
- visitStaticFieldDeclaration(VariableDefinitions node, Node definition,
- FieldElement field, Node initializer, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
- element: field, rhs: initializer));
- if (initializer != null) {
- apply(initializer, arg);
- }
- }
-
- @override
- visitTopLevelConstantDeclaration(VariableDefinitions node, Node definition,
- FieldElement field, ConstantExpression constant, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_CONSTANT_DECL,
- element: field, constant: constant.toDartText()));
- }
-
- @override
- visitTopLevelFieldDeclaration(VariableDefinitions node, Node definition,
- FieldElement field, Node initializer, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL,
- element: field, rhs: initializer));
- if (initializer != null) {
- apply(initializer, arg);
- }
- }
-
- @override
- visitAbstractGetterDeclaration(
- FunctionExpression node, MethodElement getter, arg) {
- visits
- .add(new Visit(VisitKind.VISIT_ABSTRACT_GETTER_DECL, element: getter));
- }
-
- @override
- visitAbstractSetterDeclaration(
- FunctionExpression node, MethodElement setter, NodeList parameters, arg) {
- visits.add(new Visit(VisitKind.VISIT_ABSTRACT_SETTER_DECL,
- element: setter, parameters: parameters));
- applyParameters(parameters, arg);
- }
-
- @override
- visitInstanceGetterDeclaration(
- FunctionExpression node, MethodElement getter, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_INSTANCE_GETTER_DECL,
- element: getter, body: body));
- apply(body, arg);
- }
-
- @override
- visitInstanceSetterDeclaration(FunctionExpression node, MethodElement setter,
- NodeList parameters, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_INSTANCE_SETTER_DECL,
- element: setter, parameters: parameters, body: body));
- applyParameters(parameters, arg);
- apply(body, arg);
- }
-
- @override
- visitTopLevelGetterDeclaration(
- FunctionExpression node, MethodElement getter, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_DECL,
- element: getter, body: body));
- apply(body, arg);
- }
-
- @override
- visitTopLevelSetterDeclaration(FunctionExpression node, MethodElement setter,
- NodeList parameters, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_DECL,
- element: setter, parameters: parameters, body: body));
- applyParameters(parameters, arg);
- apply(body, arg);
- }
-
- @override
- visitStaticGetterDeclaration(
- FunctionExpression node, MethodElement getter, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_DECL,
- element: getter, body: body));
- apply(body, arg);
- }
-
- @override
- visitStaticSetterDeclaration(FunctionExpression node, MethodElement setter,
- NodeList parameters, Node body, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_SETTER_DECL,
- element: setter, parameters: parameters, body: body));
- applyParameters(parameters, arg);
- apply(body, arg);
- }
-}
diff --git a/tests/compiler/dart2js/old_frontend/semantic_visitor_test_send_data.dart b/tests/compiler/dart2js/old_frontend/semantic_visitor_test_send_data.dart
deleted file mode 100644
index b324d78..0000000
--- a/tests/compiler/dart2js/old_frontend/semantic_visitor_test_send_data.dart
+++ /dev/null
@@ -1,4184 +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.
-
-part of dart2js.semantics_visitor_test;
-
-const Map<String, List<Test>> SEND_TESTS = const {
- 'Parameters': const [
- // Parameters
- const Test('m(o) => o;',
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#o)')),
- const Test(
- 'm(o) { o = 42; }',
- const Visit(VisitKind.VISIT_PARAMETER_SET,
- element: 'parameter(m#o)', rhs: '42')),
- const Test(
- 'm(o) { o(null, 42); }',
- const Visit(VisitKind.VISIT_PARAMETER_INVOKE,
- element: 'parameter(m#o)',
- arguments: '(null,42)',
- selector: 'CallStructure(arity=2)')),
- const Test(
- 'm(final o) { o = 42; }',
- const Visit(VisitKind.VISIT_FINAL_PARAMETER_SET,
- element: 'parameter(m#o)', rhs: '42')),
- ],
- 'Local variables': const [
- // Local variables
- const Test(
- 'm() { var o; return o; }',
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_GET,
- element: 'variable(m#o)')),
- const Test(
- 'm() { var o; o = 42; }',
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_SET,
- element: 'variable(m#o)', rhs: '42')),
- const Test(
- 'm() { var o; o(null, 42); }',
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_INVOKE,
- element: 'variable(m#o)',
- arguments: '(null,42)',
- selector: 'CallStructure(arity=2)')),
- const Test(
- 'm() { final o = 0; o = 42; }',
- const Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_SET,
- element: 'variable(m#o)', rhs: '42')),
- const Test(
- 'm() { const o = 0; o = 42; }',
- const Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_SET,
- element: 'variable(m#o)', rhs: '42')),
- ],
- 'Local functions': const [
- // Local functions
- const Test(
- 'm() { o(a, b) {}; return o; }',
- const Visit(VisitKind.VISIT_LOCAL_FUNCTION_GET,
- element: 'function(m#o)')),
- const Test(
- 'm() { o(a, b) {}; o(null, 42); }',
- const Visit(VisitKind.VISIT_LOCAL_FUNCTION_INVOKE,
- element: 'function(m#o)',
- arguments: '(null,42)',
- selector: 'CallStructure(arity=2)')),
- const Test(
- 'm() { o(a) {}; o(null, 42); }',
- const Visit(VisitKind.VISIT_LOCAL_FUNCTION_INCOMPATIBLE_INVOKE,
- element: 'function(m#o)',
- arguments: '(null,42)',
- selector: 'CallStructure(arity=2)')),
- const Test(
- 'm() { o(a, b) {}; o = 42; }',
- const Visit(VisitKind.VISIT_LOCAL_FUNCTION_SET,
- element: 'function(m#o)', rhs: '42')),
- ],
- 'Static fields': const [
- // Static fields
- const Test('''
- class C { static var o; }
- m() => C.o;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#o)')),
- const Test.clazz('''
- class C {
- static var o;
- m() => o;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#o)')),
- const Test.clazz('''
- class C {
- static var o;
- m() => C.o;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#o)')),
- const Test.prefix('''
- class C {
- static var o;
- }
- ''', 'm() => p.C.o;',
- const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#o)')),
- const Test.clazz(
- '''
- class C {
- var o;
- static m() => o;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_GET,
- error: MessageKind.NO_INSTANCE_AVAILABLE)),
- const Test.prefix(
- '''
- class C {
- static var o;
- }
- ''',
- 'm() => p.C.o;',
- const [
- const Visit(VisitKind.PREVISIT_DEFERRED_ACCESS, element: 'prefix(p)'),
- const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#o)'),
- ],
- isDeferred: true),
- const Test('''
- class C {
- var o;
- }
- m() => C.o;
- ''', const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
- const Test('''
- class C {
- var o;
- }
- m() { C.o = 42; }
- ''', const Visit(VisitKind.VISIT_UNRESOLVED_SET, name: 'o', rhs: '42')),
- const Test('''
- class C {
- C.o();
- }
- m() => C.o;
- ''', const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
- const Test.prefix(
- '''
- ''',
- 'm() => p.C.o;',
- const [
- const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_GET,
- receiver: 'p.C', name: 'o'),
- const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'C'),
- ]),
- const Test.prefix('''
- class C {
- }
- ''', 'm() => p.C.o;',
- const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
- const Test.prefix(
- '''
- ''',
- 'm() => p.C.o;',
- const [
- const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_GET,
- receiver: 'p.C', name: 'o'),
- const Visit(VisitKind.PREVISIT_DEFERRED_ACCESS, element: 'prefix(p)'),
- const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'C'),
- ],
- isDeferred: true),
- const Test.prefix(
- '''
- class C {
- }
- ''',
- 'm() => p.C.o;',
- const [
- const Visit(VisitKind.PREVISIT_DEFERRED_ACCESS, element: 'prefix(p)'),
- const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o'),
- ],
- isDeferred: true),
- const Test('''
- class C {}
- m() => C.this;
- ''', null),
- const Test(
- '''
- class C {
- static var o;
- }
- m() { C.o = 42; }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static var o;
- m() { o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static var o;
- m() { C.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static var o;
- }
- ''',
- 'm() { p.C.o = 42; }',
- const Visit(VisitKind.VISIT_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- var o;
- static m() { o = 42; }
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_SET,
- error: MessageKind.NO_INSTANCE_AVAILABLE, rhs: '42')),
- const Test(
- '''
- class C {
- static var o;
- }
- m() { C.o(null, 42); }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE,
- element: 'field(C#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- static var o;
- m() { o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE,
- element: 'field(C#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- static var o;
- m() { C.o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE,
- element: 'field(C#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- var o;
- static m() { o(null, 42); }
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_INVOKE,
- error: MessageKind.NO_INSTANCE_AVAILABLE, arguments: '(null,42)')),
- const Test.prefix(
- '''
- class C {
- static var o;
- }
- ''',
- 'm() { p.C.o(null, 42); }',
- const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE,
- element: 'field(C#o)', arguments: '(null,42)')),
- const Test(
- '''
- class C {}
- m() => C.this(null, 42);
- ''',
- const Visit(VisitKind.ERROR_INVALID_INVOKE,
- error: MessageKind.THIS_PROPERTY, arguments: '(null,42)')),
- const Test(
- '''
- class C { static final o = 0; }
- m() { C.o = 42; }
- ''',
- const Visit(VisitKind.VISIT_FINAL_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static final o = 0;
- m() { o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_FINAL_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static final o = 0;
- m() { C.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_FINAL_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static final o = 0;
- }
- ''',
- 'm() { p.C.o = 42; }',
- const Visit(VisitKind.VISIT_FINAL_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test(
- '''
- class C { static const o = 0; }
- m() { C.o = 42; }
- ''',
- const Visit(VisitKind.VISIT_FINAL_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static const o = 0;
- m() { o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_FINAL_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static const o = 0;
- m() { C.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_FINAL_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static const o = 0;
- }
- ''',
- 'm() { p.C.o = 42; }',
- const Visit(VisitKind.VISIT_FINAL_STATIC_FIELD_SET,
- element: 'field(C#o)', rhs: '42')),
- ],
- 'Static properties': const [
- // Static properties
- const Test('''
- class C {
- static get o => null;
- }
- m() => C.o;
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_GET, element: 'getter(C#o)')),
- const Test.clazz('''
- class C {
- static get o => null;
- m() => o;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_GET, element: 'getter(C#o)')),
- const Test.clazz('''
- class C {
- static get o => null;
- m() => C.o;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_GET, element: 'getter(C#o)')),
- const Test.prefix('''
- class C {
- static get o => null;
- }
- ''', 'm() => p.C.o;',
- const Visit(VisitKind.VISIT_STATIC_GETTER_GET, element: 'getter(C#o)')),
- const Test(
- '''
- class C { static get o => 42; }
- m() { C.o = 42; }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SET,
- element: 'getter(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static get o => 42;
- m() { o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SET,
- element: 'getter(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static get o => 42;
- m() { C.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SET,
- element: 'getter(C#o)', rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static get o => 42;
- }
- ''',
- 'm() { p.C.o = 42; }',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SET,
- element: 'getter(C#o)', rhs: '42')),
- const Test('''
- class C {
- static set o(_) {}
- }
- m() => C.o;
- ''',
- const Visit(VisitKind.VISIT_STATIC_SETTER_GET, element: 'setter(C#o)')),
- const Test.clazz('''
- class C {
- static set o(_) {}
- m() => o;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_SETTER_GET, element: 'setter(C#o)')),
-
- const Test.clazz('''
- class C {
- static set o(_) {}
- m() => C.o;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_SETTER_GET, element: 'setter(C#o)')),
- const Test.prefix('''
- class C {
- static set o(_) {}
- }
- ''', 'm() => p.C.o;',
- const Visit(VisitKind.VISIT_STATIC_SETTER_GET, element: 'setter(C#o)')),
- const Test(
- '''
- class C { static set o(_) {} }
- m() { C.o = 42; }
- ''',
- const Visit(VisitKind.VISIT_STATIC_SETTER_SET,
- element: 'setter(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static set o(_) {}
- m() { o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_SETTER_SET,
- element: 'setter(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static set o(_) {}
- m() { C.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_SETTER_SET,
- element: 'setter(C#o)', rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static set o(_) {}
- }
- ''',
- 'm() { p.C.o = 42; }',
- const Visit(VisitKind.VISIT_STATIC_SETTER_SET,
- element: 'setter(C#o)', rhs: '42')),
- const Test(
- '''
- class C { static get o => null; }
- m() => C.o(null, 42);
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_INVOKE,
- element: 'getter(C#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- static get o => null;
- m() { o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_INVOKE,
- element: 'getter(C#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- static get o => null;
- m() { C.o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_INVOKE,
- element: 'getter(C#o)', arguments: '(null,42)')),
- const Test.prefix(
- '''
- class C {
- static get o => null;
- }
- ''',
- 'm() { p.C.o(null, 42); }',
- const Visit(VisitKind.VISIT_STATIC_GETTER_INVOKE,
- element: 'getter(C#o)', arguments: '(null,42)')),
- const Test(
- '''
- class C { static set o(_) {} }
- m() => C.o(null, 42);
- ''',
- const Visit(VisitKind.VISIT_STATIC_SETTER_INVOKE,
- element: 'setter(C#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- static set o(_) {}
- m() { o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_SETTER_INVOKE,
- element: 'setter(C#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- static set o(_) {}
- m() { C.o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_SETTER_INVOKE,
- element: 'setter(C#o)', arguments: '(null,42)')),
- const Test.prefix(
- '''
- class C {
- static set o(_) {}
- }
- ''',
- 'm() { p.C.o(null, 42); }',
- const Visit(VisitKind.VISIT_STATIC_SETTER_INVOKE,
- element: 'setter(C#o)', arguments: '(null,42)')),
- ],
- 'Static functions': const [
- // Static functions
- const Test(
- '''
- class C { static o(a, b) {} }
- m() => C.o;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_GET,
- element: 'function(C#o)')),
- const Test.clazz(
- '''
- class C {
- static o(a, b) {}
- m() => o;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_GET,
- element: 'function(C#o)')),
- const Test.clazz(
- '''
- class C {
- static o(a, b) {}
- m() => C.o;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_GET,
- element: 'function(C#o)')),
- const Test.prefix(
- '''
- class C { static o(a, b) {} }
- ''',
- '''
- m() => p.C.o;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_GET,
- element: 'function(C#o)')),
- const Test(
- '''
- class C { static o(a, b) {} }
- m() { C.o = 42; }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_SET,
- element: 'function(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static o(a, b) {}
- m() { o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_SET,
- element: 'function(C#o)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static o(a, b) {}
- m() { C.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_SET,
- element: 'function(C#o)', rhs: '42')),
- const Test.prefix(
- '''
- class C { static o(a, b) {} }
- ''',
- '''
- m() { p.C.o = 42; }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_SET,
- element: 'function(C#o)', rhs: '42')),
- const Test(
- '''
- class C { static o(a, b) {} }
- m() => C.o(null, 42);
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_INVOKE,
- element: 'function(C#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- static o(a, b) {}
- m() { o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_INVOKE,
- element: 'function(C#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- static o(a, b) {}
- m() { C.o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_INVOKE,
- element: 'function(C#o)', arguments: '(null,42)')),
- const Test.prefix(
- '''
- class C {
- static o(a, b) {}
- }
- ''',
- 'm() { p.C.o(null, 42); }',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_INVOKE,
- element: 'function(C#o)', arguments: '(null,42)')),
- const Test(
- '''
- class C { static o(a, b) {} }
- m() => C.o(null);
- ''',
- const Visit(VisitKind.VISIT_STATIC_FUNCTION_INCOMPATIBLE_INVOKE,
- element: 'function(C#o)', arguments: '(null)')),
- ],
- 'Top level fields': const [
- // Top level fields
- const Test('''
- var o;
- m() => o;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_GET, element: 'field(o)')),
- const Test.prefix('''
- var o;
- ''', 'm() => p.o;',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_GET, element: 'field(o)')),
- const Test.prefix(
- '''
- var o;
- ''',
- 'm() => p.o;',
- const [
- const Visit(VisitKind.PREVISIT_DEFERRED_ACCESS, element: 'prefix(p)'),
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_GET, element: 'field(o)'),
- ],
- isDeferred: true),
- const Test.prefix('''
- ''', 'm() => p.o;',
- const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
- const Test.prefix(
- '''
- ''',
- 'm() => p.o;',
- const [
- const Visit(VisitKind.PREVISIT_DEFERRED_ACCESS, element: 'prefix(p)'),
- const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o'),
- ],
- isDeferred: true),
- const Test.prefix(
- '''
- ''',
- 'm() => p;',
- const Visit(VisitKind.ERROR_INVALID_GET,
- error: MessageKind.PREFIX_AS_EXPRESSION)),
- const Test(
- '''
- var o;
- m() { o = 42; }
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_SET,
- element: 'field(o)', rhs: '42')),
- const Test.prefix(
- '''
- var o;
- ''',
- 'm() { p.o = 42; }',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_SET,
- element: 'field(o)', rhs: '42')),
- const Test.prefix(
- '''
- ''',
- 'm() { p = 42; }',
- const Visit(VisitKind.ERROR_INVALID_SET,
- error: MessageKind.PREFIX_AS_EXPRESSION, rhs: '42')),
- const Test(
- '''
- final o = 0;
- m() { o = 42; }
- ''',
- const Visit(VisitKind.VISIT_FINAL_TOP_LEVEL_FIELD_SET,
- element: 'field(o)', rhs: '42')),
- const Test.prefix(
- '''
- final o = 0;
- ''',
- 'm() { p.o = 42; }',
- const Visit(VisitKind.VISIT_FINAL_TOP_LEVEL_FIELD_SET,
- element: 'field(o)', rhs: '42')),
- const Test(
- '''
- const o = 0;
- m() { o = 42; }
- ''',
- const Visit(VisitKind.VISIT_FINAL_TOP_LEVEL_FIELD_SET,
- element: 'field(o)', rhs: '42')),
- const Test.prefix(
- '''
- const o = 0;
- ''',
- 'm() { p.o = 42; }',
- const Visit(VisitKind.VISIT_FINAL_TOP_LEVEL_FIELD_SET,
- element: 'field(o)', rhs: '42')),
- const Test(
- '''
- var o;
- m() { o(null, 42); }
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_INVOKE,
- element: 'field(o)', arguments: '(null,42)')),
- const Test.prefix(
- '''
- var o;
- ''',
- 'm() { p.o(null, 42); }',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_INVOKE,
- element: 'field(o)', arguments: '(null,42)')),
- const Test.prefix(
- '''
- ''',
- 'm() { p(null, 42); }',
- const Visit(VisitKind.ERROR_INVALID_INVOKE,
- error: MessageKind.PREFIX_AS_EXPRESSION, arguments: '(null,42)')),
- const Test('''
- m() => o;
- ''', const Visit(VisitKind.VISIT_UNRESOLVED_GET, name: 'o')),
- const Test('''
- m() { o = 42; }
- ''', const Visit(VisitKind.VISIT_UNRESOLVED_SET, name: 'o', rhs: '42')),
- ],
- 'Top level properties': const [
- // Top level properties
- const Test(
- '''
- get o => null;
- m() => o;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_GET,
- element: 'getter(o)')),
- const Test.prefix(
- '''
- get o => null;
- ''',
- '''
- m() => p.o;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_GET,
- element: 'getter(o)')),
- const Test(
- '''
- set o(_) {}
- m() => o;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_GET,
- element: 'setter(o)')),
- const Test.prefix(
- '''
- set o(_) {}
- ''',
- '''
- m() => p.o;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_GET,
- element: 'setter(o)')),
- const Test(
- '''
- get o => null;
- m() { o = 42; }
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SET,
- element: 'getter(o)', rhs: '42')),
- const Test.prefix(
- '''
- get o => null;
- ''',
- 'm() { p.o = 42; }',
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SET,
- element: 'getter(o)', rhs: '42')),
- const Test(
- '''
- set o(_) {}
- m() { o = 42; }
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_SET,
- element: 'setter(o)', rhs: '42')),
- const Test.prefix(
- '''
- set o(_) {}
- ''',
- 'm() { p.o = 42; }',
- const Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_SET,
- element: 'setter(o)', rhs: '42')),
- const Test(
- '''
- get o => null;
- m() => o(null, 42);
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_INVOKE,
- element: 'getter(o)', arguments: '(null,42)')),
- const Test.prefix(
- '''
- get o => null;
- ''',
- 'm() { p.o(null, 42); }',
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_INVOKE,
- element: 'getter(o)', arguments: '(null,42)')),
- const Test(
- '''
- set o(_) {}
- m() => o(null, 42);
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_INVOKE,
- element: 'setter(o)', arguments: '(null,42)')),
- const Test.prefix(
- '''
- set o(_) {}
- ''',
- 'm() { p.o(null, 42); }',
- const Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_INVOKE,
- element: 'setter(o)', arguments: '(null,42)')),
- ],
- 'Top level functions': const [
- // Top level functions
- const Test(
- '''
- o(a, b) {}
- m() => o;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_GET,
- element: 'function(o)')),
- const Test(
- '''
- o(a, b) {}
- m() => o(null, 42);
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE,
- element: 'function(o)', arguments: '(null,42)')),
- const Test(
- '''
- o(a, b) {}
- m() => o(null);
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INCOMPATIBLE_INVOKE,
- element: 'function(o)', arguments: '(null)')),
- const Test.prefix(
- '''
- o(a, b) {}
- ''',
- 'm() { p.o(null, 42); }',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE,
- element: 'function(o)', arguments: '(null,42)')),
- const Test(
- '''
- m() => o(null, 42);
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_INVOKE,
- name: 'o', arguments: '(null,42)')),
- const Test.prefix(
- '''
- o(a, b) {}
- ''',
- 'm() => p.o(null, 42);',
- const [
- const Visit(VisitKind.PREVISIT_DEFERRED_ACCESS, element: 'prefix(p)'),
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE,
- element: 'function(o)', arguments: '(null,42)'),
- ],
- isDeferred: true),
- const Test.prefix(
- '''
- ''',
- 'm() => p.o(null, 42);',
- const Visit(VisitKind.VISIT_UNRESOLVED_INVOKE,
- name: 'o', arguments: '(null,42)')),
- const Test.prefix(
- '''
- ''',
- 'm() => p.o(null, 42);',
- const [
- const Visit(VisitKind.PREVISIT_DEFERRED_ACCESS, element: 'prefix(p)'),
- const Visit(VisitKind.VISIT_UNRESOLVED_INVOKE,
- name: 'o', arguments: '(null,42)'),
- ],
- isDeferred: true),
- const Test.prefix(
- '''
- ''',
- 'm() => p(null, 42);',
- const Visit(VisitKind.ERROR_INVALID_INVOKE,
- error: MessageKind.PREFIX_AS_EXPRESSION, arguments: '(null,42)')),
- const Test(
- '''
- o(a, b) {}
- m() { o = 42; }
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_SET,
- element: 'function(o)', rhs: '42')),
- const Test.prefix(
- '''
- o(a, b) {}
- ''',
- 'm() { p.o = 42; }',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_SET,
- element: 'function(o)', rhs: '42')),
- ],
- 'Dynamic properties': const [
- // Dynamic properties
- const Test('m(o) => o.foo;', const [
- const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_GET,
- receiver: 'o', name: 'foo'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#o)'),
- ]),
- const Test('m(o) { o.foo = 42; }', const [
- const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_SET,
- receiver: 'o', name: 'foo', rhs: '42'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#o)'),
- ]),
- const Test('m(o) { o.foo(null, 42); }', const [
- const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_INVOKE,
- receiver: 'o', name: 'foo', arguments: '(null,42)'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#o)'),
- ]),
- ],
- 'This access': const [
- // This access
- const Test.clazz('''
- class C {
- m() => this;
- }
- ''', const Visit(VisitKind.VISIT_THIS_GET)),
- const Test.clazz('''
- class C {
- call(a, b) {}
- m() { this(null, 42); }
- }
- ''', const Visit(VisitKind.VISIT_THIS_INVOKE, arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- call(a, b) {}
- static m() { this(null, 42); }
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_INVOKE,
- error: MessageKind.NO_THIS_AVAILABLE, arguments: '(null,42)')),
- ],
- 'This properties': const [
- // This properties
- const Test.clazz('''
- class C {
- var foo;
- m() => foo;
- }
- ''', const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
- const Test.clazz('''
- class C {
- var foo;
- m() => this.foo;
- }
- ''', const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
- const Test.clazz('''
- class C {
- get foo => null;
- m() => foo;
- }
- ''', const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
- const Test.clazz(
- '''
- class C {
- var foo;
- static m() => this.foo;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_GET,
- error: MessageKind.NO_THIS_AVAILABLE)),
- const Test.clazz('''
- class C {
- get foo => null;
- m() => this.foo;
- }
- ''', const Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: 'foo')),
- const Test.clazz('''
- class C {
- var foo;
- m() { foo = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_SET, name: 'foo', rhs: '42')),
- const Test.clazz('''
- class C {
- var foo;
- m() { this.foo = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_SET, name: 'foo', rhs: '42')),
- const Test.clazz('''
- class C {
- set foo(_) {}
- m() { foo = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_SET, name: 'foo', rhs: '42')),
- const Test.clazz('''
- class C {
- set foo(_) {}
- m() { this.foo = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_SET, name: 'foo', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- var foo;
- m() { foo(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_INVOKE,
- name: 'foo', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- var foo;
- m() { this.foo(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_INVOKE,
- name: 'foo', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C {
- var foo;
- static m() { this.foo(null, 42); }
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_INVOKE,
- error: MessageKind.NO_THIS_AVAILABLE, arguments: '(null,42)')),
- ],
- 'Super fields': const [
- // Super fields
- const Test.clazz('''
- class B {
- var o;
- }
- class C extends B {
- m() => super.o;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_GET, element: 'field(B#o)')),
- const Test.clazz(
- '''
- class B {
- var o;
- }
- class C extends B {
- m() { super.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_SET,
- element: 'field(B#o)', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- final o = 0;
- }
- class C extends B {
- m() { super.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_FINAL_SUPER_FIELD_SET,
- element: 'field(B#o)', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- var o;
- }
- class C extends B {
- m() { super.o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_INVOKE,
- element: 'field(B#o)', arguments: '(null,42)')),
- const Test.clazz('''
- class B {
- }
- class C extends B {
- m() => super.o;
- }
- ''', const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GET)),
- const Test.clazz('''
- class B {
- }
- class C extends B {
- m() => super.o = 42;
- }
- ''', const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SET, rhs: '42')),
- ],
- 'Super properties': const [
- // Super properties
- const Test.clazz('''
- class B {
- get o => null;
- }
- class C extends B {
- m() => super.o;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_GET, element: 'getter(B#o)')),
- const Test.clazz('''
- class B {
- set o(_) {}
- }
- class C extends B {
- m() => super.o;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_SETTER_GET, element: 'setter(B#o)')),
- const Test.clazz(
- '''
- class B {
- get o => 0;
- }
- class C extends B {
- m() { super.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_SET,
- element: 'getter(B#o)', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- set o(_) {}
- }
- class C extends B {
- m() { super.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_SETTER_SET,
- element: 'setter(B#o)', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- get o => null;
- }
- class C extends B {
- m() { super.o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_INVOKE,
- element: 'getter(B#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class B {
- set o(_) {}
- }
- class C extends B {
- m() { super.o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_SETTER_INVOKE,
- element: 'setter(B#o)', arguments: '(null,42)')),
- ],
- 'Super methods': const [
- // Super methods
- const Test.clazz(
- '''
- class B {
- o(a, b) {}
- }
- class C extends B {
- m() => super.o;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_METHOD_GET,
- element: 'function(B#o)')),
- const Test.clazz(
- '''
- class B {
- o(a, b) {}
- }
- class C extends B {
- m() { super.o = 42; }
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_METHOD_SET,
- element: 'function(B#o)', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- o(a, b) {}
- }
- class C extends B {
- m() { super.o(null, 42); }
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_METHOD_INVOKE,
- element: 'function(B#o)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class B {
- o(a, b) {}
- }
- class C extends B {
- m() { super.o(null); }
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_METHOD_INCOMPATIBLE_INVOKE,
- element: 'function(B#o)', arguments: '(null)')),
- const Test.clazz(
- '''
- class B {
- }
- class C extends B {
- m() => super.o(null, 42);
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INVOKE,
- arguments: '(null,42)')),
- ],
- 'Expression invoke': const [
- // Expression invoke
- const Test(
- 'm() => (a, b){}(null, 42);',
- const Visit(VisitKind.VISIT_EXPRESSION_INVOKE,
- receiver: '(a,b){}', arguments: '(null,42)')),
- ],
- 'Class type literals': const [
- // Class type literals
- const Test('''
- class C {}
- m() => C;
- ''',
- const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_GET, constant: 'C')),
- const Test(
- '''
- class C {}
- m() => C(null, 42);
- ''',
- const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_INVOKE,
- constant: 'C', arguments: '(null,42)')),
- const Test(
- '''
- class C {}
- m() => C = 42;
- ''',
- const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_SET,
- constant: 'C', rhs: '42')),
- const Test(
- '''
- class C {}
- m() => C += 42;
- ''',
- const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_COMPOUND,
- constant: 'C', operator: '+=', rhs: '42')),
- const Test(
- '''
- class C {}
- m() => C ??= 42;
- ''',
- const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_SET_IF_NULL,
- constant: 'C', rhs: '42')),
- const Test(
- '''
- class C {}
- m() => ++C;
- ''',
- const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_PREFIX,
- constant: 'C', operator: '++')),
- const Test(
- '''
- class C {}
- m() => C--;
- ''',
- const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_POSTFIX,
- constant: 'C', operator: '--')),
- const Test('''
- class C {}
- m() => (C).hashCode;
- ''', const [
- const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_GET,
- receiver: '(C)', name: 'hashCode'),
- const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_GET, constant: 'C'),
- ]),
- ],
- 'Typedef type literals': const [
- // Typedef type literals
- const Test('''
- typedef F();
- m() => F;
- ''',
- const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_GET, constant: 'F')),
- const Test(
- '''
- typedef F();
- m() => F(null, 42);
- ''',
- const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_INVOKE,
- constant: 'F', arguments: '(null,42)')),
- const Test(
- '''
- typedef F();
- m() => F = 42;
- ''',
- const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_SET,
- constant: 'F', rhs: '42')),
- const Test(
- '''
- typedef F();
- m() => F += 42;
- ''',
- const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_COMPOUND,
- constant: 'F', operator: '+=', rhs: '42')),
- const Test(
- '''
- typedef F();
- m() => F ??= 42;
- ''',
- const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_SET_IF_NULL,
- constant: 'F', rhs: '42')),
- const Test(
- '''
- typedef F();
- m() => ++F;
- ''',
- const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_PREFIX,
- constant: 'F', operator: '++')),
- const Test(
- '''
- typedef F();
- m() => F--;
- ''',
- const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_POSTFIX,
- constant: 'F', operator: '--')),
- ],
- 'Type variable type literals': const [
- // Type variable type literals
- const Test.clazz(
- '''
- class C<T> {
- m() => T;
- }
- ''',
- const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_GET,
- element: 'type_variable(C#T)')),
- const Test.clazz(
- '''
- class C<T> {
- m() => T(null, 42);
- }
- ''',
- const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_INVOKE,
- element: 'type_variable(C#T)', arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C<T> {
- m() => T = 42;
- }
- ''',
- const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_SET,
- element: 'type_variable(C#T)', rhs: '42')),
- const Test.clazz(
- '''
- class C<T> {
- m() => T += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_COMPOUND,
- element: 'type_variable(C#T)', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class C<T> {
- m() => T ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_SET_IF_NULL,
- element: 'type_variable(C#T)', rhs: '42')),
- const Test.clazz(
- '''
- class C<T> {
- m() => ++T;
- }
- ''',
- const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_PREFIX,
- element: 'type_variable(C#T)', operator: '++')),
- const Test.clazz(
- '''
- class C<T> {
- m() => T--;
- }
- ''',
- const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_POSTFIX,
- element: 'type_variable(C#T)', operator: '--')),
- const Test.clazz(
- '''
- class C<T> {
- static m() => T;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_GET,
- error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER)),
- const Test.clazz(
- '''
- class C<T> {
- static m() => T(null, 42);
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_INVOKE,
- error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
- arguments: '(null,42)')),
- const Test.clazz(
- '''
- class C<T> {
- static m() => T ??= 42;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_SET_IF_NULL,
- error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, rhs: '42')),
- const Test.clazz(
- '''
- class C<T> {
- static m() => T ??= 42;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_SET_IF_NULL,
- error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, rhs: '42')),
- const Test.clazz(
- '''
- class C<T> {
- static m() => ++T;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_PREFIX,
- error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
- operator: '++')),
- const Test.clazz(
- '''
- class C<T> {
- static m() => T--;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_POSTFIX,
- error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
- operator: '--')),
- ],
- 'Dynamic type literals': const [
- // Dynamic type literals
- const Test(
- '''
- m() => dynamic;
- ''',
- const Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_GET,
- constant: 'dynamic')),
- const Test(
- '''
- m() { dynamic(null, 42); }
- ''',
- const Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_INVOKE,
- constant: 'dynamic', arguments: '(null,42)')),
- const Test(
- '''
- m() => dynamic = 42;
- ''',
- const Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_SET,
- constant: 'dynamic', rhs: '42')),
- const Test(
- '''
- m() => dynamic += 42;
- ''',
- const Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_COMPOUND,
- constant: 'dynamic', operator: '+=', rhs: '42')),
- const Test(
- '''
- m() => dynamic ??= 42;
- ''',
- const Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_SET_IF_NULL,
- constant: 'dynamic', rhs: '42')),
- const Test(
- '''
- m() => ++dynamic;
- ''',
- const Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_PREFIX,
- constant: 'dynamic', operator: '++')),
- const Test(
- '''
- m() => dynamic--;
- ''',
- const Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_POSTFIX,
- constant: 'dynamic', operator: '--')),
- ],
- 'Assert': const [
- // Assert
- const Test(
- '''
- m() { assert(m()); }
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE,
- element: 'function(m)', arguments: '()')),
- ],
- 'Logical and': const [
- // Logical and
- const Test('''
- m() => true && false;
- ''',
- const Visit(VisitKind.VISIT_LOGICAL_AND, left: 'true', right: 'false')),
- ],
- 'Logical or': const [
- // Logical or
- const Test('''
- m() => true || false;
- ''',
- const Visit(VisitKind.VISIT_LOGICAL_OR, left: 'true', right: 'false')),
- ],
- 'Is test': const [
- // Is test
- const Test('''
- class C {}
- m() => 0 is C;
- ''', const Visit(VisitKind.VISIT_IS, expression: '0', type: 'C')),
- ],
- 'Is not test': const [
- // Is not test
- const Test('''
- class C {}
- m() => 0 is! C;
- ''', const Visit(VisitKind.VISIT_IS_NOT, expression: '0', type: 'C')),
- ],
- 'As test': const [
- // As test
- const Test('''
- class C {}
- m() => 0 as C;
- ''', const Visit(VisitKind.VISIT_AS, expression: '0', type: 'C')),
- ],
- 'Binary operators': const [
- // Binary operators
- const Test(
- '''
- m() => 2 + 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '+', right: '3')),
- const Test(
- '''
- m() => 2 - 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '-', right: '3')),
- const Test(
- '''
- m() => 2 * 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '*', right: '3')),
- const Test(
- '''
- m() => 2 / 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '/', right: '3')),
- const Test(
- '''
- m() => 2 ~/ 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '~/', right: '3')),
- const Test(
- '''
- m() => 2 % 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '%', right: '3')),
- const Test(
- '''
- m() => 2 << 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '<<', right: '3')),
- const Test(
- '''
- m() => 2 >> 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '>>', right: '3')),
- const Test(
- '''
- m() => 2 <= 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '<=', right: '3')),
- const Test(
- '''
- m() => 2 < 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '<', right: '3')),
- const Test(
- '''
- m() => 2 >= 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '>=', right: '3')),
- const Test(
- '''
- m() => 2 > 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '>', right: '3')),
- const Test(
- '''
- m() => 2 & 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '&', right: '3')),
- const Test(
- '''
- m() => 2 | 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '|', right: '3')),
- const Test(
- '''
- m() => 2 ^ 3;
- ''',
- const Visit(VisitKind.VISIT_BINARY,
- left: '2', operator: '^', right: '3')),
- const Test.clazz(
- '''
- class B {
- operator +(_) => null;
- }
- class C extends B {
- m() => super + 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_BINARY,
- element: 'function(B#+)', operator: '+', right: '42')),
- const Test.clazz(
- '''
- class B {}
- class C extends B {
- m() => super + 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_BINARY,
- operator: '+', right: '42')),
- const Test(
- '''
- m() => 2 === 3;
- ''',
- const Visit(VisitKind.ERROR_UNDEFINED_BINARY_EXPRESSION,
- left: '2', operator: '===', right: '3')),
- const Test(
- '''
- m() => 2 !== 3;
- ''',
- const Visit(VisitKind.ERROR_UNDEFINED_BINARY_EXPRESSION,
- left: '2', operator: '!==', right: '3')),
- const Test.clazz(
- '''
- class B {
- operator +(_) => null;
- }
- class C extends B {
- static m() => super + 42;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_BINARY,
- error: MessageKind.NO_SUPER_IN_STATIC, operator: '+', right: '42')),
- ],
- 'Index': const [
- // Index
- const Test('''
- m() => 2[3];
- ''', const Visit(VisitKind.VISIT_INDEX, receiver: '2', index: '3')),
- const Test(
- '''
- m() => --2[3];
- ''',
- const Visit(VisitKind.VISIT_INDEX_PREFIX,
- receiver: '2', index: '3', operator: '--')),
- const Test(
- '''
- m() => 2[3]++;
- ''',
- const Visit(VisitKind.VISIT_INDEX_POSTFIX,
- receiver: '2', index: '3', operator: '++')),
- const Test.clazz(
- '''
- class B {
- operator [](_) => null;
- }
- class C extends B {
- m() => super[42];
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_INDEX,
- element: 'function(B#[])', index: '42')),
- const Test.clazz('''
- class B {
- }
- class C extends B {
- m() => super[42];
- }
- ''', const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX, index: '42')),
- const Test.clazz(
- '''
- class B {
- operator [](_) => null;
- }
- class C extends B {
- static m() => super[42];
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_INDEX,
- error: MessageKind.NO_SUPER_IN_STATIC, index: '42')),
- const Test.clazz(
- '''
- class B {
- operator [](_) => null;
- operator []=(a, b) {}
- }
- class C extends B {
- m() => ++super[42];
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_INDEX_PREFIX,
- getter: 'function(B#[])',
- setter: 'function(B#[]=)',
- index: '42',
- operator: '++')),
- const Test.clazz(
- '''
- class B {
- operator []=(a, b) {}
- }
- class C extends B {
- m() => ++super[42];
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_PREFIX,
- setter: 'function(B#[]=)', index: '42', operator: '++')),
- const Test.clazz(
- '''
- class B {
- }
- class C extends B {
- m() => ++super[42];
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX_PREFIX,
- index: '42', operator: '++')),
- const Test.clazz(
- '''
- class B {
- operator [](_) => null;
- }
- class C extends B {
- m() => ++super[42];
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_INDEX_PREFIX,
- getter: 'function(B#[])', index: '42', operator: '++')),
- const Test.clazz(
- '''
- class B {
- operator [](_) => null;
- operator []=(a, b) {}
- }
- class C extends B {
- static m() => ++super[42];
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_INDEX_PREFIX,
- error: MessageKind.NO_SUPER_IN_STATIC,
- index: '42',
- operator: '++')),
- const Test.clazz(
- '''
- class B {
- operator [](_) => null;
- operator []=(a, b) {}
- }
- class C extends B {
- m() => super[42]--;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_INDEX_POSTFIX,
- getter: 'function(B#[])',
- setter: 'function(B#[]=)',
- index: '42',
- operator: '--')),
- const Test.clazz(
- '''
- class B {
- operator []=(a, b) {}
- }
- class C extends B {
- m() => super[42]--;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_POSTFIX,
- setter: 'function(B#[]=)', index: '42', operator: '--')),
- const Test.clazz(
- '''
- class B {
- }
- class C extends B {
- m() => super[42]--;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX_POSTFIX,
- index: '42', operator: '--')),
- const Test.clazz(
- '''
- class B {
- operator [](_) => null;
- }
- class C extends B {
- m() => super[42]--;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_INDEX_POSTFIX,
- getter: 'function(B#[])', index: '42', operator: '--')),
- const Test.clazz(
- '''
- class B {
- operator [](_) => null;
- operator []=(a, b) {}
- }
- class C extends B {
- static m() => super[42]--;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_INDEX_POSTFIX,
- error: MessageKind.NO_SUPER_IN_STATIC,
- index: '42',
- operator: '--')),
- const Test(
- '''
- m() => [][42] ??= 0;
- ''',
- const Visit(VisitKind.VISIT_INDEX_SET_IF_NULL,
- receiver: '[] ', index: '42', rhs: '0')),
- const Test.clazz(
- '''
- class B {
- operator [](_) => null;
- operator []=(a, b) {}
- }
- class C extends B {
- m() => super[42] ??= 0;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_INDEX_SET_IF_NULL,
- getter: 'function(B#[])',
- setter: 'function(B#[]=)',
- index: '42',
- rhs: '0')),
- const Test.clazz(
- '''
- class B {
- operator []=(a, b) {}
- }
- class C extends B {
- m() => super[42] ??= 0;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_SET_IF_NULL,
- setter: 'function(B#[]=)', index: '42', rhs: '0')),
- const Test.clazz(
- '''
- class B {
- operator [](_) => null;
- }
- class C extends B {
- m() => super[42] ??= 0;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_INDEX_SET_IF_NULL,
- getter: 'function(B#[])', index: '42', rhs: '0')),
- const Test.clazz(
- '''
- class B {
- }
- class C extends B {
- m() => super[42] ??= 0;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX_SET_IF_NULL,
- index: '42', rhs: '0')),
- ],
- 'Equals': const [
- // Equals
- const Test('''
- m() => 2 == 3;
- ''', const Visit(VisitKind.VISIT_EQUALS, left: '2', right: '3')),
- const Test.clazz(
- '''
- class B {
- operator ==(_) => null;
- }
- class C extends B {
- m() => super == 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_EQUALS,
- element: 'function(B#==)', right: '42')),
- const Test.clazz(
- '''
- class B {
- operator ==(_) => null;
- }
- class C extends B {
- static m() => super == 42;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_EQUALS,
- error: MessageKind.NO_SUPER_IN_STATIC, right: '42')),
- ],
- 'Not equals': const [
- // Not equals
- const Test('''
- m() => 2 != 3;
- ''', const Visit(VisitKind.VISIT_NOT_EQUALS, left: '2', right: '3')),
- const Test.clazz(
- '''
- class B {
- operator ==(_) => null;
- }
- class C extends B {
- m() => super != 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_NOT_EQUALS,
- element: 'function(B#==)', right: '42')),
- const Test.clazz(
- '''
- class B {
- operator ==(_) => null;
- }
- class C extends B {
- static m() => super != 42;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_NOT_EQUALS,
- error: MessageKind.NO_SUPER_IN_STATIC, right: '42')),
- ],
- 'Unary expression': const [
- // Unary expression
- const Test('''
- m() => -false;
- ''',
- const Visit(VisitKind.VISIT_UNARY, expression: 'false', operator: '-')),
- const Test('''
- m() => ~false;
- ''',
- const Visit(VisitKind.VISIT_UNARY, expression: 'false', operator: '~')),
- const Test.clazz(
- '''
- class B {
- operator -() => null;
- }
- class C extends B {
- m() => -super;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_UNARY,
- element: 'function(B#unary-)', operator: '-')),
- const Test.clazz('''
- class B {
- }
- class C extends B {
- m() => -super;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_UNARY, operator: '-')),
- const Test.clazz(
- '''
- class B {
- operator ~() => null;
- }
- class C extends B {
- m() => ~super;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_UNARY,
- element: 'function(B#~)', operator: '~')),
- const Test.clazz(
- '''
- class B {
- operator -() => null;
- }
- class C extends B {
- static m() => -super;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_UNARY,
- error: MessageKind.NO_SUPER_IN_STATIC, operator: '-')),
- const Test('''
- m() => !0;
- ''', const Visit(VisitKind.VISIT_NOT, expression: '0')),
- ],
- 'Index set': const [
- // Index set
- const Test(
- '''
- m() => 0[1] = 2;
- ''',
- const Visit(VisitKind.VISIT_INDEX_SET,
- receiver: '0', index: '1', rhs: '2')),
- const Test.clazz(
- '''
- class B {
- operator []=(a, b) {}
- }
- class C extends B {
- m() => super[1] = 2;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_INDEX_SET,
- element: 'function(B#[]=)', index: '1', rhs: '2')),
- const Test.clazz(
- '''
- class B {
- }
- class C extends B {
- m() => super[1] = 2;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX_SET,
- index: '1', rhs: '2')),
- const Test.clazz(
- '''
- class B {
- operator []=(a, b) {}
- }
- class C extends B {
- static m() => super[1] = 2;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_INDEX_SET,
- error: MessageKind.NO_SUPER_IN_STATIC, index: '1', rhs: '2')),
- ],
- 'Compound assignment': const [
- // Compound assignment
- const Test('''
- m(a) => a.b += 42;
- ''', const [
- const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_COMPOUND,
- receiver: 'a', name: 'b', operator: '+=', rhs: '42'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
- ]),
- const Test(
- '''
- m(a) => a += 42;
- ''',
- const Visit(VisitKind.VISIT_PARAMETER_COMPOUND,
- element: 'parameter(m#a)', operator: '+=', rhs: '42')),
- const Test(
- '''
- m(final a) => a += 42;
- ''',
- const Visit(VisitKind.VISIT_FINAL_PARAMETER_COMPOUND,
- element: 'parameter(m#a)', operator: '+=', rhs: '42')),
- const Test(
- '''
- m() {
- var a;
- a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_COMPOUND,
- element: 'variable(m#a)', operator: '+=', rhs: '42')),
- const Test(
- '''
- m() {
- final a = 0;
- a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_COMPOUND,
- element: 'variable(m#a)', operator: '+=', rhs: '42')),
- const Test(
- '''
- m() {
- a() {}
- a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_LOCAL_FUNCTION_COMPOUND,
- element: 'function(m#a)', operator: '+=', rhs: '42')),
- const Test(
- '''
- var a;
- m() => a += 42;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_COMPOUND,
- element: 'field(a)', operator: '+=', rhs: '42')),
- const Test(
- '''
- get a => 0;
- set a(_) {}
- m() => a += 42;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SETTER_COMPOUND,
- getter: 'getter(a)',
- setter: 'setter(a)',
- operator: '+=',
- rhs: '42')),
- const Test(
- '''
- class C {
- static var a;
- }
- m() => C.a += 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_COMPOUND,
- element: 'field(C#a)', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static var a;
- m() => C.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_COMPOUND,
- element: 'field(C#a)', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static var a;
- m() => a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_COMPOUND,
- element: 'field(C#a)', operator: '+=', rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static var a;
- }
- ''',
- '''
- m() => p.C.a += 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_COMPOUND,
- element: 'field(C#a)', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- var o;
- static m() { o += 42; }
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_COMPOUND,
- error: MessageKind.NO_INSTANCE_AVAILABLE,
- operator: '+=',
- rhs: '42')),
- const Test.prefix(
- '''
- ''',
- '''
- m() { p += 42; }
- ''',
- const Visit(VisitKind.ERROR_INVALID_COMPOUND,
- error: MessageKind.PREFIX_AS_EXPRESSION,
- operator: '+=',
- rhs: '42')),
- const Test(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- }
- m() => C.a += 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_COMPOUND,
- getter: 'getter(C#a)',
- setter: 'setter(C#a)',
- operator: '+=',
- rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- m() => C.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_COMPOUND,
- getter: 'getter(C#a)',
- setter: 'setter(C#a)',
- operator: '+=',
- rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- m() => a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_COMPOUND,
- getter: 'getter(C#a)',
- setter: 'setter(C#a)',
- operator: '+=',
- rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- }
- ''',
- '''
- m() => p.C.a += 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_COMPOUND,
- getter: 'getter(C#a)',
- setter: 'setter(C#a)',
- operator: '+=',
- rhs: '42')),
- // TODO(johnniwinther): Enable these when dart2js supports method and setter
- // with the same name.
- /*const Test(
- '''
- class C {
- static a() {}
- static set a(_) {}
- }
- m() => C.a += 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_COMPOUND,
- getter: 'function(C#a)', setter: 'setter(C#a)',
- operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static a() {}
- static set a(_) {}
- m() => C.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_COMPOUND,
- getter: 'function(C#a)', setter: 'setter(C#a)',
- operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static a() {}
- static set a(_) {}
- m() => a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_COMPOUND,
- getter: 'function(C#a)', setter: 'setter(C#a)',
- operator: '+=', rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static a() {}
- static set a(_) {}
- }
- ''',
- '''
- m() => p.C.a += 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_COMPOUND,
- getter: 'function(C#a)', setter: 'setter(C#a)',
- operator: '+=', rhs: '42')),*/
- const Test.clazz(
- '''
- class C {
- var a;
- m() => a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_COMPOUND,
- operator: '+=', name: 'a', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- var a = 0;
- m() => this.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_COMPOUND,
- name: 'a', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- var a = 0;
- }
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_COMPOUND,
- element: 'field(B#a)', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- final a = 0;
- }
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FINAL_FIELD_COMPOUND,
- element: 'field(B#a)', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- get a => 0;
- set a (_) {}
- }
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_COMPOUND,
- getter: 'getter(B#a)',
- setter: 'setter(B#a)',
- operator: '+=',
- rhs: '42')),
- const Test.clazz(
- '''
- class A {
- get a => 0;
- }
- class B extends A {
- set a (_) {}
- }
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_COMPOUND,
- getter: 'getter(A#a)',
- setter: 'setter(B#a)',
- operator: '+=',
- rhs: '42')),
- const Test.clazz(
- '''
- class A {
- var a;
- }
- class B extends A {
- get a => 0;
- }
-
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_FIELD_COMPOUND,
- getter: 'getter(B#a)',
- setter: 'field(A#a)',
- operator: '+=',
- rhs: '42')),
- const Test.clazz(
- '''
- class A {
- var a;
- }
- class B extends A {
- set a(_) {}
- }
-
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_SETTER_COMPOUND,
- getter: 'field(A#a)',
- setter: 'setter(B#a)',
- operator: '+=',
- rhs: '42')),
- const Test.clazz(
- '''
- class A {
- var a;
- }
- class B extends A {
- final a = 0;
- }
-
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- // TODO(johnniwinther): Change this to
- // [VISIT_SUPER_FIELD_FIELD_COMPOUND] when dart2js supports shadow
- // setters.
- const Visit(VisitKind.VISIT_SUPER_FINAL_FIELD_COMPOUND,
- element: 'field(B#a)', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- a() {}
- }
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_METHOD_COMPOUND,
- element: 'function(B#a)', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- }
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_COMPOUND,
- operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- set a(_) {}
- }
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_COMPOUND,
- setter: 'setter(B#a)', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- get a => 42;
- }
- class C extends B {
- m() => super.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_COMPOUND,
- getter: 'getter(B#a)', operator: '+=', rhs: '42')),
-
- const Test.clazz(
- '''
- class C {
- static set a(var value) { }
- m() => a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_STATIC_GETTER_COMPOUND,
- setter: 'setter(C#a)', operator: '+=', rhs: '42')),
-
- const Test.clazz(
- '''
- class C {
- static get a => 42;
- m() => C.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_STATIC_SETTER_COMPOUND,
- getter: 'getter(C#a)', operator: '+=', rhs: '42')),
-
- const Test.clazz(
- '''
- class C {
- static final a = 42;
- m() => C.a += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FINAL_FIELD_COMPOUND,
- element: 'field(C#a)', operator: '+=', rhs: '42')),
-
- const Test(
- '''
- class C {
- static a(var value) { }
- }
- m() => C.a += 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_COMPOUND,
- element: 'function(C#a)', operator: '+=', rhs: '42')),
-
- const Test(
- '''
- set a(var value) { }
- m() => a += 42;
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_GETTER_COMPOUND,
- setter: 'setter(a)', operator: '+=', rhs: '42')),
-
- const Test(
- '''
- get a => 42;
- m() => a += 42;
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_SETTER_COMPOUND,
- getter: 'getter(a)', operator: '+=', rhs: '42')),
-
- const Test(
- '''
- a(var value) { }
- m() => a += 42;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_COMPOUND,
- element: 'function(a)', operator: '+=', rhs: '42')),
-
- const Test(
- '''
- final a = 42;
- m() => a += 42;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FINAL_FIELD_COMPOUND,
- element: 'field(a)', operator: '+=', rhs: '42')),
-
- const Test(
- '''
- m() => unresolved += 42;
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_COMPOUND,
- operator: '+=', rhs: '42')),
- ],
- 'Compound index assignment': const [
- // Compound index assignment
- const Test(
- '''
- m() => 0[1] += 42;
- ''',
- const Visit(VisitKind.VISIT_COMPOUND_INDEX_SET,
- receiver: '0', index: '1', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- operator [](_) {}
- operator []=(a, b) {}
- }
- class C extends B {
- m() => super[1] += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_COMPOUND_INDEX_SET,
- getter: 'function(B#[])',
- setter: 'function(B#[]=)',
- index: '1',
- operator: '+=',
- rhs: '42')),
- const Test.clazz(
- '''
- class B {
- operator []=(a, b) {}
- }
- class C extends B {
- m() => super[1] += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_COMPOUND_INDEX_SET,
- setter: 'function(B#[]=)', index: '1', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- }
- class C extends B {
- m() => super[1] += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_COMPOUND_INDEX_SET,
- index: '1', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- operator [](_) {}
- }
- class C extends B {
- m() => super[1] += 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_COMPOUND_INDEX_SET,
- getter: 'function(B#[])', index: '1', operator: '+=', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- operator [](_) {}
- operator []=(a, b) {}
- }
- class C extends B {
- static m() => super[1] += 42;
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_COMPOUND_INDEX_SET,
- error: MessageKind.NO_SUPER_IN_STATIC,
- index: '1',
- operator: '+=',
- rhs: '42')),
- ],
- 'Prefix expression': const [
- // Prefix expression
- const Test('''
- m(a) => --a.b;
- ''', const [
- const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_PREFIX,
- receiver: 'a', name: 'b', operator: '--'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
- ]),
- const Test(
- '''
- m(a) => ++a;
- ''',
- const Visit(VisitKind.VISIT_PARAMETER_PREFIX,
- element: 'parameter(m#a)', operator: '++')),
- const Test(
- '''
- m(final a) => ++a;
- ''',
- const Visit(VisitKind.VISIT_FINAL_PARAMETER_PREFIX,
- element: 'parameter(m#a)', operator: '++')),
- const Test(
- '''
- m() {
- var a;
- --a;
- }
- ''',
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_PREFIX,
- element: 'variable(m#a)', operator: '--')),
- const Test(
- '''
- m() {
- final a = 42;
- --a;
- }
- ''',
- const Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_PREFIX,
- element: 'variable(m#a)', operator: '--')),
- const Test(
- '''
- m() {
- a() {}
- --a;
- }
- ''',
- const Visit(VisitKind.VISIT_LOCAL_FUNCTION_PREFIX,
- element: 'function(m#a)', operator: '--')),
- const Test(
- '''
- var a;
- m() => ++a;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_PREFIX,
- element: 'field(a)', operator: '++')),
- const Test(
- '''
- get a => 0;
- set a(_) {}
- m() => --a;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SETTER_PREFIX,
- getter: 'getter(a)', setter: 'setter(a)', operator: '--')),
- const Test(
- '''
- class C {
- static var a;
- }
- m() => ++C.a;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_PREFIX,
- element: 'field(C#a)', operator: '++')),
- const Test.clazz(
- '''
- class C {
- static var a;
- m() => ++C.a;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_PREFIX,
- element: 'field(C#a)', operator: '++')),
- const Test.clazz(
- '''
- class C {
- static var a;
- m() => --a;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_PREFIX,
- element: 'field(C#a)', operator: '--')),
- const Test.prefix(
- '''
- class C {
- static var a;
- }
- ''',
- '''
- m() => --p.C.a;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_PREFIX,
- element: 'field(C#a)', operator: '--')),
- const Test.clazz(
- '''
- class C {
- var o;
- static m() { ++o; }
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_PREFIX,
- error: MessageKind.NO_INSTANCE_AVAILABLE, operator: '++')),
- const Test.prefix(
- '''
- ''',
- '''
- m() { ++p; }
- ''',
- const Visit(VisitKind.ERROR_INVALID_PREFIX,
- error: MessageKind.PREFIX_AS_EXPRESSION, operator: '++')),
- const Test(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- }
- m() => ++C.a;
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_PREFIX,
- getter: 'getter(C#a)', setter: 'setter(C#a)', operator: '++')),
- const Test.clazz(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- m() => --C.a;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_PREFIX,
- getter: 'getter(C#a)', setter: 'setter(C#a)', operator: '--')),
- const Test.clazz(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- m() => --a;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_PREFIX,
- getter: 'getter(C#a)', setter: 'setter(C#a)', operator: '--')),
- const Test.prefix(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- }
- ''',
- '''
- m() => ++p.C.a;
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_PREFIX,
- getter: 'getter(C#a)', setter: 'setter(C#a)', operator: '++')),
- const Test.clazz(
- '''
- class C {
- var a;
- m() => --a;
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_PREFIX,
- name: 'a', operator: '--')),
- const Test.clazz(
- '''
- class C {
- var a = 0;
- m() => ++this.a;
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_PREFIX,
- name: 'a', operator: '++')),
- const Test.clazz(
- '''
- class B {
- var a = 0;
- }
- class C extends B {
- m() => --super.a;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_PREFIX,
- element: 'field(B#a)', operator: '--')),
- const Test.clazz(
- '''
- class B {
- final a = 0;
- }
- class C extends B {
- m() => --super.a;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FINAL_FIELD_PREFIX,
- element: 'field(B#a)', operator: '--')),
- const Test.clazz(
- '''
- class B {
- get a => 0;
- set a (_) {}
- }
- class C extends B {
- m() => --super.a;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_PREFIX,
- getter: 'getter(B#a)', setter: 'setter(B#a)', operator: '--')),
- const Test.clazz(
- '''
- class A {
- get a => 0;
- }
- class B extends A {
- set a (_) {}
- }
- class C extends B {
- m() => ++super.a;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_PREFIX,
- getter: 'getter(A#a)', setter: 'setter(B#a)', operator: '++')),
- const Test.clazz(
- '''
- class A {
- var a;
- }
- class B extends A {
- get a => 0;
- }
-
- class C extends B {
- m() => --super.a;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_FIELD_PREFIX,
- getter: 'getter(B#a)', setter: 'field(A#a)', operator: '--')),
- const Test.clazz(
- '''
- class A {
- var a;
- }
- class B extends A {
- set a(_) {}
- }
-
- class C extends B {
- m() => ++super.a;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_SETTER_PREFIX,
- getter: 'field(A#a)', setter: 'setter(B#a)', operator: '++')),
- const Test.clazz(
- '''
- class B {
- a() {}
- }
- class C extends B {
- m() => ++super.a;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_METHOD_PREFIX,
- element: 'function(B#a)', operator: '++')),
- const Test.clazz('''
- class B {
- }
- class C extends B {
- m() => ++super.a;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_PREFIX, operator: '++')),
- const Test.clazz(
- '''
- class B {
- set a(_) {}
- }
- class C extends B {
- m() => ++super.a;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_PREFIX,
- setter: 'setter(B#a)', operator: '++')),
- const Test.clazz(
- '''
- class B {
- get a => 42;
- }
- class C extends B {
- m() => ++super.a;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_PREFIX,
- getter: 'getter(B#a)', operator: '++')),
-
- const Test.clazz(
- '''
- class C {
- static set a(var value) { }
- m() => ++a;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_STATIC_GETTER_PREFIX,
- setter: 'setter(C#a)', operator: '++')),
-
- const Test.clazz(
- '''
- class C {
- static get a => 42;
- m() => ++C.a;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_STATIC_SETTER_PREFIX,
- getter: 'getter(C#a)', operator: '++')),
-
- const Test.clazz(
- '''
- class C {
- static final a = 42;
- m() => ++C.a;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FINAL_FIELD_PREFIX,
- element: 'field(C#a)', operator: '++')),
-
- const Test(
- '''
- class C {
- static a(var value) { }
- }
- m() => ++C.a;
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_PREFIX,
- element: 'function(C#a)', operator: '++')),
-
- const Test(
- '''
- set a(var value) { }
- m() => ++a;
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_GETTER_PREFIX,
- setter: 'setter(a)', operator: '++')),
-
- const Test(
- '''
- get a => 42;
- m() => ++a;
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_SETTER_PREFIX,
- getter: 'getter(a)', operator: '++')),
-
- const Test(
- '''
- a(var value) { }
- m() => ++a;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_PREFIX,
- element: 'function(a)', operator: '++')),
-
- const Test(
- '''
- final a = 42;
- m() => ++a;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FINAL_FIELD_PREFIX,
- element: 'field(a)', operator: '++')),
-
- const Test('''
- m() => ++unresolved;
- ''', const Visit(VisitKind.VISIT_UNRESOLVED_PREFIX, operator: '++')),
- ],
- 'Postfix expression': const [
- // Postfix expression
- const Test('''
- m(a) => a.b--;
- ''', const [
- const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_POSTFIX,
- receiver: 'a', name: 'b', operator: '--'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
- ]),
- const Test(
- '''
- m(a) => a++;
- ''',
- const Visit(VisitKind.VISIT_PARAMETER_POSTFIX,
- element: 'parameter(m#a)', operator: '++')),
- const Test(
- '''
- m(final a) => a++;
- ''',
- const Visit(VisitKind.VISIT_FINAL_PARAMETER_POSTFIX,
- element: 'parameter(m#a)', operator: '++')),
- const Test(
- '''
- m() {
- var a;
- a--;
- }
- ''',
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_POSTFIX,
- element: 'variable(m#a)', operator: '--')),
- const Test(
- '''
- m() {
- final a = 42;
- a--;
- }
- ''',
- const Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_POSTFIX,
- element: 'variable(m#a)', operator: '--')),
- const Test(
- '''
- m() {
- a() {}
- a--;
- }
- ''',
- const Visit(VisitKind.VISIT_LOCAL_FUNCTION_POSTFIX,
- element: 'function(m#a)', operator: '--')),
- const Test(
- '''
- var a;
- m() => a++;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_POSTFIX,
- element: 'field(a)', operator: '++')),
- const Test(
- '''
- get a => 0;
- set a(_) {}
- m() => a--;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SETTER_POSTFIX,
- getter: 'getter(a)', setter: 'setter(a)', operator: '--')),
- const Test(
- '''
- class C {
- static var a;
- }
- m() => C.a++;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_POSTFIX,
- element: 'field(C#a)', operator: '++')),
- const Test.clazz(
- '''
- class C {
- static var a;
- m() => C.a++;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_POSTFIX,
- element: 'field(C#a)', operator: '++')),
- const Test.clazz(
- '''
- class C {
- static var a;
- m() => a--;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_POSTFIX,
- element: 'field(C#a)', operator: '--')),
- const Test.prefix(
- '''
- class C {
- static var a;
- }
- ''',
- '''
- m() => p.C.a--;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_POSTFIX,
- element: 'field(C#a)', operator: '--')),
- const Test.clazz(
- '''
- class C {
- var o;
- static m() { o--; }
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_POSTFIX,
- error: MessageKind.NO_INSTANCE_AVAILABLE, operator: '--')),
- const Test.prefix(
- '''
- ''',
- '''
- m() { p--; }
- ''',
- const Visit(VisitKind.ERROR_INVALID_POSTFIX,
- error: MessageKind.PREFIX_AS_EXPRESSION, operator: '--')),
- const Test(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- }
- m() => C.a++;
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_POSTFIX,
- getter: 'getter(C#a)', setter: 'setter(C#a)', operator: '++')),
- const Test.clazz(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- m() => C.a--;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_POSTFIX,
- getter: 'getter(C#a)', setter: 'setter(C#a)', operator: '--')),
- const Test.clazz(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- m() => a--;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_POSTFIX,
- getter: 'getter(C#a)', setter: 'setter(C#a)', operator: '--')),
- const Test.prefix(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- }
- ''',
- '''
- m() => p.C.a++;
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_POSTFIX,
- getter: 'getter(C#a)', setter: 'setter(C#a)', operator: '++')),
- const Test.clazz(
- '''
- class C {
- var a;
- m() => a--;
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_POSTFIX,
- name: 'a', operator: '--')),
- const Test.clazz(
- '''
- class C {
- var a = 0;
- m() => this.a++;
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_POSTFIX,
- name: 'a', operator: '++')),
- const Test.clazz(
- '''
- class B {
- var a = 0;
- }
- class C extends B {
- m() => super.a--;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_POSTFIX,
- element: 'field(B#a)', operator: '--')),
- const Test.clazz(
- '''
- class B {
- final a = 0;
- }
- class C extends B {
- m() => super.a--;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FINAL_FIELD_POSTFIX,
- element: 'field(B#a)', operator: '--')),
- const Test.clazz(
- '''
- class B {
- get a => 0;
- set a (_) {}
- }
- class C extends B {
- m() => super.a--;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_POSTFIX,
- getter: 'getter(B#a)', setter: 'setter(B#a)', operator: '--')),
- const Test.clazz(
- '''
- class A {
- get a => 0;
- }
- class B extends A {
- set a (_) {}
- }
- class C extends B {
- m() => super.a++;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_POSTFIX,
- getter: 'getter(A#a)', setter: 'setter(B#a)', operator: '++')),
- const Test.clazz(
- '''
- class A {
- var a;
- }
- class B extends A {
- get a => 0;
- }
-
- class C extends B {
- m() => super.a--;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_FIELD_POSTFIX,
- getter: 'getter(B#a)', setter: 'field(A#a)', operator: '--')),
- const Test.clazz(
- '''
- class A {
- var a;
- }
- class B extends A {
- set a(_) {}
- }
-
- class C extends B {
- m() => super.a++;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_SETTER_POSTFIX,
- getter: 'field(A#a)', setter: 'setter(B#a)', operator: '++')),
- const Test.clazz(
- '''
- class B {
- a() {}
- }
- class C extends B {
- m() => super.a++;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_METHOD_POSTFIX,
- element: 'function(B#a)', operator: '++')),
- const Test.clazz('''
- class B {
- }
- class C extends B {
- m() => super.a++;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_POSTFIX, operator: '++')),
- const Test.clazz(
- '''
- class B {
- set a(_) {}
- }
- class C extends B {
- m() => super.a++;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_POSTFIX,
- setter: 'setter(B#a)', operator: '++')),
- const Test.clazz(
- '''
- class B {
- get a => 42;
- }
- class C extends B {
- m() => super.a++;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_POSTFIX,
- getter: 'getter(B#a)', operator: '++')),
-
- const Test.clazz(
- '''
- class C {
- static set a(var value) { }
- m() => a++;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_STATIC_GETTER_POSTFIX,
- setter: 'setter(C#a)', operator: '++')),
-
- const Test.clazz(
- '''
- class C {
- static get a => 42;
- m() => C.a++;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_STATIC_SETTER_POSTFIX,
- getter: 'getter(C#a)', operator: '++')),
-
- const Test.clazz(
- '''
- class C {
- static final a = 42;
- m() => C.a++;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FINAL_FIELD_POSTFIX,
- element: 'field(C#a)', operator: '++')),
-
- const Test(
- '''
- class C {
- static a(var value) { }
- }
- m() => C.a++;
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_POSTFIX,
- element: 'function(C#a)', operator: '++')),
-
- const Test(
- '''
- set a(var value) { }
- m() => a++;
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_GETTER_POSTFIX,
- setter: 'setter(a)', operator: '++')),
-
- const Test(
- '''
- get a => 42;
- m() => a++;
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_SETTER_POSTFIX,
- getter: 'getter(a)', operator: '++')),
-
- const Test(
- '''
- a(var value) { }
- m() => a++;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_POSTFIX,
- element: 'function(a)', operator: '++')),
-
- const Test(
- '''
- final a = 42;
- m() => a++;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FINAL_FIELD_POSTFIX,
- element: 'field(a)', operator: '++')),
-
- const Test('''
- m() => unresolved++;
- ''', const Visit(VisitKind.VISIT_UNRESOLVED_POSTFIX, operator: '++')),
- ],
- 'Constructor invocations': const [
- const Test(
- '''
- class Class {
- const Class(a, b);
- }
- m() => const Class(true, 42);
- ''',
- const Visit(VisitKind.VISIT_CONST_CONSTRUCTOR_INVOKE,
- constant: 'const Class(true, 42)')),
- const Test(
- '''
- m() => const bool.fromEnvironment('foo');
- ''',
- const Visit(VisitKind.VISIT_BOOL_FROM_ENVIRONMENT_CONSTRUCTOR_INVOKE,
- constant: 'const bool.fromEnvironment("foo")')),
- const Test(
- '''
- m() => const bool.fromEnvironment('foo', defaultValue: true);
- ''',
- const Visit(VisitKind.VISIT_BOOL_FROM_ENVIRONMENT_CONSTRUCTOR_INVOKE,
- constant: 'const bool.fromEnvironment("foo", defaultValue: true)')),
- const Test(
- '''
- m() => const int.fromEnvironment('foo');
- ''',
- const Visit(VisitKind.VISIT_INT_FROM_ENVIRONMENT_CONSTRUCTOR_INVOKE,
- constant: 'const int.fromEnvironment("foo")')),
- const Test(
- '''
- m() => const String.fromEnvironment('foo');
- ''',
- const Visit(VisitKind.VISIT_STRING_FROM_ENVIRONMENT_CONSTRUCTOR_INVOKE,
- constant: 'const String.fromEnvironment("foo")')),
- const Test(
- '''
- class Class {
- Class(a, b);
- }
- m() => const Class(true, 42);
- ''',
- const Visit(VisitKind.ERROR_NON_CONSTANT_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {}
- m() => new Class();
- ''',
- const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Class#)',
- arguments: '()',
- type: 'Class',
- selector: 'CallStructure(arity=0)')),
- const Test(
- '''
- class Class {
- Class(a, b);
- }
- m() => new Class(true, 42);
- ''',
- const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {
- Class.named(a, b);
- }
- m() => new Class.named(true, 42);
- ''',
- const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Class#named)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {}
- m() => new Class(true, 42);
- ''',
- const Visit(VisitKind.VISIT_CONSTRUCTOR_INCOMPATIBLE_INVOKE,
- element: 'generative_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {
- Class(a, b) : this._(a, b);
- Class._(a, b);
- }
- m() => new Class(true, 42);
- ''',
- const Visit(VisitKind.VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {
- Class() : this._(true, 42);
- Class._(a, b);
- }
- m() => new Class(true, 42);
- ''',
- const Visit(VisitKind.VISIT_CONSTRUCTOR_INCOMPATIBLE_INVOKE,
- element: 'generative_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {
- factory Class(a, b) => new Class._(a, b);
- Class._(a, b);
- }
- m() => new Class(true, 42);
- ''',
- const Visit(VisitKind.VISIT_FACTORY_CONSTRUCTOR_INVOKE,
- element: 'factory_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {
- factory Class() => new Class._(true, 42);
- Class._(a, b);
- }
- m() => new Class(true, 42);
- ''',
- const Visit(VisitKind.VISIT_CONSTRUCTOR_INCOMPATIBLE_INVOKE,
- element: 'factory_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class<T> {
- factory Class(a, b) = Class<int>.a;
- factory Class.a(a, b) = Class<Class<T>>.b;
- Class.b(a, b);
- }
- m() => new Class<double>(true, 42);
- ''',
- const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- element: 'factory_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class<double>',
- target: 'generative_constructor(Class#b)',
- targetType: 'Class<Class<int>>',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class<T> {
- factory Class(a) = Class<int>.a;
- factory Class.a(a, [b]) = Class<Class<T>>.b;
- Class.b(a, [b]);
- }
- m() => new Class<double>(true, 42);
- ''',
- const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- element: 'factory_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class<double>',
- target: 'generative_constructor(Class#b)',
- targetType: 'Class<Class<int>>',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {
- factory Class() = Class._;
- Class._();
- }
- m() => new Class(true, 42);
- ''',
- const Visit(
- VisitKind.VISIT_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- element: 'factory_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class<T> {
- factory Class(a, b) = Class<int>.a;
- factory Class.a(a, b) = Class<Class<T>>.b;
- Class.b(a);
- }
- m() => new Class<double>(true, 42);
- ''',
- const Visit(
- VisitKind.VISIT_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- element: 'factory_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class<double>',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {
- Class(a, b);
- }
- m() => new Class.unresolved(true, 42);
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_CONSTRUCTOR_INVOKE,
- arguments: '(true,42)')),
- const Test(
- '''
- m() => new Unresolved(true, 42);
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_CLASS_CONSTRUCTOR_INVOKE,
- arguments: '(true,42)')),
- const Test(
- '''
- abstract class AbstractClass {}
- m() => new AbstractClass();
- ''',
- const Visit(VisitKind.VISIT_ABSTRACT_CLASS_CONSTRUCTOR_INVOKE,
- element: 'generative_constructor(AbstractClass#)',
- type: 'AbstractClass',
- arguments: '()',
- selector: 'CallStructure(arity=0)')),
- const Test(
- '''
- class Class {
- factory Class(a, b) = Unresolved;
- }
- m() => new Class(true, 42);
- ''',
- const Visit(
- VisitKind.VISIT_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- element: 'factory_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {
- factory Class(a, b) = Class.named;
- }
- m() => new Class(true, 42);
- ''',
- const Visit(
- VisitKind.VISIT_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- element: 'factory_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- class Class {
- factory Class(a, b) = Class.named;
- factory Class.named(a, b) = Class.unresolved;
- }
- m() => new Class(true, 42);
- ''',
- const Visit(
- VisitKind.VISIT_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- element: 'factory_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- const Test(
- '''
- abstract class AbstractClass {
- AbstractClass(a, b);
- }
- class Class {
- factory Class(a, b) = AbstractClass;
- }
- m() => new Class(true, 42);
- ''',
- const Visit(
- VisitKind.VISIT_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- element: 'factory_constructor(Class#)',
- arguments: '(true,42)',
- type: 'Class',
- selector: 'CallStructure(arity=2)')),
- ],
- 'If not null expressions': const [
- const Test('''
- m(a) => a?.b;
- ''', const [
- const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_GET,
- receiver: 'a', name: 'b'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
- ]),
- const Test('''
- class C {
- static var b;
- }
- m(a) => C?.b;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: 'field(C#b)')),
- const Test('''
- m(a) => a?.b = 42;
- ''', const [
- const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET,
- receiver: 'a', name: 'b', rhs: '42'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
- ]),
- const Test('''
- m(a) => a?.b(42, true);
- ''', const [
- const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_INVOKE,
- receiver: 'a',
- arguments: '(42,true)',
- selector: 'Selector(call, b, arity=2)'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
- ]),
- const Test('''
- m(a) => ++a?.b;
- ''', const [
- const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_PREFIX,
- receiver: 'a', name: 'b', operator: '++'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
- ]),
- const Test('''
- m(a) => a?.b--;
- ''', const [
- const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_POSTFIX,
- receiver: 'a', name: 'b', operator: '--'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
- ]),
- const Test('''
- m(a) => a?.b *= 42;
- ''', const [
- const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_COMPOUND,
- receiver: 'a', name: 'b', operator: '*=', rhs: '42'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
- ]),
- const Test('''
- m(a) => a?.b ??= 42;
- ''', const [
- const Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET_IF_NULL,
- receiver: 'a', name: 'b', rhs: '42'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
- ]),
- const Test('''
- m(a, b) => a ?? b;
- ''', const [
- const Visit(VisitKind.VISIT_IF_NULL, left: 'a', right: 'b'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#b)'),
- ]),
- const Test(
- '''
- m(a) => a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_PARAMETER_SET_IF_NULL,
- element: 'parameter(m#a)', rhs: '42')),
- const Test.prefix(
- '''
- var o;
- ''',
- 'm() => p?.o;',
- const Visit(VisitKind.ERROR_INVALID_GET,
- error: MessageKind.PREFIX_AS_EXPRESSION)),
- ],
- 'Set if null': const [
- const Test('''
- m(a) => a.b ??= 42;
- ''', const [
- const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_SET_IF_NULL,
- receiver: 'a', name: 'b', rhs: '42'),
- const Visit(VisitKind.VISIT_PARAMETER_GET, element: 'parameter(m#a)')
- ]),
- const Test(
- '''
- m(a) => a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_PARAMETER_SET_IF_NULL,
- element: 'parameter(m#a)', rhs: '42')),
- const Test(
- '''
- m(final a) => a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_FINAL_PARAMETER_SET_IF_NULL,
- element: 'parameter(m#a)', rhs: '42')),
- const Test(
- '''
- m() {
- var a;
- a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_LOCAL_VARIABLE_SET_IF_NULL,
- element: 'variable(m#a)', rhs: '42')),
- const Test(
- '''
- m() {
- final a = 0;
- a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_SET_IF_NULL,
- element: 'variable(m#a)', rhs: '42')),
- const Test(
- '''
- m() {
- a() {}
- a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_LOCAL_FUNCTION_SET_IF_NULL,
- element: 'function(m#a)', rhs: '42')),
- const Test(
- '''
- var a;
- m() => a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_SET_IF_NULL,
- element: 'field(a)', rhs: '42')),
- const Test(
- '''
- get a => 0;
- set a(_) {}
- m() => a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SETTER_SET_IF_NULL,
- getter: 'getter(a)', setter: 'setter(a)', rhs: '42')),
- const Test(
- '''
- class C {
- static var a;
- }
- m() => C.a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_SET_IF_NULL,
- element: 'field(C#a)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static var a;
- m() => C.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_SET_IF_NULL,
- element: 'field(C#a)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static var a;
- m() => a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_SET_IF_NULL,
- element: 'field(C#a)', rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static var a;
- }
- ''',
- '''
- m() => p.C.a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_FIELD_SET_IF_NULL,
- element: 'field(C#a)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- var o;
- static m() { o ??= 42; }
- }
- ''',
- const Visit(VisitKind.ERROR_INVALID_SET_IF_NULL,
- error: MessageKind.NO_INSTANCE_AVAILABLE, rhs: '42')),
- const Test.prefix(
- '''
- ''',
- '''
- m() { p ??= 42; }
- ''',
- const Visit(VisitKind.ERROR_INVALID_SET_IF_NULL,
- error: MessageKind.PREFIX_AS_EXPRESSION, rhs: '42')),
- const Test(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- }
- m() => C.a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_SET_IF_NULL,
- getter: 'getter(C#a)', setter: 'setter(C#a)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- m() => C.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_SET_IF_NULL,
- getter: 'getter(C#a)', setter: 'setter(C#a)', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- m() => a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_SET_IF_NULL,
- getter: 'getter(C#a)', setter: 'setter(C#a)', rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static get a => 0;
- static set a(_) {}
- }
- ''',
- '''
- m() => p.C.a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_SET_IF_NULL,
- getter: 'getter(C#a)', setter: 'setter(C#a)', rhs: '42')),
- // TODO(johnniwinther): Enable these when dart2js supports method and setter
- // with the same name.
- /*const Test(
- '''
- class C {
- static a() {}
- static set a(_) {}
- }
- m() => C.a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_SET_IF_NULL,
- getter: 'function(C#a)', setter: 'setter(C#a)',
- rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static a() {}
- static set a(_) {}
- m() => C.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_SET_IF_NULL,
- getter: 'function(C#a)', setter: 'setter(C#a)',
- rhs: '42')),
- const Test.clazz(
- '''
- class C {
- static a() {}
- static set a(_) {}
- m() => a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_SET_IF_NULL,
- getter: 'function(C#a)', setter: 'setter(C#a)',
- rhs: '42')),
- const Test.prefix(
- '''
- class C {
- static a() {}
- static set a(_) {}
- }
- ''',
- '''
- m() => p.C.a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_SET_IF_NULL,
- getter: 'function(C#a)', setter: 'setter(C#a)',
- rhs: '42')),*/
- const Test.clazz(
- '''
- class C {
- var a;
- m() => a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_SET_IF_NULL,
- name: 'a', rhs: '42')),
- const Test.clazz(
- '''
- class C {
- var a = 0;
- m() => this.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_THIS_PROPERTY_SET_IF_NULL,
- name: 'a', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- var a = 0;
- }
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_SET_IF_NULL,
- element: 'field(B#a)', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- final a = 0;
- }
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FINAL_FIELD_SET_IF_NULL,
- element: 'field(B#a)', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- get a => 0;
- set a (_) {}
- }
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_SET_IF_NULL,
- getter: 'getter(B#a)', setter: 'setter(B#a)', rhs: '42')),
- const Test.clazz(
- '''
- class A {
- get a => 0;
- }
- class B extends A {
- set a (_) {}
- }
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_SET_IF_NULL,
- getter: 'getter(A#a)', setter: 'setter(B#a)', rhs: '42')),
- const Test.clazz(
- '''
- class A {
- var a;
- }
- class B extends A {
- get a => 0;
- }
-
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_GETTER_FIELD_SET_IF_NULL,
- getter: 'getter(B#a)', setter: 'field(A#a)', rhs: '42')),
- const Test.clazz(
- '''
- class A {
- var a;
- }
- class B extends A {
- set a(_) {}
- }
-
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_FIELD_SETTER_SET_IF_NULL,
- getter: 'field(A#a)', setter: 'setter(B#a)', rhs: '42')),
- const Test.clazz(
- '''
- class A {
- var a;
- }
- class B extends A {
- final a = 0;
- }
-
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- // TODO(johnniwinther): Change this to
- // [VISIT_SUPER_FIELD_FIELD_SET_IF_NULL] when dart2js supports shadow
- // setters.
- const Visit(VisitKind.VISIT_SUPER_FINAL_FIELD_SET_IF_NULL,
- element: 'field(B#a)', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- a() {}
- }
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_SUPER_METHOD_SET_IF_NULL,
- element: 'function(B#a)', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- }
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SET_IF_NULL,
- name: 'a', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- set a(_) {}
- }
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_SET_IF_NULL,
- setter: 'setter(B#a)', rhs: '42')),
- const Test.clazz(
- '''
- class B {
- get a => 42;
- }
- class C extends B {
- m() => super.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_SET_IF_NULL,
- getter: 'getter(B#a)', rhs: '42')),
-
- const Test.clazz(
- '''
- class C {
- static set a(var value) { }
- m() => a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_STATIC_GETTER_SET_IF_NULL,
- setter: 'setter(C#a)', rhs: '42')),
-
- const Test.clazz(
- '''
- class C {
- static get a => 42;
- m() => C.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_STATIC_SETTER_SET_IF_NULL,
- getter: 'getter(C#a)', rhs: '42')),
-
- const Test.clazz(
- '''
- class C {
- static final a = 42;
- m() => C.a ??= 42;
- }
- ''',
- const Visit(VisitKind.VISIT_STATIC_FINAL_FIELD_SET_IF_NULL,
- element: 'field(C#a)', rhs: '42')),
-
- const Test(
- '''
- class C {
- static a(var value) { }
- }
- m() => C.a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_STATIC_METHOD_SET_IF_NULL,
- element: 'function(C#a)', rhs: '42')),
-
- const Test(
- '''
- set a(var value) { }
- m() => a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_GETTER_SET_IF_NULL,
- setter: 'setter(a)', rhs: '42')),
-
- const Test(
- '''
- get a => 42;
- m() => a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_SETTER_SET_IF_NULL,
- getter: 'getter(a)', rhs: '42')),
-
- const Test(
- '''
- a(var value) { }
- m() => a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_SET_IF_NULL,
- element: 'function(a)', rhs: '42')),
-
- const Test(
- '''
- final a = 42;
- m() => a ??= 42;
- ''',
- const Visit(VisitKind.VISIT_TOP_LEVEL_FINAL_FIELD_SET_IF_NULL,
- element: 'field(a)', rhs: '42')),
-
- const Test(
- '''
- m() => unresolved ??= 42;
- ''',
- const Visit(VisitKind.VISIT_UNRESOLVED_SET_IF_NULL,
- name: 'unresolved', rhs: '42')),
- ],
-};
diff --git a/tests/compiler/dart2js/old_frontend/semantic_visitor_test_send_visitor.dart b/tests/compiler/dart2js/old_frontend/semantic_visitor_test_send_visitor.dart
deleted file mode 100644
index 4077d2d..0000000
--- a/tests/compiler/dart2js/old_frontend/semantic_visitor_test_send_visitor.dart
+++ /dev/null
@@ -1,2499 +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.
-
-part of dart2js.semantics_visitor_test;
-
-class SemanticSendTestVisitor extends SemanticTestVisitor {
- SemanticSendTestVisitor(TreeElements elements) : super(elements);
-
- @override
- visitAs(Send node, Node expression, ResolutionDartType type, arg) {
- visits
- .add(new Visit(VisitKind.VISIT_AS, expression: expression, type: type));
- apply(expression, arg);
- }
-
- @override
- errorInvalidCompound(Send node, ErroneousElement error,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_COMPOUND,
- error: error.messageKind, operator: operator, rhs: rhs));
- super.errorInvalidCompound(node, error, operator, rhs, arg);
- }
-
- @override
- errorInvalidGet(Send node, ErroneousElement error, arg) {
- visits
- .add(new Visit(VisitKind.ERROR_INVALID_GET, error: error.messageKind));
- super.errorInvalidGet(node, error, arg);
- }
-
- @override
- errorInvalidInvoke(Send node, ErroneousElement error, NodeList arguments,
- Selector selector, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_INVOKE,
- error: error.messageKind, arguments: arguments));
- super.errorInvalidInvoke(node, error, arguments, selector, arg);
- }
-
- @override
- errorInvalidPostfix(
- Send node, ErroneousElement error, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_POSTFIX,
- error: error.messageKind, operator: operator));
- super.errorInvalidPostfix(node, error, operator, arg);
- }
-
- @override
- errorInvalidPrefix(
- Send node, ErroneousElement error, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_PREFIX,
- error: error.messageKind, operator: operator));
- super.errorInvalidPrefix(node, error, operator, arg);
- }
-
- @override
- errorInvalidSet(Send node, ErroneousElement error, Node rhs, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_SET,
- error: error.messageKind, rhs: rhs));
- super.errorInvalidSet(node, error, rhs, arg);
- }
-
- @override
- errorInvalidSetIfNull(Send node, ErroneousElement error, Node rhs, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_SET_IF_NULL,
- error: error.messageKind, rhs: rhs));
- super.errorInvalidSetIfNull(node, error, rhs, arg);
- }
-
- @override
- errorInvalidUnary(
- Send node, UnaryOperator operator, ErroneousElement error, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_UNARY,
- error: error.messageKind, operator: operator));
- super.errorInvalidUnary(node, operator, error, arg);
- }
-
- @override
- errorInvalidEquals(Send node, ErroneousElement error, Node right, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_EQUALS,
- error: error.messageKind, right: right));
- super.errorInvalidEquals(node, error, right, arg);
- }
-
- @override
- errorInvalidNotEquals(Send node, ErroneousElement error, Node right, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_NOT_EQUALS,
- error: error.messageKind, right: right));
- super.errorInvalidNotEquals(node, error, right, arg);
- }
-
- @override
- errorInvalidBinary(Send node, ErroneousElement error, BinaryOperator operator,
- Node right, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_BINARY,
- error: error.messageKind, operator: operator, right: right));
- super.errorInvalidBinary(node, error, operator, right, arg);
- }
-
- @override
- errorInvalidIndex(Send node, ErroneousElement error, Node index, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_INDEX,
- error: error.messageKind, index: index));
- super.errorInvalidIndex(node, error, index, arg);
- }
-
- @override
- errorInvalidIndexSet(
- Send node, ErroneousElement error, Node index, Node rhs, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_INDEX_SET,
- error: error.messageKind, index: index, rhs: rhs));
- super.errorInvalidIndexSet(node, error, index, rhs, arg);
- }
-
- @override
- errorInvalidCompoundIndexSet(Send node, ErroneousElement error, Node index,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_COMPOUND_INDEX_SET,
- error: error.messageKind, index: index, operator: operator, rhs: rhs));
- super.errorInvalidCompoundIndexSet(node, error, index, operator, rhs, arg);
- }
-
- @override
- errorInvalidIndexPrefix(Send node, ErroneousElement error, Node index,
- IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_INDEX_PREFIX,
- error: error.messageKind, index: index, operator: operator));
- super.errorInvalidIndexPrefix(node, error, index, operator, arg);
- }
-
- @override
- errorInvalidIndexPostfix(Send node, ErroneousElement error, Node index,
- IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.ERROR_INVALID_INDEX_POSTFIX,
- error: error.messageKind, index: index, operator: operator));
- super.errorInvalidIndexPostfix(node, error, index, operator, arg);
- }
-
- @override
- visitBinary(Send node, Node left, BinaryOperator operator, Node right, arg) {
- visits.add(new Visit(VisitKind.VISIT_BINARY,
- left: left, operator: operator, right: right));
- super.visitBinary(node, left, operator, right, arg);
- }
-
- @override
- errorUndefinedBinaryExpression(
- Send node, Node left, Operator operator, Node right, arg) {
- visits.add(new Visit(VisitKind.ERROR_UNDEFINED_BINARY_EXPRESSION,
- left: left, operator: operator, right: right));
- super.errorUndefinedBinaryExpression(node, left, operator, right, arg);
- }
-
- @override
- visitIndex(Send node, Node receiver, Node index, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_INDEX, receiver: receiver, index: index));
- apply(receiver, arg);
- apply(index, arg);
- }
-
- @override
- visitClassTypeLiteralGet(Send node, ConstantExpression constant, arg) {
- visits.add(new Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_GET,
- constant: constant.toDartText()));
- }
-
- @override
- visitClassTypeLiteralInvoke(Send node, ConstantExpression constant,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_INVOKE,
- constant: constant.toDartText(), arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitClassTypeLiteralSet(
- SendSet node, ConstantExpression constant, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_SET,
- constant: constant.toDartText(), rhs: rhs));
- super.visitClassTypeLiteralSet(node, constant, rhs, arg);
- }
-
- @override
- visitNotEquals(Send node, Node left, Node right, arg) {
- visits.add(new Visit(VisitKind.VISIT_NOT_EQUALS, left: left, right: right));
- apply(left, arg);
- apply(right, arg);
- }
-
- @override
- visitDynamicPropertyPrefix(
- Send node, Node receiver, Name name, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_PREFIX,
- receiver: receiver, operator: operator, name: name));
- super.visitDynamicPropertyPrefix(node, receiver, name, operator, arg);
- }
-
- @override
- visitDynamicPropertyPostfix(
- Send node, Node receiver, Name name, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_POSTFIX,
- receiver: receiver, operator: operator, name: name));
- super.visitDynamicPropertyPostfix(node, receiver, name, operator, arg);
- }
-
- @override
- visitDynamicPropertyGet(Send node, Node receiver, Name name, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_GET,
- receiver: receiver, name: name));
- super.visitDynamicPropertyGet(node, receiver, name, arg);
- }
-
- @override
- visitDynamicPropertyInvoke(
- Send node, Node receiver, NodeList arguments, Selector selector, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_INVOKE,
- receiver: receiver, name: selector.name, arguments: arguments));
- super.visitDynamicPropertyInvoke(node, receiver, arguments, selector, arg);
- }
-
- @override
- visitDynamicPropertySet(
- SendSet node, Node receiver, Name name, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_SET,
- receiver: receiver, name: name, rhs: rhs));
- super.visitDynamicPropertySet(node, receiver, name, rhs, arg);
- }
-
- @override
- visitDynamicTypeLiteralGet(Send node, ConstantExpression constant, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_GET,
- constant: constant.toDartText()));
- }
-
- @override
- visitDynamicTypeLiteralInvoke(Send node, ConstantExpression constant,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_INVOKE,
- constant: constant.toDartText(), arguments: arguments));
- }
-
- @override
- visitDynamicTypeLiteralSet(
- Send node, ConstantExpression constant, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_SET,
- constant: constant.toDartText(), rhs: rhs));
- super.visitDynamicTypeLiteralSet(node, constant, rhs, arg);
- }
-
- @override
- visitExpressionInvoke(Send node, Node expression, NodeList arguments,
- CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_EXPRESSION_INVOKE,
- receiver: expression, arguments: arguments));
- }
-
- @override
- 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, ResolutionDartType type, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_IS_NOT, expression: expression, type: type));
- apply(expression, arg);
- }
-
- @override
- visitLogicalAnd(Send node, Node left, Node right, arg) {
- visits
- .add(new Visit(VisitKind.VISIT_LOGICAL_AND, left: left, right: right));
- apply(left, arg);
- apply(right, arg);
- }
-
- @override
- visitLogicalOr(Send node, Node left, Node right, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOGICAL_OR, left: left, right: right));
- apply(left, arg);
- apply(right, arg);
- }
-
- @override
- visitLocalFunctionGet(Send node, LocalFunctionElement function, arg) {
- visits
- .add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_GET, element: function));
- }
-
- @override
- visitLocalFunctionSet(
- SendSet node, LocalFunctionElement function, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_SET,
- element: function, rhs: rhs));
- super.visitLocalFunctionSet(node, function, rhs, arg);
- }
-
- @override
- visitLocalFunctionInvoke(Send node, LocalFunctionElement function,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_INVOKE,
- element: function, arguments: arguments, selector: callStructure));
- super.visitLocalFunctionInvoke(
- node, function, arguments, callStructure, arg);
- }
-
- @override
- visitLocalFunctionIncompatibleInvoke(Send node, LocalFunctionElement function,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_INCOMPATIBLE_INVOKE,
- element: function, arguments: arguments, selector: callStructure));
- super.visitLocalFunctionInvoke(
- node, function, arguments, callStructure, arg);
- }
-
- @override
- visitLocalVariableGet(Send node, LocalVariableElement variable, arg) {
- visits
- .add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_GET, element: variable));
- }
-
- @override
- visitLocalVariableInvoke(Send node, LocalVariableElement variable,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_INVOKE,
- element: variable, arguments: arguments, selector: callStructure));
- apply(arguments, arg);
- }
-
- @override
- visitLocalVariableSet(
- SendSet node, LocalVariableElement variable, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_SET,
- element: variable, rhs: rhs));
- super.visitLocalVariableSet(node, variable, rhs, arg);
- }
-
- @override
- visitFinalLocalVariableSet(
- SendSet node, LocalVariableElement variable, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_SET,
- element: variable, rhs: rhs));
- super.visitFinalLocalVariableSet(node, variable, rhs, arg);
- }
-
- @override
- visitParameterGet(Send node, ParameterElement parameter, arg) {
- visits.add(new Visit(VisitKind.VISIT_PARAMETER_GET, element: parameter));
- }
-
- @override
- visitParameterInvoke(Send node, ParameterElement parameter,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_PARAMETER_INVOKE,
- element: parameter, arguments: arguments, selector: callStructure));
- apply(arguments, arg);
- }
-
- @override
- visitParameterSet(SendSet node, ParameterElement parameter, Node rhs, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_PARAMETER_SET, element: parameter, rhs: rhs));
- super.visitParameterSet(node, parameter, rhs, arg);
- }
-
- @override
- visitFinalParameterSet(
- SendSet node, ParameterElement parameter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_PARAMETER_SET,
- element: parameter, rhs: rhs));
- super.visitFinalParameterSet(node, parameter, rhs, arg);
- }
-
- @override
- visitStaticFieldGet(Send node, FieldElement field, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FIELD_GET, element: field));
- }
-
- @override
- visitStaticFieldInvoke(Send node, FieldElement field, NodeList arguments,
- CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE,
- element: field, arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitStaticFieldSet(SendSet node, FieldElement field, Node rhs, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_STATIC_FIELD_SET, element: field, rhs: rhs));
- super.visitStaticFieldSet(node, field, rhs, arg);
- }
-
- @override
- visitFinalStaticFieldSet(SendSet node, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_STATIC_FIELD_SET,
- element: field, rhs: rhs));
- super.visitFinalStaticFieldSet(node, field, rhs, arg);
- }
-
- @override
- visitStaticFunctionGet(Send node, MethodElement function, arg) {
- visits
- .add(new Visit(VisitKind.VISIT_STATIC_FUNCTION_GET, element: function));
- }
-
- @override
- visitStaticFunctionSet(SendSet node, MethodElement function, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FUNCTION_SET,
- element: function, rhs: rhs));
- super.visitStaticFunctionSet(node, function, rhs, arg);
- }
-
- @override
- visitStaticFunctionInvoke(Send node, MethodElement function,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FUNCTION_INVOKE,
- element: function, arguments: arguments));
- super.visitStaticFunctionInvoke(
- node, function, arguments, callStructure, arg);
- }
-
- @override
- visitStaticFunctionIncompatibleInvoke(Send node, MethodElement function,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FUNCTION_INCOMPATIBLE_INVOKE,
- element: function, arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitStaticGetterGet(Send node, FunctionElement getter, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_GET, element: getter));
- super.visitStaticGetterGet(node, getter, arg);
- }
-
- @override
- visitStaticGetterSet(SendSet node, MethodElement getter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_SET,
- element: getter, rhs: rhs));
- super.visitStaticGetterSet(node, getter, rhs, arg);
- }
-
- @override
- visitStaticGetterInvoke(Send node, FunctionElement getter, NodeList arguments,
- CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_INVOKE,
- element: getter, arguments: arguments));
- super.visitStaticGetterInvoke(node, getter, arguments, callStructure, arg);
- }
-
- @override
- visitStaticSetterInvoke(Send node, FunctionElement setter, NodeList arguments,
- CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_SETTER_INVOKE,
- element: setter, arguments: arguments));
- super.visitStaticSetterInvoke(node, setter, arguments, callStructure, arg);
- }
-
- @override
- visitStaticSetterGet(Send node, FunctionElement getter, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_SETTER_GET, element: getter));
- super.visitStaticSetterGet(node, getter, arg);
- }
-
- @override
- visitStaticSetterSet(SendSet node, FunctionElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_SETTER_SET,
- element: setter, rhs: rhs));
- super.visitStaticSetterSet(node, setter, rhs, arg);
- }
-
- @override
- visitSuperBinary(Send node, FunctionElement function, BinaryOperator operator,
- Node argument, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_BINARY,
- element: function, operator: operator, right: argument));
- apply(argument, arg);
- }
-
- @override
- visitUnresolvedSuperBinary(
- Send node, Element element, BinaryOperator operator, Node argument, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_BINARY,
- operator: operator, right: argument));
- apply(argument, arg);
- }
-
- @override
- visitSuperIndex(Send node, FunctionElement function, Node index, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_INDEX,
- element: function, index: index));
- apply(index, arg);
- }
-
- @override
- visitUnresolvedSuperIndex(Send node, Element element, Node index, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX, index: index));
- apply(index, arg);
- }
-
- @override
- visitSuperNotEquals(Send node, FunctionElement function, Node argument, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_NOT_EQUALS,
- element: function, right: argument));
- apply(argument, arg);
- }
-
- @override
- visitThisGet(Identifier node, arg) {
- visits.add(new Visit(VisitKind.VISIT_THIS_GET));
- }
-
- @override
- visitThisInvoke(
- Send node, NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_THIS_INVOKE, arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitThisPropertyGet(Send node, Name name, arg) {
- visits.add(new Visit(VisitKind.VISIT_THIS_PROPERTY_GET, name: name));
- super.visitThisPropertyGet(node, name, arg);
- }
-
- @override
- visitThisPropertyInvoke(
- Send node, NodeList arguments, Selector selector, arg) {
- visits.add(new Visit(VisitKind.VISIT_THIS_PROPERTY_INVOKE,
- name: selector.name, arguments: arguments));
- super.visitThisPropertyInvoke(node, arguments, selector, arg);
- }
-
- @override
- visitThisPropertySet(SendSet node, Name name, Node rhs, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_THIS_PROPERTY_SET, name: name, rhs: rhs));
- super.visitThisPropertySet(node, name, rhs, arg);
- }
-
- @override
- visitTopLevelFieldGet(Send node, FieldElement field, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_GET, element: field));
- }
-
- @override
- visitTopLevelFieldInvoke(Send node, FieldElement field, NodeList arguments,
- CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_INVOKE,
- element: field, arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitTopLevelFieldSet(SendSet node, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_SET,
- element: field, rhs: rhs));
- super.visitTopLevelFieldSet(node, field, rhs, arg);
- }
-
- @override
- visitFinalTopLevelFieldSet(SendSet node, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_TOP_LEVEL_FIELD_SET,
- element: field, rhs: rhs));
- super.visitFinalTopLevelFieldSet(node, field, rhs, arg);
- }
-
- @override
- visitTopLevelFunctionGet(Send node, MethodElement function, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_GET, element: function));
- }
-
- @override
- visitTopLevelFunctionSet(
- SendSet node, MethodElement function, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_SET,
- element: function, rhs: rhs));
- super.visitTopLevelFunctionSet(node, function, rhs, arg);
- }
-
- @override
- visitTopLevelFunctionInvoke(Send node, MethodElement function,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE,
- element: function, arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitTopLevelFunctionIncompatibleInvoke(Send node, MethodElement function,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INCOMPATIBLE_INVOKE,
- element: function, arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitTopLevelGetterGet(Send node, FunctionElement getter, arg) {
- visits
- .add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_GET, element: getter));
- super.visitTopLevelGetterGet(node, getter, arg);
- }
-
- @override
- visitTopLevelSetterGet(Send node, FunctionElement setter, arg) {
- visits
- .add(new Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_GET, element: setter));
- super.visitTopLevelSetterGet(node, setter, arg);
- }
-
- @override
- visitTopLevelGetterInvoke(Send node, FunctionElement getter,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_INVOKE,
- element: getter, arguments: arguments));
- super
- .visitTopLevelGetterInvoke(node, getter, arguments, callStructure, arg);
- }
-
- @override
- visitTopLevelSetterInvoke(Send node, FunctionElement setter,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_INVOKE,
- element: setter, arguments: arguments));
- super
- .visitTopLevelSetterInvoke(node, setter, arguments, callStructure, arg);
- }
-
- @override
- visitTopLevelGetterSet(SendSet node, FunctionElement getter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SET,
- element: getter, rhs: rhs));
- super.visitTopLevelGetterSet(node, getter, rhs, arg);
- }
-
- @override
- visitTopLevelSetterSet(SendSet node, FunctionElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_SET,
- element: setter, rhs: rhs));
- super.visitTopLevelSetterSet(node, setter, rhs, arg);
- }
-
- @override
- visitTypeVariableTypeLiteralGet(Send node, TypeVariableElement element, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_GET,
- element: element));
- }
-
- @override
- visitTypeVariableTypeLiteralInvoke(Send node, TypeVariableElement element,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_INVOKE,
- element: element, arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitTypeVariableTypeLiteralSet(
- SendSet node, TypeVariableElement element, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_SET,
- element: element, rhs: rhs));
- super.visitTypeVariableTypeLiteralSet(node, element, rhs, arg);
- }
-
- @override
- visitTypedefTypeLiteralGet(Send node, ConstantExpression constant, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_GET,
- constant: constant.toDartText()));
- }
-
- @override
- visitTypedefTypeLiteralInvoke(Send node, ConstantExpression constant,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_INVOKE,
- constant: constant.toDartText(), arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitTypedefTypeLiteralSet(
- SendSet node, ConstantExpression constant, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_SET,
- constant: constant.toDartText(), rhs: rhs));
- super.visitTypedefTypeLiteralSet(node, constant, rhs, arg);
- }
-
- @override
- visitUnary(Send node, UnaryOperator operator, Node expression, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNARY,
- expression: expression, operator: operator));
- super.visitUnary(node, operator, expression, arg);
- }
-
- @override
- errorUndefinedUnaryExpression(
- Send node, Operator operator, Node expression, arg) {
- visits.add(new Visit(VisitKind.ERROR_UNDEFINED_UNARY_EXPRESSION,
- expression: expression, operator: operator));
- super.errorUndefinedUnaryExpression(node, operator, expression, arg);
- }
-
- @override
- visitNot(Send node, Node expression, arg) {
- visits.add(new Visit(VisitKind.VISIT_NOT, expression: expression));
- apply(expression, arg);
- }
-
- @override
- visitSuperFieldGet(Send node, FieldElement field, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_GET, element: field));
- }
-
- @override
- visitUnresolvedSuperGet(Send node, Element element, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GET));
- return super.visitUnresolvedSuperGet(node, element, arg);
- }
-
- @override
- visitUnresolvedSuperSet(Send node, Element element, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SET, rhs: rhs));
- return super.visitUnresolvedSuperSet(node, element, rhs, arg);
- }
-
- @override
- visitSuperFieldInvoke(Send node, FieldElement field, NodeList arguments,
- CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_INVOKE,
- element: field, arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitUnresolvedSuperInvoke(
- Send node, Element element, NodeList arguments, Selector selector, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INVOKE,
- arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitSuperFieldSet(SendSet node, FieldElement field, Node rhs, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_SUPER_FIELD_SET, element: field, rhs: rhs));
- super.visitSuperFieldSet(node, field, rhs, arg);
- }
-
- @override
- visitFinalSuperFieldSet(SendSet node, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_SUPER_FIELD_SET,
- element: field, rhs: rhs));
- super.visitFinalSuperFieldSet(node, field, rhs, arg);
- }
-
- @override
- visitSuperMethodGet(Send node, MethodElement method, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_GET, element: method));
- }
-
- @override
- visitSuperMethodSet(SendSet node, MethodElement method, Node rhs, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_SUPER_METHOD_SET, element: method, rhs: rhs));
- super.visitSuperMethodSet(node, method, rhs, arg);
- }
-
- @override
- visitSuperMethodInvoke(Send node, MethodElement method, NodeList arguments,
- CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_INVOKE,
- element: method, arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitSuperMethodIncompatibleInvoke(Send node, MethodElement method,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_INCOMPATIBLE_INVOKE,
- element: method, arguments: arguments));
- apply(arguments, arg);
- }
-
- @override
- visitSuperGetterGet(Send node, FunctionElement getter, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_GETTER_GET, element: getter));
- super.visitSuperGetterGet(node, getter, arg);
- }
-
- @override
- visitSuperSetterGet(Send node, FunctionElement setter, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_SETTER_GET, element: setter));
- super.visitSuperSetterGet(node, setter, arg);
- }
-
- @override
- visitSuperGetterInvoke(Send node, FunctionElement getter, NodeList arguments,
- CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_GETTER_INVOKE,
- element: getter, arguments: arguments));
- super.visitSuperGetterInvoke(node, getter, arguments, callStructure, arg);
- }
-
- @override
- visitSuperSetterInvoke(Send node, FunctionElement setter, NodeList arguments,
- CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_SETTER_INVOKE,
- element: setter, arguments: arguments));
- super.visitSuperSetterInvoke(node, setter, arguments, callStructure, arg);
- }
-
- @override
- visitSuperGetterSet(SendSet node, FunctionElement getter, Node rhs, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_SUPER_GETTER_SET, element: getter, rhs: rhs));
- super.visitSuperGetterSet(node, getter, rhs, arg);
- }
-
- @override
- visitSuperSetterSet(SendSet node, FunctionElement setter, Node rhs, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_SUPER_SETTER_SET, element: setter, rhs: rhs));
- super.visitSuperSetterSet(node, setter, rhs, arg);
- }
-
- @override
- visitSuperUnary(
- Send node, UnaryOperator operator, FunctionElement function, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_UNARY,
- element: function, operator: operator));
- }
-
- @override
- visitUnresolvedSuperUnary(
- Send node, UnaryOperator operator, Element element, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_UNARY, operator: operator));
- }
-
- @override
- visitEquals(Send node, Node left, Node right, arg) {
- visits.add(new Visit(VisitKind.VISIT_EQUALS, left: left, right: right));
- apply(left, arg);
- apply(right, arg);
- }
-
- @override
- visitSuperEquals(Send node, FunctionElement function, Node argument, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_EQUALS,
- element: function, right: argument));
- apply(argument, arg);
- }
-
- @override
- visitIndexSet(Send node, Node receiver, Node index, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_INDEX_SET,
- receiver: receiver, index: index, rhs: rhs));
- apply(receiver, arg);
- apply(index, arg);
- apply(rhs, arg);
- }
-
- @override
- visitSuperIndexSet(
- Send node, FunctionElement function, Node index, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_INDEX_SET,
- element: function, index: index, rhs: rhs));
- apply(index, arg);
- apply(rhs, arg);
- }
-
- @override
- visitDynamicPropertyCompound(Send node, Node receiver, Name name,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_COMPOUND,
- receiver: receiver, operator: operator, rhs: rhs, name: name));
- super
- .visitDynamicPropertyCompound(node, receiver, name, operator, rhs, arg);
- }
-
- @override
- visitFinalLocalVariableCompound(Send node, LocalVariableElement variable,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_COMPOUND,
- element: variable, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitFinalLocalVariablePrefix(
- Send node, LocalVariableElement variable, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_PREFIX,
- element: variable, operator: operator));
- }
-
- @override
- visitFinalLocalVariablePostfix(
- Send node, LocalVariableElement variable, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_POSTFIX,
- element: variable, operator: operator));
- }
-
- @override
- visitFinalParameterCompound(Send node, ParameterElement parameter,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_PARAMETER_COMPOUND,
- element: parameter, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitFinalParameterPrefix(
- Send node, ParameterElement parameter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_PARAMETER_PREFIX,
- element: parameter, operator: operator));
- }
-
- @override
- visitFinalParameterPostfix(
- Send node, ParameterElement parameter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_PARAMETER_POSTFIX,
- element: parameter, operator: operator));
- }
-
- @override
- visitFinalStaticFieldCompound(Send node, FieldElement field,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FINAL_FIELD_COMPOUND,
- element: field, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitFinalStaticFieldPostfix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FINAL_FIELD_POSTFIX,
- element: field, operator: operator));
- }
-
- @override
- visitFinalStaticFieldPrefix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FINAL_FIELD_PREFIX,
- element: field, operator: operator));
- }
-
- @override
- visitFinalSuperFieldCompound(Send node, FieldElement field,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FINAL_FIELD_COMPOUND,
- element: field, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitFinalTopLevelFieldCompound(Send node, FieldElement field,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FINAL_FIELD_COMPOUND,
- element: field, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitFinalTopLevelFieldPostfix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FINAL_FIELD_POSTFIX,
- element: field, operator: operator));
- }
-
- @override
- visitFinalTopLevelFieldPrefix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FINAL_FIELD_PREFIX,
- element: field, operator: operator));
- }
-
- @override
- visitLocalFunctionCompound(Send node, LocalFunctionElement function,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_COMPOUND,
- element: function, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitLocalVariableCompound(Send node, LocalVariableElement variable,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_COMPOUND,
- element: variable, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitParameterCompound(Send node, ParameterElement parameter,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_PARAMETER_COMPOUND,
- element: parameter, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitStaticFieldCompound(Send node, FieldElement field,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FIELD_COMPOUND,
- element: field, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitStaticGetterSetterCompound(Send node, FunctionElement getter,
- FunctionElement setter, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_COMPOUND,
- operator: operator, rhs: rhs, getter: getter, setter: setter));
- apply(rhs, arg);
- }
-
- @override
- visitSuperFieldCompound(Send node, FieldElement field,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_COMPOUND,
- element: field, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitSuperGetterSetterCompound(Send node, FunctionElement getter,
- FunctionElement setter, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_COMPOUND,
- operator: operator, rhs: rhs, getter: getter, setter: setter));
- apply(rhs, arg);
- }
-
- @override
- visitThisPropertyCompound(
- Send node, Name name, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_THIS_PROPERTY_COMPOUND,
- name: name, operator: operator, rhs: rhs));
- super.visitThisPropertyCompound(node, name, operator, rhs, arg);
- }
-
- @override
- visitTopLevelFieldCompound(Send node, FieldElement field,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_COMPOUND,
- element: field, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitTopLevelGetterSetterCompound(Send node, FunctionElement getter,
- FunctionElement setter, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SETTER_COMPOUND,
- operator: operator, rhs: rhs, getter: getter, setter: setter));
- apply(rhs, arg);
- }
-
- @override
- visitStaticMethodSetterCompound(Send node, FunctionElement method,
- FunctionElement setter, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_COMPOUND,
- operator: operator, rhs: rhs, getter: method, setter: setter));
- apply(rhs, arg);
- }
-
- @override
- visitSuperFieldSetterCompound(Send node, FieldElement field,
- FunctionElement setter, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_SETTER_COMPOUND,
- operator: operator, rhs: rhs, getter: field, setter: setter));
- apply(rhs, arg);
- }
-
- @override
- visitSuperGetterFieldCompound(Send node, FunctionElement getter,
- FieldElement field, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_GETTER_FIELD_COMPOUND,
- operator: operator, rhs: rhs, getter: getter, setter: field));
- apply(rhs, arg);
- }
-
- @override
- visitSuperMethodSetterCompound(Send node, FunctionElement method,
- FunctionElement setter, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_SETTER_COMPOUND,
- getter: method, setter: setter, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitSuperMethodCompound(Send node, FunctionElement method,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_COMPOUND,
- element: method, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitSuperMethodPrefix(
- Send node, FunctionElement method, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_PREFIX,
- element: method, operator: operator));
- }
-
- @override
- visitSuperMethodPostfix(
- Send node, FunctionElement method, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_POSTFIX,
- element: method, operator: operator));
- }
-
- @override
- visitUnresolvedSuperCompound(
- Send node, Element element, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_COMPOUND,
- operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedSuperPrefix(
- Send node, Element element, IncDecOperator operator, arg) {
- visits.add(
- new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_PREFIX, operator: operator));
- }
-
- @override
- visitUnresolvedSuperPostfix(
- Send node, Element element, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_POSTFIX,
- operator: operator));
- }
-
- @override
- visitTopLevelMethodSetterCompound(Send node, FunctionElement method,
- FunctionElement setter, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_SETTER_COMPOUND,
- getter: method, setter: setter, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitCompoundIndexSet(Send node, Node receiver, Node index,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_COMPOUND_INDEX_SET,
- receiver: receiver, index: index, rhs: rhs, operator: operator));
- apply(receiver, arg);
- apply(index, arg);
- apply(rhs, arg);
- }
-
- @override
- visitSuperCompoundIndexSet(
- Send node,
- FunctionElement getter,
- FunctionElement setter,
- Node index,
- AssignmentOperator operator,
- Node rhs,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_COMPOUND_INDEX_SET,
- getter: getter,
- setter: setter,
- index: index,
- rhs: rhs,
- operator: operator));
- apply(index, arg);
- apply(rhs, arg);
- }
-
- @override
- visitClassTypeLiteralCompound(Send node, ConstantExpression constant,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_COMPOUND,
- constant: constant.toDartText(), operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitDynamicTypeLiteralCompound(Send node, ConstantExpression constant,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_COMPOUND,
- constant: constant.toDartText(), operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitTypeVariableTypeLiteralCompound(Send node, TypeVariableElement element,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_COMPOUND,
- element: element, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitTypedefTypeLiteralCompound(Send node, ConstantExpression constant,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_COMPOUND,
- constant: constant.toDartText(), operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitLocalFunctionPrefix(
- Send node, LocalFunctionElement function, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_PREFIX,
- element: function, operator: operator));
- }
-
- @override
- visitClassTypeLiteralPrefix(
- Send node, ConstantExpression constant, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_PREFIX,
- constant: constant.toDartText(), operator: operator));
- }
-
- @override
- visitDynamicTypeLiteralPrefix(
- Send node, ConstantExpression constant, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_PREFIX,
- constant: constant.toDartText(), operator: operator));
- }
-
- @override
- visitLocalVariablePrefix(
- Send node, LocalVariableElement variable, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_PREFIX,
- element: variable, operator: operator));
- }
-
- @override
- visitParameterPrefix(
- Send node, ParameterElement parameter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_PARAMETER_PREFIX,
- element: parameter, operator: operator));
- }
-
- @override
- visitStaticFieldPrefix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FIELD_PREFIX,
- element: field, operator: operator));
- }
-
- @override
- visitStaticGetterSetterPrefix(Send node, FunctionElement getter,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_PREFIX,
- getter: getter, setter: setter, operator: operator));
- }
-
- @override
- visitStaticMethodSetterPrefix(Send node, FunctionElement getter,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_PREFIX,
- getter: getter, setter: setter, operator: operator));
- }
-
- @override
- visitSuperFieldFieldCompound(Send node, FieldElement readField,
- FieldElement writtenField, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_FIELD_COMPOUND,
- getter: readField, setter: writtenField, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitSuperFieldFieldPrefix(Send node, FieldElement readField,
- FieldElement writtenField, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_FIELD_PREFIX,
- getter: readField, setter: writtenField, operator: operator));
- }
-
- @override
- visitSuperFieldPrefix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_PREFIX,
- element: field, operator: operator));
- }
-
- @override
- visitFinalSuperFieldPrefix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FINAL_FIELD_PREFIX,
- element: field, operator: operator));
- }
-
- @override
- visitSuperFieldSetterPrefix(Send node, FieldElement field,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_SETTER_PREFIX,
- getter: field, setter: setter, operator: operator));
- }
-
- @override
- visitSuperGetterFieldPrefix(Send node, FunctionElement getter,
- FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_GETTER_FIELD_PREFIX,
- getter: getter, setter: field, operator: operator));
- }
-
- @override
- visitSuperGetterSetterPrefix(Send node, FunctionElement getter,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_PREFIX,
- getter: getter, setter: setter, operator: operator));
- }
-
- @override
- visitSuperMethodSetterPrefix(Send node, FunctionElement method,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_SETTER_PREFIX,
- getter: method, setter: setter, operator: operator));
- }
-
- @override
- visitThisPropertyPrefix(Send node, Name name, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_THIS_PROPERTY_PREFIX,
- name: name, operator: operator));
- super.visitThisPropertyPrefix(node, name, operator, arg);
- }
-
- @override
- visitTopLevelFieldPrefix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_PREFIX,
- element: field, operator: operator));
- }
-
- @override
- visitTopLevelGetterSetterPrefix(Send node, FunctionElement getter,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SETTER_PREFIX,
- getter: getter, setter: setter, operator: operator));
- }
-
- @override
- visitTopLevelMethodSetterPrefix(Send node, FunctionElement method,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_SETTER_PREFIX,
- getter: method, setter: setter, operator: operator));
- }
-
- @override
- visitTypeVariableTypeLiteralPrefix(
- Send node, TypeVariableElement element, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_PREFIX,
- element: element, operator: operator));
- }
-
- @override
- visitTypedefTypeLiteralPrefix(
- Send node, ConstantExpression constant, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_PREFIX,
- constant: constant.toDartText(), operator: operator));
- }
-
- @override
- visitLocalFunctionPostfix(
- Send node, LocalFunctionElement function, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_POSTFIX,
- element: function, operator: operator));
- }
-
- @override
- visitClassTypeLiteralPostfix(
- Send node, ConstantExpression constant, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_POSTFIX,
- constant: constant.toDartText(), operator: operator));
- }
-
- @override
- visitDynamicTypeLiteralPostfix(
- Send node, ConstantExpression constant, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_POSTFIX,
- constant: constant.toDartText(), operator: operator));
- }
-
- @override
- visitLocalVariablePostfix(
- Send node, LocalVariableElement variable, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_POSTFIX,
- element: variable, operator: operator));
- }
-
- @override
- visitParameterPostfix(
- Send node, ParameterElement parameter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_PARAMETER_POSTFIX,
- element: parameter, operator: operator));
- }
-
- @override
- visitStaticFieldPostfix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FIELD_POSTFIX,
- element: field, operator: operator));
- }
-
- @override
- visitStaticGetterSetterPostfix(Send node, FunctionElement getter,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_POSTFIX,
- getter: getter, setter: setter, operator: operator));
- }
-
- @override
- visitStaticMethodSetterPostfix(Send node, FunctionElement getter,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_POSTFIX,
- getter: getter, setter: setter, operator: operator));
- }
-
- @override
- visitSuperFieldFieldPostfix(Send node, FieldElement readField,
- FieldElement writtenField, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_FIELD_POSTFIX,
- getter: readField, setter: writtenField, operator: operator));
- }
-
- @override
- visitSuperFieldPostfix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_POSTFIX,
- element: field, operator: operator));
- }
-
- @override
- visitFinalSuperFieldPostfix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FINAL_FIELD_POSTFIX,
- element: field, operator: operator));
- }
-
- @override
- visitSuperFieldSetterPostfix(Send node, FieldElement field,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_SETTER_POSTFIX,
- getter: field, setter: setter, operator: operator));
- }
-
- @override
- visitSuperGetterFieldPostfix(Send node, FunctionElement getter,
- FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_GETTER_FIELD_POSTFIX,
- getter: getter, setter: field, operator: operator));
- }
-
- @override
- visitSuperGetterSetterPostfix(Send node, FunctionElement getter,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_POSTFIX,
- getter: getter, setter: setter, operator: operator));
- }
-
- @override
- visitSuperMethodSetterPostfix(Send node, FunctionElement method,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_SETTER_POSTFIX,
- getter: method, setter: setter, operator: operator));
- }
-
- @override
- visitThisPropertyPostfix(Send node, Name name, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_THIS_PROPERTY_POSTFIX,
- name: name, operator: operator));
- super.visitThisPropertyPostfix(node, name, operator, arg);
- }
-
- @override
- visitTopLevelFieldPostfix(
- Send node, FieldElement field, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_POSTFIX,
- element: field, operator: operator));
- }
-
- @override
- visitTopLevelGetterSetterPostfix(Send node, FunctionElement getter,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SETTER_POSTFIX,
- getter: getter, setter: setter, operator: operator));
- }
-
- @override
- visitTopLevelMethodSetterPostfix(Send node, FunctionElement method,
- FunctionElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_SETTER_POSTFIX,
- getter: method, setter: setter, operator: operator));
- }
-
- @override
- visitTypeVariableTypeLiteralPostfix(
- Send node, TypeVariableElement element, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_POSTFIX,
- element: element, operator: operator));
- }
-
- @override
- visitTypedefTypeLiteralPostfix(
- Send node, ConstantExpression constant, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_POSTFIX,
- constant: constant.toDartText(), operator: operator));
- }
-
- @override
- visitUnresolvedCompound(Send node, ErroneousElement element,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_COMPOUND,
- operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedGet(Send node, Element element, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_GET, name: element.name));
- }
-
- @override
- visitUnresolvedSet(Send node, Element element, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SET,
- name: element.name, rhs: rhs));
- super.visitUnresolvedSet(node, element, rhs, arg);
- }
-
- @override
- visitUnresolvedInvoke(
- Send node, Element element, NodeList arguments, Selector selector, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_INVOKE,
- name: element.name, arguments: arguments));
- super.visitUnresolvedInvoke(node, element, arguments, selector, arg);
- }
-
- @override
- visitUnresolvedPostfix(
- Send node, ErroneousElement element, IncDecOperator operator, arg) {
- visits
- .add(new Visit(VisitKind.VISIT_UNRESOLVED_POSTFIX, operator: operator));
- }
-
- @override
- visitUnresolvedPrefix(
- Send node, ErroneousElement element, IncDecOperator operator, arg) {
- visits
- .add(new Visit(VisitKind.VISIT_UNRESOLVED_PREFIX, operator: operator));
- }
-
- @override
- visitUnresolvedSuperCompoundIndexSet(Send node, Element element, Node index,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_COMPOUND_INDEX_SET,
- index: index, operator: operator, rhs: rhs));
- apply(index, arg);
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedSuperGetterCompoundIndexSet(
- Send node,
- Element element,
- MethodElement setter,
- Node index,
- AssignmentOperator operator,
- Node rhs,
- arg) {
- visits.add(new Visit(
- VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_COMPOUND_INDEX_SET,
- setter: setter,
- index: index,
- operator: operator,
- rhs: rhs));
- apply(index, arg);
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedSuperSetterCompoundIndexSet(Send node, MethodElement getter,
- Element element, Node index, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(
- VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_COMPOUND_INDEX_SET,
- getter: getter,
- index: index,
- operator: operator,
- rhs: rhs));
- apply(index, arg);
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedSuperIndexSet(
- Send node, ErroneousElement element, Node index, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX_SET,
- index: index, rhs: rhs));
- apply(index, arg);
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedSuperIndexPostfix(
- Send node, Element element, Node index, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX_POSTFIX,
- index: index, operator: operator));
- apply(index, arg);
- }
-
- @override
- visitUnresolvedSuperGetterIndexPostfix(Send node, Element element,
- MethodElement setter, Node index, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_POSTFIX,
- setter: setter, index: index, operator: operator));
- apply(index, arg);
- }
-
- @override
- visitUnresolvedSuperSetterIndexPostfix(Send node, MethodElement getter,
- Element element, Node index, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_INDEX_POSTFIX,
- getter: getter, index: index, operator: operator));
- apply(index, arg);
- }
-
- @override
- visitUnresolvedSuperIndexPrefix(
- Send node, Element element, Node index, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX_PREFIX,
- index: index, operator: operator));
- apply(index, arg);
- }
-
- @override
- visitUnresolvedSuperGetterIndexPrefix(Send node, Element element,
- MethodElement setter, Node index, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_PREFIX,
- setter: setter, index: index, operator: operator));
- apply(index, arg);
- }
-
- @override
- visitUnresolvedSuperSetterIndexPrefix(Send node, MethodElement getter,
- Element element, Node index, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_INDEX_PREFIX,
- getter: getter, index: index, operator: operator));
- apply(index, arg);
- }
-
- @override
- visitIndexPostfix(
- Send node, Node receiver, Node index, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_INDEX_POSTFIX,
- receiver: receiver, index: index, operator: operator));
- apply(receiver, arg);
- apply(index, arg);
- }
-
- @override
- visitIndexPrefix(
- Send node, Node receiver, Node index, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_INDEX_PREFIX,
- receiver: receiver, index: index, operator: operator));
- apply(receiver, arg);
- apply(index, arg);
- }
-
- @override
- visitSuperIndexPostfix(
- Send node,
- FunctionElement indexFunction,
- FunctionElement indexSetFunction,
- Node index,
- IncDecOperator operator,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_INDEX_POSTFIX,
- getter: indexFunction,
- setter: indexSetFunction,
- index: index,
- operator: operator));
- apply(index, arg);
- }
-
- @override
- visitSuperIndexPrefix(
- Send node,
- FunctionElement indexFunction,
- FunctionElement indexSetFunction,
- Node index,
- IncDecOperator operator,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_INDEX_PREFIX,
- getter: indexFunction,
- setter: indexSetFunction,
- index: index,
- operator: operator));
- apply(index, arg);
- }
-
- @override
- visitUnresolvedClassConstructorInvoke(NewExpression node, Element constructor,
- 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));
- apply(arguments, arg);
- }
-
- @override
- visitUnresolvedConstructorInvoke(NewExpression node, Element constructor,
- 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));
- apply(arguments, arg);
- }
-
- @override
- visitConstConstructorInvoke(
- NewExpression node, ConstructedConstantExpression constant, arg) {
- visits.add(new Visit(VisitKind.VISIT_CONST_CONSTRUCTOR_INVOKE,
- constant: constant.toDartText()));
- super.visitConstConstructorInvoke(node, constant, arg);
- }
-
- @override
- visitBoolFromEnvironmentConstructorInvoke(
- NewExpression node, BoolFromEnvironmentConstantExpression constant, arg) {
- visits.add(new Visit(
- VisitKind.VISIT_BOOL_FROM_ENVIRONMENT_CONSTRUCTOR_INVOKE,
- constant: constant.toDartText()));
- super.visitBoolFromEnvironmentConstructorInvoke(node, constant, arg);
- }
-
- @override
- visitIntFromEnvironmentConstructorInvoke(
- NewExpression node, IntFromEnvironmentConstantExpression constant, arg) {
- visits.add(new Visit(
- VisitKind.VISIT_INT_FROM_ENVIRONMENT_CONSTRUCTOR_INVOKE,
- constant: constant.toDartText()));
- super.visitIntFromEnvironmentConstructorInvoke(node, constant, arg);
- }
-
- @override
- visitStringFromEnvironmentConstructorInvoke(NewExpression node,
- StringFromEnvironmentConstantExpression constant, arg) {
- visits.add(new Visit(
- VisitKind.VISIT_STRING_FROM_ENVIRONMENT_CONSTRUCTOR_INVOKE,
- constant: constant.toDartText()));
- super.visitStringFromEnvironmentConstructorInvoke(node, constant, arg);
- }
-
- @override
- 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,
- arguments: arguments,
- selector: callStructure));
- super.errorNonConstantConstructorInvoke(
- node, element, type, arguments, callStructure, arg);
- }
-
- @override
- visitConstructorIncompatibleInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- NodeList arguments,
- CallStructure callStructure,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_CONSTRUCTOR_INCOMPATIBLE_INVOKE,
- element: constructor,
- type: type,
- arguments: arguments,
- selector: callStructure));
- super.visitConstructorIncompatibleInvoke(
- node, constructor, type, arguments, callStructure, arg);
- }
-
- @override
- visitFactoryConstructorInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- NodeList arguments,
- CallStructure callStructure,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_FACTORY_CONSTRUCTOR_INVOKE,
- element: constructor,
- type: type,
- arguments: arguments,
- selector: callStructure));
- apply(arguments, arg);
- }
-
- @override
- visitGenerativeConstructorInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- NodeList arguments,
- CallStructure callStructure,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_INVOKE,
- element: constructor,
- type: type,
- arguments: arguments,
- selector: callStructure));
- apply(arguments, arg);
- }
-
- @override
- visitRedirectingFactoryConstructorInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- ConstructorElement effectiveTarget,
- ResolutionInterfaceType effectiveTargetType,
- NodeList arguments,
- CallStructure callStructure,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- element: constructor,
- type: type,
- target: effectiveTarget,
- targetType: effectiveTargetType,
- arguments: arguments,
- selector: callStructure));
- apply(arguments, arg);
- }
-
- @override
- visitRedirectingGenerativeConstructorInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- NodeList arguments,
- CallStructure callStructure,
- arg) {
- visits.add(new Visit(
- VisitKind.VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_INVOKE,
- element: constructor,
- type: type,
- arguments: arguments,
- selector: callStructure));
- apply(arguments, arg);
- }
-
- @override
- visitAbstractClassConstructorInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- NodeList arguments,
- CallStructure callStructure,
- arg) {
- visits.add(new Visit(VisitKind.VISIT_ABSTRACT_CLASS_CONSTRUCTOR_INVOKE,
- element: constructor,
- type: type,
- arguments: arguments,
- selector: callStructure));
- apply(arguments, arg);
- }
-
- @override
- visitUnresolvedRedirectingFactoryConstructorInvoke(
- NewExpression node,
- ConstructorElement constructor,
- ResolutionInterfaceType type,
- NodeList arguments,
- CallStructure callStructure,
- arg) {
- visits.add(new Visit(
- VisitKind.VISIT_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
- element: constructor,
- type: type,
- arguments: arguments,
- selector: callStructure));
- apply(arguments, arg);
- }
-
- @override
- visitUnresolvedStaticGetterCompound(Send node, Element element,
- MethodElement setter, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_STATIC_GETTER_COMPOUND,
- setter: setter, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedTopLevelGetterCompound(Send node, Element element,
- MethodElement setter, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_GETTER_COMPOUND,
- setter: setter, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedStaticSetterCompound(Send node, MethodElement getter,
- Element element, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_STATIC_SETTER_COMPOUND,
- getter: getter, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedTopLevelSetterCompound(Send node, MethodElement getter,
- Element element, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_SETTER_COMPOUND,
- getter: getter, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitStaticMethodCompound(Send node, MethodElement method,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_METHOD_COMPOUND,
- element: method, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitTopLevelMethodCompound(Send node, MethodElement method,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_COMPOUND,
- element: method, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedStaticGetterPrefix(Send node, Element element,
- MethodElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_STATIC_GETTER_PREFIX,
- setter: setter, operator: operator));
- }
-
- @override
- visitUnresolvedTopLevelGetterPrefix(Send node, Element element,
- MethodElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_GETTER_PREFIX,
- setter: setter, operator: operator));
- }
-
- @override
- visitUnresolvedStaticSetterPrefix(Send node, MethodElement getter,
- Element element, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_STATIC_SETTER_PREFIX,
- getter: getter, operator: operator));
- }
-
- @override
- visitUnresolvedTopLevelSetterPrefix(Send node, MethodElement getter,
- Element element, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_SETTER_PREFIX,
- getter: getter, operator: operator));
- }
-
- @override
- visitStaticMethodPrefix(
- Send node, MethodElement method, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_METHOD_PREFIX,
- element: method, operator: operator));
- }
-
- @override
- visitTopLevelMethodPrefix(
- Send node, MethodElement method, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_PREFIX,
- element: method, operator: operator));
- }
-
- @override
- visitUnresolvedStaticGetterPostfix(Send node, Element element,
- MethodElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_STATIC_GETTER_POSTFIX,
- setter: setter, operator: operator));
- }
-
- @override
- visitUnresolvedTopLevelGetterPostfix(Send node, Element element,
- MethodElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_GETTER_POSTFIX,
- setter: setter, operator: operator));
- }
-
- @override
- visitUnresolvedStaticSetterPostfix(Send node, MethodElement getter,
- Element element, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_STATIC_SETTER_POSTFIX,
- getter: getter, operator: operator));
- }
-
- @override
- visitUnresolvedTopLevelSetterPostfix(Send node, MethodElement getter,
- Element element, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_SETTER_POSTFIX,
- getter: getter, operator: operator));
- }
-
- @override
- visitStaticMethodPostfix(
- Send node, MethodElement method, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_METHOD_POSTFIX,
- element: method, operator: operator));
- }
-
- @override
- visitTopLevelMethodPostfix(
- Send node, MethodElement method, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_POSTFIX,
- element: method, operator: operator));
- }
-
- @override
- visitUnresolvedSuperGetterCompound(Send node, Element element,
- MethodElement setter, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_COMPOUND,
- setter: setter, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedSuperGetterPostfix(Send node, Element element,
- MethodElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_POSTFIX,
- setter: setter, operator: operator));
- }
-
- @override
- visitUnresolvedSuperGetterPrefix(Send node, Element element,
- MethodElement setter, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_PREFIX,
- setter: setter, operator: operator));
- }
-
- @override
- visitUnresolvedSuperSetterCompound(Send node, MethodElement getter,
- Element element, AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_COMPOUND,
- getter: getter, operator: operator, rhs: rhs));
- apply(rhs, arg);
- }
-
- @override
- visitUnresolvedSuperSetterPostfix(Send node, MethodElement getter,
- Element element, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_POSTFIX,
- getter: getter, operator: operator));
- }
-
- @override
- visitUnresolvedSuperSetterPrefix(Send node, MethodElement getter,
- Element element, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_PREFIX,
- getter: getter, operator: operator));
- }
-
- @override
- visitIfNotNullDynamicPropertyGet(Send node, Node receiver, Name name, arg) {
- visits.add(new Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_GET,
- receiver: receiver, name: name));
- super.visitIfNotNullDynamicPropertyGet(node, receiver, name, arg);
- }
-
- @override
- visitIfNotNullDynamicPropertySet(
- Send node, Node receiver, Name name, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET,
- receiver: receiver, name: name, rhs: rhs));
- super.visitIfNotNullDynamicPropertySet(node, receiver, name, rhs, arg);
- }
-
- @override
- visitIfNotNullDynamicPropertyInvoke(
- Send node, Node receiver, NodeList arguments, Selector selector, arg) {
- visits.add(new Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_INVOKE,
- receiver: receiver, selector: selector, arguments: arguments));
- super.visitIfNotNullDynamicPropertyInvoke(
- node, receiver, arguments, selector, arg);
- }
-
- @override
- visitIfNotNullDynamicPropertyPrefix(
- Send node, Node receiver, Name name, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_PREFIX,
- receiver: receiver, name: name, operator: operator));
- super.visitIfNotNullDynamicPropertyPrefix(
- node, receiver, name, operator, arg);
- }
-
- @override
- visitIfNotNullDynamicPropertyPostfix(
- Send node, Node receiver, Name name, IncDecOperator operator, arg) {
- visits.add(new Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_POSTFIX,
- receiver: receiver, name: name, operator: operator));
- super.visitIfNotNullDynamicPropertyPostfix(
- node, receiver, name, operator, arg);
- }
-
- @override
- visitIfNotNullDynamicPropertyCompound(Send node, Node receiver, Name name,
- AssignmentOperator operator, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_COMPOUND,
- receiver: receiver, name: name, operator: operator, rhs: rhs));
- super.visitIfNotNullDynamicPropertyCompound(
- node, receiver, name, operator, rhs, arg);
- }
-
- @override
- visitIfNull(Send node, Node left, Node right, arg) {
- visits.add(new Visit(VisitKind.VISIT_IF_NULL, left: left, right: right));
- super.visitIfNull(node, left, right, arg);
- }
-
- @override
- visitConstantGet(Send node, ConstantExpression constant, arg) {
- visits.add(new Visit(VisitKind.VISIT_CONSTANT_GET,
- constant: constant.toDartText()));
- super.visitConstantGet(node, constant, arg);
- }
-
- @override
- visitConstantInvoke(Send node, ConstantExpression constant,
- NodeList arguments, CallStructure callStructure, arg) {
- visits.add(new Visit(VisitKind.VISIT_CONSTANT_INVOKE,
- constant: constant.toDartText()));
- super.visitConstantInvoke(node, constant, arguments, callStructure, arg);
- }
-
- @override
- previsitDeferredAccess(Send node, PrefixElement prefix, arg) {
- visits.add(new Visit(VisitKind.PREVISIT_DEFERRED_ACCESS, element: prefix));
- }
-
- @override
- visitClassTypeLiteralSetIfNull(
- Send node, ConstantExpression constant, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_SET_IF_NULL,
- constant: constant.toDartText(), rhs: rhs));
- super.visitClassTypeLiteralSetIfNull(node, constant, rhs, arg);
- }
-
- @override
- visitDynamicPropertySetIfNull(
- Send node, Node receiver, Name name, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_SET_IF_NULL,
- receiver: receiver, name: name, rhs: rhs));
- super.visitDynamicPropertySetIfNull(node, receiver, name, rhs, arg);
- }
-
- @override
- visitDynamicTypeLiteralSetIfNull(
- Send node, ConstantExpression constant, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_SET_IF_NULL,
- constant: constant.toDartText(), rhs: rhs));
- super.visitDynamicTypeLiteralSetIfNull(node, constant, rhs, arg);
- }
-
- @override
- visitFinalLocalVariableSetIfNull(
- Send node, LocalVariableElement variable, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_SET_IF_NULL,
- element: variable, rhs: rhs));
- super.visitFinalLocalVariableSetIfNull(node, variable, rhs, arg);
- }
-
- @override
- visitFinalParameterSetIfNull(
- Send node, ParameterElement parameter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_FINAL_PARAMETER_SET_IF_NULL,
- element: parameter, rhs: rhs));
- super.visitFinalParameterSetIfNull(node, parameter, rhs, arg);
- }
-
- @override
- visitFinalStaticFieldSetIfNull(Send node, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FINAL_FIELD_SET_IF_NULL,
- element: field, rhs: rhs));
- super.visitFinalStaticFieldSetIfNull(node, field, rhs, arg);
- }
-
- @override
- visitFinalSuperFieldSetIfNull(Send node, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FINAL_FIELD_SET_IF_NULL,
- element: field, rhs: rhs));
- super.visitFinalSuperFieldSetIfNull(node, field, rhs, arg);
- }
-
- @override
- visitFinalTopLevelFieldSetIfNull(
- Send node, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FINAL_FIELD_SET_IF_NULL,
- element: field, rhs: rhs));
- super.visitFinalTopLevelFieldSetIfNull(node, field, rhs, arg);
- }
-
- @override
- visitIfNotNullDynamicPropertySetIfNull(
- Send node, Node receiver, Name name, Node rhs, arg) {
- visits.add(new Visit(
- VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET_IF_NULL,
- receiver: receiver,
- name: name,
- rhs: rhs));
- super
- .visitIfNotNullDynamicPropertySetIfNull(node, receiver, name, rhs, arg);
- }
-
- @override
- visitLocalFunctionSetIfNull(
- Send node, LocalFunctionElement function, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_SET_IF_NULL,
- element: function, rhs: rhs));
- super.visitLocalFunctionSetIfNull(node, function, rhs, arg);
- }
-
- @override
- visitLocalVariableSetIfNull(
- Send node, LocalVariableElement variable, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_SET_IF_NULL,
- element: variable, rhs: rhs));
- super.visitLocalVariableSetIfNull(node, variable, rhs, arg);
- }
-
- @override
- visitParameterSetIfNull(
- Send node, ParameterElement parameter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_PARAMETER_SET_IF_NULL,
- element: parameter, rhs: rhs));
- super.visitParameterSetIfNull(node, parameter, rhs, arg);
- }
-
- @override
- visitStaticFieldSetIfNull(Send node, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_FIELD_SET_IF_NULL,
- element: field, rhs: rhs));
- super.visitStaticFieldSetIfNull(node, field, rhs, arg);
- }
-
- @override
- visitStaticGetterSetterSetIfNull(Send node, FunctionElement getter,
- FunctionElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_SET_IF_NULL,
- getter: getter, setter: setter, rhs: rhs));
- super.visitStaticGetterSetterSetIfNull(node, getter, setter, rhs, arg);
- }
-
- @override
- visitStaticMethodSetIfNull(Send node, FunctionElement method, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_METHOD_SET_IF_NULL,
- element: method, rhs: rhs));
- super.visitStaticMethodSetIfNull(node, method, rhs, arg);
- }
-
- @override
- visitStaticMethodSetterSetIfNull(
- Send node, MethodElement method, MethodElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_STATIC_METHOD_SETTER_SET_IF_NULL,
- getter: method, setter: setter, rhs: rhs));
- super.visitStaticMethodSetterSetIfNull(node, method, setter, rhs, arg);
- }
-
- @override
- visitSuperFieldFieldSetIfNull(Send node, FieldElement readField,
- FieldElement writtenField, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_FIELD_SET_IF_NULL,
- getter: readField, setter: writtenField, rhs: rhs));
- super
- .visitSuperFieldFieldSetIfNull(node, readField, writtenField, rhs, arg);
- }
-
- @override
- visitSuperFieldSetIfNull(Send node, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_SET_IF_NULL,
- element: field, rhs: rhs));
- super.visitSuperFieldSetIfNull(node, field, rhs, arg);
- }
-
- @override
- visitSuperFieldSetterSetIfNull(
- Send node, FieldElement field, FunctionElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_FIELD_SETTER_SET_IF_NULL,
- getter: field, setter: setter, rhs: rhs));
- super.visitSuperFieldSetterSetIfNull(node, field, setter, rhs, arg);
- }
-
- @override
- visitSuperGetterFieldSetIfNull(
- Send node, FunctionElement getter, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_GETTER_FIELD_SET_IF_NULL,
- getter: getter, setter: field, rhs: rhs));
- super.visitSuperGetterFieldSetIfNull(node, getter, field, rhs, arg);
- }
-
- @override
- visitSuperGetterSetterSetIfNull(Send node, FunctionElement getter,
- FunctionElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_GETTER_SETTER_SET_IF_NULL,
- getter: getter, setter: setter, rhs: rhs));
- super.visitSuperGetterSetterSetIfNull(node, getter, setter, rhs, arg);
- }
-
- @override
- visitSuperMethodSetIfNull(Send node, FunctionElement method, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_SET_IF_NULL,
- element: method, rhs: rhs));
- super.visitSuperMethodSetIfNull(node, method, rhs, arg);
- }
-
- @override
- visitSuperMethodSetterSetIfNull(Send node, FunctionElement method,
- FunctionElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_METHOD_SETTER_SET_IF_NULL,
- getter: method, setter: setter, rhs: rhs));
- super.visitSuperMethodSetterSetIfNull(node, method, setter, rhs, arg);
- }
-
- @override
- visitThisPropertySetIfNull(Send node, Name name, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_THIS_PROPERTY_SET_IF_NULL,
- name: name, rhs: rhs));
- super.visitThisPropertySetIfNull(node, name, rhs, arg);
- }
-
- @override
- visitTopLevelFieldSetIfNull(Send node, FieldElement field, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_SET_IF_NULL,
- element: field, rhs: rhs));
- super.visitTopLevelFieldSetIfNull(node, field, rhs, arg);
- }
-
- @override
- visitTopLevelGetterSetterSetIfNull(Send node, FunctionElement getter,
- FunctionElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_SETTER_SET_IF_NULL,
- getter: getter, setter: setter, rhs: rhs));
- super.visitTopLevelGetterSetterSetIfNull(node, getter, setter, rhs, arg);
- }
-
- @override
- visitTopLevelMethodSetIfNull(
- Send node, FunctionElement method, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_SET_IF_NULL,
- element: method, rhs: rhs));
- super.visitTopLevelMethodSetIfNull(node, method, rhs, arg);
- }
-
- @override
- visitTopLevelMethodSetterSetIfNull(Send node, FunctionElement method,
- FunctionElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_METHOD_SETTER_SET_IF_NULL,
- getter: method, setter: setter, rhs: rhs));
- super.visitTopLevelMethodSetterSetIfNull(node, method, setter, rhs, arg);
- }
-
- @override
- visitTypeVariableTypeLiteralSetIfNull(
- Send node, TypeVariableElement element, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_SET_IF_NULL,
- element: element, rhs: rhs));
- super.visitTypeVariableTypeLiteralSetIfNull(node, element, rhs, arg);
- }
-
- @override
- visitTypedefTypeLiteralSetIfNull(
- Send node, ConstantExpression constant, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_SET_IF_NULL,
- constant: constant.toDartText(), rhs: rhs));
- super.visitTypedefTypeLiteralSetIfNull(node, constant, rhs, arg);
- }
-
- @override
- visitUnresolvedSetIfNull(Send node, Element element, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SET_IF_NULL,
- name: element.name, rhs: rhs));
- super.visitUnresolvedSetIfNull(node, element, rhs, arg);
- }
-
- @override
- visitUnresolvedStaticGetterSetIfNull(
- Send node, Element element, MethodElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_STATIC_GETTER_SET_IF_NULL,
- setter: setter, rhs: rhs));
- super.visitUnresolvedStaticGetterSetIfNull(node, element, setter, rhs, arg);
- }
-
- @override
- visitUnresolvedStaticSetterSetIfNull(
- Send node, MethodElement getter, Element element, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_STATIC_SETTER_SET_IF_NULL,
- getter: getter, rhs: rhs));
- super.visitUnresolvedStaticSetterSetIfNull(node, getter, element, rhs, arg);
- }
-
- @override
- visitUnresolvedSuperGetterSetIfNull(
- Send node, Element element, MethodElement setter, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_SET_IF_NULL,
- setter: setter, rhs: rhs));
- super.visitUnresolvedSuperGetterSetIfNull(node, element, setter, rhs, arg);
- }
-
- @override
- visitUnresolvedSuperSetIfNull(Send node, Element element, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SET_IF_NULL,
- name: element.name, rhs: rhs));
- super.visitUnresolvedSuperSetIfNull(node, element, rhs, arg);
- }
-
- @override
- visitUnresolvedSuperSetterSetIfNull(
- Send node, MethodElement getter, Element element, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_SET_IF_NULL,
- getter: getter, rhs: rhs));
- super.visitUnresolvedSuperSetterSetIfNull(node, getter, element, rhs, arg);
- }
-
- @override
- visitUnresolvedTopLevelGetterSetIfNull(
- Send node, Element element, MethodElement setter, Node rhs, arg) {
- visits.add(new Visit(
- VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_GETTER_SET_IF_NULL,
- setter: setter,
- rhs: rhs));
- super.visitUnresolvedTopLevelGetterSetIfNull(
- node, element, setter, rhs, arg);
- }
-
- @override
- visitUnresolvedTopLevelSetterSetIfNull(
- Send node, MethodElement getter, Element element, Node rhs, arg) {
- visits.add(new Visit(
- VisitKind.VISIT_UNRESOLVED_TOP_LEVEL_SETTER_SET_IF_NULL,
- getter: getter,
- rhs: rhs));
- super.visitUnresolvedTopLevelSetterSetIfNull(
- node, getter, element, rhs, arg);
- }
-
- @override
- visitIndexSetIfNull(SendSet node, Node receiver, Node index, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_INDEX_SET_IF_NULL,
- receiver: receiver, index: index, rhs: rhs));
- super.visitIndexSetIfNull(node, receiver, index, rhs, arg);
- }
-
- @override
- visitSuperIndexSetIfNull(SendSet node, MethodElement getter,
- MethodElement setter, Node index, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_SUPER_INDEX_SET_IF_NULL,
- getter: getter, setter: setter, index: index, rhs: rhs));
- super.visitSuperIndexSetIfNull(node, getter, setter, index, rhs, arg);
- }
-
- @override
- visitUnresolvedSuperGetterIndexSetIfNull(Send node, Element element,
- MethodElement setter, Node index, Node rhs, arg) {
- visits.add(new Visit(
- VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_SET_IF_NULL,
- setter: setter,
- index: index,
- rhs: rhs));
- super.visitUnresolvedSuperGetterIndexSetIfNull(
- node, element, setter, index, rhs, arg);
- }
-
- @override
- visitUnresolvedSuperSetterIndexSetIfNull(Send node, MethodElement getter,
- Element element, Node index, Node rhs, arg) {
- visits.add(new Visit(
- VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_INDEX_SET_IF_NULL,
- getter: getter,
- index: index,
- rhs: rhs));
- super.visitUnresolvedSuperSetterIndexSetIfNull(
- node, getter, element, index, rhs, arg);
- }
-
- @override
- visitUnresolvedSuperIndexSetIfNull(
- Send node, Element element, Node index, Node rhs, arg) {
- visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX_SET_IF_NULL,
- index: index, rhs: rhs));
- super.visitUnresolvedSuperIndexSetIfNull(node, element, index, rhs, arg);
- }
-
- @override
- errorInvalidIndexSetIfNull(
- SendSet node, ErroneousElement error, Node index, Node rhs, arg) {
- visits.add(
- new Visit(VisitKind.ERROR_INVALID_SET_IF_NULL, index: index, rhs: rhs));
- super.visitUnresolvedSuperIndexSetIfNull(node, error, index, rhs, arg);
- }
-}
diff --git a/tests/compiler/dart2js/old_frontend/size_test.dart b/tests/compiler/dart2js/old_frontend/size_test.dart
deleted file mode 100644
index 95a1946..0000000
--- a/tests/compiler/dart2js/old_frontend/size_test.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2013, 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 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import "../compiler_helper.dart";
-
-const String TEST = "main() => [];";
-
-const Map<String, String> DEFAULT_CORELIB_WITH_LIST = const <String, String>{
- 'Object': 'class Object { const Object(); }',
- 'bool': 'class bool {}',
- 'List': 'abstract class List<E> {}',
- 'num': 'class num {}',
- 'int': 'class int {}',
- 'double': 'class double {}',
- 'String': 'class String {}',
- 'Function': 'class Function {}',
- 'Null': 'class Null {}',
- 'Type': 'class Type {}',
- 'Map': 'class Map {}',
- 'StackTrace': 'class StackTrace {}',
- 'identical': 'identical(a, b) => true;',
- 'proxy': 'const proxy = 0;',
-};
-
-main() {
- asyncTest(() =>
- compileAll(TEST, coreSource: DEFAULT_CORELIB_WITH_LIST).then((generated) {
- return MockCompiler.create((MockCompiler compiler) {
- // Make sure no class is emitted.
- Expect.isFalse(generated.contains('finishClasses'), generated);
- });
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/space_test.dart b/tests/compiler/dart2js/old_frontend/space_test.dart
deleted file mode 100644
index 8ffc6471..0000000
--- a/tests/compiler/dart2js/old_frontend/space_test.dart
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2014, 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:compiler/src/dart2js.dart' as dart2js;
-import 'package:compiler/src/commandline_options.dart';
-
-main() {
- Uri currentDirectory = Uri.base;
- Uri script = currentDirectory.resolveUri(Platform.script);
- Uri libraryRoot = script.resolve('../../../../sdk/');
- Directory.current = script.resolve("../path with spaces").toFilePath();
-
- return dart2js.main([
- "--library-root=${libraryRoot.toFilePath()}",
- Flags.analyzeOnly,
- Flags.useOldFrontend,
- "file with spaces.dart"
- ]);
-}
diff --git a/tests/compiler/dart2js/old_frontend/tag_mapping_test.dart b/tests/compiler/dart2js/old_frontend/tag_mapping_test.dart
deleted file mode 100644
index 9eff042..0000000
--- a/tests/compiler/dart2js/old_frontend/tag_mapping_test.dart
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test of import tag to library mapping.
-
-import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import '../compiler_helper.dart';
-
-const MAIN_CODE = """
-import 'library.dart';
-
-main() {
-}
-""";
-
-const LIB_CODE = """
-library lib;
-""";
-
-void main() {
- var sources = <String, String>{
- 'main.dart': MAIN_CODE,
- 'library.dart': LIB_CODE,
- };
-
- asyncTest(() => compileSources(sources, (MockCompiler compiler) {
- LibraryElement mainApp = compiler.libraryLoader
- .lookupLibrary(Uri.parse('source:/main.dart'));
- LibraryElement lib = compiler.libraryLoader
- .lookupLibrary(Uri.parse('source:/library.dart'));
- Expect.isNotNull(mainApp, 'Could not find main.dart library');
- Expect.isNotNull(lib, 'Could not find library.dart library');
-
- ImportElement import = mainApp.imports.single;
- Expect.isNotNull(import, 'Could not find import tag in $mainApp');
-
- // Test that we can get from the import tag in main.dart to the
- // library element representing library.dart.
- Expect.identical(lib, import.importedLibrary);
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/type_checker_test.dart b/tests/compiler/dart2js/old_frontend/type_checker_test.dart
deleted file mode 100644
index 6f4bcd5..0000000
--- a/tests/compiler/dart2js/old_frontend/type_checker_test.dart
+++ /dev/null
@@ -1,2621 +0,0 @@
-// Copyright (c) 2011, 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:async';
-
-import 'package:async_helper/async_helper.dart';
-import 'package:expect/expect.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'
- show ClassElementX, CompilationUnitElementX, ElementX;
-import 'package:compiler/src/io/source_file.dart';
-import 'package:compiler/src/resolution/tree_elements.dart'
- show TreeElements, TreeElementMapping;
-import 'package:compiler/src/parser/element_listener.dart';
-import 'package:compiler/src/tree/tree.dart';
-import 'package:compiler/src/typechecker.dart';
-import 'package:compiler/src/script.dart';
-import 'package:compiler/src/util/util.dart';
-
-import 'mock_compiler.dart';
-import 'parser_helper.dart';
-
-final MessageKind NOT_ASSIGNABLE = MessageKind.NOT_ASSIGNABLE;
-final MessageKind UNDEFINED_GETTER = MessageKind.UNDEFINED_GETTER;
-
-main() {
- List tests = [
- testSimpleTypes,
- testReturn,
- testFor,
- testSyncForIn,
- testAsyncForIn,
- testWhile,
- testTry,
- testSwitch,
- testEnumSwitch,
- testOperators,
- testConstructorInvocationArgumentCount,
- testConstructorInvocationArgumentTypes,
- testMethodInvocationArgumentCount,
- testMethodInvocations,
- testMethodInvocationsInClass,
- testGetterSetterInvocation,
- // testNewExpression,
- testConditionalExpression,
- testIfStatement,
- testThis,
- testSuper,
- testOperatorsAssignability,
- testFieldInitializers,
- testTypeVariableExpressions,
- testTypeVariableLookup1,
- testTypeVariableLookup2,
- testTypeVariableLookup3,
- testFunctionTypeLookup,
- testTypedefLookup,
- testTypeLiteral,
- testInitializers,
- testTypePromotionHints,
- testFunctionCall,
- testCascade,
- testAwait,
- testAsyncReturn
- ];
- asyncTest(() => Future.forEach(tests, (test) => setup(test)));
-}
-
-testSimpleTypes(MockCompiler compiler) {
- checkType(ResolutionInterfaceType type, String code) {
- Expect.equals(type, analyzeType(compiler, code));
- }
-
- checkType(compiler.resolution.commonElements.intType, "3");
- checkType(compiler.resolution.commonElements.boolType, "false");
- checkType(compiler.resolution.commonElements.boolType, "true");
- checkType(compiler.resolution.commonElements.stringType, "'hestfisk'");
-}
-
-Future testReturn(MockCompiler compiler) {
- Future check(String code, [expectedWarnings]) {
- return analyzeTopLevel(code, expectedWarnings);
- }
-
- return Future.wait([
- check("void foo() { return 3; }", MessageKind.RETURN_VALUE_IN_VOID),
- check("int bar() { return 'hest'; }", NOT_ASSIGNABLE),
- check("void baz() { var x; return x; }"),
- check(returnWithType("int", "'string'"), NOT_ASSIGNABLE),
- check(returnWithType("", "'string'")),
- check(returnWithType("Object", "'string'")),
- check(returnWithType("String", "'string'")),
- check(returnWithType("String", null)),
- check(returnWithType("int", null)),
- check(returnWithType("void", "")),
- check(returnWithType("void", 1), MessageKind.RETURN_VALUE_IN_VOID),
- check(returnWithType("void", null)),
- check(returnWithType("String", ""), MessageKind.RETURN_NOTHING),
- check(arrowReturnWithType("void", "4")),
- check("void set foo(x) => 5;"),
- // check("String foo() {};"), // Should probably fail.
- ]);
-}
-
-testFor(MockCompiler compiler) {
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- check("for (var x;true;x = x + 1) {}");
- check("for (var x;null;x = x + 1) {}");
- check("for (var x;0;x = x + 1) {}", warnings: NOT_ASSIGNABLE);
- check("for (var x;'';x = x + 1) {}", warnings: NOT_ASSIGNABLE);
-
- check("for (;true;) {}");
- check("for (;null;) {}");
- check("for (;0;) {}", warnings: NOT_ASSIGNABLE);
- check("for (;'';) {}", warnings: NOT_ASSIGNABLE);
-
- // Foreach tests
-// TODO(karlklose): for each is not yet implemented.
-// check("{ List<String> strings = ['1','2','3']; " +
-// "for (String s in strings) {} }");
-// check("{ List<int> ints = [1,2,3]; for (String s in ints) {} }",
-// NOT_ASSIGNABLE);
-// check("for (String s in true) {}", MessageKind.UNDEFINED_METHOD);
-}
-
-testSyncForIn(MockCompiler compiler) {
- String script = """
-class HasUntypedIterator {
- get iterator => null;
-}
-
-class HasIntIterator {
- Iterator<int> get iterator => null;
-}
-
-class HasNoIterator {
-}
-
-class HasCustomIntIterator {
- CustomIntIterator get iterator => null;
-}
-
-class CustomIntIterator {
- int current;
-}
-
-class HasCustomNoCurrentIterator {
- CustomNoCurrentIterator get iterator => null;
-}
-
-class CustomNoCurrentIterator {
-}
-
-var topLevelDyn;
-String topLevelString;
-int topLevelInt;
-
-class Class {
- void forIn() {}
-
- var instanceDyn;
- String instanceString;
- int instanceInt;
-
- static var staticDyn;
- static String staticString;
- static int staticInt;
-}
-""";
- compiler.parseScript(script);
- LibraryElement mainApp = compiler.mainApp;
- ClassElement foo = mainApp.find("Class");
- foo.ensureResolved(compiler.resolution);
- FunctionElement method = foo.lookupLocalMember('forIn');
-
- analyzeIn(compiler, method, """{
- for (var e in <String>[]) {}
- }""");
- analyzeIn(compiler, method, """{
- for (String e in <String>[]) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- for (int e in <String>[]) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
- analyzeIn(compiler, method, """{
- for (int e in []) {}
- }""");
-
- analyzeIn(compiler, method, """{
- for (var e in new HasUntypedIterator()) {}
- }""");
- analyzeIn(compiler, method, """{
- for (String e in new HasUntypedIterator()) {}
- }""");
- analyzeIn(compiler, method, """{
- for (int e in new HasUntypedIterator()) {}
- }""");
-
- analyzeIn(compiler, method, """{
- for (var e in new HasIntIterator()) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- for (String e in new HasIntIterator()) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
- analyzeIn(compiler, method, """{
- for (int e in new HasIntIterator()) {}
- }""");
-
- analyzeIn(
- compiler,
- method,
- """{
- for (var e in new HasNoIterator()) {}
- }""",
- warnings: MessageKind.UNDEFINED_GETTER);
- analyzeIn(
- compiler,
- method,
- """{
- for (String e in new HasNoIterator()) {}
- }""",
- warnings: MessageKind.UNDEFINED_GETTER);
- analyzeIn(
- compiler,
- method,
- """{
- for (int e in new HasNoIterator()) {}
- }""",
- warnings: MessageKind.UNDEFINED_GETTER);
-
- analyzeIn(compiler, method, """{
- for (var e in new HasCustomIntIterator()) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- for (String e in new HasCustomIntIterator()) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
- analyzeIn(compiler, method, """{
- for (int e in new HasCustomIntIterator()) {}
- }""");
-
- analyzeIn(
- compiler,
- method,
- """{
- for (var e in new HasCustomNoCurrentIterator()) {}
- }""",
- hints: MessageKind.UNDEFINED_GETTER);
- analyzeIn(
- compiler,
- method,
- """{
- for (String e in new HasCustomNoCurrentIterator()) {}
- }""",
- hints: MessageKind.UNDEFINED_GETTER);
- analyzeIn(
- compiler,
- method,
- """{
- for (int e in new HasCustomNoCurrentIterator()) {}
- }""",
- hints: MessageKind.UNDEFINED_GETTER);
-
- analyzeIn(compiler, method, """{
- var localDyn;
- for (localDyn in <String>[]) {}
- }""");
- analyzeIn(compiler, method, """{
- String localString;
- for (localString in <String>[]) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- int localInt;
- for (localInt in <String>[]) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, """{
- for (topLevelDyn in <String>[]) {}
- }""");
- analyzeIn(compiler, method, """{
- for (topLevelString in <String>[]) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- for (topLevelInt in <String>[]) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, """{
- for (instanceDyn in <String>[]) {}
- }""");
- analyzeIn(compiler, method, """{
- for (instanceString in <String>[]) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- for (instanceInt in <String>[]) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, """{
- for (staticDyn in <String>[]) {}
- }""");
- analyzeIn(compiler, method, """{
- for (staticString in <String>[]) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- for (staticInt in <String>[]) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-}
-
-testAsyncForIn(MockCompiler compiler) {
- String script = """
-abstract class CustomStream<T> implements Stream<T> {}
-abstract class StringStream implements Stream<String> {}
-
-var topLevelDyn;
-String topLevelString;
-int topLevelInt;
-
-class Class {
- void forIn() async {}
-
- var instanceDyn;
- String instanceString;
- int instanceInt;
-
- static var staticDyn;
- static String staticString;
- static int staticInt;
-}
-""";
- compiler.parseScript(script);
- LibraryElement mainApp = compiler.mainApp;
- ClassElement foo = mainApp.find("Class");
- foo.ensureResolved(compiler.resolution);
- FunctionElement method = foo.lookupLocalMember('forIn');
-
- analyzeIn(compiler, method, """{
- var stream;
- await for (var e in stream) {}
- }""");
- analyzeIn(compiler, method, """{
- var stream;
- await for (String e in stream) {}
- }""");
- analyzeIn(compiler, method, """{
- var stream;
- await for (int e in stream) {}
- }""");
-
- analyzeIn(
- compiler,
- method,
- """{
- await for (var e in []) {}
- }""",
- hints: MessageKind.NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, """{
- Stream<String> stream;
- await for (var e in stream) {}
- }""");
- analyzeIn(compiler, method, """{
- Stream<String> stream;
- await for (String e in stream) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- Stream<String> stream;
- await for (int e in stream) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, """{
- CustomStream<String> stream;
- await for (var e in stream) {}
- }""");
- analyzeIn(compiler, method, """{
- CustomStream<String> stream;
- await for (String e in stream) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- CustomStream<String> stream;
- await for (int e in stream) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, """{
- StringStream stream;
- await for (var e in stream) {}
- }""");
- analyzeIn(compiler, method, """{
- StringStream stream;
- await for (String e in stream) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- StringStream stream;
- await for (int e in stream) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, """{
- Stream<String> stream;
- var localDyn;
- await for (localDyn in stream) {}
- }""");
- analyzeIn(compiler, method, """{
- Stream<String> stream;
- String localString;
- await for (localString in stream) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- Stream<String> stream;
- int localInt;
- await for (localInt in stream) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, """{
- Stream<String> stream;
- await for (topLevelDyn in stream) {}
- }""");
- analyzeIn(compiler, method, """{
- Stream<String> stream;
- await for (topLevelString in stream) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- Stream<String> stream;
- await for (topLevelInt in stream) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, """{
- Stream<String> stream;
- await for (instanceDyn in stream) {}
- }""");
- analyzeIn(compiler, method, """{
- Stream<String> stream;
- await for (instanceString in stream) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- Stream<String> stream;
- await for (instanceInt in stream) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, """{
- Stream<String> stream;
- await for (staticDyn in stream) {}
- }""");
- analyzeIn(compiler, method, """{
- Stream<String> stream;
- await for (staticString in stream) {}
- }""");
- analyzeIn(
- compiler,
- method,
- """{
- Stream<String> stream;
- await for (staticInt in stream) {}
- }""",
- hints: MessageKind.FORIN_NOT_ASSIGNABLE);
-}
-
-testWhile(MockCompiler compiler) {
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- check("while (true) {}");
- check("while (null) {}");
- check("while (0) {}", warnings: NOT_ASSIGNABLE);
- check("while ('') {}", warnings: NOT_ASSIGNABLE);
-
- check("do {} while (true);");
- check("do {} while (null);");
- check("do {} while (0);", warnings: NOT_ASSIGNABLE);
- check("do {} while ('');", warnings: NOT_ASSIGNABLE);
- check("do { int i = 0.5; } while (true);", warnings: NOT_ASSIGNABLE);
- check("do { int i = 0.5; } while (null);", warnings: NOT_ASSIGNABLE);
-}
-
-testTry(MockCompiler compiler) {
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- check("try {} finally {}");
- check("try {} catch (e) { int i = e;} finally {}");
- check("try {} catch (e, s) { int i = e; StackTrace j = s; } finally {}");
- check("try {} on String catch (e) {} finally {}");
- check("try { int i = ''; } finally {}", warnings: NOT_ASSIGNABLE);
- check("try {} finally { int i = ''; }", warnings: NOT_ASSIGNABLE);
- check("try {} on String catch (e) { int i = e; } finally {}",
- warnings: NOT_ASSIGNABLE);
- check("try {} catch (e, s) { int i = e; int j = s; } finally {}",
- warnings: NOT_ASSIGNABLE);
- check("try {} on String catch (e, s) { int i = e; int j = s; } finally {}",
- warnings: [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-}
-
-testSwitch(MockCompiler compiler) {
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- check("switch (0) { case 1: break; case 2: break; }");
- check("switch (0) { case 1: int i = ''; break; case 2: break; }",
- warnings: NOT_ASSIGNABLE);
- check("switch (0) { case '': break; }", warnings: NOT_ASSIGNABLE);
- check("switch ('') { case 1: break; case 2: break; }",
- warnings: [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
- check("switch (1.5) { case 1: break; case 2: break; }",
- warnings: [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-}
-
-testEnumSwitch(MockCompiler compiler) {
- String DECLARATIONS = """
-enum Enum { A, B, C }
-""";
-
- check(String code, {warnings}) {
- MockCompiler compiler = new MockCompiler.internal();
- return compiler.init(DECLARATIONS).then((_) {
- analyze(compiler, code, warnings: warnings, flushDeferred: true);
- });
- }
-
- check("""
-switch (Enum.A) {
-default: break;
-}""");
-
- check("""
-switch (Enum.A) {
-case Enum.A: break;
-default: break;
-}""");
-
- check("""
-switch (Enum.A) {
-case Enum.A: break;
-case Enum.B: break;
-default: break;
-}""");
-
- check("""
-switch (Enum.A) {
-case Enum.A: break;
-case Enum.B: break;
-case Enum.C: break;
-default: break;
-}""");
-
- check("""
-switch (Enum.A) {
-case Enum.A: break;
-case Enum.B: break;
-case Enum.C: break;
-}""");
-
- check("""
-switch (Enum.A) {
-case Enum.B: break;
-case Enum.C: break;
-}""", warnings: MessageKind.MISSING_ENUM_CASES);
-
- check("""
-switch (Enum.A) {
-case Enum.A: break;
-case Enum.C: break;
-}""", warnings: MessageKind.MISSING_ENUM_CASES);
-
- check("""
-switch (Enum.A) {
-case Enum.A: break;
-case Enum.B: break;
-}""", warnings: MessageKind.MISSING_ENUM_CASES);
-
- check("""
-switch (Enum.A) {
-case Enum.A: break;
-}""", warnings: MessageKind.MISSING_ENUM_CASES);
-
- check("""
-switch (Enum.A) {
-case Enum.B: break;
-}""", warnings: MessageKind.MISSING_ENUM_CASES);
-
- check("""
-switch (Enum.A) {
-case Enum.C: break;
-}""", warnings: MessageKind.MISSING_ENUM_CASES);
-
- check("""
-switch (Enum.A) {
-}""", warnings: MessageKind.MISSING_ENUM_CASES);
-}
-
-testOperators(MockCompiler compiler) {
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- // TODO(karlklose): add the DartC tests for operators when we can parse
- // classes with operators.
- for (final op in ['+', '-', '*', '/', '%', '~/', '|', '&']) {
- check("{ var i = 1 ${op} 2; }");
- check("{ var i = 1; i ${op}= 2; }");
- check("{ int i; var j = (i = true) ${op} 2; }",
- warnings: [NOT_ASSIGNABLE, MessageKind.UNDEFINED_OPERATOR]);
- check("{ int i; var j = 1 ${op} (i = true); }",
- warnings: [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
- }
- for (final op in ['-', '~']) {
- check("{ var i = ${op}1; }");
- check("{ int i; var j = ${op}(i = true); }",
- warnings: [NOT_ASSIGNABLE, MessageKind.UNDEFINED_OPERATOR]);
- }
- for (final op in ['++', '--']) {
- check("{ int i = 1; int j = i${op}; }");
- check("{ int i = 1; bool j = i${op}; }", warnings: NOT_ASSIGNABLE);
- check("{ bool b = true; bool j = b${op}; }",
- warnings: MessageKind.UNDEFINED_OPERATOR);
- check("{ bool b = true; int j = ${op}b; }",
- warnings: MessageKind.UNDEFINED_OPERATOR);
- }
- for (final op in ['||', '&&']) {
- check("{ bool b = (true ${op} false); }");
- check("{ int b = true ${op} false; }", warnings: NOT_ASSIGNABLE);
- check("{ bool b = (1 ${op} false); }", warnings: NOT_ASSIGNABLE);
- check("{ bool b = (true ${op} 2); }", warnings: NOT_ASSIGNABLE);
- }
- for (final op in ['>', '<', '<=', '>=']) {
- check("{ bool b = 1 ${op} 2; }");
- check("{ int i = 1 ${op} 2; }", warnings: NOT_ASSIGNABLE);
- check("{ int i; bool b = (i = true) ${op} 2; }",
- warnings: [NOT_ASSIGNABLE, MessageKind.UNDEFINED_OPERATOR]);
- check("{ int i; bool b = 1 ${op} (i = true); }",
- warnings: [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
- }
- for (final op in ['==', '!=']) {
- check("{ bool b = 1 ${op} 2; }");
- check("{ int i = 1 ${op} 2; }", warnings: NOT_ASSIGNABLE);
- check("{ int i; bool b = (i = true) ${op} 2; }", warnings: NOT_ASSIGNABLE);
- check("{ int i; bool b = 1 ${op} (i = true); }", warnings: NOT_ASSIGNABLE);
- }
-}
-
-void testConstructorInvocationArgumentCount(MockCompiler compiler) {
- compiler.parseScript("""
- class C1 { C1(x, y); }
- class C2 { C2(int x, int y); }
- """);
-
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- // calls to untyped constructor C1
- check("new C1(1, 2);");
- check("new C1();", warnings: MessageKind.MISSING_ARGUMENT);
- check("new C1(1);", warnings: MessageKind.MISSING_ARGUMENT);
- check("new C1(1, 2, 3);", warnings: MessageKind.ADDITIONAL_ARGUMENT);
- // calls to typed constructor C2
- check("new C2(1, 2);");
- check("new C2();", warnings: MessageKind.MISSING_ARGUMENT);
- check("new C2(1);", warnings: MessageKind.MISSING_ARGUMENT);
- check("new C2(1, 2, 3);", warnings: MessageKind.ADDITIONAL_ARGUMENT);
-}
-
-void testConstructorInvocationArgumentTypes(MockCompiler compiler) {
- compiler.parseScript("""
- class C1 { C1(x); }
- class C2 { C2(int x); }
- class C3 {
- int field;
- C3(this.field);
- C3.named(this.field);
- }
- """);
-
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- check("new C1(42);");
- check("new C1('string');");
- check("new C2(42);");
- check("new C2('string');", warnings: NOT_ASSIGNABLE);
- check("new C3(42);");
- check("new C3('string');", warnings: NOT_ASSIGNABLE);
- check("new C3.named(42);");
- check("new C3.named('string');", warnings: NOT_ASSIGNABLE);
-}
-
-void testMethodInvocationArgumentCount(MockCompiler compiler) {
- compiler.parseScript(CLASS_WITH_METHODS);
-
- check(String text, [expectedWarnings]) {
- analyze(compiler, "{ ClassWithMethods c; $text }",
- warnings: expectedWarnings);
- }
-
- check("c.untypedNoArgumentMethod(1);", MessageKind.ADDITIONAL_ARGUMENT);
- check("c.untypedOneArgumentMethod();", MessageKind.MISSING_ARGUMENT);
- check("c.untypedOneArgumentMethod(1, 1);", MessageKind.ADDITIONAL_ARGUMENT);
- check("c.untypedTwoArgumentMethod();", MessageKind.MISSING_ARGUMENT);
- check(
- "c.untypedTwoArgumentMethod(1, 2, 3);", MessageKind.ADDITIONAL_ARGUMENT);
- check("c.intNoArgumentMethod(1);", MessageKind.ADDITIONAL_ARGUMENT);
- check("c.intOneArgumentMethod();", MessageKind.MISSING_ARGUMENT);
- check("c.intOneArgumentMethod(1, 1);", MessageKind.ADDITIONAL_ARGUMENT);
- check("c.intTwoArgumentMethod();", MessageKind.MISSING_ARGUMENT);
- check("c.intTwoArgumentMethod(1, 2, 3);", MessageKind.ADDITIONAL_ARGUMENT);
- // check("c.untypedField();");
-
- check("c.intOneArgumentOneOptionalMethod();", [MessageKind.MISSING_ARGUMENT]);
- check("c.intOneArgumentOneOptionalMethod(0);");
- check("c.intOneArgumentOneOptionalMethod(0, 1);");
- check("c.intOneArgumentOneOptionalMethod(0, 1, 2);",
- [MessageKind.ADDITIONAL_ARGUMENT]);
- check("c.intOneArgumentOneOptionalMethod(0, 1, c: 2);",
- [MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
- check("c.intOneArgumentOneOptionalMethod(0, b: 1);",
- [MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
- check("c.intOneArgumentOneOptionalMethod(a: 0, b: 1);", [
- MessageKind.NAMED_ARGUMENT_NOT_FOUND,
- MessageKind.NAMED_ARGUMENT_NOT_FOUND,
- MessageKind.MISSING_ARGUMENT
- ]);
-
- check("c.intTwoOptionalMethod();");
- check("c.intTwoOptionalMethod(0);");
- check("c.intTwoOptionalMethod(0, 1);");
- check("c.intTwoOptionalMethod(0, 1, 2);", [MessageKind.ADDITIONAL_ARGUMENT]);
- check(
- "c.intTwoOptionalMethod(a: 0);", [MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
- check("c.intTwoOptionalMethod(0, b: 1);",
- [MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
-
- check("c.intOneArgumentOneNamedMethod();", [MessageKind.MISSING_ARGUMENT]);
- check("c.intOneArgumentOneNamedMethod(0);");
- check("c.intOneArgumentOneNamedMethod(0, b: 1);");
- check(
- "c.intOneArgumentOneNamedMethod(b: 1);", [MessageKind.MISSING_ARGUMENT]);
- check("c.intOneArgumentOneNamedMethod(0, b: 1, c: 2);",
- [MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
- check("c.intOneArgumentOneNamedMethod(0, 1);",
- [MessageKind.ADDITIONAL_ARGUMENT]);
- check("c.intOneArgumentOneNamedMethod(0, 1, c: 2);",
- [MessageKind.ADDITIONAL_ARGUMENT, MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
- check("c.intOneArgumentOneNamedMethod(a: 1, b: 1);",
- [MessageKind.NAMED_ARGUMENT_NOT_FOUND, MessageKind.MISSING_ARGUMENT]);
-
- check("c.intTwoNamedMethod();");
- check("c.intTwoNamedMethod(a: 0);");
- check("c.intTwoNamedMethod(b: 1);");
- check("c.intTwoNamedMethod(a: 0, b: 1);");
- check("c.intTwoNamedMethod(b: 1, a: 0);");
- check("c.intTwoNamedMethod(0);", [MessageKind.ADDITIONAL_ARGUMENT]);
- check("c.intTwoNamedMethod(c: 2);", [MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
- check("c.intTwoNamedMethod(a: 0, c: 2);",
- [MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
- check("c.intTwoNamedMethod(a: 0, b: 1, c: 2);",
- [MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
- check("c.intTwoNamedMethod(c: 2, b: 1, a: 0);",
- [MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
- check("c.intTwoNamedMethod(0, b: 1);", [MessageKind.ADDITIONAL_ARGUMENT]);
- check("c.intTwoNamedMethod(0, 1);",
- [MessageKind.ADDITIONAL_ARGUMENT, MessageKind.ADDITIONAL_ARGUMENT]);
- check("c.intTwoNamedMethod(0, c: 2);",
- [MessageKind.ADDITIONAL_ARGUMENT, MessageKind.NAMED_ARGUMENT_NOT_FOUND]);
-}
-
-void testMethodInvocations(MockCompiler compiler) {
- compiler.parseScript(CLASS_WITH_METHODS);
-
- check(String text, [expectedWarnings]) {
- analyze(
- compiler,
- """{
- ClassWithMethods c;
- SubClass d;
- var e;
- int i;
- int j;
- int localMethod(String str) { return 0; }
- $text
- }
- """,
- warnings: expectedWarnings);
- }
-
- check("int k = c.untypedNoArgumentMethod();");
- check("ClassWithMethods x = c.untypedNoArgumentMethod();");
- check("ClassWithMethods x = d.untypedNoArgumentMethod();");
- check("int k = d.intMethod();");
- check("int k = c.untypedOneArgumentMethod(c);");
- check("ClassWithMethods x = c.untypedOneArgumentMethod(1);");
- check("int k = c.untypedOneArgumentMethod('string');");
- check("int k = c.untypedOneArgumentMethod(i);");
- check("int k = d.untypedOneArgumentMethod(d);");
- check("ClassWithMethods x = d.untypedOneArgumentMethod(1);");
- check("int k = d.untypedOneArgumentMethod('string');");
- check("int k = d.untypedOneArgumentMethod(i);");
-
- check("int k = c.untypedTwoArgumentMethod(1, 'string');");
- check("int k = c.untypedTwoArgumentMethod(i, j);");
- check("ClassWithMethods x = c.untypedTwoArgumentMethod(i, c);");
- check("int k = d.untypedTwoArgumentMethod(1, 'string');");
- check("int k = d.untypedTwoArgumentMethod(i, j);");
- check("ClassWithMethods x = d.untypedTwoArgumentMethod(i, d);");
-
- check("int k = c.intNoArgumentMethod();");
- check("ClassWithMethods x = c.intNoArgumentMethod();", NOT_ASSIGNABLE);
-
- check("int k = c.intOneArgumentMethod(c);", NOT_ASSIGNABLE);
- check("ClassWithMethods x = c.intOneArgumentMethod(1);", NOT_ASSIGNABLE);
- check("int k = c.intOneArgumentMethod('string');", NOT_ASSIGNABLE);
- check("int k = c.intOneArgumentMethod(i);");
-
- check("int k = c.intTwoArgumentMethod(1, 'string');", NOT_ASSIGNABLE);
- check("int k = c.intTwoArgumentMethod(i, j);");
- check("ClassWithMethods x = c.intTwoArgumentMethod(i, j);", NOT_ASSIGNABLE);
-
- check("c.functionField();");
- check("d.functionField();");
- check("c.functionField(1);");
- check("d.functionField('string');");
-
- check("c.intField();", MessageKind.NOT_CALLABLE);
- check("d.intField();", MessageKind.NOT_CALLABLE);
-
- check("c.untypedField();");
- check("d.untypedField();");
- check("c.untypedField(1);");
- check("d.untypedField('string');");
-
- check("c.intOneArgumentOneOptionalMethod('');", NOT_ASSIGNABLE);
- check("c.intOneArgumentOneOptionalMethod('', '');",
- [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- check("c.intTwoOptionalMethod('');", NOT_ASSIGNABLE);
- check("c.intTwoOptionalMethod('', '');", [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- check("c.intOneArgumentOneNamedMethod('');", NOT_ASSIGNABLE);
- check("c.intOneArgumentOneNamedMethod('', b: '');",
- [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- check("c.intTwoNamedMethod(a: '');", NOT_ASSIGNABLE);
- check("c.intTwoNamedMethod(b: '');", NOT_ASSIGNABLE);
- check("c.intTwoNamedMethod(a: '', b: '');", [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
- check("c.intTwoNamedMethod(b: '', a: '');", [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- // Invocation of dynamic variable.
- check("e();");
- check("e(1);");
- check("e('string');");
-
- // Invocation on local method.
- check("localMethod();", MessageKind.MISSING_ARGUMENT);
- check("localMethod(1);", NOT_ASSIGNABLE);
- check("localMethod('string');");
- check("int k = localMethod('string');");
- check("String k = localMethod('string');", NOT_ASSIGNABLE);
-
- // Invocation on parenthesized expressions.
- check("(e)();");
- check("(e)(1);");
- check("(e)('string');");
- check("(foo)();");
- check("(foo)(1);");
- check("(foo)('string');");
-
- // Invocations on function expressions.
- check("(foo){}();", MessageKind.MISSING_ARGUMENT);
- check("(foo){}(1);");
- check("(foo){}('string');");
- check("(int foo){}('string');", NOT_ASSIGNABLE);
- check("(String foo){}('string');");
- check("int k = int bar(String foo){ return 0; }('string');");
- check("int k = String bar(String foo){ return foo; }('string');",
- NOT_ASSIGNABLE);
-
- // Static invocations.
- check("ClassWithMethods.staticMethod();", MessageKind.MISSING_ARGUMENT);
- check("ClassWithMethods.staticMethod(1);", NOT_ASSIGNABLE);
- check("ClassWithMethods.staticMethod('string');");
- check("int k = ClassWithMethods.staticMethod('string');");
- check("String k = ClassWithMethods.staticMethod('string');", NOT_ASSIGNABLE);
-
- // Invocation on dynamic variable.
- check("e.foo();");
- check("e.foo(1);");
- check("e.foo('string');");
-
- // Invocation on unresolved variable.
- check("foo();");
- check("foo(1);");
- check("foo('string');");
- check("foo(a: 'string');");
- check("foo(a: localMethod(1));", NOT_ASSIGNABLE);
-}
-
-Future testMethodInvocationsInClass(MockCompiler compiler) {
- MockCompiler compiler = new MockCompiler.internal();
- return compiler.init(CLASS_WITH_METHODS).then((_) {
- LibraryElement library = compiler.mainApp;
- compiler.parseScript(CLASS_WITH_METHODS, library);
- ClassElement ClassWithMethods = library.find("ClassWithMethods");
- ClassWithMethods.ensureResolved(compiler.resolution);
- Element c = ClassWithMethods.lookupLocalMember('method');
- assert(c != null);
- ClassElement SubClass = library.find("SubClass");
- SubClass.ensureResolved(compiler.resolution);
- Element d = SubClass.lookupLocalMember('method');
- assert(d != null);
-
- check(Element element, String text, [expectedWarnings]) {
- analyzeIn(
- compiler,
- element,
- """{
- var e;
- int i;
- int j;
- int localMethod(String str) { return 0; }
- $text
- }""",
- warnings: expectedWarnings);
- }
-
- check(c, "int k = untypedNoArgumentMethod();");
- check(c, "ClassWithMethods x = untypedNoArgumentMethod();");
- check(d, "ClassWithMethods x = untypedNoArgumentMethod();");
- check(d, "int k = intMethod();");
- check(c, "int k = untypedOneArgumentMethod(this);");
- check(c, "ClassWithMethods x = untypedOneArgumentMethod(1);");
- check(c, "int k = untypedOneArgumentMethod('string');");
- check(c, "int k = untypedOneArgumentMethod(i);");
- check(d, "int k = untypedOneArgumentMethod(this);");
- check(d, "ClassWithMethods x = untypedOneArgumentMethod(1);");
- check(d, "int k = untypedOneArgumentMethod('string');");
- check(d, "int k = untypedOneArgumentMethod(i);");
-
- check(c, "int k = untypedTwoArgumentMethod(1, 'string');");
- check(c, "int k = untypedTwoArgumentMethod(i, j);");
- check(c, "ClassWithMethods x = untypedTwoArgumentMethod(i, this);");
- check(d, "int k = untypedTwoArgumentMethod(1, 'string');");
- check(d, "int k = untypedTwoArgumentMethod(i, j);");
- check(d, "ClassWithMethods x = untypedTwoArgumentMethod(i, this);");
-
- check(c, "int k = intNoArgumentMethod();");
- check(c, "ClassWithMethods x = intNoArgumentMethod();", NOT_ASSIGNABLE);
-
- check(c, "int k = intOneArgumentMethod('');", NOT_ASSIGNABLE);
- check(c, "ClassWithMethods x = intOneArgumentMethod(1);", NOT_ASSIGNABLE);
- check(c, "int k = intOneArgumentMethod('string');", NOT_ASSIGNABLE);
- check(c, "int k = intOneArgumentMethod(i);");
-
- check(c, "int k = intTwoArgumentMethod(1, 'string');", NOT_ASSIGNABLE);
- check(c, "int k = intTwoArgumentMethod(i, j);");
- check(
- c, "ClassWithMethods x = intTwoArgumentMethod(i, j);", NOT_ASSIGNABLE);
-
- check(c, "functionField();");
- check(d, "functionField();");
- check(c, "functionField(1);");
- check(d, "functionField('string');");
-
- check(c, "intField();", MessageKind.NOT_CALLABLE);
- check(d, "intField();", MessageKind.NOT_CALLABLE);
-
- check(c, "untypedField();");
- check(d, "untypedField();");
- check(c, "untypedField(1);");
- check(d, "untypedField('string');");
-
- check(c, "intOneArgumentOneOptionalMethod('');", NOT_ASSIGNABLE);
- check(c, "intOneArgumentOneOptionalMethod('', '');",
- [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- check(c, "intTwoOptionalMethod('');", NOT_ASSIGNABLE);
- check(c, "intTwoOptionalMethod('', '');", [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- check(c, "intOneArgumentOneNamedMethod('');", NOT_ASSIGNABLE);
- check(c, "intOneArgumentOneNamedMethod('', b: '');",
- [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- check(c, "intTwoNamedMethod(a: '');", NOT_ASSIGNABLE);
- check(c, "intTwoNamedMethod(b: '');", NOT_ASSIGNABLE);
- check(c, "intTwoNamedMethod(a: '', b: '');",
- [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
- check(c, "intTwoNamedMethod(b: '', a: '');",
- [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- // Invocation of dynamic variable.
- check(c, "e();");
- check(c, "e(1);");
- check(c, "e('string');");
-
- // Invocation on local method.
- check(c, "localMethod();", MessageKind.MISSING_ARGUMENT);
- check(c, "localMethod(1);", NOT_ASSIGNABLE);
- check(c, "localMethod('string');");
- check(c, "int k = localMethod('string');");
- check(c, "String k = localMethod('string');", NOT_ASSIGNABLE);
-
- // Invocation on parenthesized expressions.
- check(c, "(e)();");
- check(c, "(e)(1);");
- check(c, "(e)('string');");
- check(c, "(foo)();", UNDEFINED_GETTER);
- check(c, "(foo)(1);", UNDEFINED_GETTER);
- check(c, "(foo)('string');", UNDEFINED_GETTER);
-
- // Invocations on function expressions.
- check(c, "(foo){}();", MessageKind.MISSING_ARGUMENT);
- check(c, "(foo){}(1);");
- check(c, "(foo){}('string');");
- check(c, "(int foo){}('string');", NOT_ASSIGNABLE);
- check(c, "(String foo){}('string');");
- check(c, "int k = int bar(String foo){ return 0; }('string');");
- check(c, "int k = String bar(String foo){ return foo; }('string');",
- NOT_ASSIGNABLE);
-
- // Static invocations.
- check(c, "staticMethod();", MessageKind.MISSING_ARGUMENT);
- check(c, "staticMethod(1);", NOT_ASSIGNABLE);
- check(c, "staticMethod('string');");
- check(c, "int k = staticMethod('string');");
- check(c, "String k = staticMethod('string');", NOT_ASSIGNABLE);
- check(d, "staticMethod();", MessageKind.UNDEFINED_METHOD);
- check(d, "staticMethod(1);", MessageKind.UNDEFINED_METHOD);
- check(d, "staticMethod('string');", MessageKind.UNDEFINED_METHOD);
- check(d, "int k = staticMethod('string');", MessageKind.UNDEFINED_METHOD);
- check(
- d, "String k = staticMethod('string');", MessageKind.UNDEFINED_METHOD);
-
- // Invocation on dynamic variable.
- check(c, "e.foo();");
- check(c, "e.foo(1);");
- check(c, "e.foo('string');");
-
- // Invocation on unresolved variable.
- check(c, "foo();", MessageKind.UNDEFINED_METHOD);
- check(c, "foo(1);", MessageKind.UNDEFINED_METHOD);
- check(c, "foo('string');", MessageKind.UNDEFINED_METHOD);
- check(c, "foo(a: 'string');", MessageKind.UNDEFINED_METHOD);
- check(c, "foo(a: localMethod(1));",
- [MessageKind.UNDEFINED_METHOD, NOT_ASSIGNABLE]);
- });
-}
-
-void testFunctionCall(MockCompiler compiler) {
- compiler.parseScript(CLASS_WITH_METHODS);
-
- check(String text, [expectedWarnings]) {
- analyze(
- compiler,
- """{
- ClassWithMethods x;
- int localMethod(String str) { return 0; }
- String2Int string2int;
- Function function;
- SubFunction subFunction;
- $text
- }
- """,
- warnings: expectedWarnings);
- }
-
- check("int k = localMethod.call('');");
- check("String k = localMethod.call('');", NOT_ASSIGNABLE);
- check("int k = localMethod.call(0);", NOT_ASSIGNABLE);
-
- check("int k = ClassWithMethods.staticMethod.call('');");
- check("String k = ClassWithMethods.staticMethod.call('');", NOT_ASSIGNABLE);
- check("int k = ClassWithMethods.staticMethod.call(0);", NOT_ASSIGNABLE);
-
- check("int k = x.instanceMethod.call('');");
- check("String k = x.instanceMethod.call('');", NOT_ASSIGNABLE);
- check("int k = x.instanceMethod.call(0);", NOT_ASSIGNABLE);
-
- check("int k = topLevelMethod.call('');");
- check("String k = topLevelMethod.call('');", NOT_ASSIGNABLE);
- check("int k = topLevelMethod.call(0);", NOT_ASSIGNABLE);
-
- check("((String s) { return 0; }).call('');");
- check("((String s) { return 0; }).call(0);", NOT_ASSIGNABLE);
-
- check("(int f(String x)) { int i = f.call(''); } (null);");
- check("(int f(String x)) { String s = f.call(''); } (null);", NOT_ASSIGNABLE);
- check("(int f(String x)) { int i = f.call(0); } (null);", NOT_ASSIGNABLE);
-
- check("int k = string2int.call('');");
- check("String k = string2int.call('');", NOT_ASSIGNABLE);
- check("int k = string2int.call(0);", NOT_ASSIGNABLE);
-
- check("int k = x.string2int.call('');");
- check("String k = x.string2int.call('');", NOT_ASSIGNABLE);
- check("int k = x.string2int.call(0);", NOT_ASSIGNABLE);
-
- check("int k = function.call('');");
- check("String k = function.call('');");
- check("int k = function.call(0);");
-
- check("int k = subFunction.call('');");
- check("String k = subFunction.call('');");
- check("int k = subFunction.call(0);");
-}
-
-testNewExpression(MockCompiler compiler) {
- compiler.parseScript("class A {}");
- analyze(compiler, "A a = new A();");
- analyze(compiler, "int i = new A();", warnings: NOT_ASSIGNABLE);
-
-// TODO(karlklose): constructors are not yet implemented.
-// compiler.parseScript(
-// "class Foo {\n" +
-// " Foo(int x) {}\n" +
-// " Foo.foo() {}\n" +
-// " Foo.bar([int i = null]) {}\n" +
-// "}\n" +
-// "abstract class Bar<T> {\n" +
-// " factory Bar.make() => new Baz<T>.make();\n" +
-// "}\n" +
-// "class Baz {\n" +
-// " factory Bar<S>.make(S x) { return null; }\n" +
-// "}");
-//
-// analyze("Foo x = new Foo(0);");
-// analyze("Foo x = new Foo();", MessageKind.MISSING_ARGUMENT);
-// analyze("Foo x = new Foo('');", NOT_ASSIGNABLE);
-// analyze("Foo x = new Foo(0, null);", MessageKind.ADDITIONAL_ARGUMENT);
-//
-// analyze("Foo x = new Foo.foo();");
-// analyze("Foo x = new Foo.foo(null);", MessageKind.ADDITIONAL_ARGUMENT);
-//
-// analyze("Foo x = new Foo.bar();");
-// analyze("Foo x = new Foo.bar(0);");
-// analyze("Foo x = new Foo.bar('');", NOT_ASSIGNABLE);
-// analyze("Foo x = new Foo.bar(0, null);",
-// MessageKind.ADDITIONAL_ARGUMENT);
-//
-// analyze("Bar<String> x = new Bar<String>.make('');");
-}
-
-testConditionalExpression(MockCompiler compiler) {
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- check("int i = true ? 2 : 1;");
- check("int i = true ? 'hest' : 1;");
- check("int i = true ? 'hest' : 'fisk';", warnings: NOT_ASSIGNABLE);
- check("String s = true ? 'hest' : 'fisk';");
-
- check("true ? 1 : 2;");
- check("null ? 1 : 2;");
- check("0 ? 1 : 2;", warnings: NOT_ASSIGNABLE);
- check("'' ? 1 : 2;", warnings: NOT_ASSIGNABLE);
- check("{ int i; true ? i = 2.7 : 2; }", warnings: NOT_ASSIGNABLE);
- check("{ int i; true ? 2 : i = 2.7; }", warnings: NOT_ASSIGNABLE);
- check("{ int i; i = true ? 2.7 : 2; }");
-
- compiler.parseScript("""
- bool cond() => true;
- void f1() {}
- void f2() {}""");
- check("{ cond() ? f1() : f2(); }");
-}
-
-testIfStatement(MockCompiler compiler) {
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- check("if (true) {}");
- check("if (null) {}");
- check("if (0) {}", warnings: NOT_ASSIGNABLE);
- check("if ('') {}", warnings: NOT_ASSIGNABLE);
- check("{ int i = 27; if (true) { i = 2.7; } else {} }",
- warnings: NOT_ASSIGNABLE);
- check("{ int i = 27; if (true) {} else { i = 2.7; } }",
- warnings: NOT_ASSIGNABLE);
-}
-
-testThis(MockCompiler compiler) {
- String script = """class Foo {
- void method() {}
- }""";
- compiler.parseScript(script);
- LibraryElement mainApp = compiler.mainApp;
- ClassElement foo = mainApp.find("Foo");
- foo.ensureResolved(compiler.resolution);
- Element method = foo.lookupLocalMember('method');
- analyzeIn(compiler, method, "{ int i = this; }", warnings: NOT_ASSIGNABLE);
- analyzeIn(compiler, method, "{ Object o = this; }");
- analyzeIn(compiler, method, "{ Foo f = this; }");
-}
-
-testSuper(MockCompiler compiler) {
- String script = r'''
- class A {
- String field = "42";
- }
-
- class B extends A {
- Object field = 42;
- void method() {}
- }
- ''';
- compiler.parseScript(script);
- LibraryElement mainApp = compiler.mainApp;
- ClassElement B = mainApp.find("B");
- B.ensureResolved(compiler.resolution);
- Element method = B.lookupLocalMember('method');
- analyzeIn(compiler, method, "{ int i = super.field; }",
- warnings: NOT_ASSIGNABLE);
- analyzeIn(compiler, method, "{ Object o = super.field; }");
- analyzeIn(compiler, method, "{ String s = super.field; }");
-}
-
-const String CLASSES_WITH_OPERATORS = '''
-class Operators {
- Operators operator +(Operators other) => this;
- Operators operator -(Operators other) => this;
- Operators operator -() => this;
- Operators operator *(Operators other) => this;
- Operators operator /(Operators other) => this;
- Operators operator %(Operators other) => this;
- Operators operator ~/(Operators other) => this;
-
- Operators operator &(Operators other) => this;
- Operators operator |(Operators other) => this;
- Operators operator ^(Operators other) => this;
-
- Operators operator ~() => this;
-
- Operators operator <(Operators other) => true;
- Operators operator >(Operators other) => false;
- Operators operator <=(Operators other) => this;
- Operators operator >=(Operators other) => this;
-
- Operators operator <<(Operators other) => this;
- Operators operator >>(Operators other) => this;
-
- bool operator ==(Operators other) => true;
-
- Operators operator [](Operators key) => this;
- void operator []=(Operators key, Operators value) {}
-}
-
-class MismatchA {
- int operator+(MismatchA other) => 0;
- MismatchA operator-(int other) => this;
-
- MismatchA operator[](int key) => this;
- void operator[]=(int key, MismatchA value) {}
-}
-
-class MismatchB {
- MismatchB operator+(MismatchB other) => this;
-
- MismatchB operator[](int key) => this;
- void operator[]=(String key, MismatchB value) {}
-}
-
-class MismatchC {
- MismatchC operator+(MismatchC other) => this;
-
- MismatchC operator[](int key) => this;
- void operator[]=(int key, String value) {}
-}
-''';
-
-testOperatorsAssignability(MockCompiler compiler) {
- compiler.parseScript(CLASSES_WITH_OPERATORS);
-
- // Tests against Operators.
-
- String header = """{
- bool z;
- Operators a;
- Operators b;
- Operators c;
- """;
-
- check(String text, [expectedWarnings]) {
- analyze(compiler, '$header $text }', warnings: expectedWarnings);
- }
-
- // Positive tests on operators.
-
- check('c = a + b;');
- check('c = a - b;');
- check('c = -a;');
- check('c = a * b;');
- check('c = a / b;');
- check('c = a % b;');
- check('c = a ~/ b;');
-
- check('c = a & b;');
- check('c = a | b;');
- check('c = a ^ b;');
-
- check('c = ~a;');
-
- check('c = a < b;');
- check('c = a > b;');
- check('c = a <= b;');
- check('c = a >= b;');
-
- check('c = a << b;');
- check('c = a >> b;');
-
- check('c = a[b];');
-
- check('a[b] = c;');
- check('a[b] += c;');
- check('a[b] -= c;');
- check('a[b] *= c;');
- check('a[b] /= c;');
- check('a[b] %= c;');
- check('a[b] ~/= c;');
- check('a[b] <<= c;');
- check('a[b] >>= c;');
- check('a[b] &= c;');
- check('a[b] |= c;');
- check('a[b] ^= c;');
-
- check('a += b;');
- check('a -= b;');
- check('a *= b;');
- check('a /= b;');
- check('a %= b;');
- check('a ~/= b;');
-
- check('a <<= b;');
- check('a >>= b;');
-
- check('a &= b;');
- check('a |= b;');
- check('a ^= b;');
-
- // Negative tests on operators.
-
- // For the sake of brevity we misuse the terminology in comments:
- // 'e1 is not assignable to e2' should be read as
- // 'the type of e1 is not assignable to the type of e2', and
- // 'e1 is not assignable to operator o on e2' should be read as
- // 'the type of e1 is not assignable to the argument type of operator o
- // on e2'.
-
- // `0` is not assignable to operator + on `a`.
- check('c = a + 0;', NOT_ASSIGNABLE);
- // `a + b` is not assignable to `z`.
- check('z = a + b;', NOT_ASSIGNABLE);
-
- // `-a` is not assignable to `z`.
- check('z = -a;', NOT_ASSIGNABLE);
-
- // `0` is not assignable to operator [] on `a`.
- check('c = a[0];', NOT_ASSIGNABLE);
- // `a[b]` is not assignable to `z`.
- check('z = a[b];', NOT_ASSIGNABLE);
-
- // `0` is not assignable to operator [] on `a`.
- // Warning suppressed for `0` is not assignable to operator []= on `a`.
- check('a[0] *= c;', NOT_ASSIGNABLE);
- // `z` is not assignable to operator * on `a[0]`.
- check('a[b] *= z;', NOT_ASSIGNABLE);
-
- check('b = a++;', NOT_ASSIGNABLE);
- check('b = ++a;', NOT_ASSIGNABLE);
- check('b = a--;', NOT_ASSIGNABLE);
- check('b = --a;', NOT_ASSIGNABLE);
-
- check('c = a[b]++;', NOT_ASSIGNABLE);
- check('c = ++a[b];', NOT_ASSIGNABLE);
- check('c = a[b]--;', NOT_ASSIGNABLE);
- check('c = --a[b];', NOT_ASSIGNABLE);
-
- check('z = a == b;');
- check('z = a != b;');
-
- for (String o in ['&&', '||']) {
- check('z = z $o z;');
- check('z = a $o z;', NOT_ASSIGNABLE);
- check('z = z $o b;', NOT_ASSIGNABLE);
- check('z = a $o b;', [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
- check('a = a $o b;', [NOT_ASSIGNABLE, NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
- }
-
- check('z = !z;');
- check('z = !a;', NOT_ASSIGNABLE);
- check('a = !z;', NOT_ASSIGNABLE);
- check('a = !a;', [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- // Tests against MismatchA.
-
- header = """{
- MismatchA a;
- MismatchA b;
- MismatchA c;
- """;
-
- // Tests against int operator +(MismatchA other) => 0;
-
- // `a + b` is not assignable to `c`.
- check('c = a + b;', NOT_ASSIGNABLE);
- // `a + b` is not assignable to `a`.
- check('a += b;', NOT_ASSIGNABLE);
- // `a[0] + b` is not assignable to `a[0]`.
- check('a[0] += b;', NOT_ASSIGNABLE);
-
- // 1 is not applicable to operator +.
- check('b = a++;', NOT_ASSIGNABLE);
- // 1 is not applicable to operator +.
- // `++a` of type int is not assignable to `b`.
- check('b = ++a;', [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- // 1 is not applicable to operator +.
- check('b = a[0]++;', NOT_ASSIGNABLE);
- // 1 is not applicable to operator +.
- // `++a[0]` of type int is not assignable to `b`.
- check('b = ++a[0];', [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- // Tests against: MismatchA operator -(int other) => this;
-
- // `a - b` is not assignable to `c`.
- check('c = a + b;', NOT_ASSIGNABLE);
- // `a - b` is not assignable to `a`.
- check('a += b;', NOT_ASSIGNABLE);
- // `a[0] - b` is not assignable to `a[0]`.
- check('a[0] += b;', NOT_ASSIGNABLE);
-
- check('b = a--;');
- check('b = --a;');
-
- check('b = a[0]--;');
- check('b = --a[0];');
-
- // Tests against MismatchB.
-
- header = """{
- MismatchB a;
- MismatchB b;
- MismatchB c;
- """;
-
- // Tests against:
- // MismatchB operator [](int key) => this;
- // void operator []=(String key, MismatchB value) {}
-
- // `0` is not applicable to operator []= on `a`.
- check('a[0] = b;', NOT_ASSIGNABLE);
-
- // `0` is not applicable to operator []= on `a`.
- check('a[0] += b;', NOT_ASSIGNABLE);
- // `""` is not applicable to operator [] on `a`.
- check('a[""] += b;', NOT_ASSIGNABLE);
- // `c` is not applicable to operator [] on `a`.
- // `c` is not applicable to operator []= on `a`.
- check('a[c] += b;', [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- // Tests against MismatchB.
-
- header = """{
- MismatchC a;
- MismatchC b;
- MismatchC c;
- """;
-
- // Tests against:
- // MismatchC operator[](int key) => this;
- // void operator[]=(int key, String value) {}
-
- // `b` is not assignable to `a[0]`.
- check('a[0] += b;', NOT_ASSIGNABLE);
- // `0` is not applicable to operator + on `a[0]`.
- check('a[0] += "";', [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
- // `true` is not applicable to operator + on `a[0]`.
- // `true` is not assignable to `a[0]`.
- check('a[0] += true;', [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-}
-
-Future testFieldInitializers(MockCompiler compiler) {
- Future check(String code, [expectedWarnings]) {
- return analyzeTopLevel(code, expectedWarnings);
- }
-
- return Future.wait([
- check("""int i = 0;"""),
- check("""int i = '';""", NOT_ASSIGNABLE),
- check("""class Class {
- int i = 0;
- }"""),
- check("""class Class {
- int i = '';
- }""", NOT_ASSIGNABLE),
- ]);
-}
-
-void testTypeVariableExpressions(MockCompiler compiler) {
- String script = """class Foo<T> {
- void method() {}
- }""";
- compiler.parseScript(script);
- LibraryElement mainApp = compiler.mainApp;
- ClassElement foo = mainApp.find("Foo");
- foo.ensureResolved(compiler.resolution);
- Element method = foo.lookupLocalMember('method');
-
- analyzeIn(compiler, method, "{ Type type = T; }");
- analyzeIn(compiler, method, "{ T type = T; }", warnings: NOT_ASSIGNABLE);
- analyzeIn(compiler, method, "{ int type = T; }", warnings: NOT_ASSIGNABLE);
-
- analyzeIn(compiler, method, "{ String typeName = T.toString(); }");
- analyzeIn(compiler, method, "{ T.foo; }", warnings: UNDEFINED_GETTER);
- analyzeIn(compiler, method, "{ T.foo = 0; }",
- warnings: MessageKind.UNDEFINED_SETTER);
- analyzeIn(compiler, method, "{ T.foo(); }",
- warnings: MessageKind.UNDEFINED_METHOD);
- analyzeIn(compiler, method, "{ T + 1; }",
- warnings: MessageKind.UNDEFINED_OPERATOR);
-}
-
-void testTypeVariableLookup1(MockCompiler compiler) {
- String script = """
-class Foo {
- int field;
- void method(int argument) {}
- int operator +(Foo foo) {}
- int get getter => 21;
-}
-
-class Test<S extends Foo, T> {
- S s;
- T t;
- test() {}
-}
-""";
-
- compiler.parseScript(script);
- LibraryElement mainApp = compiler.mainApp;
- ClassElement classTest = mainApp.find("Test");
- classTest.ensureResolved(compiler.resolution);
- FunctionElement methodTest = classTest.lookupLocalMember("test");
-
- test(String expression, [message]) {
- analyzeIn(compiler, methodTest, "{ $expression; }", warnings: message);
- }
-
- test('s.field');
- test('s.method(1)');
- test('s + s');
- test('s.getter');
-
- test('t.toString');
- test('t.field', UNDEFINED_GETTER);
- test('t.method(1)', MessageKind.UNDEFINED_METHOD);
- test('t + t', MessageKind.UNDEFINED_OPERATOR);
- test('t.getter', UNDEFINED_GETTER);
-
- test('s.field = "hest"', NOT_ASSIGNABLE);
- test('s.method("hest")', NOT_ASSIGNABLE);
- test('s + "hest"', NOT_ASSIGNABLE);
- test('String v = s.getter', NOT_ASSIGNABLE);
-}
-
-void testTypeVariableLookup2(MockCompiler compiler) {
- String script = """
-class Foo {
- int field;
- void method(int argument) {}
- int operator +(Foo foo) {}
- int get getter => 21;
-}
-
-class Test<S extends T, T extends Foo> {
- S s;
- test() {}
-}""";
-
- compiler.parseScript(script);
- LibraryElement mainApp = compiler.mainApp;
- ClassElement classTest = mainApp.find("Test");
- classTest.ensureResolved(compiler.resolution);
- FunctionElement methodTest = classTest.lookupLocalMember("test");
-
- test(String expression, [message]) {
- analyzeIn(compiler, methodTest, "{ $expression; }", warnings: message);
- }
-
- test('s.field');
- test('s.method(1)');
- test('s + s');
- test('s.getter');
-}
-
-void testTypeVariableLookup3(MockCompiler compiler) {
- String script = """
-class Test<S extends T, T extends S> {
- S s;
- test() {}
-}""";
-
- compiler.parseScript(script);
- LibraryElement mainApp = compiler.mainApp;
- ClassElement classTest = mainApp.find("Test");
- classTest.ensureResolved(compiler.resolution);
- FunctionElement methodTest = classTest.lookupLocalMember("test");
-
- test(String expression, [message]) {
- analyzeIn(compiler, methodTest, "{ $expression; }", warnings: message);
- }
-
- test('s.toString');
- test('s.field', UNDEFINED_GETTER);
- test('s.method(1)', MessageKind.UNDEFINED_METHOD);
- test('s + s', MessageKind.UNDEFINED_OPERATOR);
- test('s.getter', UNDEFINED_GETTER);
-}
-
-void testFunctionTypeLookup(MockCompiler compiler) {
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- check('(int f(int)) => f.toString;');
- check('(int f(int)) => f.toString();');
- check('(int f(int)) => f.foo;', warnings: UNDEFINED_GETTER);
- check('(int f(int)) => f.foo();', warnings: MessageKind.UNDEFINED_METHOD);
-}
-
-void testTypedefLookup(MockCompiler compiler) {
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- compiler.parseScript("typedef int F(int);");
- check('(F f) => f.toString;');
- check('(F f) => f.toString();');
- check('(F f) => f.foo;', warnings: UNDEFINED_GETTER);
- check('(F f) => f.foo();', warnings: MessageKind.UNDEFINED_METHOD);
-}
-
-void testTypeLiteral(MockCompiler compiler) {
- check(String code, {warnings}) {
- analyze(compiler, code, warnings: warnings);
- }
-
- final String source = r"""class Class {
- static var field = null;
- static method() {}
- }""";
- compiler.parseScript(source);
-
- // Check direct access.
- check('Type m() => int;');
- check('int m() => int;', warnings: NOT_ASSIGNABLE);
-
- // Check access in assignment.
- check('m(Type val) => val = Class;');
- check('m(int val) => val = Class;', warnings: NOT_ASSIGNABLE);
- check('m(Type val) => val = dynamic;');
- check('m(int val) => val = dynamic;', warnings: NOT_ASSIGNABLE);
-
- // Check access as argument.
- check('m(Type val) => m(int);');
- check('m(int val) => m(int);', warnings: NOT_ASSIGNABLE);
-
- // Check access as argument in member access.
- check('m(Type val) => m(int).foo;');
- check('m(int val) => m(int).foo;', warnings: NOT_ASSIGNABLE);
-
- // Check static property access.
- check('m() => Class.field;');
- check('m() => (Class).field;', warnings: UNDEFINED_GETTER);
-
- // Check static method access.
- check('m() => Class.method();');
- check('m() => (Class).method();', warnings: MessageKind.UNDEFINED_METHOD);
-
- // Check access in invocation.
- check('m() => Class();', warnings: MessageKind.NOT_CALLABLE);
- check('m() => dynamic();', warnings: MessageKind.NOT_CALLABLE);
-}
-
-Future testInitializers(MockCompiler compiler) {
- Future check(String text, [expectedWarnings]) {
- return analyzeTopLevel(text, expectedWarnings);
- }
-
- return Future.wait([
- // Check initializers.
- check(r'''class Class {
- var a;
- Class(this.a);
- }
- '''),
- check(r'''class Class {
- int a;
- Class(this.a);
- }
- '''),
- check(r'''class Class {
- var a;
- Class(int this.a);
- }
- '''),
- check(r'''class Class {
- String a;
- Class(int this.a);
- }
- ''', NOT_ASSIGNABLE),
- check(r'''class Class {
- var a;
- Class(int a) : this.a = a;
- }
- '''),
- check(r'''class Class {
- String a;
- Class(int a) : this.a = a;
- }
- ''', NOT_ASSIGNABLE),
-
- // Check this-calls.
- check(r'''class Class {
- var a;
- Class(this.a);
- Class.named(int a) : this(a);
- }
- '''),
- check(r'''class Class {
- String a;
- Class(this.a);
- Class.named(int a) : this(a);
- }
- ''', NOT_ASSIGNABLE),
- check(r'''class Class {
- String a;
- Class(var a) : this.a = a;
- Class.named(int a) : this(a);
- }
- '''),
- check(r'''class Class {
- String a;
- Class(String a) : this.a = a;
- Class.named(int a) : this(a);
- }
- ''', NOT_ASSIGNABLE),
-
- // Check super-calls.
- check(r'''class Super {
- var a;
- Super(this.a);
- }
- class Class extends Super {
- Class.named(int a) : super(a);
- }
- '''),
- check(r'''class Super {
- String a;
- Super(this.a);
- }
- class Class extends Super {
- Class.named(int a) : super(a);
- }
- ''', NOT_ASSIGNABLE),
- check(r'''class Super {
- String a;
- Super(var a) : this.a = a;
- }
- class Class extends Super {
- Class.named(int a) : super(a);
- }
- '''),
- check(r'''class Super {
- String a;
- Super(String a) : this.a = a;
- }
- class Class extends Super {
- Class.named(int a) : super(a);
- }
- ''', NOT_ASSIGNABLE),
-
- // Check super-calls involving generics.
- check(r'''class Super<T> {
- var a;
- Super(this.a);
- }
- class Class extends Super<String> {
- Class.named(int a) : super(a);
- }
- '''),
- check(r'''class Super<T> {
- T a;
- Super(this.a);
- }
- class Class extends Super<String> {
- Class.named(int a) : super(a);
- }
- ''', NOT_ASSIGNABLE),
- check(r'''class Super<T> {
- T a;
- Super(var a) : this.a = a;
- }
- class Class extends Super<String> {
- Class.named(int a) : super(a);
- }
- '''),
- check(r'''class Super<T> {
- T a;
- Super(T a) : this.a = a;
- }
- class Class extends Super<String> {
- Class.named(int a) : super(a);
- }
- ''', NOT_ASSIGNABLE),
-
- // Check instance creations.
- check(r'''class Class {
- var a;
- Class(this.a);
- }
- method(int a) => new Class(a);
- '''),
- check(r'''class Class {
- String a;
- Class(this.a);
- }
- method(int a) => new Class(a);
- ''', NOT_ASSIGNABLE),
- check(r'''class Class {
- String a;
- Class(var a) : this.a = a;
- }
- method(int a) => new Class(a);
- '''),
- check(r'''class Class {
- String a;
- Class(String a) : this.a = a;
- }
- method(int a) => new Class(a);
- ''', NOT_ASSIGNABLE),
-
- // Check instance creations involving generics.
- check(r'''class Class<T> {
- var a;
- Class(this.a);
- }
- method(int a) => new Class<String>(a);
- '''),
- check(r'''class Class<T> {
- T a;
- Class(this.a);
- }
- method(int a) => new Class<String>(a);
- ''', NOT_ASSIGNABLE),
- check(r'''class Class<T> {
- T a;
- Class(var a) : this.a = a;
- }
- method(int a) => new Class<String>(a);
- '''),
- check(r'''class Class<T> {
- T a;
- Class(String a) : this.a = a;
- }
- method(int a) => new Class<String>(a);
- ''', NOT_ASSIGNABLE),
- ]);
-}
-
-void testGetterSetterInvocation(MockCompiler compiler) {
- compiler.parseScript(r'''int get variable => 0;
- void set variable(String s) {}
-
- class Class {
- int get instanceField => 0;
- void set instanceField(String s) {}
-
- static int get staticField => 0;
- static void set staticField(String s) {}
-
- int overriddenField;
- int get getterField => 0;
- void set setterField(int v) {}
- }
-
- class GetterClass extends Class {
- int get overriddenField => super.overriddenField;
- int get setterField => 0;
- }
-
- class SetterClass extends Class {
- void set overriddenField(int v) {}
- void set getterField(int v) {}
- }
-
- Class c;
- GetterClass gc;
- SetterClass sc;
- ''');
-
- check(String text, [expectedWarnings]) {
- analyze(compiler, '{ $text }', warnings: expectedWarnings);
- }
-
- check("variable = '';");
- check("int v = variable;");
- check("variable = 0;", NOT_ASSIGNABLE);
- check("String v = variable;", NOT_ASSIGNABLE);
- // num is not assignable to String (the type of the setter).
- check("variable += 0;", NOT_ASSIGNABLE);
- // String is not assignable to int (the argument type of the operator + on the
- // getter) and num (the result type of the operation) is not assignable to
- // String (the type of the setter).
- check("variable += '';", [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- check("c.instanceField = '';");
- check("int v = c.instanceField;");
- check("c.instanceField = 0;", NOT_ASSIGNABLE);
- check("String v = c.instanceField;", NOT_ASSIGNABLE);
-
- // num is not assignable to String (the type of the setter).
- check("c.instanceField += 0;", NOT_ASSIGNABLE);
- // String is not assignable to int (the argument type of the operator + on the
- // getter) and num (the result type of the operation) is not assignable to
- // String (the type of the setter).
- check("c.instanceField += '';", [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- check("Class.staticField = '';");
- check("int v = Class.staticField;");
- check("Class.staticField = 0;", NOT_ASSIGNABLE);
- check("String v = Class.staticField;", NOT_ASSIGNABLE);
-
- // num is not assignable to String (the type of the setter).
- check("Class.staticField += 0;", NOT_ASSIGNABLE);
- // String is not assignable to int (the argument type of the operator + on the
- // getter) and num (the result type of the operation) is not assignable to
- // String (the type of the setter).
- check("Class.staticField += '';", [NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
-
- check("int v = c.overriddenField;");
- check("c.overriddenField = 0;");
- check("int v = c.getterField;");
- check("c.getterField = 0;", MessageKind.UNDEFINED_SETTER);
- check("int v = c.setterField;",
- MessageKind.UNDEFINED_INSTANCE_GETTER_BUT_SETTER);
- check("c.setterField = 0;");
-
- check("int v = gc.overriddenField;");
- check("gc.overriddenField = 0;");
- check("int v = gc.setterField;");
- check("gc.setterField = 0;");
- check("int v = gc.getterField;");
- check("gc.getterField = 0;", MessageKind.UNDEFINED_SETTER);
-
- check("int v = sc.overriddenField;");
- check("sc.overriddenField = 0;");
- check("int v = sc.getterField;");
- check("sc.getterField = 0;");
- check("int v = sc.setterField;",
- MessageKind.UNDEFINED_INSTANCE_GETTER_BUT_SETTER);
- check("sc.setterField = 0;");
-}
-
-testTypePromotionHints(MockCompiler compiler) {
- compiler.parseScript(r'''class A {
- var a = "a";
- }
- class B extends A {
- var b = "b";
- }
- class C {
- var c = "c";
- }
- class D<T> {
- T d;
- }
- class E<T> extends D<T> {
- T e;
- }
- class F<S, U> extends E<S> {
- S f;
- }
- class G<V> extends F<V, V> {
- V g;
- }
- ''');
-
- check(String text, {warnings, hints, infos}) {
- analyze(compiler, '{ $text }',
- warnings: warnings, hints: hints, infos: infos);
- }
-
- check(r'''
- A a = new B();
- if (a is C) {
- var x = a.c;
- }''',
- warnings: [MessageKind.UNDEFINED_GETTER],
- hints: [MessageKind.NOT_MORE_SPECIFIC_SUBTYPE],
- infos: []);
-
- check(r'''
- A a = new B();
- if (a is C) {
- var x = '${a.c}${a.c}';
- }''',
- warnings: [MessageKind.UNDEFINED_GETTER, MessageKind.UNDEFINED_GETTER],
- hints: [MessageKind.NOT_MORE_SPECIFIC_SUBTYPE],
- infos: []);
-
- check(r'''
- A a = new B();
- if (a is C) {
- var x = '${a.d}${a.d}'; // Type promotion wouldn't help.
- }''',
- warnings: [MessageKind.UNDEFINED_GETTER, MessageKind.UNDEFINED_GETTER],
- hints: [],
- infos: []);
-
- check('''
- D<int> d = new E();
- if (d is E) { // Suggest E<int>.
- var x = d.e;
- }''', warnings: [
- MessageKind.UNDEFINED_GETTER
- ], hints: [
- checkMessage(MessageKind.NOT_MORE_SPECIFIC_SUGGESTION,
- {'shownTypeSuggestion': 'E<int>'})
- ], infos: []);
-
- check('''
- D<int> d = new F();
- if (d is F) { // Suggest F<int, dynamic>.
- var x = d.f;
- }''', warnings: [
- MessageKind.UNDEFINED_GETTER
- ], hints: [
- checkMessage(MessageKind.NOT_MORE_SPECIFIC_SUGGESTION,
- {'shownTypeSuggestion': 'F<int, dynamic>'})
- ], infos: []);
-
- check('''
- D<int> d = new G();
- if (d is G) { // Suggest G<int>.
- var x = d.f;
- }''', warnings: [
- MessageKind.UNDEFINED_GETTER
- ], hints: [
- checkMessage(MessageKind.NOT_MORE_SPECIFIC_SUGGESTION,
- {'shownTypeSuggestion': 'G<int>'})
- ], infos: []);
-
- check('''
- F<double, int> f = new G();
- if (f is G) { // Cannot suggest a more specific type.
- var x = f.g;
- }''',
- warnings: [MessageKind.UNDEFINED_GETTER],
- hints: [MessageKind.NOT_MORE_SPECIFIC],
- infos: []);
-
- check('''
- D<int> d = new E();
- if (d is E) {
- var x = d.f; // Type promotion wouldn't help.
- }''',
- warnings: [MessageKind.UNDEFINED_GETTER], hints: [], infos: []);
-
- check('''
- A a = new B();
- if (a is B) {
- a = null;
- var x = a.b;
- }''',
- warnings: [MessageKind.UNDEFINED_GETTER],
- hints: [MessageKind.POTENTIAL_MUTATION],
- infos: [MessageKind.POTENTIAL_MUTATION_HERE]);
-
- check('''
- A a = new B();
- if (a is B) {
- a = null;
- var x = a.c; // Type promotion wouldn't help.
- }''',
- warnings: [MessageKind.UNDEFINED_GETTER], hints: [], infos: []);
-
- check('''
- A a = new B();
- local() { a = new A(); }
- if (a is B) {
- var x = a.b;
- }''',
- warnings: [MessageKind.UNDEFINED_GETTER],
- hints: [MessageKind.POTENTIAL_MUTATION_IN_CLOSURE],
- infos: [MessageKind.POTENTIAL_MUTATION_IN_CLOSURE_HERE]);
-
- check('''
- A a = new B();
- local() { a = new A(); }
- if (a is B) {
- var x = a.c; // Type promotion wouldn't help.
- }''',
- warnings: [MessageKind.UNDEFINED_GETTER], hints: [], infos: []);
-
- check('''
- A a = new B();
- if (a is B) {
- var x = () => a;
- var y = a.b;
- }
- a = new A();''', warnings: [
- MessageKind.UNDEFINED_GETTER
- ], hints: [
- MessageKind.ACCESSED_IN_CLOSURE
- ], infos: [
- MessageKind.ACCESSED_IN_CLOSURE_HERE,
- MessageKind.POTENTIAL_MUTATION_HERE
- ]);
-
- check('''
- A a = new B();
- if (a is B) {
- var x = () => a;
- var y = a.c; // Type promotion wouldn't help.
- }
- a = new A();''',
- warnings: [MessageKind.UNDEFINED_GETTER], hints: [], infos: []);
-}
-
-void testCascade(MockCompiler compiler) {
- compiler.parseScript(r'''typedef A AFunc();
- typedef Function FuncFunc();
- class A {
- A a;
- B b;
- C c;
- AFunc afunc() => null;
- FuncFunc funcfunc() => null;
- C operator [](_) => null;
- void operator []=(_, C c) {}
- }
- class B {
- B b;
- C c;
- }
- class C {
- C c;
- AFunc afunc() => null;
- }
- ''');
-
- check(String text, {warnings, hints, infos}) {
- analyze(compiler, '{ $text }',
- warnings: warnings, hints: hints, infos: infos);
- }
-
- check('A a = new A()..a;');
-
- check('A a = new A()..b;');
-
- check('A a = new A()..a..b;');
-
- check('A a = new A()..b..c..a;');
-
- check('B b = new A()..a;', warnings: NOT_ASSIGNABLE);
-
- check('B b = new A()..b;', warnings: NOT_ASSIGNABLE);
-
- check('B b = new A().b;');
-
- check('new A().b..b;');
-
- check('new A().b..a;', warnings: UNDEFINED_GETTER);
-
- check('B b = new A().b..c;');
-
- check('C c = new A().b..c;', warnings: NOT_ASSIGNABLE);
-
- check('A a = new A()..a = new A();');
-
- check('A a = new A()..b = new B();');
-
- check('B b = new A()..b = new B();', warnings: NOT_ASSIGNABLE);
-
- check('A a = new A()..b = new A();', warnings: NOT_ASSIGNABLE);
-
- check('AFunc a = new C().afunc();');
-
- check('AFunc a = new C()..afunc();', warnings: NOT_ASSIGNABLE);
-
- check('C c = new C()..afunc();');
-
- check('A a = new C().afunc()();');
-
- check('A a = new C()..afunc()();', warnings: NOT_ASSIGNABLE);
-
- check('AFunc a = new C()..afunc()();', warnings: NOT_ASSIGNABLE);
-
- check('FuncFunc f = new A().funcfunc();');
-
- check('A a = new A().funcfunc();', warnings: NOT_ASSIGNABLE);
-
- check('FuncFunc f = new A()..funcfunc();', warnings: NOT_ASSIGNABLE);
-
- check('A a = new A()..funcfunc();');
-
- check('FuncFunc f = new A()..funcfunc()();', warnings: NOT_ASSIGNABLE);
-
- check('A a = new A()..funcfunc()();');
-
- check('FuncFunc f = new A()..funcfunc()()();', warnings: NOT_ASSIGNABLE);
-
- check('A a = new A()..funcfunc()()();');
-
- check('''A a;
- a = new A()..a = a = new A()..c.afunc();''');
-
- check('''A a = new A()..b = new B()..c.afunc();''');
-
- check('''A a = new A()..b = new A()..c.afunc();''', warnings: NOT_ASSIGNABLE);
-
- check('''A a = new A()..b = new A()..c.afunc()();''',
- warnings: NOT_ASSIGNABLE);
-
- check('''A a = new A()..b = new A()..c.afunc()().b;''',
- warnings: NOT_ASSIGNABLE);
-
- check('A a = new A().afunc()()[0].afunc();', warnings: NOT_ASSIGNABLE);
-
- check('C c = new A().afunc()()[0].afunc();', warnings: NOT_ASSIGNABLE);
-
- check('AFunc a = new A().afunc()()[0].afunc();');
-
- check('A a = new A()..afunc()()[0].afunc();');
-
- check('C c = new A()..afunc()()[0].afunc();', warnings: NOT_ASSIGNABLE);
-
- check('AFunc a = new A()..afunc()()[0].afunc();', warnings: NOT_ASSIGNABLE);
-
- check('A a = new A().afunc()()[0]..afunc();', warnings: NOT_ASSIGNABLE);
-
- check('C c = new A().afunc()()[0]..afunc();');
-
- check('AFunc a = new A().afunc()()[0]..afunc();', warnings: NOT_ASSIGNABLE);
-
- check('A a = new A()..afunc()()[0]..afunc();');
-
- check('C c = new A()..afunc()()[0]..afunc();', warnings: NOT_ASSIGNABLE);
-
- check('AFunc a = new A()..afunc()()[0]..afunc();', warnings: NOT_ASSIGNABLE);
-
- check('new A()[0] = new A();', warnings: NOT_ASSIGNABLE);
-
- check('new A()[0] = new C();');
-
- check('new A().a[0] = new A();', warnings: NOT_ASSIGNABLE);
-
- check('new A().a[0] = new C();');
-
- check('new A()..a[0] = new A();', warnings: NOT_ASSIGNABLE);
-
- check('new A()..a[0] = new C();');
-
- check('new A()..afunc()()[0] = new A();', warnings: NOT_ASSIGNABLE);
-
- check('new A()..afunc()()[0] = new C();');
-}
-
-testAwait(MockCompiler compiler) {
- String script = """class Foo {
- void method() async {}
- Future<int> asyncInt() => new Future<int>.value(0);
- Foo self() => this;
- }""";
- compiler.parseScript(script);
- LibraryElement mainApp = compiler.mainApp;
- ClassElement foo = mainApp.find("Foo");
- foo.ensureResolved(compiler.resolution);
- FunctionElement method = foo.lookupLocalMember('method');
- analyzeIn(compiler, method, "{ await 0; }");
- analyzeIn(compiler, method, "{ int i = await 0; }");
- analyzeIn(compiler, method, "{ String s = await 0; }",
- warnings: NOT_ASSIGNABLE);
- analyzeIn(compiler, method, "{ await asyncInt(); }");
- analyzeIn(compiler, method, "{ int i = await asyncInt(); }");
- analyzeIn(compiler, method, "{ String s = await asyncInt(); }",
- warnings: NOT_ASSIGNABLE);
- analyzeIn(compiler, method, "{ Foo f = self(); }");
- analyzeIn(compiler, method, "{ Foo f = await self(); }");
- analyzeIn(compiler, method, "{ Foo f = await self().asyncInt(); }",
- warnings: NOT_ASSIGNABLE);
- analyzeIn(compiler, method, "{ int i = await self().asyncInt(); }");
- analyzeIn(compiler, method, "{ String s = await self().asyncInt(); }",
- warnings: NOT_ASSIGNABLE);
-}
-
-testAsyncReturn(MockCompiler compiler) {
- Future check(String code, [expectedWarnings]) {
- return analyzeTopLevel(code, expectedWarnings);
- }
-
- return Future.wait([
- check("Future<int> foo() async { return; }"),
- check("Future<int> foo() async { return null; }"),
- check("Future<int> foo() async { return 0; }"),
- check("Future<int> foo() async { return ''; }", NOT_ASSIGNABLE),
- check("Future<int> foo() async { return new Future.value(); }"),
- check("Future<int> foo() async { return new Future<int>.value(); }"),
- check("Future<int> foo() async { return new Future<String>.value(); }",
- NOT_ASSIGNABLE),
- check("""
- Future<int> foo() async { return new Future<Future<int>>.value(); }
- """),
- check("void foo() async { return; }"),
- check("void foo() async { return 0; }", MessageKind.RETURN_VALUE_IN_VOID),
- check("void foo() async { return new Future.value(); }",
- MessageKind.RETURN_VALUE_IN_VOID),
- check("int foo() async { return; }"),
- check("int foo() async { return 0; }", NOT_ASSIGNABLE),
- check(
- "int foo() async { return new Future<int>.value(); }", NOT_ASSIGNABLE),
- check("Future<int> foo() async => null;"),
- check("Future<int> foo() async => 0;"),
- check("Future<int> foo() async => '';", NOT_ASSIGNABLE),
- check("Future<int> foo() async => new Future.value();"),
- check("Future<int> foo() async => new Future<int>.value();"),
- check("Future<int> foo() async => new Future<String>.value();",
- NOT_ASSIGNABLE),
- check("""
- Future<int> foo() async => new Future<Future<int>>.value();
- """),
- check("void foo() async { return 0; }", MessageKind.RETURN_VALUE_IN_VOID),
- check("void foo() async { return new Future.value(); }",
- MessageKind.RETURN_VALUE_IN_VOID),
- check("int foo() async => 0;", NOT_ASSIGNABLE),
- check("int foo() async => new Future<int>.value();", NOT_ASSIGNABLE),
- check("Iterable<int> foo() sync* { return; }"),
- check("Stream<int> foo() async* { return; }"),
- ]);
-}
-
-const CLASS_WITH_METHODS = '''
-typedef int String2Int(String s);
-
-int topLevelMethod(String s) {}
-
-class ClassWithMethods {
- untypedNoArgumentMethod() {}
- untypedOneArgumentMethod(argument) {}
- untypedTwoArgumentMethod(argument1, argument2) {}
-
- int intNoArgumentMethod() {}
- int intOneArgumentMethod(int argument) {}
- int intTwoArgumentMethod(int argument1, int argument2) {}
-
- void intOneArgumentOneOptionalMethod(int a, [int b]) {}
- void intTwoOptionalMethod([int a, int b]) {}
- void intOneArgumentOneNamedMethod(int a, {int b}) {}
- void intTwoNamedMethod({int a, int b}) {}
-
- Function functionField;
- var untypedField;
- int intField;
-
- static int staticMethod(String str) {}
- int instanceMethod(String str) {}
-
- void method() {}
-
- String2Int string2int;
-}
-class I {
- int intMethod();
-}
-class SubClass extends ClassWithMethods implements I {
- void method() {}
-}
-class SubFunction implements Function {}''';
-
-String returnWithType(String type, expression) {
- return "$type foo() { return $expression; }";
-}
-
-String arrowReturnWithType(String type, expression) {
- return "$type foo() => $expression;";
-}
-
-Node parseExpression(String text) => parseBodyCode(
- text,
- (parser, token) =>
- parser.parseExpression(parser.syntheticPreviousToken(token)).next);
-
-const Map<String, String> ALT_SOURCE = const <String, String>{
- 'num': r'''
- abstract class num {
- num operator +(num other);
- num operator -(num other);
- num operator *(num other);
- num operator %(num other);
- double operator /(num other);
- int operator ~/(num other);
- num operator -();
- bool operator <(num other);
- bool operator <=(num other);
- bool operator >(num other);
- bool operator >=(num other);
- }
- ''',
- 'int': r'''
- abstract class int extends num {
- int operator &(int other);
- int operator |(int other);
- int operator ^(int other);
- int operator ~();
- int operator <<(int shiftAmount);
- int operator >>(int shiftAmount);
- int operator -();
- }
- ''',
- 'String': r'''
- class String implements Pattern {
- String operator +(String other) => this;
- }
- ''',
-};
-
-Future setup(test(MockCompiler compiler)) {
- MockCompiler compiler =
- new MockCompiler.internal(coreSource: ALT_SOURCE, enableAsyncAwait: true);
- return compiler.init("import 'dart:async';").then((_) => test(compiler));
-}
-
-ResolutionDartType analyzeType(MockCompiler compiler, String text) {
- var node = parseExpression(text);
- TypeCheckerVisitor visitor = new TypeCheckerVisitor(
- compiler, new TreeElementMapping(null), compiler.resolution.types);
- return visitor.analyze(node);
-}
-
-analyzeTopLevel(String text, [expectedWarnings]) {
- if (expectedWarnings == null) expectedWarnings = [];
- if (expectedWarnings is! List) expectedWarnings = [expectedWarnings];
-
- MockCompiler compiler = new MockCompiler.internal(enableAsyncAwait: true);
- compiler.diagnosticHandler = createHandler(compiler, text);
-
- return compiler.init("import 'dart:async';").then((_) {
- LibraryElement library = compiler.mainApp;
-
- Link<Element> topLevelElements =
- parseUnit(text, compiler, library).reverse();
-
- ElementX element = null;
- Node node;
- TreeElements mapping;
- // Resolve all declarations and members.
- for (Link<Element> elements = topLevelElements;
- !elements.isEmpty;
- elements = elements.tail) {
- element = elements.head;
- if (element.isClass) {
- ClassElementX classElement = element;
- classElement.ensureResolved(compiler.resolution);
- classElement.forEachLocalMember((Element e) {
- if (!e.isSynthesized) {
- element = e;
- node = element.parseNode(compiler.parsingContext);
- compiler.resolver.resolve(element);
- mapping = element.treeElements;
- }
- });
- } else {
- node = element.parseNode(compiler.parsingContext);
- compiler.resolver.resolve(element);
- mapping = element.treeElements;
- }
- }
- // Type check last class declaration or member.
- TypeCheckerVisitor checker =
- new TypeCheckerVisitor(compiler, mapping, compiler.resolution.types);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- collector.clear();
- checker.analyze(node, mustHaveType: false);
- compareWarningKinds(text, expectedWarnings, collector.warnings);
-
- compiler.diagnosticHandler = null;
- });
-}
-
-/**
- * Analyze the statement [text] and check messages from the type checker.
- * [errors] and [warnings] can be either [:null:], a single [MessageKind] or
- * a list of [MessageKind]s. If [hints] and [infos] are [:null:] the
- * corresponding message kinds are ignored.
- */
-analyze(MockCompiler compiler, String text,
- {errors, warnings, List hints, List infos, bool flushDeferred: false}) {
- if (warnings == null) warnings = [];
- if (warnings is! List) warnings = [warnings];
- if (errors == null) errors = [];
- if (errors is! List) errors = [errors];
-
- compiler.diagnosticHandler = createHandler(compiler, text);
-
- Token tokens = scan(text);
- NodeListener listener =
- new NodeListener(const ScannerOptions(), compiler.reporter, null);
- Parser parser = new Parser(listener);
- parser.parseStatement(parser.syntheticPreviousToken(tokens));
- Node node = listener.popNode();
- Element compilationUnit = new CompilationUnitElementX(
- new Script(null, null, null), compiler.mainApp);
- Element function = new MockElement(compilationUnit);
- TreeElements elements = compiler.resolveNodeStatement(node, function);
- compiler.enqueuer.resolution.emptyDeferredQueueForTesting();
- TypeCheckerVisitor checker =
- new TypeCheckerVisitor(compiler, elements, compiler.resolution.types);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- collector.clear();
- checker.analyze(node, mustHaveType: false);
- if (flushDeferred) {
- compiler.enqueuer.resolution.emptyDeferredQueueForTesting();
- }
- compareWarningKinds(text, warnings, collector.warnings);
- compareWarningKinds(text, errors, collector.errors);
- if (hints != null) compareWarningKinds(text, hints, collector.hints);
- if (infos != null) compareWarningKinds(text, infos, collector.infos);
- compiler.diagnosticHandler = null;
-}
-
-void generateOutput(MockCompiler compiler, String text) {
- for (CollectedMessage message in compiler.diagnosticCollector.warnings) {
- int begin = message.begin;
- int end = message.end;
- SourceFile sourceFile = new StringSourceFile.fromName('analysis', text);
- print(
- sourceFile.getLocationMessage(message.message.toString(), begin, end));
- }
-}
-
-analyzeIn(MockCompiler compiler, FunctionElement element, String text,
- {warnings, hints}) {
- if (warnings == null) warnings = [];
- if (warnings is! List) warnings = [warnings];
- if (hints == null) hints = [];
- if (hints is! List) hints = [hints];
-
- compiler.resolver.resolve(element);
- Token tokens = scan(text);
- NodeListener listener =
- new NodeListener(const ScannerOptions(), compiler.reporter, null);
- Parser parser = new Parser(listener)
- ..asyncState = element.asyncMarker.asyncParserState;
- parser.parseStatement(parser.syntheticPreviousToken(tokens));
- Node node = listener.popNode();
- TreeElements elements = compiler.resolveNodeStatement(node, element);
- TypeCheckerVisitor checker =
- new TypeCheckerVisitor(compiler, elements, compiler.resolution.types);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- collector.clear();
- checker.analyze(node, mustHaveType: false);
- generateOutput(compiler, text);
- compareWarningKinds(text, warnings, collector.warnings);
- compareWarningKinds(text, hints, collector.hints);
-}
diff --git a/tests/compiler/dart2js/old_frontend/type_equals_test.dart b/tests/compiler/dart2js/old_frontend/type_equals_test.dart
deleted file mode 100644
index f36b82e..0000000
--- a/tests/compiler/dart2js/old_frontend/type_equals_test.dart
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) 2012, 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 "package:expect/expect.dart";
-import "package:async_helper/async_helper.dart";
-import 'package:compiler/src/elements/resolution_types.dart';
-import "../compiler_helper.dart";
-
-test(compiler, String name1, String name2, {bool expect}) {
- Expect.isTrue((expect != null), 'required parameter "expect" not given');
- dynamic clazz = findElement(compiler, "Class");
- clazz.ensureResolved(compiler.resolution);
- dynamic element1 = clazz.buildScope().lookup(name1);
- dynamic element2 = clazz.buildScope().lookup(name2);
- Expect.isNotNull(element1);
- Expect.isNotNull(element2);
- Expect.equals(element1.kind, ElementKind.FUNCTION);
- Expect.equals(element2.kind, ElementKind.FUNCTION);
- element1.computeType(compiler.resolution);
- element2.computeType(compiler.resolution);
- FunctionSignature signature1 = element1.functionSignature;
- FunctionSignature signature2 = element2.functionSignature;
-
- // Function signatures are used to be to provide void types (only occurring as
- // as return types) and (inlined) function types (only occurring as method
- // parameter types).
- //
- // Only a single type is used from each signature. That is, it is not the
- // intention to check the whole signatures against eachother.
- ResolutionDartType type1;
- ResolutionDartType type2;
- if (signature1.requiredParameterCount == 0) {
- // If parameters is empty, use return type.
- type1 = signature1.type.returnType;
- } else {
- // Otherwise use the first argument type.
- type1 = signature1.requiredParameters.first.type;
- }
- if (signature2.requiredParameterCount == 0) {
- // If parameters is empty, use return type.
- type2 = signature2.type.returnType;
- } else {
- // Otherwise use the first argument type.
- type2 = signature2.requiredParameters.first.type;
- }
- if (expect) {
- Expect.equals(type1, type2, "$type1 != $type2");
- } else {
- Expect.notEquals(type1, type2, "$type1 == $type2");
- }
-}
-
-void main() {
- var uri = new Uri(scheme: 'source');
- var compiler = mockCompilerFor(r"""
- typedef int Typedef1<X,Y>(String s1);
- typedef void Typedef2<Z>(T t1, S s1);
-
- class Class<T,S> {
- void void1() {}
- void void2() {}
- void int1(int a) {}
- void int2(int b) {}
- void String1(String a) {}
- void String2(String b) {}
- void ListInt1(List<int> a) {}
- void ListInt2(List<int> b) {}
- void ListString1(List<String> a) {}
- void ListString2(List<String> b) {}
- void MapIntString1(Map<int,String> a) {}
- void MapIntString2(Map<int,String> b) {}
- void TypeVar1(T t1, S s1) {}
- void TypeVar2(T t2, S s2) {}
- void Function1a(int a(String s1)) {}
- void Function2a(int b(String s2)) {}
- void Function1b(void a(T t1, S s1)) {}
- void Function2b(void b(T t2, S s2)) {}
- void Typedef1a(Typedef1<int,String> a) {}
- void Typedef2a(Typedef1<int,String> b) {}
- void Typedef1b(Typedef2<T> a) {}
- void Typedef2b(Typedef2<T> b) {}
- void Typedef1c(Typedef2<S> a) {}
- void Typedef2c(Typedef2<S> b) {}
- }
-
- void main() {}
- """, uri, analyzeAll: true, analyzeOnly: true);
- asyncTest(() => compiler.run(uri).then((_) {
- test(compiler, "void1", "void2", expect: true);
- test(compiler, "int1", "int2", expect: true);
- test(compiler, "String1", "String2", expect: true);
- test(compiler, "ListInt1", "ListInt2", expect: true);
- test(compiler, "ListString1", "ListString2", expect: true);
- test(compiler, "MapIntString1", "MapIntString2", expect: true);
- test(compiler, "TypeVar1", "TypeVar2", expect: true);
- test(compiler, "Function1a", "Function2a", expect: true);
- test(compiler, "Function1b", "Function2b", expect: true);
- test(compiler, "Typedef1a", "Typedef2a", expect: true);
- test(compiler, "Typedef1b", "Typedef2b", expect: true);
- test(compiler, "Typedef1c", "Typedef2c", expect: true);
-
- test(compiler, "void1", "int1", expect: false);
- test(compiler, "int1", "String1", expect: false);
- test(compiler, "String1", "ListInt1", expect: false);
- test(compiler, "ListInt1", "ListString1", expect: false);
- test(compiler, "ListString1", "MapIntString1", expect: false);
- test(compiler, "MapIntString1", "TypeVar1", expect: false);
- test(compiler, "TypeVar1", "Function1a", expect: false);
- test(compiler, "Function1a", "Function1b", expect: false);
- test(compiler, "Function1b", "Typedef1a", expect: false);
- test(compiler, "Typedef1a", "Typedef1b", expect: false);
- test(compiler, "Typedef1b", "Typedef1c", expect: false);
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/type_order_test.dart b/tests/compiler/dart2js/old_frontend/type_order_test.dart
deleted file mode 100644
index be592dc..0000000
--- a/tests/compiler/dart2js/old_frontend/type_order_test.dart
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) 2013, 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 type_order_test;
-
-import 'package:expect/expect.dart';
-import 'package:async_helper/async_helper.dart';
-import '../type_test_helper.dart';
-import 'package:compiler/src/elements/resolution_types.dart';
-import "package:compiler/src/elements/elements.dart"
- show ClassElement, TypedefElement;
-
-void main() {
- asyncTest(() => TypeEnvironment.create(r"""
- class A<AT, AS> {}
- typedef BS B<BT, BS>(BT t);
- class C<CT, CS> extends A<CS, CT> {}
- class X {}
- class Y {}
- class Z {}
- """).then((env) {
- var types = <ResolutionDartType>[];
- ResolutionDartType add(ResolutionDartType type) {
- types.add(type);
- return type;
- }
-
- 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');
- ResolutionDartType X = add(env['X']);
- ResolutionDartType Y = add(env['Y']);
- ResolutionDartType Z = add(env['Z']);
-
- 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]));
-
- 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);
-
- 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(<ResolutionDartType>[
- void_,
- dynamic_,
- A_raw,
- A_this,
- A_X_Y,
- A_Y_X,
- AT,
- AS,
- B_raw,
- B_this,
- B_X_Y,
- B_Y_X,
- BT,
- BS,
- C_raw,
- C_this,
- CT,
- CS,
- X,
- Y,
- Z,
- B_this_alias,
- B_Y_X_alias,
- B_X_Y_alias,
- ], Types.sorted(types));
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/type_promotion_test.dart b/tests/compiler/dart2js/old_frontend/type_promotion_test.dart
deleted file mode 100644
index c09089f..0000000
--- a/tests/compiler/dart2js/old_frontend/type_promotion_test.dart
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that dart2js produces the expected static type warnings for type
-// promotion language tests. This ensures that the analyzer and dart2js agrees
-// on these tests.
-
-import 'warnings_checker.dart';
-
-/// Map from test files to a map of their expected status. If the status map is
-/// `null` no warnings must be missing or unexpected, otherwise the status map
-/// can contain a list of line numbers for keys 'missing' and 'unexpected' for
-/// the warnings of each category.
-const Map<String, dynamic> TESTS = const {
- 'language/type_promotion_assign_test.dart': null,
- 'language/type_promotion_closure_test.dart': null,
- 'language/type_promotion_functions_test.dart': const {
- 'missing': const [65, 66, 67]
- }, // Issue 14933.
- 'language/type_promotion_local_test.dart': null,
- 'language/type_promotion_logical_and_test.dart': null,
- 'language/type_promotion_more_specific_test.dart': null,
- 'language/type_promotion_multiple_test.dart': null,
- 'language/type_promotion_parameter_test.dart': null,
-};
-
-void main() {
- checkWarnings(TESTS);
-}
diff --git a/tests/compiler/dart2js/old_frontend/type_variable_bound_test.dart b/tests/compiler/dart2js/old_frontend/type_variable_bound_test.dart
deleted file mode 100644
index e01e18e..0000000
--- a/tests/compiler/dart2js/old_frontend/type_variable_bound_test.dart
+++ /dev/null
@@ -1,282 +0,0 @@
-// Copyright (c) 2013, 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:async';
-import "package:async_helper/async_helper.dart";
-import '../compiler_helper.dart';
-import "package:expect/expect.dart";
-
-Future compile(String source) {
- Uri uri = Uri.parse('test:code');
- var compiler = mockCompilerFor(source, uri,
- analyzeOnly: true, enableTypeAssertions: true);
- compiler.diagnosticHandler = createHandler(compiler, source);
- return compiler.run(uri).then((_) {
- return compiler;
- });
-}
-
-Future test(String source, {var errors, var warnings}) async {
- if (errors == null) errors = [];
- if (errors is! List) errors = [errors];
- if (warnings == null) warnings = [];
- if (warnings is! List) warnings = [warnings];
- var compiler = await compile(source);
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.equals(!errors.isEmpty, compiler.compilationFailed);
- Expect.equals(
- errors.length,
- collector.errors.length,
- 'unexpected error count: ${collector.errors.length} '
- 'expected ${errors.length}');
- Expect.equals(
- warnings.length,
- collector.warnings.length,
- 'unexpected warning count: ${collector.warnings.length} '
- 'expected ${warnings.length}');
-
- for (int i = 0; i < errors.length; i++) {
- Expect.equals(errors[i], collector.errors.elementAt(i).message.kind);
- }
- for (int i = 0; i < warnings.length; i++) {
- Expect.equals(warnings[i], collector.warnings.elementAt(i).message.kind);
- }
-}
-
-Future test1() async {
- var compiler = await compile(r"""
-class A<T extends T> {}
-
-void main() {
- new A();
-}
-""");
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isFalse(compiler.compilationFailed);
- Expect.isTrue(
- collector.errors.isEmpty, 'unexpected errors: ${collector.errors}');
- Expect.equals(1, collector.warnings.length,
- 'expected exactly one warning, but got ${collector.warnings}');
-
- print(collector.warnings.elementAt(0));
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
- collector.warnings.elementAt(0).message.kind);
- Expect.equals("T",
- collector.warnings.elementAt(0).message.arguments['typeVariableName']);
-}
-
-Future test2() async {
- var compiler = await compile(r"""
-class B<T extends S, S extends T> {}
-
-void main() {
- new B();
-}
-""");
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isFalse(compiler.compilationFailed);
- print(collector.errors);
- Expect.isTrue(collector.errors.isEmpty, 'unexpected errors');
- Expect.equals(2, collector.warnings.length,
- 'expected exactly two errors, but got ${collector.warnings}');
-
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
- collector.warnings.elementAt(0).message.kind);
- Expect.equals("T",
- collector.warnings.elementAt(0).message.arguments['typeVariableName']);
-
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
- collector.warnings.elementAt(1).message.kind);
- Expect.equals("S",
- collector.warnings.elementAt(1).message.arguments['typeVariableName']);
-}
-
-Future test3() async {
- var compiler = await compile(r"""
-class C<T extends S, S extends U, U extends T> {}
-
-void main() {
- new C();
-}
-""");
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isFalse(compiler.compilationFailed);
- print(collector.errors);
- Expect.isTrue(collector.errors.isEmpty, 'unexpected errors');
- Expect.equals(3, collector.warnings.length,
- 'expected exactly one error, but got ${collector.warnings}');
-
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
- collector.warnings.elementAt(0).message.kind);
- Expect.equals("T",
- collector.warnings.elementAt(0).message.arguments['typeVariableName']);
-
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
- collector.warnings.elementAt(1).message.kind);
- Expect.equals("S",
- collector.warnings.elementAt(1).message.arguments['typeVariableName']);
-
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
- collector.warnings.elementAt(2).message.kind);
- Expect.equals("U",
- collector.warnings.elementAt(2).message.arguments['typeVariableName']);
-}
-
-Future test4() async {
- var compiler = await compile(r"""
-class D<T extends S, S extends U, U extends S> {}
-
-void main() {
- new D();
-}
-""");
- DiagnosticCollector collector = compiler.diagnosticCollector;
- Expect.isFalse(compiler.compilationFailed);
- print(collector.errors);
- Expect.isTrue(collector.errors.isEmpty, 'unexpected errors');
- Expect.equals(2, collector.warnings.length,
- 'expected exactly one error, but got ${collector.warnings}');
-
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
- collector.warnings.elementAt(0).message.kind);
- Expect.equals("S",
- collector.warnings.elementAt(0).message.arguments['typeVariableName']);
-
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
- collector.warnings.elementAt(1).message.kind);
- Expect.equals("U",
- collector.warnings.elementAt(1).message.arguments['typeVariableName']);
-}
-
-Future test5() {
- return test(r"""
-class A<T extends num> {}
-
-void main() {
- new A();
- new A<num>();
- new A<dynamic>();
- new A<int>();
- new A<double>();
-}
-""");
-}
-
-Future test6() {
- return test(r"""
-class A<T extends num> {}
-
-void main() {
- new A<String>();
-}
-""", warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND);
-}
-
-Future test7() {
- return test(r"""
-class A<T extends num> {}
-class B<T> extends A<T> {} // Warning produced here.
-
-void main() {
- new B(); // No warning produced here.
- new B<String>(); // No warning produced here.
-}
-""", warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND);
-}
-
-Future test8() {
- return test(r"""
-class B<T extends B<T>> {}
-class C<T extends B<T>> extends B<T> {}
-class D<T extends C<T>> extends C<T> {}
-class E<T extends E<T>> extends D<T> {}
-class F extends E<F> {}
-
-void main() {
- new B();
- new B<dynamic>();
- new B<F>();
- new B<B<F>>();
- new C();
- new C<dynamic>();
- new C<B<F>>();
- new D();
- new D<dynamic>();
- new D<C<F>>();
- new E();
- new E<dynamic>();
- new E<E<F>>();
- new F();
-}
-""");
-}
-
-Future test9() {
- return test(r"""
-class B<T extends B<T>> {}
-class C<T extends B<T>> extends B<T> {}
-class D<T extends C<T>> extends C<T> {}
-class E<T extends E<T>> extends D<T> {}
-class F extends E<F> {}
-
-void main() {
- new D<B<F>>(); // Warning: B<F> is not a subtype of C<T>.
- new E<D<F>>(); // Warning: E<F> is not a subtype of E<T>.
-}
-""", warnings: [
- MessageKind.INVALID_TYPE_VARIABLE_BOUND,
- MessageKind.INVALID_TYPE_VARIABLE_BOUND
- ]);
-}
-
-Future test10() {
- return test(r"""
-class A {
- const A();
-}
-class Test<T extends A> {
- final T x = const A();
- const Test();
-}
-main() {
- print(const Test<A>());
-}
-""");
-}
-
-// TODO(het): The error is reported twice because both the Dart and JS constant
-// compilers are run on the const constructor, investigate why.
-Future test11() {
- return test(r"""
-class A {
- const A();
-}
-class B extends A {
- const B();
-}
-class Test<T extends A> {
- final T x = const A();
- const Test();
-}
-main() {
- print(const Test<B>());
-}
-""", errors: [MessageKind.NOT_ASSIGNABLE, MessageKind.NOT_ASSIGNABLE]);
-}
-
-main() {
- asyncTest(() async {
- await test1();
- await test2();
- await test3();
- await test4();
- await test5();
- await test6();
- await test7();
- await test8();
- await test9();
- await test10();
- await test11();
- });
-}
diff --git a/tests/compiler/dart2js/old_frontend/type_variable_occurrence_test.dart b/tests/compiler/dart2js/old_frontend/type_variable_occurrence_test.dart
deleted file mode 100644
index ac88d12..0000000
--- a/tests/compiler/dart2js/old_frontend/type_variable_occurrence_test.dart
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (c) 2013, 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 type_variable_occurrence_test;
-
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/elements/elements.dart' show ClassElement;
-import 'package:compiler/src/elements/resolution_types.dart';
-import 'package:compiler/src/elements/types.dart';
-import 'package:expect/expect.dart';
-
-import '../type_test_helper.dart';
-
-void main() {
- testTypeVariableOccurrence();
-}
-
-testTypeVariableOccurrence() {
- asyncTest(() => TypeEnvironment.create(r"""
- typedef S Typedef1<S>();
- typedef void Typedef2<S>(S s);
- typedef void Typedef3<S>(A<S> a);
-
- class A<T> {
- int field1;
- T field2;
- A<int> field3;
- A<T> field4;
- A<A<int>> field5;
- A<A<T>> field6;
-
- Typedef1 field7;
- Typedef1<int> field8;
- Typedef1<T> field9;
- Typedef1<Typedef1<T>> field10;
-
- Typedef2 field11;
- Typedef2<int> field12;
- Typedef2<T> field13;
- Typedef2<Typedef1<T>> field14;
-
- Typedef3 field15;
- Typedef3<int> field16;
- Typedef3<T> field17;
- Typedef3<Typedef1<T>> field18;
-
- void method1() {}
- T method2() => null;
- A<T> method3() => null;
- void method4(T t) {}
- void method5(A<T> t) {}
- void method6(void foo(T t)) {}
- void method7([T t]) {}
- void method8({T t}) {}
- }
- """).then((env) {
- ClassElement A = env.getElement('A');
-
- expect(bool expectResult, String memberName) {
- ResolutionDartType memberType = env.getMemberType(memberName, A);
- ResolutionTypeVariableType typeVariable =
- memberType.typeVariableOccurrence;
- if (expectResult) {
- Expect.isNotNull(typeVariable);
- Expect.equals(A, DartTypes.getClassContext(memberType));
- } else {
- Expect.isNull(typeVariable);
- Expect.isNull(DartTypes.getClassContext(memberType));
- }
- }
-
- // int field1;
- expect(false, 'field1');
- // T field2;
- expect(true, 'field2');
- // A<int> field3;
- expect(false, 'field3');
- // A<T> field4;
- expect(true, 'field4');
- // A<A<int>> field5;
- expect(false, 'field5');
- // A<A<T>> field6;
- expect(true, 'field6');
-
- // Typedef1 field7;
- expect(false, 'field7');
- // Typedef1<int> field8;
- expect(false, 'field8');
- // Typedef1<T> field9;
- expect(true, 'field9');
- // Typedef1<Typedef1<T>> field10;
- expect(true, 'field10');
-
- // Typedef2 field11;
- expect(false, 'field11');
- // Typedef2<int> field12;
- expect(false, 'field12');
- // Typedef2<T> field13;
- expect(true, 'field13');
- // Typedef2<Typedef1<T>> field14;
- expect(true, 'field14');
-
- // Typedef3 field15;
- expect(false, 'field15');
- // Typedef3<int> field16;
- expect(false, 'field16');
- // Typedef3<T> field17;
- expect(true, 'field17');
- // Typedef3<Typedef1<T>> field18;
- expect(true, 'field18');
-
- // void method1() {}
- expect(false, 'method1');
- // T method2() => null;
- expect(true, 'method2');
- // A<T> method3() => null;
- expect(true, 'method3');
- // void method4(T t) {}
- expect(true, 'method4');
- // void method5(A<T> t) {}
- expect(true, 'method5');
- // void method6(void foo(T t)) {}
- expect(true, 'method6');
- // void method7([T t]);
- expect(true, 'method7');
- // void method8({T t});
- expect(true, 'method8');
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/unparser2_test.dart b/tests/compiler/dart2js/old_frontend/unparser2_test.dart
deleted file mode 100644
index 458b6f3..0000000
--- a/tests/compiler/dart2js/old_frontend/unparser2_test.dart
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) 2012, 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 "package:expect/expect.dart";
-import "package:compiler/src/parser/element_listener.dart";
-import "package:compiler/src/parser/node_listener.dart";
-import "package:front_end/src/fasta/parser.dart";
-import "package:front_end/src/fasta/scanner.dart";
-import "package:compiler/src/tree/tree.dart";
-
-import "package:compiler/src/diagnostics/diagnostic_listener.dart";
-import "package:compiler/src/elements/elements.dart"
- show CompilationUnitElement, LibraryElement;
-import "package:compiler/src/elements/modelx.dart"
- show CompilationUnitElementX, LibraryElementX;
-import "package:compiler/src/script.dart";
-
-main() {
- testClassDef();
- testClass1Field();
- testClass2Fields();
- testClass1Field1Method();
- testClass1Field2Method();
- testClassDefTypeParam();
- testEnumDef();
- testEnum1Value();
- testEnum2Value();
- testEnum3Value();
- testEnum3CommaValue();
-}
-
-testClassDef() {
- compareCode('class T{}');
-}
-
-testClass1Field() {
- compareCode('class T{var x;}');
-}
-
-testClass2Fields() {
- compareCode('class T{var x;var y;}');
-}
-
-testClass1Field1Method() {
- compareCode('class T{var x;m(){}}');
-}
-
-testClass1Field2Method() {
- compareCode('class T{a(){}b(){}}');
-}
-
-testClassDefTypeParam() {
- compareCode('class T<X>{}');
-}
-
-testEnumDef() {
- compareCode('enum T {}');
-}
-
-testEnum1Value() {
- compareCode('enum T {A}');
-}
-
-testEnum2Value() {
- compareCode('enum T {A,B}');
-}
-
-testEnum3Value() {
- compareCode('enum T {A,B,C}');
-}
-
-testEnum3CommaValue() {
- compareCode('enum T {A,B,C,}', expectedResult: 'enum T {A,B,C}');
-}
-
-void compareCode(String code, {String expectedResult}) {
- if (expectedResult == null) {
- expectedResult = code;
- }
- Expect.equals(expectedResult, doUnparse(code));
-}
-
-String doUnparse(String source) {
- MessageCollector diagnosticListener = new MessageCollector();
- Script script = new Script(null, null, null);
- LibraryElement lib = new LibraryElementX(script);
- CompilationUnitElement element = new CompilationUnitElementX(script, lib);
- StringScanner scanner = new StringScanner(source);
- Token beginToken = scanner.tokenize();
- NodeListener listener =
- new NodeListener(const ScannerOptions(), diagnosticListener, element);
- Parser parser = new Parser(listener);
- parser.parseUnit(beginToken);
- Node node = listener.popNode();
- Expect.isTrue(listener.nodes.isEmpty);
- return unparse(node);
-}
-
-class MessageCollector extends DiagnosticReporter {
- List<String> messages;
- MessageCollector() {
- messages = [];
- }
- void internalError(node, covariant String reason) {
- messages.add(reason);
- throw reason;
- }
-
- void log(message) {
- messages.add(message);
- }
-
- noSuchMethod(Invocation invocation) => throw 'unsupported operation';
-}
diff --git a/tests/compiler/dart2js/old_frontend/unparser_test.dart b/tests/compiler/dart2js/old_frontend/unparser_test.dart
deleted file mode 100644
index cd815c8..0000000
--- a/tests/compiler/dart2js/old_frontend/unparser_test.dart
+++ /dev/null
@@ -1,432 +0,0 @@
-// Copyright (c) 2012, 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 'package:expect/expect.dart';
-import 'parser_helper.dart';
-import 'package:compiler/src/tree/tree.dart';
-
-testUnparse(String statement) {
- Node node = parseStatement(statement);
- Expect.equals(statement, unparse(node));
-}
-
-testUnparseMember(String member) {
- Node node = parseMember(member);
- Expect.equals(member, unparse(node));
-}
-
-testUnparseUnit(String code) {
- Node node = fullParseUnit(code);
- Expect.equals(code, unparse(node));
-}
-
-testUnparseTopLevelWithMetadata(String code) {
- testUnparseUnit(code);
- // TODO(ahe): Enable when supported.
- // testUnparseUnit('@foo $code');
-}
-
-testSignedConstants() {
- testUnparse('var x=-42;');
- testUnparse('var x=-.42;');
- testUnparse('var x=-0;');
- testUnparse('var x=-0.0;');
- testUnparse('var x=-.0;');
-}
-
-testGenericTypes() {
- testUnparse('var x=new List<List<int>>();');
- testUnparse('var x=new List<List<List<int>>>();');
- testUnparse('var x=new List<List<List<List<int>>>>();');
- testUnparse('var x=new List<List<List<List<List<int>>>>>();');
-}
-
-testForLoop() {
- testUnparse('for(;i<100;i++ ){}');
- testUnparse('for(i=0;i<100;i++ ){}');
-}
-
-testEmptyList() {
- testUnparse('var x=[] ;');
-}
-
-testClosure() {
- testUnparse('var x=(var x)=>x;');
-}
-
-testIndexedOperatorDecl() {
- testUnparseMember('operator[](int i)=>null;');
- testUnparseMember('operator[]=(int i,int j)=>null;');
-}
-
-testNativeMethods() {
- testUnparseMember('foo()native;');
- testUnparseMember('foo()native "bar";');
- testUnparseMember('foo()native "this.x = 41";');
-}
-
-testPrefixIncrements() {
- testUnparse(' ++i;');
- testUnparse(' ++a[i];');
- testUnparse(' ++a[ ++b[i]];');
-}
-
-testConstModifier() {
- testUnparse('foo([var a=const[] ]){}');
- testUnparse('foo([var a=const{}]){}');
- testUnparse('foo(){var a=const[] ;var b=const{};}');
- testUnparse('foo([var a=const[const{"a":const[1,2,3]}]]){}');
-}
-
-testSimpleObjectInstantiation() {
- testUnparse('main(){new Object();}');
-}
-
-testLibraryName() {
- testUnparseTopLevelWithMetadata('library com;');
- testUnparseTopLevelWithMetadata('library com.example;');
- testUnparseTopLevelWithMetadata('library com.example.dart;');
-}
-
-testImport() {
- testUnparseTopLevelWithMetadata('import "søhest";');
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest;');
-}
-
-testExport() {
- testUnparseTopLevelWithMetadata('export "søhest";');
-}
-
-testConditionalImport() {
- testUnparseTopLevelWithMetadata('import "søhest" if(some.dotted.id)"other";');
- testUnparseTopLevelWithMetadata('import "søhest" if(id=="some str")"other";');
- testUnparseTopLevelWithMetadata('import "søhest"'
- ' if(id=="some str")"other"'
- ' if(id)"other2";');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" if(some.dotted.id)"other" as fiskehest;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" if(id=="some str")"other" as fiskehest;');
- testUnparseTopLevelWithMetadata('import "søhest"'
- ' if(id=="some str")"other"'
- ' if(id)"other2"'
- ' as fiskehest;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" if(some.dotted.id)"other" deferred as fiskehest;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" if(id=="some str")"other" deferred as fiskehest;');
- testUnparseTopLevelWithMetadata('import "søhest"'
- ' if(id=="some str")"other"'
- ' if(id)"other2"'
- ' deferred as fiskehest;');
- testUnparseTopLevelWithMetadata('import "søhest"'
- ' if(id=="some str")"other"'
- ' if(id)"other2"'
- ' deferred as fiskehest'
- ' show foo,bar;');
-}
-
-testConditionalExport() {
- testUnparseTopLevelWithMetadata('export "søhest" if(some.dotted.id)"other";');
- testUnparseTopLevelWithMetadata('export "søhest" if(id=="some str")"other";');
- testUnparseTopLevelWithMetadata('export "søhest"'
- ' if(id=="some str")"other"'
- ' if(id)"other2";');
- testUnparseTopLevelWithMetadata('export "søhest"'
- ' if(id=="some str")"other"'
- ' if(id)"other2"'
- ' show foo,bar;');
-}
-
-testPart() {
- testUnparseTopLevelWithMetadata('part "søhest";');
-}
-
-testPartOf() {
- testUnparseTopLevelWithMetadata('part of com;');
- testUnparseTopLevelWithMetadata('part of com.example;');
- testUnparseTopLevelWithMetadata('part of com.example.dart;');
-}
-
-testCombinators() {
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest show a;');
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest show hide;');
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest show show;');
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest show a,hide;');
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest show a,show;');
-
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest hide a;');
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest hide hide;');
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest hide show;');
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest hide a,hide;');
- testUnparseTopLevelWithMetadata('import "søhest" as fiskehest hide a,show;');
-
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest show a hide a;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest show hide hide hide;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest show show hide show;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest show a,hide hide a,hide;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest show a,show hide a,show;');
-
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest hide a show a;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest hide hide show hide;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest hide show show show;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest hide a,hide show a,hide;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest hide a,show show a,show;');
-
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest show a show a;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest show hide show hide;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest show show show show;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest show a,hide show a,hide;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest show a,show show a,show;');
-
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest hide a hide a;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest hide hide hide hide;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest hide show hide show;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest hide a,hide hide a,hide;');
- testUnparseTopLevelWithMetadata(
- 'import "søhest" as fiskehest hide a,show hide a,show;');
-
- testUnparseTopLevelWithMetadata('export "søhest" show a;');
- testUnparseTopLevelWithMetadata('export "søhest" show hide;');
- testUnparseTopLevelWithMetadata('export "søhest" show show;');
- testUnparseTopLevelWithMetadata('export "søhest" show a,hide;');
- testUnparseTopLevelWithMetadata('export "søhest" show a,show;');
-
- testUnparseTopLevelWithMetadata('export "søhest" hide a;');
- testUnparseTopLevelWithMetadata('export "søhest" hide hide;');
- testUnparseTopLevelWithMetadata('export "søhest" hide show;');
- testUnparseTopLevelWithMetadata('export "søhest" hide a,hide;');
- testUnparseTopLevelWithMetadata('export "søhest" hide a,show;');
-
- testUnparseTopLevelWithMetadata('export "søhest" show a hide a;');
- testUnparseTopLevelWithMetadata('export "søhest" show hide hide hide;');
- testUnparseTopLevelWithMetadata('export "søhest" show show hide show;');
- testUnparseTopLevelWithMetadata('export "søhest" show a,hide hide a,hide;');
- testUnparseTopLevelWithMetadata('export "søhest" show a,show hide a,show;');
-
- testUnparseTopLevelWithMetadata('export "søhest" hide a show a;');
- testUnparseTopLevelWithMetadata('export "søhest" hide hide show hide;');
- testUnparseTopLevelWithMetadata('export "søhest" hide show show show;');
- testUnparseTopLevelWithMetadata('export "søhest" hide a,hide show a,hide;');
- testUnparseTopLevelWithMetadata('export "søhest" hide a,show show a,show;');
-
- testUnparseTopLevelWithMetadata('export "søhest" show a show a;');
- testUnparseTopLevelWithMetadata('export "søhest" show hide show hide;');
- testUnparseTopLevelWithMetadata('export "søhest" show show show show;');
- testUnparseTopLevelWithMetadata('export "søhest" show a,hide show a,hide;');
- testUnparseTopLevelWithMetadata('export "søhest" show a,show show a,show;');
-
- testUnparseTopLevelWithMetadata('export "søhest" hide a hide a;');
- testUnparseTopLevelWithMetadata('export "søhest" hide hide hide hide;');
- testUnparseTopLevelWithMetadata('export "søhest" hide show hide show;');
- testUnparseTopLevelWithMetadata('export "søhest" hide a,hide hide a,hide;');
- testUnparseTopLevelWithMetadata('export "søhest" hide a,show hide a,show;');
-}
-
-testDeferredImport() {
- testUnparseTopLevelWithMetadata('import "lib.dart" as a;');
- testUnparseTopLevelWithMetadata('import "lib.dart" deferred as a;');
- testUnparseTopLevelWithMetadata('import "lib.dart" deferred as a show b;');
- testUnparseTopLevelWithMetadata('import "lib.dart" deferred as a hide b;');
-}
-
-testUnparseMemberAndAsMemberOfFoo(String code) {
- testUnparseMember(code);
- testUnparseTopLevelWithMetadata('class Foo{$code}');
-}
-
-testRedirectingFactoryConstructors() {
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar.baz;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<T>;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<List<T>,T>;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<T>.baz;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<List<T>,T>.baz;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar.baz;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<T>;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<List<T>,T>;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<T>.baz;");
- testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<List<T>,T>.baz;");
- testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar;");
- testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar.baz;");
- testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<T>;");
- testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<List<T>,T>;");
- testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<T>.baz;");
- testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<List<T>,T>.baz;");
- testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar;");
- testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar.baz;");
- testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar<T>;");
- testUnparseMemberAndAsMemberOfFoo(
- "const factory Foo()=prefix.Bar<List<T>,T>;");
- testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar<T>.baz;");
- testUnparseMemberAndAsMemberOfFoo(
- "const factory Foo()=prefix.Bar<List<T>,T>.baz;");
- testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar;");
- testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar.baz;");
- testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar<T>;");
- testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar<List<T>,T>;");
- testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar<T>.baz;");
- testUnparseMemberAndAsMemberOfFoo(
- "external factory Foo()=Bar<List<T>,T>.baz;");
- testUnparseMemberAndAsMemberOfFoo("external factory Foo()=prefix.Bar;");
- testUnparseMemberAndAsMemberOfFoo("external factory Foo()=prefix.Bar.baz;");
- testUnparseMemberAndAsMemberOfFoo("external factory Foo()=prefix.Bar<T>;");
- testUnparseMemberAndAsMemberOfFoo(
- "external factory Foo()=prefix.Bar<List<T>,T>;");
- testUnparseMemberAndAsMemberOfFoo(
- "external factory Foo()=prefix.Bar<T>.baz;");
- testUnparseMemberAndAsMemberOfFoo(
- "external factory Foo()=prefix.Bar<List<T>,T>.baz;");
- testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar;");
- testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar.baz;");
- testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar<T>;");
- testUnparseMemberAndAsMemberOfFoo(
- "external const factory Foo()=Bar<List<T>,T>;");
- testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar<T>.baz;");
- testUnparseMemberAndAsMemberOfFoo(
- "external const factory Foo()=Bar<List<T>,T>.baz;");
- testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=prefix.Bar;");
- testUnparseMemberAndAsMemberOfFoo(
- "external const factory Foo()=prefix.Bar.baz;");
- testUnparseMemberAndAsMemberOfFoo(
- "external const factory Foo()=prefix.Bar<T>;");
- testUnparseMemberAndAsMemberOfFoo(
- "external const factory Foo()=prefix.Bar<List<T>,T>;");
- testUnparseMemberAndAsMemberOfFoo(
- "external const factory Foo()=prefix.Bar<T>.baz;");
- testUnparseMemberAndAsMemberOfFoo(
- "external const factory Foo()=prefix.Bar<List<T>,T>.baz;");
-}
-
-testClassDeclarations() {
- testUnparseTopLevelWithMetadata('class Foo{}');
- testUnparseTopLevelWithMetadata('abstract class Foo{}');
- testUnparseTopLevelWithMetadata('class Fisk{operator-(x){}}');
-}
-
-testMixinApplications() {
- testUnparseTopLevelWithMetadata('class C = S with M;');
- testUnparseTopLevelWithMetadata('class C = S with M1,M2;');
- testUnparseTopLevelWithMetadata('class C = S with M1,M2,M3;');
-
- testUnparseTopLevelWithMetadata('class C<A> = S with M;');
- testUnparseTopLevelWithMetadata('class C<A,B> = S with M;');
-
- testUnparseTopLevelWithMetadata('class C = S<A> with M;');
- testUnparseTopLevelWithMetadata('class C = S<A,B> with M;');
-
- testUnparseTopLevelWithMetadata('class C = S with M<A>;');
- testUnparseTopLevelWithMetadata('class C = S with M<A,B>;');
- testUnparseTopLevelWithMetadata('class C = S with M1<A>,M2;');
- testUnparseTopLevelWithMetadata('class C = S with M1,M2<A,B>;');
-
- testUnparseTopLevelWithMetadata('abstract class C = S with M;');
- testUnparseTopLevelWithMetadata('abstract class C<A> = S<A> with M<A>;');
-}
-
-testUnparseParameters(List<String> variableDeclarations) {
- var sb = new StringBuffer();
- sb.write('Constructor(');
- int index = 0;
- for (String variableDeclaration in variableDeclarations) {
- if (index != 0) {
- sb.write(', ');
- }
- sb.write(variableDeclaration);
- index++;
- }
- sb.write(');');
-
- FunctionExpression node = parseMember(sb.toString());
- index = 0;
- for (VariableDefinitions parameter in node.parameters.nodes) {
- Expect.equals(variableDeclarations[index], unparse(parameter));
- index++;
- }
-}
-
-testParameters() {
- testUnparseParameters(["foo", "bar=0", "int baz", "int boz=0"]);
- testUnparseParameters(
- ["this.foo", "this.bar=0", "int this.baz", "int this.boz=0"]);
- testUnparseParameters(
- ["foo()", "void bar()", "int baz(a)", "int boz(int a,int b)=null"]);
- testUnparseParameters([
- "this.foo()",
- //"void this.bar()", // Commented out due to Issue 7852
- //"int this.baz(a)", // Commented out due to Issue 7852
- //"int this.boz(int a,int b)=null" // Commented out due to Issue 7852
- ]);
- testUnparseParameters(
- ["@a foo", "@b @c bar=0", "@D(0) int baz", "@E([f],{g:h}) int boz=0"]);
-}
-
-testSymbolLiterals() {
- testUnparse("#+;");
- testUnparse("#-;");
- testUnparse("#*;");
- testUnparse("#/;");
- testUnparse("#~/;");
- testUnparse("#%;");
- testUnparse("#<;");
- testUnparse("#<=;");
- testUnparse("#>;");
- testUnparse("#>=;");
- testUnparse("#==;");
- testUnparse("#&;");
- testUnparse("#|;");
- testUnparse("#^;");
-
- testUnparse("#a;");
- testUnparse("#a.b;");
- testUnparse("#a.b.c;");
- testUnparse("#aa.bb.cc.dd;");
-}
-
-main() {
- testSignedConstants();
- testGenericTypes();
- testForLoop();
- testEmptyList();
- testClosure();
- testIndexedOperatorDecl();
- testNativeMethods();
- testPrefixIncrements();
- testConstModifier();
- testSimpleObjectInstantiation();
- testLibraryName();
- testImport();
- testExport();
- testConditionalImport();
- testConditionalExport();
- testPart();
- testPartOf();
- testCombinators();
- testDeferredImport();
- testRedirectingFactoryConstructors();
- testClassDeclarations();
- testMixinApplications();
- testParameters();
- testSymbolLiterals();
-}
diff --git a/tests/compiler/dart2js/old_frontend/warnings_checker.dart b/tests/compiler/dart2js/old_frontend/warnings_checker.dart
deleted file mode 100644
index 2bb7c4e..0000000
--- a/tests/compiler/dart2js/old_frontend/warnings_checker.dart
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Test that dart2js produces the expected static type warnings to ensures that
-// the analyzer and dart2js agrees on the tests.
-
-import 'dart:async';
-import 'dart:io';
-import 'package:expect/expect.dart';
-import 'package:async_helper/async_helper.dart';
-import '../memory_compiler.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:compiler/src/filenames.dart';
-import 'package:compiler/src/io/source_file.dart';
-import 'package:compiler/src/source_file_provider.dart';
-import 'package:compiler/src/util/uri_extras.dart';
-import 'dart:convert';
-
-final _multiTestRegExpSeperator = new RegExp(r"//[#/]");
-
-void checkWarnings(Map<String, dynamic> tests, [List<String> arguments]) {
- bool isWindows = Platform.isWindows;
- bool warningsMismatch = false;
- bool verbose = arguments != null && arguments.contains('-v');
- asyncTest(() => Future.forEach(tests.keys, (String test) async {
- Uri uri = Uri.base.resolve('tests/$test');
- String source = utf8.decode(readAll(uriPathToNative(uri.path)));
- SourceFile file = new StringSourceFile(
- uri, relativize(currentDirectory, uri, isWindows), source);
- Map<int, String> expectedWarnings = {};
- int lineNo = 0;
- for (String line in source.split('\n')) {
- if (line.contains(_multiTestRegExpSeperator) &&
- (line.contains('static type warning') ||
- line.contains('static warning'))) {
- expectedWarnings[lineNo] = line;
- }
- lineNo++;
- }
- Set<int> unseenWarnings = new Set<int>.from(expectedWarnings.keys);
- DiagnosticCollector collector = new DiagnosticCollector();
- await runCompiler(
- entryPoint: uri,
- diagnosticHandler: collector,
- options: [Flags.analyzeOnly, Flags.useOldFrontend],
- showDiagnostics: verbose);
- Map<String, List<int>> statusMap = tests[test];
- // Line numbers with known unexpected warnings.
- List<int> unexpectedStatus = [];
- if (statusMap != null && statusMap.containsKey('unexpected')) {
- unexpectedStatus = statusMap['unexpected'];
- }
- // Line numbers with known missing warnings.
- List<int> missingStatus = [];
- if (statusMap != null && statusMap.containsKey('missing')) {
- missingStatus = statusMap['missing'];
- }
- for (CollectedMessage message in collector.warnings) {
- Expect.equals(uri, message.uri);
- int lineNo = file.getLocation(message.begin).line - 1;
- if (expectedWarnings.containsKey(lineNo)) {
- unseenWarnings.remove(lineNo);
- } else if (!unexpectedStatus.contains(lineNo + 1)) {
- warningsMismatch = true;
- print(file.getLocationMessage(
- 'Unexpected warning: ${message.message}',
- message.begin,
- message.end));
- }
- }
- if (!unseenWarnings.isEmpty) {
- for (int lineNo in unseenWarnings) {
- if (!missingStatus.contains(lineNo + 1)) {
- warningsMismatch = true;
- String line = expectedWarnings[lineNo];
- print('$uri [${lineNo+1}]: Missing static type warning.');
- print(line);
- }
- }
- }
- }).then((_) {
- Expect.isFalse(warningsMismatch);
- }));
-}
diff --git a/tests/compiler/dart2js/old_frontend/zero_termination_test.dart b/tests/compiler/dart2js/old_frontend/zero_termination_test.dart
deleted file mode 100644
index 0165af1..0000000
--- a/tests/compiler/dart2js/old_frontend/zero_termination_test.dart
+++ /dev/null
@@ -1,118 +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.
-
-// A regression test for issue 22667.
-//
-// Makes sure that we don't print a '\0' character for files that are not
-// properly new-line terminated.
-library zero_termination_test;
-
-import 'dart:async';
-import 'dart:convert';
-import 'dart:io';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/commandline_options.dart';
-import 'package:expect/expect.dart';
-import 'package:path/path.dart' as path;
-
-import '../end_to_end/launch_helper.dart' show launchDart2Js;
-
-Uri pathOfData = Platform.script;
-Directory tempDir;
-String outFilePath;
-
-_sendNotFound(HttpResponse response) {
- response.statusCode = HttpStatus.NOT_FOUND;
- response.close();
-}
-
-Future handleRequest(HttpRequest request) {
- final String path = request.uri.path.substring(1);
- final Uri requestPath = pathOfData.resolve(path);
- final File file = new File(requestPath.toFilePath());
- return file.exists().then((bool found) {
- if (found) {
- file.openRead().pipe(request.response).catchError((e) {
- _sendNotFound(request.response);
- });
- } else {
- _sendNotFound(request.response);
- }
- });
-}
-
-void cleanup() {
- File outFile = new File(outFilePath);
- if (outFile.existsSync()) {
- outFile.deleteSync();
- }
-}
-
-void check(ProcessResult result) {
- Expect.notEquals(0, result.exitCode);
- List<int> stdout = result.stdout;
- String stdoutString = utf8.decode(stdout);
- Expect.isTrue(stdoutString.contains("Error"), "stdout:\n$stdoutString");
- // Make sure the "499" from the last line is in the output.
- Expect.isTrue(stdoutString.contains("499"), "stdout:\n$stdoutString");
-
- // Make sure that the output does not contain any 0 character.
- Expect.isFalse(stdout.contains(0));
-}
-
-Future testFile() async {
- String inFilePath =
- pathOfData.resolve('data/one_line_dart_program.dart').path;
- List<String> args = [
- inFilePath,
- "--out=" + outFilePath,
- Flags.useOldFrontend
- ];
- await cleanup();
- check(await launchDart2Js(args, noStdoutEncoding: true));
- await cleanup();
-}
-
-Future serverRunning(HttpServer server) async {
- int port = server.port;
- String inFilePath = "http://127.0.0.1:$port/data/one_line_dart_program.dart";
- List<String> args = [
- inFilePath,
- "--out=" + outFilePath,
- Flags.useOldFrontend
- ];
-
- server.listen(handleRequest);
- try {
- await cleanup();
- check(await launchDart2Js(args, noStdoutEncoding: true));
- } finally {
- await server.close();
- await cleanup();
- }
-}
-
-Future testHttp() {
- return HttpServer
- .bind(InternetAddress.LOOPBACK_IP_V4, 0)
- .then((HttpServer server) => serverRunning(server));
-}
-
-runTests() async {
- tempDir = Directory.systemTemp.createTempSync('directory_test');
- outFilePath = path.join(tempDir.path, "out.js");
-
- try {
- await testFile();
- await testHttp();
- } finally {
- await tempDir.delete(recursive: true);
- }
-}
-
-main() {
- asyncTest(() async {
- await runTests();
- });
-}
diff --git a/tests/compiler/dart2js/path with spaces/file with spaces.dart b/tests/compiler/dart2js/path with spaces/file with spaces.dart
deleted file mode 100644
index b0cc204..0000000
--- a/tests/compiler/dart2js/path with spaces/file with spaces.dart
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) 2014, 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 'library space/lib with spaces.dart';
-
-main() {
- if (foo() != 499) throw "bad value";
-}
diff --git a/tests/compiler/dart2js/path with spaces/library space/lib with spaces.dart b/tests/compiler/dart2js/path with spaces/library space/lib with spaces.dart
deleted file mode 100644
index 16da6e3..0000000
--- a/tests/compiler/dart2js/path with spaces/library space/lib with spaces.dart
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) 2014, 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 spaces;
-
-part "part space/part space.dart";
-
-foo() => bar();
diff --git a/tests/compiler/dart2js/path with spaces/library space/part space/part space.dart b/tests/compiler/dart2js/path with spaces/library space/part space/part space.dart
deleted file mode 100644
index 58aff0f..0000000
--- a/tests/compiler/dart2js/path with spaces/library space/part space/part space.dart
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright (c) 2014, 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.
-
-part of spaces;
-
-bar() => 499;
diff --git a/tests/compiler/dart2js/quarantined/http_launch_data/http_launch_main.dart b/tests/compiler/dart2js/quarantined/http_launch_data/http_launch_main.dart
deleted file mode 100644
index b2359a9..0000000
--- a/tests/compiler/dart2js/quarantined/http_launch_data/http_launch_main.dart
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) 2014, 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 'lib1.dart';
-
-main() {
- print(foo());
-}
diff --git a/tests/compiler/dart2js/quarantined/http_launch_data/http_launch_main_package.dart b/tests/compiler/dart2js/quarantined/http_launch_data/http_launch_main_package.dart
deleted file mode 100644
index 03ffa18..0000000
--- a/tests/compiler/dart2js/quarantined/http_launch_data/http_launch_main_package.dart
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (c) 2014, 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.
-
-// ignore: URI_DOES_NOT_EXIST
-import 'package:simple/simple.dart';
-
-main() {
- // ignore: UNDEFINED_FUNCTION
- print(foo());
-}
diff --git a/tests/compiler/dart2js/quarantined/http_launch_data/lib1.dart b/tests/compiler/dart2js/quarantined/http_launch_data/lib1.dart
deleted file mode 100644
index 7e4ab7e..0000000
--- a/tests/compiler/dart2js/quarantined/http_launch_data/lib1.dart
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright (c) 2014, 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.
-
-foo() => "hello http tester";
diff --git a/tests/compiler/dart2js/quarantined/http_launch_data/packages/simple/simple.dart b/tests/compiler/dart2js/quarantined/http_launch_data/packages/simple/simple.dart
deleted file mode 100644
index 7e4ab7e..0000000
--- a/tests/compiler/dart2js/quarantined/http_launch_data/packages/simple/simple.dart
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright (c) 2014, 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.
-
-foo() => "hello http tester";
diff --git a/tests/compiler/dart2js/quarantined/http_launch_data/pkcert/README b/tests/compiler/dart2js/quarantined/http_launch_data/pkcert/README
deleted file mode 100644
index fe764a9..0000000
--- a/tests/compiler/dart2js/quarantined/http_launch_data/pkcert/README
+++ /dev/null
@@ -1,16 +0,0 @@
-This is a certificate database used by Dart for testing purposes.
-
-It is created as a certificate database by NSS (Network Security Services),
-a library from Mozilla, using the certutil tool. It uses a cert9.db file,
-rather than a cert8.db file, so the database directory must be specified with
-"sql:" in front of the directory path, or the environment variable
-NSS_DEFAULT_DB_TYPE must be set to "sql".
-
-The password for the key database is "dartdart".
-
-The database contains a root certificate from Equifax, used to verify the
-client https connection to www.google.dk. It contains a self-signed
-certificate for a local certificate authority myauthority_cert, and a
-server certificate for localhost called localhost_cert, signed by
-myauthority_cert. It contains the key for localhost_cert, but
-not the key for myauthority_cert.
diff --git a/tests/compiler/dart2js/quarantined/http_launch_data/pkcert/cert9.db b/tests/compiler/dart2js/quarantined/http_launch_data/pkcert/cert9.db
deleted file mode 100644
index 497fca6..0000000
--- a/tests/compiler/dart2js/quarantined/http_launch_data/pkcert/cert9.db
+++ /dev/null
Binary files differ
diff --git a/tests/compiler/dart2js/quarantined/http_launch_data/pkcert/key4.db b/tests/compiler/dart2js/quarantined/http_launch_data/pkcert/key4.db
deleted file mode 100644
index fc06432..0000000
--- a/tests/compiler/dart2js/quarantined/http_launch_data/pkcert/key4.db
+++ /dev/null
Binary files differ
diff --git a/tests/compiler/dart2js/quarantined/http_test.dart b/tests/compiler/dart2js/quarantined/http_test.dart
deleted file mode 100644
index 309fc5f..0000000
--- a/tests/compiler/dart2js/quarantined/http_test.dart
+++ /dev/null
@@ -1,186 +0,0 @@
-// Copyright (c) 2014, 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.
-//
-// Test:
-// *) Compiling a script fetched over HTTP.
-// *) Importing a library fetched over HTTP.
-// *) Automatically resolving package_root when script is fetched over HTTP.
-
-library http_launch_test;
-
-import 'dart:async';
-import 'dart:io';
-import 'package:async_helper/async_helper.dart';
-import 'package:expect/expect.dart';
-import 'package:path/path.dart' as path;
-
-import '../end_to_end/launch_helper.dart' show launchDart2Js;
-
-Uri pathOfData = Platform.script.resolve('http_launch_data/');
-Directory tempDir;
-String outFilePath;
-
-_sendNotFound(HttpResponse response) {
- response.statusCode = HttpStatus.NOT_FOUND;
- response.close();
-}
-
-Future handleRequest(HttpRequest request) {
- final String path = request.uri.path.substring(1);
- final Uri requestPath = pathOfData.resolve(path);
- final File file = new File(requestPath.toFilePath());
- return file.exists().then((bool found) {
- if (found) {
- file.openRead().pipe(request.response).catchError((e) {
- _sendNotFound(request.response);
- });
- } else {
- _sendNotFound(request.response);
- }
- });
-}
-
-void check(ProcessResult result) {
- Expect.equals(0, result.exitCode);
- File outFile = new File(outFilePath);
- Expect.isTrue(outFile.existsSync());
- Expect.isTrue(outFile.readAsStringSync().contains("hello http tester"));
-}
-
-void checkNotFound(ProcessResult result, String filename) {
- Expect.notEquals(0, result.exitCode);
- Expect.isTrue(result.stdout.contains("404"));
- Expect.isTrue(result.stdout.contains(filename));
-}
-
-cleanup() {
- File outFile = new File(outFilePath);
- if (outFile.existsSync()) {
- outFile.deleteSync();
- }
-}
-
-Future testNonHttp() {
- String inFilePath = pathOfData.resolve('http_launch_main.dart').toFilePath();
- List<String> args = [inFilePath, "--out=" + outFilePath];
- return launchDart2Js(args).then(check).then((_) {
- cleanup();
- });
-}
-
-Future testHttpMain(String serverUrl) {
- String inFilePath = '$serverUrl/http_launch_main.dart';
- List<String> args = [inFilePath, "--out=" + outFilePath];
- return launchDart2Js(args).then(check).then((_) {
- cleanup();
- });
-}
-
-Future testHttpLib(String serverUrl) {
- File file = new File(path.join(tempDir.path, "in.dart"));
- file.writeAsStringSync("""
- import '$serverUrl/lib1.dart';
- main() { print(foo()); }
- """);
- String inFilePath = file.path;
- List<String> args = [inFilePath, "--out=" + outFilePath];
- return launchDart2Js(args)
- .then(check)
- .whenComplete(file.deleteSync)
- .then((_) {
- cleanup();
- });
-}
-
-Future testHttpPackage(String serverUrl) {
- String inFilePath =
- pathOfData.resolve('http_launch_main_package.dart').toFilePath();
- String packageRoot = '$serverUrl/packages/';
- List<String> args = [
- inFilePath,
- "--out=" + outFilePath,
- "--package-root=" + packageRoot
- ];
- return launchDart2Js(args).then(check).then((_) {
- cleanup();
- });
-}
-
-Future testBadHttp(String serverUrl) {
- File file = new File(path.join(tempDir.path, "in_bad.dart"));
- file.writeAsStringSync("""
- import '$serverUrl/not_existing.dart';
- main() { print(foo()); }
- """);
- String inFilePath = file.path;
- List<String> args = [inFilePath, "--out=" + outFilePath];
- return launchDart2Js(args)
- .then((pr) => checkNotFound(pr, "not_existing.dart"))
- .whenComplete(file.deleteSync)
- .then((_) {
- cleanup();
- });
-}
-
-Future testBadHttp2(String serverUrl) {
- String inFilePath = '$serverUrl/not_found.dart';
- List<String> args = [inFilePath, "--out=" + outFilePath];
- return launchDart2Js(args)
- .then((processResult) => checkNotFound(processResult, "not_found.dart"))
- .then((_) {
- cleanup();
- });
-}
-
-serverRunning(HttpServer server, String scheme) {
- tempDir = Directory.systemTemp.createTempSync('directory_test');
- outFilePath = path.join(tempDir.path, "out.js");
- int port = server.port;
- String serverUrl = "$scheme://127.0.0.1:$port";
-
- asyncStart();
- server.listen(handleRequest);
- return new Future.value()
- .then((_) => cleanup()) // Make sure we start fresh.
- .then((_) => testNonHttp())
- .then((_) => testHttpMain(serverUrl))
- .then((_) => testHttpLib(serverUrl))
- .then((_) => testHttpPackage(serverUrl))
- .then((_) => testBadHttp(serverUrl))
- .then((_) => testBadHttp2(serverUrl))
- .whenComplete(() => tempDir.delete(recursive: true))
- .whenComplete(server.close)
- .then((_) => asyncEnd());
-}
-
-Future testHttp() {
- return HttpServer
- .bind(InternetAddress.LOOPBACK_IP_V4, 0)
- .then((HttpServer server) => serverRunning(server, "http"));
-}
-
-void initializeSSL() {
- Uri pathOfPkcert = pathOfData.resolve('pkcert');
- String testPkcertDatabase = pathOfPkcert.toFilePath();
- // Issue 29926.
- // ignore: UNDEFINED_METHOD
- SecureSocket.initialize(database: testPkcertDatabase, password: 'dartdart');
-}
-
-Future testHttps() {
- initializeSSL();
- return HttpServer
- // Issue 29926.
- // ignore: NOT_ENOUGH_REQUIRED_ARGUMENTS
- .bindSecure(InternetAddress.LOOPBACK_IP_V4, 0,
- // Issue 29926.
- // ignore: UNDEFINED_NAMED_PARAMETER
- certificateName: 'localhost_cert')
- .then((HttpServer server) => serverRunning(server, "https"));
-}
-
-main() {
- asyncStart();
- testHttp().then((_) => testHttps).whenComplete(asyncEnd);
-}