KT-62071 [AA] Do not throw error from getScopeContextForPosition when implicitScope of receiver value is null
`implicitScope` can be `null` in case when the implicit receiver resides in a user-defined `kotlin.*` package, but the user have not yet allowed this with compiler argument directive. In this case, we don't want the IDE to crush and show exceptions - the `kotlin` package would be highlighted by the compiler diagnostics and other resolve problems, and that would be enough ^KT-62071 Fixed
This commit is contained in:
+8
-7
@@ -282,13 +282,14 @@ class FirTowerDataElement(
|
||||
private fun ImplicitReceiverValue<*>.getImplicitScope(
|
||||
processTypeScope: FirTypeScope.(ConeKotlinType) -> FirTypeScope,
|
||||
): FirScope {
|
||||
return when (val type = type.fullyExpandedType(useSiteSession)) {
|
||||
is ConeErrorType,
|
||||
is ConeStubType -> FirTypeScope.Empty
|
||||
else -> implicitScope?.processTypeScope(type) ?: errorWithAttachment("Scope for type ${type::class.simpleName} is null") {
|
||||
withConeTypeEntry("type", type)
|
||||
}
|
||||
}
|
||||
// N.B.: implicitScope == null when the type sits in a user-defined 'kotlin' package,
|
||||
// but there is no '-Xallow-kotlin-package' compiler argument provided
|
||||
val implicitScope = implicitScope ?: return FirTypeScope.Empty
|
||||
|
||||
val type = type.fullyExpandedType(useSiteSession)
|
||||
if (type is ConeErrorType || type is ConeStubType) return FirTypeScope.Empty
|
||||
|
||||
return implicitScope.processTypeScope(type)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user