From 50e06814a99497ba1fe7966447c09f0a309bd6ef Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Wed, 27 Nov 2024 11:42:30 +0100 Subject: [PATCH] Rebased on main and updated error message for record field injection. --- .../service/inject/codegen/InjectionExtension.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/service/inject/codegen/src/main/java/io/helidon/service/inject/codegen/InjectionExtension.java b/service/inject/codegen/src/main/java/io/helidon/service/inject/codegen/InjectionExtension.java index 5a752210337..9ae22e16a18 100644 --- a/service/inject/codegen/src/main/java/io/helidon/service/inject/codegen/InjectionExtension.java +++ b/service/inject/codegen/src/main/java/io/helidon/service/inject/codegen/InjectionExtension.java @@ -1066,6 +1066,14 @@ private List 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());