Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: lib/src/options.dart

Issue 980103002: Disable infer-from-overrides by default (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/testing.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Set of flags and options passed to the compiler 5 /// Set of flags and options passed to the compiler
6 library dev_compiler.src.options; 6 library dev_compiler.src.options;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:args/args.dart'; 10 import 'package:args/args.dart';
11 import 'package:cli_util/cli_util.dart' show getSdkDir; 11 import 'package:cli_util/cli_util.dart' show getSdkDir;
12 import 'package:dev_compiler/config.dart'; 12 import 'package:dev_compiler/config.dart';
13 import 'package:logging/logging.dart' show Level; 13 import 'package:logging/logging.dart' show Level;
14 14
15 /// Options used by our TypeResolver. 15 /// Options used by our TypeResolver.
16 class ResolverOptions { 16 class ResolverOptions {
17 /// Whether to resolve 'package:' uris using the multi-package resolver. 17 /// Whether to resolve 'package:' uris using the multi-package resolver.
18 final bool useMultiPackage; 18 final bool useMultiPackage;
19 19
20 /// Package root when resolving 'package:' urls the standard way. 20 /// Package root when resolving 'package:' urls the standard way.
21 final String packageRoot; 21 final String packageRoot;
22 22
23 /// List of paths used for the multi-package resolver. 23 /// List of paths used for the multi-package resolver.
24 final List<String> packagePaths; 24 final List<String> packagePaths;
25 25
26 /// Whether to infer return types and field types from overriden members. 26 /// Whether to infer return types and field types from overriden members.
27 final bool inferFromOverrides; 27 final bool inferFromOverrides;
28 static const bool INFER_FROM_OVERRIDES_DEFAULT = false;
vsm 2015/03/05 03:58:56 Trying to make one place to set this so it's easy
28 29
29 /// Whether to infer types for consts and static fields by looking at 30 /// Whether to infer types for consts and static fields by looking at
30 /// identifiers on the RHS. For example, in a constant declaration like: 31 /// identifiers on the RHS. For example, in a constant declaration like:
31 /// 32 ///
32 /// const A = B; 33 /// const A = B;
33 /// 34 ///
34 /// We can infer the type of `A` based on the type of `B`. The current 35 /// We can infer the type of `A` based on the type of `B`. The current
35 /// implementation of this inference is limited and will only work if `B` is 36 /// implementation of this inference is limited and will only work if `B` is
36 /// defined in a different library than `A`. Because this might be surprising 37 /// defined in a different library than `A`. Because this might be surprising
37 /// to users, this is turned off by default. 38 /// to users, this is turned off by default.
38 final bool inferStaticsFromIdentifiers; 39 final bool inferStaticsFromIdentifiers;
39 40
40 /// Whether to ignore ordering issues and do a best effort in inference. When 41 /// Whether to ignore ordering issues and do a best effort in inference. When
41 /// false, inference of top-levels and statics is limited to only consider 42 /// false, inference of top-levels and statics is limited to only consider
42 /// expressions in the RHS for which the type is known precisely without 43 /// expressions in the RHS for which the type is known precisely without
43 /// regard of the ordering in which we apply inference. Turning this flag on 44 /// regard of the ordering in which we apply inference. Turning this flag on
44 /// will consider more expressions, including expressions where the RHS is 45 /// will consider more expressions, including expressions where the RHS is
45 /// another identifier (which [inferStaticsFromIdentifiers]). 46 /// another identifier (which [inferStaticsFromIdentifiers]).
46 /// 47 ///
47 /// Note: this option is experimental will be removed once we have a proper 48 /// Note: this option is experimental will be removed once we have a proper
48 /// implementation of inference in the future, which should handle all 49 /// implementation of inference in the future, which should handle all
49 /// ordering concerns. 50 /// ordering concerns.
50 final bool inferInNonStableOrder; 51 final bool inferInNonStableOrder;
51 52
52 /// Restrict inference of fields and top-levels to those that are final and 53 /// Restrict inference of fields and top-levels to those that are final and
53 /// const. 54 /// const.
54 final bool onlyInferConstsAndFinalFields; 55 final bool onlyInferConstsAndFinalFields;
55 56
56 ResolverOptions({this.useMultiPackage: false, this.packageRoot: 'packages/', 57 ResolverOptions({this.useMultiPackage: false, this.packageRoot: 'packages/',
57 this.packagePaths: const <String>[], this.inferFromOverrides: true, 58 this.packagePaths: const <String>[],
59 this.inferFromOverrides: INFER_FROM_OVERRIDES_DEFAULT,
58 this.inferStaticsFromIdentifiers: false, 60 this.inferStaticsFromIdentifiers: false,
59 this.inferInNonStableOrder: false, 61 this.inferInNonStableOrder: false,
60 this.onlyInferConstsAndFinalFields: false}); 62 this.onlyInferConstsAndFinalFields: false});
61 } 63 }
62 64
63 // TODO(vsm): Merge RulesOptions and TypeOptions 65 // TODO(vsm): Merge RulesOptions and TypeOptions
64 /// Options used by our RestrictedRules. 66 /// Options used by our RestrictedRules.
65 class RulesOptions extends TypeOptions { 67 class RulesOptions extends TypeOptions {
66 /// Whether to allow casts in constant contexts. 68 /// Whether to allow casts in constant contexts.
67 final bool allowConstCasts; 69 final bool allowConstCasts;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 @override 199 @override
198 final bool emitSourceMaps; 200 final bool emitSourceMaps;
199 201
200 CompilerOptions({this.allowConstCasts: true, this.checkSdk: false, 202 CompilerOptions({this.allowConstCasts: true, this.checkSdk: false,
201 this.dumpInfo: false, this.dumpInfoFile, this.dumpSrcDir, 203 this.dumpInfo: false, this.dumpInfoFile, this.dumpSrcDir,
202 this.forceCompile: false, this.formatOutput: false, 204 this.forceCompile: false, this.formatOutput: false,
203 this.cheapTestFormat: false, this.ignoreTypes: false, this.outputDir, 205 this.cheapTestFormat: false, this.ignoreTypes: false, this.outputDir,
204 this.outputDart: false, this.useColors: true, 206 this.outputDart: false, this.useColors: true,
205 this.covariantGenerics: true, this.relaxedCasts: true, 207 this.covariantGenerics: true, this.relaxedCasts: true,
206 this.useMultiPackage: false, this.packageRoot: 'packages/', 208 this.useMultiPackage: false, this.packageRoot: 'packages/',
207 this.packagePaths: const <String>[], this.inferFromOverrides: true, 209 this.packagePaths: const <String>[],
210 this.inferFromOverrides: ResolverOptions.INFER_FROM_OVERRIDES_DEFAULT,
208 this.inferStaticsFromIdentifiers: false, 211 this.inferStaticsFromIdentifiers: false,
209 this.inferInNonStableOrder: false, 212 this.inferInNonStableOrder: false,
210 this.onlyInferConstsAndFinalFields: false, 213 this.onlyInferConstsAndFinalFields: false,
211 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false, 214 this.nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, this.help: false,
212 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE, 215 this.useMockSdk: false, this.dartSdkPath, this.logLevel: Level.SEVERE,
213 this.emitSourceMaps: true, this.entryPointFile: null, 216 this.emitSourceMaps: true, this.entryPointFile: null,
214 this.serverMode: false, this.port: 8080}); 217 this.serverMode: false, this.port: 8080});
215 } 218 }
216 219
217 /// Parses options from the command-line 220 /// Parses options from the command-line
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 ..addFlag('ignore-types', 273 ..addFlag('ignore-types',
271 help: 'Ignore types during codegen', defaultsTo: false) 274 help: 'Ignore types during codegen', defaultsTo: false)
272 ..addFlag('relaxed-casts', 275 ..addFlag('relaxed-casts',
273 help: 'Cast between Dart assignable types', defaultsTo: true) 276 help: 'Cast between Dart assignable types', defaultsTo: true)
274 ..addOption('nonnullable', 277 ..addOption('nonnullable',
275 abbr: 'n', 278 abbr: 'n',
276 help: 'Comma separated string of non-nullable types', 279 help: 'Comma separated string of non-nullable types',
277 defaultsTo: null) 280 defaultsTo: null)
278 ..addFlag('infer-from-overrides', 281 ..addFlag('infer-from-overrides',
279 help: 'Infer unspecified types of fields and return types from ' 282 help: 'Infer unspecified types of fields and return types from '
280 'definitions in supertypes', defaultsTo: true) 283 'definitions in supertypes',
284 defaultsTo: ResolverOptions.INFER_FROM_OVERRIDES_DEFAULT)
281 ..addFlag('infer-transitively', 285 ..addFlag('infer-transitively',
282 help: 'Infer consts/fields from definitions in other libraries', 286 help: 'Infer consts/fields from definitions in other libraries',
283 defaultsTo: false) 287 defaultsTo: false)
284 ..addFlag('infer-only-finals', 288 ..addFlag('infer-only-finals',
285 help: 'Do not infer non-const or non-final fields', defaultsTo: false) 289 help: 'Do not infer non-const or non-final fields', defaultsTo: false)
286 ..addFlag('infer-eagerly', 290 ..addFlag('infer-eagerly',
287 help: 'experimental: allows a non-stable order of transitive inference on' 291 help: 'experimental: allows a non-stable order of transitive inference on'
288 ' consts and fields. This is used to test for possible inference with a ' 292 ' consts and fields. This is used to test for possible inference with a '
289 'proper implementation in the future.', defaultsTo: false) 293 'proper implementation in the future.', defaultsTo: false)
290 294
(...skipping 25 matching lines...) Expand all
316 defaultsTo: '8080') 320 defaultsTo: '8080')
317 ..addFlag('force-compile', 321 ..addFlag('force-compile',
318 help: 'Compile code with static errors', defaultsTo: false) 322 help: 'Compile code with static errors', defaultsTo: false)
319 ..addOption('log', abbr: 'l', help: 'Logging level', defaultsTo: 'severe') 323 ..addOption('log', abbr: 'l', help: 'Logging level', defaultsTo: 'severe')
320 ..addFlag('dump-info', 324 ..addFlag('dump-info',
321 abbr: 'i', help: 'Dump summary information', defaultsTo: false) 325 abbr: 'i', help: 'Dump summary information', defaultsTo: false)
322 ..addOption('dump-info-file', 326 ..addOption('dump-info-file',
323 abbr: 'f', 327 abbr: 'f',
324 help: 'Dump info json file (requires dump-info)', 328 help: 'Dump info json file (requires dump-info)',
325 defaultsTo: null); 329 defaultsTo: null);
OLDNEW
« no previous file with comments | « no previous file | lib/src/testing.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698