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 =>
35
35
tpt.tpe match {
36
36
case NoType => tree // it's a plain function
37
37
case tpe @ SAMType (_) if tpe.isRef(defn.PartialFunctionClass ) =>
38
+ checkRefinements(tpe, fn.pos)
38
39
toPartialFunction(tree)
39
40
case tpe @ SAMType (_) if isPlatformSam(tpe.classSymbol.asClass) =>
40
41
checkRefinements(tpe, fn.pos)
@@ -90,7 +91,7 @@ class ExpandSAMs extends MiniPhaseTransform { thisTransformer =>
90
91
private def checkRefinements (tpe : Type , pos : Position )(implicit ctx : Context ): Unit = tpe match {
91
92
case RefinedType (parent, name, _) =>
92
93
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)
94
95
checkRefinements(parent, pos)
95
96
case _ =>
96
97
}
Original file line number Diff line number Diff line change @@ -12,4 +12,6 @@ object Foo {
12
12
val fun0a : Fun0 [Int ] = () => 42
13
13
val fun0b : Fun0 [Int ] { def foo (): Int } = () => 42 // error
14
14
15
+ val pf : PartialFunction [Int , Int ]{ def foo (): Int } = { case x1 => 42 } // error
16
+
15
17
}
You can’t perform that action at this time.
0 commit comments