sema: accept enum element reference as compile-time const value

This commit is contained in:
Xi Ge
2021-11-29 22:48:49 -08:00
parent 709d9b98dd
commit fdcb08ead2
3 changed files with 51 additions and 4 deletions

View File

@@ -1506,8 +1506,17 @@ ConstraintSystem::TypeMatchResult constraints::matchCallArguments(
}
if (!argument.isCompileTimeConst() && param.isCompileTimeConst()) {
if (cs.shouldAttemptFixes()) {
cs.recordFix(NotCompileTimeConst::create(cs, paramTy,
cs.getConstraintLocator(loc)));
auto *locator = cs.getConstraintLocator(loc);
SourceRange range;
// simplify locator so the anchor is the exact argument.
locator = simplifyLocator(cs, locator, range);
if (locator->getPath().empty() &&
locator->getAnchor().isExpr(ExprKind::UnresolvedMemberChainResult)) {
locator =
cs.getConstraintLocator(cast<UnresolvedMemberChainResultExpr>(
locator->getAnchor().get<Expr*>())->getChainBase());
}
cs.recordFix(NotCompileTimeConst::create(cs, paramTy, locator));
}
}