Remove some usages of KotlinBuiltIns.getInstance()

Introduce DeclarationDescriptor.builtIns extension to get builtins where descriptors are available
Introduce various utilities in KotlinBuiltIns to check for primitive types and get fq names of builtins
This commit is contained in:
Pavel V. Talanov
2015-04-23 15:40:16 +03:00
parent 21d9c272c9
commit ac2cb9af74
71 changed files with 334 additions and 288 deletions
@@ -194,7 +194,7 @@ public class InjectorForLazyResolveWithJava {
this.argumentTypeResolver = new ArgumentTypeResolver();
this.expressionTypingComponents = new ExpressionTypingComponents();
this.expressionTypingServices = new ExpressionTypingServices(expressionTypingComponents);
this.callExpressionResolver = new CallExpressionResolver(callResolver);
this.callExpressionResolver = new CallExpressionResolver(callResolver, kotlinBuiltIns);
this.controlStructureTypingUtils = new ControlStructureTypingUtils(callResolver);
this.descriptorResolver = new DescriptorResolver();
this.delegatedPropertyResolver = new DelegatedPropertyResolver();
@@ -221,7 +221,7 @@ public class InjectorForReplWithJava {
this.argumentTypeResolver = new ArgumentTypeResolver();
this.expressionTypingComponents = new ExpressionTypingComponents();
this.expressionTypingServices = new ExpressionTypingServices(expressionTypingComponents);
this.callExpressionResolver = new CallExpressionResolver(callResolver);
this.callExpressionResolver = new CallExpressionResolver(callResolver, kotlinBuiltIns);
this.controlStructureTypingUtils = new ControlStructureTypingUtils(callResolver);
this.descriptorResolver = new DescriptorResolver();
this.delegatedPropertyResolver = new DelegatedPropertyResolver();
@@ -219,7 +219,7 @@ public class InjectorForTopDownAnalyzerForJvm {
this.argumentTypeResolver = new ArgumentTypeResolver();
this.expressionTypingComponents = new ExpressionTypingComponents();
this.expressionTypingServices = new ExpressionTypingServices(expressionTypingComponents);
this.callExpressionResolver = new CallExpressionResolver(callResolver);
this.callExpressionResolver = new CallExpressionResolver(callResolver, kotlinBuiltIns);
this.controlStructureTypingUtils = new ControlStructureTypingUtils(callResolver);
this.descriptorResolver = new DescriptorResolver();
this.delegatedPropertyResolver = new DelegatedPropertyResolver();
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.types.*;
import java.util.*;
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getBuiltIns;
import static org.jetbrains.kotlin.types.Variance.INVARIANT;
public class SingleAbstractMethodUtils {
@@ -121,8 +122,7 @@ public class SingleAbstractMethodUtils {
for (ValueParameterDescriptor parameter : valueParameters) {
parameterTypes.add(parameter.getType());
}
return KotlinBuiltIns.getInstance().getFunctionType(
Annotations.EMPTY, null, parameterTypes, returnType);
return getBuiltIns(function).getFunctionType(Annotations.EMPTY, null, parameterTypes, returnType);
}
private static boolean isSamInterface(@NotNull ClassDescriptor klass) {
@@ -50,6 +50,7 @@ import java.util.*;
import static org.jetbrains.kotlin.load.java.components.TypeUsage.*;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName;
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getBuiltIns;
import static org.jetbrains.kotlin.types.Variance.INVARIANT;
public class SignaturesPropagationData {
@@ -263,7 +264,7 @@ public class SignaturesPropagationData {
stableName != null ? stableName : originalParam.getName(),
altType,
originalParam.declaresDefaultValue(),
varargCheckResult.isVararg ? KotlinBuiltIns.getInstance().getArrayElementType(altType) : null,
varargCheckResult.isVararg ? getBuiltIns(originalParam).getArrayElementType(altType) : null,
SourceElement.NO_SOURCE
));
}