Merge remote-tracking branch 'origin/master'

This commit is contained in:
svtk
2012-01-18 13:31:52 +04:00
181 changed files with 2587 additions and 597 deletions
@@ -10,6 +10,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver;
import org.jetbrains.jet.lang.types.DescriptorSubstitutor;
import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeSubstitutor;
import org.jetbrains.jet.lang.types.Variance;
@@ -37,6 +38,15 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
private List<TypeParameterDescriptor> typeParemeters;
private PropertyGetterDescriptor getter;
private PropertySetterDescriptor setter;
private PropertyDescriptor() {
super(ErrorUtils.getErrorClass(), Collections.<AnnotationDescriptor>emptyList(), "dummy");
this.modality = null;
this.visibility = null;
this.isVar = false;
this.isObject = false;
this.original = null;
}
private PropertyDescriptor(
@Nullable PropertyDescriptor original,
@@ -243,4 +253,8 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
propertyDescriptor.initialize(newGetter, newSetter);
return propertyDescriptor;
}
public static PropertyDescriptor createDummy() {
return new PropertyDescriptor();
}
}
@@ -73,7 +73,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
this,
annotations,
false,
"&" + name,
name,
Collections.<TypeParameterDescriptor>emptyList(),
upperBounds);
}
@@ -0,0 +1,19 @@
package org.jetbrains.jet.lang.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
/**
* @author abreslav
*/
public class JetVisibilityChecker {
/**
* @param locationOwner owner of the call site
* @param subject the descriptor whose visibility is being checked
* @return <code>true</code> iff subject is visible locationOwner
*/
public boolean isVisible(@NotNull DeclarationDescriptor locationOwner, @NotNull DeclarationDescriptor subject) {
// TODO : stub implementation
return true;
}
}
@@ -100,13 +100,7 @@ public class TypeResolver {
int expectedArgumentCount = parameters.size();
int actualArgumentCount = arguments.size();
if (ErrorUtils.isError(typeConstructor)) {
result[0] = new JetTypeImpl(
annotations,
typeConstructor,
nullable,
arguments, // TODO : review
classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList())
);
result[0] = ErrorUtils.createErrorType("??");
}
else {
if (actualArgumentCount != expectedArgumentCount) {
@@ -15,7 +15,13 @@ import java.util.*;
public class ErrorUtils {
private static final ModuleDescriptor ERROR_MODULE = new ModuleDescriptor("<ERROR MODULE>");
private static final JetScope ERROR_SCOPE = new JetScope() {
private static final JetScope ERROR_SCOPE = new ErrorScope();
public static class ErrorScope implements JetScope {
private ErrorScope() {}
@Override
public ClassifierDescriptor getClassifier(@NotNull String name) {
@@ -82,7 +88,7 @@ public class ErrorUtils {
return Collections.emptyList();
}
};
}
private static final ClassDescriptorImpl ERROR_CLASS = new ClassDescriptorImpl(ERROR_MODULE, Collections.<AnnotationDescriptor>emptyList(), "<ERROR CLASS>") {
@NotNull
@@ -96,6 +102,12 @@ public class ErrorUtils {
public Modality getModality() {
return Modality.OPEN;
}
@NotNull
@Override
public ClassDescriptor substitute(TypeSubstitutor substitutor) {
return ERROR_CLASS;
}
};
private static final Set<FunctionDescriptor> ERROR_FUNCTION_GROUP = Collections.singleton(createErrorFunction(0, Collections.<JetType>emptyList()));
@@ -78,6 +78,7 @@ public class JetStandardLibrary {
private EnumMap<PrimitiveType, JetType> primitiveTypeToArrayJetType;
private EnumMap<PrimitiveType, JetType> primitiveTypeToNullableArrayJetType;
private Map<JetType, JetType> primitiveJetTypeToJetArrayType;
private Map<JetType, JetType> jetArrayTypeToPrimitiveJetType;
private JetStandardLibrary(@NotNull Project project) {
// TODO : review
@@ -147,6 +148,7 @@ public class JetStandardLibrary {
primitiveTypeToArrayJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
primitiveTypeToNullableArrayJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
primitiveJetTypeToJetArrayType = new HashMap<JetType, JetType>();
jetArrayTypeToPrimitiveJetType = new HashMap<JetType, JetType>();
for (PrimitiveType primitive : PrimitiveType.values()) {
makePrimitive(primitive);
@@ -167,6 +169,7 @@ public class JetStandardLibrary {
primitiveTypeToArrayJetType.put(primitiveType, arrayType);
primitiveTypeToNullableArrayJetType.put(primitiveType, TypeUtils.makeNullable(arrayType));
primitiveJetTypeToJetArrayType.put(type, arrayType);
jetArrayTypeToPrimitiveJetType.put(arrayType, type);
}
@NotNull
@@ -334,6 +337,22 @@ public class JetStandardLibrary {
getArray().getMemberScope(types)
);
}
@NotNull
public JetType getArrayElementType(@NotNull JetType arrayType) {
// make non-null?
if (arrayType.getConstructor().getDeclarationDescriptor() == getArray()) {
if (arrayType.getArguments().size() != 1) {
throw new IllegalStateException();
}
return arrayType.getArguments().get(0).getType();
}
JetType primitiveType = jetArrayTypeToPrimitiveJetType.get(arrayType);
if (primitiveType == null) {
throw new IllegalStateException("not array: " + arrayType);
}
return primitiveType;
}
@NotNull
public JetType getIterableType(@NotNull JetType argument) {
@@ -23,6 +23,11 @@ public final class JetTypeImpl extends AnnotatedImpl implements JetType {
public JetTypeImpl(List<AnnotationDescriptor> annotations, TypeConstructor constructor, boolean nullable, @NotNull List<TypeProjection> arguments, JetScope memberScope) {
super(annotations);
if (memberScope instanceof ErrorUtils.ErrorScope) {
throw new IllegalStateException();
}
this.constructor = constructor;
this.nullable = nullable;
this.arguments = arguments;
@@ -100,6 +100,9 @@ public class TypeUtils {
if (type.isNullable() == nullable) {
return type;
}
if (ErrorUtils.isErrorType(type)) {
return type;
}
return new JetTypeImpl(type.getAnnotations(), type.getConstructor(), nullable, type.getArguments(), type.getMemberScope());
}
@@ -285,6 +288,9 @@ public class TypeUtils {
@NotNull
public static JetType makeUnsubstitutedType(ClassDescriptor classDescriptor, JetScope unsubstitutedMemberScope) {
if (ErrorUtils.isError(classDescriptor)) {
return ErrorUtils.createErrorType("This is very helpful diagnostics message");
}
List<TypeProjection> arguments = getDefaultTypeProjections(classDescriptor.getTypeConstructor().getParameters());
return new JetTypeImpl(
Collections.<AnnotationDescriptor>emptyList(),