diff --git a/.idea/dictionaries/abreslav.xml b/.idea/dictionaries/abreslav.xml index db3d985c5e2..5a2eeed92c5 100644 --- a/.idea/dictionaries/abreslav.xml +++ b/.idea/dictionaries/abreslav.xml @@ -1,6 +1,7 @@ + accessor inferrer nullable substitutor diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java index 92ed1abf9d8..63c6902b960 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java @@ -1092,7 +1092,29 @@ public class JetTypeInferrer { @Override public void visitProperty(JetProperty property) { + + JetPropertyAccessor getter = property.getGetter(); + if (getter != null) { + semanticServices.getErrorHandler().genericError(getter.getNode(), "Local variables are not allowed to have getters"); + } + + JetPropertyAccessor setter = property.getSetter(); + if (setter != null) { + semanticServices.getErrorHandler().genericError(setter.getNode(), "Local variables are not allowed to have setters"); + } + PropertyDescriptor propertyDescriptor = classDescriptorResolver.resolvePropertyDescriptor(scope.getContainingDeclaration(), scope, property); + JetExpression initializer = property.getInitializer(); + if (property.getPropertyTypeRef() != null && initializer != null) { + JetType initializerType = getType(scope, initializer, false); + JetType outType = propertyDescriptor.getOutType(); + if (outType != null && + initializerType != null && + !semanticServices.getTypeChecker().isConvertibleTo(initializerType, outType)) { + semanticServices.getErrorHandler().typeMismatch(initializer, outType, initializerType); + } + } + scope.addPropertyDescriptor(propertyDescriptor); trace.recordDeclarationResolution(property, propertyDescriptor); }