Skip to content

Commit

Permalink
Version 3.7.0-58.0.dev
Browse files Browse the repository at this point in the history
Merge c433fe1 into dev
  • Loading branch information
Dart CI committed Oct 23, 2024
2 parents 2a4b728 + c433fe1 commit 75c42f3
Show file tree
Hide file tree
Showing 142 changed files with 10,941 additions and 2,534 deletions.
1 change: 1 addition & 0 deletions pkg/_fe_analyzer_shared/analysis_options_no_lints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ analyzer:
- test/inference/inferred_type_arguments/data/**
- test/inference/inferred_variable_types/data/**
- test/inheritance/data/**
- test/metadata/data/**
49 changes: 49 additions & 0 deletions pkg/_fe_analyzer_shared/lib/src/metadata/arguments.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'expressions.dart';
import 'proto.dart';

/// Superclass for named and position arguments.
// TODO(johnniwinther): Merge subclasses into one class?
sealed class Argument {
/// Returns the [Argument] corresponding to this [Argument] in
/// which all [UnresolvedIdentifier]s have been resolved within their scope.
///
/// If this didn't create a new [Argument], `null` is returned.
Argument? resolve();
}

class PositionalArgument extends Argument {
final Expression expression;

PositionalArgument(this.expression);

@override
String toString() => 'PositionalArgument($expression)';

@override
Argument? resolve() {
Expression? newExpression = expression.resolve();
return newExpression == null ? null : new PositionalArgument(newExpression);
}
}

class NamedArgument extends Argument {
final String name;
final Expression expression;

NamedArgument(this.name, this.expression);

@override
String toString() => 'NamedArgument($name,$expression)';

@override
Argument? resolve() {
Expression? newExpression = expression.resolve();
return newExpression == null
? null
: new NamedArgument(name, newExpression);
}
}
13 changes: 13 additions & 0 deletions pkg/_fe_analyzer_shared/lib/src/metadata/ast.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

export 'arguments.dart';
export 'elements.dart';
export 'expressions.dart';
export 'formal_parameters.dart';
export 'proto.dart';
export 'record_fields.dart';
export 'references.dart';
export 'string_literal_parts.dart';
export 'type_annotations.dart';
104 changes: 104 additions & 0 deletions pkg/_fe_analyzer_shared/lib/src/metadata/elements.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'expressions.dart';
import 'proto.dart';

/// Superclass for collection elements.
sealed class Element {
/// Returns the [Element] corresponding to this [Element] in
/// which all [UnresolvedIdentifier]s have been resolved within their scope.
///
/// If this didn't create a new [Element], `null` is returned.
Element? resolve();
}

class ExpressionElement extends Element {
final Expression expression;
final bool isNullAware;

ExpressionElement(this.expression, {required this.isNullAware});

@override
String toString() =>
'ExpressionElement($expression,isNullAware=$isNullAware)';

@override
Element? resolve() {
Expression? newExpression = expression.resolve();
return newExpression == null
? null
: new ExpressionElement(newExpression, isNullAware: isNullAware);
}
}

class MapEntryElement extends Element {
final Expression key;
final Expression value;
final bool isNullAwareKey;
final bool isNullAwareValue;

MapEntryElement(this.key, this.value,
{required this.isNullAwareKey, required this.isNullAwareValue});

@override
String toString() => 'MapEntryElement($key,$value,'
'isNullAwareKey=$isNullAwareValue,isNullAwareValue=$isNullAwareValue)';

@override
Element? resolve() {
Expression? newKey = key.resolve();
Expression? newValue = value.resolve();
return newKey == null && newValue == null
? null
: new MapEntryElement(newKey ?? key, newValue ?? value,
isNullAwareKey: isNullAwareKey, isNullAwareValue: isNullAwareValue);
}
}

class SpreadElement extends Element {
final Expression expression;
final bool isNullAware;

SpreadElement(this.expression, {required this.isNullAware});

@override
String toString() => 'SpreadElement($expression,isNullAware=$isNullAware)';

@override
Element? resolve() {
Expression? newExpression = expression.resolve();
return newExpression == null
? null
: new SpreadElement(newExpression, isNullAware: isNullAware);
}
}

class IfElement extends Element {
final Expression condition;
final Element then;
final Element? otherwise;

IfElement(this.condition, this.then, [this.otherwise]);

@override
String toString() => 'IfElement($condition,$then,$otherwise)';

@override
Element? resolve() {
Expression? newCondition = condition.resolve();
Element? newThen = then.resolve();
Element? newOtherwise = otherwise?.resolve();
if (otherwise != null) {
return newCondition == null && newThen == null && newOtherwise == null
? null
: new IfElement(newCondition ?? condition, newThen ?? then,
newOtherwise ?? otherwise);
} else {
return newCondition == null && newThen == null
? null
: new IfElement(newCondition ?? condition, newThen ?? then);
}
}
}
Loading

0 comments on commit 75c42f3

Please sign in to comment.