Created kind in LexicalScope
This commit is contained in:
@@ -38,10 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
|
|||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
|
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils;
|
import org.jetbrains.kotlin.resolve.scopes.*;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl;
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.RedeclarationHandler;
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.types.*;
|
import org.jetbrains.kotlin.types.*;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||||
@@ -566,7 +563,7 @@ public class BodyResolver {
|
|||||||
final ConstructorDescriptor unsubstitutedPrimaryConstructor
|
final ConstructorDescriptor unsubstitutedPrimaryConstructor
|
||||||
) {
|
) {
|
||||||
return new LexicalScopeImpl(originalScope, unsubstitutedPrimaryConstructor, false, null,
|
return new LexicalScopeImpl(originalScope, unsubstitutedPrimaryConstructor, false, null,
|
||||||
"Scope with value parameters of a constructor", RedeclarationHandler.DO_NOTHING,
|
LexicalScopeKind.PRIMARY_CONSTRUCTOR_DEFAULT_VALUE, RedeclarationHandler.DO_NOTHING,
|
||||||
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
||||||
@@ -805,7 +802,7 @@ public class BodyResolver {
|
|||||||
KtProperty property = (KtProperty) function.getParent();
|
KtProperty property = (KtProperty) function.getParent();
|
||||||
final SyntheticFieldDescriptor fieldDescriptor = new SyntheticFieldDescriptor(accessorDescriptor, property);
|
final SyntheticFieldDescriptor fieldDescriptor = new SyntheticFieldDescriptor(accessorDescriptor, property);
|
||||||
innerScope = new LexicalScopeImpl(innerScope, functionDescriptor, true, null,
|
innerScope = new LexicalScopeImpl(innerScope, functionDescriptor, true, null,
|
||||||
"Accessor inner scope with synthetic field",
|
LexicalScopeKind.PROPERTY_ACCESSOR,
|
||||||
RedeclarationHandler.DO_NOTHING, new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
RedeclarationHandler.DO_NOTHING, new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsKt;
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils;
|
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
||||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
|
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
|
||||||
@@ -778,7 +779,7 @@ public class DescriptorResolver {
|
|||||||
else {
|
else {
|
||||||
LexicalWritableScope writableScope = new LexicalWritableScope(
|
LexicalWritableScope writableScope = new LexicalWritableScope(
|
||||||
scope, containingDeclaration, false, null, new TraceBasedRedeclarationHandler(trace),
|
scope, containingDeclaration, false, null, new TraceBasedRedeclarationHandler(trace),
|
||||||
"Scope with type parameters of a property");
|
LexicalScopeKind.PROPERTY_HEADER);
|
||||||
typeParameterDescriptors = resolveTypeParametersForCallableDescriptor(
|
typeParameterDescriptors = resolveTypeParametersForCallableDescriptor(
|
||||||
propertyDescriptor, writableScope, scope, typeParameters, trace);
|
propertyDescriptor, writableScope, scope, typeParameters, trace);
|
||||||
writableScope.changeLockLevel(LexicalWritableScope.LockLevel.READING);
|
writableScope.changeLockLevel(LexicalWritableScope.LockLevel.READING);
|
||||||
@@ -991,7 +992,7 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private PropertySetterDescriptor resolvePropertySetterDescriptor(
|
private PropertySetterDescriptor resolvePropertySetterDescriptor(
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scopeWithTypeParameters,
|
||||||
@NotNull KtProperty property,
|
@NotNull KtProperty property,
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
@NotNull AnnotationSplitter annotationSplitter,
|
@NotNull AnnotationSplitter annotationSplitter,
|
||||||
@@ -1002,7 +1003,7 @@ public class DescriptorResolver {
|
|||||||
if (setter != null) {
|
if (setter != null) {
|
||||||
Annotations annotations = new CompositeAnnotations(CollectionsKt.listOf(
|
Annotations annotations = new CompositeAnnotations(CollectionsKt.listOf(
|
||||||
annotationSplitter.getAnnotationsForTarget(PROPERTY_SETTER),
|
annotationSplitter.getAnnotationsForTarget(PROPERTY_SETTER),
|
||||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, setter.getModifierList(), trace)));
|
annotationResolver.resolveAnnotationsWithoutArguments(scopeWithTypeParameters, setter.getModifierList(), trace)));
|
||||||
KtParameter parameter = setter.getParameter();
|
KtParameter parameter = setter.getParameter();
|
||||||
|
|
||||||
setterDescriptor = new PropertySetterDescriptorImpl(propertyDescriptor, annotations,
|
setterDescriptor = new PropertySetterDescriptorImpl(propertyDescriptor, annotations,
|
||||||
@@ -1032,7 +1033,7 @@ public class DescriptorResolver {
|
|||||||
type = propertyDescriptor.getType(); // TODO : this maybe unknown at this point
|
type = propertyDescriptor.getType(); // TODO : this maybe unknown at this point
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
type = typeResolver.resolveType(scope, typeReference, trace, true);
|
type = typeResolver.resolveType(scopeWithTypeParameters, typeReference, trace, true);
|
||||||
KotlinType inType = propertyDescriptor.getType();
|
KotlinType inType = propertyDescriptor.getType();
|
||||||
if (inType != null) {
|
if (inType != null) {
|
||||||
if (!TypeUtils.equalTypes(type, inType)) {
|
if (!TypeUtils.equalTypes(type, inType)) {
|
||||||
@@ -1045,7 +1046,7 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ValueParameterDescriptorImpl valueParameterDescriptor =
|
ValueParameterDescriptorImpl valueParameterDescriptor =
|
||||||
resolveValueParameterDescriptor(scope, setterDescriptor, parameter, 0, type, trace);
|
resolveValueParameterDescriptor(scopeWithTypeParameters, setterDescriptor, parameter, 0, type, trace);
|
||||||
setterDescriptor.initialize(valueParameterDescriptor);
|
setterDescriptor.initialize(valueParameterDescriptor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1071,7 +1072,7 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private PropertyGetterDescriptorImpl resolvePropertyGetterDescriptor(
|
private PropertyGetterDescriptorImpl resolvePropertyGetterDescriptor(
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scopeWithTypeParameters,
|
||||||
@NotNull KtProperty property,
|
@NotNull KtProperty property,
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
@NotNull AnnotationSplitter annotationSplitter,
|
@NotNull AnnotationSplitter annotationSplitter,
|
||||||
@@ -1082,13 +1083,13 @@ public class DescriptorResolver {
|
|||||||
if (getter != null) {
|
if (getter != null) {
|
||||||
Annotations getterAnnotations = new CompositeAnnotations(CollectionsKt.listOf(
|
Annotations getterAnnotations = new CompositeAnnotations(CollectionsKt.listOf(
|
||||||
annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER),
|
annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER),
|
||||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, getter.getModifierList(), trace)));
|
annotationResolver.resolveAnnotationsWithoutArguments(scopeWithTypeParameters, getter.getModifierList(), trace)));
|
||||||
|
|
||||||
KotlinType outType = propertyDescriptor.getType();
|
KotlinType outType = propertyDescriptor.getType();
|
||||||
KotlinType returnType = outType;
|
KotlinType returnType = outType;
|
||||||
KtTypeReference returnTypeReference = getter.getReturnTypeReference();
|
KtTypeReference returnTypeReference = getter.getReturnTypeReference();
|
||||||
if (returnTypeReference != null) {
|
if (returnTypeReference != null) {
|
||||||
returnType = typeResolver.resolveType(scope, returnTypeReference, trace, true);
|
returnType = typeResolver.resolveType(scopeWithTypeParameters, returnTypeReference, trace, true);
|
||||||
if (outType != null && !TypeUtils.equalTypes(returnType, outType)) {
|
if (outType != null && !TypeUtils.equalTypes(returnType, outType)) {
|
||||||
trace.report(WRONG_GETTER_RETURN_TYPE.on(returnTypeReference, propertyDescriptor.getReturnType(), outType));
|
trace.report(WRONG_GETTER_RETURN_TYPE.on(returnTypeReference, propertyDescriptor.getReturnType(), outType));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.recordScope
|
|||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
|
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope
|
||||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
@@ -142,7 +143,7 @@ class FunctionDescriptorResolver(
|
|||||||
expectedFunctionType: KotlinType
|
expectedFunctionType: KotlinType
|
||||||
) {
|
) {
|
||||||
val innerScope = LexicalWritableScope(scope, functionDescriptor, true, null,
|
val innerScope = LexicalWritableScope(scope, functionDescriptor, true, null,
|
||||||
TraceBasedRedeclarationHandler(trace), "Function descriptor header scope")
|
TraceBasedRedeclarationHandler(trace), LexicalScopeKind.FUNCTION_HEADER)
|
||||||
|
|
||||||
val typeParameterDescriptors = descriptorResolver.
|
val typeParameterDescriptors = descriptorResolver.
|
||||||
resolveTypeParametersForCallableDescriptor(functionDescriptor, innerScope, scope, function.getTypeParameters(), trace)
|
resolveTypeParametersForCallableDescriptor(functionDescriptor, innerScope, scope, function.getTypeParameters(), trace)
|
||||||
@@ -284,7 +285,7 @@ class FunctionDescriptorResolver(
|
|||||||
constructorDescriptor,
|
constructorDescriptor,
|
||||||
false, null,
|
false, null,
|
||||||
TraceBasedRedeclarationHandler(trace),
|
TraceBasedRedeclarationHandler(trace),
|
||||||
"Scope with value parameters of a constructor"
|
LexicalScopeKind.CONSTRUCTOR_HEADER
|
||||||
)
|
)
|
||||||
parameterScope.changeLockLevel(LexicalWritableScope.LockLevel.BOTH)
|
parameterScope.changeLockLevel(LexicalWritableScope.LockLevel.BOTH)
|
||||||
val constructor = constructorDescriptor.initialize(
|
val constructor = constructorDescriptor.initialize(
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class FunctionDescriptorUtil {
|
|||||||
@NotNull RedeclarationHandler redeclarationHandler
|
@NotNull RedeclarationHandler redeclarationHandler
|
||||||
) {
|
) {
|
||||||
ReceiverParameterDescriptor receiver = descriptor.getExtensionReceiverParameter();
|
ReceiverParameterDescriptor receiver = descriptor.getExtensionReceiverParameter();
|
||||||
return new LexicalScopeImpl(outerScope, descriptor, true, receiver, "Function inner scope", redeclarationHandler,
|
return new LexicalScopeImpl(outerScope, descriptor, true, receiver, LexicalScopeKind.FUNCTION_INNER_SCOPE, redeclarationHandler,
|
||||||
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
||||||
|
|||||||
+4
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsUtil
|
|||||||
import org.jetbrains.kotlin.resolve.calls.util.CallMaker
|
import org.jetbrains.kotlin.resolve.calls.util.CallMaker
|
||||||
import org.jetbrains.kotlin.resolve.scopes.BaseLexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.BaseLexicalScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils
|
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||||
@@ -105,6 +106,9 @@ public fun resolvePossiblyAmbiguousCallableReference(
|
|||||||
|
|
||||||
// todo: drop this class when new resolve will be finished
|
// todo: drop this class when new resolve will be finished
|
||||||
class StaticScopeAsLexicalScope(val staticScope: MemberScope) : BaseLexicalScope(staticScope.memberScopeAsImportingScope(), classifier) {
|
class StaticScopeAsLexicalScope(val staticScope: MemberScope) : BaseLexicalScope(staticScope.memberScopeAsImportingScope(), classifier) {
|
||||||
|
override val kind: LexicalScopeKind
|
||||||
|
get() = LexicalScopeKind.CALLABLE_REFERENCE
|
||||||
|
|
||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println(toString())
|
p.println(toString())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.recordScope
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.BaseLexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.BaseLexicalScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
|
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.withParent
|
import org.jetbrains.kotlin.resolve.scopes.utils.withParent
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
@@ -106,6 +107,9 @@ public open class FileScopeProviderImpl(
|
|||||||
scope = LazyImportScope(scope, aliasImportResolver, LazyImportScope.FilteringKind.ALL, "Alias imports in $debugName")
|
scope = LazyImportScope(scope, aliasImportResolver, LazyImportScope.FilteringKind.ALL, "Alias imports in $debugName")
|
||||||
|
|
||||||
val lexicalScope = object : BaseLexicalScope(scope, packageFragment) {
|
val lexicalScope = object : BaseLexicalScope(scope, packageFragment) {
|
||||||
|
override val kind: LexicalScopeKind
|
||||||
|
get() = LexicalScopeKind.FILE
|
||||||
|
|
||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println("File top-level scope (empty)")
|
p.println("File top-level scope (empty)")
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-15
@@ -21,10 +21,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.psi.KtParameter
|
import org.jetbrains.kotlin.psi.KtParameter
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
|
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.*
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalChainedScope
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl
|
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -35,14 +32,14 @@ class ClassResolutionScopesSupport(
|
|||||||
private val getOuterScope: () -> LexicalScope,
|
private val getOuterScope: () -> LexicalScope,
|
||||||
private val primaryConstructorParameters: List<KtParameter>? = null
|
private val primaryConstructorParameters: List<KtParameter>? = null
|
||||||
) {
|
) {
|
||||||
private fun scopeWithGenerics(parent: LexicalScope, debugName: String): LexicalScopeImpl {
|
private fun scopeWithGenerics(parent: LexicalScope): LexicalScopeImpl {
|
||||||
return LexicalScopeImpl(parent, classDescriptor, false, null, debugName) {
|
return LexicalScopeImpl(parent, classDescriptor, false, null, LexicalScopeKind.CLASS_HEADER) {
|
||||||
classDescriptor.declaredTypeParameters.forEach { addClassifierDescriptor(it) }
|
classDescriptor.declaredTypeParameters.forEach { addClassifierDescriptor(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public val scopeForClassHeaderResolution: () -> LexicalScope = storageManager.createLazyValue {
|
public val scopeForClassHeaderResolution: () -> LexicalScope = storageManager.createLazyValue {
|
||||||
scopeWithGenerics(getOuterScope(), "Scope for class header resolution for ${classDescriptor.name}")
|
scopeWithGenerics(getOuterScope())
|
||||||
}
|
}
|
||||||
|
|
||||||
private val inheritanceScope: () -> LexicalScope = storageManager.createLazyValueWithPostCompute(
|
private val inheritanceScope: () -> LexicalScope = storageManager.createLazyValueWithPostCompute(
|
||||||
@@ -57,10 +54,9 @@ class ClassResolutionScopesSupport(
|
|||||||
|
|
||||||
|
|
||||||
public val scopeForMemberDeclarationResolution: () -> LexicalScope = storageManager.createLazyValue {
|
public val scopeForMemberDeclarationResolution: () -> LexicalScope = storageManager.createLazyValue {
|
||||||
val scopeWithGenerics = scopeWithGenerics(inheritanceScope(),
|
val scopeWithGenerics = scopeWithGenerics(inheritanceScope())
|
||||||
"Scope with generics for ${classDescriptor.name}")
|
|
||||||
LexicalScopeImpl(scopeWithGenerics, classDescriptor, true, classDescriptor.thisAsReceiverParameter,
|
LexicalScopeImpl(scopeWithGenerics, classDescriptor, true, classDescriptor.thisAsReceiverParameter,
|
||||||
"Scope for member declaration resolution: ${classDescriptor.name}")
|
LexicalScopeKind.CLASS_MEMBER_SCOPE)
|
||||||
}
|
}
|
||||||
|
|
||||||
public val scopeForStaticMemberDeclarationResolution: () -> LexicalScope = storageManager.createLazyValue {
|
public val scopeForStaticMemberDeclarationResolution: () -> LexicalScope = storageManager.createLazyValue {
|
||||||
@@ -69,7 +65,7 @@ class ClassResolutionScopesSupport(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LexicalScopeImpl(inheritanceScope(), classDescriptor, false, null,
|
LexicalScopeImpl(inheritanceScope(), classDescriptor, false, null,
|
||||||
"Scope for static member declaration resolution: ${classDescriptor.name}")
|
LexicalScopeKind.CLASS_STATIC_SCOPE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +76,7 @@ class ClassResolutionScopesSupport(
|
|||||||
"primary constructor parameters must be not null, because primary constructor exist: $primaryConstructor"
|
"primary constructor parameters must be not null, because primary constructor exist: $primaryConstructor"
|
||||||
}
|
}
|
||||||
LexicalScopeImpl(scopeForMemberDeclarationResolution(), primaryConstructor, false, null,
|
LexicalScopeImpl(scopeForMemberDeclarationResolution(), primaryConstructor, false, null,
|
||||||
"Scope for initializer resolution: ${classDescriptor.name}") {
|
LexicalScopeKind.CLASS_INITIALIZER) {
|
||||||
primaryConstructorParameters!!.forEachIndexed {
|
primaryConstructorParameters!!.forEachIndexed {
|
||||||
index, parameter ->
|
index, parameter ->
|
||||||
if (!parameter.hasValOrVar()) {
|
if (!parameter.hasValOrVar()) {
|
||||||
@@ -117,9 +113,9 @@ class ClassResolutionScopesSupport(
|
|||||||
staticScopes.addIfNotNull(classDescriptor.companionObjectDescriptor?.unsubstitutedInnerClassesScope)
|
staticScopes.addIfNotNull(classDescriptor.companionObjectDescriptor?.unsubstitutedInnerClassesScope)
|
||||||
|
|
||||||
return LexicalChainedScope(parent, ownerDescriptor, false,
|
return LexicalChainedScope(parent, ownerDescriptor, false,
|
||||||
classDescriptor.companionObjectDescriptor?.thisAsReceiverParameter,
|
classDescriptor.companionObjectDescriptor?.thisAsReceiverParameter,
|
||||||
"Scope with static members, nested classes and companion object for ${classDescriptor.name}",
|
LexicalScopeKind.CLASS_INHERITANCE,
|
||||||
memberScopes = *staticScopes.toTypedArray(), isStaticScope = true)
|
memberScopes = *staticScopes.toTypedArray(), isStaticScope = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ public final class JetScopeUtils {
|
|||||||
getPropertyDeclarationInnerScope(propertyDescriptor, parentScope,
|
getPropertyDeclarationInnerScope(propertyDescriptor, parentScope,
|
||||||
propertyDescriptor.getTypeParameters(),
|
propertyDescriptor.getTypeParameters(),
|
||||||
propertyDescriptor.getExtensionReceiverParameter(), trace);
|
propertyDescriptor.getExtensionReceiverParameter(), trace);
|
||||||
return new LexicalScopeImpl(propertyDeclarationInnerScope, parentScope.getOwnerDescriptor(), false, null, "Accessor Scope");
|
return new LexicalScopeImpl(propertyDeclarationInnerScope, parentScope.getOwnerDescriptor(), false, null, LexicalScopeKind.UNSORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LexicalScope getPropertyDeclarationInnerScope(
|
public static LexicalScope getPropertyDeclarationInnerScope(
|
||||||
@@ -111,7 +111,7 @@ public final class JetScopeUtils {
|
|||||||
) {
|
) {
|
||||||
return new LexicalScopeImpl(
|
return new LexicalScopeImpl(
|
||||||
outerScope, propertyDescriptor, addLabelForProperty, receiver,
|
outerScope, propertyDescriptor, addLabelForProperty, receiver,
|
||||||
"Property declaration inner scope",
|
LexicalScopeKind.UNSORTED,
|
||||||
redeclarationHandler, new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
redeclarationHandler, new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class LexicalChainedScope @JvmOverloads constructor(
|
|||||||
override val ownerDescriptor: DeclarationDescriptor,
|
override val ownerDescriptor: DeclarationDescriptor,
|
||||||
override val isOwnerDescriptorAccessibleByLabel: Boolean,
|
override val isOwnerDescriptorAccessibleByLabel: Boolean,
|
||||||
override val implicitReceiver: ReceiverParameterDescriptor?,
|
override val implicitReceiver: ReceiverParameterDescriptor?,
|
||||||
private val debugName: String,
|
override val kind: LexicalScopeKind,
|
||||||
vararg memberScopes: MemberScope,
|
vararg memberScopes: MemberScope,
|
||||||
@Deprecated("This value is temporary hack for resolve -- don't use it!")
|
@Deprecated("This value is temporary hack for resolve -- don't use it!")
|
||||||
val isStaticScope: Boolean = false
|
val isStaticScope: Boolean = false
|
||||||
@@ -47,10 +47,10 @@ public class LexicalChainedScope @JvmOverloads constructor(
|
|||||||
|
|
||||||
override fun getContributedFunctions(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getContributedFunctions(name, location) }
|
override fun getContributedFunctions(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getContributedFunctions(name, location) }
|
||||||
|
|
||||||
override fun toString(): String = debugName
|
override fun toString(): String = kind.toString()
|
||||||
|
|
||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println(javaClass.simpleName, ": ", debugName, "; for descriptor: ", ownerDescriptor.name,
|
p.println(javaClass.simpleName, ": ", kind, "; for descriptor: ", ownerDescriptor.name,
|
||||||
" with implicitReceiver: ", implicitReceiver?.value ?: "NONE", " {")
|
" with implicitReceiver: ", implicitReceiver?.value ?: "NONE", " {")
|
||||||
p.pushIndent()
|
p.pushIndent()
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class LexicalScopeImpl @JvmOverloads constructor(
|
|||||||
override val ownerDescriptor: DeclarationDescriptor,
|
override val ownerDescriptor: DeclarationDescriptor,
|
||||||
override val isOwnerDescriptorAccessibleByLabel: Boolean,
|
override val isOwnerDescriptorAccessibleByLabel: Boolean,
|
||||||
override val implicitReceiver: ReceiverParameterDescriptor?,
|
override val implicitReceiver: ReceiverParameterDescriptor?,
|
||||||
private val debugName: String,
|
override val kind: LexicalScopeKind,
|
||||||
redeclarationHandler: RedeclarationHandler = RedeclarationHandler.DO_NOTHING,
|
redeclarationHandler: RedeclarationHandler = RedeclarationHandler.DO_NOTHING,
|
||||||
initialize: LexicalScopeImpl.InitializeHandler.() -> Unit = {}
|
initialize: LexicalScopeImpl.InitializeHandler.() -> Unit = {}
|
||||||
): LexicalScope, WritableScopeStorage(redeclarationHandler) {
|
): LexicalScope, WritableScopeStorage(redeclarationHandler) {
|
||||||
@@ -43,10 +43,10 @@ public class LexicalScopeImpl @JvmOverloads constructor(
|
|||||||
override fun getContributedFunctions(name: Name, location: LookupLocation) = getFunctions(name)
|
override fun getContributedFunctions(name: Name, location: LookupLocation) = getFunctions(name)
|
||||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = addedDescriptors
|
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = addedDescriptors
|
||||||
|
|
||||||
override fun toString(): String = debugName
|
override fun toString(): String = kind.toString()
|
||||||
|
|
||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println(javaClass.simpleName, ": ", debugName, "; for descriptor: ", ownerDescriptor.name,
|
p.println(javaClass.simpleName, ": ", kind, "; for descriptor: ", ownerDescriptor.name,
|
||||||
" with implicitReceiver: ", implicitReceiver?.value ?: "NONE", " {")
|
" with implicitReceiver: ", implicitReceiver?.value ?: "NONE", " {")
|
||||||
p.pushIndent()
|
p.pushIndent()
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class LexicalWritableScope(
|
|||||||
override val isOwnerDescriptorAccessibleByLabel: Boolean,
|
override val isOwnerDescriptorAccessibleByLabel: Boolean,
|
||||||
override val implicitReceiver: ReceiverParameterDescriptor?,
|
override val implicitReceiver: ReceiverParameterDescriptor?,
|
||||||
redeclarationHandler: RedeclarationHandler,
|
redeclarationHandler: RedeclarationHandler,
|
||||||
private val debugName: String
|
override val kind: LexicalScopeKind
|
||||||
) : LexicalScope, WritableScopeStorage(redeclarationHandler) {
|
) : LexicalScope, WritableScopeStorage(redeclarationHandler) {
|
||||||
public enum class LockLevel {
|
public enum class LockLevel {
|
||||||
WRITING,
|
WRITING,
|
||||||
@@ -106,7 +106,7 @@ class LexicalWritableScope(
|
|||||||
override fun getContributedFunctions(name: Name, location: LookupLocation)
|
override fun getContributedFunctions(name: Name, location: LookupLocation)
|
||||||
= this@LexicalWritableScope.getFunctions(name, descriptorLimit)
|
= this@LexicalWritableScope.getFunctions(name, descriptorLimit)
|
||||||
|
|
||||||
override fun toString(): String = "Snapshot($descriptorLimit) for $debugName"
|
override fun toString(): String = "Snapshot($descriptorLimit) for $kind"
|
||||||
|
|
||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println("Snapshot with descriptorLimit = $descriptorLimit for scope:")
|
p.println("Snapshot with descriptorLimit = $descriptorLimit for scope:")
|
||||||
@@ -114,10 +114,10 @@ class LexicalWritableScope(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String = debugName
|
override fun toString(): String = kind.toString()
|
||||||
|
|
||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println(javaClass.simpleName, ": ", debugName, "; for descriptor: ", ownerDescriptor.name,
|
p.println(javaClass.simpleName, ": ", kind, "; for descriptor: ", ownerDescriptor.name,
|
||||||
" with implicitReceiver: ", implicitReceiver?.value ?: "NONE", " {")
|
" with implicitReceiver: ", implicitReceiver?.value ?: "NONE", " {")
|
||||||
p.pushIndent()
|
p.pushIndent()
|
||||||
|
|
||||||
|
|||||||
@@ -38,9 +38,13 @@ interface LexicalScope: HierarchicalScope {
|
|||||||
|
|
||||||
val implicitReceiver: ReceiverParameterDescriptor?
|
val implicitReceiver: ReceiverParameterDescriptor?
|
||||||
|
|
||||||
|
val kind: LexicalScopeKind
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun empty(parent: HierarchicalScope, ownerDescriptor: DeclarationDescriptor): BaseLexicalScope {
|
fun empty(parent: HierarchicalScope, ownerDescriptor: DeclarationDescriptor): BaseLexicalScope {
|
||||||
return object : BaseLexicalScope(parent, ownerDescriptor) {
|
return object : BaseLexicalScope(parent, ownerDescriptor) {
|
||||||
|
override val kind: LexicalScopeKind get() = LexicalScopeKind.EMPTY
|
||||||
|
|
||||||
override fun printStructure(p: Printer) {
|
override fun printStructure(p: Printer) {
|
||||||
p.println("Empty lexical scope with owner = $ownerDescriptor and parent = ${parent}.")
|
p.println("Empty lexical scope with owner = $ownerDescriptor and parent = ${parent}.")
|
||||||
}
|
}
|
||||||
@@ -49,6 +53,47 @@ interface LexicalScope: HierarchicalScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class LexicalScopeKind {
|
||||||
|
@Deprecated("Temporary")
|
||||||
|
UNSORTED,
|
||||||
|
EMPTY,
|
||||||
|
|
||||||
|
CLASS_HEADER,
|
||||||
|
CLASS_INHERITANCE,
|
||||||
|
CONSTRUCTOR_HEADER,
|
||||||
|
PRIMARY_CONSTRUCTOR_DEFAULT_VALUE,
|
||||||
|
CLASS_STATIC_SCOPE,
|
||||||
|
CLASS_MEMBER_SCOPE,
|
||||||
|
CLASS_INITIALIZER,
|
||||||
|
|
||||||
|
PROPERTY_HEADER,
|
||||||
|
PROPERTY_INITIALIZER,
|
||||||
|
PROPERTY_DELEGATE,
|
||||||
|
PROPERTY_ACCESSOR,
|
||||||
|
|
||||||
|
FUNCTION_HEADER,
|
||||||
|
FUNCTION_INNER_SCOPE,
|
||||||
|
|
||||||
|
CODE_BLOCK,
|
||||||
|
|
||||||
|
LEFT_BOOLEAN_EXPRESSION,
|
||||||
|
RIGHT_BOOLEAN_EXPRESSION,
|
||||||
|
|
||||||
|
THEN,
|
||||||
|
ELSE,
|
||||||
|
DO_WHILE,
|
||||||
|
CATCH,
|
||||||
|
FOR,
|
||||||
|
WHILE,
|
||||||
|
WHEN,
|
||||||
|
|
||||||
|
FILE,
|
||||||
|
CALLABLE_REFERENCE,
|
||||||
|
|
||||||
|
// for tests, KDoc & IDE
|
||||||
|
SYNTHETIC
|
||||||
|
}
|
||||||
|
|
||||||
interface ImportingScope : HierarchicalScope {
|
interface ImportingScope : HierarchicalScope {
|
||||||
override val parent: ImportingScope?
|
override val parent: ImportingScope?
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -59,6 +59,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate;
|
|||||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy;
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy;
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
|
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
|
||||||
import org.jetbrains.kotlin.resolve.constants.*;
|
import org.jetbrains.kotlin.resolve.constants.*;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
@@ -1224,11 +1225,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
KotlinTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context.replaceExpectedType(booleanType), facade);
|
KotlinTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context.replaceExpectedType(booleanType), facade);
|
||||||
DataFlowInfo dataFlowInfo = leftTypeInfo.getDataFlowInfo();
|
DataFlowInfo dataFlowInfo = leftTypeInfo.getDataFlowInfo();
|
||||||
|
|
||||||
LexicalWritableScope leftScope = newWritableScopeImpl(context, "Left scope of && or ||");
|
LexicalWritableScope leftScope = newWritableScopeImpl(context, LexicalScopeKind.LEFT_BOOLEAN_EXPRESSION);
|
||||||
// TODO: This gets computed twice: here and in extractDataFlowInfoFromCondition() for the whole condition
|
// TODO: This gets computed twice: here and in extractDataFlowInfoFromCondition() for the whole condition
|
||||||
boolean isAnd = operationType == KtTokens.ANDAND;
|
boolean isAnd = operationType == KtTokens.ANDAND;
|
||||||
DataFlowInfo flowInfoLeft = components.dataFlowAnalyzer.extractDataFlowInfoFromCondition(left, isAnd, context).and(dataFlowInfo);
|
DataFlowInfo flowInfoLeft = components.dataFlowAnalyzer.extractDataFlowInfoFromCondition(left, isAnd, context).and(dataFlowInfo);
|
||||||
LexicalWritableScope rightScope = isAnd ? leftScope : newWritableScopeImpl(context, "Right scope of && or ||");
|
LexicalWritableScope rightScope = isAnd ? leftScope : newWritableScopeImpl(context, LexicalScopeKind.RIGHT_BOOLEAN_EXPRESSION);
|
||||||
|
|
||||||
ExpressionTypingContext contextForRightExpr =
|
ExpressionTypingContext contextForRightExpr =
|
||||||
context.replaceDataFlowInfo(flowInfoLeft).replaceScope(rightScope).replaceExpectedType(booleanType);
|
context.replaceDataFlowInfo(flowInfoLeft).replaceScope(rightScope).replaceExpectedType(booleanType);
|
||||||
|
|||||||
+7
-6
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
||||||
@@ -98,8 +99,8 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
KtExpression elseBranch = ifExpression.getElse();
|
KtExpression elseBranch = ifExpression.getElse();
|
||||||
KtExpression thenBranch = ifExpression.getThen();
|
KtExpression thenBranch = ifExpression.getThen();
|
||||||
|
|
||||||
LexicalWritableScope thenScope = newWritableScopeImpl(context, "Then scope");
|
LexicalWritableScope thenScope = newWritableScopeImpl(context, LexicalScopeKind.THEN);
|
||||||
LexicalWritableScope elseScope = newWritableScopeImpl(context, "Else scope");
|
LexicalWritableScope elseScope = newWritableScopeImpl(context, LexicalScopeKind.ELSE);
|
||||||
DataFlowInfo thenInfo = components.dataFlowAnalyzer.extractDataFlowInfoFromCondition(condition, true, context).and(conditionDataFlowInfo);
|
DataFlowInfo thenInfo = components.dataFlowAnalyzer.extractDataFlowInfoFromCondition(condition, true, context).and(conditionDataFlowInfo);
|
||||||
DataFlowInfo elseInfo = components.dataFlowAnalyzer.extractDataFlowInfoFromCondition(condition, false, context).and(conditionDataFlowInfo);
|
DataFlowInfo elseInfo = components.dataFlowAnalyzer.extractDataFlowInfoFromCondition(condition, false, context).and(conditionDataFlowInfo);
|
||||||
|
|
||||||
@@ -227,7 +228,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
KotlinTypeInfo bodyTypeInfo;
|
KotlinTypeInfo bodyTypeInfo;
|
||||||
DataFlowInfo conditionInfo = components.dataFlowAnalyzer.extractDataFlowInfoFromCondition(condition, true, context).and(dataFlowInfo);
|
DataFlowInfo conditionInfo = components.dataFlowAnalyzer.extractDataFlowInfoFromCondition(condition, true, context).and(dataFlowInfo);
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
LexicalWritableScope scopeToExtend = newWritableScopeImpl(context, "Scope extended in while's condition");
|
LexicalWritableScope scopeToExtend = newWritableScopeImpl(context, LexicalScopeKind.WHILE);
|
||||||
bodyTypeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
bodyTypeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope(
|
||||||
scopeToExtend, Collections.singletonList(body),
|
scopeToExtend, Collections.singletonList(body),
|
||||||
CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(conditionInfo));
|
CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(conditionInfo));
|
||||||
@@ -320,7 +321,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
bodyTypeInfo = facade.getTypeInfo(body, context.replaceScope(context.scope));
|
bodyTypeInfo = facade.getTypeInfo(body, context.replaceScope(context.scope));
|
||||||
}
|
}
|
||||||
else if (body != null) {
|
else if (body != null) {
|
||||||
LexicalWritableScope writableScope = newWritableScopeImpl(context, "do..while body scope");
|
LexicalWritableScope writableScope = newWritableScopeImpl(context, LexicalScopeKind.DO_WHILE);
|
||||||
conditionScope = writableScope;
|
conditionScope = writableScope;
|
||||||
List<KtExpression> block;
|
List<KtExpression> block;
|
||||||
if (body instanceof KtBlockExpression) {
|
if (body instanceof KtBlockExpression) {
|
||||||
@@ -388,7 +389,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
loopRangeInfo = TypeInfoFactoryKt.noTypeInfo(context);
|
loopRangeInfo = TypeInfoFactoryKt.noTypeInfo(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
LexicalWritableScope loopScope = newWritableScopeImpl(context, "Scope with for-loop index");
|
LexicalWritableScope loopScope = newWritableScopeImpl(context, LexicalScopeKind.FOR);
|
||||||
|
|
||||||
KtParameter loopParameter = expression.getLoopParameter();
|
KtParameter loopParameter = expression.getLoopParameter();
|
||||||
if (loopParameter != null) {
|
if (loopParameter != null) {
|
||||||
@@ -480,7 +481,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
KotlinType throwableType = components.builtIns.getThrowable().getDefaultType();
|
KotlinType throwableType = components.builtIns.getThrowable().getDefaultType();
|
||||||
components.dataFlowAnalyzer.checkType(variableDescriptor.getType(), catchParameter, context.replaceExpectedType(throwableType));
|
components.dataFlowAnalyzer.checkType(variableDescriptor.getType(), catchParameter, context.replaceExpectedType(throwableType));
|
||||||
if (catchBody != null) {
|
if (catchBody != null) {
|
||||||
LexicalWritableScope catchScope = newWritableScopeImpl(context, "Catch scope");
|
LexicalWritableScope catchScope = newWritableScopeImpl(context, LexicalScopeKind.CATCH);
|
||||||
catchScope.addVariableDescriptor(variableDescriptor);
|
catchScope.addVariableDescriptor(variableDescriptor);
|
||||||
KotlinType type = facade.getTypeInfo(catchBody, context.replaceScope(catchScope)).getType();
|
KotlinType type = facade.getTypeInfo(catchBody, context.replaceScope(catchScope)).getType();
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
|||||||
+2
-1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.context.ContextDependency;
|
|||||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
|
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
@@ -160,7 +161,7 @@ public class ExpressionTypingServices {
|
|||||||
|
|
||||||
DeclarationDescriptor containingDescriptor = context.scope.getOwnerDescriptor();
|
DeclarationDescriptor containingDescriptor = context.scope.getOwnerDescriptor();
|
||||||
LexicalWritableScope scope = new LexicalWritableScope(context.scope, containingDescriptor, false, null,
|
LexicalWritableScope scope = new LexicalWritableScope(context.scope, containingDescriptor, false, null,
|
||||||
new TraceBasedRedeclarationHandler(context.trace), "getBlockReturnedType");
|
new TraceBasedRedeclarationHandler(context.trace), LexicalScopeKind.CODE_BLOCK);
|
||||||
scope.changeLockLevel(LexicalWritableScope.LockLevel.BOTH);
|
scope.changeLockLevel(LexicalWritableScope.LockLevel.BOTH);
|
||||||
|
|
||||||
KotlinTypeInfo r;
|
KotlinTypeInfo r;
|
||||||
|
|||||||
+4
-3
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
|||||||
import org.jetbrains.kotlin.resolve.ObservableBindingTrace;
|
import org.jetbrains.kotlin.resolve.ObservableBindingTrace;
|
||||||
import org.jetbrains.kotlin.resolve.TraceBasedRedeclarationHandler;
|
import org.jetbrains.kotlin.resolve.TraceBasedRedeclarationHandler;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
||||||
@@ -79,9 +80,9 @@ public class ExpressionTypingUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static LexicalWritableScope newWritableScopeImpl(ExpressionTypingContext context, @NotNull String scopeDebugName) {
|
public static LexicalWritableScope newWritableScopeImpl(ExpressionTypingContext context, @NotNull LexicalScopeKind scopeKind) {
|
||||||
LexicalWritableScope scope = new LexicalWritableScope(
|
LexicalWritableScope scope = new LexicalWritableScope(context.scope, context.scope.getOwnerDescriptor(), false, null,
|
||||||
context.scope, context.scope.getOwnerDescriptor(), false, null, new TraceBasedRedeclarationHandler(context.trace), scopeDebugName);
|
new TraceBasedRedeclarationHandler(context.trace), scopeKind);
|
||||||
scope.changeLockLevel(LexicalWritableScope.LockLevel.BOTH);
|
scope.changeLockLevel(LexicalWritableScope.LockLevel.BOTH);
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.AnnotationChecker;
|
|||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContextUtils;
|
import org.jetbrains.kotlin.resolve.BindingContextUtils;
|
||||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
|
import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
||||||
import org.jetbrains.kotlin.types.DeferredType;
|
import org.jetbrains.kotlin.types.DeferredType;
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||||
@@ -146,7 +147,7 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<Kotlin
|
|||||||
|
|
||||||
protected ExpressionTypingVisitorForStatements createStatementVisitor(ExpressionTypingContext context) {
|
protected ExpressionTypingVisitorForStatements createStatementVisitor(ExpressionTypingContext context) {
|
||||||
return new ExpressionTypingVisitorForStatements(this,
|
return new ExpressionTypingVisitorForStatements(this,
|
||||||
ExpressionTypingUtils.newWritableScopeImpl(context, "statement scope"),
|
ExpressionTypingUtils.newWritableScopeImpl(context, LexicalScopeKind.CODE_BLOCK),
|
||||||
basic, controlStructures, patterns, functions);
|
basic, controlStructures, patterns, functions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue;
|
|||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory;
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastResult;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastResult;
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
|
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
||||||
import org.jetbrains.kotlin.types.*;
|
import org.jetbrains.kotlin.types.*;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
@@ -120,7 +121,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
KtExpression bodyExpression = whenEntry.getExpression();
|
KtExpression bodyExpression = whenEntry.getExpression();
|
||||||
if (bodyExpression != null) {
|
if (bodyExpression != null) {
|
||||||
LexicalWritableScope scopeToExtend = newWritableScopeImpl(context, "Scope extended in when entry");
|
LexicalWritableScope scopeToExtend = newWritableScopeImpl(context, LexicalScopeKind.WHEN);
|
||||||
ExpressionTypingContext newContext = contextWithExpectedType
|
ExpressionTypingContext newContext = contextWithExpectedType
|
||||||
.replaceScope(scopeToExtend).replaceDataFlowInfo(infosForCondition.thenInfo).replaceContextDependency(INDEPENDENT);
|
.replaceScope(scopeToExtend).replaceDataFlowInfo(infosForCondition.thenInfo).replaceContextDependency(INDEPENDENT);
|
||||||
CoercionStrategy coercionStrategy = isStatement ? CoercionStrategy.COERCION_TO_UNIT : CoercionStrategy.NO_COERCION;
|
CoercionStrategy coercionStrategy = isStatement ? CoercionStrategy.COERCION_TO_UNIT : CoercionStrategy.NO_COERCION;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil;
|
import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.ImportingScope;
|
import org.jetbrains.kotlin.resolve.scopes.ImportingScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
import org.jetbrains.kotlin.tests.di.ContainerForTests;
|
import org.jetbrains.kotlin.tests.di.ContainerForTests;
|
||||||
@@ -139,7 +140,7 @@ public class ExpectedResolveDataUtil {
|
|||||||
|
|
||||||
LexicalScopeImpl lexicalScope = new LexicalScopeImpl(ImportingScope.Empty.INSTANCE, classDescriptor, false,
|
LexicalScopeImpl lexicalScope = new LexicalScopeImpl(ImportingScope.Empty.INSTANCE, classDescriptor, false,
|
||||||
classDescriptor.getThisAsReceiverParameter(),
|
classDescriptor.getThisAsReceiverParameter(),
|
||||||
"Scope with implicit this for class: " + classDescriptor);
|
LexicalScopeKind.SYNTHETIC);
|
||||||
|
|
||||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||||
new BindingTraceContext(), lexicalScope,
|
new BindingTraceContext(), lexicalScope,
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
import org.jetbrains.kotlin.resolve.scopes.*;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl;
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.RedeclarationHandler;
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
|
||||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||||
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
||||||
@@ -96,7 +93,7 @@ public class DefaultModalityModifiersTest extends KotlinLiteFixture {
|
|||||||
AnalysisResult bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(file);
|
AnalysisResult bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(file);
|
||||||
final DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
|
final DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
|
||||||
return new LexicalScopeImpl(ScopeUtilsKt.memberScopeAsImportingScope(libraryScope), root, false, null,
|
return new LexicalScopeImpl(ScopeUtilsKt.memberScopeAsImportingScope(libraryScope), root, false, null,
|
||||||
"JetDefaultModalityModifiersTest", RedeclarationHandler.DO_NOTHING,
|
LexicalScopeKind.SYNTHETIC, RedeclarationHandler.DO_NOTHING,
|
||||||
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil;
|
import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
||||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||||
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
import org.jetbrains.kotlin.test.KotlinLiteFixture;
|
||||||
@@ -562,7 +563,7 @@ public class KotlinTypeCheckerTest extends KotlinLiteFixture {
|
|||||||
);
|
);
|
||||||
|
|
||||||
LexicalScope scope = new LexicalScopeImpl(scopeWithImports, scopeWithImports.getOwnerDescriptor(), false,
|
LexicalScope scope = new LexicalScopeImpl(scopeWithImports, scopeWithImports.getOwnerDescriptor(), false,
|
||||||
receiverParameterDescriptor, "Scope with receiver: " + thisType);
|
receiverParameterDescriptor, LexicalScopeKind.SYNTHETIC);
|
||||||
assertType(scope, expression, expectedType);
|
assertType(scope, expression, expectedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
|
|||||||
LexicalScope topLevelScope = trace.get(BindingContext.LEXICAL_SCOPE, jetFile);
|
LexicalScope topLevelScope = trace.get(BindingContext.LEXICAL_SCOPE, jetFile);
|
||||||
final ClassifierDescriptor contextClass = ScopeUtilsKt.findClassifier(topLevelScope, Name.identifier("___Context"), NoLookupLocation.FROM_TEST);
|
final ClassifierDescriptor contextClass = ScopeUtilsKt.findClassifier(topLevelScope, Name.identifier("___Context"), NoLookupLocation.FROM_TEST);
|
||||||
assert contextClass instanceof ClassDescriptor;
|
assert contextClass instanceof ClassDescriptor;
|
||||||
LexicalScope typeParameters = new LexicalScopeImpl(topLevelScope, module, false, null, "Type parameter scope",
|
LexicalScope typeParameters = new LexicalScopeImpl(topLevelScope, module, false, null, LexicalScopeKind.SYNTHETIC,
|
||||||
RedeclarationHandler.THROW_EXCEPTION,
|
RedeclarationHandler.THROW_EXCEPTION,
|
||||||
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -103,7 +103,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
|
|||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return new LexicalChainedScope(typeParameters, module, false, null, "TypeSubstitutorTest::getContextScope()",
|
return new LexicalChainedScope(typeParameters, module, false, null, LexicalScopeKind.SYNTHETIC,
|
||||||
new MemberScope[] {
|
new MemberScope[] {
|
||||||
contextClass.getDefaultType().getMemberScope(),
|
contextClass.getDefaultType().getMemberScope(),
|
||||||
module.getBuiltIns().getBuiltInsPackageScope()
|
module.getBuiltIns().getBuiltInsPackageScope()
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public class TypeUnifierTest extends KotlinLiteFixture {
|
|||||||
|
|
||||||
private TypeProjection makeTypeProjection(MemberScope scope, String typeStr) {
|
private TypeProjection makeTypeProjection(MemberScope scope, String typeStr) {
|
||||||
LexicalScope withX = new LexicalScopeImpl(ScopeUtilsKt.memberScopeAsImportingScope(scope), builtIns.getBuiltInsModule(),
|
LexicalScope withX = new LexicalScopeImpl(ScopeUtilsKt.memberScopeAsImportingScope(scope), builtIns.getBuiltInsModule(),
|
||||||
false, null, "With X", RedeclarationHandler.DO_NOTHING,
|
false, null, LexicalScopeKind.SYNTHETIC, RedeclarationHandler.DO_NOTHING,
|
||||||
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ private fun getPackageInnerScope(descriptor: PackageFragmentDescriptor): MemberS
|
|||||||
private fun getClassInnerScope(outerScope: LexicalScope, descriptor: ClassDescriptor): LexicalScope {
|
private fun getClassInnerScope(outerScope: LexicalScope, descriptor: ClassDescriptor): LexicalScope {
|
||||||
|
|
||||||
val headerScope = LexicalScopeImpl(outerScope, descriptor, false, descriptor.thisAsReceiverParameter,
|
val headerScope = LexicalScopeImpl(outerScope, descriptor, false, descriptor.thisAsReceiverParameter,
|
||||||
"Class ${descriptor.name} header scope") {
|
LexicalScopeKind.SYNTHETIC) {
|
||||||
for (typeParameter in descriptor.declaredTypeParameters) {
|
for (typeParameter in descriptor.declaredTypeParameters) {
|
||||||
addClassifierDescriptor(typeParameter)
|
addClassifierDescriptor(typeParameter)
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ private fun getClassInnerScope(outerScope: LexicalScope, descriptor: ClassDescri
|
|||||||
}
|
}
|
||||||
|
|
||||||
return LexicalChainedScope(headerScope, descriptor, false, null,
|
return LexicalChainedScope(headerScope, descriptor, false, null,
|
||||||
"Class ${descriptor.name} scope",
|
LexicalScopeKind.SYNTHETIC,
|
||||||
*scopeChain.toTypedArray())
|
*scopeChain.toTypedArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.BindingTraceContext
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.TypeResolver
|
import org.jetbrains.kotlin.resolve.TypeResolver
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.SubstitutionUtils
|
import org.jetbrains.kotlin.types.SubstitutionUtils
|
||||||
@@ -77,7 +78,7 @@ internal class HeuristicSignatures(
|
|||||||
private fun typeFromText(text: String, typeParameters: Collection<TypeParameterDescriptor>): KotlinType {
|
private fun typeFromText(text: String, typeParameters: Collection<TypeParameterDescriptor>): KotlinType {
|
||||||
val typeRef = KtPsiFactory(project).createType(text)
|
val typeRef = KtPsiFactory(project).createType(text)
|
||||||
val rootPackagesScope = SubpackagesScope(moduleDescriptor, FqName.ROOT).memberScopeAsImportingScope()
|
val rootPackagesScope = SubpackagesScope(moduleDescriptor, FqName.ROOT).memberScopeAsImportingScope()
|
||||||
val scope = LexicalScopeImpl(rootPackagesScope, moduleDescriptor, false, null, "Root packages + type parameters") {
|
val scope = LexicalScopeImpl(rootPackagesScope, moduleDescriptor, false, null, LexicalScopeKind.SYNTHETIC) {
|
||||||
typeParameters.forEach { addClassifierDescriptor(it) }
|
typeParameters.forEach { addClassifierDescriptor(it) }
|
||||||
}
|
}
|
||||||
val type = typeResolver.resolveType(scope, typeRef, BindingTraceContext(), false)
|
val type = typeResolver.resolveType(scope, typeRef, BindingTraceContext(), false)
|
||||||
|
|||||||
+2
-1
@@ -67,6 +67,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope
|
import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier
|
import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
@@ -354,7 +355,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
val memberScope = receiverClassDescriptor.getMemberScope(projections)
|
val memberScope = receiverClassDescriptor.getMemberScope(projections)
|
||||||
|
|
||||||
return LexicalScopeImpl(memberScope.memberScopeAsImportingScope(), receiverClassDescriptor, false, null,
|
return LexicalScopeImpl(memberScope.memberScopeAsImportingScope(), receiverClassDescriptor, false, null,
|
||||||
"Scope with type parameters for ${receiverClassDescriptor.getName()}") {
|
LexicalScopeKind.SYNTHETIC) {
|
||||||
receiverClassDescriptor.typeConstructor.parameters.forEach { addClassifierDescriptor(it) }
|
receiverClassDescriptor.typeConstructor.parameters.forEach { addClassifierDescriptor(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user