Add experimental flag inference-update-2.
This is initially intended to support type promotion of fields (https://github.com/dart-lang/language/issues/2020). However, if time allows, we may roll other type inference improvements into it. Change-Id: Ie4548ceafe671a9a328a11ad950a4e70f4d3ca41 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244766 Reviewed-by: Devon Carew <devoncarew@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
@@ -84,7 +84,7 @@ import 'package:meta/meta.dart';
|
||||
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
|
||||
class AnalysisDriver implements AnalysisDriverGeneric {
|
||||
/// The version of data format, should be incremented on every format change.
|
||||
static const int DATA_VERSION = 218;
|
||||
static const int DATA_VERSION = 219;
|
||||
|
||||
/// The number of exception contexts allowed to write. Once this field is
|
||||
/// zero, we stop writing any new exception contexts in this process.
|
||||
|
||||
@@ -22,6 +22,7 @@ final _knownFeatures = <String, ExperimentalFeature>{
|
||||
EnableString.extension_types: ExperimentalFeatures.extension_types,
|
||||
EnableString.generic_metadata: ExperimentalFeatures.generic_metadata,
|
||||
EnableString.inference_update_1: ExperimentalFeatures.inference_update_1,
|
||||
EnableString.inference_update_2: ExperimentalFeatures.inference_update_2,
|
||||
EnableString.macros: ExperimentalFeatures.macros,
|
||||
EnableString.named_arguments_anywhere:
|
||||
ExperimentalFeatures.named_arguments_anywhere,
|
||||
@@ -67,6 +68,9 @@ class EnableString {
|
||||
/// String to enable the experiment "inference-update-1"
|
||||
static const String inference_update_1 = 'inference-update-1';
|
||||
|
||||
/// String to enable the experiment "inference-update-2"
|
||||
static const String inference_update_2 = 'inference-update-2';
|
||||
|
||||
/// String to enable the experiment "macros"
|
||||
static const String macros = 'macros';
|
||||
|
||||
@@ -196,8 +200,18 @@ class ExperimentalFeatures {
|
||||
releaseVersion: null,
|
||||
);
|
||||
|
||||
static final macros = ExperimentalFeature(
|
||||
static final inference_update_2 = ExperimentalFeature(
|
||||
index: 9,
|
||||
enableString: EnableString.inference_update_2,
|
||||
isEnabledByDefault: IsEnabledByDefault.inference_update_2,
|
||||
isExpired: IsExpired.inference_update_2,
|
||||
documentation: 'Type promotion for fields',
|
||||
experimentalReleaseVersion: null,
|
||||
releaseVersion: null,
|
||||
);
|
||||
|
||||
static final macros = ExperimentalFeature(
|
||||
index: 10,
|
||||
enableString: EnableString.macros,
|
||||
isEnabledByDefault: IsEnabledByDefault.macros,
|
||||
isExpired: IsExpired.macros,
|
||||
@@ -207,7 +221,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final named_arguments_anywhere = ExperimentalFeature(
|
||||
index: 10,
|
||||
index: 11,
|
||||
enableString: EnableString.named_arguments_anywhere,
|
||||
isEnabledByDefault: IsEnabledByDefault.named_arguments_anywhere,
|
||||
isExpired: IsExpired.named_arguments_anywhere,
|
||||
@@ -217,7 +231,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final non_nullable = ExperimentalFeature(
|
||||
index: 11,
|
||||
index: 12,
|
||||
enableString: EnableString.non_nullable,
|
||||
isEnabledByDefault: IsEnabledByDefault.non_nullable,
|
||||
isExpired: IsExpired.non_nullable,
|
||||
@@ -227,7 +241,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final nonfunction_type_aliases = ExperimentalFeature(
|
||||
index: 12,
|
||||
index: 13,
|
||||
enableString: EnableString.nonfunction_type_aliases,
|
||||
isEnabledByDefault: IsEnabledByDefault.nonfunction_type_aliases,
|
||||
isExpired: IsExpired.nonfunction_type_aliases,
|
||||
@@ -237,7 +251,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final set_literals = ExperimentalFeature(
|
||||
index: 13,
|
||||
index: 14,
|
||||
enableString: EnableString.set_literals,
|
||||
isEnabledByDefault: IsEnabledByDefault.set_literals,
|
||||
isExpired: IsExpired.set_literals,
|
||||
@@ -247,7 +261,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final spread_collections = ExperimentalFeature(
|
||||
index: 14,
|
||||
index: 15,
|
||||
enableString: EnableString.spread_collections,
|
||||
isEnabledByDefault: IsEnabledByDefault.spread_collections,
|
||||
isExpired: IsExpired.spread_collections,
|
||||
@@ -257,7 +271,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final super_parameters = ExperimentalFeature(
|
||||
index: 15,
|
||||
index: 16,
|
||||
enableString: EnableString.super_parameters,
|
||||
isEnabledByDefault: IsEnabledByDefault.super_parameters,
|
||||
isExpired: IsExpired.super_parameters,
|
||||
@@ -267,7 +281,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final test_experiment = ExperimentalFeature(
|
||||
index: 16,
|
||||
index: 17,
|
||||
enableString: EnableString.test_experiment,
|
||||
isEnabledByDefault: IsEnabledByDefault.test_experiment,
|
||||
isExpired: IsExpired.test_experiment,
|
||||
@@ -278,7 +292,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final triple_shift = ExperimentalFeature(
|
||||
index: 17,
|
||||
index: 18,
|
||||
enableString: EnableString.triple_shift,
|
||||
isEnabledByDefault: IsEnabledByDefault.triple_shift,
|
||||
isExpired: IsExpired.triple_shift,
|
||||
@@ -288,7 +302,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final value_class = ExperimentalFeature(
|
||||
index: 18,
|
||||
index: 19,
|
||||
enableString: EnableString.value_class,
|
||||
isEnabledByDefault: IsEnabledByDefault.value_class,
|
||||
isExpired: IsExpired.value_class,
|
||||
@@ -298,7 +312,7 @@ class ExperimentalFeatures {
|
||||
);
|
||||
|
||||
static final variance = ExperimentalFeature(
|
||||
index: 19,
|
||||
index: 20,
|
||||
enableString: EnableString.variance,
|
||||
isEnabledByDefault: IsEnabledByDefault.variance,
|
||||
isExpired: IsExpired.variance,
|
||||
@@ -338,6 +352,9 @@ class IsEnabledByDefault {
|
||||
/// Default state of the experiment "inference-update-1"
|
||||
static const bool inference_update_1 = false;
|
||||
|
||||
/// Default state of the experiment "inference-update-2"
|
||||
static const bool inference_update_2 = false;
|
||||
|
||||
/// Default state of the experiment "macros"
|
||||
static const bool macros = false;
|
||||
|
||||
@@ -403,6 +420,9 @@ class IsExpired {
|
||||
/// Expiration status of the experiment "inference-update-1"
|
||||
static const bool inference_update_1 = false;
|
||||
|
||||
/// Expiration status of the experiment "inference-update-2"
|
||||
static const bool inference_update_2 = false;
|
||||
|
||||
/// Expiration status of the experiment "macros"
|
||||
static const bool macros = false;
|
||||
|
||||
@@ -470,6 +490,10 @@ mixin _CurrentState {
|
||||
bool get inference_update_1 =>
|
||||
isEnabled(ExperimentalFeatures.inference_update_1);
|
||||
|
||||
/// Current state for the flag "inference-update-2"
|
||||
bool get inference_update_2 =>
|
||||
isEnabled(ExperimentalFeatures.inference_update_2);
|
||||
|
||||
/// Current state for the flag "macros"
|
||||
bool get macros => isEnabled(ExperimentalFeatures.macros);
|
||||
|
||||
|
||||
@@ -131,6 +131,14 @@ class ExperimentalFlag {
|
||||
experimentEnabledVersion: const Version(2, 18),
|
||||
experimentReleasedVersion: const Version(2, 18));
|
||||
|
||||
static const ExperimentalFlag inferenceUpdate2 = const ExperimentalFlag(
|
||||
name: 'inference-update-2',
|
||||
isEnabledByDefault: false,
|
||||
isExpired: false,
|
||||
enabledVersion: const Version(2, 18),
|
||||
experimentEnabledVersion: const Version(2, 18),
|
||||
experimentReleasedVersion: const Version(2, 18));
|
||||
|
||||
static const ExperimentalFlag macros = const ExperimentalFlag(
|
||||
name: 'macros',
|
||||
isEnabledByDefault: false,
|
||||
@@ -306,6 +314,10 @@ class GlobalFeatures {
|
||||
GlobalFeature get inferenceUpdate1 => _inferenceUpdate1 ??=
|
||||
_computeGlobalFeature(ExperimentalFlag.inferenceUpdate1);
|
||||
|
||||
GlobalFeature? _inferenceUpdate2;
|
||||
GlobalFeature get inferenceUpdate2 => _inferenceUpdate2 ??=
|
||||
_computeGlobalFeature(ExperimentalFlag.inferenceUpdate2);
|
||||
|
||||
GlobalFeature? _macros;
|
||||
GlobalFeature get macros =>
|
||||
_macros ??= _computeGlobalFeature(ExperimentalFlag.macros);
|
||||
@@ -415,6 +427,11 @@ class LibraryFeatures {
|
||||
_inferenceUpdate1 ??= globalFeatures._computeLibraryFeature(
|
||||
ExperimentalFlag.inferenceUpdate1, canonicalUri, libraryVersion);
|
||||
|
||||
LibraryFeature? _inferenceUpdate2;
|
||||
LibraryFeature get inferenceUpdate2 =>
|
||||
_inferenceUpdate2 ??= globalFeatures._computeLibraryFeature(
|
||||
ExperimentalFlag.inferenceUpdate2, canonicalUri, libraryVersion);
|
||||
|
||||
LibraryFeature? _macros;
|
||||
LibraryFeature get macros =>
|
||||
_macros ??= globalFeatures._computeLibraryFeature(
|
||||
@@ -497,6 +514,8 @@ ExperimentalFlag? parseExperimentalFlag(String flag) {
|
||||
return ExperimentalFlag.genericMetadata;
|
||||
case "inference-update-1":
|
||||
return ExperimentalFlag.inferenceUpdate1;
|
||||
case "inference-update-2":
|
||||
return ExperimentalFlag.inferenceUpdate2;
|
||||
case "macros":
|
||||
return ExperimentalFlag.macros;
|
||||
case "named-arguments-anywhere":
|
||||
@@ -544,6 +563,8 @@ final Map<ExperimentalFlag, bool> defaultExperimentalFlags = {
|
||||
ExperimentalFlag.genericMetadata.isEnabledByDefault,
|
||||
ExperimentalFlag.inferenceUpdate1:
|
||||
ExperimentalFlag.inferenceUpdate1.isEnabledByDefault,
|
||||
ExperimentalFlag.inferenceUpdate2:
|
||||
ExperimentalFlag.inferenceUpdate2.isEnabledByDefault,
|
||||
ExperimentalFlag.macros: ExperimentalFlag.macros.isEnabledByDefault,
|
||||
ExperimentalFlag.namedArgumentsAnywhere:
|
||||
ExperimentalFlag.namedArgumentsAnywhere.isEnabledByDefault,
|
||||
|
||||
@@ -128,6 +128,9 @@ features:
|
||||
inference-update-1:
|
||||
help: "Horizontal type inference for function expressions passed to generic invocations."
|
||||
|
||||
inference-update-2:
|
||||
help: "Type promotion for fields"
|
||||
|
||||
# Experiment flag only used for testing.
|
||||
test-experiment:
|
||||
help: >-
|
||||
|
||||
Reference in New Issue
Block a user