when doing `KSType` comparison, should we always c...
# ksp
y
when doing
KSType
comparison, should we always check for nullability explicitly?
Copy code
val someType: KSType = 
if (someType == resolver.builtIns.stringType || someType == resolver.builtIns.stringType.makeNullable()) {
  ...
}
j
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
Thanks! Is it enough to check someType.declaration == otherType.declaration if I don’t care about the nullability difference?
j
no, you still need to consider type arguments.
y
How about someType.makeNullable() == otherType.makeNullable()?
j
that should work.
y
If I’m comparing against a builtin type I don’t need to consider type argument right?
j
there are still generic types in builtins, it’s really up to your use case.
y
Ok thank you!