[
https://issues.apache.org/jira/browse/GROOVY-10750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17645026#comment-17645026
]
Christopher Smith edited comment on GROOVY-10750 at 12/8/22 11:56 PM:
----------------------------------------------------------------------
For some reason I had thought this was fixed (and it works in at least some
circumstances), but I just got tripped up by it again. Is this likely to be
resolvable in 4.x? I certainly understand difficulties if inference is
involved, but in cases where I can affirmatively declare {{public static final
String}}, it would be nice for annotations to compile.
-Specifically, it appears that references to external string constants defined
_on a Groovy interface_ (but in a different jar) work fine, but references to
identically shaped constants on a Java interface produce this error.- The error
message was appearing in a different place from where I expected but is present
in both cases.
was (Author: chrylis):
For some reason I had thought this was fixed (and it works in at least some
circumstances), but I just got tripped up by it again. Is this likely to be
resolvable in 4.x? I certainly understand difficulties if inference is
involved, but in cases where I can affirmatively declare {{public static final
String}}, it would be nice for annotations to compile.
Specifically, it appears that references to external string constants defined
_on a Groovy interface_ (but in a different jar) work fine, but references to
identically shaped constants on a Java interface produce this error.
> Compiler does not resolve compile-time constants in string concatenation
> ------------------------------------------------------------------------
>
> Key: GROOVY-10750
> URL: https://issues.apache.org/jira/browse/GROOVY-10750
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 4.0.4, 4.0.6
> Reporter: Christopher Smith
> Priority: Minor
>
> This appears to be the same behavior marked as fixed in GROOVY-9855. In a
> Groovy 4.0.4 compilation, this code:
> {code}
> @CompileStatic
> @RequestMapping(path = FooController.BASE_URL)
> class FooController {
> public static final String BASE_URL = '/foos'
> }
> @CompileStatic
> @RequestMapping(path = FooBarController.BASE_URL)
> class FooBarController {
> public static final String BASE_URL = FooController.BASE_URL +
> '/{fooId}/bars'
> }
> {code}
> succeeds for FooController, but FooBarController produces a pair of errors:
> {code}
> FooBarController.groovy: 20: Expected 'com.example.FooBarController.BASE_URL'
> to be an inline constant of type java.lang.String not a property expression
> in @org.springframework.web.bind.annotation.RequestMapping
> FooBarController.groovy: 20: Attribute 'path' should have type
> 'java.lang.String'; but found type 'java.lang.Object' in
> @org.springframework.web.bind.annotation.RequestMapping
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)