Types of selectors in DotQualifiedExpressions are recorded
This commit is contained in:
@@ -378,7 +378,7 @@ public class JetTypeInferrer {
|
||||
if (typeReference == null) {
|
||||
throw new UnsupportedOperationException("Type inference for parameters is not implemented yet");
|
||||
}
|
||||
PropertyDescriptor propertyDescriptor = classDescriptorResolver.resolvePropertyDescriptor(functionDescriptor, scope, parameter);
|
||||
PropertyDescriptor propertyDescriptor = classDescriptorResolver.resolveValueParameterDescriptor(functionDescriptor, scope, parameter);
|
||||
parameterDescriptors.put(parameter.getName(), propertyDescriptor);
|
||||
parameterTypes.add(propertyDescriptor.getOutType());
|
||||
}
|
||||
@@ -644,7 +644,7 @@ public class JetTypeInferrer {
|
||||
JetTypeReference typeReference = loopParameter.getTypeReference();
|
||||
PropertyDescriptor propertyDescriptor;
|
||||
if (typeReference != null) {
|
||||
propertyDescriptor = semanticServices.getClassDescriptorResolver(trace).resolvePropertyDescriptor(scope.getContainingDeclaration(), scope, loopParameter);
|
||||
propertyDescriptor = semanticServices.getClassDescriptorResolver(trace).resolveValueParameterDescriptor(scope.getContainingDeclaration(), scope, loopParameter);
|
||||
JetType actualParameterType = propertyDescriptor.getOutType();
|
||||
if (expectedParameterType != null &&
|
||||
!semanticServices.getTypeChecker().isSubtypeOf(expectedParameterType, actualParameterType)) {
|
||||
@@ -655,10 +655,9 @@ public class JetTypeInferrer {
|
||||
if (expectedParameterType == null) {
|
||||
expectedParameterType = ErrorType.createErrorType("Error");
|
||||
}
|
||||
propertyDescriptor = semanticServices.getClassDescriptorResolver(trace).resolvePropertyDescriptor(scope.getContainingDeclaration(), loopParameter, expectedParameterType);
|
||||
propertyDescriptor = semanticServices.getClassDescriptorResolver(trace).resolveValueParameterDescriptor(scope.getContainingDeclaration(), loopParameter, expectedParameterType);
|
||||
}
|
||||
loopScope.addPropertyDescriptor(propertyDescriptor);
|
||||
trace.recordDeclarationResolution(loopParameter, propertyDescriptor);
|
||||
|
||||
JetExpression body = expression.getBody();
|
||||
if (body != null) {
|
||||
@@ -783,6 +782,9 @@ public class JetTypeInferrer {
|
||||
else {
|
||||
result = selectorReturnType;
|
||||
}
|
||||
if (selectorExpression != null && result != null) {
|
||||
trace.recordExpressionType(selectorExpression, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -798,7 +800,7 @@ public class JetTypeInferrer {
|
||||
}
|
||||
else if (selectorExpression != null) {
|
||||
// TODO : not a simple name -> resolve in scope, expect property type or a function type
|
||||
throw new UnsupportedOperationException();
|
||||
semanticServices.getErrorHandler().genericError(selectorExpression.getNode(), "Unsupported selector expression type: " + selectorExpression);
|
||||
}
|
||||
return receiverType;
|
||||
}
|
||||
@@ -1121,7 +1123,6 @@ public class JetTypeInferrer {
|
||||
}
|
||||
|
||||
scope.addPropertyDescriptor(propertyDescriptor);
|
||||
trace.recordDeclarationResolution(property, propertyDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ fun foo(o : `java::java.lang.Object`Object, l : `java::java.util`util.`java::jav
|
||||
|
||||
class B : `java::java.lang.Object`Object {
|
||||
fun bar(~o~o : `java::java.lang.Object`Object) {
|
||||
`java::java.lang.System`System.`java::java.lang.System.out`out.`java::java.io.PrintStream.print(Object)`print(`o`o)
|
||||
`java::java.lang.System`System.`java::java.lang.System.out`out.`java::java.io.PrintStream.print(Object)`print(`o`o)`:std::Unit`
|
||||
}
|
||||
|
||||
fun f(a : `java::java.util`util.`java::java.util.List`List) {}
|
||||
|
||||
@@ -108,16 +108,9 @@ public class ExpectedResolveData {
|
||||
|
||||
if ("!".equals(name)) {
|
||||
JetReferenceExpression referenceExpression = PsiTreeUtil.getParentOfType(element, JetReferenceExpression.class);
|
||||
JetExpression statement = referenceExpression;
|
||||
while (true) {
|
||||
PsiElement parent = statement.getParent();
|
||||
if (!(parent instanceof JetExpression)) break;
|
||||
if (parent instanceof JetBlockExpression) break;
|
||||
statement = (JetExpression) parent;
|
||||
}
|
||||
assertTrue(
|
||||
"Must have been unresolved: " + referenceExpression.getText() +
|
||||
" in " + statement.getText() +
|
||||
"Must have been unresolved: " +
|
||||
renderReferenceInContext(referenceExpression) +
|
||||
" but was resolved to " + DescriptorUtil.renderPresentableText(bindingContext.resolveReferenceExpression(referenceExpression)),
|
||||
unresolvedReferences.contains(referenceExpression));
|
||||
continue;
|
||||
@@ -157,7 +150,7 @@ public class ExpectedResolveData {
|
||||
}
|
||||
assertNotNull(reference);
|
||||
assertSame(
|
||||
"Reference `" + name + "`" + reference.getText() + " at " + reference.getTextOffset() + " is resolved into " + actualName + ".",
|
||||
"Reference `" + name + "`" + renderReferenceInContext(reference) + " is resolved into " + actualName + ".",
|
||||
expected, actual);
|
||||
}
|
||||
|
||||
@@ -196,12 +189,25 @@ public class ExpectedResolveData {
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull(expression.getText(), expressionType);
|
||||
assertNotNull(expression.getText() + " type is null", expressionType);
|
||||
assertSame("At " + position + ": ", expectedTypeConstructor, expressionType.getConstructor());
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T getAncestorOfType(Class<T> type, PsiElement element) {
|
||||
private static String renderReferenceInContext(JetReferenceExpression referenceExpression) {
|
||||
JetExpression statement = referenceExpression;
|
||||
while (true) {
|
||||
PsiElement parent = statement.getParent();
|
||||
if (!(parent instanceof JetExpression)) break;
|
||||
if (parent instanceof JetBlockExpression) break;
|
||||
statement = (JetExpression) parent;
|
||||
}
|
||||
JetDeclaration declaration = PsiTreeUtil.getParentOfType(referenceExpression, JetDeclaration.class);
|
||||
return referenceExpression.getText() +
|
||||
" in " + statement.getText() + (declaration == null ? "" : " in " + declaration.getText());
|
||||
}
|
||||
|
||||
private static <T> T getAncestorOfType(Class<T> type, PsiElement element) {
|
||||
while (element != null && !type.isInstance(element)) {
|
||||
element = element.getParent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user