Skip to content

Fix #1490: type test of union types via type alias #1491

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
Sep 1, 2016
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
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/transform/TypeTestsCasts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ trait TypeTestsCasts {
* The transform happens before erasure of `argType`, thus cannot be merged
* with `transformIsInstanceOf`, which depends on erased type of `argType`.
*/
def transformOrTypeTest(qual: Tree, argType: Type): Tree = argType match {
def transformOrTypeTest(qual: Tree, argType: Type): Tree = argType.dealias match {
case OrType(tp1, tp2) =>
evalOnce(qual) { fun =>
transformOrTypeTest(fun, tp1)
Expand Down
3 changes: 3 additions & 0 deletions tests/run/i1490.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
true
true
false
13 changes: 13 additions & 0 deletions tests/run/i1490.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Base {
type T = Int | Boolean
def test(x: Object) = x.isInstanceOf[T]
}

object Test {
def main(args: Array[String]) = {
val b = new Base
println(b.test(Int.box(3)))
println(b.test(Boolean.box(false)))
println(b.test(Double.box(3.4)))
}
}