File tree 3 files changed +16
-1
lines changed
compiler/src/dotty/tools/dotc
3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -638,6 +638,9 @@ object Flags {
638
638
/** value that's final or inline */
639
639
final val FinalOrInline : FlagSet = Final | Inline
640
640
641
+ /** class that's final or sealed */
642
+ final val FinalOrSealed : FlagSet = Final | Sealed
643
+
641
644
/** A covariant type parameter instance */
642
645
final val LocalCovariant : FlagConjunction = allOf(Local , Covariant )
643
646
Original file line number Diff line number Diff line change @@ -985,7 +985,11 @@ class Typer extends Namer
985
985
case SAMType (sam)
986
986
if ! defn.isFunctionType(pt) && mt <:< sam =>
987
987
if (! isFullyDefined(pt, ForceDegree .all))
988
- ctx.error(ex " result type of closure is an underspecified SAM type $pt" , tree.sourcePos)
988
+ ctx.error(ex " result type of lambda is an underspecified SAM type $pt" , tree.sourcePos)
989
+ else if (pt.classSymbol.is(FinalOrSealed )) {
990
+ val offendingFlag = pt.classSymbol.flags & FinalOrSealed
991
+ ctx.error(ex " lambda cannot implement $offendingFlag ${pt.classSymbol}" , tree.sourcePos)
992
+ }
989
993
TypeTree (pt)
990
994
case _ =>
991
995
if (mt.isParamDependent) {
Original file line number Diff line number Diff line change
1
+ val x : String <:< Int = _.toInt // error
2
+
3
+ abstract final class Foo { def f (x : Int ): Int }
4
+
5
+ val foo : Foo = x => x // error
6
+
7
+ val foo2 : Foo = Predef .identity // error
8
+
You can’t perform that action at this time.
0 commit comments