Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit aa6fbac

Browse files
author
Dart CI
committed
Version 2.17.0-13.0.dev
Merge commit 'a32e171a6fb1da8bdf3212433b389976dc079461' into 'dev'
2 parents ba044d5 + a32e171 commit aa6fbac

File tree

48 files changed

+1889
-727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1889
-727
lines changed

pkg/_fe_analyzer_shared/lib/src/macros/api/introspection.dart

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ abstract class TypeAnnotation {
1414

1515
/// A [Code] object representation of this type annotation.
1616
Code get code;
17-
18-
/// Allows you to check the kind of a [TypeAnnotation] in a switch statement,
19-
/// and without `is` checks.
20-
TypeAnnotationKind get kind;
2117
}
2218

2319
/// The base class for function type declarations.
@@ -33,9 +29,6 @@ abstract class FunctionTypeAnnotation implements TypeAnnotation {
3329

3430
/// The type parameters for this function.
3531
Iterable<TypeParameterDeclaration> get typeParameters;
36-
37-
@override
38-
TypeAnnotationKind get kind => TypeAnnotationKind.functionType;
3932
}
4033

4134
/// An unresolved reference to a type.
@@ -48,9 +41,6 @@ abstract class NamedTypeAnnotation implements TypeAnnotation {
4841

4942
/// The type arguments, if applicable.
5043
Iterable<TypeAnnotation> get typeArguments;
51-
52-
@override
53-
TypeAnnotationKind get kind => TypeAnnotationKind.namedType;
5444
}
5545

5646
/// The interface representing a resolved type.
@@ -75,10 +65,6 @@ abstract class NamedStaticType implements StaticType {
7565
abstract class Declaration {
7666
/// The name of this declaration.
7767
String get name;
78-
79-
/// Allows you to check the kind of a [Declaration] in a switch statement,
80-
/// and without `is` checks.
81-
DeclarationKind get kind;
8268
}
8369

8470
/// A declaration that defines a new type in the program.
@@ -105,9 +91,6 @@ abstract class TypeDeclaration implements Declaration {
10591
/// Information about fields, methods, and constructors must be retrieved from
10692
/// the `builder` objects.
10793
abstract class ClassDeclaration implements TypeDeclaration {
108-
@override
109-
DeclarationKind get kind => DeclarationKind.clazz;
110-
11194
/// Whether this class has an `abstract` modifier.
11295
bool get isAbstract;
11396

@@ -129,18 +112,12 @@ abstract class ClassDeclaration implements TypeDeclaration {
129112

130113
/// Type alias introspection information.
131114
abstract class TypeAliasDeclaration extends TypeDeclaration {
132-
@override
133-
DeclarationKind get kind => DeclarationKind.typeAlias;
134-
135115
/// The type annotation this is an alias for.
136116
TypeAnnotation get type;
137117
}
138118

139119
/// Function introspection information.
140120
abstract class FunctionDeclaration implements Declaration {
141-
@override
142-
DeclarationKind get kind => DeclarationKind.function;
143-
144121
/// Whether this function has an `abstract` modifier.
145122
bool get isAbstract;
146123

@@ -168,9 +145,6 @@ abstract class FunctionDeclaration implements Declaration {
168145

169146
/// Method introspection information.
170147
abstract class MethodDeclaration implements FunctionDeclaration {
171-
@override
172-
DeclarationKind get kind => DeclarationKind.method;
173-
174148
/// The class that defines this method.
175149
TypeAnnotation get definingClass;
176150
}
@@ -183,9 +157,6 @@ abstract class ConstructorDeclaration implements MethodDeclaration {
183157

184158
/// Variable introspection information.
185159
abstract class VariableDeclaration implements Declaration {
186-
@override
187-
DeclarationKind get kind => DeclarationKind.variable;
188-
189160
/// Whether this function has an `abstract` modifier.
190161
bool get isAbstract;
191162

@@ -201,18 +172,12 @@ abstract class VariableDeclaration implements Declaration {
201172

202173
/// Field introspection information ..
203174
abstract class FieldDeclaration implements VariableDeclaration {
204-
@override
205-
DeclarationKind get kind => DeclarationKind.field;
206-
207175
/// The class that defines this method.
208176
TypeAnnotation get definingClass;
209177
}
210178

211179
/// Parameter introspection information.
212180
abstract class ParameterDeclaration implements Declaration {
213-
@override
214-
DeclarationKind get kind => DeclarationKind.parameter;
215-
216181
/// The type of this parameter.
217182
TypeAnnotation get type;
218183

@@ -230,28 +195,6 @@ abstract class ParameterDeclaration implements Declaration {
230195

231196
/// Type parameter introspection information.
232197
abstract class TypeParameterDeclaration implements Declaration {
233-
@override
234-
DeclarationKind get kind => DeclarationKind.typeParameter;
235-
236198
/// The bounds for this type parameter, if it has any.
237199
TypeAnnotation? get bounds;
238200
}
239-
240-
// The kinds of type declarations.
241-
enum DeclarationKind {
242-
clazz,
243-
constructor,
244-
field,
245-
function,
246-
method,
247-
parameter,
248-
typeAlias,
249-
typeParameter,
250-
variable,
251-
}
252-
253-
// The kinds of type annotations.
254-
enum TypeAnnotationKind {
255-
namedType,
256-
functionType,
257-
}

pkg/_fe_analyzer_shared/lib/src/macros/bootstrap.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const String template = '''
2626
import 'dart:async';
2727
import 'dart:isolate';
2828
29+
import 'package:_fe_analyzer_shared/src/macros/executor_shared/introspection_impls.dart';
2930
import 'package:_fe_analyzer_shared/src/macros/executor_shared/response_impls.dart';
3031
import 'package:_fe_analyzer_shared/src/macros/executor_shared/serialization.dart';
3132
import 'package:_fe_analyzer_shared/src/macros/executor_shared/protocol.dart';
@@ -99,12 +100,14 @@ Future<SerializableResponse> _instantiateMacro(
99100
return new SerializableResponse(
100101
responseType: MessageType.macroInstanceIdentifier,
101102
response: identifier,
102-
requestId: request.id);
103+
requestId: request.id,
104+
serializationZoneId: request.serializationZoneId);
103105
} catch (e) {
104106
return new SerializableResponse(
105107
responseType: MessageType.error,
106108
error: e.toString(),
107-
requestId: request.id);
109+
requestId: request.id,
110+
serializationZoneId: request.serializationZoneId);
108111
}
109112
}
110113
@@ -118,7 +121,7 @@ Future<SerializableResponse> _executeDefinitionsPhase(
118121
}
119122
Declaration declaration = request.declaration;
120123
if (instance is FunctionDefinitionMacro &&
121-
declaration is FunctionDeclaration) {
124+
declaration is FunctionDeclarationImpl) {
122125
FunctionDefinitionBuilderImpl builder = new FunctionDefinitionBuilderImpl(
123126
declaration,
124127
request.typeResolver,
@@ -128,7 +131,8 @@ Future<SerializableResponse> _executeDefinitionsPhase(
128131
return new SerializableResponse(
129132
responseType: MessageType.macroExecutionResult,
130133
response: builder.result,
131-
requestId: request.id);
134+
requestId: request.id,
135+
serializationZoneId: request.serializationZoneId);
132136
} else {
133137
throw new UnsupportedError(
134138
('Only FunctionDefinitionMacros are supported currently'));
@@ -137,7 +141,8 @@ Future<SerializableResponse> _executeDefinitionsPhase(
137141
return new SerializableResponse(
138142
responseType: MessageType.error,
139143
error: e.toString(),
140-
requestId: request.id);
144+
requestId: request.id,
145+
serializationZoneId: request.serializationZoneId);
141146
}
142147
}
143148
''';

pkg/_fe_analyzer_shared/lib/src/macros/executor.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ abstract class MacroExecutor {
6262
///
6363
/// Throws an exception if there is an error executing the macro.
6464
Future<MacroExecutionResult> executeTypesPhase(
65-
MacroInstanceIdentifier macro, Declaration declaration);
65+
MacroInstanceIdentifier macro, covariant Declaration declaration);
6666

6767
/// Runs the declarations phase for [macro] on a given [declaration].
6868
///
6969
/// Throws an exception if there is an error executing the macro.
7070
Future<MacroExecutionResult> executeDeclarationsPhase(
7171
MacroInstanceIdentifier macro,
72-
Declaration declaration,
72+
covariant Declaration declaration,
7373
TypeResolver typeResolver,
7474
ClassIntrospector classIntrospector);
7575

@@ -78,7 +78,7 @@ abstract class MacroExecutor {
7878
/// Throws an exception if there is an error executing the macro.
7979
Future<MacroExecutionResult> executeDefinitionsPhase(
8080
MacroInstanceIdentifier macro,
81-
Declaration declaration,
81+
covariant Declaration declaration,
8282
TypeResolver typeResolver,
8383
ClassIntrospector classIntrospector,
8484
TypeDeclarationResolver typeDeclarationResolver);

0 commit comments

Comments
 (0)