Skip to content

Commit

Permalink
Version 3.3.0-73.0.dev
Browse files Browse the repository at this point in the history
Merge 289302b into dev
  • Loading branch information
Dart CI committed Oct 28, 2023
2 parents 5c7dcac + 289302b commit 5dbee20
Show file tree
Hide file tree
Showing 20 changed files with 804 additions and 577 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ enum E {
''', matchFixMessage: "Create constructor 'E'");
}

@FailingTest(reason: 'parameter types should be inferred')
Future<void> test_undefined_enum_constructor_unnamed_parameters() async {
await resolveTestCode('''
enum E {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,31 @@ class ClassToMove {}
>>>>>>>>>> lib/main.dart
class A {}
class B {}
''';
await _singleDeclaration(
originalSource: originalSource,
expected: expected,
declarationName: declarationName,
);
}

Future<void> test_kind_extensionType() async {
var originalSource = '''
class A {}
extensionType ExtensionTypeToMove^(int i) {}
class B {}
''';
var declarationName = 'ExtensionTypeToMove';

var expected = '''
>>>>>>>>>> lib/extension_type_to_move.dart created
extensionType ExtensionTypeToMove(int i) {}
>>>>>>>>>> lib/main.dart
class A {}
class B {}
''';
await _singleDeclaration(
Expand Down
3 changes: 3 additions & 0 deletions pkg/analyzer/lib/dart/element/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,9 @@ abstract class ExecutableElement implements FunctionTypedElement {
/// If `true`, declaration has the explicit `augment` modifier.
bool get isAugmentation;

/// Whether the executable element is an extension type member.
bool get isExtensionTypeMember;

/// Whether the executable element is external.
///
/// Executable elements are external if they are explicitly marked as such
Expand Down
64 changes: 39 additions & 25 deletions pkg/analyzer/lib/src/dart/element/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2811,6 +2811,15 @@ abstract class ExecutableElementImpl extends _ExistingElementImpl
setModifier(Modifier.ASYNCHRONOUS, isAsynchronous);
}

@override
bool get isExtensionTypeMember {
return hasModifier(Modifier.EXTENSION_TYPE_MEMBER);
}

set isExtensionTypeMember(bool value) {
setModifier(Modifier.EXTENSION_TYPE_MEMBER, value);
}

@override
bool get isExternal {
return hasModifier(Modifier.EXTERNAL);
Expand Down Expand Up @@ -5140,95 +5149,99 @@ class Modifier implements Comparable<Modifier> {
/// Indicates that the element is an enum constant field.
static const Modifier ENUM_CONSTANT = Modifier('ENUM_CONSTANT', 9);

/// Indicates that the element is an extension type member.
static const Modifier EXTENSION_TYPE_MEMBER =
Modifier('EXTENSION_TYPE_MEMBER', 10);

/// Indicates that a class element was defined by an enum declaration.
static const Modifier EXTERNAL = Modifier('EXTERNAL', 10);
static const Modifier EXTERNAL = Modifier('EXTERNAL', 11);

/// Indicates that the modifier 'factory' was applied to the element.
static const Modifier FACTORY = Modifier('FACTORY', 11);
static const Modifier FACTORY = Modifier('FACTORY', 12);

/// Indicates that the modifier 'final' was applied to the element.
static const Modifier FINAL = Modifier('FINAL', 12);
static const Modifier FINAL = Modifier('FINAL', 13);

/// Indicates that an executable element has a body marked as being a
/// generator.
static const Modifier GENERATOR = Modifier('GENERATOR', 13);
static const Modifier GENERATOR = Modifier('GENERATOR', 14);

/// Indicates that the pseudo-modifier 'get' was applied to the element.
static const Modifier GETTER = Modifier('GETTER', 14);
static const Modifier GETTER = Modifier('GETTER', 15);

/// A flag used for libraries indicating that the variable has an explicit
/// initializer.
static const Modifier HAS_INITIALIZER = Modifier('HAS_INITIALIZER', 15);
static const Modifier HAS_INITIALIZER = Modifier('HAS_INITIALIZER', 16);

/// A flag used for libraries indicating that the defining compilation unit
/// has a `part of` directive, meaning that this unit should be a part,
/// but is used as a library.
static const Modifier HAS_PART_OF_DIRECTIVE =
Modifier('HAS_PART_OF_DIRECTIVE', 16);
Modifier('HAS_PART_OF_DIRECTIVE', 17);

/// Indicates that the value of [Element.sinceSdkVersion] was computed.
static const Modifier HAS_SINCE_SDK_VERSION_COMPUTED =
Modifier('HAS_SINCE_SDK_VERSION_COMPUTED', 17);
Modifier('HAS_SINCE_SDK_VERSION_COMPUTED', 18);

/// [HAS_SINCE_SDK_VERSION_COMPUTED] and the value was not `null`.
static const Modifier HAS_SINCE_SDK_VERSION_VALUE =
Modifier('HAS_SINCE_SDK_VERSION_VALUE', 18);
Modifier('HAS_SINCE_SDK_VERSION_VALUE', 19);

/// Indicates that the associated element did not have an explicit type
/// associated with it. If the element is an [ExecutableElement], then the
/// type being referred to is the return type.
static const Modifier IMPLICIT_TYPE = Modifier('IMPLICIT_TYPE', 19);
static const Modifier IMPLICIT_TYPE = Modifier('IMPLICIT_TYPE', 20);

/// Indicates that the modifier 'inline' was applied to the element.
static const Modifier INLINE = Modifier('INLINE', 20);
static const Modifier INLINE = Modifier('INLINE', 21);

/// Indicates that the modifier 'interface' was applied to the element.
static const Modifier INTERFACE = Modifier('INTERFACE', 21);
static const Modifier INTERFACE = Modifier('INTERFACE', 22);

/// Indicates that the method invokes the super method with the same name.
static const Modifier INVOKES_SUPER_SELF = Modifier('INVOKES_SUPER_SELF', 22);
static const Modifier INVOKES_SUPER_SELF = Modifier('INVOKES_SUPER_SELF', 23);

/// Indicates that modifier 'lazy' was applied to the element.
static const Modifier LATE = Modifier('LATE', 23);
static const Modifier LATE = Modifier('LATE', 24);

/// Indicates that a class is a macro builder.
static const Modifier MACRO = Modifier('MACRO', 24);
static const Modifier MACRO = Modifier('MACRO', 25);

/// Indicates that a class is a mixin application.
static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 25);
static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 26);

/// Indicates that a class is a mixin class.
static const Modifier MIXIN_CLASS = Modifier('MIXIN_CLASS', 26);
static const Modifier MIXIN_CLASS = Modifier('MIXIN_CLASS', 27);

static const Modifier PROMOTABLE = Modifier('IS_PROMOTABLE', 27);
static const Modifier PROMOTABLE = Modifier('IS_PROMOTABLE', 28);

/// Indicates whether the type of a [PropertyInducingElementImpl] should be
/// used to infer the initializer. We set it to `false` if the type was
/// inferred from the initializer itself.
static const Modifier SHOULD_USE_TYPE_FOR_INITIALIZER_INFERENCE =
Modifier('SHOULD_USE_TYPE_FOR_INITIALIZER_INFERENCE', 28);
Modifier('SHOULD_USE_TYPE_FOR_INITIALIZER_INFERENCE', 29);

/// Indicates that the modifier 'sealed' was applied to the element.
static const Modifier SEALED = Modifier('SEALED', 29);
static const Modifier SEALED = Modifier('SEALED', 30);

/// Indicates that the pseudo-modifier 'set' was applied to the element.
static const Modifier SETTER = Modifier('SETTER', 30);
static const Modifier SETTER = Modifier('SETTER', 31);

/// See [TypeParameterizedElement.isSimplyBounded].
static const Modifier SIMPLY_BOUNDED = Modifier('SIMPLY_BOUNDED', 31);
static const Modifier SIMPLY_BOUNDED = Modifier('SIMPLY_BOUNDED', 32);

/// Indicates that the modifier 'static' was applied to the element.
static const Modifier STATIC = Modifier('STATIC', 32);
static const Modifier STATIC = Modifier('STATIC', 33);

/// Indicates that the element does not appear in the source code but was
/// implicitly created. For example, if a class does not define any
/// constructors, an implicit zero-argument constructor will be created and it
/// will be marked as being synthetic.
static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 33);
static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 34);

/// Indicates that the element was appended to this enclosing element to
/// simulate temporary the effect of applying augmentation.
static const Modifier TEMP_AUGMENTATION = Modifier('TEMP_AUGMENTATION', 34);
static const Modifier TEMP_AUGMENTATION = Modifier('TEMP_AUGMENTATION', 35);

static const List<Modifier> values = [
ABSTRACT,
Expand All @@ -5240,6 +5253,7 @@ class Modifier implements Comparable<Modifier> {
DEFERRED,
ENUM,
ENUM_CONSTANT,
EXTENSION_TYPE_MEMBER,
EXTERNAL,
FACTORY,
FINAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ class InheritanceManager3 {
for (final entry in getInterface(interface.element).map.entries) {
final name = entry.key;
final executable = ExecutableMember.from2(entry.value, substitution);
if (executable.enclosingElement is ExtensionTypeElement) {
if (executable.isExtensionTypeMember) {
(extensionCandidates[name] ??= []).add(executable);
} else {
(notExtensionCandidates[name] ??= []).add(executable);
Expand Down
3 changes: 3 additions & 0 deletions pkg/analyzer/lib/src/dart/element/member.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ abstract class ExecutableMember extends Member implements ExecutableElement {
@override
bool get isAugmentation => declaration.isAugmentation;

@override
bool get isExtensionTypeMember => declaration.isExtensionTypeMember;

@override
bool get isExternal => declaration.isExternal;

Expand Down
24 changes: 14 additions & 10 deletions pkg/analyzer/lib/src/generated/resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2424,16 +2424,6 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
parameters: constructorElement.parameters,
errorReporter: errorReporter,
);
for (var argument in argumentList.arguments) {
analyzeExpression(argument, argument.staticParameterElement?.type);
popRewrite();
}
arguments.typeArguments?.accept(this);

var whyNotPromotedList =
<Map<DartType, NonPromotionReason> Function()>[];
checkForArgumentTypesNotAssignableInList(
argumentList, whyNotPromotedList);
} else if (definingLibrary.featureSet
.isEnabled(Feature.enhanced_enums)) {
var requiredParameterCount = constructorElement.parameters
Expand All @@ -2451,6 +2441,20 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
}
}

var arguments = node.arguments;
if (arguments != null) {
var argumentList = arguments.argumentList;
for (var argument in argumentList.arguments) {
analyzeExpression(argument, argument.staticParameterElement?.type);
popRewrite();
}
arguments.typeArguments?.accept(this);

var whyNotPromotedList = <Map<DartType, NonPromotionReason> Function()>[];
checkForArgumentTypesNotAssignableInList(
argumentList, whyNotPromotedList);
}

elementResolver.visitEnumConstantDeclaration(node);
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/analyzer/lib/src/summary2/element_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,13 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
element.methods = holder.methods;
element.typeParameters = holder.typeParameters;

final executables = const <ExecutableElementImpl>[]
.followedBy(element.accessors)
.followedBy(element.methods);
for (final executable in executables) {
executable.isExtensionTypeMember = true;
}

node.implementsClause?.accept(this);

// TODO(scheglov) We cannot do this anymore.
Expand Down
22 changes: 14 additions & 8 deletions pkg/analyzer/lib/src/summary2/element_flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,11 @@ class MethodElementFlags {
static const int _isAbstract = 1 << 2;
static const int _isAsynchronous = 1 << 3;
static const int _isAugmentation = 1 << 4;
static const int _isExternal = 1 << 5;
static const int _isGenerator = 1 << 6;
static const int _isStatic = 1 << 7;
static const int _isSynthetic = 1 << 8;
static const int _isExtensionTypeMember = 1 << 5;
static const int _isExternal = 1 << 6;
static const int _isGenerator = 1 << 7;
static const int _isStatic = 1 << 8;
static const int _isSynthetic = 1 << 9;

static void read(SummaryDataReader reader, MethodElementImpl element) {
final bits = reader.readUInt30();
Expand All @@ -266,6 +267,7 @@ class MethodElementFlags {
element.isAbstract = (bits & _isAbstract) != 0;
element.isAsynchronous = (bits & _isAsynchronous) != 0;
element.isAugmentation = (bits & _isAugmentation) != 0;
element.isExtensionTypeMember = (bits & _isExtensionTypeMember) != 0;
element.isExternal = (bits & _isExternal) != 0;
element.isGenerator = (bits & _isGenerator) != 0;
element.isStatic = (bits & _isStatic) != 0;
Expand All @@ -279,6 +281,7 @@ class MethodElementFlags {
result |= element.isAbstract ? _isAbstract : 0;
result |= element.isAsynchronous ? _isAsynchronous : 0;
result |= element.isAugmentation ? _isAugmentation : 0;
result |= element.isExtensionTypeMember ? _isExtensionTypeMember : 0;
result |= element.isExternal ? _isExternal : 0;
result |= element.isGenerator ? _isGenerator : 0;
result |= element.isStatic ? _isStatic : 0;
Expand Down Expand Up @@ -343,10 +346,11 @@ class PropertyAccessorElementFlags {
static const int _hasImplicitReturnType = 1 << 4;
static const int _isAbstract = 1 << 5;
static const int _isAsynchronous = 1 << 6;
static const int _isExternal = 1 << 7;
static const int _isGenerator = 1 << 8;
static const int _isStatic = 1 << 9;
static const int _isTempAugmentation = 1 << 10;
static const int _isExtensionTypeMember = 1 << 7;
static const int _isExternal = 1 << 8;
static const int _isGenerator = 1 << 9;
static const int _isStatic = 1 << 10;
static const int _isTempAugmentation = 1 << 11;

static void read(
SummaryDataReader reader,
Expand All @@ -360,6 +364,7 @@ class PropertyAccessorElementFlags {
element.hasImplicitReturnType = (byte & _hasImplicitReturnType) != 0;
element.isAbstract = (byte & _isAbstract) != 0;
element.isAsynchronous = (byte & _isAsynchronous) != 0;
element.isExtensionTypeMember = (byte & _isExtensionTypeMember) != 0;
element.isExternal = (byte & _isExternal) != 0;
element.isGenerator = (byte & _isGenerator) != 0;
element.isStatic = (byte & _isStatic) != 0;
Expand All @@ -375,6 +380,7 @@ class PropertyAccessorElementFlags {
result |= element.hasImplicitReturnType ? _hasImplicitReturnType : 0;
result |= element.isAbstract ? _isAbstract : 0;
result |= element.isAsynchronous ? _isAsynchronous : 0;
result |= element.isExtensionTypeMember ? _isExtensionTypeMember : 0;
result |= element.isExternal ? _isExternal : 0;
result |= element.isGenerator ? _isGenerator : 0;
result |= element.isStatic ? _isStatic : 0;
Expand Down
Loading

0 comments on commit 5dbee20

Please sign in to comment.