Skip to content

Commit 2ecd3d2

Browse files
authored
Merge pull request #3277 from dotty-staging/fix-3206
Fix #3206: make sure partial function has `@unchecked`
2 parents 4062c4a + c3bb79d commit 2ecd3d2

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
878878
tree.selector match {
879879
case EmptyTree =>
880880
val (protoFormals, _) = decomposeProtoFunction(pt, 1)
881-
val unchecked = pt <:< defn.PartialFunctionType
881+
val unchecked = pt.isRef(defn.PartialFunctionClass)
882882
typed(desugar.makeCaseLambda(tree.cases, protoFormals.length, unchecked) withPos tree.pos, pt)
883883
case _ =>
884884
val sel1 = typedExpr(tree.selector)
@@ -2251,7 +2251,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
22512251
* tree that went unreported. A scenario where this happens is i1802.scala.
22522252
*/
22532253
def ensureReported(tp: Type) = tp match {
2254-
case err: ErrorType if !ctx.reporter.hasErrors => ctx.error(err.msg, tree.pos)
2254+
case err: ErrorType if !ctx.reporter.errorsReported => ctx.error(err.msg, tree.pos)
22552255
case _ =>
22562256
}
22572257

tests/neg/ensureReported.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object AnonymousF {
2+
val f = {
3+
case l @ List(1) => // error: missing parameter type // error: Ambiguous overload
4+
Some(l)
5+
}
6+
}

tests/patmat/i3206.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Test {
2+
val foo: PartialFunction[Option[Int], Int] = {
3+
case Some(x) => x
4+
}
5+
}

tests/patmat/partial-function.check

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)