Skip to content

Commit

Permalink
Suppress unnecessary casts.
Browse files Browse the repository at this point in the history
These were introduced in a previous change that introduced the `dagger.internal.Provider` type. They are difficult to avoid with Map Providers.

Fixes #4201.

RELNOTES=Fixes #4201.
PiperOrigin-RevId: 599885719
  • Loading branch information
Chang-Eric authored and Dagger Team committed Jan 19, 2024
1 parent 3cbc94a commit 813ffce
Show file tree
Hide file tree
Showing 336 changed files with 683 additions and 342 deletions.
4 changes: 2 additions & 2 deletions java/dagger/internal/codegen/base/SourceFileGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static androidx.room.compiler.processing.JavaPoetExtKt.addOriginatingElement;
import static com.google.common.base.Preconditions.checkNotNull;
import static dagger.internal.codegen.javapoet.AnnotationSpecs.Suppression.CAST;
import static dagger.internal.codegen.javapoet.AnnotationSpecs.Suppression.KOTLIN_INTERNAL;
import static dagger.internal.codegen.javapoet.AnnotationSpecs.Suppression.RAWTYPES;
import static dagger.internal.codegen.javapoet.AnnotationSpecs.Suppression.UNCHECKED;
Expand Down Expand Up @@ -100,13 +101,12 @@ private JavaFile buildJavaFile(T input, TypeSpec.Builder typeSpecBuilder) {
.build());
generatedAnnotation.ifPresent(typeSpecBuilder::addAnnotation);

// TODO(b/134590785): Remove UNCHECKED/RAWTYPES and suppress locally where necessary.
// TODO(b/263891456): Remove KOTLIN_INTERNAL and use Object/raw types where necessary.
typeSpecBuilder.addAnnotation(
AnnotationSpecs.suppressWarnings(
ImmutableSet.<Suppression>builder()
.addAll(warningSuppressions())
.add(UNCHECKED, RAWTYPES, KOTLIN_INTERNAL)
.add(UNCHECKED, RAWTYPES, KOTLIN_INTERNAL, CAST)
.build()));

String packageName = closestEnclosingTypeElement(originatingElement).getPackageName();
Expand Down
3 changes: 2 additions & 1 deletion java/dagger/internal/codegen/javapoet/AnnotationSpecs.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public enum Suppression {
RAWTYPES("rawtypes"),
UNCHECKED("unchecked"),
FUTURE_RETURN_VALUE_IGNORED("FutureReturnValueIgnored"),
KOTLIN_INTERNAL("KotlinInternal", "KotlinInternalInJava")
KOTLIN_INTERNAL("KotlinInternal", "KotlinInternalInJava"),
CAST("cast")
;

private final ImmutableList<String> values;
Expand Down
2 changes: 1 addition & 1 deletion javatests/dagger/internal/codegen/GeneratedLines.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class GeneratedLines {

private static final String SUPPRESS_WARNINGS_ANNOTATION =
"@SuppressWarnings({"
+ "\"unchecked\", \"rawtypes\", \"KotlinInternal\", \"KotlinInternalInJava\""
+ "\"unchecked\", \"rawtypes\", \"KotlinInternal\", \"KotlinInternalInJava\", \"cast\""
+ "})";

private static final String IMPORT_DAGGER_GENERATED = "import dagger.internal.DaggerGenerated;";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import javax.inject.Provider;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
public final class Foo_Factory {
private final Provider<Bar> argProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import javax.inject.Provider;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
public final class Foo_Factory {
private final Provider<Bar> argProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerMyComponent {
private DaggerMyComponent() {
Expand Down Expand Up @@ -94,3 +95,4 @@ final class DaggerMyComponent {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerMyComponent {
private DaggerMyComponent() {
Expand Down Expand Up @@ -147,3 +148,4 @@ final class DaggerMyComponent {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerSimpleComponent {
private DaggerSimpleComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerTestComponent {
private DaggerTestComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerBComponent {
private DaggerBComponent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import javax.annotation.processing.Generated;
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
"KotlinInternalInJava",
"cast"
})
final class DaggerBComponent {
private DaggerBComponent() {
Expand Down
Loading

0 comments on commit 813ffce

Please sign in to comment.