Skip to content

Commit

Permalink
remove covariant generics option
Browse files Browse the repository at this point in the history
Thoughts? Seems unlikely we'll go with invariant at this point.
I'd like to see covariant generics go, but it seems we need variance annotations of some sort before that becomes realistic. (e.g. Iterable is used all over the place)

[email protected]

Review URL: https://codereview.chromium.org/1165303002
  • Loading branch information
John Messerly committed Jun 8, 2015
1 parent 73be4ca commit a5132e6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 373 deletions.
6 changes: 1 addition & 5 deletions pkg/dev_compiler/lib/src/checker/rules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,7 @@ class RestrictedRules extends TypeRules {
for (int i = 0; i < tArgs1.length; i++) {
DartType t1 = tArgs1[i];
DartType t2 = tArgs2[i];
if (options.covariantGenerics) {
if (!isSubTypeOf(t1, t2)) return false;
} else {
if ((t1 != t2) && !t2.isDynamic) return false;
}
if (!isSubTypeOf(t1, t2)) return false;
}
return true;
}
Expand Down
22 changes: 5 additions & 17 deletions pkg/dev_compiler/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ class ResolverOptions {
// TODO(vsm): Merge RulesOptions and TypeOptions
/// Options used by our RestrictedRules.
class RulesOptions extends TypeOptions {
/// Whether to use covariant generics
final bool covariantGenerics;

/// Whether to infer types downwards from local context
final bool inferDownwards;
static const inferDownwardsDefault = true;
Expand All @@ -86,9 +83,8 @@ class RulesOptions extends TypeOptions {
/// Whether to use static types for code generation.
final bool ignoreTypes;

RulesOptions({this.covariantGenerics: true,
this.inferDownwards: inferDownwardsDefault, this.relaxedCasts: true,
this.ignoreTypes: false});
RulesOptions({this.inferDownwards: inferDownwardsDefault,
this.relaxedCasts: true, this.ignoreTypes: false});
}

class JSCodeOptions {
Expand Down Expand Up @@ -150,10 +146,6 @@ class CompilerOptions implements RulesOptions, ResolverOptions, JSCodeOptions {
/// Host name or address for HTTP server when [serverMode] is on.
final String host;

/// Whether to use covariant generics
@override
final bool covariantGenerics;

/// Whether to inject casts between Dart assignable types.
@override
final bool relaxedCasts;
Expand Down Expand Up @@ -214,10 +206,9 @@ class CompilerOptions implements RulesOptions, ResolverOptions, JSCodeOptions {

CompilerOptions({this.checkSdk: false, this.dumpInfo: false,
this.dumpInfoFile, this.forceCompile: false, this.ignoreTypes: false,
this.outputDir, this.useColors: true, this.covariantGenerics: true,
this.relaxedCasts: true, this.useMultiPackage: false,
this.packageRoot: 'packages/', this.packagePaths: const <String>[],
this.resources: const <String>[],
this.outputDir, this.useColors: true, this.relaxedCasts: true,
this.useMultiPackage: false, this.packageRoot: 'packages/',
this.packagePaths: const <String>[], this.resources: const <String>[],
this.inferDownwards: RulesOptions.inferDownwardsDefault,
this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
this.inferTransitively: ResolverOptions.inferTransitivelyDefault,
Expand Down Expand Up @@ -283,7 +274,6 @@ CompilerOptions parseOptions(List<String> argv) {
forceCompile: args['force-compile'] || serverMode,
ignoreTypes: args['ignore-types'],
outputDir: outputDir,
covariantGenerics: args['covariant-generics'],
relaxedCasts: args['relaxed-casts'],
useColors: useColors,
customUrlMappings: customUrlMappings,
Expand Down Expand Up @@ -320,8 +310,6 @@ final ArgParser argParser = new ArgParser()
abbr: 's', help: 'Typecheck sdk libs', defaultsTo: false)
..addFlag('mock-sdk',
abbr: 'm', help: 'Use a mock Dart SDK', defaultsTo: false)
..addFlag('covariant-generics',
help: 'Use covariant generics', defaultsTo: true)
..addFlag('ignore-types',
help: 'Ignore types during codegen', defaultsTo: false)
..addFlag('relaxed-casts',
Expand Down
4 changes: 1 addition & 3 deletions pkg/dev_compiler/lib/src/testing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ import 'utils.dart';
///
CheckerResults testChecker(Map<String, String> testFiles, {String sdkDir,
customUrlMappings: const {},
CheckerReporter createReporter(AnalysisContext context),
covariantGenerics: true, relaxedCasts: true,
CheckerReporter createReporter(AnalysisContext context), relaxedCasts: true,
inferDownwards: RulesOptions.inferDownwardsDefault,
inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
inferTransitively: ResolverOptions.inferTransitivelyDefault,
Expand All @@ -61,7 +60,6 @@ CheckerResults testChecker(Map<String, String> testFiles, {String sdkDir,
var uriResolver = new TestUriResolver(provider);

var options = new CompilerOptions(
covariantGenerics: covariantGenerics,
relaxedCasts: relaxedCasts,
inferDownwards: inferDownwards,
inferFromOverrides: inferFromOverrides,
Expand Down
Loading

0 comments on commit a5132e6

Please sign in to comment.