Structural types: Structural access not allowed … because it has a parameter type with an unstable erasure

It’s a restriction specifically of the reflectiveSelectable implementation of Selectable. Since reflectiveSelectable uses JVM method handles it needs a precise parameter and return type signature for isBefore. But since isBefore uses a local type parameter, that signature cannot be generated.

For normal method calls that’s not a problem since there is a clever “bridge” machinery to compensate for the rigidity of JVM signatures. But those techniques cannot be used for reflective access.

So, it’s a rather technical implementation restriction due to a limitation of the JVM. Note also that this only applies to reflectiveSelectable, Other implementations of Selectable might not have that restriction.

2 Likes