File tree 2 files changed +28
-0
lines changed
java/dagger/internal/codegen/validation
javatests/dagger/internal/codegen
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
255
255
constructorElement );
256
256
}
257
257
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
+
258
265
// Note: superficial validation of the annotations is done as part of getting the scopes.
259
266
ImmutableSet <Scope > scopes =
260
267
injectionAnnotations .getScopes (constructorElement .getEnclosingElement ());
Original file line number Diff line number Diff line change @@ -147,6 +147,27 @@ public final class InjectConstructorFactoryGeneratorTest {
147
147
});
148
148
}
149
149
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
+
150
171
@ Test public void fieldAndMethodGenerics () {
151
172
Source file =
152
173
CompilerTests .javaSource (
You can’t perform that action at this time.
0 commit comments