Stricter check for enum classes in EnumModelProvider #558 #559
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Co-author: @volivan239
Description
Java enums allow users to declare anonymous classes corresponding to constants. These classes are commonly used to overload
toString
or methods declared in the enum class. These classes are not enums themselves. According to the comment in thejava.lang.Class#isEnum
method:Suppose we have an enum:
Anonymous inner classes
Foo$1
andFoo$2
are (non-direct) subtypes ofjava.lang.Enum
, but are not declared as enums, and are not considered enums from the point of view of the Java specification: their direct superclass isFoo
.These specialized anonymous classes do not have enum constants themselves, and
getEnumConstants
method will returnnull
for them.Fixes #558
Type of Change
How Has This Been Tested?
Automated Testing
No new unit tests are added. All existing tests should pass.
Manual Scenario
Run the contest estimator on
com.google.common.base.CaseFormat
class of the Guava library by editingmain
function body inContestEstimator.kt
:Tests (probably with errors due to other issues) should be generated. Without the fix, a
NullPointerException
would be thrown, and no tests would be generated.Checklist: