Skip to content

Commit c30bc9b

Browse files
committed
Fix generation of lambdas for Unit-returning closures.
1 parent 60824de commit c30bc9b

24 files changed

+510
-1
lines changed

src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,10 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
796796
if(t.exists) t
797797
else {
798798
val arity = field.meth.tpe.widenDealias.paramTypes.size - _1.size
799-
ctx.requiredClass(("scala.compat.java8.JFunction"+arity).toTermName)
799+
val returnsUnit = field.meth.tpe.widenDealias.resultType.classSymbol == UnitClass
800+
if(returnsUnit)
801+
ctx.requiredClass(("scala.compat.java8.JProcedure"+arity).toTermName)
802+
else ctx.requiredClass(("scala.compat.java8.JFunction"+arity).toTermName)
800803
}
801804
}
802805
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure0 extends JFunction0<BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid();
16+
17+
default BoxedUnit apply() {
18+
applyVoid();
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure1<T1> extends JFunction1<T1, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1);
16+
17+
default BoxedUnit apply(T1 t1) {
18+
applyVoid(t1);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> extends JFunction10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> extends JFunction11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> extends JFunction12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> extends JFunction13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> extends JFunction14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> extends JFunction15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> extends JFunction16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> extends JFunction17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> extends JFunction18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> extends JFunction19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure2<T1, T2> extends JFunction2<T1, T2, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2) {
18+
applyVoid(t1, t2);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> extends JFunction20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> extends JFunction21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20, T21 t21);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20, T21 t21) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
* Copyright (C) 2012-2014 Typesafe Inc. <http://www.typesafe.com>
4+
*/
5+
6+
package scala.compat.java8;
7+
8+
import scala.runtime.BoxedUnit;
9+
10+
@FunctionalInterface
11+
public interface JProcedure22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> extends JFunction22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, BoxedUnit> {
12+
default void $init$() {
13+
}
14+
15+
void applyVoid(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20, T21 t21, T22 t22);
16+
17+
default BoxedUnit apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17, T18 t18, T19 t19, T20 t20, T21 t21, T22 t22) {
18+
applyVoid(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22);
19+
return BoxedUnit.UNIT;
20+
}
21+
}
22+

0 commit comments

Comments
 (0)