Skip to content

Generate specialized Functional Interfaces for Function{0,1,2} #16

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

Merged
merged 4 commits into from
Nov 17, 2014

Conversation

retronym
Copy link
Member

No description provided.

As exerciced in the test, a specialized (Int => Int) function can
be implemented by extending the functional interface
`JFunction1$mcII$sp`.

Representative example of the generated code:

```java
public interface JFunction0$mcV$sp extends JFunction0 {
    abstract void apply$mcV$sp();

    default Object apply() { apply$mcV$sp(); return scala.runtime.BoxedUnit.UNIT; }
}

public interface JFunction0$mcZ$sp extends JFunction0 {
    abstract boolean apply$mcZ$sp();

    default Object apply() { return (Boolean) apply$mcZ$sp(); }
}

public interface JFunction1$mcDD$sp extends JFunction1 {
    abstract double apply$mcDD$sp(double v1);

    default Object apply(Object t) { return (Double) apply$mcDD$sp((Double) t); }
}

public interface JFunction1$mcVD$sp extends JFunction1 {
    abstract void apply$mcVD$sp(double v1);

    default Object apply(Object t) { apply$mcVD$sp((Double) t); return scala.runtime.BoxedUnit.UNIT; }
}

public final class JFunction {
    private JFunction() {}
    public static <R> scala.Function0<R> func(JFunction0<R> f) { return f; }
    public static scala.Function0<BoxedUnit> proc(JProcedure0 p) { return p; }
    public static scala.Function0<BoxedUnit> procSpecialized(JFunction0$mcV$sp f) { return f; }
    public static scala.Function0<Byte> funcSpecialized(JFunction0$mcB$sp f) { return f; }
    public static scala.Function0<Short> funcSpecialized(JFunction0$mcS$sp f) { return f; }
    public static scala.Function0<Integer> funcSpecialized(JFunction0$mcI$sp f) { return f; }
    public static scala.Function0<Long> funcSpecialized(JFunction0$mcJ$sp f) { return f; }
    public static scala.Function0<Character> funcSpecialized(JFunction0$mcC$sp f) { return f; }
    public static scala.Function0<Float> funcSpecialized(JFunction0$mcF$sp f) { return f; }
    public static scala.Function0<Double> funcSpecialized(JFunction0$mcD$sp f) { return f; }
    public static scala.Function0<Boolean> funcSpecialized(JFunction0$mcZ$sp f) { return f; }
    public static <T1, R> scala.Function1<T1, R> func(JFunction1<T1, R> f) { return f; }
    public static <T1> scala.Function1<T1, BoxedUnit> proc(JProcedure1<T1> p) { return p; }
    public static scala.Function1<Integer, BoxedUnit> procSpecialized(JFunction1$mcVI$sp f) { return f; }
    public static scala.Function1<Integer, Boolean> funcSpecialized(JFunction1$mcZI$sp f) { return f; }
```

I've also modified the code generator to create `JProcedure0` (which
was an oversight), and to switch to Scala 2.11.4.
Handy when varying other build parameters, such as `scalaVersion`,
results in unavailabilty of genjavadoc or in a Scaladoc bug.
retronym added a commit that referenced this pull request Nov 17, 2014
Generate specialized Functional Interfaces for Function{0,1,2}
@retronym retronym merged commit f3d7993 into scala:master Nov 17, 2014
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

Successfully merging this pull request may close these issues.

1 participant