Skip to content

fix #8956: add regression test #9128

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 2 commits into from
Jun 8, 2020
Merged
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions tests/pos/i8956.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
type Numeric = Double | Int

val v1 = 100
val v2 = 100.0
def check1(i: Double | Int | String): Unit = {
i match {
case a:(Double | Int) => println(s"numeric = $a")
case _ => println("categorical")
}
}
/*
[warn] 25 | case a:Numeric => println(s"numeric = $a")
[warn] | ^^^^^^^^^
[warn] | the type test for gg.SlidingIssue.Numeric cannot be checked at runtime
[warn] one warning found
*/
def check2(i: Double | Int | String): Unit = {
i match {
case a:Numeric => println(s"numeric = $a")
case _ => println("categorical")
}
Copy link
Contributor

@liufengyun liufengyun Jun 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to add a check file for this to avoid regression.

Edited: -Xfatal-warnings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved it to tests/pos-special/fatal-warnings/i8956.scala

}