Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDEA reports 'Cannot assign' every time def is used in Groovy

I am struggling to prevent IDEA from complaining about assignment to variable declared by def keyword.

enter image description here

The assignment is absolutely safe as far as I can tell (I observe the same for literals of other types assigned to defed variables). I do not see why assigning Integer into Object would be a problem in the first place.

There does not seem to be any explanation in inspections settings (Groovy > Assignment issues > Incompatible type assignments) nor any fine grained configuration to tune this. When turned off completely, it stops reporting real problems like Integer a = "" as well.

How do I get it to report real problems without highlighting safe assignments?

like image 461
Oliver Gondža Avatar asked Oct 14 '25 03:10

Oliver Gondža


1 Answers

IntelliJ IDEA can not relay grok the groovy code unless there are both Groovy and Java SDKs configured. By importing the project Groovy got configured automatically, but Java did not.

like image 169
Oliver Gondža Avatar answered Oct 19 '25 13:10

Oliver Gondža



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!