summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala5
-rw-r--r--test/files/pos/t8861.flags1
-rw-r--r--test/files/pos/t8861.scala11
3 files changed, 14 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index cf97474d9a..27e17fc65f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -553,9 +553,8 @@ trait Infer extends Checkable {
// ...or lower bound of a type param, since they're asking for it.
def canWarnAboutAny = {
val loBounds = tparams map (_.info.bounds.lo)
- val hasAny = pt :: restpe :: formals ::: argtpes ::: loBounds exists (t =>
- (t contains AnyClass) || (t contains AnyValClass)
- )
+ def containsAny(t: Type) = (t contains AnyClass) || (t contains AnyValClass)
+ val hasAny = pt :: restpe :: formals ::: argtpes ::: loBounds exists (_.dealiasWidenChain exists containsAny)
!hasAny
}
def argumentPosition(idx: Int): Position = context.tree match {
diff --git a/test/files/pos/t8861.flags b/test/files/pos/t8861.flags
new file mode 100644
index 0000000000..99a6391058
--- /dev/null
+++ b/test/files/pos/t8861.flags
@@ -0,0 +1 @@
+-Xlint:infer-any -Xfatal-warnings
diff --git a/test/files/pos/t8861.scala b/test/files/pos/t8861.scala
new file mode 100644
index 0000000000..816d15700e
--- /dev/null
+++ b/test/files/pos/t8861.scala
@@ -0,0 +1,11 @@
+
+trait Test {
+ type R = PartialFunction[Any, Unit]
+
+ val x: R = { case "" => }
+ val y: R = { case "" => }
+
+ val z: R = x orElse y
+ val zz = x orElse y
+}
+