mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AST] Remove stored TypeLoc from TypedPattern (#19175)
* [AST] Remove stored TypeLoc from TypedPattern TypedPattern was only using this TypeLoc as a means to a TypeRepr, which caused it to store the pattern type twice (through the superclass and through the TypeLoc itself.) This also fixes a bug where deserializing a TypedPattern doesn't store the type correctly and generally cleans up TypedPattern initialization. Resolves rdar://44144435 * Address review comments
This commit is contained in:
@@ -221,7 +221,7 @@ static DeclRefExpr *convertEnumToIndex(SmallVectorImpl<ASTNode> &stmts,
|
||||
// generate: var indexVar
|
||||
Pattern *indexPat = new (C) NamedPattern(indexVar, /*implicit*/ true);
|
||||
indexPat->setType(intType);
|
||||
indexPat = new (C) TypedPattern(indexPat, TypeLoc::withoutLoc(intType));
|
||||
indexPat = TypedPattern::createImplicit(C, indexPat, intType);
|
||||
indexPat->setType(intType);
|
||||
auto *indexBind = PatternBindingDecl::createImplicit(
|
||||
C, StaticSpellingKind::None, indexPat, /*InitExpr*/ nullptr, funcDecl);
|
||||
@@ -1105,9 +1105,7 @@ static ValueDecl *deriveHashable_hashValue(DerivedConformance &derived) {
|
||||
|
||||
Pattern *hashValuePat = new (C) NamedPattern(hashValueDecl, /*implicit*/true);
|
||||
hashValuePat->setType(intType);
|
||||
hashValuePat
|
||||
= new (C) TypedPattern(hashValuePat, TypeLoc::withoutLoc(intType),
|
||||
/*implicit*/ true);
|
||||
hashValuePat = TypedPattern::createImplicit(C, hashValuePat, intType);
|
||||
hashValuePat->setType(intType);
|
||||
|
||||
auto *patDecl = PatternBindingDecl::createImplicit(
|
||||
|
||||
Reference in New Issue
Block a user