Skip to content

Commit 66802ac

Browse files
committed
Discover present java8-compat classes during compilation.
Function0, Function1, Function2 are all specialized for different type params. FunctionalInterface filters out classes that are known to not exists and relies on getClassIfDefined for a precise check.
1 parent 815516b commit 66802ac

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/dotty/tools/dotc/transform/FunctionalInterfaces.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ class FunctionalInterfaces extends MiniPhaseTransform {
6565
if (shouldSpecialize(m)) {
6666
val interfaceName = (functionName ++ m.paramTypes.length.toString).specializedFor(m.resultType, m.paramTypes)
6767
// symbols loaded from classpath aren't defined in periods earlier than when they where loaded
68-
val interface = ctx.withPhase(ctx.typerPhase).requiredClass(functionPackage ++ interfaceName)
69-
val tpt = tpd.TypeTree(interface.asType.typeRef)
70-
tpd.Closure(tree.env, tree.meth, tpt)
68+
val interface = ctx.withPhase(ctx.typerPhase).getClassIfDefined(functionPackage ++ interfaceName)
69+
if (interface.exists) {
70+
val tpt = tpd.TypeTree(interface.asType.typeRef)
71+
tpd.Closure(tree.env, tree.meth, tpt)
72+
} else tree
7173
} else tree
7274
case _ =>
7375
tree

0 commit comments

Comments
 (0)