Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
RELNOTES=N/A
PiperOrigin-RevId: 584100389
  • Loading branch information
cushon authored and Dagger Team committed Nov 20, 2023
1 parent afc33bf commit 75a3a0a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions java/dagger/internal/codegen/binding/MethodSignatureFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import androidx.room.compiler.processing.XTypeElement;
import androidx.room.compiler.processing.XVariableElement;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Streams;
import com.squareup.javapoet.ClassName;
import dagger.internal.codegen.base.Formatter;
import dagger.internal.codegen.xprocessing.XAnnotations;
Expand Down Expand Up @@ -152,17 +153,24 @@ private static String nameOfType(XType type) {
}

private static ImmutableList<String> formatedAnnotations(XExecutableElement executableElement) {
Nullability nullability = Nullability.of(executableElement);
ImmutableList<String> formattedAnnotations =
executableElement.getAllAnnotations().stream()
// Filter out @NotNull annotations added by KAPT to make error messages consistent
.filter(annotation -> !annotation.getClassName().equals(JET_BRAINS_NOT_NULL))
.map(MethodSignatureFormatter::formatAnnotation)
Streams.concat(
executableElement.getAllAnnotations().stream()
// Filter out @NotNull annotations added by KAPT to make error messages
// consistent
.filter(annotation -> !annotation.getClassName().equals(JET_BRAINS_NOT_NULL))
.map(MethodSignatureFormatter::formatAnnotation),
nullability.nullableAnnotations().stream()
// Filter out @NotNull annotations added by KAPT to make error messages
// consistent
.filter(annotation -> !annotation.equals(JET_BRAINS_NOT_NULL))
.map(annotation -> String.format("@%s", annotation.canonicalName())))
.distinct()
.collect(toImmutableList());
Nullability nullability = Nullability.of(executableElement);
if (nullability.isKotlinTypeNullable()
&& nullability.nullableAnnotations().stream()
.noneMatch(JET_BRAINS_NULLABLE::equals)
&& getProcessingEnv(executableElement).findTypeElement(JET_BRAINS_NULLABLE) != null) {
&& nullability.nullableAnnotations().stream().noneMatch(JET_BRAINS_NULLABLE::equals)
&& getProcessingEnv(executableElement).findTypeElement(JET_BRAINS_NULLABLE) != null) {
formattedAnnotations =
ImmutableList.<String>builder()
.addAll(formattedAnnotations)
Expand Down

0 comments on commit 75a3a0a

Please sign in to comment.