raphw / byte-buddy

Runtime code generation for the Java virtual machine.
https://bytebuddy.net
Apache License 2.0
6.27k stars 806 forks source link

Cannot resolve `In` from class `zio.cache.Cache$$anon$1` #1577

Closed jxnu-liguobin closed 1 month ago

jxnu-liguobin commented 10 months ago

This is Scala, since the minimum reproduction code is uncertain at this point, a guess would be something like this:

abstract class Cache[-Key, +Value]:

  def get(key: Key): Value

object Cache:

  def make[In, Key, Value](keyBy: In => Key) = new Cache[In, Value]:
    override def get(in: In): Value = ???

The full code is here https://github.com/zio/zio-cache/blob/series/2.x/zio-cache/shared/src/main/scala/zio/cache/Cache.scala

raphw commented 8 months ago

I would assume that there is an issue in the Scala compiler here. Did you try to resolve the type variables using Java reflection? It would normally result in the same error.

jxnu-liguobin commented 8 months ago

I would assume that there is an issue in the Scala compiler here. Did you try to resolve the type variables using Java reflection? It would normally result in the same error.

Are you referring to the get method for reflecting Cache instances? But what I got was the Object

raphw commented 8 months ago

If you get hold of zio.cache.Cache$$anon$1 Class representstion, and call methods for getting generic types on it, I'd assume it yields similar exceptions.