Reputation: 92106
IntelliJ IDEA's Scala plugin many times complains about "type mismatch" even though the code in question compiles absolutely fine. I find this quite irritating, and would like to disable this feature. I didn't find any relevant option on searching in the settings. How do I get rid of it?
Upvotes: 3
Views: 4231
Reputation: 34443
There seems a way to disable type aware highlighting just for a region of Scala code in IntelliJ. This was mentioned by a JetBrains developer in SCL-10983, later I found a documentation in Troubleshoot common Scala issues.
Let us take following code (intentionally plain wrong):
class Data {
/*_*/
def data: Int = this
/*_*/
def dataAgain: Int = this
}
Only the second error will be highlighted in red, the first one enclosed in /*_*/
will be ignored.
Upvotes: 4
Reputation: 92106
@rxg: Here is a small test case to demonstrate the problem:
rows
is of type IndexedSeq[Row]
where Row
is from Apache POI's Excel library. traverse
if a function from Scalaz. Validation
is a data structure from Scalaz.
GryphonError
is an ADT from our codebase.
rows.zipWithIndex.traverse[({type L[X] = Validation[Seq[GryphonError], X]})#L, Seq[Any]] { case (row, r) =>
// some stuff
}
scalac compiles this code fine. IDEA's type-inspector complains:
Type mismatch, expected: ((Row, Int) => F[B])
actual: ((Row, Int) => F[IndexedSeq[B]])
Upvotes: 1
Reputation: 3982
You can completely turn off error highlighting by clicking the little man with a bowler hat at the bottom-right hand corner of the screen and choosing "None" for Highlighting Level. But then you lose all error highlighting, not just the one that is annoying you. (Sorry, StackOverflow won't let me post an image to show exactly where to find "Hector the Inspector!)
Upvotes: 4
Reputation: 7963
Switching off 'Type Aware Highlighting' by clicking this symbol may help a bit.
Edit
There are also a number of Scala specific inspections which can be enabled and disabled. These can be accessed by clicking on the 'Inspector' icon (just to the left of the 'Type Aware' icon) shown in the first screenshot above and clicking 'configure inspections on the pop-up dialog.
Upvotes: 10