Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type classes derivation : arrays (or varargs) are problematic #81

Open
gneuvill opened this issue Jan 12, 2018 · 1 comment
Open

Type classes derivation : arrays (or varargs) are problematic #81

gneuvill opened this issue Jan 12, 2018 · 1 comment

Comments

@gneuvill
Copy link
Contributor

gneuvill commented Jan 12, 2018

Ex:

@Data @Derive(@Instances(Equal.class))
public interface VThing {
   interface Cases<R> {
        R VThing(String... names); // or String[]
    }
   <R> R match(Cases<R> cases);
}

Behaviour : no instances is searched after (because in DeriveUtilsImpl.instanceInitializer, instance resolution is conditioned by the arg. type being a DeclaredType, which ArrayType are not) ; consequently, uncompilable code gets generated

Current workaround : use a collection type for which instances can be resolved.

@jbgi Is this worth fixing ?

@gneuvill gneuvill changed the title Type classes derivation : varargs are problematic Type classes derivation : arrays (or varargs) are problematic Mar 12, 2018
jbgi pushed a commit that referenced this issue Mar 17, 2018
@jbgi
Copy link
Member

jbgi commented Mar 17, 2018

Slightly improved via the last commits: see https://github.com/derive4j/derive4j/blob/master/examples/src/main/java/org/derive4j/example/ArrayWrapper.java#L21
But yeah, not sure if it's worth going any further: one should probably use immutable array wrappers anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants