$fieldName resolved
This commit is contained in:
@@ -38,4 +38,11 @@ public interface JetScope {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName);
|
Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param fieldName includes the "$"
|
||||||
|
* @return the property declaring this field, if any
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName);
|
||||||
}
|
}
|
||||||
@@ -54,4 +54,9 @@ public class JetScopeAdapter implements JetScope {
|
|||||||
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
|
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
|
||||||
return scope.getDeclarationsByLabel(labelName);
|
return scope.getDeclarationsByLabel(labelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||||
|
return scope.getPropertyByFieldReference(fieldName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -42,4 +42,9 @@ public abstract class JetScopeImpl implements JetScope {
|
|||||||
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
|
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,4 +73,9 @@ public class SubstitutingScope implements JetScope {
|
|||||||
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
|
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
|
||||||
throw new UnsupportedOperationException(); // TODO
|
throw new UnsupportedOperationException(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||||
|
throw new UnsupportedOperationException(); // TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ public class TopDownAnalyzer {
|
|||||||
declaringScopes.put(property, declaringScope);
|
declaringScopes.put(property, declaringScope);
|
||||||
PropertyDescriptor descriptor = classDescriptorResolver.resolvePropertyDescriptor(declaringScope.getContainingDeclaration(), declaringScope, property);
|
PropertyDescriptor descriptor = classDescriptorResolver.resolvePropertyDescriptor(declaringScope.getContainingDeclaration(), declaringScope, property);
|
||||||
declaringScope.addVariableDescriptor(descriptor);
|
declaringScope.addVariableDescriptor(descriptor);
|
||||||
|
declaringScope.addPropertyDescriptorByFieldName("$" + descriptor.getName(), descriptor);
|
||||||
properties.put(property, descriptor);
|
properties.put(property, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ public class WritableScope extends JetScopeAdapter {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final DeclarationDescriptor ownerDeclarationDescriptor;
|
private final DeclarationDescriptor ownerDeclarationDescriptor;
|
||||||
|
|
||||||
|
// FieldNames include "$"
|
||||||
|
@Nullable
|
||||||
|
private Map<String, PropertyDescriptor> propertyDescriptorsByFieldNames;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Map<String, VariableDescriptor> variableDescriptors;
|
private Map<String, VariableDescriptor> variableDescriptors;
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -270,4 +274,24 @@ public class WritableScope extends JetScopeAdapter {
|
|||||||
}
|
}
|
||||||
this.thisType = thisType;
|
this.thisType = thisType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"NullableProblems"})
|
||||||
|
@NotNull
|
||||||
|
private Map<String, PropertyDescriptor> getPropertyDescriptorsByFieldNames() {
|
||||||
|
if (propertyDescriptorsByFieldNames == null) {
|
||||||
|
propertyDescriptorsByFieldNames = new HashMap<String, PropertyDescriptor>();
|
||||||
|
}
|
||||||
|
return propertyDescriptorsByFieldNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPropertyDescriptorByFieldName(@NotNull String fieldName, PropertyDescriptor propertyDescriptor) {
|
||||||
|
getPropertyDescriptorsByFieldNames().put(fieldName, propertyDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||||
|
PropertyDescriptor descriptor = getPropertyDescriptorsByFieldNames().get(fieldName);
|
||||||
|
if (descriptor != null) return descriptor;
|
||||||
|
return super.getPropertyByFieldReference(fieldName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ public class JavaClassMembersScope implements JetScope {
|
|||||||
throw new UnsupportedOperationException(); // TODO
|
throw new UnsupportedOperationException(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||||
for (PsiClass innerClass : psiClass.getAllInnerClasses()) {
|
for (PsiClass innerClass : psiClass.getAllInnerClasses()) {
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ public class ErrorUtils {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
|
||||||
|
return null; // TODO : review
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final FunctionGroup ERROR_FUNCTION_GROUP = new FunctionGroup() {
|
private static final FunctionGroup ERROR_FUNCTION_GROUP = new FunctionGroup() {
|
||||||
|
|||||||
@@ -440,25 +440,38 @@ public class JetTypeInferrer {
|
|||||||
public void visitSimpleNameExpression(JetSimpleNameExpression expression) {
|
public void visitSimpleNameExpression(JetSimpleNameExpression expression) {
|
||||||
// TODO : other members
|
// TODO : other members
|
||||||
// TODO : type substitutions???
|
// TODO : type substitutions???
|
||||||
String referencedName = expression.getReferencedName();
|
if (expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
|
||||||
if (referencedName != null) {
|
PropertyDescriptor property = scope.getPropertyByFieldReference(expression.getReferencedName());
|
||||||
VariableDescriptor variable = scope.getVariable(referencedName);
|
if (property == null) {
|
||||||
if (variable != null) {
|
semanticServices.getErrorHandler().unresolvedReference(expression);
|
||||||
trace.recordReferenceResolution(expression, variable);
|
}
|
||||||
result = variable.getOutType();
|
else {
|
||||||
if (result == null) {
|
trace.recordReferenceResolution(expression, property);
|
||||||
semanticServices.getErrorHandler().genericError(expression.getNode(), "This variable is not readable in this context");
|
result = property.getOutType();
|
||||||
}
|
}
|
||||||
return;
|
}
|
||||||
} else {
|
else {
|
||||||
NamespaceDescriptor namespace = scope.getNamespace(referencedName);
|
assert expression.getReferencedNameElementType() == JetTokens.IDENTIFIER;
|
||||||
if (namespace != null) {
|
String referencedName = expression.getReferencedName();
|
||||||
trace.recordReferenceResolution(expression, namespace);
|
if (referencedName != null) {
|
||||||
result = namespace.getNamespaceType();
|
VariableDescriptor variable = scope.getVariable(referencedName);
|
||||||
return;
|
if (variable != null) {
|
||||||
}
|
trace.recordReferenceResolution(expression, variable);
|
||||||
|
result = variable.getOutType();
|
||||||
|
if (result == null) {
|
||||||
|
semanticServices.getErrorHandler().genericError(expression.getNode(), "This variable is not readable in this context");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
NamespaceDescriptor namespace = scope.getNamespace(referencedName);
|
||||||
|
if (namespace != null) {
|
||||||
|
trace.recordReferenceResolution(expression, namespace);
|
||||||
|
result = namespace.getNamespaceType();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
semanticServices.getErrorHandler().unresolvedReference(expression);
|
||||||
}
|
}
|
||||||
semanticServices.getErrorHandler().unresolvedReference(expression);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
var x : Int = 1 + x
|
var x : Int = 1 + x
|
||||||
get() : Int = 1
|
get() : Int = 1
|
||||||
set(<error>ref</error> value : <error>Long</error>) {$x = value}
|
set(<error>ref</error> value : <error>Long</error>) {
|
||||||
|
$x = value.int
|
||||||
|
$x = <error>1.lng</error>
|
||||||
|
}
|
||||||
|
|
||||||
val xx : Int = 1 + x
|
val xx : Int = 1 + x
|
||||||
get() : Int = 1
|
get() : Int = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user