Skip to content

Commit

Permalink
Version 3.8.0-43.0.dev
Browse files Browse the repository at this point in the history
Merge 4312e9a into dev
  • Loading branch information
Dart CI committed Jan 28, 2025
2 parents 1442ca0 + 4312e9a commit 8ca1656
Show file tree
Hide file tree
Showing 37 changed files with 416 additions and 305 deletions.
8 changes: 8 additions & 0 deletions pkg/analyzer/lib/src/dart/ast/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,10 @@ final class AssignmentExpressionImpl extends ExpressionImpl
@override
MethodElement2? get element => staticElement?.asElement2;

set element(MethodElement2? element) {
staticElement = element?.asElement;
}

@override
Token get endToken => _rightHandSide.endToken;

Expand Down Expand Up @@ -14170,6 +14174,10 @@ final class PostfixExpressionImpl extends ExpressionImpl
@override
MethodElement2? get element => staticElement?.asElement2;

set element(MethodElement2? value) {
staticElement = value?.asElement;
}

@override
Token get endToken => operator;

Expand Down
58 changes: 50 additions & 8 deletions pkg/analyzer/lib/src/dart/element/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4260,7 +4260,7 @@ class FieldElementImpl extends PropertyInducingElementImpl
bool inheritsCovariant = false;

/// The element corresponding to this fragment.
FieldElement2? _element;
FieldElementImpl2? _element;

/// Initialize a newly created synthetic field element to have the given
/// [name] at the given [offset].
Expand All @@ -4275,7 +4275,7 @@ class FieldElementImpl extends PropertyInducingElementImpl
FieldElement get declaration => this;

@override
FieldElement2 get element {
FieldElementImpl2 get element {
if (_element != null) {
return _element!;
}
Expand All @@ -4290,7 +4290,7 @@ class FieldElementImpl extends PropertyInducingElementImpl
return FieldElementImpl2(firstFragment as FieldElementImpl);
}

set element(FieldElement2 element) => _element = element;
set element(FieldElementImpl2 element) => _element = element;

@override
bool get isAbstract {
Expand Down Expand Up @@ -4555,6 +4555,13 @@ class FormalParameterElementImpl extends PromotableElementImpl2
}
}

/// Creates a synthetic parameter with [name], [type] and [parameterKind].
factory FormalParameterElementImpl.synthetic(
String? name, DartType type, ParameterKind parameterKind) {
var fragment = ParameterElementImpl.synthetic(name, type, parameterKind);
return FormalParameterElementImpl(fragment);
}

@override
FormalParameterElement get baseElement => this;

Expand Down Expand Up @@ -5502,6 +5509,11 @@ class GenericFunctionTypeElementImpl2 extends FunctionTypedElementImpl2
}
}

/// Common base class for all analyzer-internal classes that implement
/// [GetterElement].
abstract class GetterElement2OrMember
implements PropertyAccessorElement2OrMember, GetterElement {}

class GetterElementImpl extends PropertyAccessorElementImpl2
with
FragmentedExecutableElementMixin<GetterFragment>,
Expand All @@ -5510,7 +5522,7 @@ class GetterElementImpl extends PropertyAccessorElementImpl2
FragmentedAnnotatableElementMixin<GetterFragment>,
FragmentedElementMixin<GetterFragment>,
_HasSinceSdkVersionMixin
implements GetterElement {
implements GetterElement2OrMember {
@override
final PropertyAccessorElementImpl firstFragment;

Expand Down Expand Up @@ -9942,7 +9954,10 @@ abstract class PromotableElementImpl2 extends VariableElementImpl2
/// Common base class for all analyzer-internal classes that implement
/// `PropertyAccessorElement2`.
abstract class PropertyAccessorElement2OrMember
implements PropertyAccessorElement2, ExecutableElement2OrMember {}
implements PropertyAccessorElement2, ExecutableElement2OrMember {
@override
PropertyInducingElement2OrMember? get variable3;
}

/// A concrete implementation of a [PropertyAccessorElement].
class PropertyAccessorElementImpl extends ExecutableElementImpl
Expand Down Expand Up @@ -10165,7 +10180,9 @@ abstract class PropertyAccessorElementImpl2 extends ExecutableElementImpl2
String? get name3 => firstFragment.name2;

@override
PropertyInducingElement2? get variable3 => firstFragment.variable2?.element;
PropertyInducingElementImpl2? get variable3 {
return firstFragment.variable2?.element;
}
}

/// Implicit getter for a [PropertyInducingElementImpl].
Expand Down Expand Up @@ -10310,6 +10327,11 @@ abstract class PropertyAccessorElementOrMember
PropertyInducingElementOrMember? get variable2;
}

/// Common base class for all analyzer-internal classes that implement
/// [PropertyInducingElement2].
abstract class PropertyInducingElement2OrMember
implements VariableElement2OrMember, PropertyInducingElement2 {}

/// A concrete implementation of a [PropertyInducingElement].
abstract class PropertyInducingElementImpl
extends NonParameterVariableElementImpl
Expand Down Expand Up @@ -10351,6 +10373,9 @@ abstract class PropertyInducingElementImpl
@override
List<Fragment> get children3 => const [];

@override
PropertyInducingElementImpl2 get element;

@override
Fragment? get enclosingFragment => enclosingElement3 as Fragment;

Expand Down Expand Up @@ -10491,7 +10516,7 @@ abstract class PropertyInducingElementImpl
}

abstract class PropertyInducingElementImpl2 extends VariableElementImpl2
implements PropertyInducingElement2 {
implements PropertyInducingElement2OrMember {
@override
bool get hasInitializer {
return _fragments.any((f) => f.hasInitializer);
Expand Down Expand Up @@ -10529,6 +10554,11 @@ abstract class PropertyInducingElementTypeInference {
TypeImpl perform();
}

/// Common base class for all analyzer-internal classes that implement
/// [SetterElement].
abstract class SetterElement2OrMember
implements PropertyAccessorElement2OrMember, SetterElement {}

class SetterElementImpl extends PropertyAccessorElementImpl2
with
FragmentedExecutableElementMixin<SetterFragment>,
Expand All @@ -10537,7 +10567,7 @@ class SetterElementImpl extends PropertyAccessorElementImpl2
FragmentedAnnotatableElementMixin<SetterFragment>,
FragmentedElementMixin<SetterFragment>,
_HasSinceSdkVersionMixin
implements SetterElement {
implements SetterElement2OrMember {
@override
final PropertyAccessorElementImpl firstFragment;

Expand Down Expand Up @@ -11211,6 +11241,13 @@ class TypeAliasElementImpl2 extends TypeDefiningElementImpl2
@override
TypeImpl get aliasedType => firstFragment.aliasedType;

set aliasedType(TypeImpl value) {
firstFragment.aliasedType = value;
}

/// The aliased type, might be `null` if not yet linked.
DartType? get aliasedTypeRaw => firstFragment.aliasedTypeRaw;

@override
TypeAliasElementImpl2 get baseElement => this;

Expand Down Expand Up @@ -11487,6 +11524,11 @@ class TypeParameterElementImpl2 extends TypeDefiningElementImpl2
@override
TypeImpl? get boundShared => bound;

/// The default value of the type parameter. It is used to provide the
/// corresponding missing type argument in type annotations and as the
/// fall-back type value in type inference.
DartType? get defaultType => firstFragment.defaultType;

@override
List<TypeParameterElementImpl> get fragments {
return [
Expand Down
17 changes: 10 additions & 7 deletions pkg/analyzer/lib/src/dart/element/member.dart
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ class FieldMember extends VariableMember
FieldElementOrMember,
FieldElement2,
VariableElement2OrMember,
PropertyInducingElementOrMember {
PropertyInducingElementOrMember,
PropertyInducingElement2OrMember {
/// Initialize a newly created element to represent a field, based on the
/// [declaration], with applied [substitution].
FieldMember(
Expand Down Expand Up @@ -726,7 +727,8 @@ class FieldMember extends VariableMember

/// A getter element defined in a parameterized type where the values of the
/// type parameters are known.
class GetterMember extends PropertyAccessorMember implements GetterElement {
class GetterMember extends PropertyAccessorMember
implements GetterElement2OrMember {
GetterMember._(
super.declaration,
super.augmentationSubstitution,
Expand Down Expand Up @@ -763,8 +765,8 @@ class GetterMember extends PropertyAccessorMember implements GetterElement {
String? get lookupName => _element2.lookupName;

@override
PropertyInducingElement2? get variable3 =>
variable2.asElement2 as PropertyInducingElement2?;
PropertyInducingElement2OrMember? get variable3 =>
variable2.asElement2 as PropertyInducingElement2OrMember?;

@override
GetterElement get _element2 => declaration.asElement2 as GetterElement;
Expand Down Expand Up @@ -1484,7 +1486,8 @@ abstract class PropertyAccessorMember extends ExecutableMember

/// A setter element defined in a parameterized type where the values of the
/// type parameters are known.
class SetterMember extends PropertyAccessorMember implements SetterElement {
class SetterMember extends PropertyAccessorMember
implements SetterElement2OrMember {
SetterMember._(
super.declaration,
super.augmentationSubstitution,
Expand Down Expand Up @@ -1521,8 +1524,8 @@ class SetterMember extends PropertyAccessorMember implements SetterElement {
String? get lookupName => _element2.lookupName;

@override
PropertyInducingElement2? get variable3 =>
variable2.asElement2 as PropertyInducingElement2?;
PropertyInducingElement2OrMember? get variable3 =>
variable2.asElement2 as PropertyInducingElement2OrMember?;

@override
SetterElement get _element2 => declaration.asElement2 as SetterElement;
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/element/type_algebra.dart
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ abstract class _TypeSubstitutor
return NamedTypeBuilder(
type.linker,
type.typeSystem,
type.element,
type.element3,
arguments,
type.nullabilitySuffix,
);
Expand Down
27 changes: 27 additions & 0 deletions pkg/analyzer/lib/src/dart/element/type_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,19 @@ class TypeSystemImpl implements TypeSystem {
leftType, operatorElement, [rightType], currentType);
}

/// Determine the type of a binary expression with the given [operator] whose
/// left operand has the type [leftType] and whose right operand has the type
/// [rightType], given that resolution has so far produced the [currentType].
DartType refineBinaryExpressionType2(
DartType leftType,
TokenType operator,
DartType rightType,
DartType currentType,
MethodElement2? operatorElement) {
return refineBinaryExpressionType(
leftType, operator, rightType, currentType, operatorElement?.asElement);
}

/// Determines the context type for the parameters of a method invocation
/// where the type of the target is [targetType], the method being invoked is
/// [methodElement], the context surrounding the method invocation is
Expand All @@ -1693,6 +1706,20 @@ class TypeSystemImpl implements TypeSystem {
}
}

/// Determines the context type for the parameters of a method invocation
/// where the type of the target is [targetType], the method being invoked is
/// [methodElement], the context surrounding the method invocation is
/// [invocationContext], and the context type produced so far by resolution is
/// [currentType].
TypeImpl refineNumericInvocationContext2(
DartType? targetType,
Element2? methodElement,
DartType invocationContext,
TypeImpl currentType) {
return refineNumericInvocationContext(
targetType, methodElement?.asElement, invocationContext, currentType);
}

/// Determines the type of a method invocation where the type of the target is
/// [targetType], the method being invoked is [methodElement], the types of
/// the arguments passed to the method are [argumentTypes], and the type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// 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.

// ignore_for_file: analyzer_use_new_elements

import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
import 'package:_fe_analyzer_shared/src/types/shared_type.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
Expand All @@ -21,7 +19,6 @@ import 'package:analyzer/src/dart/element/type_system.dart';
import 'package:analyzer/src/dart/resolver/type_property_resolver.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/utilities/extensions/element.dart';

/// Helper for resolving [AssignmentExpression]s.
class AssignmentExpressionResolver {
Expand Down Expand Up @@ -56,8 +53,8 @@ class AssignmentExpressionResolver {
var left = node.leftHandSide;
var right = node.rightHandSide;

var readElement = leftResolution.readElement;
var writeElement = leftResolution.writeElement;
var readElement = leftResolution.readElement2;
var writeElement = leftResolution.writeElement2;
var writeElement2 = leftResolution.writeElement2;

if (hasRead) {
Expand Down Expand Up @@ -86,7 +83,7 @@ class AssignmentExpressionResolver {
TypeImpl rhsContext;
{
var leftType = node.writeType;
if (writeElement is VariableElement) {
if (writeElement is VariableElement2) {
leftType = _resolver.localVariableTypeProvider
.getType(left as SimpleIdentifierImpl, isRead: false);
}
Expand Down Expand Up @@ -195,11 +192,11 @@ class AssignmentExpressionResolver {
case TokenType.BAR_BAR_EQ:
return _typeProvider.boolType;
default:
var method = node.staticElement;
var method = node.element;
if (method != null) {
var parameters = method.parameters;
var parameters = method.formalParameters;
if (parameters.isNotEmpty) {
return _typeSystem.refineNumericInvocationContext(
return _typeSystem.refineNumericInvocationContext2(
leftType,
method,
leftType,
Expand Down Expand Up @@ -255,7 +252,7 @@ class AssignmentExpressionResolver {
propertyErrorEntity: operator,
nameErrorEntity: operator,
);
node.staticElement = result.getter2?.asElement as MethodElement?;
node.element = result.getter2 as MethodElement2?;
if (result.needsGetterError) {
_errorReporter.atToken(
operator,
Expand All @@ -282,12 +279,12 @@ class AssignmentExpressionResolver {
assignedType = _typeProvider.boolType;
} else {
var leftType = node.readType!;
var operatorElement = node.staticElement;
var operatorElement = node.element;
if (leftType is DynamicType) {
assignedType = DynamicTypeImpl.instance;
} else if (operatorElement != null) {
var rightType = rightHandSide.typeOrThrow;
assignedType = _typeSystem.refineBinaryExpressionType(
assignedType = _typeSystem.refineBinaryExpressionType2(
leftType,
operator,
rightType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// 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.

// ignore_for_file: analyzer_use_new_elements

import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
Expand Down Expand Up @@ -80,7 +78,7 @@ class FunctionExpressionInvocationResolver {
var result = _typePropertyResolver.resolve(
receiver: function,
receiverType: receiverType,
name: FunctionElement.CALL_METHOD_NAME,
name: MethodElement2.CALL_METHOD_NAME,
propertyErrorEntity: function,
nameErrorEntity: function,
);
Expand Down Expand Up @@ -168,7 +166,7 @@ class FunctionExpressionInvocationResolver {
{required TypeImpl contextType}) {
var result = _extensionResolver.getOverrideMember(
function,
FunctionElement.CALL_METHOD_NAME,
MethodElement2.CALL_METHOD_NAME,
);
var callElement = result.getter2?.asElement;
node.staticElement = callElement;
Expand Down
Loading

0 comments on commit 8ca1656

Please sign in to comment.