0

Picture says it all:

enter image description here

I want the squiggle to be under Int, rather than having it under an unintended type (Unit in the example)

How do I achieve this behavior?

improbable
  • 2,308
  • 2
  • 15
  • 28
nz_21
  • 6,140
  • 7
  • 34
  • 80
  • This is warning you that your types don't match and your code won't compile, so the best idea is to fix the code so that the warning goes away. – Tim Dec 18 '19 at 23:26
  • I agree that a warning is a good thing. However, I would much prefer to have the squiggle under `Int`, rather than having it below a completely new type. That's the default behavior for other languages as well – nz_21 Dec 18 '19 at 23:29
  • I disagree that "That's the default behavior for other languages." I just tried in Java with `int wha() { return ""; }`, and jshell highlights `""`, not `int`. Haskell and [Pytype](https://github.com/google/pytype) gave similar behavior. – Brian McCutchon Dec 19 '19 at 02:13
  • @Brian I meant that's the default behavior of *Intellij* for other languages – nz_21 Dec 19 '19 at 02:15
  • @nz_21I update my answer, and this is a complete answer to your question. – improbable Apr 13 '20 at 11:40

2 Answers2

0

You have defined a function that returns Int but your implementation returns Unity, you can fix it by providing a default return value or null

def wha():Int = {
   0
}
0

You can't. All kinds of errors, warnings, problems, etc. for certain behavior are pre-setup and called inspections in IntelliJ. They are configured in "Inspections"(Preferences | Editor | Inspections) for all languages and frameworks separately. The only configuration available there is to enable/disable an inspection and change its severity level - you cannot change how they work.

UPDATE:
Apparently, recently Jetbrains introduced the feature to create custom inspections through Structural Search Inspection. You should be able to create custom inspection for Scala otherwise it's still not achievable.
And there is still no posibility to edit pre-existing inspections though as of version 2020.1

improbable
  • 2,308
  • 2
  • 15
  • 28