TypeChecker: Minor simplifications for operators and using for

This commit is contained in:
wechman 2022-09-23 13:35:38 +02:00 committed by Kamil Śliwak
parent 1dd05e2978
commit 27df07c4ce

View File

@ -1751,7 +1751,9 @@ bool TypeChecker::visit(UnaryOperation const& _operation)
else else
_operation.annotation().type = result.get(); _operation.annotation().type = result.get();
_operation.annotation().isConstant = false; _operation.annotation().isConstant = false;
_operation.annotation().isPure = !modifying && *_operation.subExpression().annotation().isPure; _operation.annotation().isPure =
!modifying &&
*_operation.subExpression().annotation().isPure;
_operation.annotation().isLValue = false; _operation.annotation().isLValue = false;
return false; return false;
@ -3750,8 +3752,9 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
solAssert(m_errorReporter.hasErrors()); solAssert(m_errorReporter.hasErrors());
return; return;
} }
solAssert(_usingFor.typeName()->annotation().type); Type const* usingForType = _usingFor.typeName()->annotation().type;
if (Declaration const* typeDefinition = _usingFor.typeName()->annotation().type->typeDefinition()) solAssert(usingForType);
if (Declaration const* typeDefinition = usingForType->typeDefinition())
{ {
if (typeDefinition->scope() != m_currentSourceUnit) if (typeDefinition->scope() != m_currentSourceUnit)
m_errorReporter.typeError( m_errorReporter.typeError(
@ -3785,10 +3788,12 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
return; return;
} }
solAssert(_usingFor.typeName()->annotation().type); Type const* usingForType = _usingFor.typeName()->annotation().type;
solAssert(usingForType);
Type const* normalizedType = TypeProvider::withLocationIfReference( Type const* normalizedType = TypeProvider::withLocationIfReference(
DataLocation::Storage, DataLocation::Storage,
_usingFor.typeName()->annotation().type usingForType
); );
solAssert(normalizedType); solAssert(normalizedType);
@ -3824,7 +3829,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
"The function \"{}\" cannot be bound to the type \"{}\" because the type cannot " "The function \"{}\" cannot be bound to the type \"{}\" because the type cannot "
"be implicitly converted to the first argument of the function (\"{}\"){}", "be implicitly converted to the first argument of the function (\"{}\"){}",
joinHumanReadable(path->path(), "."), joinHumanReadable(path->path(), "."),
_usingFor.typeName()->annotation().type->toString(true /* withoutDataLocation */), usingForType->toString(true /* withoutDataLocation */),
functionType->selfType()->humanReadableName(), functionType->selfType()->humanReadableName(),
result.message().empty() ? "." : ": " + result.message() result.message().empty() ? "." : ": " + result.message()
) )