Skip to content

Commit 2de0949

Browse files
Chang-EricDagger Team
authored andcommitted
Rollback of: "Fix handling of Kotlin object Producer modules so that @JvmStatic isn't required"
PiperOrigin-RevId: 644122947
1 parent c9903cc commit 2de0949

File tree

4 files changed

+7
-182
lines changed

4 files changed

+7
-182
lines changed

java/dagger/internal/codegen/writing/ProducerFactoryGenerator.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -314,34 +314,25 @@ private MethodSpec callProducesMethod(ProductionBinding binding, FactoryFields f
314314
methodBuilder.addAnnotation(AnnotationSpecs.suppressWarnings(UNCHECKED));
315315
}
316316

317-
CodeBlock moduleCodeBlock;
318-
if (factoryFields.moduleField.isPresent()) {
319-
moduleCodeBlock = CodeBlock.of(factoryFields.moduleField.get().name);
320-
} else if (binding.contributingModule().isPresent()
321-
&& binding.contributingModule().get().isKotlinObject()) {
322-
moduleCodeBlock = CodeBlock.of(
323-
"$T.INSTANCE", binding.bindingTypeElement().get().getClassName());
324-
} else {
325-
moduleCodeBlock = CodeBlock.of("$T", binding.bindingTypeElement().get().getClassName());
326-
}
327-
328-
CodeBlock factoryMethodCall =
317+
CodeBlock moduleCodeBlock =
329318
CodeBlock.of(
330319
"$L.$L($L)",
331-
moduleCodeBlock,
320+
factoryFields.moduleField.isPresent()
321+
? factoryFields.moduleField.get().name
322+
: CodeBlock.of("$T", binding.bindingTypeElement().get().getClassName()),
332323
getSimpleName(binding.bindingElement().get()),
333324
makeParametersCodeBlock(parameterCodeBlocks.build()));
334325

335326
switch (binding.productionKind().get()) {
336327
case IMMEDIATE:
337328
methodBuilder.addStatement(
338-
"return $T.<$T>immediateFuture($L)", FUTURES, contributedTypeName, factoryMethodCall);
329+
"return $T.<$T>immediateFuture($L)", FUTURES, contributedTypeName, moduleCodeBlock);
339330
break;
340331
case FUTURE:
341-
methodBuilder.addStatement("return $L", factoryMethodCall);
332+
methodBuilder.addStatement("return $L", moduleCodeBlock);
342333
break;
343334
case SET_OF_FUTURE:
344-
methodBuilder.addStatement("return $T.allAsSet($L)", PRODUCERS, factoryMethodCall);
335+
methodBuilder.addStatement("return $T.allAsSet($L)", PRODUCERS, moduleCodeBlock);
345336
break;
346337
}
347338
return methodBuilder.build();

javatests/dagger/functional/producers/kotlin/BUILD

Lines changed: 0 additions & 47 deletions
This file was deleted.

javatests/dagger/functional/producers/kotlin/ObjectModuleClasses.kt

Lines changed: 0 additions & 77 deletions
This file was deleted.

javatests/dagger/functional/producers/kotlin/ObjectModuleTest.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)