Initializer checking fixed
This commit is contained in:
@@ -863,19 +863,12 @@ public class TopDownAnalyzer {
|
|||||||
JetTypeInferrer.Services typeInferrer = semanticServices.getTypeInferrerServices(traceForConstructors, flowInformationProvider);
|
JetTypeInferrer.Services typeInferrer = semanticServices.getTypeInferrerServices(traceForConstructors, flowInformationProvider);
|
||||||
JetType type = typeInferrer.getType(getPropertyDeclarationInnerScope(scope, propertyDescriptor), initializer, NO_EXPECTED_TYPE);
|
JetType type = typeInferrer.getType(getPropertyDeclarationInnerScope(scope, propertyDescriptor), initializer, NO_EXPECTED_TYPE);
|
||||||
|
|
||||||
JetType expectedType;
|
JetType expectedType = propertyDescriptor.getInType();
|
||||||
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
if (expectedType == null) {
|
||||||
if (setter != null) {
|
expectedType = propertyDescriptor.getOutType();
|
||||||
expectedType = setter.getReturnType();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
expectedType = propertyDescriptor.getInType();
|
|
||||||
if (expectedType == null) {
|
|
||||||
expectedType = propertyDescriptor.getOutType();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (type != null && expectedType != null
|
if (type != null && expectedType != null
|
||||||
&& !semanticServices.getTypeChecker().isConvertibleTo(type, expectedType)) {
|
&& !semanticServices.getTypeChecker().isSubtypeOf(type, expectedType)) {
|
||||||
trace.getErrorHandler().typeMismatch(initializer, expectedType, type);
|
trace.getErrorHandler().typeMismatch(initializer, expectedType, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -888,7 +881,7 @@ public class TopDownAnalyzer {
|
|||||||
JetScope declaringScope = declaringScopes.get(declaration);
|
JetScope declaringScope = declaringScopes.get(declaration);
|
||||||
assert declaringScope != null;
|
assert declaringScope != null;
|
||||||
|
|
||||||
resolveFunctionBody(traceForMembers, (JetNamedFunction) declaration, (FunctionDescriptorImpl) descriptor, declaringScope);
|
resolveFunctionBody(traceForMembers, (JetNamedFunction) declaration, descriptor, declaringScope);
|
||||||
|
|
||||||
assert descriptor.getReturnType() != null;
|
assert descriptor.getReturnType() != null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user