You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Ernestas (JIRA)" <ji...@apache.org> on 2019/05/09 06:55:00 UTC
[jira] [Updated] (GROOVY-9114) Groovy chooses inline reified method
over standard from Kotlin class
[ https://issues.apache.org/jira/browse/GROOVY-9114?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ernestas updated GROOVY-9114:
-----------------------------
Description:
Given kotlin class with two methods:
{code:java}
fun pathParam(key: String): String = ContextUtil.pathParamOrThrow(pathParamMap, key, matchedPath)
/** Reified version of [pathParam] (Kotlin only) */
inline fun <reified T : Any> pathParam(key: String) = pathParam(key, T::class.java)
{code}
and used from groovy as:
{code:java}
def id = pathParam("id){code}
Groovy for some reason chooses inline reified version, which of course fails with:
{noformat}
java.lang.UnsupportedOperationException: This function has a reified type parameter and thus can only be inlined at compilation time, not called directly.{noformat}
Is there anything that can be done so groovy uses the first (non reified, understandable by java and groovy) version of the method?
This bug comes from [https://github.com/tipsy/javalin/issues/574]
was:
Given kotlin class with two methods:
{code:java}
fun pathParam(key: String): String = ContextUtil.pathParamOrThrow(pathParamMap, key, matchedPath)
/** Reified version of [pathParam] (Kotlin only) */
inline fun <reified T : Any> pathParam(key: String) = pathParam(key, T::class.java)
{code}
and used from groovy as:
{code:java}
def id = pathParam("id){code}
Groovy executes inline reified version, which of course fails with:
{noformat}
java.lang.UnsupportedOperationException: This function has a reified type parameter and thus can only be inlined at compilation time, not called directly.{noformat}
Is there anything that can be done so groovy uses the first (non reified, understandable by java and groovy) version of the method?
This bug comes from [https://github.com/tipsy/javalin/issues/574]
> Groovy chooses inline reified method over standard from Kotlin class
> ---------------------------------------------------------------------
>
> Key: GROOVY-9114
> URL: https://issues.apache.org/jira/browse/GROOVY-9114
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 2.5.x
> Reporter: Ernestas
> Priority: Major
>
> Given kotlin class with two methods:
> {code:java}
> fun pathParam(key: String): String = ContextUtil.pathParamOrThrow(pathParamMap, key, matchedPath)
>
> /** Reified version of [pathParam] (Kotlin only) */
> inline fun <reified T : Any> pathParam(key: String) = pathParam(key, T::class.java)
> {code}
> and used from groovy as:
> {code:java}
> def id = pathParam("id){code}
> Groovy for some reason chooses inline reified version, which of course fails with:
> {noformat}
> java.lang.UnsupportedOperationException: This function has a reified type parameter and thus can only be inlined at compilation time, not called directly.{noformat}
> Is there anything that can be done so groovy uses the first (non reified, understandable by java and groovy) version of the method?
>
> This bug comes from [https://github.com/tipsy/javalin/issues/574]
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)