mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
Fix DeclarationResolver handling of annotations containing closures.
R=brianwilkerson@google.com Review URL: https://codereview.chromium.org/2436733004 .
This commit is contained in:
parent
d631a142a4
commit
148af481ff
|
@ -9,7 +9,9 @@ import 'package:analyzer/dart/ast/token.dart';
|
|||
import 'package:analyzer/dart/ast/visitor.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/exception/exception.dart';
|
||||
import 'package:analyzer/src/dart/element/builder.dart';
|
||||
import 'package:analyzer/src/dart/element/element.dart';
|
||||
import 'package:analyzer/src/generated/resolver.dart';
|
||||
|
||||
/**
|
||||
* A visitor that resolves declarations in an AST structure to already built
|
||||
|
@ -50,6 +52,17 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Object visitAnnotation(Annotation node) {
|
||||
// Annotations can only contain elements in certain erroneous situations,
|
||||
// in which case the elements are disconnected from the rest of the element
|
||||
// model, thus we can't reconnect to them. To avoid crashes, just create
|
||||
// fresh elements.
|
||||
ElementHolder elementHolder = new ElementHolder();
|
||||
new ElementBuilder(elementHolder, _enclosingUnit).visitAnnotation(node);
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Object visitCatchClause(CatchClause node) {
|
||||
SimpleIdentifier exceptionParameter = node.exceptionParameter;
|
||||
|
|
|
@ -2438,6 +2438,11 @@ typedef String FunctionTypeAlias(int i);
|
|||
|
||||
enum EnumeratedType {Invalid, Valid}
|
||||
|
||||
class A {
|
||||
const A(x);
|
||||
}
|
||||
|
||||
@A(const [(_) => null])
|
||||
class ClassOne {
|
||||
int instanceField;
|
||||
static int staticField;
|
||||
|
|
Loading…
Reference in a new issue