[Sema]Construct type refinement hierarchy for other source files

Resolving signatures of declarations from files other than the primary source
file causes first-pass type checking, including diagnostics for potential
unavailability, to be performed on those declarations. Prior to this commit, the
type refinement context hierarchy was only constructed for the primary file, so
spurious errors were emitted when checking declarations in other files. With
this commit, the availability checker builds the hierarchy for a source file the
first time its hierarchy is queried. We will eventually want to build the
hierarchy more lazily, but that will come later.

Swift SVN r25746
This commit is contained in:
Devin Coughlin
2015-03-04 05:36:48 +00:00
parent 9ed3a4a196
commit 6b5a3d775e
8 changed files with 163 additions and 14 deletions

View File

@@ -811,6 +811,8 @@ private:
mutable Identifier PrivateDiscriminator;
/// The root TypeRefinementContext for this SourceFile.
///
/// This is set during type checking.
TypeRefinementContext *TRC = nullptr;
/// If non-null, used to track name lookups that happen within this file.
@@ -1006,9 +1008,14 @@ public:
return isScriptMode() || hasMainClass();
}
/// Get the root refinement context for the file.
/// Get the root refinement context for the file. The root context may be
/// null if the context hierarchy has not been built yet. Use
/// TypeChecker::getOrBuildTypeRefinementContext() to get a built
/// root of the hierarchy.
TypeRefinementContext *getTypeRefinementContext();
/// Set the root refinement context for the file.
void setTypeRefinementContext(TypeRefinementContext *TRC);
};