Temporarily add @androidx.hilt.Assisted.
@Assisted is used to explicitly mark ViewModel and Workers
parameters that are assisted injected. The annotation should
be replaced by Dagger's once it is available. In the mean time
however, it is useful for validation and serves as an indicator
that the assisted params are not normal dependency requests.
Test: hilt-compiler:test
Change-Id: I74f7d087bdf1bd293079ac6abcbce68d892000e0
diff --git a/hilt/hilt-common/src/main/java/androidx/hilt/Assisted.java b/hilt/hilt-common/src/main/java/androidx/hilt/Assisted.java
new file mode 100644
index 0000000..6da5548
--- /dev/null
+++ b/hilt/hilt-common/src/main/java/androidx/hilt/Assisted.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.hilt;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marks a parameter in a {@link androidx.hilt.lifecycle.ViewModelInject}-annotated constructor
+ * or a {@link androidx.hilt.work.WorkerInject}-annotated constructor to be assisted
+ * injected at runtime via a factory.
+ */
+// TODO(danysantiago): Remove and replace with dagger.assisted.
+@Target(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Assisted {
+}
diff --git a/hilt/hilt-common/src/main/java/androidx/hilt/lifecycle/ViewModelInject.java b/hilt/hilt-common/src/main/java/androidx/hilt/lifecycle/ViewModelInject.java
index c5ec2cf..fd1bbed 100644
--- a/hilt/hilt-common/src/main/java/androidx/hilt/lifecycle/ViewModelInject.java
+++ b/hilt/hilt-common/src/main/java/androidx/hilt/lifecycle/ViewModelInject.java
@@ -35,14 +35,14 @@
* Example:
* <pre>
* public class DonutViewModel {
- * {@literal @}ViewModelInject
- * public DonutViewModel(SavedStateHandle handle, RecipeRepository repository) {
+ * @ViewModelInject
+ * public DonutViewModel(@Assisted SavedStateHandle handle, RecipeRepository repository) {
* // ...
* }
* }
* </pre>
* <pre>
- * {@literal @}AndroidEntryPoint
+ * @AndroidEntryPoint
* public class CookingActivity extends AppCompatActivity {
* public void onCreate(Bundle savedInstanceState) {
* DonutViewModel vm = new ViewModelProvider(this).get(DonutViewModel.class);
@@ -51,9 +51,10 @@
* </pre>
* <p>
* Only one constructor in the {@code ViewModel} must be annotated with {@code ViewModelInject}. The
- * constructor can optionally define a {@link androidx.lifecycle.SavedStateHandle} parameter along
- * with any other dependency. The {@code SavedStateHandle} must not be a type param of
- * {@link javax.inject.Provider} nor {@link dagger.Lazy} and must not be qualified.
+ * constructor can optionally define a {@link androidx.hilt.Assisted}-annotated
+ * {@link androidx.lifecycle.SavedStateHandle} parameter along with any other dependency. The
+ * {@code SavedStateHandle} must not be a type param of {@link javax.inject.Provider} nor
+ * {@link dagger.Lazy} and must not be qualified.
* <p>
* Only dependencies available in the
* {@link dagger.hilt.android.components.ActivityRetainedComponent} can be injected into the
diff --git a/hilt/hilt-common/src/main/java/androidx/hilt/work/WorkerInject.java b/hilt/hilt-common/src/main/java/androidx/hilt/work/WorkerInject.java
index d7358ef..7418cf1 100644
--- a/hilt/hilt-common/src/main/java/androidx/hilt/work/WorkerInject.java
+++ b/hilt/hilt-common/src/main/java/androidx/hilt/work/WorkerInject.java
@@ -36,19 +36,20 @@
* Example:
* <pre>
* public class UploadWorker extends Worker {
- * {@literal @}WorkerInject
- * public UploadWorker(Context context, WorkerParameters params, HttpClient httpClient) {
+ * @WorkerInject
+ * public UploadWorker(@Assisted Context context, @Assisted WorkerParameters params,
+ * HttpClient httpClient) {
* // ...
* }
* }
* </pre>
* <pre>
- * {@literal @}GenerateComponents
- * {@literal @}AndroidEntryPoint
+ * @GenerateComponents
+ * @AndroidEntryPoint
* public class MyApplication extends Application implements Configuration.Provider {
- * {@literal @}Inject HiltWorkerFactory workerFactory;
+ * @Inject HiltWorkerFactory workerFactory;
*
- * {@literal @}Override
+ * @Override
* public Configuration getWorkManagerConfiguration() {
* return Configuration.Builder()
* .setWorkerFactory(workerFactory)
@@ -58,9 +59,10 @@
* </pre>
* <p>
* Only one constructor in the {@code Worker} must be annotated with {@code WorkerInject}. The
- * constructor must define parameters for a {@code Context} and a {@code WorkerParameters} along
- * with any other dependencies. Both the {@code Context} and {@code WorkerParameters} must not be
- * a type param of {@link javax.inject.Provider} nor {@link dagger.Lazy} and must not be qualified.
+ * constructor must define parameters for a {@link androidx.hilt.Assisted}-annotated {@code Context}
+ * and a {@link androidx.hilt.Assisted}-annotated {@code WorkerParameters} along with any other
+ * dependencies. Both the {@code Context} and {@code WorkerParameters} must not be a type param
+ * of {@link javax.inject.Provider} nor {@link dagger.Lazy} and must not be qualified.
* <p>
* Only dependencies available in the {@link dagger.hilt.android.components.ApplicationComponent}
* can be injected into the {@code Worker}.
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/assisted/DependencyRequest.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/assisted/DependencyRequest.kt
index e0f6646..1e76c56 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/assisted/DependencyRequest.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/assisted/DependencyRequest.kt
@@ -16,6 +16,7 @@
package androidx.hilt.assisted
+import androidx.hilt.Assisted
import androidx.hilt.ClassNames
import androidx.hilt.ext.hasAnnotation
import com.squareup.javapoet.AnnotationSpec
@@ -51,9 +52,7 @@
}
}
-internal fun VariableElement.toDependencyRequest(
- isAssistedPredicate: (TypeName) -> Boolean
-): DependencyRequest {
+internal fun VariableElement.toDependencyRequest(): DependencyRequest {
val qualifier = annotationMirrors.find {
it.annotationType.asElement().hasAnnotation("javax.inject.Qualifier")
}?.let { AnnotationSpec.get(it) }
@@ -61,7 +60,7 @@
return DependencyRequest(
name = simpleName.toString(),
type = type,
- isAssisted = isAssistedPredicate(type) && qualifier == null,
+ isAssisted = hasAnnotation(Assisted::class) && qualifier == null,
qualifier = qualifier
)
}
\ No newline at end of file
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectElements.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectElements.kt
index 4f41dab..206c4f6 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectElements.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectElements.kt
@@ -46,8 +46,6 @@
"${className.simpleNames().joinToString("_")}_HiltModule")
val dependencyRequests = constructorElement.parameters.map { constructorArg ->
- constructorArg.toDependencyRequest { paramTypeName ->
- paramTypeName == ClassNames.SAVED_STATE_HANDLE
- }
+ constructorArg.toDependencyRequest()
}
}
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectStep.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectStep.kt
index ff3c5db..8c1ccc5 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectStep.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelInjectStep.kt
@@ -16,6 +16,7 @@
package androidx.hilt.lifecycle
+import androidx.hilt.Assisted
import androidx.hilt.ClassNames
import androidx.hilt.ext.hasAnnotation
import com.google.auto.common.BasicAnnotationProcessor
@@ -78,7 +79,7 @@
if (!types.isSubtype(typeElement.asType(),
elements.getTypeElement(ClassNames.VIEW_MODEL.toString()).asType())) {
error("@ViewModelInject is only supported on types that subclass " +
- "androidx.lifecycle.ViewModel.")
+ "${ClassNames.VIEW_MODEL}.")
valid = false
}
@@ -103,13 +104,20 @@
}
// Validate there is at most one SavedStateHandle constructor arg.
- val savedStateArgs = constructorElement.parameters
- .map { TypeName.get(it.asType()) }
- .count { it == ClassNames.SAVED_STATE_HANDLE }
- if (savedStateArgs > 1) {
- error("Expected zero or one constructor argument of type androidx.lifecycle" +
- ".SavedStateHandle, found $savedStateArgs", constructorElement)
- valid = false
+ constructorElement.parameters.filter {
+ TypeName.get(it.asType()) == ClassNames.SAVED_STATE_HANDLE
+ }.apply {
+ if (size > 1) {
+ error("Expected zero or one constructor argument of type " +
+ "${ClassNames.SAVED_STATE_HANDLE}, found $size", constructorElement)
+ valid = false
+ }
+ firstOrNull()?.let {
+ if (!it.hasAnnotation(Assisted::class)) {
+ error("Missing @Assisted annotation in param '${it.simpleName}'.", it)
+ valid = false
+ }
+ }
}
if (!valid) return null
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectElements.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectElements.kt
index 5bd7258..5f830a6 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectElements.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectElements.kt
@@ -46,8 +46,6 @@
"${className.simpleNames().joinToString("_")}_HiltModule")
val dependencyRequests = constructorElement.parameters.map { constructorArg ->
- constructorArg.toDependencyRequest { paramTypeName ->
- listOf(ClassNames.CONTEXT, ClassNames.WORKER_PARAMETERS).any { paramTypeName == it }
- }
+ constructorArg.toDependencyRequest()
}
}
\ No newline at end of file
diff --git a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectStep.kt b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectStep.kt
index e413090..752edf6 100644
--- a/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectStep.kt
+++ b/hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerInjectStep.kt
@@ -16,11 +16,13 @@
package androidx.hilt.work
+import androidx.hilt.Assisted
import androidx.hilt.ClassNames
import androidx.hilt.ext.hasAnnotation
import com.google.auto.common.BasicAnnotationProcessor
import com.google.auto.common.MoreElements
import com.google.common.collect.SetMultimap
+import com.squareup.javapoet.TypeName
import javax.annotation.processing.ProcessingEnvironment
import javax.lang.model.element.Element
import javax.lang.model.element.ExecutableElement
@@ -79,7 +81,7 @@
if (!types.isSubtype(typeElement.asType(),
elements.getTypeElement(ClassNames.WORKER.toString()).asType())) {
error("@WorkerInject is only supported on types that subclass " +
- "androidx.work.Worker.")
+ "${ClassNames.WORKER}.")
valid = false
}
@@ -103,6 +105,38 @@
valid = false
}
+ constructorElement.parameters.filter {
+ TypeName.get(it.asType()) == ClassNames.CONTEXT
+ }.apply {
+ if (size != 1) {
+ error("Expected exactly one constructor argument of type " +
+ "${ClassNames.CONTEXT}, found $size", constructorElement)
+ valid = false
+ }
+ firstOrNull()?.let {
+ if (!it.hasAnnotation(Assisted::class)) {
+ error("Missing @Assisted annotation in param '${it.simpleName}'.", it)
+ valid = false
+ }
+ }
+ }
+
+ constructorElement.parameters.filter {
+ TypeName.get(it.asType()) == ClassNames.WORKER_PARAMETERS
+ }.apply {
+ if (size != 1) {
+ error("Expected exactly one constructor argument of type " +
+ "${ClassNames.WORKER_PARAMETERS}, found $size", constructorElement)
+ valid = false
+ }
+ firstOrNull()?.let {
+ if (!it.hasAnnotation(Assisted::class)) {
+ error("Missing @Assisted annotation in param '${it.simpleName}'.", it)
+ valid = false
+ }
+ }
+ }
+
if (!valid) return null
return WorkerInjectElements(typeElement, constructorElement)
diff --git a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/lifecycle/ViewModelGeneratorTest.kt b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/lifecycle/ViewModelGeneratorTest.kt
index 7e66ccc..5d8a80b 100644
--- a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/lifecycle/ViewModelGeneratorTest.kt
+++ b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/lifecycle/ViewModelGeneratorTest.kt
@@ -82,13 +82,14 @@
val myViewModel = """
package androidx.hilt.lifecycle.test;
+ import androidx.hilt.Assisted;
import androidx.hilt.lifecycle.ViewModelInject;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.SavedStateHandle;
class MyViewModel extends ViewModel {
@ViewModelInject
- MyViewModel(SavedStateHandle savedState) { }
+ MyViewModel(@Assisted SavedStateHandle savedState) { }
}
""".toJFO("androidx.hilt.lifecycle.test.MyViewModel")
@@ -137,6 +138,7 @@
val myViewModel = """
package androidx.hilt.lifecycle.test;
+ import androidx.hilt.Assisted;
import androidx.hilt.lifecycle.ViewModelInject;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.SavedStateHandle;
@@ -144,7 +146,7 @@
class MyViewModel extends ViewModel {
@ViewModelInject
- MyViewModel(String s, Foo f, SavedStateHandle savedState, long l) { }
+ MyViewModel(String s, Foo f, @Assisted SavedStateHandle savedState, long l) { }
}
""".toJFO("androidx.hilt.lifecycle.test.MyViewModel")
@@ -204,6 +206,7 @@
val myViewModel = """
package androidx.hilt.lifecycle.test;
+ import androidx.hilt.Assisted;
import androidx.hilt.lifecycle.ViewModelInject;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.SavedStateHandle;
@@ -212,7 +215,7 @@
class MyViewModel extends ViewModel {
@ViewModelInject
- MyViewModel(String s, Provider<Foo> f, SavedStateHandle savedState) { }
+ MyViewModel(String s, Provider<Foo> f, @Assisted SavedStateHandle savedState) { }
}
""".toJFO("androidx.hilt.lifecycle.test.MyViewModel")
@@ -272,6 +275,7 @@
val myViewModel = """
package androidx.hilt.lifecycle.test;
+ import androidx.hilt.Assisted;
import androidx.hilt.lifecycle.ViewModelInject;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.SavedStateHandle;
@@ -283,7 +287,7 @@
class MyViewModel extends ViewModel {
@ViewModelInject
MyViewModel(@Named("TheString") String s, @MyQualifier Provider<Long> l,
- SavedStateHandle savedState) {
+ @Assisted SavedStateHandle savedState) {
}
}
""".toJFO("androidx.hilt.lifecycle.test.MyViewModel")
diff --git a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/lifecycle/ViewModelInjectStepTest.kt b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/lifecycle/ViewModelInjectStepTest.kt
index 58bebfb..8b764a1 100644
--- a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/lifecycle/ViewModelInjectStepTest.kt
+++ b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/lifecycle/ViewModelInjectStepTest.kt
@@ -155,11 +155,13 @@
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.SavedStateHandle;
+ import androidx.hilt.Assisted;
import androidx.hilt.lifecycle.ViewModelInject;
class MyViewModel extends ViewModel {
@ViewModelInject
- MyViewModel(SavedStateHandle savedState1, SavedStateHandle savedState2) { }
+ MyViewModel(@Assisted SavedStateHandle savedState1,
+ @Assisted SavedStateHandle savedState2) { }
}
""".toJFO("androidx.hilt.lifecycle.test.MyViewModel")
@@ -175,4 +177,31 @@
"androidx.lifecycle.SavedStateHandle, found 2")
}
}
+
+ @Test
+ fun verifySavedStateHandleArgIsAnnotated() {
+ val myViewModel = """
+ package androidx.hilt.lifecycle.test;
+
+ import androidx.lifecycle.ViewModel;
+ import androidx.lifecycle.SavedStateHandle;
+ import androidx.hilt.lifecycle.ViewModelInject;
+
+ class MyViewModel extends ViewModel {
+ @ViewModelInject
+ MyViewModel(SavedStateHandle savedState) { }
+ }
+ """.toJFO("androidx.hilt.lifecycle.test.MyViewModel")
+
+ val compilation = compiler()
+ .compile(myViewModel,
+ Sources.VIEW_MODEL,
+ Sources.SAVED_STATE_HANDLE
+ )
+ assertThat(compilation).apply {
+ failed()
+ hadErrorCount(1)
+ hadErrorContainingMatch("Missing @Assisted annotation in param 'savedState'")
+ }
+ }
}
\ No newline at end of file
diff --git a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerGeneratorTest.kt b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerGeneratorTest.kt
index a65b5d5..2e52af8 100644
--- a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerGeneratorTest.kt
+++ b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerGeneratorTest.kt
@@ -41,6 +41,7 @@
package androidx.hilt.work.test;
import android.content.Context;
+ import androidx.hilt.Assisted;
import androidx.hilt.work.WorkerInject;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
@@ -48,7 +49,8 @@
class MyWorker extends Worker {
@WorkerInject
- MyWorker(Context context, WorkerParameters params, String s, Foo f, long l) {
+ MyWorker(@Assisted Context context, @Assisted WorkerParameters params, String s,
+ Foo f, long l) {
super(context, params);
}
}
@@ -106,13 +108,14 @@
package androidx.hilt.work.test;
import android.content.Context;
+ import androidx.hilt.Assisted;
import androidx.hilt.work.WorkerInject;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
class MyWorker extends Worker {
@WorkerInject
- MyWorker(Context context, WorkerParameters params) {
+ MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
super(context, params);
}
}
diff --git a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerInjectStepTest.kt b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerInjectStepTest.kt
index be6ea3b..f627096 100644
--- a/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerInjectStepTest.kt
+++ b/hilt/hilt-compiler/src/test/kotlin/androidx/hilt/work/WorkerInjectStepTest.kt
@@ -32,11 +32,14 @@
val myWorker = """
package androidx.hilt.work.test;
+ import android.content.Context;
+ import androidx.hilt.Assisted;
import androidx.hilt.work.WorkerInject;
+ import androidx.work.WorkerParameters;
class MyWorker {
@WorkerInject
- MyWorker() { }
+ MyWorker(@Assisted Context context, @Assisted WorkerParameters params) { }
}
""".toJFO("androidx.hilt.work.work.MyWorker")
@@ -56,6 +59,7 @@
package androidx.hilt.work.test;
import android.content.Context;
+ import androidx.hilt.Assisted;
import androidx.hilt.work.WorkerInject;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
@@ -63,7 +67,7 @@
class MyWorker extends Worker {
@WorkerInject
- MyWorker(Context context, WorkerParameters params) {
+ MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
super(context, params);
}
@@ -89,13 +93,14 @@
package androidx.hilt.work.test;
import android.content.Context;
+ import androidx.hilt.Assisted;
import androidx.hilt.work.WorkerInject;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
class MyWorker extends Worker {
@WorkerInject
- private MyWorker(Context context, WorkerParameters params) {
+ private MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
super(context, params);
}
}
@@ -117,6 +122,7 @@
package androidx.hilt.work.test;
import android.content.Context;
+ import androidx.hilt.Assisted;
import androidx.hilt.work.WorkerInject;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
@@ -124,7 +130,7 @@
class Outer {
class MyWorker extends Worker {
@WorkerInject
- MyWorker(Context context, WorkerParameters params) {
+ MyWorker(@Assisted Context context, @Assisted WorkerParameters params) {
super(context, params);
}
}
diff --git a/hilt/integration-tests/viewmodelapp/src/main/java/androidx/hilt/integration/viewmodelapp/SimpleViewModel.kt b/hilt/integration-tests/viewmodelapp/src/main/java/androidx/hilt/integration/viewmodelapp/SimpleViewModel.kt
index 97ab932..45bbd5f 100644
--- a/hilt/integration-tests/viewmodelapp/src/main/java/androidx/hilt/integration/viewmodelapp/SimpleViewModel.kt
+++ b/hilt/integration-tests/viewmodelapp/src/main/java/androidx/hilt/integration/viewmodelapp/SimpleViewModel.kt
@@ -16,15 +16,16 @@
package androidx.hilt.integration.viewmodelapp
+import androidx.hilt.Assisted
+import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
-import androidx.hilt.lifecycle.ViewModelInject
import javax.inject.Inject
@Suppress("UNUSED_PARAMETER")
class SimpleViewModel @ViewModelInject constructor(
mngr: MyManager,
- savedState: SavedStateHandle
+ @Assisted savedState: SavedStateHandle
) : ViewModel() {
fun hi() = "$this - hi"
}
diff --git a/hilt/integration-tests/workerapp/src/main/java/androidx/hilt/integration/workerapp/SimpleWorker.kt b/hilt/integration-tests/workerapp/src/main/java/androidx/hilt/integration/workerapp/SimpleWorker.kt
index 6e4bb46..ce8543d 100644
--- a/hilt/integration-tests/workerapp/src/main/java/androidx/hilt/integration/workerapp/SimpleWorker.kt
+++ b/hilt/integration-tests/workerapp/src/main/java/androidx/hilt/integration/workerapp/SimpleWorker.kt
@@ -18,14 +18,15 @@
import android.content.Context
import android.util.Log
+import androidx.hilt.Assisted
import androidx.hilt.work.WorkerInject
import androidx.work.Worker
import androidx.work.WorkerParameters
import javax.inject.Inject
class SimpleWorker @WorkerInject constructor(
- context: Context,
- params: WorkerParameters,
+ @Assisted context: Context,
+ @Assisted params: WorkerParameters,
private val logger: MyLogger
) : Worker(context, params) {
override fun doWork(): Result {