Closed traceyyoshima closed 9 months ago
@knutwannheden @kunli2 this is a list of conditions that differ from Java to augment the type validation for Kotlin. I'll be adding to the list as other issues are identified. Please feel free to add/remove/edit as you see fit.
@knutwannheden @kunli2 is a list of errors thrown after type validation is added to Assertions#kotlin, which I think should be added as acceptable types.
Do you think there are any cases, which should not be considered acceptable?
I think so too
@knutwannheden @kunli2 is a list of errors thrown after type validation is added to Assertions#kotlin, which I think should be added as acceptable types.
I am not sure I understand the question correctly.
Please also note that the TypeAlias example is an import alias and not a type alias. Of course the import alias can also be used to alias type names, but this is still distict from typealias
.
Annotation use-site
Code
Info on use-site name
A use-site annotation is a keyword that informs the compiler where to apply annotation. The use-site annotation does not resolve to an annotation with a type, which means the type is null. FindMissingTypes does not consider this case as a valid null type, which leads to an error.
Aliases
Code
Info
The variable type of a type aliases identifier is constructed from the aliased type. So, the aliased type and the J.Identifier's name do not match. The identifier
i
has a type ofjava.util.regex.Pattern{name=CASE_INSENSITIVE,type=kotlin.Int}
MethodInvocation syntax sugar
Code
Info on
get
andset
Kotlin recommends using
map[key]
instead ofmap.get(key)
. The type associated with theget
is a MethodType with the nameget
, which does not match the name of the method invocation createda
. A similar issue happens withset
.Code
Info on
invoke
A similar issue exists for implicit invoke calls.
Code
Info on
anonymous functions
Anonymous functions have the name
anonymous
, which does not match the identifier created with an empty name.NamedVariable
Code
Info on receivers
An extension receiver has an unused name,
<receiverType>
, which does not match the variable type name.Code
Info on destructuring declarations
Similar to receivers, a destruct is created with a name
<destruct>
MemberReference
Null types on class literal expressions
Type::class
. Type validation fails because the types are intentionally set to null here.