Turn unreachable error into assert

The exact conditions are already checked when iterating over the
possibleMembers where the function `canTakeArguments()` is called
for each member. The function does the identical check.
This commit is contained in:
Mathias Baumann 2019-02-12 11:41:05 +01:00
parent 10888b21d8
commit a70fee7316

View File

@ -2090,12 +2090,11 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
annotation.type = possibleMembers.front().type; annotation.type = possibleMembers.front().type;
if (auto funType = dynamic_cast<FunctionType const*>(annotation.type.get())) if (auto funType = dynamic_cast<FunctionType const*>(annotation.type.get()))
if (funType->bound() && !exprType->isImplicitlyConvertibleTo(*funType->selfType())) solAssert(
m_errorReporter.typeError( !funType->bound() || exprType->isImplicitlyConvertibleTo(*funType->selfType()),
_memberAccess.location(), "Function \"" + memberName + "\" cannot be called on an object of type " +
"Function \"" + memberName + "\" cannot be called on an object of type " + exprType->toString() + " (expected " + funType->selfType()->toString() + ")."
exprType->toString() + " (expected " + funType->selfType()->toString() + ")." );
);
if (auto const* structType = dynamic_cast<StructType const*>(exprType.get())) if (auto const* structType = dynamic_cast<StructType const*>(exprType.get()))
annotation.isLValue = !structType->dataStoredIn(DataLocation::CallData); annotation.isLValue = !structType->dataStoredIn(DataLocation::CallData);