Renamed method and got rid of some usages.

This commit is contained in:
Evgeny Gerashchenko
2013-11-26 18:08:39 +04:00
parent ad7044cc6c
commit 557aaf363a
12 changed files with 16 additions and 19 deletions
@@ -23,7 +23,6 @@ import org.jetbrains.asm4.Type;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor; import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor;
import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.JetTypeImpl; import org.jetbrains.jet.lang.types.JetTypeImpl;
import org.jetbrains.jet.lang.types.TypeProjection; import org.jetbrains.jet.lang.types.TypeProjection;
@@ -140,11 +139,10 @@ public class FunctionTypesUtil {
@NotNull @NotNull
private static ClassDescriptor createFunctionImplDescriptor(@NotNull Name name, @NotNull ClassDescriptor functionInterface) { private static ClassDescriptor createFunctionImplDescriptor(@NotNull Name name, @NotNull ClassDescriptor functionInterface) {
JetScope builtInsScope = KotlinBuiltIns.getInstance().getBuiltInsScope(); PackageFragmentDescriptor builtinsFragment = KotlinBuiltIns.getInstance().getBuiltInsPackageFragment();
MutableClassDescriptor functionImpl = new MutableClassDescriptor( MutableClassDescriptor functionImpl = new MutableClassDescriptor(
KotlinBuiltIns.getInstance().getBuiltInsPackageFragment(), builtinsFragment,
builtInsScope, builtinsFragment.getMemberScope(),
ClassKind.CLASS, ClassKind.CLASS,
false, false,
name name
@@ -105,7 +105,7 @@ public class RangeCodegenUtil {
) { ) {
ClassifierDescriptor declarationDescriptor = rangeOrProgression.getConstructor().getDeclarationDescriptor(); ClassifierDescriptor declarationDescriptor = rangeOrProgression.getConstructor().getDeclarationDescriptor();
assert declarationDescriptor != null; assert declarationDescriptor != null;
if (declarationDescriptor != KotlinBuiltIns.getInstance().getBuiltInsScope().getClassifier(declarationDescriptor.getName())) { if (declarationDescriptor != KotlinBuiltIns.getInstance().getBuiltInsPackageScope().getClassifier(declarationDescriptor.getName())) {
// Must be a standard library class // Must be a standard library class
return null; return null;
} }
@@ -51,7 +51,7 @@ public class BuiltinsDeserializationTest extends KotlinTestWithEnvironment {
} }
public void testBuiltIns() throws Exception { public void testBuiltIns() throws Exception {
Collection<DeclarationDescriptor> allDescriptors = KotlinBuiltIns.getInstance().getBuiltInsScope().getAllDescriptors(); Collection<DeclarationDescriptor> allDescriptors = KotlinBuiltIns.getInstance().getBuiltInsPackageScope().getAllDescriptors();
PackageFragmentDescriptor actualPackage = getDeserializedDescriptorsAsPackage(allDescriptors); PackageFragmentDescriptor actualPackage = getDeserializedDescriptorsAsPackage(allDescriptors);
RecursiveDescriptorComparator.Configuration configuration = RecursiveDescriptorComparator.RECURSIVE.withRenderer( RecursiveDescriptorComparator.Configuration configuration = RecursiveDescriptorComparator.RECURSIVE.withRenderer(
@@ -254,7 +254,7 @@ public abstract class ExpectedResolveData {
JetType actualType = bindingContext.get(BindingContext.TYPE, typeReference); JetType actualType = bindingContext.get(BindingContext.TYPE, typeReference);
assertNotNull("Type " + name + " not resolved for reference " + name, actualType); assertNotNull("Type " + name + " not resolved for reference " + name, actualType);
ClassifierDescriptor expectedClass = builtIns.getBuiltInsScope().getClassifier(Name.identifier(name.substring(STANDARD_PREFIX.length()))); ClassifierDescriptor expectedClass = builtIns.getBuiltInClassByName(Name.identifier(name.substring(STANDARD_PREFIX.length())));
assertNotNull("Expected class not found: " + name); assertNotNull("Expected class not found: " + name);
assertSame("Type resolution mismatch: ", expectedClass.getTypeConstructor(), actualType.getConstructor()); assertSame("Type resolution mismatch: ", expectedClass.getTypeConstructor(), actualType.getConstructor());
continue; continue;
@@ -311,7 +311,7 @@ public abstract class ExpectedResolveData {
TypeConstructor expectedTypeConstructor; TypeConstructor expectedTypeConstructor;
if (typeName.startsWith(STANDARD_PREFIX)) { if (typeName.startsWith(STANDARD_PREFIX)) {
String name = typeName.substring(STANDARD_PREFIX.length()); String name = typeName.substring(STANDARD_PREFIX.length());
ClassifierDescriptor expectedClass = builtIns.getBuiltInsScope().getClassifier(Name.identifier(name)); ClassifierDescriptor expectedClass = builtIns.getBuiltInClassByName(Name.identifier(name));
assertNotNull("Expected class not found: " + typeName, expectedClass); assertNotNull("Expected class not found: " + typeName, expectedClass);
expectedTypeConstructor = expectedClass.getTypeConstructor(); expectedTypeConstructor = expectedClass.getTypeConstructor();
@@ -69,7 +69,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
InjectorForTests injector = new InjectorForTests(getProject(), root); InjectorForTests injector = new InjectorForTests(getProject(), root);
KotlinBuiltIns builtIns = injector.getKotlinBuiltIns(); KotlinBuiltIns builtIns = injector.getKotlinBuiltIns();
descriptorResolver = injector.getDescriptorResolver(); descriptorResolver = injector.getDescriptorResolver();
scope = createScope(builtIns.getBuiltInsScope()); scope = createScope(builtIns.getBuiltInsPackageScope());
} }
public void tearDown() throws Exception { public void tearDown() throws Exception {
@@ -182,7 +182,7 @@ public class JetOverloadTest extends JetLiteFixture {
private FunctionDescriptor makeFunction(String funDecl) { private FunctionDescriptor makeFunction(String funDecl) {
JetNamedFunction function = JetPsiFactory.createFunction(getProject(), funDecl); JetNamedFunction function = JetPsiFactory.createFunction(getProject(), funDecl);
return descriptorResolver.resolveFunctionDescriptor(root, builtIns.getBuiltInsScope(), function, return descriptorResolver.resolveFunctionDescriptor(root, builtIns.getBuiltInsPackageScope(), function,
JetTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY); JetTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
} }
} }
@@ -172,7 +172,7 @@ public class JetOverridingTest extends JetLiteFixture {
private FunctionDescriptor makeFunction(String funDecl) { private FunctionDescriptor makeFunction(String funDecl) {
JetNamedFunction function = JetPsiFactory.createFunction(getProject(), funDecl); JetNamedFunction function = JetPsiFactory.createFunction(getProject(), funDecl);
return descriptorResolver.resolveFunctionDescriptor(root, builtIns.getBuiltInsScope(), function, return descriptorResolver.resolveFunctionDescriptor(root, builtIns.getBuiltInsPackageScope(), function,
JetTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY); JetTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
} }
} }
@@ -96,7 +96,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
topLevelDeclarations, topLevelDeclarations,
typeParameters, typeParameters,
contextClass.getDefaultType().getMemberScope(), contextClass.getDefaultType().getMemberScope(),
KotlinBuiltIns.getInstance().getBuiltInsScope()); KotlinBuiltIns.getInstance().getBuiltInsPackageScope());
} }
private void doTest(@Nullable String expectedTypeStr, String initialTypeStr, Pair<String, String>... substitutionStrs) { private void doTest(@Nullable String expectedTypeStr, String initialTypeStr, Pair<String, String>... substitutionStrs) {
@@ -198,7 +198,7 @@ public class TypeUnifierTest extends JetLiteFixture {
} }
private TypeProjection makeType(String typeStr) { private TypeProjection makeType(String typeStr) {
return makeTypeProjection(builtIns.getBuiltInsScope(), typeStr); return makeTypeProjection(builtIns.getBuiltInsPackageScope(), typeStr);
} }
private TypeProjection makeTypeProjection(JetScope scope, String typeStr) { private TypeProjection makeTypeProjection(JetScope scope, String typeStr) {
@@ -174,7 +174,7 @@ public final class JavaClassResolver {
List<Name> segments = qualifiedName.pathSegments(); List<Name> segments = qualifiedName.pathSegments();
if (segments.size() < 2) return null; if (segments.size() < 2) return null;
JetScope scope = KotlinBuiltIns.getInstance().getBuiltInsScope(); JetScope scope = KotlinBuiltIns.getInstance().getBuiltInsPackageScope();
for (int i = 1, size = segments.size(); i < size; i++) { for (int i = 1, size = segments.size(); i < size; i++) {
ClassifierDescriptor classifier = scope.getClassifier(segments.get(i)); ClassifierDescriptor classifier = scope.getClassifier(segments.get(i));
if (classifier == null) return null; if (classifier == null) return null;
@@ -227,9 +227,8 @@ public class KotlinBuiltIns {
return builtInsModule.getPackageFragmentProvider().getPackageFragments(BUILT_INS_PACKAGE_FQ_NAME).get(0); return builtInsModule.getPackageFragmentProvider().getPackageFragments(BUILT_INS_PACKAGE_FQ_NAME).get(0);
} }
@Deprecated
@NotNull @NotNull
public JetScope getBuiltInsScope() { // TODO 1 scope? public JetScope getBuiltInsPackageScope() {
return getBuiltInsPackageFragment().getMemberScope(); return getBuiltInsPackageFragment().getMemberScope();
} }
@@ -241,7 +240,7 @@ public class KotlinBuiltIns {
@NotNull @NotNull
public ClassDescriptor getBuiltInClassByName(@NotNull Name simpleName) { public ClassDescriptor getBuiltInClassByName(@NotNull Name simpleName) {
ClassifierDescriptor classifier = getBuiltInsScope().getClassifier(simpleName); ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getClassifier(simpleName);
assert classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + classifier; assert classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + classifier;
return (ClassDescriptor) classifier; return (ClassDescriptor) classifier;
} }
@@ -51,7 +51,7 @@ fun generate(): String {
val builtIns = KotlinBuiltIns.getInstance() val builtIns = KotlinBuiltIns.getInstance()
[suppress("UNCHECKED_CAST")] [suppress("UNCHECKED_CAST")]
val allPrimitiveTypes = builtIns.getBuiltInsPackage().getMemberScope().getAllDescriptors() val allPrimitiveTypes = builtIns.getBuiltInsPackageScope().getAllDescriptors()
.filter { it is ClassDescriptor && builtIns.isPrimitiveType(it.getDefaultType()) } as List<ClassDescriptor> .filter { it is ClassDescriptor && builtIns.isPrimitiveType(it.getDefaultType()) } as List<ClassDescriptor>
for (descriptor in allPrimitiveTypes + builtIns.getString()) { for (descriptor in allPrimitiveTypes + builtIns.getString()) {