Skip to content

Commit 59827c6

Browse files
trexemDagger Team
authored andcommitted
Defer ViewModelMetadata processing on error types or missing @AssistedFactory.
This change throws an ErrorTypeException when the assisted factory type is an error type or when the factory class is not yet annotated with @AssistedFactory. This allows the compiler to defer processing to a later round, giving time for the necessary types and annotations to be fully generated. RELNOTES=Defered ViewModelMetadata processing on error types or missing @AssistedFactory PiperOrigin-RevId: 927045751
1 parent ee224b6 commit 59827c6

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

hilt-compiler/main/java/dagger/hilt/android/processor/internal/viewmodel/ViewModelMetadata.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ private constructor(val viewModelElement: XTypeElement, val assistedFactory: XTy
8383
.getAsType(ASSISTED_FACTORY_VALUE)
8484
val assistedFactory = assistedFactoryType.typeElement!!
8585

86+
Processors.checkNotErrorType(assistedFactoryType)
87+
8688
if (assistedFactoryType.asTypeName() != XTypeName.ANY_OBJECT) {
8789
ProcessorErrors.checkState(
8890
isAssistedInjectFeatureEnabled,

hilt-compiler/main/java/dagger/hilt/processor/internal/BUILD

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ java_library(
8080
"//third_party/java/guava/base",
8181
"//third_party/java/guava/collect",
8282
"//third_party/java/javapoet",
83-
"//third_party/kotlin/kotlin:kotlin_stdlib",
84-
"//third_party/kotlin/kotlin_symbol_processing:symbol-processing-api",
8583
],
8684
)
8785

hilt-compiler/main/java/dagger/hilt/processor/internal/Processors.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,5 +502,11 @@ public static boolean hasJavaPackagePrivateVisibility(XHasModifiers element) {
502502
&& !element.isPublic();
503503
}
504504

505+
public static void checkNotErrorType(XType type) {
506+
if (type.isError()) {
507+
throw new ErrorTypeException("bad type", type.getTypeElement());
508+
}
509+
}
510+
505511
private Processors() {}
506512
}

0 commit comments

Comments
 (0)