Removed usages of getTuple() and isTupleType()

This commit is contained in:
Evgeny Gerashchenko
2013-03-19 16:10:21 +04:00
parent 6e623c57e1
commit ca27637ef2
5 changed files with 11 additions and 5 deletions
@@ -147,9 +147,9 @@ public class IntrinsicMethods {
declareIntrinsicProperty(Name.identifier("CharSequence"), Name.identifier("length"), new StringLength()); declareIntrinsicProperty(Name.identifier("CharSequence"), Name.identifier("length"), new StringLength());
declareIntrinsicProperty(Name.identifier("String"), Name.identifier("length"), new StringLength()); declareIntrinsicProperty(Name.identifier("String"), Name.identifier("length"), new StringLength());
Name tuple0Name = KotlinBuiltIns.getInstance().getTuple(0).getName(); Name unitName = KotlinBuiltIns.getInstance().getUnit().getName();
intrinsicsMap.registerIntrinsic( intrinsicsMap.registerIntrinsic(
getClassObjectFqName(tuple0Name), getClassObjectFqName(unitName),
Name.identifier("VALUE"), -1, new UnitValue()); Name.identifier("VALUE"), -1, new UnitValue());
for (PrimitiveType type : PrimitiveType.NUMBER_TYPES) { for (PrimitiveType type : PrimitiveType.NUMBER_TYPES) {
@@ -95,8 +95,9 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
String shortName = type.getReferenceExpression().getReferencedName(); String shortName = type.getReferenceExpression().getReferencedName();
String longName = (qualifier == null ? "" : qualifier.getText() + ".") + shortName; String longName = (qualifier == null ? "" : qualifier.getText() + ".") + shortName;
// TODO remove this code when Unit will be not a synonym for Tuple0
if (KotlinBuiltIns.UNIT_ALIAS.getName().equals(longName)) { if (KotlinBuiltIns.UNIT_ALIAS.getName().equals(longName)) {
return visitCommonType(KotlinBuiltIns.getInstance().getTuple(0), type); return visitCommonType(KotlinBuiltIns.getInstance().getUnit(), type);
} }
return visitCommonType(longName, type); return visitCommonType(longName, type);
@@ -429,6 +429,11 @@ public class KotlinBuiltIns {
return getBuiltInClassByName("Number"); return getBuiltInClassByName("Number");
} }
@NotNull
public ClassDescriptor getUnit() {
return getBuiltInClassByName("Tuple0");
}
@NotNull @NotNull
public ClassDescriptor getFunction(int parameterCount) { public ClassDescriptor getFunction(int parameterCount) {
return getBuiltInClassByName("Function" + parameterCount); return getBuiltInClassByName("Function" + parameterCount);
@@ -54,7 +54,7 @@ public class JetPluginUtil {
public static boolean checkTypeIsStandard(JetType type, Project project) { public static boolean checkTypeIsStandard(JetType type, Project project) {
if (KotlinBuiltIns.getInstance().isAny(type) || KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type) || KotlinBuiltIns.getInstance().isUnit(type) || if (KotlinBuiltIns.getInstance().isAny(type) || KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type) || KotlinBuiltIns.getInstance().isUnit(type) ||
KotlinBuiltIns.getInstance().isTupleType(type) || KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(type)) { KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(type)) {
return true; return true;
} }
@@ -56,7 +56,7 @@ import java.util.List;
public class BuiltInsReferenceResolver extends AbstractProjectComponent { public class BuiltInsReferenceResolver extends AbstractProjectComponent {
private BindingContext bindingContext = null; private BindingContext bindingContext = null;
private final FqName TUPLE0_FQ_NAME = DescriptorUtils.getFQName(KotlinBuiltIns.getInstance().getTuple(0)).toSafe(); private final FqName TUPLE0_FQ_NAME = DescriptorUtils.getFQName(KotlinBuiltIns.getInstance().getUnit()).toSafe();
public BuiltInsReferenceResolver( public BuiltInsReferenceResolver(
Project project, Project project,