[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:
Harlan
2018-09-07 21:14:04 -07:00
committed by GitHub
parent 0dd56dfda1
commit eb75ad80dc
11 changed files with 102 additions and 97 deletions

View File

@@ -381,9 +381,11 @@ Expected<Pattern *> ModuleFile::readPattern(DeclContext *owningDC) {
return subPattern;
}
auto result = new (getContext()) TypedPattern(subPattern.get(), TypeLoc(),
auto type = getType(typeID);
auto result = new (getContext()) TypedPattern(subPattern.get(),
/*typeRepr*/nullptr,
isImplicit);
recordPatternType(result, getType(typeID));
recordPatternType(result, type);
restoreOffset.reset();
return result;
}