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:
Roman Golyshev
2023-10-17 18:23:24 +02:00
committed by teamcity
parent eb6db02649
commit 3c68b27280
7 changed files with 158 additions and 7 deletions
@@ -0,0 +1,9 @@
// FILE: main.kt
package kotlin.myPackage
class SomeClass {
fun test(param: String) {
<expr>param</expr>
}
}
@@ -0,0 +1,51 @@
element: param
implicit receivers:
type: kotlin.myPackage.SomeClass
owner symbol: KtFirNamedClassOrObjectSymbol
scopes:
LocalScope, index = 0
packages: 0
classifiers: 0
callables: 0
constructors: 0
LocalScope, index = 1
packages: 0
classifiers: 0
callables: 1
param: kotlin.String
constructors: 0
TypeScope, index = 2
packages: 0
classifiers: 0
callables: 0
constructors: 0
ExplicitSimpleImportingScope, index = 3
packages: 0
classifiers: 0
callables: 0
constructors: 0
PackageMemberScope, index = 4
packages: 0
classifiers: 0
callables: 0
constructors: 0
DefaultSimpleImportingScope, index = 5
DefaultSimpleImportingScope, index = 6
ExplicitStarImportingScope, index = 7
packages: 0
classifiers: 0
callables: 0
constructors: 0
DefaultSimpleImportingScope, index = 8
DefaultStarImportingScope, index = 9
@@ -0,0 +1,72 @@
element: param
implicit receivers:
type: KtClassErrorType:
annotationsList: []
type: ERROR_TYPE
owner symbol: KtFirNamedClassOrObjectSymbol
scopes:
LocalScope, index = 0
packages: 0
classifiers: 0
callables: 0
constructors: 0
LocalScope, index = 1
packages: 0
classifiers: 0
callables: 1
KtValueParameterSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
generatedPrimaryConstructorProperty: null
hasDefaultValue: false
isCrossinline: false
isExtension: false
isImplicitLambdaParameter: false
isNoinline: false
isVararg: false
name: param
origin: SOURCE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/String
symbolKind: LOCAL
typeParameters: []
constructors: 0
TypeScope, index = 2
packages: 0
classifiers: 0
callables: 0
constructors: 0
ExplicitSimpleImportingScope, index = 3
packages: 0
classifiers: 0
callables: 0
constructors: 0
PackageMemberScope, index = 4
packages: 0
classifiers: 0
callables: 0
constructors: 0
DefaultSimpleImportingScope, index = 5
DefaultSimpleImportingScope, index = 6
ExplicitStarImportingScope, index = 7
packages: 0
classifiers: 0
callables: 0
constructors: 0
DefaultSimpleImportingScope, index = 8
DefaultStarImportingScope, index = 9