diff options
author | Martin Odersky <odersky@gmail.com> | 2016-03-21 18:17:26 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-03-21 18:17:30 +0100 |
commit | 4df2e28a54978ee16e24bab961d9b491b6fe8707 (patch) | |
tree | c27b15c30014727a234804f7010be0cbf85ad28d /tests | |
parent | 1b29119b8ed1a2c3b382dfca01d6dde71f6ae733 (diff) | |
download | dotty-4df2e28a54978ee16e24bab961d9b491b6fe8707.tar.gz dotty-4df2e28a54978ee16e24bab961d9b491b6fe8707.tar.bz2 dotty-4df2e28a54978ee16e24bab961d9b491b6fe8707.zip |
Fix problem involving classtag based pattern matches.
Rewriting did not go far enough, as evidenced by pos/i1174.scala
Fixes #1174
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/i1174.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/pos/i1174.scala b/tests/pos/i1174.scala new file mode 100644 index 000000000..5875a38ad --- /dev/null +++ b/tests/pos/i1174.scala @@ -0,0 +1,19 @@ +import scala.reflect.ClassTag +import scala.util._ + +object Main { + class A + + def constructAs[TTT <: A](implicit ev: ClassTag[TTT]): Try[TTT] = Try { + new A() + }.flatMap { + case ev(inst) => + val b: TTT = inst + Success(inst) + case inst: TTT => + Success(inst) + case _ => + val tag = implicitly[ClassTag[TTT]] + Failure(new ClassCastException(s"Failed to construct instance of class ${tag.runtimeClass.getName}")) + } +} |