You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/01/04 20:08:00 UTC
[jira] [Commented] (GROOVY-10887) groovyc STC loses generic information in extension methods
[ https://issues.apache.org/jira/browse/GROOVY-10887?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17654617#comment-17654617 ]
Eric Milles commented on GROOVY-10887:
--------------------------------------
I have this:
{code:groovy}
@Grab('org.springframework.integration:spring-integration-groovy:5.5.15')
import org.springframework.integration.channel.AbstractMessageChannel
import org.springframework.integration.dsl.MessageChannelSpec
import org.springframework.integration.dsl.MessageChannels
@Grab('org.springframework:spring-messaging:5.3.24')
import org.springframework.messaging.MessageChannel
def <AMC extends AbstractMessageChannel, MCS extends MessageChannelSpec<MCS,AMC>> MCS mark(MCS self) {
self.interceptor(null) // returns self
}
MessageChannel make() {
mark(MessageChannels.publishSubscribe(true).minSubscribers(2)).get()
}
{code}
But it does not reproduce and I cannot move to "use" under STC or to an extension module without infrastructure. Can you provide a sample project?
> groovyc STC loses generic information in extension methods
> ----------------------------------------------------------
>
> Key: GROOVY-10887
> URL: https://issues.apache.org/jira/browse/GROOVY-10887
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 4.0.6, 4.0.7
> Reporter: Christopher Smith
> Assignee: Eric Milles
> Priority: Major
>
> N.B.: This code compiles as expected under GRECLIPSE (both the 2022-12-06 and 2022-12-26 nightlies) but fails under groovyc.
> I have extension methods that are intended to be applied to Spring Integration DSLs:
> {code}
> public final class SpringIntegrationDefaultMethods {
> public static <C extends AbstractMessageChannel, S extends MessageChannelSpec<S, C>>
> S markMessagesAsJumpered(S self) {
> return self.interceptor(new JumperInterceptor()); // returns S
> }
> }
> {code}
> {code}
> moduleName = example-util-spring-integration
> moduleVersion = 0.0.1
> extensionClasses = com.example.util.spring.integration.groovy.SpringIntegrationDefaultMethods
> {code}
> From a Groovy configuration class:
> {code}
> @Bean(CHANNEL_DISPATCH_MESSAGE)
> MessageChannel dispatchQueueOutgoing() {
> // org.springframework.integration.dsl.MessageChannels.
> publishSubscribe(true) // line 49
> .minSubscribers(2)
> .markMessagesAsJumpered()
> .get()
> }
> {code}
> In Eclipse, this compiles as expected. In groovyc 4.0.6 and 4.0.7, I get
> {code}
> [ERROR] /home/christopher/git/.../DispatchHandlingIntegration.groovy: 49: [Static type checking] - Cannot find matching method S#get(). Please check if the declared type is correct and if the method exists.
> [ERROR] @ line 49, column 9.
> [ERROR] publishSubscribe(true)
> {code}
> Adding an explicit type witness
> {code}
> .<PublishSubscribeChannel, PublishSubscribeChannelSpec<?>> markMessagesAsJumpered()
> {code}
> resolves the error in groovyc.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)