dart2js: retain constants that are used as annotations in constructors and setters.

BUG= http://dartbug.com/23128
R=herhut@google.com

Review URL: https://codereview.chromium.org//1072043002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45064 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
floitsch@google.com
2015-04-10 13:10:11 +00:00
parent bc1f440a42
commit ffeedc00bf
2 changed files with 17 additions and 1 deletions
@@ -196,7 +196,9 @@ class CodeEmitterTask extends CompilerTask {
for (Element element in backend.generatedCode.keys) {
if (backend.isAccessibleByReflection(element)) {
bool shouldRetainMetadata = backend.retainMetadataOf(element);
if (shouldRetainMetadata && element.isFunction) {
if (shouldRetainMetadata &&
(element.isFunction || element.isConstructor ||
element.isSetter)) {
FunctionElement function = element;
function.functionSignature.forEachParameter(
backend.retainMetadataOf);
@@ -13,6 +13,11 @@ class ParameterAnnotation {
}
class Foo {
Foo(@ParameterAnnotation("vogel") p) {}
Foo.named(@ParameterAnnotation("hamster") p) {}
Foo.named2(@ParameterAnnotation("hamster") p,
@ParameterAnnotation("wurm") p2) {}
f1(@ParameterAnnotation("hest") p) {}
f2(@ParameterAnnotation("hest") @ParameterAnnotation("fisk") p) {}
f3(a, @ParameterAnnotation("fugl") p) {}
@@ -22,6 +27,8 @@ class Foo {
[@ParameterAnnotation("hval") p]) {}
f6({@ParameterAnnotation("fisk") z,
@ParameterAnnotation("hval") p}) {}
set s1(@ParameterAnnotation("cheval") p) {}
}
expectAnnotations(Type type, Symbol method, int parameterIndex,
@@ -39,6 +46,11 @@ expectAnnotations(Type type, Symbol method, int parameterIndex,
}
main() {
expectAnnotations(Foo, #Foo, 0, ["vogel"]);
expectAnnotations(Foo, #Foo.named, 0, ["hamster"]);
expectAnnotations(Foo, #Foo.named2, 0, ["hamster"]);
expectAnnotations(Foo, #Foo.named2, 1, ["wurm"]);
expectAnnotations(Foo, #f1, 0, ["hest"]);
expectAnnotations(Foo, #f2, 0, ["hest", "fisk"]);
expectAnnotations(Foo, #f3, 0, []);
@@ -49,4 +61,6 @@ main() {
expectAnnotations(Foo, #f5, 1, ["hval"]);
expectAnnotations(Foo, #f6, 0, ["fisk"]);
expectAnnotations(Foo, #f6, 1, ["hval"]);
expectAnnotations(Foo, const Symbol('s1='), 0, ["cheval"]);
}