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 15:51:00 UTC

[jira] [Comment Edited] (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:comment-tabpanel&focusedCommentId=16836484#comment-16836484 ] 

Ernestas edited comment on GROOVY-9114 at 5/9/19 3:50 PM:
----------------------------------------------------------

Thanks for your response.

The small case I use to reproduce (kotlin file):
{code:java}
package com.test

class Example {

    fun pathParam(key: String): String = "param=$key"
    inline fun <reified T : Any> pathParam(key: String) = Holder(T::class.java.getDeclaredConstructor().newInstance())

    data class Holder<T>(val value: T)
}
{code}
Test (groovy file):
{code:java}
package com.test

class Test {
    static void main(String[] args) {
        def example = new Example()
        def result = example.pathParam("test")
        println result
    }
}
{code}
Resulting bytecode from kotlin file:
{noformat}
// ================com/test/Example.class =================
// class version 50.0 (50)
// access flags 0x31
public final class com/test/Example {


// access flags 0x11
public final pathParam(Ljava/lang/String;)Ljava/lang/String;
@Lorg/jetbrains/annotations/NotNull;() // invisible
// annotable parameter count: 1 (visible)
// annotable parameter count: 1 (invisible)
@Lorg/jetbrains/annotations/NotNull;() // invisible, parameter 0
L0
ALOAD 1
LDC "key"
INVOKESTATIC kotlin/jvm/internal/Intrinsics.checkParameterIsNotNull (Ljava/lang/Object;Ljava/lang/String;)V
L1
LINENUMBER 5 L1
NEW java/lang/StringBuilder
DUP
INVOKESPECIAL java/lang/StringBuilder.<init> ()V
LDC "param="
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
ALOAD 1
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String;
ARETURN
L2
LOCALVARIABLE this Lcom/test/Example; L0 L2 0
LOCALVARIABLE key Ljava/lang/String; L0 L2 1
MAXSTACK = 2
MAXLOCALS = 2

// access flags 0x12
// signature <T:Ljava/lang/Object;>(Ljava/lang/String;)Lcom/test/Example$Holder<TT;>;
// declaration: com.test.Example$Holder<T> pathParam<T>(java.lang.String)
private final pathParam(Ljava/lang/String;)Lcom/test/Example$Holder;
// annotable parameter count: 1 (visible)
// annotable parameter count: 1 (invisible)
L0
LDC 0
ISTORE 2
L1
LINENUMBER 6 L1
NEW com/test/Example$Holder
DUP
ICONST_4
LDC "T"
INVOKESTATIC kotlin/jvm/internal/Intrinsics.reifiedOperationMarker (ILjava/lang/String;)V
LDC Ljava/lang/Object;.class
ICONST_0
ANEWARRAY java/lang/Class
INVOKEVIRTUAL java/lang/Class.getDeclaredConstructor ([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
ICONST_0
ANEWARRAY java/lang/Object
INVOKEVIRTUAL java/lang/reflect/Constructor.newInstance ([Ljava/lang/Object;)Ljava/lang/Object;
INVOKESPECIAL com/test/Example$Holder.<init> (Ljava/lang/Object;)V
ARETURN
L2
LOCALVARIABLE this Lcom/test/Example; L0 L2 0
LOCALVARIABLE key Ljava/lang/String; L0 L2 1
LOCALVARIABLE $i$f$pathParam I L1 L2 2
MAXSTACK = 4
MAXLOCALS = 3

// access flags 0x1
public <init>()V
L0
LINENUMBER 3 L0
ALOAD 0
INVOKESPECIAL java/lang/Object.<init> ()V
RETURN
L1
LOCALVARIABLE this Lcom/test/Example; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1

@Lkotlin/Metadata;(mv={1, 1, 13}, bv={1, 0, 3}, k=1, d1={"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0008\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0008\u0004\u0018\u00002\u00020\u0001:\u0001\u0009B\u0005\u00a2\u0006\u0002\u0010\u0002J\u000e\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0004J+\u0010\u0003\u001a\u0010\u0012\u000c\u0012\n \u0008*\u0004\u0018\u0001H\u0007H\u00070\u0006\"\n\u0008\u0000\u0010\u0007\u0018\u0001*\u00020\u00012\u0006\u0010\u0005\u001a\u00020\u0004H\u0086\u0008\u00a8\u0006\n"}, d2={"Lcom/test/Example;", "", "()V", "pathParam", "", "key", "Lcom/test/Example$Holder;", "T", "kotlin.jvm.PlatformType", "Holder", "facebook-parent.facebook.main"})
// access flags 0x19
public final static INNERCLASS com/test/Example$Holder com/test/Example Holder
// compiled from: Example.kt
}


// ================com/test/Example$Holder.class =================
// class version 50.0 (50)
// access flags 0x31
// signature <T:Ljava/lang/Object;>Ljava/lang/Object;
// declaration: com/test/Example$Holder<T>
public final class com/test/Example$Holder {


// access flags 0x12
// signature TT;
// declaration: value extends T
private final Ljava/lang/Object; value

// access flags 0x11
// signature ()TT;
// declaration: T getValue()
public final getValue()Ljava/lang/Object;
L0
LINENUMBER 8 L0
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
ARETURN
L1
LOCALVARIABLE this Lcom/test/Example$Holder; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1

// access flags 0x1
// signature (TT;)V
// declaration: void <init>(T)
public <init>(Ljava/lang/Object;)V
// annotable parameter count: 1 (visible)
// annotable parameter count: 1 (invisible)
L0
LINENUMBER 8 L0
ALOAD 0
INVOKESPECIAL java/lang/Object.<init> ()V
ALOAD 0
ALOAD 1
PUTFIELD com/test/Example$Holder.value : Ljava/lang/Object;
RETURN
L1
LOCALVARIABLE this Lcom/test/Example$Holder; L0 L1 0
LOCALVARIABLE value Ljava/lang/Object; L0 L1 1
MAXSTACK = 2
MAXLOCALS = 2

// access flags 0x11
// signature ()TT;
// declaration: T component1()
public final component1()Ljava/lang/Object;
L0
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
ARETURN
L1
LOCALVARIABLE this Lcom/test/Example$Holder; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1

// access flags 0x11
// signature (TT;)Lcom/test/Example$Holder<TT;>;
// declaration: com.test.Example$Holder<T> copy(T)
public final copy(Ljava/lang/Object;)Lcom/test/Example$Holder;
@Lorg/jetbrains/annotations/NotNull;() // invisible
// annotable parameter count: 1 (visible)
// annotable parameter count: 1 (invisible)
L0
NEW com/test/Example$Holder
DUP
ALOAD 1
INVOKESPECIAL com/test/Example$Holder.<init> (Ljava/lang/Object;)V
ARETURN
L1
LOCALVARIABLE this Lcom/test/Example$Holder; L0 L1 0
LOCALVARIABLE value Ljava/lang/Object; L0 L1 1
MAXSTACK = 3
MAXLOCALS = 2

// access flags 0x1009
public static synthetic copy$default(Lcom/test/Example$Holder;Ljava/lang/Object;ILjava/lang/Object;)Lcom/test/Example$Holder;
@Lorg/jetbrains/annotations/NotNull;() // invisible
ILOAD 2
ICONST_1
IAND
IFEQ L0
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
ASTORE 1
L0
ALOAD 0
ALOAD 1
INVOKEVIRTUAL com/test/Example$Holder.copy (Ljava/lang/Object;)Lcom/test/Example$Holder;
ARETURN
MAXSTACK = 2
MAXLOCALS = 4

// access flags 0x1
public toString()Ljava/lang/String;
@Lorg/jetbrains/annotations/NotNull;() // invisible
NEW java/lang/StringBuilder
DUP
INVOKESPECIAL java/lang/StringBuilder.<init> ()V
LDC "Holder(value="
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/Object;)Ljava/lang/StringBuilder;
LDC ")"
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String;
ARETURN
MAXSTACK = 2
MAXLOCALS = 1

// access flags 0x1
public hashCode()I
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
DUP
IFNULL L0
INVOKEVIRTUAL java/lang/Object.hashCode ()I
GOTO L1
L0
POP
ICONST_0
L1
IRETURN
MAXSTACK = 2
MAXLOCALS = 1

// access flags 0x1
public equals(Ljava/lang/Object;)Z
@Lorg/jetbrains/annotations/Nullable;() // invisible, parameter 0
ALOAD 0
ALOAD 1
IF_ACMPEQ L0
ALOAD 1
INSTANCEOF com/test/Example$Holder
IFEQ L1
ALOAD 1
CHECKCAST com/test/Example$Holder
ASTORE 2
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
ALOAD 2
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
INVOKESTATIC kotlin/jvm/internal/Intrinsics.areEqual (Ljava/lang/Object;Ljava/lang/Object;)Z
IFEQ L1
L0
ICONST_1
IRETURN
L1
ICONST_0
IRETURN
MAXSTACK = 2
MAXLOCALS = 3

@Lkotlin/Metadata;(mv={1, 1, 13}, bv={1, 0, 3}, k=1, d1={"\u0000\"\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0000\n\u0002\u0008\u0009\n\u0002\u0010\u000b\n\u0002\u0008\u0002\n\u0002\u0010\u0008\n\u0000\n\u0002\u0010\u000e\n\u0000\u0008\u0086\u0008\u0018\u0000*\u0004\u0008\u0000\u0010\u00012\u00020\u0002B\r\u0012\u0006\u0010\u0003\u001a\u00028\u0000\u00a2\u0006\u0002\u0010\u0004J\u000e\u0010\u0008\u001a\u00028\u0000H\u00c6\u0003\u00a2\u0006\u0002\u0010\u0006J\u001e\u0010\u0009\u001a\u0008\u0012\u0004\u0012\u00028\u00000\u00002\u0008\u0008\u0002\u0010\u0003\u001a\u00028\u0000H\u00c6\u0001\u00a2\u0006\u0002\u0010\nJ\u0013\u0010\u000b\u001a\u00020\u000c2\u0008\u0010\r\u001a\u0004\u0018\u00010\u0002H\u00d6\u0003J\u0009\u0010\u000e\u001a\u00020\u000fH\u00d6\u0001J\u0009\u0010\u0010\u001a\u00020\u0011H\u00d6\u0001R\u0013\u0010\u0003\u001a\u00028\u0000\u00a2\u0006\n\n\u0002\u0010\u0007\u001a\u0004\u0008\u0005\u0010\u0006\u00a8\u0006\u0012"}, d2={"Lcom/test/Example$Holder;", "T", "", "value", "(Ljava/lang/Object;)V", "getValue", "()Ljava/lang/Object;", "Ljava/lang/Object;", "component1", "copy", "(Ljava/lang/Object;)Lcom/test/Example$Holder;", "equals", "", "other", "hashCode", "", "toString", "", "facebook-parent.facebook.main"})
// access flags 0x19
public final static INNERCLASS com/test/Example$Holder com/test/Example Holder
// compiled from: Example.kt
}


// ================META-INF/facebook-parent.facebook.main.kotlin_module =================
{noformat}
The exception during execution of groovy file:
{noformat}
Exception in thread "main" java.lang.UnsupportedOperationException: This function has a reified type parameter and thus can only be inlined at compilation time, not called directly.
	at kotlin.jvm.internal.Intrinsics.throwUndefinedForReified(Intrinsics.java:193)
	at kotlin.jvm.internal.Intrinsics.throwUndefinedForReified(Intrinsics.java:187)
	at kotlin.jvm.internal.Intrinsics.reifiedOperationMarker(Intrinsics.java:197)
	at com.platformlunar.facebook.Example.pathParam(Example.kt:6)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:213)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:55)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
	at Test.main(Test.groovy:6)
{noformat}
During debugging execution of the call, I can see groovy chooses the inline reified method
{noformat}
<T:Ljava/lang/Object;>(Ljava/lang/String;)Lcom/platformlunar/facebook/Example$Holder<TT;>;
{noformat}
I can only guess groovy chooses def type of Object in `def result = pathParam("id")`. Ideally, groovy would exclude Kotlin's reified methods from the equation since they're not usable in java and groovy.


was (Author: ernestas):
Thanks for your response.

The small case I use to reproduce (kotlin file):
{code:java}
package com.test

class Example {

    fun pathParam(key: String): String = "param=$key"
    inline fun <reified T : Any> pathParam(key: String) = Holder(T::class.java.getDeclaredConstructor().newInstance())

    data class Holder<T>(val value: T)
}
{code}
Test (groovy file):
{code:java}
package com.test

class Test {
    static void main(String[] args) {
        def example = new Example()
        def result = example.pathParam("test")
        println result
    }
}
{code}
Resulting bytecode from kotlin file:
{noformat}
// ================com/test/Example.class =================
// class version 50.0 (50)
// access flags 0x31
public final class com/test/Example {


// access flags 0x11
public final pathParam(Ljava/lang/String;)Ljava/lang/String;
@Lorg/jetbrains/annotations/NotNull;() // invisible
// annotable parameter count: 1 (visible)
// annotable parameter count: 1 (invisible)
@Lorg/jetbrains/annotations/NotNull;() // invisible, parameter 0
L0
ALOAD 1
LDC "key"
INVOKESTATIC kotlin/jvm/internal/Intrinsics.checkParameterIsNotNull (Ljava/lang/Object;Ljava/lang/String;)V
L1
LINENUMBER 5 L1
NEW java/lang/StringBuilder
DUP
INVOKESPECIAL java/lang/StringBuilder.<init> ()V
LDC "param="
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
ALOAD 1
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String;
ARETURN
L2
LOCALVARIABLE this Lcom/test/Example; L0 L2 0
LOCALVARIABLE key Ljava/lang/String; L0 L2 1
MAXSTACK = 2
MAXLOCALS = 2

// access flags 0x12
// signature <T:Ljava/lang/Object;>(Ljava/lang/String;)Lcom/test/Example$Holder<TT;>;
// declaration: com.test.Example$Holder<T> pathParam<T>(java.lang.String)
private final pathParam(Ljava/lang/String;)Lcom/test/Example$Holder;
// annotable parameter count: 1 (visible)
// annotable parameter count: 1 (invisible)
L0
LDC 0
ISTORE 2
L1
LINENUMBER 6 L1
NEW com/test/Example$Holder
DUP
ICONST_4
LDC "T"
INVOKESTATIC kotlin/jvm/internal/Intrinsics.reifiedOperationMarker (ILjava/lang/String;)V
LDC Ljava/lang/Object;.class
ICONST_0
ANEWARRAY java/lang/Class
INVOKEVIRTUAL java/lang/Class.getDeclaredConstructor ([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
ICONST_0
ANEWARRAY java/lang/Object
INVOKEVIRTUAL java/lang/reflect/Constructor.newInstance ([Ljava/lang/Object;)Ljava/lang/Object;
INVOKESPECIAL com/test/Example$Holder.<init> (Ljava/lang/Object;)V
ARETURN
L2
LOCALVARIABLE this Lcom/test/Example; L0 L2 0
LOCALVARIABLE key Ljava/lang/String; L0 L2 1
LOCALVARIABLE $i$f$pathParam I L1 L2 2
MAXSTACK = 4
MAXLOCALS = 3

// access flags 0x1
public <init>()V
L0
LINENUMBER 3 L0
ALOAD 0
INVOKESPECIAL java/lang/Object.<init> ()V
RETURN
L1
LOCALVARIABLE this Lcom/test/Example; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1

@Lkotlin/Metadata;(mv={1, 1, 13}, bv={1, 0, 3}, k=1, d1={"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0008\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0008\u0004\u0018\u00002\u00020\u0001:\u0001\u0009B\u0005\u00a2\u0006\u0002\u0010\u0002J\u000e\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0004J+\u0010\u0003\u001a\u0010\u0012\u000c\u0012\n \u0008*\u0004\u0018\u0001H\u0007H\u00070\u0006\"\n\u0008\u0000\u0010\u0007\u0018\u0001*\u00020\u00012\u0006\u0010\u0005\u001a\u00020\u0004H\u0086\u0008\u00a8\u0006\n"}, d2={"Lcom/test/Example;", "", "()V", "pathParam", "", "key", "Lcom/test/Example$Holder;", "T", "kotlin.jvm.PlatformType", "Holder", "facebook-parent.facebook.main"})
// access flags 0x19
public final static INNERCLASS com/test/Example$Holder com/test/Example Holder
// compiled from: Example.kt
}


// ================com/test/Example$Holder.class =================
// class version 50.0 (50)
// access flags 0x31
// signature <T:Ljava/lang/Object;>Ljava/lang/Object;
// declaration: com/test/Example$Holder<T>
public final class com/test/Example$Holder {


// access flags 0x12
// signature TT;
// declaration: value extends T
private final Ljava/lang/Object; value

// access flags 0x11
// signature ()TT;
// declaration: T getValue()
public final getValue()Ljava/lang/Object;
L0
LINENUMBER 8 L0
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
ARETURN
L1
LOCALVARIABLE this Lcom/test/Example$Holder; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1

// access flags 0x1
// signature (TT;)V
// declaration: void <init>(T)
public <init>(Ljava/lang/Object;)V
// annotable parameter count: 1 (visible)
// annotable parameter count: 1 (invisible)
L0
LINENUMBER 8 L0
ALOAD 0
INVOKESPECIAL java/lang/Object.<init> ()V
ALOAD 0
ALOAD 1
PUTFIELD com/test/Example$Holder.value : Ljava/lang/Object;
RETURN
L1
LOCALVARIABLE this Lcom/test/Example$Holder; L0 L1 0
LOCALVARIABLE value Ljava/lang/Object; L0 L1 1
MAXSTACK = 2
MAXLOCALS = 2

// access flags 0x11
// signature ()TT;
// declaration: T component1()
public final component1()Ljava/lang/Object;
L0
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
ARETURN
L1
LOCALVARIABLE this Lcom/test/Example$Holder; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1

// access flags 0x11
// signature (TT;)Lcom/test/Example$Holder<TT;>;
// declaration: com.test.Example$Holder<T> copy(T)
public final copy(Ljava/lang/Object;)Lcom/test/Example$Holder;
@Lorg/jetbrains/annotations/NotNull;() // invisible
// annotable parameter count: 1 (visible)
// annotable parameter count: 1 (invisible)
L0
NEW com/test/Example$Holder
DUP
ALOAD 1
INVOKESPECIAL com/test/Example$Holder.<init> (Ljava/lang/Object;)V
ARETURN
L1
LOCALVARIABLE this Lcom/test/Example$Holder; L0 L1 0
LOCALVARIABLE value Ljava/lang/Object; L0 L1 1
MAXSTACK = 3
MAXLOCALS = 2

// access flags 0x1009
public static synthetic copy$default(Lcom/test/Example$Holder;Ljava/lang/Object;ILjava/lang/Object;)Lcom/test/Example$Holder;
@Lorg/jetbrains/annotations/NotNull;() // invisible
ILOAD 2
ICONST_1
IAND
IFEQ L0
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
ASTORE 1
L0
ALOAD 0
ALOAD 1
INVOKEVIRTUAL com/test/Example$Holder.copy (Ljava/lang/Object;)Lcom/test/Example$Holder;
ARETURN
MAXSTACK = 2
MAXLOCALS = 4

// access flags 0x1
public toString()Ljava/lang/String;
@Lorg/jetbrains/annotations/NotNull;() // invisible
NEW java/lang/StringBuilder
DUP
INVOKESPECIAL java/lang/StringBuilder.<init> ()V
LDC "Holder(value="
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/Object;)Ljava/lang/StringBuilder;
LDC ")"
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String;
ARETURN
MAXSTACK = 2
MAXLOCALS = 1

// access flags 0x1
public hashCode()I
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
DUP
IFNULL L0
INVOKEVIRTUAL java/lang/Object.hashCode ()I
GOTO L1
L0
POP
ICONST_0
L1
IRETURN
MAXSTACK = 2
MAXLOCALS = 1

// access flags 0x1
public equals(Ljava/lang/Object;)Z
@Lorg/jetbrains/annotations/Nullable;() // invisible, parameter 0
ALOAD 0
ALOAD 1
IF_ACMPEQ L0
ALOAD 1
INSTANCEOF com/test/Example$Holder
IFEQ L1
ALOAD 1
CHECKCAST com/test/Example$Holder
ASTORE 2
ALOAD 0
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
ALOAD 2
GETFIELD com/test/Example$Holder.value : Ljava/lang/Object;
INVOKESTATIC kotlin/jvm/internal/Intrinsics.areEqual (Ljava/lang/Object;Ljava/lang/Object;)Z
IFEQ L1
L0
ICONST_1
IRETURN
L1
ICONST_0
IRETURN
MAXSTACK = 2
MAXLOCALS = 3

@Lkotlin/Metadata;(mv={1, 1, 13}, bv={1, 0, 3}, k=1, d1={"\u0000\"\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0000\n\u0002\u0008\u0009\n\u0002\u0010\u000b\n\u0002\u0008\u0002\n\u0002\u0010\u0008\n\u0000\n\u0002\u0010\u000e\n\u0000\u0008\u0086\u0008\u0018\u0000*\u0004\u0008\u0000\u0010\u00012\u00020\u0002B\r\u0012\u0006\u0010\u0003\u001a\u00028\u0000\u00a2\u0006\u0002\u0010\u0004J\u000e\u0010\u0008\u001a\u00028\u0000H\u00c6\u0003\u00a2\u0006\u0002\u0010\u0006J\u001e\u0010\u0009\u001a\u0008\u0012\u0004\u0012\u00028\u00000\u00002\u0008\u0008\u0002\u0010\u0003\u001a\u00028\u0000H\u00c6\u0001\u00a2\u0006\u0002\u0010\nJ\u0013\u0010\u000b\u001a\u00020\u000c2\u0008\u0010\r\u001a\u0004\u0018\u00010\u0002H\u00d6\u0003J\u0009\u0010\u000e\u001a\u00020\u000fH\u00d6\u0001J\u0009\u0010\u0010\u001a\u00020\u0011H\u00d6\u0001R\u0013\u0010\u0003\u001a\u00028\u0000\u00a2\u0006\n\n\u0002\u0010\u0007\u001a\u0004\u0008\u0005\u0010\u0006\u00a8\u0006\u0012"}, d2={"Lcom/test/Example$Holder;", "T", "", "value", "(Ljava/lang/Object;)V", "getValue", "()Ljava/lang/Object;", "Ljava/lang/Object;", "component1", "copy", "(Ljava/lang/Object;)Lcom/test/Example$Holder;", "equals", "", "other", "hashCode", "", "toString", "", "facebook-parent.facebook.main"})
// access flags 0x19
public final static INNERCLASS com/test/Example$Holder com/test/Example Holder
// compiled from: Example.kt
}


// ================META-INF/facebook-parent.facebook.main.kotlin_module =================
{noformat}

> 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)