Skip to content

Commit 2828fcf

Browse files
authored
Merge pull request #7785 from dotty-staging/fix-#7783
Fix #7783: Widen AnyVal to Any when checking class relation
2 parents 4e92703 + c8f66e4 commit 2828fcf

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ object TypeTestsCasts {
168168
cpy.TypeApply(tree)(expr1.select(sym).withSpan(expr.span), List(TypeTree(tp)))
169169

170170
def effectiveClass(tp: Type): Symbol =
171-
if (tp.isRef(defn.PairClass)) effectiveClass(erasure(tp))
171+
if tp.isRef(defn.PairClass) then effectiveClass(erasure(tp))
172+
else if tp.isRef(defn.AnyValClass) then defn.AnyClass
172173
else tp.classSymbol
173174

174175
def foundCls = effectiveClass(expr.tpe.widen)

tests/run/i7783.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test extends App {
2+
def foo(t: AnyVal): Unit = t match {
3+
case _: Int =>
4+
}
5+
foo(3)
6+
}

0 commit comments

Comments
 (0)