mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 15:01:30 +00:00
Issue 30034. Parse annotations for typedef(s) and resynthesize from Kernel in analyzer.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com BUG= https://github.com/dart-lang/sdk/issues/30034 Review-Url: https://codereview.chromium.org/2987983004 .
This commit is contained in:
parent
02cdd6a59b
commit
f9424908a5
4 changed files with 32 additions and 21 deletions
|
@ -5089,6 +5089,10 @@ class FunctionTypeAliasElementImpl extends ElementImpl
|
|||
|
||||
@override
|
||||
List<ElementAnnotation> get metadata {
|
||||
if (_kernel != null) {
|
||||
_metadata ??= enclosingUnit._kernelContext
|
||||
.buildAnnotations(enclosingUnit, _kernel.annotations);
|
||||
}
|
||||
if (_unlinkedTypedef != null) {
|
||||
return _metadata ??=
|
||||
_buildAnnotations(enclosingUnit, _unlinkedTypedef.annotations);
|
||||
|
|
|
@ -690,11 +690,6 @@ class ResynthesizeKernelStrongTest extends ResynthesizeTest {
|
|||
await super.test_metadata_fieldFormalParameter_withDefault();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
test_metadata_functionTypeAlias() async {
|
||||
await super.test_metadata_functionTypeAlias();
|
||||
}
|
||||
|
||||
@failingTest
|
||||
test_metadata_functionTypedFormalParameter() async {
|
||||
await super.test_metadata_functionTypedFormalParameter();
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
library fasta.diet_listener;
|
||||
|
||||
import 'package:kernel/ast.dart' show AsyncMarker, Class, InterfaceType;
|
||||
import 'package:kernel/ast.dart'
|
||||
show AsyncMarker, Class, InterfaceType, Typedef;
|
||||
import 'package:kernel/ast.dart';
|
||||
|
||||
import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
|
||||
|
||||
|
@ -195,12 +197,15 @@ class DietListener extends StackListener {
|
|||
void endFunctionTypeAlias(
|
||||
Token typedefKeyword, Token equals, Token endToken) {
|
||||
debugEvent("FunctionTypeAlias");
|
||||
if (equals != null) {
|
||||
// This is a `typedef NAME = TYPE`.
|
||||
discard(2); // Name and metadata.
|
||||
} else {
|
||||
discard(3); // Name, endToken, and metadata.
|
||||
}
|
||||
|
||||
if (equals == null) pop(); // endToken
|
||||
String name = pop();
|
||||
Token metadata = pop();
|
||||
|
||||
Builder typedefBuilder = lookupBuilder(typedefKeyword, null, name);
|
||||
parseMetadata(typedefBuilder, metadata,
|
||||
(typedefBuilder.target as Typedef).addAnnotation);
|
||||
|
||||
checkEmpty(typedefKeyword.charOffset);
|
||||
}
|
||||
|
||||
|
@ -474,15 +479,11 @@ class DietListener extends StackListener {
|
|||
Token metadata = pop();
|
||||
assert(currentClass == null);
|
||||
assert(memberScope == library.scope);
|
||||
|
||||
Builder classBuilder = lookupBuilder(token, null, name);
|
||||
if (metadata != null) {
|
||||
StackListener listener = createListener(classBuilder, memberScope, false);
|
||||
Parser parser = new Parser(listener);
|
||||
parser.parseMetadataStar(metadata);
|
||||
List metadataConstants = listener.finishMetadata();
|
||||
Class cls = classBuilder.target;
|
||||
metadataConstants.forEach(cls.addAnnotation);
|
||||
}
|
||||
parseMetadata(
|
||||
classBuilder, metadata, (classBuilder.target as Class).addAnnotation);
|
||||
|
||||
currentClass = classBuilder;
|
||||
memberScope = currentClass.scope;
|
||||
}
|
||||
|
@ -656,4 +657,15 @@ class DietListener extends StackListener {
|
|||
void debugEvent(String name) {
|
||||
// printEvent(name);
|
||||
}
|
||||
|
||||
void parseMetadata(Builder builder, Token metadata,
|
||||
void addAnnotation(Expression annotation)) {
|
||||
if (metadata != null) {
|
||||
var listener = createListener(builder, memberScope, false);
|
||||
var parser = new Parser(listener);
|
||||
parser.parseMetadataStar(metadata);
|
||||
List<Expression> metadataConstants = listener.finishMetadata();
|
||||
metadataConstants.forEach(addAnnotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ inference/downwards_inference_annotations_parameter: Fail
|
|||
inference/downwards_inference_annotations_parameter_local: Crash
|
||||
inference/downwards_inference_annotations_type_variable: Fail
|
||||
inference/downwards_inference_annotations_type_variable_local: Crash
|
||||
inference/downwards_inference_annotations_typedef: Fail
|
||||
inference/downwards_inference_annotations_typedef: Crash
|
||||
inference/downwards_inference_assignment_statements: Crash
|
||||
inference/downwards_inference_async_await: Fail
|
||||
inference/downwards_inference_for_each: Fail
|
||||
|
|
Loading…
Reference in a new issue