Remove --analyze-* flags
Change-Id: I72f7834ba754bd5affec1a72d1d7be203031aa42
Reviewed-on: https://dart-review.googlesource.com/64041
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
diff --git a/pkg/compiler/lib/src/commandline_options.dart b/pkg/compiler/lib/src/commandline_options.dart
index 42d6b0c..2dc90ba 100644
--- a/pkg/compiler/lib/src/commandline_options.dart
+++ b/pkg/compiler/lib/src/commandline_options.dart
@@ -8,10 +8,6 @@
class Flags {
static const String allowMockCompilation = '--allow-mock-compilation';
static const String allowNativeExtensions = '--allow-native-extensions';
- static const String analyzeAll = '--analyze-all';
- static const String analyzeMain = '--analyze-main';
- static const String analyzeOnly = '--analyze-only';
- static const String analyzeSignaturesOnly = '--analyze-signatures-only';
static const String disableInlining = '--disable-inlining';
static const String disableProgramSplit = '--disable-program-split';
static const String disableDiagnosticColors = '--disable-diagnostic-colors';
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index e16eb6f..f0ebe13 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -42,7 +42,6 @@
import 'universe/selector.dart' show Selector;
import 'universe/world_builder.dart'
show ResolutionWorldBuilder, CodegenWorldBuilder;
-import 'universe/use.dart' show StaticUse, TypeUse;
import 'universe/world_impact.dart'
show ImpactStrategy, WorldImpact, WorldImpactBuilderImpl;
import 'world.dart' show JClosedWorld, KClosedWorld;
@@ -77,8 +76,6 @@
api.CompilerOutput get outputProvider => _outputProvider;
- List<Uri> librariesToAnalyzeWhenRun;
-
Uri mainLibraryUri;
JClosedWorld backendClosedWorldForTesting;
@@ -206,10 +203,6 @@
return _codegenWorldBuilder;
}
- bool get analyzeAll => options.analyzeAll || compileAll;
-
- bool get compileAll => false;
-
bool get disableTypeInference =>
options.disableTypeInference || compilationFailed;
@@ -270,23 +263,11 @@
.add(selector);
}
- assert(uri != null || options.analyzeOnly);
+ assert(uri != null);
// As far as I can tell, this branch is only used by test code.
- if (librariesToAnalyzeWhenRun != null) {
- await Future.forEach(librariesToAnalyzeWhenRun, (libraryUri) async {
- reporter.log('Analyzing $libraryUri (${options.buildId})');
- LoadedLibraries loadedLibraries =
- await libraryLoader.loadLibrary(libraryUri);
- processLoadedLibraries(loadedLibraries);
- });
- }
LibraryEntity mainApp;
if (uri != null) {
- if (options.analyzeOnly) {
- reporter.log('Analyzing $uri (${options.buildId})');
- } else {
- reporter.log('Compiling $uri (${options.buildId})');
- }
+ reporter.log('Compiling $uri (${options.buildId})');
LoadedLibraries libraries = await libraryLoader.loadLibrary(uri);
// Note: libraries may be null because of errors trying to find files or
// parse-time errors (when using `package:front_end` as a loader).
@@ -330,22 +311,6 @@
phase = PHASE_RESOLVING;
resolutionEnqueuer.applyImpact(mainImpact);
- if (analyzeAll) {
- libraryLoader.libraries.forEach((LibraryEntity library) {
- reporter.log('Enqueuing ${library.canonicalUri}');
- resolutionEnqueuer.applyImpact(computeImpactForLibrary(library));
- });
- } else if (options.analyzeMain) {
- if (rootLibrary != null) {
- resolutionEnqueuer.applyImpact(computeImpactForLibrary(rootLibrary));
- }
- if (librariesToAnalyzeWhenRun != null) {
- for (Uri libraryUri in librariesToAnalyzeWhenRun) {
- resolutionEnqueuer.applyImpact(
- computeImpactForLibrary(libraryLoader.lookupLibrary(libraryUri)));
- }
- }
- }
reporter.log('Resolving...');
processQueue(frontendStrategy.elementEnvironment, resolutionEnqueuer,
@@ -366,7 +331,6 @@
}
}
- if (options.analyzeOnly) return null;
assert(mainFunction != null);
JClosedWorld closedWorld = closeResolution(mainFunction);
@@ -392,11 +356,6 @@
Enqueuer codegenEnqueuer =
startCodegen(closedWorld, globalInferenceResults);
- if (compileAll) {
- libraryLoader.libraries.forEach((LibraryEntity library) {
- codegenEnqueuer.applyImpact(computeImpactForLibrary(library));
- });
- }
processQueue(closedWorld.elementEnvironment, codegenEnqueuer, mainFunction,
libraryLoader.libraries,
onProgress: showCodegenProgress);
@@ -453,25 +412,6 @@
return closedWorldRefiner;
}
- /// Compute the [WorldImpact] for accessing all elements in [library].
- WorldImpact computeImpactForLibrary(LibraryEntity library) {
- WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl();
-
- void registerStaticUse(MemberEntity element) {
- impactBuilder.registerStaticUse(new StaticUse.directUse(element));
- }
-
- ElementEnvironment elementEnvironment = frontendStrategy.elementEnvironment;
-
- elementEnvironment.forEachLibraryMember(library, registerStaticUse);
- elementEnvironment.forEachClass(library, (ClassEntity cls) {
- impactBuilder.registerTypeUse(
- new TypeUse.instantiation(elementEnvironment.getRawType(cls)));
- elementEnvironment.forEachLocalClassMember(cls, registerStaticUse);
- });
- return impactBuilder;
- }
-
/**
* Empty the [enqueuer] queue.
*/
@@ -606,10 +546,6 @@
if (mainLibraryUri != null) {
userCodeLocations.add(new CodeLocation(mainLibraryUri));
}
- if (librariesToAnalyzeWhenRun != null) {
- userCodeLocations.addAll(
- librariesToAnalyzeWhenRun.map((Uri uri) => new CodeLocation(uri)));
- }
if (userCodeLocations.isEmpty && assumeInUserCode) {
// Assume in user code since [mainApp] has not been set yet.
userCodeLocations.add(const AnyLocation());
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart
index e84b39b..0bde91f 100644
--- a/pkg/compiler/lib/src/dart2js.dart
+++ b/pkg/compiler/lib/src/dart2js.dart
@@ -121,7 +121,6 @@
List<String> options = new List<String>();
bool wantHelp = false;
bool wantVersion = false;
- bool analyzeOnly = false;
bool trustTypeAnnotations = false;
bool checkedMode = false;
bool strongMode = true;
@@ -196,11 +195,6 @@
return filenames.join("\n");
}
- void setAnalyzeOnly(String argument) {
- analyzeOnly = true;
- passThrough(argument);
- }
-
void setAllowNativeExtensions(String argument) {
helpAndFail("Option '${Flags.allowNativeExtensions}' is not supported.");
}
@@ -342,13 +336,10 @@
new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true),
new OptionHandler('--packages=.+', setPackageConfig),
new OptionHandler('--package-root=.+|-p.+', setPackageRoot),
- new OptionHandler(Flags.analyzeAll, passThrough),
- new OptionHandler(Flags.analyzeOnly, setAnalyzeOnly),
new OptionHandler(Flags.noSourceMaps, passThrough),
new OptionHandler(Option.resolutionInput, ignoreOption),
new OptionHandler(Option.bazelPaths, setBazelPaths),
new OptionHandler(Flags.resolveOnly, ignoreOption),
- new OptionHandler(Flags.analyzeSignaturesOnly, setAnalyzeOnly),
new OptionHandler(Flags.disableNativeLiveTypeAnalysis, passThrough),
new OptionHandler('--categories=.*', setCategories),
new OptionHandler(Flags.disableInlining, passThrough),
@@ -480,7 +471,6 @@
onInfo: diagnosticHandler.info, onFailure: fail);
api.CompilationResult compilationDone(api.CompilationResult result) {
- if (analyzeOnly) return result;
if (!result.isSuccess) {
fail('Compilation failed.');
}
diff --git a/pkg/compiler/lib/src/enqueue.dart b/pkg/compiler/lib/src/enqueue.dart
index 8a0d580..7e1492e 100644
--- a/pkg/compiler/lib/src/enqueue.dart
+++ b/pkg/compiler/lib/src/enqueue.dart
@@ -501,16 +501,6 @@
}
}
-/// Strategy that only enqueues directly used elements.
-class DirectEnqueuerStrategy extends EnqueuerStrategy {
- const DirectEnqueuerStrategy();
- void processStaticUse(EnqueuerImpl enqueuer, StaticUse staticUse) {
- if (staticUse.kind == StaticUseKind.DIRECT_USE) {
- enqueuer.processStaticUse(staticUse);
- }
- }
-}
-
/// Strategy used for tree-shaking.
class TreeShakingEnqueuerStrategy extends EnqueuerStrategy {
const TreeShakingEnqueuerStrategy();
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index 87f2fc6..116f542 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -18,12 +18,7 @@
import '../elements/entities.dart';
import '../elements/types.dart';
import '../enqueue.dart'
- show
- DirectEnqueuerStrategy,
- Enqueuer,
- EnqueueTask,
- ResolutionEnqueuer,
- TreeShakingEnqueuerStrategy;
+ show Enqueuer, EnqueueTask, ResolutionEnqueuer, TreeShakingEnqueuerStrategy;
import '../frontend_strategy.dart';
import '../io/source_information.dart'
show SourceInformation, SourceInformationStrategy;
@@ -598,9 +593,7 @@
task,
compiler.options,
compiler.reporter,
- compiler.options.analyzeOnly && compiler.options.analyzeMain
- ? const DirectEnqueuerStrategy()
- : const TreeShakingEnqueuerStrategy(),
+ const TreeShakingEnqueuerStrategy(),
new ResolutionEnqueuerListener(
compiler.options,
elementEnvironment,
diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart
index fc870e9..04b3841 100644
--- a/pkg/compiler/lib/src/options.dart
+++ b/pkg/compiler/lib/src/options.dart
@@ -70,26 +70,6 @@
/// dart:html for unit testing purposes.
bool allowMockCompilation = false;
- /// Whether to resolve all functions in the program, not just those reachable
- /// from main. This implies [analyzeOnly] is true as well.
- bool analyzeAll = false;
-
- /// Whether to disable tree-shaking for the main script. This marks all
- /// functions in the main script as reachable (not just a function named
- /// `main`).
- // TODO(sigmund): rename. The current name seems to indicate that only the
- // main function is retained, which is the opposite of what this does.
- bool analyzeMain = false;
-
- /// Whether to run the compiler just for the purpose of analysis. That is, to
- /// run resolution and type-checking alone, but otherwise do not generate any
- /// code.
- bool analyzeOnly = false;
-
- /// Whether to skip analysis of method bodies and field initializers. Implies
- /// [analyzeOnly].
- bool analyzeSignaturesOnly = false;
-
/// Sets a combination of flags for benchmarking 'production' mode.
bool benchmarkingProduction = false;
@@ -282,10 +262,6 @@
return new CompilerOptions()
..libraryRoot = libraryRoot
..allowMockCompilation = _hasOption(options, Flags.allowMockCompilation)
- ..analyzeAll = _hasOption(options, Flags.analyzeAll)
- ..analyzeMain = _hasOption(options, Flags.analyzeMain)
- ..analyzeOnly = _hasOption(options, Flags.analyzeOnly)
- ..analyzeSignaturesOnly = _hasOption(options, Flags.analyzeSignaturesOnly)
..benchmarkingProduction =
_hasOption(options, Flags.benchmarkingProduction)
..buildId =
@@ -370,7 +346,6 @@
}
void deriveOptions() {
- if (analyzeSignaturesOnly || analyzeAll) analyzeOnly = true;
if (benchmarkingProduction) {
useStartupEmitter = true;
trustPrimitives = true;
diff --git a/pkg/compiler/lib/src/universe/codegen_world_builder.dart b/pkg/compiler/lib/src/universe/codegen_world_builder.dart
index 8c448bd..cc99a9d 100644
--- a/pkg/compiler/lib/src/universe/codegen_world_builder.dart
+++ b/pkg/compiler/lib/src/universe/codegen_world_builder.dart
@@ -369,7 +369,6 @@
break;
case StaticUseKind.SUPER_FIELD_SET:
case StaticUseKind.FIELD_SET:
- case StaticUseKind.DIRECT_USE:
case StaticUseKind.CLOSURE:
case StaticUseKind.CLOSURE_CALL:
case StaticUseKind.CALL_METHOD:
@@ -426,7 +425,6 @@
case StaticUseKind.SET:
case StaticUseKind.INIT:
case StaticUseKind.REFLECT:
- case StaticUseKind.DIRECT_USE:
useSet.addAll(usage.normalUse());
break;
case StaticUseKind.CONSTRUCTOR_INVOKE:
diff --git a/pkg/compiler/lib/src/universe/resolution_world_builder.dart b/pkg/compiler/lib/src/universe/resolution_world_builder.dart
index d3f30e2..75cbb01 100644
--- a/pkg/compiler/lib/src/universe/resolution_world_builder.dart
+++ b/pkg/compiler/lib/src/universe/resolution_world_builder.dart
@@ -721,7 +721,6 @@
case StaticUseKind.SET:
useSet.addAll(usage.write());
break;
- case StaticUseKind.DIRECT_USE:
case StaticUseKind.REFLECT:
useSet.addAll(usage.fullyUse());
break;
diff --git a/pkg/compiler/lib/src/universe/use.dart b/pkg/compiler/lib/src/universe/use.dart
index 5cfeed7..9972e88 100644
--- a/pkg/compiler/lib/src/universe/use.dart
+++ b/pkg/compiler/lib/src/universe/use.dart
@@ -141,7 +141,6 @@
CONST_CONSTRUCTOR_INVOKE,
REDIRECTION,
DIRECT_INVOKE,
- DIRECT_USE,
INLINING,
INVOKE,
GET,
@@ -517,11 +516,6 @@
return new StaticUse.internal(element, StaticUseKind.INVOKE);
}
- /// Direct use of [element] as done with `--analyze-all` and `--analyze-main`.
- factory StaticUse.directUse(MemberEntity element) {
- return new StaticUse.internal(element, StaticUseKind.DIRECT_USE);
- }
-
/// Inlining of [element].
factory StaticUse.constructorInlining(
ConstructorEntity element, InterfaceType instanceType) {
diff --git a/tests/compiler/dart2js/all_native_test.dart b/tests/compiler/dart2js/all_native_test.dart
index 9550f03..ae40236 100644
--- a/tests/compiler/dart2js/all_native_test.dart
+++ b/tests/compiler/dart2js/all_native_test.dart
@@ -16,15 +16,24 @@
test(List<String> options) async {
DiagnosticCollector collector = new DiagnosticCollector();
+ String fileName = 'sdk/tests/compiler/dart2js_native/main.dart';
+ Uri entryPoint = Uri.parse('memory:$fileName');
await runCompiler(
+ entryPoint: entryPoint,
memorySourceFiles: {
- 'main.dart': '''
+ fileName: '''
import 'dart:html';
- main() => document;
+ import 'dart:_js_helper';
+
+ method(o) native;
+
+ main() {
+ method(document);
+ }
'''
},
diagnosticHandler: collector,
- options: [Flags.analyzeAll, Flags.verbose]..addAll(options));
+ options: [Flags.verbose]..addAll(options));
int allNativeUsedCount =
collector.verboseInfos.where((CollectedMessage message) {
return message.text.startsWith('All native types marked as used due to ');
diff --git a/tests/compiler/dart2js/compiler_helper.dart b/tests/compiler/dart2js/compiler_helper.dart
index df85ea4..5415410 100644
--- a/tests/compiler/dart2js/compiler_helper.dart
+++ b/tests/compiler/dart2js/compiler_helper.dart
@@ -43,7 +43,6 @@
String methodName,
bool enableTypeAssertions: false,
bool minify: false,
- bool analyzeAll: false,
bool disableInlining: true,
bool trustJSInteropTypeAnnotations: false,
void check(String generatedEntry),
@@ -60,9 +59,6 @@
if (minify) {
options.add(Flags.minify);
}
- if (analyzeAll) {
- options.add(Flags.analyzeAll);
- }
if (trustJSInteropTypeAnnotations) {
options.add(Flags.trustJSInteropTypeAnnotations);
}
diff --git a/tests/compiler/dart2js/dart2js.status b/tests/compiler/dart2js/dart2js.status
index a79f3a6..2519623 100644
--- a/tests/compiler/dart2js/dart2js.status
+++ b/tests/compiler/dart2js/dart2js.status
@@ -18,7 +18,6 @@
equivalence/id_equivalence1_test: Pass, Slow
equivalence/id_equivalence2_test: Pass, Slow
generate_code_with_compile_time_errors_test: RuntimeError # not supported yet with the new FE.
-in_user_code_test: RuntimeError # analyze-only with CFE is not complete (Issues 32512, 32513)
inference/inference0_test: Slow, Pass
inference/inference1_test: Slow, Pass
inference/simple_inferrer_const_closure2_test: Fail # Issue 16507
diff --git a/tests/compiler/dart2js/generic_methods/function_type_variable_test.dart b/tests/compiler/dart2js/generic_methods/function_type_variable_test.dart
index 20bf4c6..4d29bc9 100644
--- a/tests/compiler/dart2js/generic_methods/function_type_variable_test.dart
+++ b/tests/compiler/dart2js/generic_methods/function_type_variable_test.dart
@@ -39,7 +39,21 @@
}
void F11<Q extends C3<Q>>(Q q) {}
void F12<P extends C3<P>>(P p) {}
- """),
+
+ main() {
+ ${createUses(existentialTypeData)}
+
+ new C1();
+ new C2();
+ new C3.fact();
+ new C4();
+
+ F9(null, null);
+ F10();
+ F11(null);
+ F12(null);
+ }
+ """),
options: [Flags.strongMode]);
testToString(FunctionType type, String expectedToString) {
diff --git a/tests/compiler/dart2js/generic_methods/generic_method_type_test.dart b/tests/compiler/dart2js/generic_methods/generic_method_type_test.dart
index 3d90b38..ae12d71 100644
--- a/tests/compiler/dart2js/generic_methods/generic_method_type_test.dart
+++ b/tests/compiler/dart2js/generic_methods/generic_method_type_test.dart
@@ -25,6 +25,11 @@
TypeEnvironment env = await TypeEnvironment.create("""
${createTypedefs(signatures, prefix: 't')}
${createMethods(signatures, prefix: 'm')}
+
+ main() {
+ ${createUses(signatures, prefix: 't')}
+ ${createUses(signatures, prefix: 'm')}
+ }
""", options: [Flags.strongMode]);
for (FunctionTypeData data in signatures) {
diff --git a/tests/compiler/dart2js/in_user_code_test.dart b/tests/compiler/dart2js/in_user_code_test.dart
index bc75652..82c080f 100644
--- a/tests/compiler/dart2js/in_user_code_test.dart
+++ b/tests/compiler/dart2js/in_user_code_test.dart
@@ -7,7 +7,6 @@
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' show Compiler;
import 'memory_compiler.dart';
@@ -31,6 +30,8 @@
import 'package:sup/boz.dart';
import 'baz.dart';
+
+main() {}
""",
'pkg/sub/baz.dart': """
library sub.baz;
@@ -44,12 +45,11 @@
"""
};
-Future test(List<Uri> entryPoints, Map<String, bool> expectedResults) async {
- print("Test: $entryPoints");
+Future test(Uri entryPoint, Map<String, bool> expectedResults) async {
+ print("Test: $entryPoint");
CompilationResult result = await runCompiler(
- entryPoints: entryPoints,
+ entryPoint: entryPoint,
memorySourceFiles: SOURCE,
- options: [Flags.analyzeOnly, Flags.analyzeAll],
packageConfig: Uri.parse('memory:.packages'));
Compiler compiler = result.compiler;
expectedResults.forEach((String uri, bool expectedResult) {
@@ -69,9 +69,7 @@
}
Future runTests() async {
- await test([
- Uri.parse('memory:main.dart')
- ], {
+ await test(Uri.parse('memory:main.dart'), {
'memory:main.dart': true,
'memory:foo.dart': true,
'memory:pkg/sub/bar.dart': true,
@@ -82,35 +80,10 @@
'dart:core': false,
'dart:async': false
});
- // TODO(sigmund): compiler with CFE doesn't work when given sdk libraries as
- // entrypoints (Issue XYZ).
- //await test(
- // [Uri.parse('dart:async')], {'dart:core': true, 'dart:async': true});
- await test([
- Uri.parse('package:sub/bar.dart')
- ], {
+ await test(Uri.parse('package:sub/bar.dart'), {
'package:sub/bar.dart': true,
'package:sub/baz.dart': true,
'package:sup/boz.dart': false,
'dart:core': false
});
- await test([
- Uri.parse('package:sub/bar.dart'),
- Uri.parse('package:sup/boz.dart')
- ], {
- 'package:sub/bar.dart': true,
- 'package:sub/baz.dart': true,
- 'package:sup/boz.dart': true,
- 'dart:core': false
- });
- //await test([
- // Uri.parse('dart:async'),
- // Uri.parse('package:sub/bar.dart')
- //], {
- // 'package:sub/bar.dart': true,
- // 'package:sub/baz.dart': true,
- // 'package:sup/boz.dart': false,
- // 'dart:core': true,
- // 'dart:async': true
- //});
}
diff --git a/tests/compiler/dart2js/inference/type_mask2_test.dart b/tests/compiler/dart2js/inference/type_mask2_test.dart
index 904a4c4..4ceb18b 100644
--- a/tests/compiler/dart2js/inference/type_mask2_test.dart
+++ b/tests/compiler/dart2js/inference/type_mask2_test.dart
@@ -97,7 +97,7 @@
class C extends A {}
class D implements A {}
class E extends B implements A {}
- """, mainSource: r"""
+
main() {
new A();
new B();
@@ -209,13 +209,11 @@
}
Future testStringSubtypes() async {
- TypeEnvironment env = await TypeEnvironment.create('',
- mainSource: r"""
+ TypeEnvironment env = await TypeEnvironment.create(r"""
main() {
'' is String;
}
- """,
- testBackendWorld: true);
+ """, testBackendWorld: true);
JClosedWorld closedWorld = env.jClosedWorld;
ClassEntity Object_ = env.getElement("Object");
diff --git a/tests/compiler/dart2js/inference/union_type_test.dart b/tests/compiler/dart2js/inference/union_type_test.dart
index a34dceb..bec8ae3 100644
--- a/tests/compiler/dart2js/inference/union_type_test.dart
+++ b/tests/compiler/dart2js/inference/union_type_test.dart
@@ -13,7 +13,7 @@
TypeEnvironment env = await TypeEnvironment.create(r"""
class A {}
class B {}
- """, mainSource: r"""
+
main() {
new A();
new B();
diff --git a/tests/compiler/dart2js/instantiated_classes_test.dart b/tests/compiler/dart2js/instantiated_classes_test.dart
index b51bee2..4289d6f 100644
--- a/tests/compiler/dart2js/instantiated_classes_test.dart
+++ b/tests/compiler/dart2js/instantiated_classes_test.dart
@@ -16,13 +16,13 @@
Future test(String source, List<String> directlyInstantiatedClasses,
[List<String> newClasses = const <String>["Class"]]) async {
StringBuffer mainSource = new StringBuffer();
+ mainSource.writeln(source);
mainSource.write('main() {\n');
for (String newClass in newClasses) {
mainSource.write(' new $newClass();\n');
}
mainSource.write('}');
- dynamic env = await TypeEnvironment.create(source,
- mainSource: mainSource.toString());
+ dynamic env = await TypeEnvironment.create(mainSource.toString());
LibraryEntity mainLibrary =
env.compiler.frontendStrategy.elementEnvironment.mainLibrary;
Iterable<ClassEntity> expectedClasses =
diff --git a/tests/compiler/dart2js/memory_compiler.dart b/tests/compiler/dart2js/memory_compiler.dart
index 6564b2b..70b8757 100644
--- a/tests/compiler/dart2js/memory_compiler.dart
+++ b/tests/compiler/dart2js/memory_compiler.dart
@@ -83,7 +83,6 @@
Future<CompilationResult> runCompiler(
{Map<String, dynamic> memorySourceFiles: const <String, dynamic>{},
Uri entryPoint,
- List<Uri> entryPoints,
CompilerDiagnostics diagnosticHandler,
CompilerOutput outputProvider,
List<String> options: const <String>[],
@@ -107,7 +106,6 @@
packageRoot: packageRoot,
packageConfig: packageConfig,
packagesDiscoveryProvider: packagesDiscoveryProvider);
- compiler.librariesToAnalyzeWhenRun = entryPoints;
if (beforeRun != null) {
beforeRun(compiler);
}
diff --git a/tests/compiler/dart2js/model/class_set_test.dart b/tests/compiler/dart2js/model/class_set_test.dart
index 70b8807..da0633f 100644
--- a/tests/compiler/dart2js/model/class_set_test.dart
+++ b/tests/compiler/dart2js/model/class_set_test.dart
@@ -46,7 +46,7 @@
class E extends C {}
class F extends C {}
class G extends C {}
- """, mainSource: r"""
+
main() {
new A();
new C();
@@ -374,7 +374,7 @@
class H extends F {}
class I extends F {}
class X {}
- """, mainSource: r"""
+
main() {
new A();
new C();
@@ -593,8 +593,7 @@
class A {
call() => null;
}
- """,
- mainSource: r"""
+
main() {
new A();
() {};
diff --git a/tests/compiler/dart2js/model/constant_value_test.dart b/tests/compiler/dart2js/model/constant_value_test.dart
index 05d5194..5f5fa16 100644
--- a/tests/compiler/dart2js/model/constant_value_test.dart
+++ b/tests/compiler/dart2js/model/constant_value_test.dart
@@ -16,14 +16,16 @@
enableDebugMode();
asyncTest(() async {
- TypeEnvironment env = await TypeEnvironment.create('''
+ TypeEnvironment env = await TypeEnvironment.create("""
class C {
final field1;
final field2;
C(this.field1, this.field2);
}
- ''');
+
+ main() => new C(null, null);
+ """);
ClassEntity C = env.getClass('C');
InterfaceType C_raw = env.elementEnvironment.getRawType(C);
FieldEntity field1 = env.elementEnvironment.lookupClassMember(C, 'field1');
diff --git a/tests/compiler/dart2js/model/future_or_test.dart b/tests/compiler/dart2js/model/future_or_test.dart
index 4da2f32..bdee3aa 100644
--- a/tests/compiler/dart2js/model/future_or_test.dart
+++ b/tests/compiler/dart2js/model/future_or_test.dart
@@ -11,7 +11,9 @@
main() {
asyncTest(() async {
- var env = await TypeEnvironment.create('''
+ var env = await TypeEnvironment.create("""
+import 'dart:async';
+
Future<num> futureNum() async => null;
FutureOr<num> futureOrNum() async => null;
@@ -33,7 +35,22 @@
Future<T> futureT() async => null;
FutureOr<T> futureOrT() async => null;
}
-''', options: [Flags.strongMode]);
+
+main() {
+ futureNum();
+ futureOrNum();
+ futureInt();
+ futureOrInt();
+ futureListNum();
+ futureOrListNum();
+ futureFutureNum();
+ futureOrFutureOrNum();
+ futureNull();
+ futureOrNull();
+ new C().futureT();
+ new C().futureOrT();
+}
+""", options: [Flags.strongMode]);
FunctionType getFunctionType(String name, String expectedType,
[ClassEntity cls]) {
FunctionType type = env.getMemberType(name, cls);
diff --git a/tests/compiler/dart2js/model/mixin_typevariable_test.dart b/tests/compiler/dart2js/model/mixin_typevariable_test.dart
index ff9a9ec..5cfca15 100644
--- a/tests/compiler/dart2js/model/mixin_typevariable_test.dart
+++ b/tests/compiler/dart2js/model/mixin_typevariable_test.dart
@@ -26,6 +26,11 @@
class C1<C1_T> extends S<C1_T> with M1<C1_T>, M2<C1_T>, M3<C1_T> {}
class C2<C2_T> = S<C2_T> with M1<C2_T>, M2<C2_T>, M3<C2_T>;
+
+ main() {
+ new C1();
+ new C2();
+ }
""", expectNoWarningsOrErrors: true);
ClassEntity Object = env.getElement('Object');
ClassEntity S = env.getClass('S');
@@ -89,6 +94,17 @@
class F1<F1_T> extends A<_> with B<_, B<F1_T, _>> {}
class F2<F2_T> = A<_> with B<_, B<F2_T, _>>;
+
+ main() {
+ new C1();
+ new C2();
+ new D1();
+ new D2();
+ new E1();
+ new E2();
+ new F1();
+ new F2();
+ }
""", expectNoWarningsOrErrors: true);
DartType _dynamic = env['dynamic'];
DartType _ = env['_'];
diff --git a/tests/compiler/dart2js/model/subtype_test.dart b/tests/compiler/dart2js/model/subtype_test.dart
index 3b99cb7..2a98af7 100644
--- a/tests/compiler/dart2js/model/subtype_test.dart
+++ b/tests/compiler/dart2js/model/subtype_test.dart
@@ -59,6 +59,10 @@
// TODO(johnniwinther): Inheritance with different type arguments is
// currently not supported by the implementation.
class C<T1, T2> extends B<T2, T1> /*implements A<A<T1>>*/ {}
+
+ main() {
+ new C();
+ }
""", options: strongMode ? [Flags.strongMode] : [Flags.noPreviewDart2])
.then((env) {
void expect(bool expectSubtype, DartType T, DartType S,
@@ -312,6 +316,17 @@
int m4(V v, U u) => null;
void m5(V v, int i) => null;
}
+
+ main() {
+ new W();
+ var a = new A();
+ a.call(null, null);
+ a.m1(null, null);
+ a.m2(null, null);
+ a.m3(null, null);
+ a.m4(null, null);
+ a.m5(null, null);
+ }
""", options: strongMode ? [Flags.strongMode] : [Flags.noPreviewDart2])
.then((env) {
void expect(bool expectSubtype, DartType T, DartType S,
@@ -361,13 +376,23 @@
];
Future testFunctionSubtyping({bool strongMode}) async {
- await TypeEnvironment.create(createMethods(functionTypesData),
+ await TypeEnvironment.create(
+ createMethods(functionTypesData, additionalData: """
+ main() {
+ ${createUses(functionTypesData)}
+ }
+ """),
options: strongMode ? [Flags.strongMode] : [Flags.noPreviewDart2])
.then(functionSubtypingHelper);
}
Future testTypedefSubtyping({bool strongMode}) async {
- await TypeEnvironment.create(createTypedefs(functionTypesData),
+ await TypeEnvironment.create(
+ createTypedefs(functionTypesData, additionalData: """
+ main() {
+ ${createUses(functionTypesData)}
+ }
+ """),
options: strongMode ? [Flags.strongMode] : [Flags.noPreviewDart2])
.then(functionSubtypingHelper);
}
@@ -445,13 +470,23 @@
];
Future testFunctionSubtypingOptional({bool strongMode}) async {
- await TypeEnvironment.create(createMethods(optionalFunctionTypesData),
+ await TypeEnvironment.create(
+ createMethods(optionalFunctionTypesData, additionalData: """
+ main() {
+ ${createUses(optionalFunctionTypesData)}
+ }
+ """),
options: strongMode ? [Flags.strongMode] : [Flags.noPreviewDart2])
.then((env) => functionSubtypingOptionalHelper(env, strongMode));
}
Future testTypedefSubtypingOptional({bool strongMode}) async {
- await TypeEnvironment.create(createTypedefs(optionalFunctionTypesData),
+ await TypeEnvironment.create(
+ createTypedefs(optionalFunctionTypesData, additionalData: """
+ main() {
+ ${createUses(optionalFunctionTypesData)}
+ }
+ """),
options: strongMode ? [Flags.strongMode] : [Flags.noPreviewDart2])
.then((env) => functionSubtypingOptionalHelper(env, strongMode));
}
@@ -517,13 +552,23 @@
];
Future testFunctionSubtypingNamed({bool strongMode}) async {
- await TypeEnvironment.create(createMethods(namedFunctionTypesData),
+ await TypeEnvironment.create(
+ createMethods(namedFunctionTypesData, additionalData: """
+ main() {
+ ${createUses(namedFunctionTypesData)}
+ }
+ """),
options: strongMode ? [Flags.strongMode] : [Flags.noPreviewDart2])
.then((env) => functionSubtypingNamedHelper(env, strongMode));
}
Future testTypedefSubtypingNamed({bool strongMode}) async {
- await TypeEnvironment.create(createTypedefs(namedFunctionTypesData),
+ await TypeEnvironment.create(
+ createTypedefs(namedFunctionTypesData, additionalData: """
+ main() {
+ ${createUses(namedFunctionTypesData)}
+ }
+ """),
options: strongMode ? [Flags.strongMode] : [Flags.noPreviewDart2])
.then((env) => functionSubtypingNamedHelper(env, strongMode));
}
@@ -576,6 +621,19 @@
class H<T extends S, S extends T> {}
class I<T extends S, S extends U, U extends T> {}
class J<T extends S, S extends U, U extends S> {}
+
+ main() {
+ new A();
+ new B();
+ new C();
+ new D();
+ new E<num, int>();
+ new F();
+ new G();
+ new H();
+ new I();
+ new J();
+ }
""", options: strongMode ? [Flags.strongMode] : [Flags.noPreviewDart2])
.then((env) {
void expect(bool expectSubtype, DartType T, DartType S,
@@ -801,6 +859,19 @@
takeInt(int o) => null;
takeVoid(void o) => null;
takeObject(Object o) => null;
+
+ main() {
+ new ClassWithCall().call;
+ returnNum();
+ returnInt();
+ returnVoid();
+ returnObject();
+
+ takeNum(null);
+ takeInt(null);
+ takeVoid(null);
+ takeObject(null);
+ }
""", options: strongMode ? [Flags.strongMode] : [Flags.noPreviewDart2])
.then((env) {
void expect(bool expectSubtype, DartType T, DartType S) {
diff --git a/tests/compiler/dart2js/model/subtypeset_test.dart b/tests/compiler/dart2js/model/subtypeset_test.dart
index fac2f27..6b338b0 100644
--- a/tests/compiler/dart2js/model/subtypeset_test.dart
+++ b/tests/compiler/dart2js/model/subtypeset_test.dart
@@ -42,7 +42,7 @@
class G extends C {}
abstract class H implements C {}
abstract class I implements H {}
- """, mainSource: r"""
+
main() {
new A().call;
new C();
diff --git a/tests/compiler/dart2js/model/type_substitution_test.dart b/tests/compiler/dart2js/model/type_substitution_test.dart
index 2844a00..6aec923 100644
--- a/tests/compiler/dart2js/model/type_substitution_test.dart
+++ b/tests/compiler/dart2js/model/type_substitution_test.dart
@@ -2,8 +2,6 @@
// 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.
-// TODO(johnniwinther): Port this test to be frontend agnostic.
-
library type_substitution_test;
import 'package:expect/expect.dart';
@@ -50,7 +48,7 @@
class D<T> extends A<int> {}
class E<T> extends A<A<T>> {}
class F<T, U> extends B<F<T, String>> implements A<F<B<U>, int>> {}
- ''', mainSource: '''
+
main() {
new A();
new B();
@@ -118,6 +116,8 @@
testTypeSubstitution() async {
var env = await TypeEnvironment.create(r"""
class Class<T,S> {}
+
+ main() => new Class();
""");
InterfaceType Class_T_S = env["Class"];
Expect.isNotNull(Class_T_S);
diff --git a/tests/compiler/dart2js/model/world_test.dart b/tests/compiler/dart2js/model/world_test.dart
index e4599ef..a4b49ce 100644
--- a/tests/compiler/dart2js/model/world_test.dart
+++ b/tests/compiler/dart2js/model/world_test.dart
@@ -30,6 +30,8 @@
testClassSets() async {
var env = await TypeEnvironment.create(r"""
+ import 'dart:html' as html;
+
class A implements X {}
class B {}
class C_Super extends A {}
@@ -39,8 +41,7 @@
class F extends Object with A implements B {}
class G extends Object with B, A {}
class X {}
- """, mainSource: r"""
- import 'dart:html' as html;
+
main() {
new A();
new B();
@@ -232,7 +233,7 @@
class H2 extends H1 {}
class H3 extends H2 implements H {}
class H4 extends H2 with H {}
- """, mainSource: r"""
+
main() {
new B();
new C1();
@@ -315,8 +316,7 @@
}
testNativeClasses() async {
- var env = await TypeEnvironment.create('',
- mainSource: r"""
+ var env = await TypeEnvironment.create(r"""
import 'dart:html' as html;
main() {
html.window; // Creates 'Window'.
@@ -324,8 +324,7 @@
new html.CanvasElement() // Creates CanvasElement
..getContext(''); // Creates CanvasRenderingContext2D
}
- """,
- testBackendWorld: true);
+ """, testBackendWorld: true);
JClosedWorld closedWorld = env.jClosedWorld;
ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
LibraryEntity dart_html = elementEnvironment.lookupLibrary(Uris.dart_html);
@@ -530,8 +529,7 @@
}
testCommonSubclasses() async {
- var env = await TypeEnvironment.create('',
- mainSource: r"""
+ var env = await TypeEnvironment.create(r"""
class A {}
class B {}
class C extends A {}
@@ -554,8 +552,7 @@
new I();
new J();
}
- """,
- testBackendWorld: true);
+ """, testBackendWorld: true);
JClosedWorld closedWorld = env.jClosedWorld;
ClassEntity A = env.getElement("A");
diff --git a/tests/compiler/dart2js/needs_no_such_method_test.dart b/tests/compiler/dart2js/needs_no_such_method_test.dart
index db958ac..58babc1 100644
--- a/tests/compiler/dart2js/needs_no_such_method_test.dart
+++ b/tests/compiler/dart2js/needs_no_such_method_test.dart
@@ -41,6 +41,7 @@
Future run(List<String> instantiated) async {
StringBuffer main = new StringBuffer();
+ main.writeln(CLASSES);
main.write('main() {');
for (String cls in instantiated) {
main.write('new $cls();');
@@ -48,10 +49,8 @@
main.write('}');
testMode = '$instantiated';
- var env = await TypeEnvironment.create(CLASSES,
- mainSource: main.toString(),
- testBackendWorld: true,
- options: [Flags.noPreviewDart2]);
+ var env = await TypeEnvironment.create(main.toString(),
+ testBackendWorld: true, options: [Flags.noPreviewDart2]);
foo = new Selector.call(const PublicName('foo'), CallStructure.NO_ARGS);
bar = new Selector.call(const PublicName('bar'), CallStructure.NO_ARGS);
baz = new Selector.call(const PublicName('baz'), CallStructure.NO_ARGS);
diff --git a/tests/compiler/dart2js/receiver_type_test.dart b/tests/compiler/dart2js/receiver_type_test.dart
index c158073..d8ad1ac 100644
--- a/tests/compiler/dart2js/receiver_type_test.dart
+++ b/tests/compiler/dart2js/receiver_type_test.dart
@@ -28,7 +28,7 @@
class C extends B {
call() {}
}
- """, mainSource: """
+
main() {
(new A())();
new B();
diff --git a/tests/compiler/dart2js/show_package_warnings_test.dart b/tests/compiler/dart2js/show_package_warnings_test.dart
index 5182eef..284d6ae 100644
--- a/tests/compiler/dart2js/show_package_warnings_test.dart
+++ b/tests/compiler/dart2js/show_package_warnings_test.dart
@@ -78,7 +78,7 @@
int warnings: 0,
int hints: 0,
int infos: 0}) async {
- var options = [Flags.analyzeOnly];
+ List<String> options = <String>[];
if (showPackageWarnings != null) {
if (showPackageWarnings.isEmpty) {
options.add(Flags.showPackageWarnings);
diff --git a/tests/compiler/dart2js/type_test_helper.dart b/tests/compiler/dart2js/type_test_helper.dart
index 1aed7af..b5f162a 100644
--- a/tests/compiler/dart2js/type_test_helper.dart
+++ b/tests/compiler/dart2js/type_test_helper.dart
@@ -27,41 +27,22 @@
static Future<TypeEnvironment> create(String source,
{bool expectNoErrors: false,
bool expectNoWarningsOrErrors: false,
- bool stopAfterTypeInference: false,
- String mainSource,
bool testBackendWorld: false,
List<String> options: const <String>[],
Map<String, String> fieldTypeMap: const <String, String>{}}) async {
Uri uri;
Compiler compiler;
- if (mainSource != null) {
- stopAfterTypeInference = true;
- }
- if (testBackendWorld) {
- stopAfterTypeInference = true;
- assert(mainSource != null);
- }
- if (mainSource == null) {
- source = '''import 'dart:async';
- main() {}
- $source''';
- } else {
- source = '$mainSource\n$source';
- }
memory.DiagnosticCollector collector;
collector = new memory.DiagnosticCollector();
uri = Uri.parse('memory:main.dart');
memory.CompilationResult result = await memory.runCompiler(
entryPoint: uri,
memorySourceFiles: {'main.dart': source},
- options: stopAfterTypeInference
- ? ([Flags.disableTypeInference]..addAll(options))
- : ([Flags.disableTypeInference, Flags.analyzeAll, Flags.analyzeOnly]
- ..addAll(options)),
+ options: [Flags.disableTypeInference]..addAll(options),
diagnosticHandler: collector,
beforeRun: (compiler) {
ImpactCacheDeleter.retainCachesForTesting = true;
- compiler.stopAfterTypeInference = stopAfterTypeInference;
+ compiler.stopAfterTypeInference = true;
});
compiler = result.compiler;
if (expectNoErrors || expectNoWarningsOrErrors) {