Bogus syntax error: Scala plugin seems to be failing to detect case classes (Solved)

After upgrading the Scala plugin on Intellij IDEA 12 (12.1.4 build 129.713) recently, I've been getting this error in all of my project's case classes:

Class APIError must be declared abstract or implement abstract member 'equals(that: Any: Boolean)' in 'scala.Equals'



It looks a bit to me like the syntax parser is failing to determine a class is actually a case class, and therefore gets automatic implementations of some methods.

The project is generated through SBT (0.12) in Play Framework (2.1.3) project. When I compile through SBT everything goes fine without any warnings or errors at all.

I tried fiddling a bit with the project generation options but nothing helps (I had not changed them from the defaults previously besides using with-sources=yes). I also tried completely erasing the .idea and .idea_modules folders, recreating the project's artifact caches from scratch, but the error is still there.

Here is a small sample of a file which exhibits the issue.

package controllers

import play.api.http.Status
import play.api.mvc.Results
import play.api.libs.json._

object APIError {
  implicit val APIErrorFormat = Json.format[APIError]

  def JsonError(error: JsError) = APIError(
    Status.BAD_REQUEST,
    0,
    "JSON_ERROR",
    "Error parsing JSON input",
    JsError.toFlatJson(error)
  )

  def ValidationError(key: String, message: String) = APIError(
    Status.BAD_REQUEST,
    0,
    "VALIDATION_ERROR",
    s"Validation error ($key): $message"
  )

  def KeyConstraintError[V](key: String, value: V)(implicit w: Writes[V]) = APIError(
    Status.BAD_REQUEST,
    0,
    "KEY_CONSTRAINT_ERROR",
    s"Object with key `$key` already exists",
    Json.obj(
      "key" -> key,
      "value" -> value
    )
  )
}

case class APIError(
  httpCode: Int,
  subCode: Int,
  key: String,
  message: String,
  data: JsValue = Json.obj())
{
  def toResult =
    Results.Status(httpCode)(Json.toJson[APIError](this))
}
2 comments

This is both embarassing and weird: apparently I had accidentaly erased my configured JDK, and that caused those errors. Setting it back up solved everything.

I would never have guessed it though if I hadn't stumbled onto it while messing with unrelated settings.

Maybe a big flashy warning 'you don't have a JDK set up, dumbass' could help clumsy people like me ¯\_(ツ)_/¯

0

Such a warning, and many more, are on the way. Sorry for the inconvenience.

0

Please sign in to leave a comment.