Created common supertype for LexicalScope & ImportingScope -- HierarchicalScope

This commit is contained in:
Stanislav Erokhin
2015-11-02 14:57:52 +03:00
parent 4c36e20242
commit 21fdd2ffc3
22 changed files with 119 additions and 131 deletions
@@ -138,7 +138,7 @@ public class ExpectedResolveDataUtil {
emptyModule.setDependencies(emptyModule);
emptyModule.initialize(PackageFragmentProvider.Empty.INSTANCE$);
LexicalScopeImpl lexicalScope = new LexicalScopeImpl(ImportingScope.Empty.INSTANCE, classDescriptor, false,
LexicalScopeImpl lexicalScope = new LexicalScopeImpl(ScopeUtilsKt.asLexicalScope(ImportingScope.Empty.INSTANCE, emptyModule), classDescriptor, false,
classDescriptor.getThisAsReceiverParameter(),
"Scope with implicit this for class: " + classDescriptor);
@@ -92,7 +92,7 @@ public class DefaultModalityModifiersTest extends KotlinLiteFixture {
assert aClass instanceof KtClass;
AnalysisResult bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(file);
final DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
return new LexicalScopeImpl(ScopeUtilsKt.memberScopeAsImportingScope(libraryScope), root, false, null,
return new LexicalScopeImpl(TypeTestUtilsKt.asLexicalScope(libraryScope), root, false, null,
"JetDefaultModalityModifiersTest", RedeclarationHandler.DO_NOTHING,
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
@Override
@@ -25,8 +25,7 @@ import org.jetbrains.kotlin.resolve.FunctionDescriptorResolver;
import org.jetbrains.kotlin.resolve.OverloadUtil;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
import org.jetbrains.kotlin.resolve.scopes.ImportingScope;
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
import org.jetbrains.kotlin.test.ConfigurationKind;
import org.jetbrains.kotlin.test.KotlinLiteFixture;
import org.jetbrains.kotlin.test.KotlinTestUtils;
@@ -171,7 +170,7 @@ public class KotlinOverloadTest extends KotlinLiteFixture {
private FunctionDescriptor makeFunction(String funDecl) {
KtNamedFunction function = KtPsiFactoryKt.KtPsiFactory(getProject()).createFunction(funDecl);
ImportingScope scope = ScopeUtilsKt.memberScopeAsImportingScope(JvmPlatform.INSTANCE$.getBuiltIns().getBuiltInsPackageScope());
LexicalScope scope = TypeTestUtilsKt.asLexicalScope(JvmPlatform.INSTANCE$.getBuiltIns().getBuiltInsPackageScope());
return functionDescriptorResolver.resolveFunctionDescriptor(root, scope, function, KotlinTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
}
}
@@ -201,7 +201,7 @@ public class TypeUnifierTest extends KotlinLiteFixture {
}
private TypeProjection makeTypeProjection(KtScope scope, String typeStr) {
LexicalScope withX = new LexicalScopeImpl(ScopeUtilsKt.memberScopeAsImportingScope(scope), scope.getContainingDeclaration(),
LexicalScope withX = new LexicalScopeImpl(TypeTestUtilsKt.asLexicalScope(scope), scope.getContainingDeclaration(),
false, null, "With X", RedeclarationHandler.DO_NOTHING,
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
@Override
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.types
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.resolve.scopes.BaseLexicalScope
import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
@@ -25,11 +24,9 @@ import org.jetbrains.kotlin.utils.Printer
public fun KtScope.asLexicalScope(): LexicalScope {
val importingScope = memberScopeAsImportingScope()
return object : BaseLexicalScope(importingScope) {
override val ownerDescriptor: DeclarationDescriptor
get() = importingScope.ownerDescriptor
return object : BaseLexicalScope(importingScope, getContainingDeclaration()) {
override fun printStructure(p: Printer) {
p.println("Util scope for tests")
}
}
}