File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed
compiler/src/dotty/tools/dotc/config Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,10 @@ class JavaPlatform extends Platform {
5050 cls.superClass == defn.ObjectClass &&
5151 cls.directlyInheritedTraits.forall(_.is(NoInits )) &&
5252 ! ExplicitOuter .needsOuterIfReferenced(cls) &&
53- cls.typeRef.fields.isEmpty // Superaccessors already show up as abstract methods here, so no test necessary
53+ // Superaccessors already show up as abstract methods here, so no test necessary
54+ cls.typeRef.fields.isEmpty &&
55+ // LambdaMetafactory can't handle SAMs with Unit return type unless it's a FunctionN itself
56+ ! cls.typeRef.possibleSamMethods.exists(_.info.resultType.isRef(defn.UnitClass ))
5457
5558 /** We could get away with excluding BoxedBooleanClass for the
5659 * purpose of equality testing since it need not compare equal
Original file line number Diff line number Diff line change 1+ 1
2+ 2
3+ 3
4+ 42
5+ hello
Original file line number Diff line number Diff line change 1+ trait Con [- T ] extends (T => Unit ):
2+ def apply (t : T ): Unit
3+
4+ trait Con2 [- T ] extends (T => Int ):
5+ def apply (t : T ): Int
6+
7+ trait Con3 [+ R ] extends (() => R ):
8+ def apply (): R
9+
10+ object Test :
11+ def main (args : Array [String ]): Unit =
12+ val f1 : (Int => Unit ) = i => println(i)
13+ f1(1 )
14+
15+ val c1 : Con [Int ] = i => println(i)
16+ c1(2 )
17+
18+ val c2 : Con2 [Int ] = i => { println(i); i }
19+ c2(3 )
20+
21+ val c3 : Con3 [Int ] = () => 42
22+ println(c3())
23+
24+ val c4 : Con3 [Unit ] = () => println(" hello" )
25+ c4()
You can’t perform that action at this time.
0 commit comments