Skip to content

Commit 6fb6680

Browse files
Medowhillodersky
authored andcommitted
reordered checks
1 parent c5f533e commit 6fb6680

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,11 +2481,10 @@ class Typer extends Namer
24812481
!tree.symbol.is(InlineMethod) &&
24822482
!ctx.mode.is(Mode.Pattern) &&
24832483
!(isSyntheticApply(tree) && !isExpandableApply)) {
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-
}
2484+
if (!pt.classSymbol.hasAnnotation(defn.FunctionalInterfaceAnnot) &&
2485+
!defn.isFunctionType(pt) &&
2486+
SAMType.unapply(pt).isDefined)
2487+
ctx.warning(ex"${tree.symbol} is eta-expanded even though ${pt.classSymbol} does not have the @FunctionalInterface annotation.", tree.pos)
24892488
simplify(typed(etaExpand(tree, wtp, arity), pt), pt, locked)
24902489
} else if (wtp.paramInfos.isEmpty && isAutoApplied(tree.symbol))
24912490
readaptSimplified(tpd.Apply(tree, Nil))

0 commit comments

Comments
 (0)