Skip to content

Commit 8c15b6a

Browse files
committed
apt: remove kotlin generated warning
1 parent dbc5bcd commit 8c15b6a

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

  • modules/jooby-apt/src/main/java/io/jooby/internal/apt

‎modules/jooby-apt/src/main/java/io/jooby/internal/apt/WebRoute.java‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,22 +163,29 @@ public void setUncheckedCast(boolean value) {
163163

164164
protected List<String> getJavaMethodSignature(boolean kt) {
165165
return getParameters(false).stream()
166-
.map(
167-
it -> {
168-
var type = it.getType();
169-
if (kt && type.isPrimitive()) {
170-
return type(kt, type.getRawType().toString());
171-
}
172-
return type.getRawType().toString();
173-
})
166+
.map(it -> {
167+
var type = it.getType();
168+
if (kt && type.isPrimitive()) {
169+
return type(kt, type.getRawType().toString());
170+
}
171+
return type.getRawType().toString();
172+
})
174173
.map(it -> it + clazz(kt))
175174
.toList();
176175
}
177176

178177
protected boolean isNullableKotlinReturn() {
178+
// Kotlin always marks the Object return type of a suspend fun as @Nullable (it may return
179+
// COROUTINE_SUSPENDED), so it says nothing about the declared return type.
180+
var annotations =
181+
isSuspendFun()
182+
? getReturnType().getType().getAnnotationMirrors()
183+
: Stream.concat(
184+
method.getAnnotationMirrors().stream(),
185+
method.getReturnType().getAnnotationMirrors().stream())
186+
.toList();
179187
// SpotBugs/FindBugs vs JSpecify:
180-
return Stream.of(method.getAnnotationMirrors(), method.getReturnType().getAnnotationMirrors())
181-
.flatMap(List::stream)
188+
return annotations.stream()
182189
.map(javax.lang.model.element.AnnotationMirror::getAnnotationType)
183190
.map(java.util.Objects::toString)
184191
.anyMatch(AnnotationSupport.NULLABLE);

0 commit comments

Comments
 (0)