-
Notifications
You must be signed in to change notification settings - Fork 21
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
Error message not helpful when val definition contains extra '()' #6564
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6564?orig=1 |
@retronym said: scala> object a { def unapply(a: Any): Boolean = true }
defined module a
scala> { val a(): String = ""; 0 }
res3: Int = 0
scala> cm.universe.reify { val a(): String = "" }
res18: cm.universe.Expr[Unit] =
Expr[Unit]({
<synthetic> private[this] val x$1 = ("": @unchecked: String) match {
case a() => ()
};
()
})
scala> val cm = reflect.runtime.currentMirror
cm: reflect.runtime.universe.Mirror = JavaMirror with ...
scala> cm.universe.showRaw(res18)
res19: String =
Expr[Unit]({
<synthetic> private[this] val x$1 = ("": @unchecked: String) match {
case a() => ()
};
()
})
scala> cm.universe.showRaw(res18.tree)
res20: String = Block(List(ValDef(Modifiers(PRIVATE | LOCAL | SYNTHETIC), newTermName("x$1"), TypeTree(), Match(Typed(Annotated(Apply(Select(New(Ident(scala.unchecked)), nme.CONSTRUCTOR), List()), Literal(Constant(""))), Ident(newTypeName("String"))), List(CaseDef(Apply(Select(Select(Select(Select(Ident($line34), newTermName("$read")), newTermName("$iw")), newTermName("$iw")), newTermName("a")), List()), EmptyTree, Literal(Constant(()))))))), Literal(Constant(())))
|
@adriaanm said: |
Punting this in favor of actual correctness bugs in this area. Possible umbrella issue: #11800 The use case is switching This case is probably a scalafix lint. |
If a val definition contains an extra set of parenthesis, like if not correctly transforming a def into a val, the error reported by the compiler is not really helpful.
It would be better if the error was something like:
expected ':' or '=', found '('
The text was updated successfully, but these errors were encountered: