Skip to content

Commit 7f94bbf

Browse files
committed
[AST] NFC: Drop Type from TypeBase::isCGFloatType
This makes naming consistent with other accessors e.g. `isDouble`
1 parent 9e3a058 commit 7f94bbf

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ class alignas(1 << TypeAlignInBits) TypeBase
802802

803803
/// Check if this is a CGFloat type from CoreGraphics framework
804804
/// on macOS or Foundation on Linux.
805-
bool isCGFloatType();
805+
bool isCGFloat();
806806

807807
/// Check if this is either an Array, Set or Dictionary collection type defined
808808
/// at the top level of the Swift module

lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ bool TypeBase::isStdlibType() {
813813
return false;
814814
}
815815

816-
bool TypeBase::isCGFloatType() {
816+
bool TypeBase::isCGFloat() {
817817
auto *NTD = getAnyNominal();
818818
if (!NTD)
819819
return false;

lib/Sema/CSBindings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ void BindingSet::addBinding(PotentialBinding binding) {
548548
if (!TypeVar->getImpl().isClosureParameterType()) {
549549
auto type = binding.BindingType;
550550

551-
if (type->isCGFloatType() &&
551+
if (type->isCGFloat() &&
552552
llvm::any_of(Bindings, [](const PotentialBinding &binding) {
553553
return binding.BindingType->isDouble();
554554
}))
@@ -557,7 +557,7 @@ void BindingSet::addBinding(PotentialBinding binding) {
557557
if (type->isDouble()) {
558558
auto inferredCGFloat =
559559
llvm::find_if(Bindings, [](const PotentialBinding &binding) {
560-
return binding.BindingType->isCGFloatType();
560+
return binding.BindingType->isCGFloat();
561561
});
562562

563563
if (inferredCGFloat != Bindings.end()) {

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,8 +2422,8 @@ bool ContextualFailure::diagnoseAsError() {
24222422
// If this is an attempt at a Double <-> CGFloat conversion
24232423
// through optional chaining, let's produce a tailored diagnostic.
24242424
if (isExpr<OptionalEvaluationExpr>(getAnchor())) {
2425-
if ((fromType->isDouble() || fromType->isCGFloatType()) &&
2426-
(toType->isDouble() || toType->isCGFloatType())) {
2425+
if ((fromType->isDouble() || fromType->isCGFloat()) &&
2426+
(toType->isDouble() || toType->isCGFloat())) {
24272427
fromType = OptionalType::get(fromType);
24282428
toType = OptionalType::get(toType);
24292429
diagnostic = diag::cannot_implicitly_convert_in_optional_context;

lib/Sema/CSGen.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ namespace {
383383
return true;
384384

385385
// Don't favor narrowing conversions.
386-
if (argTy->isDouble() && paramTy->isCGFloatType())
386+
if (argTy->isDouble() && paramTy->isCGFloat())
387387
return false;
388388

389389
llvm::SmallSetVector<ProtocolDecl *, 2> literalProtos;
@@ -420,7 +420,7 @@ namespace {
420420
// it is the same as the parameter type.
421421
// Check whether there is a default type to compare against.
422422
if (paramTy->isEqual(defaultType) ||
423-
(defaultType->isDouble() && paramTy->isCGFloatType()))
423+
(defaultType->isDouble() && paramTy->isCGFloat()))
424424
return true;
425425
}
426426
}
@@ -560,7 +560,7 @@ namespace {
560560
// in order to preserve current behavior, let's not favor overloads
561561
// which would result in conversion from CGFloat to Double; otherwise
562562
// it would lead to ambiguities.
563-
if (argTy->isCGFloatType() && paramTy->isDouble())
563+
if (argTy->isCGFloat() && paramTy->isDouble())
564564
return false;
565565

566566
return isFavoredParamAndArg(CS, paramTy, argTy) &&
@@ -719,10 +719,10 @@ namespace {
719719
// Avoid favoring overloads that would require narrowing conversion
720720
// to match the arguments.
721721
{
722-
if (firstArgTy->isDouble() && firstParamTy->isCGFloatType())
722+
if (firstArgTy->isDouble() && firstParamTy->isCGFloat())
723723
return false;
724724

725-
if (secondArgTy->isDouble() && secondParamTy->isCGFloatType())
725+
if (secondArgTy->isDouble() && secondParamTy->isCGFloat())
726726
return false;
727727
}
728728

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5474,7 +5474,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
54745474

54755475
if (kind >= ConstraintKind::Subtype &&
54765476
nominal1->getDecl() != nominal2->getDecl() &&
5477-
((nominal1->isCGFloatType() || nominal2->isCGFloatType()) &&
5477+
((nominal1->isCGFloat() || nominal2->isCGFloat()) &&
54785478
(nominal1->isDouble() || nominal2->isDouble()))) {
54795479
ConstraintLocatorBuilder location{locator};
54805480
// Look through all value-to-optional promotions to allow
@@ -5532,7 +5532,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
55325532
auto isCGFloatInit = [&](ASTNode location) {
55335533
if (auto *call = getAsExpr<CallExpr>(location)) {
55345534
if (auto *typeExpr = dyn_cast<TypeExpr>(call->getFn())) {
5535-
return getInstanceType(typeExpr)->isCGFloatType();
5535+
return getInstanceType(typeExpr)->isCGFloat();
55365536
}
55375537
}
55385538
return false;
@@ -5561,7 +5561,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
55615561
return false;
55625562
})) {
55635563
conversionsOrFixes.push_back(
5564-
desugar1->isCGFloatType()
5564+
desugar1->isCGFloat()
55655565
? ConversionRestrictionKind::CGFloatToDouble
55665566
: ConversionRestrictionKind::DoubleToCGFloat);
55675567
}

0 commit comments

Comments
 (0)