[ https://issues.apache.org/jira/browse/GROOVY-10887?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17808769#comment-17808769 ]
Eric Milles commented on GROOVY-10887: -------------------------------------- Is this still an issue under 4.0.18? If so, could 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)