Skip to content

Commit

Permalink
Version 2.19.0-231.0.dev
Browse files Browse the repository at this point in the history
Merge 51b6dba into dev
  • Loading branch information
Dart CI committed Sep 22, 2022
2 parents e6f4425 + 51b6dba commit a7848c0
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 43 deletions.
60 changes: 29 additions & 31 deletions pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,10 @@ abstract class FlowAnalysis<Node extends Object, Statement extends Node,
Expression extends Object, Variable extends Object, Type extends Object> {
factory FlowAnalysis(Operations<Variable, Type> operations,
AssignedVariables<Node, Variable> assignedVariables,
{required bool respectImplicitlyTypedVarInitializers,
Set<Object?> promotableFields = const {}}) {
{required bool respectImplicitlyTypedVarInitializers}) {
return new _FlowAnalysisImpl(operations, assignedVariables,
respectImplicitlyTypedVarInitializers:
respectImplicitlyTypedVarInitializers,
promotableFields: promotableFields);
respectImplicitlyTypedVarInitializers);
}

factory FlowAnalysis.legacy(Operations<Variable, Type> operations,
Expand Down Expand Up @@ -492,10 +490,10 @@ abstract class FlowAnalysis<Node extends Object, Statement extends Node,
/// expression.
///
/// [propertyMember] should be whatever data structure the client uses to keep
/// track of the field or property being accessed. This will be matched
/// against set set of promotable fields passed to the [FlowAnalysis]
/// constructor. [staticType] should be the static type of the value returned
/// by the property get.
/// track of the field or property being accessed. If not `null`,
/// [Operations.isPropertyPromotable] will be consulted to find out whether
/// the property is promotable. [staticType] should be the static type of the
/// value returned by the property get.
///
/// Note: although only fields can be promoted, this method uses the
/// nomenclature "property" rather than "field", to highlight the fact that
Expand All @@ -516,10 +514,11 @@ abstract class FlowAnalysis<Node extends Object, Statement extends Node,
/// the static type of the value returned by the property get.
///
/// [propertyMember] should be whatever data structure the client uses to keep
/// track of the field or property being accessed. This will be matched
/// against the set of promotable fields passed to the [FlowAnalysis]
/// constructor. In the event of non-promotion of a property get, this value
/// can be retrieved from [PropertyNotPromoted.propertyMember].
/// track of the field or property being accessed. If not `null`,
/// [Operations.isPropertyPromotable] will be consulted to find out whether
/// the property is promotable. In the event of non-promotion of a property
/// get, this value can be retrieved from
/// [PropertyNotPromoted.propertyMember].
///
/// If the property's type is currently promoted, the promoted type is
/// returned. Otherwise `null` is returned.
Expand Down Expand Up @@ -610,10 +609,11 @@ abstract class FlowAnalysis<Node extends Object, Statement extends Node,
/// returned by the property get.
///
/// [propertyMember] should be whatever data structure the client uses to keep
/// track of the field or property being accessed. This will be matched
/// against the set of promotable fields passed to the [FlowAnalysis]
/// constructor. In the event of non-promotion of a property get, this value
/// can be retrieved from [PropertyNotPromoted.propertyMember].
/// track of the field or property being accessed. If not `null`,
/// [Operations.isPropertyPromotable] will be consulted to find out whether
/// the property is promotable. In the event of non-promotion of a property
/// get, this value can be retrieved from
/// [PropertyNotPromoted.propertyMember].
///
/// If the property's type is currently promoted, the promoted type is
/// returned. Otherwise `null` is returned.
Expand Down Expand Up @@ -808,14 +808,12 @@ class FlowAnalysisDebug<Node extends Object, Statement extends Node,

factory FlowAnalysisDebug(Operations<Variable, Type> operations,
AssignedVariables<Node, Variable> assignedVariables,
{required bool respectImplicitlyTypedVarInitializers,
Set<Object?> promotableFields = const {}}) {
{required bool respectImplicitlyTypedVarInitializers}) {
print('FlowAnalysisDebug()');
return new FlowAnalysisDebug._(new _FlowAnalysisImpl(
operations, assignedVariables,
respectImplicitlyTypedVarInitializers:
respectImplicitlyTypedVarInitializers,
promotableFields: promotableFields));
respectImplicitlyTypedVarInitializers));
}

factory FlowAnalysisDebug.legacy(Operations<Variable, Type> operations,
Expand Down Expand Up @@ -2244,7 +2242,13 @@ abstract class NonPromotionReasonVisitor<R, Node extends Object,

/// Operations on types and variables, abstracted from concrete type interfaces.
abstract class Operations<Variable extends Object, Type extends Object>
implements TypeOperations<Type>, VariableOperations<Variable, Type> {}
implements TypeOperations<Type>, VariableOperations<Variable, Type> {
/// Determines whether the given property can be promoted. [propertyMember]
/// will correspond to a `propertyMember` value passed to
/// [FlowAnalysis.promotedPropertyType], [FlowAnalysis.propertyGet], or
/// [FlowAnalysis.thisOrSuperPropertyGet].
bool isPropertyPromotable(Object property);
}

/// Non-promotion reason describing the situation where an expression was not
/// promoted due to the fact that it's a property get.
Expand Down Expand Up @@ -3161,16 +3165,9 @@ class _FlowAnalysisImpl<Node extends Object, Statement extends Node,
@override
final PromotionKeyStore<Variable> promotionKeyStore;

/// The set of fields that can be promoted. The type of the set element is
/// `Object?` to match the type of the `propertyMember` argument of
/// [promotedFieldType], [propertyGet], and [thisOrSuperPropertyGet].
final Set<Object?> _promotableFields;

_FlowAnalysisImpl(this.operations, this._assignedVariables,
{required this.respectImplicitlyTypedVarInitializers,
Set<Object?> promotableFields = const {}})
: promotionKeyStore = _assignedVariables.promotionKeyStore,
_promotableFields = promotableFields {
{required this.respectImplicitlyTypedVarInitializers})
: promotionKeyStore = _assignedVariables.promotionKeyStore {
if (!_assignedVariables.isFinished) {
_assignedVariables.finish();
}
Expand Down Expand Up @@ -4096,7 +4093,8 @@ class _FlowAnalysisImpl<Node extends Object, Statement extends Node,
Type? _handleProperty(Expression? wholeExpression, Expression? target,
String propertyName, Object? propertyMember, Type staticType) {
int targetKey;
bool isPromotable = _promotableFields.contains(propertyMember);
bool isPromotable = propertyMember != null &&
operations.isPropertyPromotable(propertyMember);
if (target == null) {
targetKey = promotionKeyStore.thisPromotionKey;
} else {
Expand Down
7 changes: 5 additions & 2 deletions pkg/_fe_analyzer_shared/test/mini_ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,10 @@ class Harness
return type.type == 'Never';
}

@override
bool isPropertyPromotable(Object property) =>
promotableFields.contains(property);

@override
bool isSameType(Type type1, Type type2) {
return type1.type == type2.type;
Expand Down Expand Up @@ -809,8 +813,7 @@ class Harness
: FlowAnalysis<Node, Statement, Expression, Var, Type>(
this, visitor._assignedVariables,
respectImplicitlyTypedVarInitializers:
_respectImplicitlyTypedVarInitializers,
promotableFields: promotableFields);
_respectImplicitlyTypedVarInitializers);
typeAnalyzer.dispatchStatement(b);
typeAnalyzer.finish();
expect(typeAnalyzer.errors._accumulatedErrors, expectedErrors);
Expand Down
3 changes: 3 additions & 0 deletions pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ class TypeSystemOperations
return typeSystem.isBottom(type);
}

@override
bool isPropertyPromotable(Object property) => false;

@override
bool isSameType(covariant TypeImpl type1, covariant TypeImpl type2) {
return type1 == type2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ class OperationsCfe
return typeEnvironment.coreTypes.isBottom(type);
}

@override
bool isPropertyPromotable(Object property) => false;

// TODO(cstefantsova): Consider checking for mutual subtypes instead of ==.
@override
bool isSameType(DartType type1, DartType type2) => type1 == type2;
Expand Down
1 change: 1 addition & 0 deletions pkg/front_end/test/spell_checking_list_code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ constant's
constness
constraining
consult
consulted
consumers
container
containers
Expand Down
7 changes: 7 additions & 0 deletions pkg/nnbd_migration/lib/src/decorated_type_operations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ class DecoratedTypeOperations
return false;
}

@override
bool isPropertyPromotable(Object property) {
// TODO(paulberry): research whether we would get higher quality migrations
// if we returned `true` instead.
return false;
}

@override
bool isSameType(DecoratedType type1, DecoratedType type2) {
return type1 == type2;
Expand Down
2 changes: 1 addition & 1 deletion pkg/nnbd_migration/lib/src/edge_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
Element? baseElement = element.declaration;
if (targetType != null) {
var enclosingElement = baseElement!.enclosingElement3;
if (enclosingElement is ClassElement) {
if (enclosingElement is InterfaceElement) {
if (targetType.type.explicitBound is InterfaceType &&
enclosingElement.typeParameters.isNotEmpty) {
substitution = _decoratedClassHierarchy!
Expand Down
18 changes: 18 additions & 0 deletions pkg/nnbd_migration/test/api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8777,6 +8777,24 @@ main() {
await _checkSingleFileChanges(content, expected);
}

Future<void> test_reference_to_mixin_getter() async {
var content = '''
mixin M {
Object f() => this.x;
Object get x => null;
}
''';
var expected = '''
mixin M {
Object? f() => this.x;
Object? get x => null;
}
''';
await _checkSingleFileChanges(content, expected);
}

Future<void> test_regression_40551() async {
var content = '''
class B<T extends Object> { // bound should not be made nullable
Expand Down
13 changes: 5 additions & 8 deletions pkg/test_runner/lib/src/browser_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,6 @@ abstract class Browser {
/// Starts the browser loading the given url
Future<bool> start(String url);

/// Called when the driver page is requested, that is, when the browser first
/// contacts the test server. At this time, it's safe to assume that the
/// browser process has started and opened its first window.
///
/// This is used by [Safari] to ensure the browser window has focus.
Future<Null> onDriverPageRequested() => Future.value();

@override
String toString() => '$runtimeType';
}
Expand All @@ -266,13 +259,15 @@ abstract class WebDriverBrowser extends Browser {
WebDriver? _driver;
final int _port;
final Map<String, dynamic> _desiredCapabilities;
bool _terminated = false;

WebDriverBrowser(this._port, this._desiredCapabilities);

@override
Future<bool> start(String url) async {
_logEvent('Starting $this browser on: $url');
await _createDriver();
if (_terminated) return false;
await _driver!.get(url);
try {
_logEvent('Got version: ${await version}');
Expand All @@ -287,11 +282,13 @@ abstract class WebDriverBrowser extends Browser {
for (var i = 5; i >= 0; i--) {
// Give the driver process some time to be ready to accept connections.
await Future.delayed(const Duration(seconds: 1));
if (_terminated) return;
try {
_driver = await createDriver(
uri: Uri.parse('http://localhost:$_port/'),
desired: _desiredCapabilities);
} catch (error) {
if (_terminated) return;
if (i > 0) {
_logEvent(
'Failed to create driver ($i retries left).\nError: $error');
Expand All @@ -307,6 +304,7 @@ abstract class WebDriverBrowser extends Browser {

@override
Future<bool> close() async {
_terminated = true;
await _driver?.quit();
// Give the driver process some time to be quit the browser.
return true;
Expand Down Expand Up @@ -1255,7 +1253,6 @@ class BrowserTestingServer {
}

Future<String> getDriverPage(String browserId) async {
await testRunner.browserStatus[browserId]?.browser.onDriverPageRequested();
var errorReportingUrl =
"http://$localIp:${errorReportingServer.port}/$browserId";
var driverContent = """
Expand Down
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 2
MINOR 19
PATCH 0
PRERELEASE 230
PRERELEASE 231
PRERELEASE_PATCH 0

0 comments on commit a7848c0

Please sign in to comment.