Skip to content

Fix #7783: Widen AnyVal to Any when checking class relation #7785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ object TypeTestsCasts {
cpy.TypeApply(tree)(expr1.select(sym).withSpan(expr.span), List(TypeTree(tp)))

def effectiveClass(tp: Type): Symbol =
if (tp.isRef(defn.PairClass)) effectiveClass(erasure(tp))
if tp.isRef(defn.PairClass) then effectiveClass(erasure(tp))
else if tp.isRef(defn.AnyValClass) then defn.AnyClass
else tp.classSymbol

def foundCls = effectiveClass(expr.tpe.widen)
Expand Down
6 changes: 6 additions & 0 deletions tests/run/i7783.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Test extends App {
def foo(t: AnyVal): Unit = t match {
case _: Int =>
}
foo(3)
}