Which is preferable between - `ClassId.topLevel(F...
# compiler
m
Which is preferable between •
ClassId.topLevel(FqName("kotlin.jvm.JvmSynthetic"))
•
ClassId.topLevel(FqName(JvmSynthetic::class.qualifiedName!!))
y
It's a matter of taste really. I'd probably go with the latter
j
In general I prefer the former, since the latter only does what you expect if the type is not a typealias
true 2
m
@jw Sorry, what do you mean?
the latter only does what you expect
And the former does more than what you expect?
y
The latter (
::class.qualifiedName
) doesn't work well for type aliases (it'll give you the underlying class's fqn)
m
Ah, I think I understand.
Foo::class.qualifiedName
where
import com.example.MyClass; typealias Foo = MyClass
returns
com.example.MyClass
not
$package.Foo
? Does that cause any problems when passed to
FqName
then
ClassId.topLevel
?
y
It depends on the situation. If you want to detect the type alias itself or if e.g. it's an
actual typealias
then you might face issues.
m
Got it, thanks!
j
Try it with List and MutableList