Skip to content

Commit 50e0681

Browse files
committed
Rebased on main and updated error message for record field injection.
1 parent 47c482a commit 50e0681

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

service/inject/codegen/src/main/java/io/helidon/service/inject/codegen/InjectionExtension.java

+8
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,14 @@ private List<TypedElementInfo> fieldInjectElements(TypeInfo typeInfo) {
10661066
.filter(ElementInfoPredicates::isPrivate)
10671067
.findFirst();
10681068
if (firstFound.isPresent()) {
1069+
if (typeInfo.kind() == ElementKind.RECORD) {
1070+
throw new CodegenException("Discovered " + InjectCodegenTypes.INJECTION_INJECT.fqName()
1071+
+ " annotation on record field(s). This is not supported. "
1072+
+ "If this is the only constructor, you can remove the Inject annotation; "
1073+
+ "if you need to inject the default constructor, kindly create an explicit"
1074+
+ " default constructor and annotate it with Inject.",
1075+
firstFound.get().originatingElementValue());
1076+
}
10691077
throw new CodegenException("Discovered " + InjectCodegenTypes.INJECTION_INJECT.fqName()
10701078
+ " annotation on private field(s). We cannot support private field injection.",
10711079
firstFound.get().originatingElementValue());

0 commit comments

Comments
 (0)