<@U0B85AN68> I'm looking into the cases to actuall...
# arrow
r
@Eugenio I'm looking into the cases to actually support generic type args. I still don't see how we can support this without a runtime lookup. Provided I have this:
Copy code
@implicit fun provideIntList(): List<Int> = listOf(1,2,3)
inline fun <reified A> la(@implicit l: List<A>): List<A> = l
val lint: List<Int> = <http://target.la|target.la><Int>()
My understanding is that the annotation processor has no visibility as to where
lint
is. You mentioned that:
Copy code
...what you would want is to generate one function for every generic provider, and then change the bytecode (at call site) to swap every generic invocation with the actual specific function
the annotation processor can do all the analysis and code generation, but there has to be another step to swap those invocations in the bytecode.
In that case even if we were able to replace the invocations in the bytecode some of those invocations are actually of this form:
Copy code
inline fun <reified A> addToList(a: A, @implicit l: List<A>): List<A> = l + a
And those methods need to work for any
A
provided there is a
List<A>
implicit provided, in this case
provideIntList()
whenever
A
is
Int
. Meaning the compiler should bail when
addToList<String>("a")
is declared but compile when
addToList<Int>(1)
is declared because
provideIntList()
is available implicitly. Scala uses the typechecking phase to do implicit resolution AFAIK so even with bytecode injection we would not be able to support this at compile time? If that is the case only runtime lookups are the option to support generic args which are most of the cases in Kategory. Thoughts?