Chromium Code Reviews| Index: pkg/compiler/lib/src/resolution/resolution.dart |
| diff --git a/pkg/compiler/lib/src/resolution/resolution.dart b/pkg/compiler/lib/src/resolution/resolution.dart |
| index 6c4f90b232c6adb126da9a4910fc1e7a5a8b5bb2..e7eb51b96b9a37e7b48c6b85df38a81e1c4d101f 100644 |
| --- a/pkg/compiler/lib/src/resolution/resolution.dart |
| +++ b/pkg/compiler/lib/src/resolution/resolution.dart |
| @@ -21,6 +21,11 @@ import '../compiler.dart' show |
| Compiler; |
| import '../compile_time_constants.dart' show |
| ConstantCompiler; |
| +import '../constants/expressions.dart' show |
| + ConstantExpression, |
| + ConstantExpressionKind, |
| + ConstructedConstantExpression, |
| + ErroneousConstantExpression; |
| import '../constants/values.dart' show |
| ConstantValue; |
| import '../core_types.dart' show |
| @@ -1061,8 +1066,29 @@ class ResolverTask extends CompilerTask { |
| node.accept(visitor); |
| // TODO(johnniwinther): Avoid passing the [TreeElements] to |
| // [compileMetadata]. |
| - annotation.constant = |
| - constantCompiler.compileMetadata(annotation, node, registry.mapping); |
| + ConstantExpression constant = constantCompiler.compileMetadata( |
| + annotation, node, registry.mapping); |
| + switch (constant.kind) { |
| + case ConstantExpressionKind.CONSTRUCTED: |
| + ConstructedConstantExpression constructedConstant = constant; |
| + if (constructedConstant.type.isGeneric) { |
| + // Enforce the unnecessary syntactic restriction that disallows type |
|
karlklose
2015/12/09 14:07:29
Maybe file a bug against the specification instead
Johnni Winther
2015/12/09 14:43:43
Done.
|
| + // arguments in the immediate const constructor call. |
| + reporter.reportErrorMessage( |
| + node, MessageKind.INVALID_METADATA_GENERIC); |
| + constant = new ErroneousConstantExpression(); |
| + } |
| + break; |
| + case ConstantExpressionKind.VARIABLE: |
| + case ConstantExpressionKind.ERRONEOUS: |
| + break; |
| + default: |
|
karlklose
2015/12/09 14:07:29
Consider asserting what can reach here.
Johnni Winther
2015/12/09 14:43:43
Everything else (the kind is an enum).
|
| + reporter.reportErrorMessage(node, MessageKind.INVALID_METADATA); |
| + constant = new ErroneousConstantExpression(); |
| + break; |
| + } |
| + annotation.constant = constant; |
| + |
| constantCompiler.evaluate(annotation.constant); |
| // TODO(johnniwinther): Register the relation between the annotation |
| // and the annotated element instead. This will allow the backend to |