mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:51:18 +00:00
Add more flags, fix missing initialization of a couple flags
BUG= R=vsm@google.com Review URL: https://chromereviews.googleplex.com/150577015
This commit is contained in:
parent
0ddedfb3da
commit
c1f84cfada
|
@ -49,13 +49,18 @@ final ArgParser argParser = new ArgParser()
|
|||
'the list of directories where to look for packages.', defaultsTo: '')
|
||||
..addFlag('sdk-check',
|
||||
abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false)
|
||||
..addFlag('infer-statics-from-others',
|
||||
..addFlag('infer-from-overrides',
|
||||
help: 'Infer unspecified types of fields and return types from '
|
||||
'definitions in supertypes', defaultsTo: true)
|
||||
..addFlag('infer-transitively',
|
||||
help: 'Infer consts/fields from definitions in other libraries',
|
||||
defaultsTo: false)
|
||||
..addFlag('ignore-inference-order',
|
||||
help: 'Allow a non-stable order of inferencing types for consts and '
|
||||
'fields. (experimental, used to test for possible inference with a '
|
||||
'proper implementation in the future)', defaultsTo: false);
|
||||
..addFlag('infer-only-finals',
|
||||
help: 'Do not infer non-const or non-final fields', defaultsTo: false)
|
||||
..addFlag('infer-eagerly',
|
||||
help: 'experimental: allows a non-stable order of transitive inference on'
|
||||
' consts and fields. This is used to test for possible inference with a '
|
||||
'proper implementation in the future.', defaultsTo: false);
|
||||
|
||||
void _showUsageAndExit() {
|
||||
print('usage: dartdevc [<options>] <file.dart>\n');
|
||||
|
@ -106,7 +111,11 @@ void main(List<String> argv) {
|
|||
useColors: useColors,
|
||||
useMultiPackage: args['use-multi-package'],
|
||||
packageRoot: args['package-root'],
|
||||
packagePaths: args['package-paths'].split(','));
|
||||
packagePaths: args['package-paths'].split(','),
|
||||
inferFromOverrides: args['infer-from-overrides'],
|
||||
inferStaticsFromIdentifiers: args['infer-transitively'],
|
||||
inferInNonStableOrder: args['infer-eagerly'],
|
||||
onlyInferConstsAndFinalFields: args['infer-only-finals']);
|
||||
|
||||
var typeResolver = shouldMockSdk
|
||||
? new TypeResolver.fromMock(mockSdkSources, options)
|
||||
|
|
|
@ -244,6 +244,11 @@ class RestrictedStaticTypeAnalyzer extends StaticTypeAnalyzer {
|
|||
// we rule out cases that could depend on the order in which we process
|
||||
// them.
|
||||
if (element is! LocalVariableElement) {
|
||||
if (_options.onlyInferConstsAndFinalFields &&
|
||||
!element.isConst &&
|
||||
!element.isFinal) {
|
||||
return;
|
||||
}
|
||||
// Only infer types if the library is not in a cycle. Otherwise we can't
|
||||
// guarantee that we are order independent (we can't guarantee that we'll
|
||||
// visit all top-level declarations in all libraries, before we visit
|
||||
|
|
|
@ -42,10 +42,15 @@ class ResolverOptions {
|
|||
/// ordering concerns.
|
||||
final bool inferInNonStableOrder;
|
||||
|
||||
/// Restrict inference of fields and top-levels to those that are final and
|
||||
/// const.
|
||||
final bool onlyInferConstsAndFinalFields;
|
||||
|
||||
ResolverOptions({this.useMultiPackage: false, this.packageRoot: 'packages/',
|
||||
this.packagePaths: const [], this.inferFromOverrides: true,
|
||||
this.inferStaticsFromIdentifiers: false,
|
||||
this.inferInNonStableOrder: false});
|
||||
this.inferInNonStableOrder: false,
|
||||
this.onlyInferConstsAndFinalFields: false});
|
||||
}
|
||||
|
||||
/// Options used by ddc's RestrictedRules.
|
||||
|
@ -123,6 +128,11 @@ class CompilerOptions implements RulesOptions, ResolverOptions {
|
|||
@override
|
||||
final bool inferInNonStableOrder;
|
||||
|
||||
/// Restrict inference of fields and top-levels to those that are final and
|
||||
/// const.
|
||||
@override
|
||||
final bool onlyInferConstsAndFinalFields;
|
||||
|
||||
CompilerOptions({this.checkSdk: false, this.dumpInfo: false,
|
||||
this.dumpInfoFile, this.dumpSrcDir, this.forceCompile: false,
|
||||
this.formatOutput: false, this.outputDir, this.outputDart: false,
|
||||
|
@ -130,5 +140,6 @@ class CompilerOptions implements RulesOptions, ResolverOptions {
|
|||
this.relaxedCasts: true, this.useMultiPackage: false,
|
||||
this.packageRoot: 'packages/', this.packagePaths: const [],
|
||||
this.inferFromOverrides: true, this.inferStaticsFromIdentifiers: false,
|
||||
this.inferInNonStableOrder: false});
|
||||
this.inferInNonStableOrder: false,
|
||||
this.onlyInferConstsAndFinalFields: false});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue