Skip to content

Commit 6de2e63

Browse files
authored
Merge pull request swiftlang#39774 from xedin/fix-no-assert-warnings
[Sema] Fix unused function/variable warnings in no-assertion configuration
2 parents 8359c4c + 84fa8a3 commit 6de2e63

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

lib/Sema/CSDiagnostics.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,11 @@ class MissingConformanceFailure final : public RequirementFailure {
351351
std::pair<Type, Type> conformance)
352352
: RequirementFailure(solution, conformance.first, conformance.second,
353353
locator) {
354+
#ifndef NDEBUG
354355
auto reqElt = locator->castLastElementTo<LocatorPathElt::AnyRequirement>();
355356
assert(reqElt.getRequirementKind() == RequirementKind::Conformance ||
356357
reqElt.getRequirementKind() == RequirementKind::Layout);
358+
#endif
357359
}
358360

359361
bool diagnoseAsError() override;
@@ -408,8 +410,10 @@ class SameTypeRequirementFailure final : public RequirementFailure {
408410
SameTypeRequirementFailure(const Solution &solution, Type lhs, Type rhs,
409411
ConstraintLocator *locator)
410412
: RequirementFailure(solution, lhs, rhs, locator) {
413+
#ifndef NDEBUG
411414
auto reqElt = locator->castLastElementTo<LocatorPathElt::AnyRequirement>();
412415
assert(reqElt.getRequirementKind() == RequirementKind::SameType);
416+
#endif
413417
}
414418

415419
protected:
@@ -444,8 +448,10 @@ class SuperclassRequirementFailure final : public RequirementFailure {
444448
SuperclassRequirementFailure(const Solution &solution, Type lhs, Type rhs,
445449
ConstraintLocator *locator)
446450
: RequirementFailure(solution, lhs, rhs, locator) {
451+
#ifndef NDEBUG
447452
auto reqElt = locator->castLastElementTo<LocatorPathElt::AnyRequirement>();
448453
assert(reqElt.getRequirementKind() == RequirementKind::Superclass);
454+
#endif
449455
}
450456

451457
protected:
@@ -869,9 +875,11 @@ class ThrowingFunctionConversionFailure final : public ContextualFailure {
869875
ThrowingFunctionConversionFailure(const Solution &solution, Type fromType,
870876
Type toType, ConstraintLocator *locator)
871877
: ContextualFailure(solution, fromType, toType, locator) {
878+
#ifndef NDEBUG
872879
auto fnType1 = fromType->castTo<FunctionType>();
873880
auto fnType2 = toType->castTo<FunctionType>();
874881
assert(fnType1->isThrowing() != fnType2->isThrowing());
882+
#endif
875883
}
876884

877885
bool diagnoseAsError() override;
@@ -890,9 +898,11 @@ class AsyncFunctionConversionFailure final : public ContextualFailure {
890898
AsyncFunctionConversionFailure(const Solution &solution, Type fromType,
891899
Type toType, ConstraintLocator *locator)
892900
: ContextualFailure(solution, fromType, toType, locator) {
901+
#ifndef NDEBUG
893902
auto fnType1 = fromType->castTo<FunctionType>();
894903
auto fnType2 = toType->castTo<FunctionType>();
895904
assert(fnType1->isAsync() != fnType2->isAsync());
905+
#endif
896906
}
897907

898908
bool diagnoseAsError() override;

lib/Sema/ConstraintSystem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4779,6 +4779,7 @@ ArgumentList *Solution::getArgumentList(ConstraintLocator *locator) const {
47794779
return nullptr;
47804780
}
47814781

4782+
#ifndef NDEBUG
47824783
/// Given an apply expr, returns true if it is expected to have a direct callee
47834784
/// overload, resolvable using `getChoiceFor`. Otherwise, returns false.
47844785
static bool shouldHaveDirectCalleeOverload(const CallExpr *callExpr) {
@@ -4807,6 +4808,7 @@ static bool shouldHaveDirectCalleeOverload(const CallExpr *callExpr) {
48074808
// Assume that anything else would have a direct callee.
48084809
return true;
48094810
}
4811+
#endif
48104812

48114813
Type Solution::resolveInterfaceType(Type type) const {
48124814
auto resolvedType = type.transform([&](Type type) -> Type {
@@ -4856,9 +4858,11 @@ Solution::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
48564858
if (!applyArgElt)
48574859
return None;
48584860

4861+
#ifndef NDEBUG
48594862
auto nextIter = iter + 1;
48604863
assert(!locator->findLast<LocatorPathElt::ApplyArgToParam>(nextIter) &&
48614864
"Multiple ApplyArgToParam components?");
4865+
#endif
48624866

48634867
// Form a new locator that ends at the apply-arg-to-param element, and
48644868
// simplify it to get the full argument expression.
@@ -5778,9 +5782,11 @@ getRequirementInfo(ConstraintSystem &cs, ConstraintLocator *reqLocator) {
57785782

57795783
auto path = reqLocator->getPath();
57805784
auto iter = path.rbegin();
5785+
57815786
auto openedGeneric =
57825787
reqLocator->findLast<LocatorPathElt::OpenedGeneric>(iter);
57835788
assert(openedGeneric);
5789+
(void)openedGeneric;
57845790

57855791
auto newPath = path.drop_back(iter - path.rbegin() + 1);
57865792
auto *baseLoc = cs.getConstraintLocator(reqLocator->getAnchor(), newPath);

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,10 @@ CheckedCastKind TypeChecker::typeCheckCheckedCast(Type fromType,
14991499
case BridgingCoercion:
15001500
return CheckedCastKind::BridgingCoercion;
15011501
}
1502+
15021503
assert(hasCoercion && "Not a coercion?");
1504+
(void)hasCoercion;
1505+
15031506
return CheckedCastKind::Coercion;
15041507
}
15051508
}

0 commit comments

Comments
 (0)