Cannot call toString() on a list of non-literal expressions
Whenever I try to use literalList() and pass non-literal expressions, I get the error:
Not a supported literal type
According to #225 this should be supported, though.
Please provide a minimal reproduction case. What code do you try to run which produces this error?
When I tried to provide the minimal reproduction case, I noticed that the same code I couldn't get to work yesterday seems to work fine today. So it seems to have been some other issue on my side. Thank you nonetheless for responding!
I ran into this issue and I think the root cause is LiteralListExpression.toString()'s implementation:
https://github.com/dart-lang/code_builder/blob/743cb0a9f40079ff76fa45a6c2cb7d59a7ec4ad6/lib/src/specs/expression/literal.dart#L137
It passes each value to literal() which is what throws the reported error:
https://github.com/dart-lang/code_builder/blob/743cb0a9f40079ff76fa45a6c2cb7d59a7ec4ad6/lib/src/specs/expression/literal.dart#L35
I encountered this issue rather indirectly via the equalsDart matcher, because it invokes toString() in order to describe a mismatch.
I'm not very familiar with this code base, but I wonder if simply calling toString(), instead of literal(), on each value would be sufficient?