asPsiType¶
context(session: KaSession)
fun KaType.asPsiType(
useSitePosition: PsiElement,
allowErrorTypes: Boolean,
mode: KaTypeMappingMode = KaTypeMappingMode.DEFAULT,
isAnnotationMethod: Boolean = false,
suppressWildcards: Boolean? = null,
preserveAnnotations: Boolean = true,
allowNonJvmPlatforms: Boolean = false
): PsiType?
Converts the given KaType to a PsiType in the context of the useSitePosition.
PsiType is JVM conception, so this method will return null for non-JVM platforms, unless allowNonJvmPlatforms is set.
Receiver¶
The KaType to convert.
Parameters¶
-
useSitePosition: Determines whether the given
KaTypeneeds to be approximated. For instance, if the given type is local but the use site is in the same local scope, we do not need to approximate the local type. However, when exposed to the public as a return type, the resulting type must be approximated accordingly. -
allowErrorTypes: Determines whether the
KaTypeshould still be converted if it contains an error type. When this option isfalse, the result will benullif theKaTypecontains an error type. Whentrue, erroneous types will be replaced with theerror.NonExistentClasstype. -
suppressWildcards: Indicates whether wildcards in type arguments should be suppressed. This option works similar to adding a
JvmSuppressWildcardsannotation to the containing declaration. -
truemeans they should be suppressed. -
falsemeans they should appear. -
nullmeans that the default applies, where wildcard suppression/appearance is determined by type annotations. -
preserveAnnotations: Whether annotations from the original
KaTypeshould be included in the resulting PsiType with an appropriate conversion. -
allowNonJvmPlatforms: Whether the PsiType should be computed even for non-JVM modules. The flag provides no validity guarantees – the returned type may be unresolvable from Java, or
null.