comparison, should we always check for nullability explicitly?
Copy code
val someType: KSType =
if (someType == resolver.builtIns.stringType || someType == resolver.builtIns.stringType.makeNullable()) {
...
}
j
Jiaxiang
01/30/2023, 6:19 PM
nullable types and non nullable types are different, they do have a subtyping relation, but if your use case is around strict equality check, then nullability has to be checked.
y
Yang
01/30/2023, 9:08 PM
Thanks! Is it enough to check someType.declaration == otherType.declaration if I don’t care about the nullability difference?
j
Jiaxiang
01/30/2023, 9:16 PM
no, you still need to consider type arguments.
y
Yang
01/30/2023, 9:20 PM
How about someType.makeNullable() == otherType.makeNullable()?
j
Jiaxiang
01/30/2023, 9:21 PM
that should work.
y
Yang
01/30/2023, 9:22 PM
If I’m comparing against a builtin type I don’t need to consider type argument right?
j
Jiaxiang
01/30/2023, 9:24 PM
there are still generic types in builtins, it’s really up to your use case.