Skip to content

Commit 17f12da

Browse files
committed
[NFC] AST: Remove TypedPattern:getTypeLoc()
1 parent b26310e commit 17f12da

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

include/swift/AST/Pattern.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ namespace swift {
3434
class Expr;
3535
enum class CheckedCastKind : unsigned;
3636
class TypeExpr;
37-
class TypeLoc;
3837

3938
/// PatternKind - The classification of different kinds of
4039
/// value-matching pattern.
@@ -447,7 +446,6 @@ class TypedPattern : public Pattern {
447446

448447
TypeRepr *getTypeRepr() const { return PatTypeRepr; }
449448

450-
TypeLoc getTypeLoc() const;
451449
SourceLoc getLoc() const;
452450
SourceRange getSourceRange() const;
453451

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,9 @@ void PrintAST::printTypedPattern(const TypedPattern *TP) {
10791079
if (auto decl = named->getDecl())
10801080
isIUO = decl->isImplicitlyUnwrappedOptional();
10811081

1082-
printTypeLocForImplicitlyUnwrappedOptional(TP->getTypeLoc(), isIUO);
1082+
const auto TyLoc = TypeLoc(TP->getTypeRepr(),
1083+
TP->hasType() ? TP->getType() : Type());
1084+
printTypeLocForImplicitlyUnwrappedOptional(TyLoc, isIUO);
10831085
}
10841086

10851087
/// Determines if we are required to print the name of a property declaration,

lib/AST/Pattern.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,6 @@ TypedPattern::TypedPattern(Pattern *pattern, TypeRepr *tr)
406406
Bits.TypedPattern.IsPropagatedType = false;
407407
}
408408

409-
TypeLoc TypedPattern::getTypeLoc() const {
410-
TypeLoc loc = TypeLoc(PatTypeRepr);
411-
412-
if (hasType())
413-
loc.setType(getType());
414-
415-
return loc;
416-
}
417-
418409
SourceLoc TypedPattern::getLoc() const {
419410
if (SubPattern->isImplicit() && PatTypeRepr)
420411
return PatTypeRepr->getSourceRange().Start;

lib/Sema/ConstraintSystem.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4639,8 +4639,10 @@ SolutionApplicationTarget SolutionApplicationTarget::forInitialization(
46394639
if (auto *typedPattern = dyn_cast<TypedPattern>(pattern)) {
46404640
const Pattern *inner = typedPattern->getSemanticsProvidingPattern();
46414641
if (isa<NamedPattern>(inner) || isa<AnyPattern>(inner)) {
4642-
contextualType = typedPattern->getTypeLoc();
4643-
if (!contextualType.getType())
4642+
contextualType = TypeLoc(typedPattern->getTypeRepr());
4643+
if (typedPattern->hasType())
4644+
contextualType.setType(typedPattern->getType());
4645+
else
46444646
contextualType.setType(patternType);
46454647
}
46464648
}

lib/Sema/TypeCheckAccess.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,8 @@ class AccessControlChecker : public AccessControlCheckerBase,
497497
if (!anyVar)
498498
return;
499499

500-
checkTypeAccess(TP->getTypeLoc(), anyVar, /*mayBeInferred*/true,
500+
checkTypeAccess(TP->hasType() ? TP->getType() : Type(),
501+
TP->getTypeRepr(), anyVar, /*mayBeInferred*/true,
501502
[&](AccessScope typeAccessScope,
502503
const TypeRepr *complainRepr,
503504
DowngradeToWarning downgradeToWarning) {
@@ -1117,7 +1118,8 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
11171118
return;
11181119

11191120
checkTypeAccess(
1120-
TP->getTypeLoc(),
1121+
TP->hasType() ? TP->getType() : Type(),
1122+
TP->getTypeRepr(),
11211123
fixedLayoutStructContext ? fixedLayoutStructContext : anyVar,
11221124
/*mayBeInferred*/ true,
11231125
[&](AccessScope typeAccessScope, const TypeRepr *complainRepr,
@@ -1835,7 +1837,8 @@ class ExportabilityChecker : public DeclVisitor<ExportabilityChecker> {
18351837
if (shouldSkipChecking(anyVar))
18361838
return;
18371839

1838-
checkType(TP->getTypeLoc(), anyVar, getDiagnoser(anyVar));
1840+
checkType(TP->hasType() ? TP->getType() : Type(),
1841+
TP->getTypeRepr(), anyVar, getDiagnoser(anyVar));
18391842

18401843
// Check the property wrapper types.
18411844
for (auto attr : anyVar->getAttachedPropertyWrappers())

0 commit comments

Comments
 (0)