We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The following code does not compile:
import scala.reflect.ClassTag import scala.util._ object Main { class A def constructAs[T <: A: ClassTag]: Try[T] = Try { new A() }.flatMap { case inst: T => Success(inst) case _ => val tag = implicitly[ClassTag[T]] Failure(new ClassCastException(s"Failed to construct instance of class ${tag.runtimeClass.getName}")) } }
Dotc gives the following error:
Main.scala:10: error: type mismatch: found : Main.A(inst) required: Nothing' case inst: T => Success(inst) ^ one error found
If I leave out the context bound, the code compiles fine. In Scala 2.11.8 it compiles too.
Weirdly enough, if I leave out the explicit return type, it also compiles fine.
The text was updated successfully, but these errors were encountered:
Fix problem involving classtag based pattern matches.
4df2e28
Rewriting did not go far enough, as evidenced by pos/i1174.scala Fixes scala#1174
Merge pull request #1187 from dotty-staging/fix-#1174
fadcf44
No branches or pull requests
The following code does not compile:
Dotc gives the following error:
If I leave out the context bound, the code compiles fine. In Scala 2.11.8 it compiles too.
Weirdly enough, if I leave out the explicit return type, it also compiles fine.
The text was updated successfully, but these errors were encountered: