Skip to content

Commit

Permalink
Version 3.3.0-158.0.dev
Browse files Browse the repository at this point in the history
Merge b9dc72f into dev
  • Loading branch information
Dart CI committed Nov 22, 2023
2 parents c6a0122 + b9dc72f commit df958dc
Show file tree
Hide file tree
Showing 159 changed files with 4,265 additions and 1,771 deletions.
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ vars = {
# Checkout extra javascript engines for testing or benchmarking.
# d8, the V8 shell, is always checked out.
"checkout_javascript_engines": False,
"d8_tag": "version:12.1.97",
"d8_tag": "version:12.1.131",
"jsshell_tag": "version:120.0",

# https://chrome-infra-packages.appspot.com/p/fuchsia/third_party/clang
Expand Down Expand Up @@ -129,7 +129,7 @@ vars = {
"characters_rev": "7633a16a22c626e19ca750223237396315268a06",
"cli_util_rev": "500dffab6e00332c4c0b814359f06c8a9c3a5573",
"clock_rev": "f975668839f45bad561d6227f88297bbbcff03fa",
"collection_rev": "f309148623c4755ce9d6c00850092458325058ca",
"collection_rev": "2d57a82ad079fe2d127f5a9b188170de2f5cdedc",
"convert_rev": "35031701fab532ada1a75c51155c0a6801055d88",
"crypto_rev": "f3e64d234416466683e29a4b20cf751684cbae6a",
"csslib_rev": "17346e528b19c09b2d20589e0ffa0f01a5ad54ad",
Expand Down
4 changes: 2 additions & 2 deletions pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ enum ExperimentalFlag {

inlineClass(
name: 'inline-class',
isEnabledByDefault: false,
isEnabledByDefault: true,
isExpired: false,
experimentEnabledVersion: defaultLanguageVersion,
experimentEnabledVersion: const Version(3, 3),
experimentReleasedVersion: const Version(3, 3)),

macros(
Expand Down
27 changes: 19 additions & 8 deletions pkg/_fe_analyzer_shared/lib/src/macros/api/introspection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ abstract interface class IntrospectableEnumDeclaration
/// The class for introspecting on an extension.
///
/// Note that extensions do not actually introduce a new type, but we model them
/// as [ParameterizedTypeDeclaration]s anyways, because they generally look
/// as [ParameterizedTypeDeclaration]s anyway, because they generally look
/// exactly like other type declarations, and are treated the same.
abstract interface class ExtensionDeclaration
implements ParameterizedTypeDeclaration, Declaration {
Expand All @@ -231,6 +231,17 @@ abstract interface class ExtensionDeclaration
abstract interface class IntrospectableExtensionDeclaration
implements ExtensionDeclaration, IntrospectableType {}

/// The class for introspecting on an extension type.
abstract interface class ExtensionTypeDeclaration
implements ParameterizedTypeDeclaration, Declaration {
/// The type that appears on the `on` clause of this extension type.
TypeAnnotation get onType;
}

/// An introspectable extension type declaration.
abstract interface class IntrospectableExtensionTypeDeclaration
implements ExtensionTypeDeclaration, IntrospectableType {}

/// Mixin introspection information.
///
/// Information about fields and methods must be retrieved from the `builder`
Expand Down Expand Up @@ -260,9 +271,6 @@ abstract interface class TypeAliasDeclaration

/// Function introspection information.
abstract interface class FunctionDeclaration implements Declaration {
/// Whether this function has an `abstract` modifier.
bool get hasAbstract;

/// Whether or not this function has a body.
///
/// This is useful when augmenting a function, so you know whether an
Expand Down Expand Up @@ -309,13 +317,13 @@ abstract interface class ConstructorDeclaration implements MethodDeclaration {

/// Variable introspection information.
abstract interface class VariableDeclaration implements Declaration {
/// Whether this field has an `external` modifier.
/// Whether this variable has an `external` modifier.
bool get hasExternal;

/// Whether this field has a `final` modifier.
/// Whether this variable has a `final` modifier.
bool get hasFinal;

/// Whether this field has a `late` modifier.
/// Whether this variable has a `late` modifier.
bool get hasLate;

/// The type of this field.
Expand All @@ -324,7 +332,10 @@ abstract interface class VariableDeclaration implements Declaration {

/// Field introspection information.
abstract interface class FieldDeclaration
implements VariableDeclaration, MemberDeclaration {}
implements VariableDeclaration, MemberDeclaration {
/// Whether this field has an `abstract` modifier.
bool get hasAbstract;
}

/// General parameter introspection information, see the subtypes
/// [FunctionTypeParameter] and [ParameterDeclaration].
Expand Down
25 changes: 25 additions & 0 deletions pkg/_fe_analyzer_shared/lib/src/macros/api/macros.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,28 @@ abstract interface class ExtensionDefinitionMacro implements Macro {
IntrospectableExtensionDeclaration extension,
TypeDefinitionBuilder builder);
}

/// The interface for [Macro]s that can be applied to any extension type
/// declaration, and want to contribute new type declarations to the program.
abstract interface class ExtensionTypeTypesMacro implements Macro {
FutureOr<void> buildTypesForExtensionType(
ExtensionTypeDeclaration extension, TypeBuilder builder);
}

/// The interface for [Macro]s that can be applied to any extension type
/// declaration, and want to contribute new non-type declarations to the
/// program.
abstract interface class ExtensionTypeDeclarationsMacro implements Macro {
FutureOr<void> buildDeclarationsForExtensionType(
IntrospectableExtensionTypeDeclaration extension,
MemberDeclarationBuilder builder);
}

/// The interface for [Macro]s that can be applied to any extension type
/// declaration, and want to augment the definitions of the members of that
/// extension.
abstract interface class ExtensionTypeDefinitionMacro implements Macro {
FutureOr<void> buildDefinitionForExtensionType(
IntrospectableExtensionTypeDeclaration extension,
TypeDefinitionBuilder builder);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// 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 'package:_fe_analyzer_shared/src/macros/api.dart';
import 'package:_fe_analyzer_shared/src/macros/executor.dart';
import 'package:_fe_analyzer_shared/src/macros/executor/builder_impls.dart';
import 'package:_fe_analyzer_shared/src/macros/executor/introspection_impls.dart';
import 'package:_fe_analyzer_shared/src/macros/api.dart';

/// Runs [macro] in the types phase and returns a [MacroExecutionResult].
Future<MacroExecutionResult> executeTypesMacro(
Expand Down Expand Up @@ -44,6 +44,8 @@ Future<MacroExecutionResult> executeTypesMacro(
target.identifier as IdentifierImpl, introspector));
case (ExtensionDeclaration target, ExtensionTypesMacro macro):
await macro.buildTypesForExtension(target, typeBuilder);
case (ExtensionTypeDeclaration target, ExtensionTypeTypesMacro macro):
await macro.buildTypesForExtensionType(target, typeBuilder);
case (MixinDeclaration target, MixinTypesMacro macro):
await macro.buildTypesForMixin(
target,
Expand Down Expand Up @@ -120,6 +122,16 @@ Future<MacroExecutionResult> executeDeclarationsMacro(Macro macro,
'introspectable in the declarations phase.');
}
await macro.buildDeclarationsForExtension(target, memberBuilder);
case (
ExtensionTypeDeclaration target,
ExtensionTypeDeclarationsMacro macro
):
if (target is! IntrospectableExtensionTypeDeclarationImpl) {
throw new ArgumentError(
'Extension type declarations annotated with a macro should be '
'introspectable in the declarations phase.');
}
await macro.buildDeclarationsForExtensionType(target, memberBuilder);
case (MixinDeclaration target, MixinDeclarationsMacro macro):
if (target is! IntrospectableMixinDeclarationImpl) {
throw new ArgumentError(
Expand Down Expand Up @@ -197,6 +209,16 @@ Future<MacroExecutionResult> executeDefinitionMacro(Macro macro, Object target,
'introspectable in the definitions phase.');
}
await macro.buildDefinitionForExtension(target, typeBuilder);
case (
ExtensionTypeDeclaration target,
ExtensionTypeDefinitionMacro macro
):
if (target is! IntrospectableExtensionTypeDeclaration) {
throw new ArgumentError(
'Extension declarations annotated with a macro should be '
'introspectable in the definitions phase.');
}
await macro.buildDefinitionForExtensionType(target, typeBuilder);
case (MixinDeclaration target, MixinDefinitionMacro macro):
if (target is! IntrospectableMixinDeclaration) {
throw new ArgumentError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,6 @@ class TypeParameterDeclarationImpl extends DeclarationImpl

class FunctionDeclarationImpl extends DeclarationImpl
implements FunctionDeclaration {
@override
final bool hasAbstract;

@override
final bool hasBody;

Expand Down Expand Up @@ -521,7 +518,6 @@ class FunctionDeclarationImpl extends DeclarationImpl
required super.identifier,
required super.library,
required super.metadata,
required this.hasAbstract,
required this.hasBody,
required this.hasExternal,
required this.isGetter,
Expand All @@ -538,7 +534,6 @@ class FunctionDeclarationImpl extends DeclarationImpl
super.serializeUncached(serializer);

serializer
..addBool(hasAbstract)
..addBool(hasBody)
..addBool(hasExternal)
..addBool(isGetter)
Expand Down Expand Up @@ -582,7 +577,6 @@ class MethodDeclarationImpl extends FunctionDeclarationImpl
required super.library,
required super.metadata,
// Function fields.
required super.hasAbstract,
required super.hasBody,
required super.hasExternal,
required super.isGetter,
Expand Down Expand Up @@ -621,7 +615,6 @@ class ConstructorDeclarationImpl extends MethodDeclarationImpl
required super.library,
required super.metadata,
// Function fields.
required super.hasAbstract,
required super.hasBody,
required super.hasExternal,
required super.isGetter,
Expand Down Expand Up @@ -692,6 +685,9 @@ class FieldDeclarationImpl extends VariableDeclarationImpl
@override
final IdentifierImpl definingType;

@override
final bool hasAbstract;

@override
final bool isStatic;

Expand All @@ -708,6 +704,7 @@ class FieldDeclarationImpl extends VariableDeclarationImpl
required super.type,
// Field fields.
required this.definingType,
required this.hasAbstract,
required this.isStatic,
});

Expand All @@ -719,7 +716,9 @@ class FieldDeclarationImpl extends VariableDeclarationImpl
super.serializeUncached(serializer);

definingType.serialize(serializer);
serializer.addBool(isStatic);
serializer
..addBool(hasAbstract)
..addBool(isStatic);
}
}

Expand Down Expand Up @@ -957,6 +956,44 @@ class ExtensionDeclarationImpl extends ParameterizedTypeDeclarationImpl
}
}

mixin _IntrospectableExtensionType on ExtensionTypeDeclarationImpl
implements IntrospectableType, IntrospectableExtensionTypeDeclaration {
@override
RemoteInstanceKind get kind =>
RemoteInstanceKind.introspectableExtensionTypeDeclaration;
}

class IntrospectableExtensionTypeDeclarationImpl = ExtensionTypeDeclarationImpl
with _IntrospectableExtensionType;

class ExtensionTypeDeclarationImpl extends ParameterizedTypeDeclarationImpl
implements ExtensionTypeDeclaration {
@override
final TypeAnnotationImpl onType;

@override
RemoteInstanceKind get kind => RemoteInstanceKind.extensionTypeDeclaration;

ExtensionTypeDeclarationImpl({
// Declaration fields.
required super.id,
required super.identifier,
required super.library,
required super.metadata,
// ParameterizedTypeDeclaration fields.
required super.typeParameters,
// ExtensionTypeDeclaration fields.
required this.onType,
});

@override
void serializeUncached(Serializer serializer) {
super.serializeUncached(serializer);

onType.serialize(serializer);
}
}

mixin _IntrospectableMixin on MixinDeclarationImpl
implements IntrospectableMixinDeclaration {
@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ enum RemoteInstanceKind {
enumDeclaration,
enumValueDeclaration,
extensionDeclaration,
extensionTypeDeclaration,
fieldDeclaration,
functionDeclaration,
functionTypeAnnotation,
Expand All @@ -116,6 +117,7 @@ enum RemoteInstanceKind {
introspectableClassDeclaration,
introspectableEnumDeclaration,
introspectableExtensionDeclaration,
introspectableExtensionTypeDeclaration,
introspectableMixinDeclaration,
library,
methodDeclaration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ extension DeserializerExtensions on Deserializer {
(this..moveNext())._expectEnumValueDeclaration(id),
RemoteInstanceKind.extensionDeclaration =>
(this..moveNext())._expectExtensionDeclaration(id),
RemoteInstanceKind.extensionTypeDeclaration =>
(this..moveNext())._expectExtensionTypeDeclaration(id),
RemoteInstanceKind.mixinDeclaration =>
(this..moveNext())._expectMixinDeclaration(id),
RemoteInstanceKind.constructorDeclaration =>
Expand All @@ -55,6 +57,8 @@ extension DeserializerExtensions on Deserializer {
(this..moveNext())._expectIntrospectableEnumDeclaration(id),
RemoteInstanceKind.introspectableExtensionDeclaration =>
(this..moveNext())._expectIntrospectableExtensionDeclaration(id),
RemoteInstanceKind.introspectableExtensionTypeDeclaration =>
(this..moveNext())._expectIntrospectableExtensionTypeDeclaration(id),
RemoteInstanceKind.introspectableMixinDeclaration =>
(this..moveNext())._expectIntrospectableMixinDeclaration(id),
RemoteInstanceKind.library => (this..moveNext())._expectLibrary(id),
Expand Down Expand Up @@ -193,7 +197,6 @@ extension DeserializerExtensions on Deserializer {
identifier: expectRemoteInstance(),
library: RemoteInstance.deserialize(this),
metadata: (this..moveNext())._expectRemoteInstanceList(),
hasAbstract: (this..moveNext()).expectBool(),
hasBody: (this..moveNext()).expectBool(),
hasExternal: (this..moveNext()).expectBool(),
isGetter: (this..moveNext()).expectBool(),
Expand All @@ -211,7 +214,6 @@ extension DeserializerExtensions on Deserializer {
identifier: expectRemoteInstance(),
library: RemoteInstance.deserialize(this),
metadata: (this..moveNext())._expectRemoteInstanceList(),
hasAbstract: (this..moveNext()).expectBool(),
hasBody: (this..moveNext()).expectBool(),
hasExternal: (this..moveNext()).expectBool(),
isGetter: (this..moveNext()).expectBool(),
Expand All @@ -231,7 +233,6 @@ extension DeserializerExtensions on Deserializer {
identifier: expectRemoteInstance(),
library: RemoteInstance.deserialize(this),
metadata: (this..moveNext())._expectRemoteInstanceList(),
hasAbstract: (this..moveNext()).expectBool(),
hasBody: (this..moveNext()).expectBool(),
hasExternal: (this..moveNext()).expectBool(),
isGetter: (this..moveNext()).expectBool(),
Expand Down Expand Up @@ -274,6 +275,7 @@ extension DeserializerExtensions on Deserializer {
hasLate: (this..moveNext()).expectBool(),
type: RemoteInstance.deserialize(this),
definingType: RemoteInstance.deserialize(this),
hasAbstract: (this..moveNext()).expectBool(),
isStatic: (this..moveNext()).expectBool(),
);

Expand Down Expand Up @@ -410,6 +412,26 @@ extension DeserializerExtensions on Deserializer {
onType: RemoteInstance.deserialize(this),
);

ExtensionTypeDeclarationImpl _expectExtensionTypeDeclaration(int id) =>
new ExtensionTypeDeclarationImpl(
id: id,
identifier: expectRemoteInstance(),
library: RemoteInstance.deserialize(this),
metadata: (this..moveNext())._expectRemoteInstanceList(),
typeParameters: (this..moveNext())._expectRemoteInstanceList(),
onType: RemoteInstance.deserialize(this),
);
IntrospectableExtensionTypeDeclarationImpl
_expectIntrospectableExtensionTypeDeclaration(int id) =>
new IntrospectableExtensionTypeDeclarationImpl(
id: id,
identifier: expectRemoteInstance(),
library: RemoteInstance.deserialize(this),
metadata: (this..moveNext())._expectRemoteInstanceList(),
typeParameters: (this..moveNext())._expectRemoteInstanceList(),
onType: RemoteInstance.deserialize(this),
);

TypeAliasDeclarationImpl _expectTypeAliasDeclaration(int id) =>
new TypeAliasDeclarationImpl(
id: id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ void checkFunctionDeclaration(FunctionDeclaration actual) {
String name = actual.identifier.name;
FunctionData? expected = expectedFunctionData[name];
if (expected != null) {
expect(expected.isAbstract, actual.hasAbstract, '$name.isAbstract');
expect(expected.isExternal, actual.hasExternal, '$name.isExternal');
expect(expected.isOperator, actual.isOperator, '$name.isOperator');
expect(expected.isGetter, actual.isGetter, '$name.isGetter');
Expand Down
Loading

0 comments on commit df958dc

Please sign in to comment.