Merge branch 'master' of git.labs.intellij.net:jet

This commit is contained in:
Dmitry Jemerov
2011-03-24 15:53:05 +01:00
4 changed files with 36 additions and 6 deletions
@@ -114,6 +114,6 @@ public class BindingTraceContext extends BindingTrace implements BindingContext
@Override @Override
public PsiElement getDeclarationPsiElement(DeclarationDescriptor descriptor) { public PsiElement getDeclarationPsiElement(DeclarationDescriptor descriptor) {
return descriptorToDeclarations.get(descriptor); return descriptorToDeclarations.get(descriptor.getOriginal());
} }
} }
@@ -37,6 +37,10 @@ public class JavaTypeTransformer {
return JetStandardClasses.getNullableAnyType(); return JetStandardClasses.getNullableAnyType();
} }
if ("java.lang.String".equals(psiClass.getQualifiedName())) {
return standardLibrary.getNullableStringType();
}
ClassDescriptor descriptor = resolver.resolveClass(psiClass); ClassDescriptor descriptor = resolver.resolveClass(psiClass);
// TODO : arguments & raw types // TODO : arguments & raw types
List<TypeProjection> arguments = Collections.<TypeProjection>emptyList(); // TODO List<TypeProjection> arguments = Collections.<TypeProjection>emptyList(); // TODO
@@ -335,6 +335,9 @@ public class JetTypeInferrer {
if (property != null) { if (property != null) {
trace.recordReferenceResolution(expression, property); trace.recordReferenceResolution(expression, property);
result = property.getOutType(); result = property.getOutType();
if (result == null) {
semanticServices.getErrorHandler().genericError(expression.getNode(), "This property is not readable in this context");
}
return; return;
} else { } else {
NamespaceDescriptor namespace = scope.getNamespace(referencedName); NamespaceDescriptor namespace = scope.getNamespace(referencedName);
@@ -1036,9 +1039,11 @@ public class JetTypeInferrer {
List<JetType> argumentTypes = getTypes(scope, indexExpressions); List<JetType> argumentTypes = getTypes(scope, indexExpressions);
if (argumentTypes == null) return; if (argumentTypes == null) return;
FunctionDescriptor functionDescriptor = lookupFunction(scope, expression, "get", receiverType, argumentTypes, true); if (receiverType != null) {
if (functionDescriptor != null) { FunctionDescriptor functionDescriptor = lookupFunction(scope, expression, "get", receiverType, argumentTypes, true);
result = functionDescriptor.getUnsubstitutedReturnType(); if (functionDescriptor != null) {
result = functionDescriptor.getUnsubstitutedReturnType();
}
} }
} }
@@ -9,6 +9,8 @@ import java.util.List;
* @author abreslav * @author abreslav
*/ */
public class DescriptorUtil { public class DescriptorUtil {
private DescriptorUtil() {}
public static String renderPresentableText(DeclarationDescriptor declarationDescriptor) { public static String renderPresentableText(DeclarationDescriptor declarationDescriptor) {
if (declarationDescriptor == null) return "<null>"; if (declarationDescriptor == null) return "<null>";
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
@@ -16,8 +18,27 @@ public class DescriptorUtil {
new DeclarationDescriptorVisitor<Void, StringBuilder>() { new DeclarationDescriptorVisitor<Void, StringBuilder>() {
@Override @Override
public Void visitPropertyDescriptor(PropertyDescriptor descriptor, StringBuilder builder) { public Void visitPropertyDescriptor(PropertyDescriptor descriptor, StringBuilder builder) {
JetType type = descriptor.getOutType(); JetType outType = descriptor.getOutType();
builder.append(renderName(descriptor)).append(" : ").append(type); JetType inType = descriptor.getInType();
String typeString = "<no type>";
if (inType != null && outType != null) {
builder.append("var ");
if (inType.equals(outType)) {
typeString = outType.toString();
}
else {
typeString = "<in " + inType + " out " + outType + ">";
}
}
else if (outType != null) {
builder.append("val ");
typeString = outType.toString();
}
else if (inType != null) {
builder.append("<write-only> ");
typeString = inType.toString();
}
builder.append(renderName(descriptor)).append(" : ").append(typeString);
return super.visitPropertyDescriptor(descriptor, builder); return super.visitPropertyDescriptor(descriptor, builder);
} }