frontend.java: Drop usages of KotlinBuiltIns.getInstance()

This commit is contained in:
Pavel V. Talanov
2015-09-22 16:32:04 +03:00
parent 64d8baee1d
commit 0a2bd257a5
4 changed files with 16 additions and 8 deletions
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.resolve.*;
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisCompletedHandlerExtension;
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
@@ -71,8 +72,8 @@ public enum TopDownAnalyzerFacadeForJVM {
list.add(new ImportPath("kotlin.jvm.*"));
list.add(new ImportPath("kotlin.io.*"));
addAllClassifiersToImportPathList(list, KotlinBuiltIns.getInstance().getBuiltInsPackageScope());
addAllClassifiersToImportPathList(list, KotlinBuiltIns.getInstance().getAnnotationPackageScope());
addAllClassifiersToImportPathList(list, JvmPlatform.INSTANCE$.getBuiltIns().getBuiltInsPackageScope());
addAllClassifiersToImportPathList(list, JvmPlatform.INSTANCE$.getBuiltIns().getAnnotationPackageScope());
return list;
}
@@ -193,7 +194,7 @@ public enum TopDownAnalyzerFacadeForJVM {
MutableModuleContext context = ContextForNewModule(
project, Name.special("<" + moduleName + ">"), JVM_MODULE_PARAMETERS
);
context.setDependencies(context.getModule(), KotlinBuiltIns.getInstance().getBuiltInsModule());
context.setDependencies(context.getModule(), JvmPlatform.INSTANCE$.getBuiltIns().getBuiltInsModule());
return context;
}
}
@@ -32,6 +32,8 @@ import org.jetbrains.kotlin.load.java.components.ExternalAnnotationResolver;
import org.jetbrains.kotlin.load.java.structure.JavaMember;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.JavaResolverUtils;
import org.jetbrains.kotlin.resolve.jvm.JvmPackage;
import org.jetbrains.kotlin.types.JetType;
@@ -49,6 +51,7 @@ import java.util.Set;
import static org.jetbrains.kotlin.load.java.components.TypeUsage.MEMBER_SIGNATURE_CONTRAVARIANT;
import static org.jetbrains.kotlin.load.java.components.TypeUsage.UPPER_BOUND;
import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory;
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getBuiltIns;
public class AlternativeMethodSignatureData extends ElementAlternativeSignatureData {
private final JetNamedFunction altFunDeclaration;
@@ -219,7 +222,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
alternativeVarargElementType = TypeTransformingVisitor.computeType(alternativeTypeElement, originalParamVarargElementType,
originalToAltTypeParameters, MEMBER_SIGNATURE_CONTRAVARIANT);
alternativeType = KotlinBuiltIns.getInstance().getArrayType(Variance.OUT_VARIANCE, alternativeVarargElementType);
alternativeType = getBuiltIns(originalParameterDescriptor).getArrayType(Variance.OUT_VARIANCE, alternativeVarargElementType);
}
Name altName = annotationValueParameter.getNameAsName();
@@ -35,6 +35,8 @@ import org.jetbrains.kotlin.types.checker.JetTypeChecker;
import java.util.Arrays;
import java.util.List;
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isArray;
// This class contains heuristics for processing corner cases in propagation
class PropagationHeuristics {
// Checks for case when method returning Super[] is overridden with method returning Sub[]
@@ -47,10 +49,10 @@ class PropagationHeuristics {
.filter(typesFromSuper, new Condition<SignaturesPropagationData.TypeAndVariance>() {
@Override
public boolean value(SignaturesPropagationData.TypeAndVariance typeAndVariance) {
return typeAndVariance.type.getConstructor().getDeclarationDescriptor() == KotlinBuiltIns.getInstance().getArray();
return isArray(typeAndVariance.type);
}
});
if (KotlinBuiltIns.getInstance().getArray() == type.getConstructor().getDeclarationDescriptor() && !arrayTypesFromSuper.isEmpty()) {
if (isArray(type) && !arrayTypesFromSuper.isEmpty()) {
assert type.getArguments().size() == 1;
if (type.getArguments().get(0).getProjectionKind() == Variance.INVARIANT) {
for (SignaturesPropagationData.TypeAndVariance typeAndVariance : arrayTypesFromSuper) {
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.TypeResolver;
import org.jetbrains.kotlin.resolve.jvm.JvmPackage;
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.types.*;
@@ -84,9 +85,10 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
@Override
public JetType visitFunctionType(@NotNull JetFunctionType type, Void data) {
KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns();
return visitCommonType(type.getReceiverTypeReference() == null
? KotlinBuiltIns.getInstance().getFunction(type.getParameters().size())
: KotlinBuiltIns.getInstance().getExtensionFunction(type.getParameters().size()), type);
? builtIns.getFunction(type.getParameters().size())
: builtIns.getExtensionFunction(type.getParameters().size()), type);
}
@Override