Status Update
Comments
hu...@gmail.com <hu...@gmail.com> #2
when we have class like:
class SomeNamedClass {
fun someMethod() {
val anonymous = ArgumentLiveData.create(object : Function<Any, LiveData<Any>> {
override fun apply(input: Any?): LiveData<Any> {
return MutableLiveData()
}
})
}
}
in in TestMode.TYPE_ALIAS, it's look like:
class SomeNamedClass {
fun someMethod() {
val anonymous = ArgumentLiveData.create(object : TYPE_ALIAS_1 {
override fun apply(input: TYPE_ALIAS_3): TYPE_ALIAS_2 {
return MutableLiveData()
}
})
}
}
I think it's a mistake to replace Function<Any, LiveData<Any>> to TYPE_ALIAS_1
lp...@google.com <lp...@google.com> #3
In Compose lint checks we currently skip this test mode for this reason, because it doesn't really make sense to typealias a composable function type
tn...@google.com <tn...@google.com>
tn...@google.com <tn...@google.com> #4
"which cause exception when analyze it." -- can you show what this exception is? Is it in lint, or in your own lint check? It looks to me like the above is valid Kotlin, so somebody could use type aliases in their code here (to avoid to repeat Function<Any, LiveData<Any>> over and over.)
Louis, I wasn't aware that this test mode had been skipped in AndroidX. Can you say more about why it doesn't make sense to typealias a composable function type? I can change the test mode to automatically skip those if that's the case (but in this bug report the APIs aren't composeable functions as far as I know.)
tn...@google.com <tn...@google.com> #5
I've tweaked the typealias test mode to skip the following types:
- @Composable () -> Unit
- @Composable (() -> Unit)?
- @Composable () -> Unit)?
tn...@google.com <tn...@google.com> #6
These are excluded via
But just as is done for compose (and as indicated by the test mode when it fails the test), you can deliberately skip this test mode from your lint check if you don't think your detector needs to handle type aliases.
Description
Thant's because when we have class like:
public class SomeNamedClass {
public void someMethod() {
ArgumentLiveData<Object, Object> anonymous = ArgumentLiveData.create(new Function<Object, LiveData<Object>>() {
@Override
public LiveData<Object> apply(Object input) {
return null;
}
});
}
}
in TestMode.TYPE_ALIAS, it's look like:
class SomeNamedClass {
fun someMethod() {
val anonymous = ArgumentLiveData.create(object : Function<Any, LiveData<Any>> {
override fun apply(input: Any?): LiveData<Any> {
return MutableLiveData()
}
})
}
}
which cause exception when analyze it.