-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace TyppeLiteral anonymous-object syntax with KType #21
Comments
This sounds like an interesting idea. Currently The experimental issue aside, I'm curious how this would change the binding DSL. I played around using your |
Thats a very good point, I'm sorry I missed it. I wonder how other DSL's using
I think you can provide a workaround. when using
if you wanted to keep strict compatibility, I think it would be possible to box-up a |
I am still hoping to get back around to this, im just swamped |
the extensive use of this function:
kotlin-guice/kotlin-guice/src/main/kotlin/dev/misfitlabs/kotlinguice4/TypeLiteral.kt
Line 29 in 7d2a052
means you are going to end up with a lot of class files pretaining to anonymous overloads. The TypeLiteral hack was added by google as a clever way to avoid type-erasure.
But in a library such as this, I believe you should use
java.lang.reflect.Type
andkotlin.reflect.KType
, which each do not suffer from type-erasure and will not require any additional *.class files.I suggest using something like this:
Once completed, there should be a (measurable) reduction in class files and possibly a measurable increase in performance, particularly for slow hard-drive computers using *.class file distributions (rather than jar distributions).
an implementation note:
while this is technically 1.3 compatible, on
1.3.61
thejavaType
extension inkotlin-jvm
will throw. Unfortunately this cant be solved via a simple if-statement because if you exposethen, of course, because the if statement cannot be done at compile time, the compiler will generate the class files that we're trying to avoid in the first place! While the native community might solve this with something like
#IFDEF KOTLIN_1_4
, for better and for worse we have no such deviceI'm really not sure what an elegent solution here is:
javaType
extension function from 1.4. Its not huge and its not too dependent on kotlin 1.4, but it is a reasonably sophisticated string parser and it is responsible for mapping things likekotlin.String
tojava.lang.String
, andkotlin.collections.List<A>
tojava.util.List<? extends A>
.Anyways, if you're interested, I'd be happy to give an implemenation a try and issue a pull request!
The text was updated successfully, but these errors were encountered: