Extract method
This commit is contained in:
@@ -804,14 +804,13 @@ public class KotlinBuiltIns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFunctionType(@NotNull JetType type) {
|
public boolean isFunctionType(@NotNull JetType type) {
|
||||||
DeclarationDescriptor constructor = type.getConstructor().getDeclarationDescriptor();
|
return setContainsClassOf(functionClassesSet, type) || setContainsClassOf(extensionFunctionClassesSet, type);
|
||||||
return functionClassesSet.contains(constructor) || extensionFunctionClassesSet.contains(constructor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetType getReceiverType(@NotNull JetType type) {
|
public JetType getReceiverType(@NotNull JetType type) {
|
||||||
assert isFunctionType(type) : type;
|
assert isFunctionType(type) : type;
|
||||||
if (extensionFunctionClassesSet.contains(type.getConstructor().getDeclarationDescriptor())) {
|
if (setContainsClassOf(extensionFunctionClassesSet, type)) {
|
||||||
return type.getArguments().get(0).getType();
|
return type.getArguments().get(0).getType();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -843,7 +842,7 @@ public class KotlinBuiltIns {
|
|||||||
public List<TypeProjection> getParameterTypeProjectionsFromFunctionType(@NotNull JetType type) {
|
public List<TypeProjection> getParameterTypeProjectionsFromFunctionType(@NotNull JetType type) {
|
||||||
assert isFunctionType(type);
|
assert isFunctionType(type);
|
||||||
List<TypeProjection> arguments = type.getArguments();
|
List<TypeProjection> arguments = type.getArguments();
|
||||||
int first = extensionFunctionClassesSet.contains(type.getConstructor().getDeclarationDescriptor()) ? 1 : 0;
|
int first = setContainsClassOf(extensionFunctionClassesSet, type) ? 1 : 0;
|
||||||
int last = arguments.size() - 2;
|
int last = arguments.size() - 2;
|
||||||
List<TypeProjection> parameterTypes = Lists.newArrayList();
|
List<TypeProjection> parameterTypes = Lists.newArrayList();
|
||||||
for (int i = first; i <= last; i++) {
|
for (int i = first; i <= last; i++) {
|
||||||
@@ -936,7 +935,7 @@ public class KotlinBuiltIns {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isTupleType(@NotNull JetType type) {
|
public boolean isTupleType(@NotNull JetType type) {
|
||||||
return tupleClassesSet.contains(type.getConstructor().getDeclarationDescriptor());
|
return setContainsClassOf(tupleClassesSet, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -961,11 +960,16 @@ public class KotlinBuiltIns {
|
|||||||
return new JetTypeImpl(annotations, tuple.getTypeConstructor(), false, typeArguments, tuple.getMemberScope(typeArguments));
|
return new JetTypeImpl(annotations, tuple.getTypeConstructor(), false, typeArguments, tuple.getMemberScope(typeArguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TypeProjection> toProjections(List<JetType> arguments) {
|
private static List<TypeProjection> toProjections(List<JetType> arguments) {
|
||||||
List<TypeProjection> result = new ArrayList<TypeProjection>();
|
List<TypeProjection> result = new ArrayList<TypeProjection>();
|
||||||
for (JetType argument : arguments) {
|
for (JetType argument : arguments) {
|
||||||
result.add(new TypeProjection(Variance.OUT_VARIANCE, argument));
|
result.add(new TypeProjection(Variance.OUT_VARIANCE, argument));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean setContainsClassOf(ImmutableSet<ClassDescriptor> set, JetType type) {
|
||||||
|
//noinspection SuspiciousMethodCalls
|
||||||
|
return set.contains(type.getConstructor().getDeclarationDescriptor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user