Skip to content

Commit af93327

Browse files
authored
allow all constant expressions as long as they contain only literals (#3147)
Closes #1929 by allowing all constant expressions, but they can only contain literals.
1 parent 6a69029 commit af93327

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

working/macros/feature-specification.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,22 +1091,14 @@ to a form that the corresponding constructor on the macro class expects, which
10911091
it specifies through parameter types:
10921092

10931093
* If the parameter type is `bool`, `double`, `int`, `Null`, `num`, `String`,
1094-
`List`, `Set`, or `Map`, (or the nullable forms of any of those), then the
1095-
argument expression must be a boolean, number, null, string, list, set, or
1096-
map literal.
1097-
1098-
* Number literals may be negated.
1099-
* String literals may not contain any interpolation, but may be adjacent
1100-
strings, and may be raw strings.
1101-
* List, Set and Map literals may only contain entries matching any of the
1102-
supported argument types. If the parameter type specifies a generic type
1103-
argument, it must be one of the allowed parameter types or `Object`,
1104-
recursively. Note that `Object` is allowed in order to exclude null items,
1105-
but all the actual entries must be of one of the supported types.
1106-
1107-
**TODO**: Do we want to allow more complex expressions? Could we allow
1108-
constant expressions whose identifiers can be successfully resolved before
1109-
macro expansion (#1929)?
1094+
`List`, `Set`, `Map`, `Object`, or `dynamic` (or the nullable forms of any
1095+
of those), then the argument expression must be a constant expression
1096+
containing only boolean, number, null, string, list, set, or map literals.
1097+
Note that `Object` and `dynamic` are allowed as types but the actual values
1098+
must still be of one of the supported types.
1099+
1100+
* Any type arguments (inferred or explicit) must be one of the allowed
1101+
parameter types, recursively.
11101102

11111103
* If the parameter type is `Code` (or a subtype of `Code`), the argument
11121104
expression is automatically converted to a corresponding `Code` instance.

0 commit comments

Comments
 (0)