Skip to content

Commit

Permalink
Rebased on main and updated error message for record field injection.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-langer committed Nov 27, 2024
1 parent 47c482a commit 50e0681
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,14 @@ private List<TypedElementInfo> fieldInjectElements(TypeInfo typeInfo) {
.filter(ElementInfoPredicates::isPrivate)
.findFirst();
if (firstFound.isPresent()) {
if (typeInfo.kind() == ElementKind.RECORD) {
throw new CodegenException("Discovered " + InjectCodegenTypes.INJECTION_INJECT.fqName()
+ " annotation on record field(s). This is not supported. "
+ "If this is the only constructor, you can remove the Inject annotation; "
+ "if you need to inject the default constructor, kindly create an explicit"
+ " default constructor and annotate it with Inject.",
firstFound.get().originatingElementValue());
}
throw new CodegenException("Discovered " + InjectCodegenTypes.INJECTION_INJECT.fqName()
+ " annotation on private field(s). We cannot support private field injection.",
firstFound.get().originatingElementValue());
Expand Down

0 comments on commit 50e0681

Please sign in to comment.