Delite
Delite copied to clipboard
Suggest: Add -Xfatal-warnings to build
I suggest turning all build warnings into compiler errors. I have noticed that there are lots of potentially fatal errors lurking in Delite's codebase. There are many (>50) instances of code that relies upon not-present functionality. Specifically, pattern matching on something's type when that type information will not be present due to Java's runtime type erasure.
The standard ways to do this behavior w/in Scala use ClassTag
s. There's also TypeTag
s and Manifest
s, which are built for this exact thing. [1] However, there's an incompatibility w/ TypeTag
for Scala 2.10 (iirc): only works on 2.11.
In my experience, I've been able to do a lot of runtime type checking by using a ClassTag
, getting the actual type's runtime type (as a Class
instance), then checking to see if that is the same type that we're looking for. This is a good resource [2].
For the flag, we'd have to go to project/Build.scala
and add the following setting:
scalacOptions += "-Xfatal-warnings",
[1] http://docs.scala-lang.org/overviews/reflection/typetags-manifests.html [2] https://scalerablog.wordpress.com/2015/12/21/classtag-class-and-war-stories/