Skip to content
Snippets Groups Projects
Commit f7d8de68 authored by Pete Gillin's avatar Pete Gillin
Browse files

Skip nullability validation of an enum's valueOf(String).

This method doesn't exist in source so we shouldn't be expected to
annotate it. (Tools consuming annotations should presumably
special-case it.)

Bug: 73448108
Test: make core-current-stubs-nullability-validation-check-nullability-warnings
Change-Id: I3dfab539ca49ca8ba834097c3ad6d6284c9ae782
parent f9cd204d
No related branches found
No related tags found
No related merge requests found
......@@ -100,6 +100,10 @@ class NullablityAnnotationsValidator() {
if (type == null) {
throw DriverException("Missing type on $method item $label")
}
if (method.isEnumValueOfString()) {
// Don't validate an enum's valueOf(String) method, which doesn't exist in source.
return
}
val annotations = item.modifiers.annotations()
val nullabilityAnnotations = annotations.filter(this::isAnyNullabilityAnnotation)
if (nullabilityAnnotations.size > 1) {
......@@ -198,3 +202,6 @@ class NullablityAnnotationsValidator() {
}
}
}
private fun MethodItem.isEnumValueOfString() =
containingClass().isEnum() && name() == "valueOf" && parameters().map { it.type().toTypeString() } == listOf("java.lang.String")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment