File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
javatests/dagger/internal/codegen
java/dagger/internal/codegen/validation Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,13 @@ private ValidationReport validateConstructor(XConstructorElement constructorElem
255255 constructorElement );
256256 }
257257
258+ if (enclosingElement .isValueClass ()) {
259+ builder .addError (
260+ String .format ("@%s constructors on Kotlin inline value classes is not supported" ,
261+ injectAnnotation .simpleName ()),
262+ constructorElement );
263+ }
264+
258265 // Note: superficial validation of the annotations is done as part of getting the scopes.
259266 ImmutableSet <Scope > scopes =
260267 injectionAnnotations .getScopes (constructorElement .getEnclosingElement ());
Original file line number Diff line number Diff line change @@ -147,6 +147,27 @@ public final class InjectConstructorFactoryGeneratorTest {
147147 });
148148 }
149149
150+ @ Test public void injectConstructorOnInlineValueClass () {
151+ Source file =
152+ CompilerTests .kotlinSource (
153+ "test.InlineValueClass.kt" ,
154+ "package test" ,
155+ "" ,
156+ "import javax.inject.Inject;" ,
157+ "" ,
158+ "@JvmInline value class InlineValueClass" ,
159+ " @Inject constructor(private val v: Int)" );
160+ CompilerTests .daggerCompiler (file )
161+ .compile (
162+ subject -> {
163+ subject .hasErrorCount (1 );
164+ subject .hasErrorContaining (
165+ "@Inject constructors on Kotlin inline value classes is not supported" )
166+ .onSource (file )
167+ .onLine (6 );
168+ });
169+ }
170+
150171 @ Test public void fieldAndMethodGenerics () {
151172 Source file =
152173 CompilerTests .javaSource (
You can’t perform that action at this time.
0 commit comments