Similar things have been touched before, like GROOVY-2340. But I didn't see exactly this. I'm not sure if single character GStrings are even a thing. Sorry if they aren't.
But I found the following a bit inconsistent:
final String S = 'A'
final Character C = 'A'
final GString G = "$S"
final Number N = 65
assert C == S && S == G // 1a
assert C == G // 1b
assert S == C && G == S // 2a
//assert G == C // 2b, fails, inconsistent with 2a and 1b
assert N == S && S == G // 3a
//assert N == G // 3b, fails, inconsistent with 3a
assert S == N && G == S // 4a
//assert G == N // 4b, fails, inconsistent with 4a
So, a single character GString equals a character, but only if it is on RHS. It doesn't equal a number, ever. I wonder if it should behave like String here.
If there's interest in "fixing" this, I've got a patch that allows all those asserts pass and doesn't seem to fail any of the existing test cases.
This message was sent by Atlassian JIRA