Skip to content

Commit c5f533e

Browse files
Medowhillodersky
authored andcommitted
check SAM type also
1 parent f3f8ede commit c5f533e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,8 +2481,11 @@ class Typer extends Namer
24812481
!tree.symbol.is(InlineMethod) &&
24822482
!ctx.mode.is(Mode.Pattern) &&
24832483
!(isSyntheticApply(tree) && !isExpandableApply)) {
2484-
if (!defn.isFunctionType(pt) && !pt.classSymbol.hasAnnotation(defn.FunctionalInterfaceAnnot))
2485-
ctx.warning(ex"${tree.symbol} is eta-expanded even though ${pt.classSymbol} does not have the @FunctionalInterface annotation.", tree.pos)
2484+
pt match {
2485+
case SAMType(_) if !defn.isFunctionType(pt) && !pt.classSymbol.hasAnnotation(defn.FunctionalInterfaceAnnot) =>
2486+
ctx.warning(ex"${tree.symbol} is eta-expanded even though ${pt.classSymbol} does not have the @FunctionalInterface annotation.", tree.pos)
2487+
case _ =>
2488+
}
24862489
simplify(typed(etaExpand(tree, wtp, arity), pt), pt, locked)
24872490
} else if (wtp.paramInfos.isEmpty && isAutoApplied(tree.symbol))
24882491
readaptSimplified(tpd.Apply(tree, Nil))

0 commit comments

Comments
 (0)