Fix UOE when using Java annotation with infinity/NaN as default value

The root problem is the fact that ConstantExpressionEvaluator returns
null for values such as infinity and NaN loaded from cls psi (see
IDEA-207252). This commit simply reverts a part of 8ab9226805 where we
started to compute default values more often than needed. In
LazyJavaClassMemberScope, we only need to check whether or not there
_is_ a default value, not compute its value.

 #KT-29792 Fixed
This commit is contained in:
Alexander Udalov
2019-02-13 17:49:03 +01:00
parent b2cdf2dc74
commit f2bf81e799
10 changed files with 76 additions and 2 deletions
@@ -675,7 +675,7 @@ class LazyJavaClassMemberScope(
method.name,
// Parameters of annotation constructors in Java are never nullable
TypeUtils.makeNotNullable(returnType),
method.annotationParameterDefaultValue != null,
method.hasAnnotationParameterDefaultValue,
/* isCrossinline = */ false,
/* isNoinline = */ false,
// Nulls are not allowed in annotation arguments in Java
@@ -105,7 +105,12 @@ interface JavaMethod : JavaMember, JavaTypeParameterListOwner {
val valueParameters: List<JavaValueParameter>
val returnType: JavaType
// WARNING: computing the default value may lead to an exception in the compiler because of IDEA-207252.
// If you only need to check default value presence, use `hasAnnotationParameterDefaultValue` instead.
val annotationParameterDefaultValue: JavaAnnotationArgument?
val hasAnnotationParameterDefaultValue: Boolean
get() = annotationParameterDefaultValue != null
}
interface JavaField : JavaMember {