Skip to content

Commit 122a190

Browse files
committed
Make inference defaults consts for easy tweaking
[email protected] Review URL: https://codereview.chromium.org/988743003
1 parent 4487294 commit 122a190

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

pkg/dev_compiler/lib/src/options.dart

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ResolverOptions {
2525

2626
/// Whether to infer return types and field types from overriden members.
2727
final bool inferFromOverrides;
28-
static const bool INFER_FROM_OVERRIDES_DEFAULT = false;
28+
static const inferFromOverridesDefault = false;
2929

3030
/// Whether to infer types for consts and static fields by looking at
3131
/// identifiers on the RHS. For example, in a constant declaration like:
@@ -37,6 +37,7 @@ class ResolverOptions {
3737
/// defined in a different library than `A`. Because this might be surprising
3838
/// to users, this is turned off by default.
3939
final bool inferStaticsFromIdentifiers;
40+
static const inferStaticsFromIdentifiersDefault = false;
4041

4142
/// Whether to ignore ordering issues and do a best effort in inference. When
4243
/// false, inference of top-levels and statics is limited to only consider
@@ -49,17 +50,19 @@ class ResolverOptions {
4950
/// implementation of inference in the future, which should handle all
5051
/// ordering concerns.
5152
final bool inferInNonStableOrder;
53+
static const inferInNonStableOrderDefault = false;
5254

5355
/// Restrict inference of fields and top-levels to those that are final and
5456
/// const.
5557
final bool onlyInferConstsAndFinalFields;
58+
static const onlyInferConstAndFinalFieldsDefault = false;
5659

5760
ResolverOptions({this.useMultiPackage: false, this.packageRoot: 'packages/',
5861
this.packagePaths: const <String>[],
59-
this.inferFromOverrides: INFER_FROM_OVERRIDES_DEFAULT,
60-
this.inferStaticsFromIdentifiers: false,
61-
this.inferInNonStableOrder: false,
62-
this.onlyInferConstsAndFinalFields: false});
62+
this.inferFromOverrides: inferFromOverridesDefault,
63+
this.inferStaticsFromIdentifiers: inferStaticsFromIdentifiersDefault,
64+
this.inferInNonStableOrder: inferInNonStableOrderDefault,
65+
this.onlyInferConstsAndFinalFields: onlyInferConstAndFinalFieldsDefault});
6366
}
6467

6568
// TODO(vsm): Merge RulesOptions and TypeOptions
@@ -207,10 +210,10 @@ class CompilerOptions implements RulesOptions, ResolverOptions, JSCodeOptions {
207210
this.covariantGenerics: true, this.relaxedCasts: true,
208211
this.useMultiPackage: false, this.packageRoot: 'packages/',
209212
this.packagePaths: const <String>[],
210-
this.inferFromOverrides: ResolverOptions.INFER_FROM_OVERRIDES_DEFAULT,
211-
this.inferStaticsFromIdentifiers: false,
212-
this.inferInNonStableOrder: false,
213-
this.onlyInferConstsAndFinalFields: false,
213+
this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
214+
this.inferStaticsFromIdentifiers: ResolverOptions.inferStaticsFromIdentifiersDefault,
215+
this.inferInNonStableOrder: ResolverOptions.inferInNonStableOrderDefault,
216+
this.onlyInferConstsAndFinalFields: ResolverOptions.onlyInferConstAndFinalFieldsDefault,
214217
this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false,
215218
this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE,
216219
this.emitSourceMaps: true, this.entryPointFile: null,
@@ -281,16 +284,18 @@ final ArgParser argParser = new ArgParser()
281284
..addFlag('infer-from-overrides',
282285
help: 'Infer unspecified types of fields and return types from '
283286
'definitions in supertypes',
284-
defaultsTo: ResolverOptions.INFER_FROM_OVERRIDES_DEFAULT)
287+
defaultsTo: ResolverOptions.inferFromOverridesDefault)
285288
..addFlag('infer-transitively',
286289
help: 'Infer consts/fields from definitions in other libraries',
287-
defaultsTo: false)
290+
defaultsTo: ResolverOptions.inferStaticsFromIdentifiersDefault)
288291
..addFlag('infer-only-finals',
289-
help: 'Do not infer non-const or non-final fields', defaultsTo: false)
292+
help: 'Do not infer non-const or non-final fields',
293+
defaultsTo: ResolverOptions.onlyInferConstAndFinalFieldsDefault)
290294
..addFlag('infer-eagerly',
291295
help: 'experimental: allows a non-stable order of transitive inference on'
292296
' consts and fields. This is used to test for possible inference with a '
293-
'proper implementation in the future.', defaultsTo: false)
297+
'proper implementation in the future.',
298+
defaultsTo: ResolverOptions.inferInNonStableOrderDefault)
294299

295300
// input/output options
296301
..addOption('out', abbr: 'o', help: 'Output directory', defaultsTo: null)

pkg/dev_compiler/lib/src/testing.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ import 'package:dev_compiler/devc.dart' show Compiler;
5050
CheckerResults testChecker(Map<String, String> testFiles,
5151
{bool allowConstCasts: true, String sdkDir, CheckerReporter reporter,
5252
covariantGenerics: true, relaxedCasts: true,
53-
inferFromOverrides: ResolverOptions.INFER_FROM_OVERRIDES_DEFAULT,
54-
inferStaticsFromIdentifiers: false, inferInNonStableOrder: false,
53+
inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
54+
inferStaticsFromIdentifiers: ResolverOptions.inferStaticsFromIdentifiersDefault,
55+
inferInNonStableOrder: ResolverOptions.inferInNonStableOrderDefault,
5556
nonnullableTypes: TypeOptions.NONNULLABLE_TYPES}) {
5657
expect(testFiles.containsKey('/main.dart'), isTrue,
5758
reason: '`/main.dart` is missing in testFiles');

0 commit comments

Comments
 (0)