Re: Inspection for null on left side of comparison if(null=company)... ?

Hello Taras,

I stand corrected - I configured an IDEA SDK for the IDEA project by
mistake.

As for the inspection in questions,
com.intellij.psi.util.IsConstantExpressionVisitor#visitLiteralExpressi
on() seem to special-case null. Is there some language detail that I
forgot?


We looked at that code and tried to understand why it does that, but couldn't
figure it out right away, and the checkin comment for the change introducing
that special case is empty. :)

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


3 comments
Comment actions Permalink

Hello Taras,

I stand corrected - I configured an IDEA SDK for the IDEA project by
mistake.

As for the inspection in questions,
com.intellij.psi.util.IsConstantExpressionVisitor#visitLiteralExpressi
on() seem to special-case null. Is there some language detail that I
forgot?


We looked at that code and tried to understand why it does that, but couldn't
figure it out right away, and the checkin comment for the change introducing
that special case is empty. :)

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Hello Taras,

As for the inspection in questions,
com.intellij.psi.util.IsConstantExpressionVisitor#visitLiteralExpression()
seem to special-case null. Is there some language detail that I forgot?


AFAIK, null is not constant according to JLS. For example that's also why null can't be used as
default value in annotations.

Sascha

0
Comment actions Permalink

Hello Sascha,

Indeed, Bas reminded me of this distinction in the comments for http://youtrack.jetbrains.net/issue/IDEADEV-41208
I think that in the context of this inspection it can be treated as a constant though.

Taras

0

Please sign in to leave a comment.