File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ class ExpandSAMs extends MiniPhaseTransform { thisTransformer =>
3535 tpt.tpe match {
3636 case NoType => tree // it's a plain function
3737 case tpe @ SAMType (_) if tpe.isRef(defn.PartialFunctionClass ) =>
38+ checkRefinements(tpe, fn.pos)
3839 toPartialFunction(tree)
3940 case tpe @ SAMType (_) if isPlatformSam(tpe.classSymbol.asClass) =>
4041 checkRefinements(tpe, fn.pos)
@@ -90,7 +91,7 @@ class ExpandSAMs extends MiniPhaseTransform { thisTransformer =>
9091 private def checkRefinements (tpe : Type , pos : Position )(implicit ctx : Context ): Unit = tpe match {
9192 case RefinedType (parent, name, _) =>
9293 if (name.isTermName && tpe.member(name).symbol.ownersIterator.isEmpty) // if member defined in the refinement
93- ctx.error(s " Cannot refine $name on a lambda " , pos)
94+ ctx.error(" Lambda does not define " + name , pos)
9495 checkRefinements(parent, pos)
9596 case _ =>
9697 }
Original file line number Diff line number Diff line change @@ -12,4 +12,6 @@ object Foo {
1212 val fun0a : Fun0 [Int ] = () => 42
1313 val fun0b : Fun0 [Int ] { def foo (): Int } = () => 42 // error
1414
15+ val pf : PartialFunction [Int , Int ]{ def foo (): Int } = { case x1 => 42 } // error
16+
1517}
You can’t perform that action at this time.
0 commit comments