kotlinpoet icon indicating copy to clipboard operation
kotlinpoet copied to clipboard

KClass use is converted into java.* in code.

Open JakeWharton opened this issue 8 years ago • 4 comments

See tests for a lot of examples of this

JakeWharton avatar May 23 '17 17:05 JakeWharton

Some interesting bits here.

KClass provides a simple name and a qualified name but no good way to convert it to the current internal representation unless we parse the qualified name like bestGuess.

We need to handle things like Array<String?>::class properly.

JakeWharton avatar May 25 '17 04:05 JakeWharton

Might be blocked by https://youtrack.jetbrains.com/issue/KT-17912 and https://youtrack.jetbrains.com/issue/KT-18104

JakeWharton avatar May 26 '17 15:05 JakeWharton

For now let's go with a bestGuess-style approach of using the qualifiedName and simpleName to try and infer the package and any outerclasses. While this may be wrong some of the time, it will be correct most of the time which is better than the current behavior of being semantically wrong all of the time.

JakeWharton avatar May 30 '17 17:05 JakeWharton

Further complicated by the fact that I can write Array<String>::class but I can't get String as the parameter only Array yet I can't write Array::class to create a ParameterizedTypeName. I can write List::class though, but not List<String>::class.

Super weird...

JakeWharton avatar May 31 '17 03:05 JakeWharton