LazyClassContext introduced
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.resolve.lazy
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||||
|
|
||||||
|
public trait DeclarationScopeProvider {
|
||||||
|
fun getResolutionScopeForDeclaration(elementOfDeclaration: PsiElement): JetScope
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.resolve.lazy
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||||
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorResolver
|
||||||
|
import org.jetbrains.kotlin.resolve.TypeResolver
|
||||||
|
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||||
|
import org.jetbrains.kotlin.resolve.AnnotationResolver
|
||||||
|
|
||||||
|
public trait LazyClassContext {
|
||||||
|
val scopeProvider: DeclarationScopeProvider
|
||||||
|
|
||||||
|
val storageManager: StorageManager
|
||||||
|
val trace: BindingTrace
|
||||||
|
val moduleDescriptor: ModuleDescriptor
|
||||||
|
val descriptorResolver: DescriptorResolver
|
||||||
|
val typeResolver: TypeResolver
|
||||||
|
val declarationProviderFactory: DeclarationProviderFactory
|
||||||
|
val annotationResolver: AnnotationResolver
|
||||||
|
}
|
||||||
@@ -48,7 +48,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ResolveSession implements KotlinCodeAnalyzer {
|
public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
|
||||||
private final LazyResolveStorageManager storageManager;
|
private final LazyResolveStorageManager storageManager;
|
||||||
private final ExceptionTracker exceptionTracker;
|
private final ExceptionTracker exceptionTracker;
|
||||||
|
|
||||||
@@ -221,13 +221,12 @@ public class ResolveSession implements KotlinCodeAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
//@Override
|
@Override
|
||||||
public LazyResolveStorageManager getStorageManager() {
|
public LazyResolveStorageManager getStorageManager() {
|
||||||
return storageManager;
|
return storageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
//@Override
|
|
||||||
public ExceptionTracker getExceptionTracker() {
|
public ExceptionTracker getExceptionTracker() {
|
||||||
return exceptionTracker;
|
return exceptionTracker;
|
||||||
}
|
}
|
||||||
@@ -297,7 +296,6 @@ public class ResolveSession implements KotlinCodeAnalyzer {
|
|||||||
return (ClassDescriptor) classifier;
|
return (ClassDescriptor) classifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ScriptDescriptor getScriptDescriptor(@NotNull JetScript script) {
|
public ScriptDescriptor getScriptDescriptor(@NotNull JetScript script) {
|
||||||
return scriptDescriptors.invoke(script);
|
return scriptDescriptors.invoke(script);
|
||||||
@@ -334,11 +332,13 @@ public class ResolveSession implements KotlinCodeAnalyzer {
|
|||||||
return trace.getBindingContext();
|
return trace.getBindingContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public BindingTrace getTrace() {
|
public BindingTrace getTrace() {
|
||||||
return trace;
|
return trace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public DeclarationProviderFactory getDeclarationProviderFactory() {
|
public DeclarationProviderFactory getDeclarationProviderFactory() {
|
||||||
return declarationProviderFactory;
|
return declarationProviderFactory;
|
||||||
@@ -507,16 +507,19 @@ public class ResolveSession implements KotlinCodeAnalyzer {
|
|||||||
return jetImportFactory;
|
return jetImportFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public AnnotationResolver getAnnotationResolver() {
|
public AnnotationResolver getAnnotationResolver() {
|
||||||
return annotationResolve;
|
return annotationResolve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public DescriptorResolver getDescriptorResolver() {
|
public DescriptorResolver getDescriptorResolver() {
|
||||||
return descriptorResolver;
|
return descriptorResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public TypeResolver getTypeResolver() {
|
public TypeResolver getTypeResolver() {
|
||||||
return typeResolver;
|
return typeResolver;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ScopeProvider {
|
public class ScopeProvider implements DeclarationScopeProvider {
|
||||||
public static class AdditionalFileScopeProvider {
|
public static class AdditionalFileScopeProvider {
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JetScope> scopes(@NotNull JetFile file) {
|
public List<JetScope> scopes(@NotNull JetFile file) {
|
||||||
@@ -101,6 +101,7 @@ public class ScopeProvider {
|
|||||||
"LazyFileScope for file " + file.getName());
|
"LazyFileScope for file " + file.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetScope getResolutionScopeForDeclaration(@NotNull PsiElement elementOfDeclaration) {
|
public JetScope getResolutionScopeForDeclaration(@NotNull PsiElement elementOfDeclaration) {
|
||||||
JetDeclaration jetDeclaration = JetStubbedPsiUtil.getPsiOrStubParent(elementOfDeclaration, JetDeclaration.class, false);
|
JetDeclaration jetDeclaration = JetStubbedPsiUtil.getPsiOrStubParent(elementOfDeclaration, JetDeclaration.class, false);
|
||||||
|
|||||||
+8
-8
@@ -22,8 +22,6 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.resolve.AnnotationResolver
|
import org.jetbrains.kotlin.resolve.AnnotationResolver
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||||
import org.jetbrains.kotlin.resolve.ScriptNameUtil
|
import org.jetbrains.kotlin.resolve.ScriptNameUtil
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
|
||||||
import org.jetbrains.kotlin.resolve.lazy.data.JetScriptInfo
|
import org.jetbrains.kotlin.resolve.lazy.data.JetScriptInfo
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProvider
|
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProvider
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -35,14 +33,16 @@ import java.util.*
|
|||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
|
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||||
|
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext
|
||||||
|
|
||||||
public abstract class AbstractLazyMemberScope<D : DeclarationDescriptor, DP : DeclarationProvider> protected(
|
public abstract class AbstractLazyMemberScope<D : DeclarationDescriptor, DP : DeclarationProvider> protected(
|
||||||
protected val resolveSession: ResolveSession,
|
protected val c: LazyClassContext,
|
||||||
protected val declarationProvider: DP,
|
protected val declarationProvider: DP,
|
||||||
protected val thisDescriptor: D,
|
protected val thisDescriptor: D,
|
||||||
protected val trace: BindingTrace) : JetScope {
|
protected val trace: BindingTrace) : JetScope {
|
||||||
|
|
||||||
protected val storageManager: StorageManager = resolveSession.getStorageManager()
|
protected val storageManager: StorageManager = c.storageManager
|
||||||
private val classDescriptors: MemoizedFunctionToNotNull<Name, List<ClassDescriptor>> = storageManager.createMemoizedFunction { resolveClassDescriptor(it) }
|
private val classDescriptors: MemoizedFunctionToNotNull<Name, List<ClassDescriptor>> = storageManager.createMemoizedFunction { resolveClassDescriptor(it) }
|
||||||
private val functionDescriptors: MemoizedFunctionToNotNull<Name, Collection<FunctionDescriptor>> = storageManager.createMemoizedFunction { doGetFunctions(it) }
|
private val functionDescriptors: MemoizedFunctionToNotNull<Name, Collection<FunctionDescriptor>> = storageManager.createMemoizedFunction { doGetFunctions(it) }
|
||||||
private val propertyDescriptors: MemoizedFunctionToNotNull<Name, Collection<VariableDescriptor>> = storageManager.createMemoizedFunction { doGetProperties(it) }
|
private val propertyDescriptors: MemoizedFunctionToNotNull<Name, Collection<VariableDescriptor>> = storageManager.createMemoizedFunction { doGetProperties(it) }
|
||||||
@@ -51,9 +51,9 @@ public abstract class AbstractLazyMemberScope<D : DeclarationDescriptor, DP : De
|
|||||||
return declarationProvider.getClassOrObjectDeclarations(name).map {
|
return declarationProvider.getClassOrObjectDeclarations(name).map {
|
||||||
// SCRIPT: Creating a script class
|
// SCRIPT: Creating a script class
|
||||||
if (it is JetScriptInfo)
|
if (it is JetScriptInfo)
|
||||||
LazyScriptClassDescriptor(resolveSession, thisDescriptor, name, it)
|
LazyScriptClassDescriptor(c as ResolveSession, thisDescriptor, name, it)
|
||||||
else
|
else
|
||||||
LazyClassDescriptor(resolveSession, thisDescriptor, name, it)
|
LazyClassDescriptor(c, thisDescriptor, name, it)
|
||||||
}.toReadOnlyList()
|
}.toReadOnlyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public abstract class AbstractLazyMemberScope<D : DeclarationDescriptor, DP : De
|
|||||||
val declarations = declarationProvider.getFunctionDeclarations(name)
|
val declarations = declarationProvider.getFunctionDeclarations(name)
|
||||||
for (functionDeclaration in declarations) {
|
for (functionDeclaration in declarations) {
|
||||||
val resolutionScope = getScopeForMemberDeclarationResolution(functionDeclaration)
|
val resolutionScope = getScopeForMemberDeclarationResolution(functionDeclaration)
|
||||||
result.add(resolveSession.getDescriptorResolver().resolveFunctionDescriptorWithAnnotationArguments(
|
result.add(c.descriptorResolver.resolveFunctionDescriptorWithAnnotationArguments(
|
||||||
thisDescriptor,
|
thisDescriptor,
|
||||||
resolutionScope,
|
resolutionScope,
|
||||||
functionDeclaration,
|
functionDeclaration,
|
||||||
@@ -96,7 +96,7 @@ public abstract class AbstractLazyMemberScope<D : DeclarationDescriptor, DP : De
|
|||||||
val declarations = declarationProvider.getPropertyDeclarations(name)
|
val declarations = declarationProvider.getPropertyDeclarations(name)
|
||||||
for (propertyDeclaration in declarations) {
|
for (propertyDeclaration in declarations) {
|
||||||
val resolutionScope = getScopeForMemberDeclarationResolution(propertyDeclaration)
|
val resolutionScope = getScopeForMemberDeclarationResolution(propertyDeclaration)
|
||||||
val propertyDescriptor = resolveSession.getDescriptorResolver().resolvePropertyDescriptor(
|
val propertyDescriptor = c.descriptorResolver.resolvePropertyDescriptor(
|
||||||
thisDescriptor,
|
thisDescriptor,
|
||||||
resolutionScope,
|
resolutionScope,
|
||||||
propertyDeclaration,
|
propertyDeclaration,
|
||||||
|
|||||||
+33
-40
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import kotlin.Function0;
|
import kotlin.Function0;
|
||||||
import kotlin.Function1;
|
import kotlin.Function1;
|
||||||
import kotlin.KotlinPackage;
|
import kotlin.KotlinPackage;
|
||||||
@@ -28,6 +27,7 @@ import org.jetbrains.annotations.Mutable;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.ReadOnly;
|
import org.jetbrains.annotations.ReadOnly;
|
||||||
|
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext;
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
@@ -40,8 +40,6 @@ import org.jetbrains.kotlin.resolve.ModifiersChecker;
|
|||||||
import org.jetbrains.kotlin.resolve.TypeHierarchyResolver;
|
import org.jetbrains.kotlin.resolve.TypeHierarchyResolver;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.LazyEntity;
|
import org.jetbrains.kotlin.resolve.lazy.LazyEntity;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ScopeProvider;
|
|
||||||
import org.jetbrains.kotlin.resolve.lazy.data.JetClassInfoUtil;
|
import org.jetbrains.kotlin.resolve.lazy.data.JetClassInfoUtil;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.data.JetClassLikeInfo;
|
import org.jetbrains.kotlin.resolve.lazy.data.JetClassLikeInfo;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.data.SyntheticClassObjectInfo;
|
import org.jetbrains.kotlin.resolve.lazy.data.SyntheticClassObjectInfo;
|
||||||
@@ -73,7 +71,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
return TypeUtils.getClassDescriptor(type) != null;
|
return TypeUtils.getClassDescriptor(type) != null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final ResolveSession resolveSession;
|
private final LazyClassContext c;
|
||||||
|
|
||||||
private final JetClassLikeInfo originalClassInfo;
|
private final JetClassLikeInfo originalClassInfo;
|
||||||
private final ClassMemberDeclarationProvider declarationProvider;
|
private final ClassMemberDeclarationProvider declarationProvider;
|
||||||
@@ -99,25 +97,25 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
private final NullableLazyValue<Void> forceResolveAllContents;
|
private final NullableLazyValue<Void> forceResolveAllContents;
|
||||||
|
|
||||||
public LazyClassDescriptor(
|
public LazyClassDescriptor(
|
||||||
@NotNull final ResolveSession resolveSession,
|
@NotNull LazyClassContext c,
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@NotNull Name name,
|
@NotNull Name name,
|
||||||
@NotNull JetClassLikeInfo classLikeInfo
|
@NotNull JetClassLikeInfo classLikeInfo
|
||||||
) {
|
) {
|
||||||
super(resolveSession.getStorageManager(), containingDeclaration, name,
|
super(c.getStorageManager(), containingDeclaration, name,
|
||||||
toSourceElement(classLikeInfo.getCorrespondingClassOrObject())
|
toSourceElement(classLikeInfo.getCorrespondingClassOrObject())
|
||||||
);
|
);
|
||||||
this.resolveSession = resolveSession;
|
this.c = c;
|
||||||
|
|
||||||
if (classLikeInfo.getCorrespondingClassOrObject() != null) {
|
if (classLikeInfo.getCorrespondingClassOrObject() != null) {
|
||||||
this.resolveSession.getTrace().record(BindingContext.CLASS, classLikeInfo.getCorrespondingClassOrObject(), this);
|
this.c.getTrace().record(BindingContext.CLASS, classLikeInfo.getCorrespondingClassOrObject(), this);
|
||||||
}
|
}
|
||||||
this.resolveSession.getTrace().record(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, DescriptorUtils.getFqName(this), this);
|
this.c.getTrace().record(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, DescriptorUtils.getFqName(this), this);
|
||||||
|
|
||||||
this.originalClassInfo = classLikeInfo;
|
this.originalClassInfo = classLikeInfo;
|
||||||
this.declarationProvider = resolveSession.getDeclarationProviderFactory().getClassMemberDeclarationProvider(classLikeInfo);
|
this.declarationProvider = c.getDeclarationProviderFactory().getClassMemberDeclarationProvider(classLikeInfo);
|
||||||
|
|
||||||
this.unsubstitutedMemberScope = createMemberScope(resolveSession, this.declarationProvider);
|
this.unsubstitutedMemberScope = createMemberScope(c, this.declarationProvider);
|
||||||
|
|
||||||
this.typeConstructor = new LazyClassTypeConstructor();
|
this.typeConstructor = new LazyClassTypeConstructor();
|
||||||
|
|
||||||
@@ -136,21 +134,20 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
: resolveVisibilityFromModifiers(modifierList, getDefaultClassVisibility(this));
|
: resolveVisibilityFromModifiers(modifierList, getDefaultClassVisibility(this));
|
||||||
this.isInner = isInnerClass(modifierList) && !ModifiersChecker.isIllegalInner(this);
|
this.isInner = isInnerClass(modifierList) && !ModifiersChecker.isIllegalInner(this);
|
||||||
|
|
||||||
StorageManager storageManager = resolveSession.getStorageManager();
|
StorageManager storageManager = c.getStorageManager();
|
||||||
|
|
||||||
|
|
||||||
if (modifierList != null) {
|
if (modifierList != null) {
|
||||||
this.annotations = new LazyAnnotations(
|
this.annotations = new LazyAnnotations(
|
||||||
new LazyAnnotationsContext(
|
new LazyAnnotationsContext(
|
||||||
resolveSession.getAnnotationResolver(),
|
c.getAnnotationResolver(),
|
||||||
storageManager,
|
storageManager,
|
||||||
resolveSession.getTrace()
|
c.getTrace()
|
||||||
) {
|
) {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public JetScope getScope() {
|
public JetScope getScope() {
|
||||||
JetClassLikeInfo ownerInfo = declarationProvider.getOwnerInfo();
|
return getOuterScope();
|
||||||
return resolveSession.getScopeProvider().getResolutionScopeForDeclaration(ownerInfo.getScopeAnchor());
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifierList.getAnnotationEntries()
|
modifierList.getAnnotationEntries()
|
||||||
@@ -168,9 +165,9 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
else {
|
else {
|
||||||
this.danglingAnnotations = new LazyAnnotations(
|
this.danglingAnnotations = new LazyAnnotations(
|
||||||
new LazyAnnotationsContext(
|
new LazyAnnotationsContext(
|
||||||
resolveSession.getAnnotationResolver(),
|
c.getAnnotationResolver(),
|
||||||
storageManager,
|
storageManager,
|
||||||
resolveSession.getTrace()
|
c.getTrace()
|
||||||
) {
|
) {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
@@ -224,10 +221,10 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
// NOTE: Called from constructor!
|
// NOTE: Called from constructor!
|
||||||
@NotNull
|
@NotNull
|
||||||
protected LazyClassMemberScope createMemberScope(
|
protected LazyClassMemberScope createMemberScope(
|
||||||
@NotNull ResolveSession resolveSession,
|
@NotNull LazyClassContext c,
|
||||||
@NotNull ClassMemberDeclarationProvider declarationProvider
|
@NotNull ClassMemberDeclarationProvider declarationProvider
|
||||||
) {
|
) {
|
||||||
return new LazyClassMemberScope(resolveSession, declarationProvider, this, resolveSession.getTrace());
|
return new LazyClassMemberScope(c, declarationProvider, this, c.getTrace());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -250,11 +247,12 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
}
|
}
|
||||||
scope.changeLockLevel(WritableScope.LockLevel.READING);
|
scope.changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
|
|
||||||
PsiElement scopeAnchor = declarationProvider.getOwnerInfo().getScopeAnchor();
|
return new ChainedScope(this, "ScopeForClassHeaderResolution: " + getName(), scope, getOuterScope());
|
||||||
|
}
|
||||||
|
|
||||||
return new ChainedScope(this, "ScopeForClassHeaderResolution: " + getName(),
|
@NotNull
|
||||||
scope,
|
protected JetScope getOuterScope() {
|
||||||
getScopeProvider().getResolutionScopeForDeclaration(scopeAnchor));
|
return c.getScopeProvider().getResolutionScopeForDeclaration(declarationProvider.getOwnerInfo().getScopeAnchor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -382,7 +380,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
private LazyClassDescriptor computeClassObjectDescriptor(@Nullable JetClassObject classObject) {
|
private LazyClassDescriptor computeClassObjectDescriptor(@Nullable JetClassObject classObject) {
|
||||||
JetClassLikeInfo classObjectInfo = getClassObjectInfo(classObject);
|
JetClassLikeInfo classObjectInfo = getClassObjectInfo(classObject);
|
||||||
if (classObjectInfo != null) {
|
if (classObjectInfo != null) {
|
||||||
return new LazyClassDescriptor(resolveSession, this, getClassObjectName(getName()), classObjectInfo);
|
return new LazyClassDescriptor(c, this, getClassObjectName(getName()), classObjectInfo);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -391,7 +389,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
private JetClassLikeInfo getClassObjectInfo(@Nullable JetClassObject classObject) {
|
private JetClassLikeInfo getClassObjectInfo(@Nullable JetClassObject classObject) {
|
||||||
if (classObject != null) {
|
if (classObject != null) {
|
||||||
if (!isClassObjectAllowed()) {
|
if (!isClassObjectAllowed()) {
|
||||||
resolveSession.getTrace().report(CLASS_OBJECT_NOT_ALLOWED.on(classObject));
|
c.getTrace().report(CLASS_OBJECT_NOT_ALLOWED.on(classObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
return JetClassInfoUtil.createClassLikeInfo(classObject.getObjectDeclaration());
|
return JetClassInfoUtil.createClassLikeInfo(classObject.getObjectDeclaration());
|
||||||
@@ -524,7 +522,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class LazyClassTypeConstructor extends AbstractClassTypeConstructor implements LazyEntity {
|
private class LazyClassTypeConstructor extends AbstractClassTypeConstructor implements LazyEntity {
|
||||||
private final NotNullLazyValue<Supertypes> supertypes = resolveSession.getStorageManager().createLazyValueWithPostCompute(
|
private final NotNullLazyValue<Supertypes> supertypes = c.getStorageManager().createLazyValueWithPostCompute(
|
||||||
new Function0<Supertypes>() {
|
new Function0<Supertypes>() {
|
||||||
@Override
|
@Override
|
||||||
public Supertypes invoke() {
|
public Supertypes invoke() {
|
||||||
@@ -542,12 +540,12 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
|
|
||||||
JetClassOrObject classOrObject = info.getCorrespondingClassOrObject();
|
JetClassOrObject classOrObject = info.getCorrespondingClassOrObject();
|
||||||
if (classOrObject == null) {
|
if (classOrObject == null) {
|
||||||
return new Supertypes(Collections.singleton(resolveSession.getModuleDescriptor().getBuiltIns().getAnyType()));
|
return new Supertypes(Collections.singleton(c.getModuleDescriptor().getBuiltIns().getAnyType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<JetType> allSupertypes = resolveSession.getDescriptorResolver()
|
List<JetType> allSupertypes = c.getDescriptorResolver()
|
||||||
.resolveSupertypes(getScopeForClassHeaderResolution(), LazyClassDescriptor.this, classOrObject,
|
.resolveSupertypes(getScopeForClassHeaderResolution(), LazyClassDescriptor.this, classOrObject,
|
||||||
resolveSession.getTrace());
|
c.getTrace());
|
||||||
|
|
||||||
return new Supertypes(Lists.newArrayList(Collections2.filter(allSupertypes, VALID_SUPERTYPE)));
|
return new Supertypes(Lists.newArrayList(Collections2.filter(allSupertypes, VALID_SUPERTYPE)));
|
||||||
}
|
}
|
||||||
@@ -567,7 +565,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
private final NotNullLazyValue<List<TypeParameterDescriptor>> parameters = resolveSession.getStorageManager().createLazyValue(new Function0<List<TypeParameterDescriptor>>() {
|
private final NotNullLazyValue<List<TypeParameterDescriptor>> parameters = c.getStorageManager().createLazyValue(new Function0<List<TypeParameterDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<TypeParameterDescriptor> invoke() {
|
public List<TypeParameterDescriptor> invoke() {
|
||||||
JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo();
|
JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo();
|
||||||
@@ -575,13 +573,13 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
if (typeParameterList == null) return Collections.emptyList();
|
if (typeParameterList == null) return Collections.emptyList();
|
||||||
|
|
||||||
if (classInfo.getClassKind() == ClassKind.ENUM_CLASS) {
|
if (classInfo.getClassKind() == ClassKind.ENUM_CLASS) {
|
||||||
resolveSession.getTrace().report(TYPE_PARAMETERS_IN_ENUM.on(typeParameterList));
|
c.getTrace().report(TYPE_PARAMETERS_IN_ENUM.on(typeParameterList));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<JetTypeParameter> typeParameters = typeParameterList.getParameters();
|
List<JetTypeParameter> typeParameters = typeParameterList.getParameters();
|
||||||
List<TypeParameterDescriptor> parameters = new ArrayList<TypeParameterDescriptor>(typeParameters.size());
|
List<TypeParameterDescriptor> parameters = new ArrayList<TypeParameterDescriptor>(typeParameters.size());
|
||||||
for (int i = 0; i < typeParameters.size(); i++) {
|
for (int i = 0; i < typeParameters.size(); i++) {
|
||||||
parameters.add(new LazyTypeParameterDescriptor(resolveSession, LazyClassDescriptor.this, typeParameters.get(i), i));
|
parameters.add(new LazyTypeParameterDescriptor(c, LazyClassDescriptor.this, typeParameters.get(i), i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return parameters;
|
return parameters;
|
||||||
@@ -589,7 +587,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
});
|
});
|
||||||
|
|
||||||
private final NullableLazyValue<Void> forceResolveAllContents =
|
private final NullableLazyValue<Void> forceResolveAllContents =
|
||||||
resolveSession.getStorageManager().createRecursionTolerantNullableLazyValue(new Function0<Void>() {
|
c.getStorageManager().createRecursionTolerantNullableLazyValue(new Function0<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void invoke() {
|
public Void invoke() {
|
||||||
doForceResolveAllContents();
|
doForceResolveAllContents();
|
||||||
@@ -619,7 +617,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
ClassifierDescriptor supertypeDescriptor = supertype.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor supertypeDescriptor = supertype.getConstructor().getDeclarationDescriptor();
|
||||||
if (supertypeDescriptor instanceof ClassDescriptor) {
|
if (supertypeDescriptor instanceof ClassDescriptor) {
|
||||||
ClassDescriptor superclass = (ClassDescriptor) supertypeDescriptor;
|
ClassDescriptor superclass = (ClassDescriptor) supertypeDescriptor;
|
||||||
TypeHierarchyResolver.reportCyclicInheritanceHierarchyError(resolveSession.getTrace(), LazyClassDescriptor.this,
|
TypeHierarchyResolver.reportCyclicInheritanceHierarchyError(c.getTrace(), LazyClassDescriptor.this,
|
||||||
superclass);
|
superclass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -695,9 +693,4 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
ForceResolveUtil.forceResolveAllContents(getParameters());
|
ForceResolveUtil.forceResolveAllContents(getParameters());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private ScopeProvider getScopeProvider() {
|
|
||||||
return resolveSession.getScopeProvider();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-11
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.diagnostics.Errors
|
|||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.resolve.*
|
import org.jetbrains.kotlin.resolve.*
|
||||||
import org.jetbrains.kotlin.resolve.dataClassUtils.*
|
import org.jetbrains.kotlin.resolve.dataClassUtils.*
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProvider
|
import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProvider
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||||
@@ -40,12 +39,15 @@ import org.jetbrains.kotlin.resolve.DelegationResolver.generateDelegatedMembers
|
|||||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker
|
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker
|
||||||
|
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.isObjectLiteral
|
||||||
|
|
||||||
public open class LazyClassMemberScope(resolveSession: ResolveSession,
|
public open class LazyClassMemberScope(
|
||||||
declarationProvider: ClassMemberDeclarationProvider,
|
c: LazyClassContext,
|
||||||
thisClass: LazyClassDescriptor,
|
declarationProvider: ClassMemberDeclarationProvider,
|
||||||
trace: BindingTrace)
|
thisClass: LazyClassDescriptor,
|
||||||
: AbstractLazyMemberScope<LazyClassDescriptor, ClassMemberDeclarationProvider>(resolveSession, declarationProvider, thisClass, trace) {
|
trace: BindingTrace
|
||||||
|
) : AbstractLazyMemberScope<LazyClassDescriptor, ClassMemberDeclarationProvider>(c, declarationProvider, thisClass, trace) {
|
||||||
|
|
||||||
private val descriptorsFromDeclaredElements = storageManager.createLazyValue {
|
private val descriptorsFromDeclaredElements = storageManager.createLazyValue {
|
||||||
computeDescriptorsFromDeclaredElements(DescriptorKindFilter.ALL, JetScope.ALL_NAME_FILTER)
|
computeDescriptorsFromDeclaredElements(DescriptorKindFilter.ALL, JetScope.ALL_NAME_FILTER)
|
||||||
@@ -86,7 +88,7 @@ public open class LazyClassMemberScope(resolveSession: ResolveSession,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val primaryConstructor: NullableLazyValue<ConstructorDescriptor>
|
private val primaryConstructor: NullableLazyValue<ConstructorDescriptor>
|
||||||
= resolveSession.getStorageManager().createNullableLazyValue { resolvePrimaryConstructor() }
|
= c.storageManager.createNullableLazyValue { resolvePrimaryConstructor() }
|
||||||
|
|
||||||
override fun getScopeForMemberDeclarationResolution(declaration: JetDeclaration): JetScope {
|
override fun getScopeForMemberDeclarationResolution(declaration: JetDeclaration): JetScope {
|
||||||
if (declaration is JetProperty) {
|
if (declaration is JetProperty) {
|
||||||
@@ -219,7 +221,7 @@ public open class LazyClassMemberScope(resolveSession: ResolveSession,
|
|||||||
|
|
||||||
val parameter = primaryConstructorParameters.get(valueParameterDescriptor.getIndex())
|
val parameter = primaryConstructorParameters.get(valueParameterDescriptor.getIndex())
|
||||||
if (parameter.hasValOrVarNode()) {
|
if (parameter.hasValOrVarNode()) {
|
||||||
val propertyDescriptor = resolveSession.getDescriptorResolver().resolvePrimaryConstructorParameterToAProperty(
|
val propertyDescriptor = c.descriptorResolver.resolvePrimaryConstructorParameterToAProperty(
|
||||||
thisDescriptor, valueParameterDescriptor, thisDescriptor.getScopeForClassHeaderResolution(), parameter, trace)
|
thisDescriptor, valueParameterDescriptor, thisDescriptor.getScopeForClassHeaderResolution(), parameter, trace)
|
||||||
result.add(propertyDescriptor)
|
result.add(propertyDescriptor)
|
||||||
}
|
}
|
||||||
@@ -231,7 +233,7 @@ public open class LazyClassMemberScope(resolveSession: ResolveSession,
|
|||||||
?: return setOf() // Enum class objects do not have delegated members
|
?: return setOf() // Enum class objects do not have delegated members
|
||||||
|
|
||||||
val lazyTypeResolver = DelegationResolver.TypeResolver { reference ->
|
val lazyTypeResolver = DelegationResolver.TypeResolver { reference ->
|
||||||
resolveSession.getTypeResolver().resolveType(thisDescriptor.getScopeForClassHeaderResolution(), reference, trace, false)
|
c.typeResolver.resolveType(thisDescriptor.getScopeForClassHeaderResolution(), reference, trace, false)
|
||||||
}
|
}
|
||||||
val lazyMemberExtractor = DelegationResolver.MemberExtractor<T> {
|
val lazyMemberExtractor = DelegationResolver.MemberExtractor<T> {
|
||||||
type -> extractor.extract(type, name)
|
type -> extractor.extract(type, name)
|
||||||
@@ -274,7 +276,7 @@ public open class LazyClassMemberScope(resolveSession: ResolveSession,
|
|||||||
if (!thisDescriptor.getKind().isSingleton()) {
|
if (!thisDescriptor.getKind().isSingleton()) {
|
||||||
assert(classOrObject is JetClass) { "No JetClass for $thisDescriptor" }
|
assert(classOrObject is JetClass) { "No JetClass for $thisDescriptor" }
|
||||||
classOrObject as JetClass
|
classOrObject as JetClass
|
||||||
val constructor = resolveSession.getDescriptorResolver().resolvePrimaryConstructorDescriptor(
|
val constructor = c.descriptorResolver.resolvePrimaryConstructorDescriptor(
|
||||||
thisDescriptor.getScopeForClassHeaderResolution(), thisDescriptor, classOrObject, trace)
|
thisDescriptor.getScopeForClassHeaderResolution(), thisDescriptor, classOrObject, trace)
|
||||||
assert(constructor != null) { "No constructor created for $thisDescriptor" }
|
assert(constructor != null) { "No constructor created for $thisDescriptor" }
|
||||||
setDeferredReturnType(constructor)
|
setDeferredReturnType(constructor)
|
||||||
@@ -290,7 +292,7 @@ public open class LazyClassMemberScope(resolveSession: ResolveSession,
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected fun setDeferredReturnType(descriptor: ConstructorDescriptorImpl) {
|
protected fun setDeferredReturnType(descriptor: ConstructorDescriptorImpl) {
|
||||||
descriptor.setReturnType(DeferredType.create(resolveSession.getStorageManager(), trace, { thisDescriptor.getDefaultType() }))
|
descriptor.setReturnType(DeferredType.create(c.storageManager, trace, { thisDescriptor.getDefaultType() }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not add details here, they may compromise the laziness during debugging
|
// Do not add details here, they may compromise the laziness during debugging
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
|
|
||||||
public class LazyPackageMemberScope(
|
public class LazyPackageMemberScope(
|
||||||
resolveSession: ResolveSession,
|
private val resolveSession: ResolveSession,
|
||||||
declarationProvider: PackageMemberDeclarationProvider,
|
declarationProvider: PackageMemberDeclarationProvider,
|
||||||
thisPackage: PackageFragmentDescriptor)
|
thisPackage: PackageFragmentDescriptor)
|
||||||
: AbstractLazyMemberScope<PackageFragmentDescriptor, PackageMemberDeclarationProvider>(resolveSession, declarationProvider, thisPackage, resolveSession.getTrace()) {
|
: AbstractLazyMemberScope<PackageFragmentDescriptor, PackageMemberDeclarationProvider>(resolveSession, declarationProvider, thisPackage, resolveSession.getTrace()) {
|
||||||
|
|||||||
+6
-3
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.resolve.lazy.descriptors;
|
package org.jetbrains.kotlin.resolve.lazy.descriptors;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities;
|
import org.jetbrains.kotlin.descriptors.Visibilities;
|
||||||
import org.jetbrains.kotlin.descriptors.Visibility;
|
import org.jetbrains.kotlin.descriptors.Visibility;
|
||||||
@@ -39,13 +40,15 @@ public class LazyScriptClassDescriptor extends LazyClassDescriptor {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected LazyScriptClassMemberScope createMemberScope(
|
protected LazyScriptClassMemberScope createMemberScope(
|
||||||
@NotNull ResolveSession resolveSession, @NotNull ClassMemberDeclarationProvider declarationProvider
|
@NotNull LazyClassContext c,
|
||||||
|
@NotNull ClassMemberDeclarationProvider declarationProvider
|
||||||
) {
|
) {
|
||||||
return new LazyScriptClassMemberScope(
|
return new LazyScriptClassMemberScope(
|
||||||
resolveSession,
|
// Must be a ResolveSession for scripts
|
||||||
|
(ResolveSession) c,
|
||||||
declarationProvider,
|
declarationProvider,
|
||||||
this,
|
this,
|
||||||
TemporaryBindingTrace.create(resolveSession.getTrace(), "A trace for script class, needed to avoid rewrites on members")
|
TemporaryBindingTrace.create(c.getTrace(), "A trace for script class, needed to avoid rewrites on members")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-15
@@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.utils.toReadOnlyList
|
|||||||
|
|
||||||
// SCRIPT: Members of a script class
|
// SCRIPT: Members of a script class
|
||||||
public class LazyScriptClassMemberScope protected(
|
public class LazyScriptClassMemberScope protected(
|
||||||
resolveSession: ResolveSession,
|
private val resolveSession: ResolveSession,
|
||||||
declarationProvider: ClassMemberDeclarationProvider,
|
declarationProvider: ClassMemberDeclarationProvider,
|
||||||
thisClass: LazyClassDescriptor,
|
thisClass: LazyClassDescriptor,
|
||||||
trace: BindingTrace)
|
trace: BindingTrace)
|
||||||
|
|||||||
+11
-11
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors;
|
|||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor;
|
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor;
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
@@ -25,7 +26,6 @@ import org.jetbrains.kotlin.resolve.BindingContext;
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorResolver;
|
import org.jetbrains.kotlin.resolve.DescriptorResolver;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.LazyEntity;
|
import org.jetbrains.kotlin.resolve.lazy.LazyEntity;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -33,17 +33,17 @@ import java.util.Set;
|
|||||||
import static org.jetbrains.kotlin.resolve.source.SourcePackage.toSourceElement;
|
import static org.jetbrains.kotlin.resolve.source.SourcePackage.toSourceElement;
|
||||||
|
|
||||||
public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescriptor implements LazyEntity {
|
public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescriptor implements LazyEntity {
|
||||||
private final ResolveSession resolveSession;
|
private final LazyClassContext c;
|
||||||
|
|
||||||
private final JetTypeParameter jetTypeParameter;
|
private final JetTypeParameter jetTypeParameter;
|
||||||
|
|
||||||
public LazyTypeParameterDescriptor(
|
public LazyTypeParameterDescriptor(
|
||||||
@NotNull ResolveSession resolveSession,
|
@NotNull LazyClassContext c,
|
||||||
@NotNull LazyClassDescriptor containingDeclaration,
|
@NotNull LazyClassDescriptor containingDeclaration,
|
||||||
@NotNull JetTypeParameter jetTypeParameter,
|
@NotNull JetTypeParameter jetTypeParameter,
|
||||||
int index) {
|
int index) {
|
||||||
super(
|
super(
|
||||||
resolveSession.getStorageManager(),
|
c.getStorageManager(),
|
||||||
containingDeclaration,
|
containingDeclaration,
|
||||||
jetTypeParameter.getNameAsSafeName(),
|
jetTypeParameter.getNameAsSafeName(),
|
||||||
jetTypeParameter.getVariance(),
|
jetTypeParameter.getVariance(),
|
||||||
@@ -51,10 +51,10 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
|||||||
index,
|
index,
|
||||||
toSourceElement(jetTypeParameter)
|
toSourceElement(jetTypeParameter)
|
||||||
);
|
);
|
||||||
this.resolveSession = resolveSession;
|
this.c = c;
|
||||||
this.jetTypeParameter = jetTypeParameter;
|
this.jetTypeParameter = jetTypeParameter;
|
||||||
|
|
||||||
this.resolveSession.getTrace().record(BindingContext.TYPE_PARAMETER, jetTypeParameter, this);
|
this.c.getTrace().record(BindingContext.TYPE_PARAMETER, jetTypeParameter, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -72,7 +72,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
|||||||
resolveUpperBoundsFromWhereClause(upperBounds);
|
resolveUpperBoundsFromWhereClause(upperBounds);
|
||||||
|
|
||||||
if (upperBounds.isEmpty()) {
|
if (upperBounds.isEmpty()) {
|
||||||
upperBounds.add(resolveSession.getModuleDescriptor().getBuiltIns().getDefaultBound());
|
upperBounds.add(c.getModuleDescriptor().getBuiltIns().getDefaultBound());
|
||||||
}
|
}
|
||||||
|
|
||||||
return upperBounds;
|
return upperBounds;
|
||||||
@@ -83,12 +83,12 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
|||||||
if (classOrObject instanceof JetClass) {
|
if (classOrObject instanceof JetClass) {
|
||||||
JetClass jetClass = (JetClass) classOrObject;
|
JetClass jetClass = (JetClass) classOrObject;
|
||||||
for (JetTypeConstraint jetTypeConstraint : jetClass.getTypeConstraints()) {
|
for (JetTypeConstraint jetTypeConstraint : jetClass.getTypeConstraints()) {
|
||||||
DescriptorResolver.reportUnsupportedClassObjectConstraint(resolveSession.getTrace(), jetTypeConstraint);
|
DescriptorResolver.reportUnsupportedClassObjectConstraint(c.getTrace(), jetTypeConstraint);
|
||||||
|
|
||||||
JetSimpleNameExpression constrainedParameterName = jetTypeConstraint.getSubjectTypeParameterName();
|
JetSimpleNameExpression constrainedParameterName = jetTypeConstraint.getSubjectTypeParameterName();
|
||||||
if (constrainedParameterName != null) {
|
if (constrainedParameterName != null) {
|
||||||
if (getName().equals(constrainedParameterName.getReferencedNameAsName())) {
|
if (getName().equals(constrainedParameterName.getReferencedNameAsName())) {
|
||||||
resolveSession.getTrace().record(BindingContext.REFERENCE_TARGET, constrainedParameterName, this);
|
c.getTrace().record(BindingContext.REFERENCE_TARGET, constrainedParameterName, this);
|
||||||
|
|
||||||
JetTypeReference boundTypeReference = jetTypeConstraint.getBoundTypeReference();
|
JetTypeReference boundTypeReference = jetTypeConstraint.getBoundTypeReference();
|
||||||
if (boundTypeReference != null) {
|
if (boundTypeReference != null) {
|
||||||
@@ -105,9 +105,9 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JetType resolveBoundType(@NotNull JetTypeReference boundTypeReference) {
|
private JetType resolveBoundType(@NotNull JetTypeReference boundTypeReference) {
|
||||||
return resolveSession.getTypeResolver()
|
return c.getTypeResolver()
|
||||||
.resolveType(getContainingDeclaration().getScopeForClassHeaderResolution(), boundTypeReference,
|
.resolveType(getContainingDeclaration().getScopeForClassHeaderResolution(), boundTypeReference,
|
||||||
resolveSession.getTrace(), false);
|
c.getTrace(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user