From 8ec634e7873525d62e01163dff48ded4df51e46c Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Sat, 28 Mar 2020 15:11:14 -0700 Subject: [PATCH 1/5] [ASTVerifier] NFC: Remove verifyBound This isn't used for anything. --- lib/AST/ASTVerifier.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/AST/ASTVerifier.cpp b/lib/AST/ASTVerifier.cpp index 2fe478a3ecfc4..e0be48546c946 100644 --- a/lib/AST/ASTVerifier.cpp +++ b/lib/AST/ASTVerifier.cpp @@ -419,10 +419,6 @@ class Verifier : public ASTWalker { // Always verify the node as a parsed node. verifyParsed(node); - // If we've bound names already, verify as a bound node. - if (!SF || SF->ASTStage >= SourceFile::NameBound) - verifyBound(node); - // If we've checked types already, do some extra verification. if (!SF || SF->ASTStage >= SourceFile::TypeChecked) { verifyCheckedAlways(node); @@ -523,11 +519,6 @@ class Verifier : public ASTWalker { verifyParsed(cast::BaseTy>(ASTNode)); } - void verifyBound(Expr *E) {} - void verifyBound(Stmt *S) {} - void verifyBound(Pattern *P) {} - void verifyBound(Decl *D) {} - /// @{ /// These verification functions are always run on type checked ASTs /// (even if there were errors). From e8cbe76cba7e1b8385053c7152a7986ec2f3ed11 Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Fri, 27 Mar 2020 15:22:04 -0700 Subject: [PATCH 2/5] NFC: Fix NameBinding indentation --- lib/Sema/NameBinding.cpp | 394 +++++++++++++++++++-------------------- 1 file changed, 197 insertions(+), 197 deletions(-) diff --git a/lib/Sema/NameBinding.cpp b/lib/Sema/NameBinding.cpp index 69018ad651d54..8fe4065c79ac2 100644 --- a/lib/Sema/NameBinding.cpp +++ b/lib/Sema/NameBinding.cpp @@ -50,211 +50,211 @@ using ImportOptions = SourceFile::ImportOptions; using ImportFlags = SourceFile::ImportFlags; namespace { - /// Represents an import which the NameBinder knows exists, but which has not - /// yet had its options checked, module loaded, or cross-imports found. +/// Represents an import which the NameBinder knows exists, but which has not +/// yet had its options checked, module loaded, or cross-imports found. +/// +/// An UnboundImport may represent a physical ImportDecl written in the +/// source, or it may represent a cross-import overlay that has been found and +/// needs to be loaded. +struct UnboundImport { + /// The source location to use when diagnosing errors for this import. + SourceLoc importLoc; + + /// The options for this import, such as "exported" or + /// "implementation-only". Use this field, not \c attrs, to determine the + /// behavior expected for this import. + ImportOptions options; + + /// If \c options includes \c PrivateImport, the filename we should import + /// private declarations from. + StringRef privateImportFileName; + + /// The module names being imported. There will usually be just one for the + /// top-level module, but a submodule import will have more. + ModuleDecl::AccessPathTy modulePath; + + /// If this is a scoped import, the names of the declaration being imported; + /// otherwise empty. (Currently the compiler doesn't support nested scoped + /// imports, so there should always be zero or one elements, but + /// \c AccessPathTy is the common currency type for this.) + ModuleDecl::AccessPathTy declPath; + + // Names of explicitly imported SPI groups via @_spi. + ArrayRef spiGroups; + + /// If this UnboundImport directly represents an ImportDecl, contains the + /// ImportDecl it represents. This should only be used for diagnostics and + /// for updating the AST; if you want to read information about the import, + /// get it from the other fields in \c UnboundImport rather than from the + /// \c ImportDecl. /// - /// An UnboundImport may represent a physical ImportDecl written in the - /// source, or it may represent a cross-import overlay that has been found and - /// needs to be loaded. - struct UnboundImport { - /// The source location to use when diagnosing errors for this import. - SourceLoc importLoc; - - /// The options for this import, such as "exported" or - /// "implementation-only". Use this field, not \c attrs, to determine the - /// behavior expected for this import. - ImportOptions options; - - /// If \c options includes \c PrivateImport, the filename we should import - /// private declarations from. - StringRef privateImportFileName; - - /// The module names being imported. There will usually be just one for the - /// top-level module, but a submodule import will have more. - ModuleDecl::AccessPathTy modulePath; - - /// If this is a scoped import, the names of the declaration being imported; - /// otherwise empty. (Currently the compiler doesn't support nested scoped - /// imports, so there should always be zero or one elements, but - /// \c AccessPathTy is the common currency type for this.) - ModuleDecl::AccessPathTy declPath; - - // Names of explicitly imported SPI groups via @_spi. - ArrayRef spiGroups; - - /// If this UnboundImport directly represents an ImportDecl, contains the - /// ImportDecl it represents. This should only be used for diagnostics and - /// for updating the AST; if you want to read information about the import, - /// get it from the other fields in \c UnboundImport rather than from the - /// \c ImportDecl. - /// - /// If this UnboundImport represents a cross-import, contains the declaring - /// module's \c ModuleDecl. - PointerUnion importOrUnderlyingModuleDecl; - - NullablePtr getImportDecl() const { - return importOrUnderlyingModuleDecl.is() ? - importOrUnderlyingModuleDecl.get() : nullptr; - } + /// If this UnboundImport represents a cross-import, contains the declaring + /// module's \c ModuleDecl. + PointerUnion importOrUnderlyingModuleDecl; - NullablePtr getUnderlyingModule() const { - return importOrUnderlyingModuleDecl.is() ? - importOrUnderlyingModuleDecl.get() : nullptr; - } + NullablePtr getImportDecl() const { + return importOrUnderlyingModuleDecl.is() ? + importOrUnderlyingModuleDecl.get() : nullptr; + } - /// Create an UnboundImport for a user-written import declaration. - explicit UnboundImport(ImportDecl *ID); - - /// Create an UnboundImport for a cross-import overlay. - explicit UnboundImport(ASTContext &ctx, - const UnboundImport &base, Identifier overlayName, - const ImportedModuleDesc &declaringImport, - const ImportedModuleDesc &bystandingImport); - - /// Diagnoses if the import would simply load the module \p SF already - /// belongs to, with no actual effect. - /// - /// Some apparent self-imports do actually load a different module; this - /// method allows them. - bool checkNotTautological(const SourceFile &SF); - - /// Make sure the module actually loaded, and diagnose if it didn't. - bool checkModuleLoaded(ModuleDecl *M, SourceFile &SF); - - /// Find the top-level module for this module; that is, if \p M is the - /// module \c Foo.Bar.Baz, this finds \c Foo. - /// - /// Specifically, this method returns: - /// - /// \li \p M if \p M is a top-level module. - /// \li \c nullptr if \p M is a submodule of \c SF's parent module. (This - /// corner case can occur in mixed-source frameworks, where Swift code - /// can import a Clang submodule of itself.) - /// \li The top-level parent (i.e. ancestor with no parent) module above - /// \p M otherwise. - NullablePtr getTopLevelModule(ModuleDecl *M, SourceFile &SF); - - /// Diagnose any errors concerning the \c @_exported, \c @_implementationOnly, - /// \c @testable, or \c @_private attributes, including a - /// non-implementation-only import of a fragile library from a resilient one. - void validateOptions(NullablePtr topLevelModule, SourceFile &SF); - - /// Create an \c ImportedModuleDesc from the information in this - /// UnboundImport. - ImportedModuleDesc makeDesc(ModuleDecl *module) const { - return ImportedModuleDesc({ declPath, module }, options, - privateImportFileName, spiGroups); - } + NullablePtr getUnderlyingModule() const { + return importOrUnderlyingModuleDecl.is() ? + importOrUnderlyingModuleDecl.get() : nullptr; + } - private: - void validatePrivate(ModuleDecl *topLevelModule); - void validateImplementationOnly(ASTContext &ctx); - void validateTestable(ModuleDecl *topLevelModule); - void validateResilience(NullablePtr topLevelModule, - SourceFile &SF); - - /// Diagnoses an inability to import \p modulePath in this situation and, if - /// \p attrs is provided and has an \p attrKind, invalidates the attribute and - /// offers a fix-it to remove it. - void diagnoseInvalidAttr(DeclAttrKind attrKind, DiagnosticEngine &diags, - Diag diagID); - }; - - class NameBinder final : public DeclVisitor { - friend DeclVisitor; - - SourceFile &SF; - ASTContext &ctx; - - /// Imports which still need their options checked, modules loaded, and - /// cross-imports found. - SmallVector unboundImports; - - /// The list of fully bound imports. - SmallVector boundImports; - - /// All imported modules, including by re-exports, and including submodules. - llvm::DenseSet visibleModules; - - /// \c visibleModules but without the submodules. - /// - /// We use a \c SmallSetVector here because this doubles as the worklist for - /// cross-importing, so we want to keep it in order; this is feasible - /// because this set is usually fairly small, while \c visibleModules is - /// often enormous. - SmallSetVector crossImportableModules; - - /// The subset of \c crossImportableModules which may declare cross-imports. - /// - /// This is a performance optimization. Since most modules do not register - /// any cross-imports, we can usually compare against this list, which is - /// much, much smaller than \c crossImportableModules. - SmallVector crossImportDeclaringModules; - - /// The index of the next module in \c visibleModules that should be - /// cross-imported. - size_t nextModuleToCrossImport = 0; - - public: - NameBinder(SourceFile &SF) - : SF(SF), ctx(SF.getASTContext()) - { } - - /// Retrieve the finalized imports. - ArrayRef getFinishedImports() const { - return boundImports; - } + /// Create an UnboundImport for a user-written import declaration. + explicit UnboundImport(ImportDecl *ID); - private: - // We only need to visit import decls. - void visitImportDecl(ImportDecl *ID); + /// Create an UnboundImport for a cross-import overlay. + explicit UnboundImport(ASTContext &ctx, + const UnboundImport &base, Identifier overlayName, + const ImportedModuleDesc &declaringImport, + const ImportedModuleDesc &bystandingImport); - // Ignore other decls. - void visitDecl(Decl *D) {} + /// Diagnoses if the import would simply load the module \p SF already + /// belongs to, with no actual effect. + /// + /// Some apparent self-imports do actually load a different module; this + /// method allows them. + bool checkNotTautological(const SourceFile &SF); - template - InFlightDiagnostic diagnose(ArgTypes &&...Args) { - return ctx.Diags.diagnose(std::forward(Args)...); - } + /// Make sure the module actually loaded, and diagnose if it didn't. + bool checkModuleLoaded(ModuleDecl *M, SourceFile &SF); + + /// Find the top-level module for this module; that is, if \p M is the + /// module \c Foo.Bar.Baz, this finds \c Foo. + /// + /// Specifically, this method returns: + /// + /// \li \p M if \p M is a top-level module. + /// \li \c nullptr if \p M is a submodule of \c SF's parent module. (This + /// corner case can occur in mixed-source frameworks, where Swift code + /// can import a Clang submodule of itself.) + /// \li The top-level parent (i.e. ancestor with no parent) module above + /// \p M otherwise. + NullablePtr getTopLevelModule(ModuleDecl *M, SourceFile &SF); + + /// Diagnose any errors concerning the \c @_exported, \c @_implementationOnly, + /// \c @testable, or \c @_private attributes, including a + /// non-implementation-only import of a fragile library from a resilient one. + void validateOptions(NullablePtr topLevelModule, SourceFile &SF); + + /// Create an \c ImportedModuleDesc from the information in this + /// UnboundImport. + ImportedModuleDesc makeDesc(ModuleDecl *module) const { + return ImportedModuleDesc({ declPath, module }, options, + privateImportFileName, spiGroups); + } + +private: + void validatePrivate(ModuleDecl *topLevelModule); + void validateImplementationOnly(ASTContext &ctx); + void validateTestable(ModuleDecl *topLevelModule); + void validateResilience(NullablePtr topLevelModule, + SourceFile &SF); + + /// Diagnoses an inability to import \p modulePath in this situation and, if + /// \p attrs is provided and has an \p attrKind, invalidates the attribute and + /// offers a fix-it to remove it. + void diagnoseInvalidAttr(DeclAttrKind attrKind, DiagnosticEngine &diags, + Diag diagID); +}; - /// Check a single unbound import, bind it, add it to \c boundImports, - /// and add its cross-import overlays to \c unboundImports. - void bindImport(UnboundImport &&I); - - /// Adds \p I and \p M to \c boundImports and \c visibleModules. - void addImport(const UnboundImport &I, ModuleDecl *M); - - /// Adds \p desc and everything it re-exports to \c visibleModules using - /// the settings from \c desc. - void addVisibleModules(ImportedModuleDesc desc); - - /// * If \p I is a cross-import overlay, registers \p M as overlaying - /// \p I.underlyingModule in \c SF. - /// * Discovers any cross-imports between \p I and previously bound imports, - /// then adds them to \c unboundImports using source locations from \p I. - void crossImport(ModuleDecl *M, UnboundImport &I); - - /// Discovers any cross-imports between \p newImport and - /// \p oldImports and adds them to \c unboundImports, using source - /// locations from \p I. - void findCrossImportsInLists(UnboundImport &I, - ArrayRef declaring, - ArrayRef bystanding, - bool shouldDiagnoseRedundantCrossImports); - - /// Discovers any cross-imports between \p declaringImport and - /// \p bystandingImport and adds them to \c unboundImports, using source - /// locations from \p I. - void findCrossImports(UnboundImport &I, - const ImportedModuleDesc &declaringImport, - const ImportedModuleDesc &bystandingImport, - bool shouldDiagnoseRedundantCrossImports); - - /// Load a module referenced by an import statement. - /// - /// Returns null if no module can be loaded. - ModuleDecl *getModule(ArrayRef> ModuleID); - }; +class NameBinder final : public DeclVisitor { + friend DeclVisitor; + + SourceFile &SF; + ASTContext &ctx; + + /// Imports which still need their options checked, modules loaded, and + /// cross-imports found. + SmallVector unboundImports; + + /// The list of fully bound imports. + SmallVector boundImports; + + /// All imported modules, including by re-exports, and including submodules. + llvm::DenseSet visibleModules; + + /// \c visibleModules but without the submodules. + /// + /// We use a \c SmallSetVector here because this doubles as the worklist for + /// cross-importing, so we want to keep it in order; this is feasible + /// because this set is usually fairly small, while \c visibleModules is + /// often enormous. + SmallSetVector crossImportableModules; + + /// The subset of \c crossImportableModules which may declare cross-imports. + /// + /// This is a performance optimization. Since most modules do not register + /// any cross-imports, we can usually compare against this list, which is + /// much, much smaller than \c crossImportableModules. + SmallVector crossImportDeclaringModules; + + /// The index of the next module in \c visibleModules that should be + /// cross-imported. + size_t nextModuleToCrossImport = 0; + +public: + NameBinder(SourceFile &SF) + : SF(SF), ctx(SF.getASTContext()) + { } + + /// Retrieve the finalized imports. + ArrayRef getFinishedImports() const { + return boundImports; + } + +private: + // We only need to visit import decls. + void visitImportDecl(ImportDecl *ID); + + // Ignore other decls. + void visitDecl(Decl *D) {} + + template + InFlightDiagnostic diagnose(ArgTypes &&...Args) { + return ctx.Diags.diagnose(std::forward(Args)...); + } + + /// Check a single unbound import, bind it, add it to \c boundImports, + /// and add its cross-import overlays to \c unboundImports. + void bindImport(UnboundImport &&I); + + /// Adds \p I and \p M to \c boundImports and \c visibleModules. + void addImport(const UnboundImport &I, ModuleDecl *M); + + /// Adds \p desc and everything it re-exports to \c visibleModules using + /// the settings from \c desc. + void addVisibleModules(ImportedModuleDesc desc); + + /// * If \p I is a cross-import overlay, registers \p M as overlaying + /// \p I.underlyingModule in \c SF. + /// * Discovers any cross-imports between \p I and previously bound imports, + /// then adds them to \c unboundImports using source locations from \p I. + void crossImport(ModuleDecl *M, UnboundImport &I); + + /// Discovers any cross-imports between \p newImport and + /// \p oldImports and adds them to \c unboundImports, using source + /// locations from \p I. + void findCrossImportsInLists(UnboundImport &I, + ArrayRef declaring, + ArrayRef bystanding, + bool shouldDiagnoseRedundantCrossImports); + + /// Discovers any cross-imports between \p declaringImport and + /// \p bystandingImport and adds them to \c unboundImports, using source + /// locations from \p I. + void findCrossImports(UnboundImport &I, + const ImportedModuleDesc &declaringImport, + const ImportedModuleDesc &bystandingImport, + bool shouldDiagnoseRedundantCrossImports); + + /// Load a module referenced by an import statement. + /// + /// Returns null if no module can be loaded. + ModuleDecl *getModule(ArrayRef> ModuleID); +}; } // end anonymous namespace //===----------------------------------------------------------------------===// From d2434e1bf70d6baf40f74268751a866378cff83b Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Sat, 28 Mar 2020 15:11:23 -0700 Subject: [PATCH 3/5] NFC: Rename NameBinding to ImportResolution --- include/swift/AST/SourceFile.h | 4 +- include/swift/Subsystems.h | 21 ++-- lib/AST/Module.cpp | 2 +- lib/Frontend/Frontend.cpp | 22 ++--- lib/IDE/CompletionInstance.cpp | 2 +- lib/Sema/CMakeLists.txt | 2 +- .../{NameBinding.cpp => ImportResolution.cpp} | 96 +++++++++---------- lib/Sema/SourceLoader.cpp | 2 +- lib/Sema/TypeChecker.cpp | 7 +- lib/Serialization/Deserialization.cpp | 2 +- 10 files changed, 77 insertions(+), 83 deletions(-) rename lib/Sema/{NameBinding.cpp => ImportResolution.cpp} (92%) diff --git a/include/swift/AST/SourceFile.h b/include/swift/AST/SourceFile.h index 8fe0793cb8fd6..57054c3fc5d74 100644 --- a/include/swift/AST/SourceFile.h +++ b/include/swift/AST/SourceFile.h @@ -318,8 +318,8 @@ class SourceFile final : public FileUnit { enum ASTStage_t { /// The source file is not name bound or type checked. Unprocessed, - /// Name binding has completed. - NameBound, + /// Import resolution has completed. + ImportsResolved, /// Type checking has completed. TypeChecked }; diff --git a/include/swift/Subsystems.h b/include/swift/Subsystems.h index 5ea460bdf702a..dd9791109bb4a 100644 --- a/include/swift/Subsystems.h +++ b/include/swift/Subsystems.h @@ -118,33 +118,32 @@ namespace swift { bool TokenizeInterpolatedString = true, ArrayRef SplitTokens = ArrayRef()); - /// Once parsing is complete, this walks the AST to resolve imports, record - /// operators, and do other top-level validation. - void performNameBinding(SourceFile &SF); + /// This walks the AST to resolve imports. + void performImportResolution(SourceFile &SF); /// Once type-checking is complete, this instruments code with calls to an /// intrinsic that record the expected values of local variables so they can /// be compared against the results from the debugger. void performDebuggerTestingTransform(SourceFile &SF); - /// Once parsing and name-binding are complete, this optionally transforms the - /// ASTs to add calls to external logging functions. + /// Once type checking is complete, this optionally transforms the ASTs to add + /// calls to external logging functions. /// /// \param HighPerformance True if the playground transform should omit /// instrumentation that has a high runtime performance impact. void performPlaygroundTransform(SourceFile &SF, bool HighPerformance); - /// Once parsing and name-binding are complete this optionally walks the ASTs - /// to add calls to externally provided functions that simulate - /// "program counter"-like debugging events. See the comment at the top of - /// lib/Sema/PCMacro.cpp for a description of the calls inserted. + /// Once type checking is complete this optionally walks the ASTs to add calls + /// to externally provided functions that simulate "program counter"-like + /// debugging events. See the comment at the top of lib/Sema/PCMacro.cpp for a + /// description of the calls inserted. void performPCMacro(SourceFile &SF); /// Bind all 'extension' visible from \p SF to the extended nominal. void bindExtensions(SourceFile &SF); - /// Once parsing and name-binding are complete, this walks the AST to resolve - /// types and diagnose problems therein. + /// Once import resolution is complete, this walks the AST to resolve types + /// and diagnose problems therein. void performTypeChecking(SourceFile &SF); /// Now that we have type-checked an entire module, perform any type diff --git a/lib/AST/Module.cpp b/lib/AST/Module.cpp index bc6c9201ed498..15c454cb9c186 100644 --- a/lib/AST/Module.cpp +++ b/lib/AST/Module.cpp @@ -1182,7 +1182,7 @@ lookupOperatorDeclForName(const FileUnit &File, SourceLoc Loc, } auto &SF = cast(File); - assert(SF.ASTStage >= SourceFile::NameBound); + assert(SF.ASTStage >= SourceFile::ImportsResolved); // Check if the decl exists on the file. if (auto *op = OperatorLookup::lookup(eval, desc)) diff --git a/lib/Frontend/Frontend.cpp b/lib/Frontend/Frontend.cpp index aef9c0df47803..7e2860a0ce732 100644 --- a/lib/Frontend/Frontend.cpp +++ b/lib/Frontend/Frontend.cpp @@ -752,7 +752,7 @@ shouldImplicityImportSwiftOnoneSupportModule(CompilerInvocation &Invocation) { } void CompilerInstance::performParseAndResolveImportsOnly() { - performSemaUpTo(SourceFile::NameBound); + performSemaUpTo(SourceFile::ImportsResolved); } void CompilerInstance::performSema() { @@ -926,12 +926,12 @@ void CompilerInstance::parseAndCheckTypesUpTo( auto *SF = dyn_cast(File); if (!SF) return true; - return SF->ASTStage >= SourceFile::NameBound; + return SF->ASTStage >= SourceFile::ImportsResolved; }) && "some files have not yet had their imports resolved"); MainModule->setHasResolvedImports(); forEachFileToTypeCheck([&](SourceFile &SF) { - if (limitStage == SourceFile::NameBound) { + if (limitStage == SourceFile::ImportsResolved) { bindExtensions(SF); return; } @@ -951,8 +951,8 @@ void CompilerInstance::parseAndCheckTypesUpTo( } }); - // If the limiting AST stage is name binding, we're done. - if (limitStage <= SourceFile::NameBound) { + // If the limiting AST stage is import resolution, we're done. + if (limitStage <= SourceFile::ImportsResolved) { return; } @@ -967,8 +967,8 @@ void CompilerInstance::parseLibraryFile( SourceFileKind::Library, implicitImports.kind, BufferID); addAdditionalInitialImportsTo(NextInput, implicitImports); - // Name binding will lazily trigger parsing of the file. - performNameBinding(*NextInput); + // Import resolution will lazily trigger parsing of the file. + performImportResolution(*NextInput); } bool CompilerInstance::parsePartialModulesAndLibraryFiles( @@ -997,7 +997,7 @@ bool CompilerInstance::parsePartialModulesAndLibraryFiles( void CompilerInstance::parseAndTypeCheckMainFileUpTo( SourceFile::ASTStage_t LimitStage) { - assert(LimitStage >= SourceFile::NameBound); + assert(LimitStage >= SourceFile::ImportsResolved); FrontendStatsTracer tracer(getStatsReporter(), "parse-and-typecheck-main-file"); bool mainIsPrimary = @@ -1010,13 +1010,13 @@ void CompilerInstance::parseAndTypeCheckMainFileUpTo( auto DidSuppressWarnings = Diags.getSuppressWarnings(); Diags.setSuppressWarnings(DidSuppressWarnings || !mainIsPrimary); - // For a primary, perform type checking if needed. Otherwise, just do name - // binding. + // For a primary, perform type checking if needed. Otherwise, just do import + // resolution. if (mainIsPrimary && LimitStage >= SourceFile::TypeChecked) { performTypeChecking(MainFile); } else { assert(!TheSILModule && "Should perform type checking for SIL"); - performNameBinding(MainFile); + performImportResolution(MainFile); } // Parse the SIL decls if needed. diff --git a/lib/IDE/CompletionInstance.cpp b/lib/IDE/CompletionInstance.cpp index 5f60902d487ec..7a33a8c9cef83 100644 --- a/lib/IDE/CompletionInstance.cpp +++ b/lib/IDE/CompletionInstance.cpp @@ -326,7 +326,7 @@ bool CompletionInstance::performCachedOperaitonIfPossible( // Re-process the whole file (parsing will be lazily triggered). Still // re-use imported modules. - performNameBinding(*newSF); + performImportResolution(*newSF); bindExtensions(*newSF); #ifndef NDEBUG diff --git a/lib/Sema/CMakeLists.txt b/lib/Sema/CMakeLists.txt index 0f7f77608449c..feb7ee9d14c5a 100644 --- a/lib/Sema/CMakeLists.txt +++ b/lib/Sema/CMakeLists.txt @@ -25,10 +25,10 @@ add_swift_host_library(swiftSema STATIC DerivedConformanceError.cpp DerivedConformanceRawRepresentable.cpp DerivedConformances.cpp + ImportResolution.cpp InstrumenterSupport.cpp LookupVisibleDecls.cpp MiscDiagnostics.cpp - NameBinding.cpp PCMacro.cpp PlaygroundTransform.cpp ResilienceDiagnostics.cpp diff --git a/lib/Sema/NameBinding.cpp b/lib/Sema/ImportResolution.cpp similarity index 92% rename from lib/Sema/NameBinding.cpp rename to lib/Sema/ImportResolution.cpp index 8fe4065c79ac2..c5d78d18e1b85 100644 --- a/lib/Sema/NameBinding.cpp +++ b/lib/Sema/ImportResolution.cpp @@ -1,8 +1,8 @@ -//===--- NameBinding.cpp - Name Binding -----------------------------------===// +//===--- ImportResolution.cpp - Import Resolution -------------------------===// // // This source file is part of the Swift.org open source project // -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -11,11 +11,10 @@ //===----------------------------------------------------------------------===// // // This file performs import resolution. -// FIXME: Rename NameBinding to ImportResolution. // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "swift-name-binding" +#define DEBUG_TYPE "swift-import-resolution" #include "swift/AST/ASTWalker.h" #include "swift/AST/DiagnosticsSema.h" #include "swift/AST/ModuleLoader.h" @@ -41,7 +40,7 @@ using namespace swift; //===----------------------------------------------------------------------===// -// MARK: NameBinder and supporting types +// MARK: ImportResolver and supporting types //===----------------------------------------------------------------------===// using ImportedModule = ModuleDecl::ImportedModule; @@ -50,8 +49,8 @@ using ImportOptions = SourceFile::ImportOptions; using ImportFlags = SourceFile::ImportFlags; namespace { -/// Represents an import which the NameBinder knows exists, but which has not -/// yet had its options checked, module loaded, or cross-imports found. +/// Represents an import which the ImportResolver knows exists, but which has +/// not yet had its options checked, module loaded, or cross-imports found. /// /// An UnboundImport may represent a physical ImportDecl written in the /// source, or it may represent a cross-import overlay that has been found and @@ -160,8 +159,8 @@ struct UnboundImport { Diag diagID); }; -class NameBinder final : public DeclVisitor { - friend DeclVisitor; +class ImportResolver final : public DeclVisitor { + friend DeclVisitor; SourceFile &SF; ASTContext &ctx; @@ -196,9 +195,7 @@ class NameBinder final : public DeclVisitor { size_t nextModuleToCrossImport = 0; public: - NameBinder(SourceFile &SF) - : SF(SF), ctx(SF.getASTContext()) - { } + ImportResolver(SourceFile &SF) : SF(SF), ctx(SF.getASTContext()) {} /// Retrieve the finalized imports. ArrayRef getFinishedImports() const { @@ -258,38 +255,37 @@ class NameBinder final : public DeclVisitor { } // end anonymous namespace //===----------------------------------------------------------------------===// -// MARK: performNameBinding +// MARK: performImportResolution //===----------------------------------------------------------------------===// -/// performNameBinding - Once parsing is complete, this walks the AST to -/// resolve imports. +/// performImportResolution - This walks the AST to resolve imports. /// -/// Most names are actually bound by the type checker, but before we can -/// type-check a source file, we need to make declarations imported from other -/// modules available. Name binding processes top-level \c ImportDecl nodes -/// to perform this task, along with related validation. +/// Before we can type-check a source file, we need to make declarations +/// imported from other modules available. This is done by processing top-level +/// \c ImportDecl nodes, along with related validation. /// -/// Name binding operates on a parsed but otherwise unvalidated AST. -void swift::performNameBinding(SourceFile &SF) { +/// Import resolution operates on a parsed but otherwise unvalidated AST. +void swift::performImportResolution(SourceFile &SF) { FrontendStatsTracer tracer(SF.getASTContext().Stats, - "Name binding"); + "Import resolution"); // Make sure we skip adding the standard library imports if the // source file is empty. - if (SF.ASTStage == SourceFile::NameBound || SF.getTopLevelDecls().empty()) { - SF.ASTStage = SourceFile::NameBound; + if (SF.ASTStage == SourceFile::ImportsResolved || + SF.getTopLevelDecls().empty()) { + SF.ASTStage = SourceFile::ImportsResolved; return; } - NameBinder Binder(SF); + ImportResolver resolver(SF); // Resolve each import declaration. for (auto D : SF.getTopLevelDecls()) - Binder.visit(D); + resolver.visit(D); - SF.addImports(Binder.getFinishedImports()); + SF.addImports(resolver.getFinishedImports()); - SF.ASTStage = SourceFile::NameBound; + SF.ASTStage = SourceFile::ImportsResolved; verify(SF); } @@ -297,7 +293,7 @@ void swift::performNameBinding(SourceFile &SF) { // MARK: Import handling generally //===----------------------------------------------------------------------===// -void NameBinder::visitImportDecl(ImportDecl *ID) { +void ImportResolver::visitImportDecl(ImportDecl *ID) { assert(unboundImports.empty()); unboundImports.emplace_back(ID); @@ -305,7 +301,7 @@ void NameBinder::visitImportDecl(ImportDecl *ID) { bindImport(unboundImports.pop_back_val()); } -void NameBinder::bindImport(UnboundImport &&I) { +void ImportResolver::bindImport(UnboundImport &&I) { auto ID = I.getImportDecl(); if (!I.checkNotTautological(SF)) { @@ -343,7 +339,7 @@ void NameBinder::bindImport(UnboundImport &&I) { ID.get()->setModule(M); } -void NameBinder::addImport(const UnboundImport &I, ModuleDecl *M) { +void ImportResolver::addImport(const UnboundImport &I, ModuleDecl *M) { auto importDesc = I.makeDesc(M); addVisibleModules(importDesc); boundImports.push_back(importDesc); @@ -353,7 +349,8 @@ void NameBinder::addImport(const UnboundImport &I, ModuleDecl *M) { // MARK: Import module loading //===----------------------------------------------------------------------===// -ModuleDecl *NameBinder::getModule(ArrayRef> modulePath) { +ModuleDecl * +ImportResolver::getModule(ArrayRef> modulePath) { assert(!modulePath.empty()); auto moduleID = modulePath[0]; @@ -667,7 +664,7 @@ ScopedImportLookupRequest::evaluate(Evaluator &evaluator, // If we weren't able to load the module referenced by the import, we're done. // The fact that we failed to load the module has already been diagnosed by - // name binding. + // import resolution. auto *module = import->getModule(); if (!module) return ArrayRef(); @@ -676,8 +673,8 @@ ScopedImportLookupRequest::evaluate(Evaluator &evaluator, /// /// We validate the scope by making sure that the named declaration exists /// and is of the kind indicated by the keyword. This can't be done until - /// we've performed name binding, since that can introduce additional imports - /// (such as cross-import overlays) which could provide the declaration. + /// we've performed import resolution, since that can introduce additional + /// imports (such as cross-import overlays) which could provide the declaration. auto &ctx = module->getASTContext(); auto declPath = import->getDeclPath(); auto modulePath = import->getModulePath(); @@ -789,16 +786,16 @@ UnboundImport::UnboundImport(ASTContext &ctx, options |= ImportFlags::ImplementationOnly; } -void NameBinder::crossImport(ModuleDecl *M, UnboundImport &I) { +void ImportResolver::crossImport(ModuleDecl *M, UnboundImport &I) { // FIXME: There is a fundamental problem with this find-as-we-go approach: // The '@_exported import'-ed modules in this module's other files should be // taken into account, but they haven't been bound yet, and binding them would // require cross-importing. Chicken, meet egg. // - // The way to fix this is probably to restructure name binding so we first - // bind all exported imports in all files, then bind all other imports in each - // file. This may become simpler if we bind all ImportDecls before we start - // computing cross-imports, but I haven't figured that part out yet. + // The way to fix this is probably to restructure import resolution so we + // first bind all exported imports in all files, then bind all other imports + // in each file. This may become simpler if we bind all ImportDecls before we + // start computing cross-imports, but I haven't figured that part out yet. // // Fixing this is tracked within Apple by rdar://problem/59527118. I haven't // filed an SR because I plan to address it myself, but if this comment is @@ -855,11 +852,10 @@ void NameBinder::crossImport(ModuleDecl *M, UnboundImport &I) { nextModuleToCrossImport = crossImportableModules.size(); } -void -NameBinder::findCrossImportsInLists(UnboundImport &I, - ArrayRef declaring, - ArrayRef bystanding, - bool shouldDiagnoseRedundantCrossImports) { +void ImportResolver::findCrossImportsInLists( + UnboundImport &I, ArrayRef declaring, + ArrayRef bystanding, + bool shouldDiagnoseRedundantCrossImports) { for (auto &declaringImport : declaring) { if (!canCrossImport(declaringImport)) continue; @@ -874,10 +870,10 @@ NameBinder::findCrossImportsInLists(UnboundImport &I, } } -void NameBinder::findCrossImports(UnboundImport &I, - const ImportedModuleDesc &declaringImport, - const ImportedModuleDesc &bystandingImport, - bool shouldDiagnoseRedundantCrossImports) { +void ImportResolver::findCrossImports( + UnboundImport &I, const ImportedModuleDesc &declaringImport, + const ImportedModuleDesc &bystandingImport, + bool shouldDiagnoseRedundantCrossImports) { assert(&declaringImport != &bystandingImport); LLVM_DEBUG( @@ -935,7 +931,7 @@ static bool isSubmodule(ModuleDecl* M) { return clangMod && clangMod->Parent; } -void NameBinder::addVisibleModules(ImportedModuleDesc importDesc) { +void ImportResolver::addVisibleModules(ImportedModuleDesc importDesc) { // FIXME: namelookup::getAllImports() doesn't quite do what we need (mainly // w.r.t. scoped imports), but it seems like we could extend it to do so, and // then eliminate most of this. diff --git a/lib/Sema/SourceLoader.cpp b/lib/Sema/SourceLoader.cpp index 5c8ccd4d980ef..92d736f23c5c6 100644 --- a/lib/Sema/SourceLoader.cpp +++ b/lib/Sema/SourceLoader.cpp @@ -129,7 +129,7 @@ ModuleDecl *SourceLoader::loadModule(SourceLoc importLoc, Ctx.LangOpts.CollectParsedToken, Ctx.LangOpts.BuildSyntaxTree); importMod->addFile(*importFile); - performNameBinding(*importFile); + performImportResolution(*importFile); importMod->setHasResolvedImports(); return importMod; } diff --git a/lib/Sema/TypeChecker.cpp b/lib/Sema/TypeChecker.cpp index 9f2109abb7eae..1e41769433e85 100644 --- a/lib/Sema/TypeChecker.cpp +++ b/lib/Sema/TypeChecker.cpp @@ -336,10 +336,10 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval, SourceFile *SF) const { BufferIndirectlyCausingDiagnosticRAII cpr(*SF); - // Make sure that name binding has been completed before doing any type + // Make sure that import resolution has been completed before doing any type // checking. - performNameBinding(*SF); - + performImportResolution(*SF); + // Could build scope maps here because the AST is stable now. { @@ -367,7 +367,6 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval, SourceFile *SF) const { // Type check the top-level elements of the source file. for (auto D : SF->getTopLevelDecls()) { if (auto *TLCD = dyn_cast(D)) { - // Immediately perform global name-binding etc. TypeChecker::typeCheckTopLevelCodeDecl(TLCD); TypeChecker::contextualizeTopLevelCode(TLCD); } else { diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index ec6fa3c9637b9..6932e2abb7ded 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -2013,7 +2013,7 @@ ModuleDecl *ModuleFile::getModule(ArrayRef name, if (name.empty() || name.front().empty()) return getContext().TheBuiltinModule; - // FIXME: duplicated from NameBinder::getModule + // FIXME: duplicated from ImportResolver::getModule if (name.size() == 1 && name.front() == FileContext->getParentModule()->getName()) { if (!UnderlyingModule && allowLoading) { From 92c8a65f09ad35d872e931653f3e677de17c3805 Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Thu, 31 Oct 2019 10:45:00 -0700 Subject: [PATCH 4/5] Drop references to name binding as a phase A lot of places appear to mean "name lookup". A few places meant "import resolution". --- docs/CompilerPerformance.md | 2 +- include/swift/AST/DiagnosticsSema.def | 2 +- include/swift/AST/Expr.h | 8 ++++---- include/swift/AST/ImportCache.h | 2 +- include/swift/AST/SourceFile.h | 9 ++++----- include/swift/AST/TypeRepr.h | 5 +++-- include/swift/AST/Types.h | 13 +++++++------ include/swift/Frontend/Frontend.h | 2 +- include/swift/Parse/Scope.h | 2 +- lib/AST/Module.cpp | 16 ++++++++-------- lib/Parse/ParseExpr.cpp | 4 ++-- lib/ParseSIL/ParseSIL.cpp | 1 - lib/Sema/CSGen.cpp | 4 ++-- lib/Sema/ConstraintSystem.h | 4 ++-- lib/Sema/TypeCheckType.h | 2 +- lib/Sema/TypeChecker.h | 2 +- test/NameBinding/library.swift | 2 +- test/NameBinding/name-binding.swift | 9 ++++----- test/NameBinding/scope_map_lookup.swift | 4 ++-- 19 files changed, 46 insertions(+), 47 deletions(-) diff --git a/docs/CompilerPerformance.md b/docs/CompilerPerformance.md index 3f5599520711c..f48097660e226 100644 --- a/docs/CompilerPerformance.md +++ b/docs/CompilerPerformance.md @@ -570,7 +570,7 @@ compilers on hand while you're working. Total Execution Time: 0.0876 seconds (0.0877 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- - 0.0241 ( 53.9%) 0.0394 ( 92.0%) 0.0635 ( 72.5%) 0.0635 ( 72.5%) Name binding + 0.0241 ( 53.9%) 0.0394 ( 92.0%) 0.0635 ( 72.5%) 0.0635 ( 72.5%) Import resolution 0.0170 ( 38.0%) 0.0025 ( 5.8%) 0.0195 ( 22.3%) 0.0195 ( 22.2%) Type checking / Semantic analysis 0.0013 ( 3.0%) 0.0004 ( 0.8%) 0.0017 ( 1.9%) 0.0017 ( 1.9%) LLVM output 0.0010 ( 2.3%) 0.0003 ( 0.7%) 0.0013 ( 1.5%) 0.0013 ( 1.5%) SILGen diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index 10f428f712967..bb4c200acba64 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -661,7 +661,7 @@ NOTE(add_return_type_note,none, "did you mean to add a return type?", ()) //------------------------------------------------------------------------------ -// MARK: Name Binding +// MARK: Import Resolution //------------------------------------------------------------------------------ ERROR(sema_no_import,Fatal, diff --git a/include/swift/AST/Expr.h b/include/swift/AST/Expr.h index a8d34a2212f51..e9560eef8238d 100644 --- a/include/swift/AST/Expr.h +++ b/include/swift/AST/Expr.h @@ -1333,9 +1333,9 @@ class SuperRefExpr : public Expr { } }; -/// A reference to a type in expression context, spelled out as a TypeLoc. Sema -/// forms this expression as a result of name binding. This always has -/// MetaTypetype. +/// A reference to a type in expression context, spelled out as a TypeLoc. +/// +/// The type of this expression is always \c MetaTypeType. class TypeExpr : public Expr { TypeLoc Info; TypeExpr(Type Ty); @@ -4831,7 +4831,7 @@ class AssignExpr : public Expr { }; /// A pattern production that has been parsed but hasn't been resolved -/// into a complete pattern. Name binding converts these into standalone pattern +/// into a complete pattern. Pattern checking converts these into standalone pattern /// nodes or raises an error if a pattern production appears in an invalid /// position. class UnresolvedPatternExpr : public Expr { diff --git a/include/swift/AST/ImportCache.h b/include/swift/AST/ImportCache.h index 37705f4fba9cc..90ea89bc3b4ec 100644 --- a/include/swift/AST/ImportCache.h +++ b/include/swift/AST/ImportCache.h @@ -148,7 +148,7 @@ class alignas(ModuleDecl::ImportedModule) ImportCache { const DeclContext *dc); /// This is a hack to cope with main file parsing and REPL parsing, where - /// we can add ImportDecls after name binding. + /// we can add ImportDecls after import resolution. void clear() { ImportSetForDC.clear(); } diff --git a/include/swift/AST/SourceFile.h b/include/swift/AST/SourceFile.h index 57054c3fc5d74..03d08da3a4dde 100644 --- a/include/swift/AST/SourceFile.h +++ b/include/swift/AST/SourceFile.h @@ -23,9 +23,8 @@ class PersistentParserState; /// A file containing Swift source code. /// /// This is a .swift or .sil file (or a virtual file, such as the contents of -/// the REPL). Since it contains raw source, it must be parsed and name-bound -/// before being used for anything; a full type-check is also necessary for -/// IR generation. +/// the REPL). Since it contains raw source, it must be type checked for IR +/// generation. class SourceFile final : public FileUnit { friend class ParseSourceFileRequest; @@ -128,7 +127,7 @@ class SourceFile final : public FileUnit { /// This is the list of modules that are imported by this module. /// - /// This is filled in by the Name Binding phase. + /// This is filled in by the import resolution phase. ArrayRef Imports; /// A unique identifier representing this file; used to mark private decls @@ -316,7 +315,7 @@ class SourceFile final : public FileUnit { const SourceFileKind Kind; enum ASTStage_t { - /// The source file is not name bound or type checked. + /// The source file has not had its imports resolved or been type checked. Unprocessed, /// Import resolution has completed. ImportsResolved, diff --git a/include/swift/AST/TypeRepr.h b/include/swift/AST/TypeRepr.h index d72b3290e4765..14e99ea6225e9 100644 --- a/include/swift/AST/TypeRepr.h +++ b/include/swift/AST/TypeRepr.h @@ -263,7 +263,7 @@ class ComponentIdentTypeRepr : public IdentTypeRepr { /// component. /// /// The initial parsed representation is always an identifier, and - /// name binding will resolve this to a specific declaration. + /// name lookup will resolve this to a specific declaration. llvm::PointerUnion IdOrDecl; /// The declaration context from which the bound declaration was @@ -282,7 +282,8 @@ class ComponentIdentTypeRepr : public IdentTypeRepr { /// correction. void overwriteNameRef(DeclNameRef newId) { IdOrDecl = newId; } - /// Return true if this has been name-bound already. + /// Return true if this name has been resolved to a type decl. This happens + /// during type resolution. bool isBound() const { return IdOrDecl.is(); } TypeDecl *getBoundDecl() const { return IdOrDecl.dyn_cast(); } diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h index c0da7fe307146..9f964ab633c1a 100644 --- a/include/swift/AST/Types.h +++ b/include/swift/AST/Types.h @@ -1271,10 +1271,11 @@ class NominalOrBoundGenericNominalType : public AnyGenericType { }; DEFINE_EMPTY_CAN_TYPE_WRAPPER(NominalOrBoundGenericNominalType, AnyGenericType) -/// ErrorType - This represents a type that was erroneously constructed. This -/// is produced when parsing types and when name binding type aliases, and is -/// installed in declaration that use these erroneous types. All uses of a -/// declaration of invalid type should be ignored and not re-diagnosed. +/// ErrorType - Represents the type of an erroneously constructed declaration, +/// expression, or type. When creating ErrorTypes, an associated error +/// diagnostic should always be emitted. That way when later stages of +/// compilation encounter an ErrorType installed by earlier phases they do not +/// have to emit further diagnostics to abort compilation. class ErrorType final : public TypeBase { friend class ASTContext; // The Error type is always canonical. @@ -6410,11 +6411,11 @@ inline ArrayRef AnyFunctionType::getParams() const { llvm_unreachable("Undefined function type"); } } - + /// If this is a method in a type or extension thereof, compute /// and return a parameter to be used for the 'self' argument. The type of /// the parameter is the empty Type() if no 'self' argument should exist. This -/// can only be used after name binding has resolved types. +/// can only be used after types have been resolved. /// /// \param isInitializingCtor Specifies whether we're computing the 'self' /// type of an initializing constructor, which accepts an instance 'self' diff --git a/include/swift/Frontend/Frontend.h b/include/swift/Frontend/Frontend.h index 56cc305f8538d..9c4851b712e82 100644 --- a/include/swift/Frontend/Frontend.h +++ b/include/swift/Frontend/Frontend.h @@ -623,7 +623,7 @@ class CompilerInstance { void performParseOnly(bool EvaluateConditionals = false, bool CanDelayBodies = true); - /// Parses and performs name binding on all input files. + /// Parses and performs import resolution on all input files. /// /// This is similar to a parse-only invocation, but module imports will also /// be processed. diff --git a/include/swift/Parse/Scope.h b/include/swift/Parse/Scope.h index c10b97f35daee..0e77904dbc2ff 100644 --- a/include/swift/Parse/Scope.h +++ b/include/swift/Parse/Scope.h @@ -170,7 +170,7 @@ inline ValueDecl *ScopeInfo::lookupValueName(DeclNameRef Name) { assert(CurScope && "no scope"); // If we found nothing, or we found a decl at the top-level, return nothing. // We ignore results at the top-level because we may have overloading that - // will be resolved properly by name binding. + // will be resolved properly by name lookup. std::pair Res = HT.lookup(CurScope->HTScope, Name.getFullName()); if (Res.first < ResolvableDepth) diff --git a/lib/AST/Module.cpp b/lib/AST/Module.cpp index 15c454cb9c186..65a71839750df 100644 --- a/lib/AST/Module.cpp +++ b/lib/AST/Module.cpp @@ -1351,14 +1351,14 @@ void ModuleDecl::getImportedModules(SmallVectorImpl &modules, void SourceFile::getImportedModules(SmallVectorImpl &modules, ModuleDecl::ImportFilter filter) const { - // FIXME: Ideally we should assert that the file has been name bound before - // calling this function. However unfortunately that can cause issues for - // overlays which can depend on a Clang submodule for the underlying framework - // they are overlaying, which causes us to attempt to load the overlay again. - // We need to find a way to ensure that an overlay dependency with the same - // name as the overlay always loads the underlying Clang module. We currently - // handle this for a direct import from the overlay, but not when it happens - // through other imports. + // FIXME: Ideally we should assert that the file has had its imports resolved + // before calling this function. However unfortunately that can cause issues + // for overlays which can depend on a Clang submodule for the underlying + // framework they are overlaying, which causes us to attempt to load the + // overlay again. We need to find a way to ensure that an overlay dependency + // with the same name as the overlay always loads the underlying Clang module. + // We currently handle this for a direct import from the overlay, but not when + // it happens through other imports. assert(filter && "no imports requested?"); for (auto desc : Imports) { ModuleDecl::ImportFilter requiredFilter; diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index e68ce88cabd99..980a15e014826 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -46,8 +46,8 @@ ParserResult Parser::parseExprImpl(Diag<> Message, SyntaxParsingContext ExprParsingContext(SyntaxContext, SyntaxContextKind::Expr); // If we are parsing a refutable pattern, check to see if this is the start - // of a let/var/is pattern. If so, parse it to an UnresolvedPatternExpr and - // name binding will perform final validation. + // of a let/var/is pattern. If so, parse it as an UnresolvedPatternExpr and + // let pattern type checking determine its final form. // // Only do this if we're parsing a pattern, to improve QoI on malformed // expressions followed by (e.g.) let/var decls. diff --git a/lib/ParseSIL/ParseSIL.cpp b/lib/ParseSIL/ParseSIL.cpp index 109f457502f96..049cd14000227 100644 --- a/lib/ParseSIL/ParseSIL.cpp +++ b/lib/ParseSIL/ParseSIL.cpp @@ -1093,7 +1093,6 @@ static bool parseDeclSILOptional(bool *isTransparent, bool SILParser::performTypeLocChecking(TypeLoc &T, bool IsSILType, GenericEnvironment *GenericEnv, DeclContext *DC) { - // Do some type checking / name binding for the parsed type. if (GenericEnv == nullptr) GenericEnv = ContextGenericEnv; diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp index 8c64fe4e03277..a739f01892e45 100644 --- a/lib/Sema/CSGen.cpp +++ b/lib/Sema/CSGen.cpp @@ -3135,8 +3135,8 @@ namespace { } Type visitUnresolvedPatternExpr(UnresolvedPatternExpr *expr) { - // If there are UnresolvedPatterns floating around after name binding, - // they are pattern productions in invalid positions. However, we will + // If there are UnresolvedPatterns floating around after pattern type + // checking, they are definitely invalid. However, we will // diagnose that condition elsewhere; to avoid unnecessary noise errors, // just plop an open type variable here. diff --git a/lib/Sema/ConstraintSystem.h b/lib/Sema/ConstraintSystem.h index 41c2e97589c05..4b09bfc48c51c 100644 --- a/lib/Sema/ConstraintSystem.h +++ b/lib/Sema/ConstraintSystem.h @@ -2323,8 +2323,8 @@ class ConstraintSystem { /// system, to avoid. /// /// FIXME: This caching should almost certainly be performed at the - /// module level, since type checking occurs after name binding, - /// and no new names are introduced after name binding. + /// module level, since type checking occurs after import resolution, + /// and no new names are introduced after that point. /// /// \returns A reference to the member-lookup result. LookupResult &lookupMember(Type base, DeclNameRef name); diff --git a/lib/Sema/TypeCheckType.h b/lib/Sema/TypeCheckType.h index bcd564c9b20ba..9254a0b92b745 100644 --- a/lib/Sema/TypeCheckType.h +++ b/lib/Sema/TypeCheckType.h @@ -339,7 +339,7 @@ class TypeResolution { /// Resolves a TypeRepr to a type. /// - /// Performs name binding, checking of generic arguments, and so on in order + /// Performs name lookup, checking of generic arguments, and so on in order /// to create a well-formed type. /// /// \param TyR The type representation to check. diff --git a/lib/Sema/TypeChecker.h b/lib/Sema/TypeChecker.h index 8e96c886aef2b..c701cf2080186 100644 --- a/lib/Sema/TypeChecker.h +++ b/lib/Sema/TypeChecker.h @@ -423,7 +423,7 @@ Expr *resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE, DeclContext *Context); /// Validate the given type. /// -/// Type validation performs name binding, checking of generic arguments, +/// Type validation performs name lookup, checking of generic arguments, /// and so on to determine whether the given type is well-formed and can /// be used as a type. /// diff --git a/test/NameBinding/library.swift b/test/NameBinding/library.swift index 1cb83826b6c26..b77d3f8f81c46 100644 --- a/test/NameBinding/library.swift +++ b/test/NameBinding/library.swift @@ -21,7 +21,7 @@ var c = 1 var d = 2 var e = 3 -// Name-binding with imports +// Name lookup with imports. import imported_module func over1(_ x: UInt64) {} // expected-note{{found this candidate}} func over2(_ x: UInt32) {} diff --git a/test/NameBinding/name-binding.swift b/test/NameBinding/name-binding.swift index 25b6ffc2017f1..b2ce3276bec39 100644 --- a/test/NameBinding/name-binding.swift +++ b/test/NameBinding/name-binding.swift @@ -23,7 +23,7 @@ var importedunion: unionSearchFlags = .backwards var notimported : MaybeInt // expected-error {{use of undeclared type 'MaybeInt'}} //===----------------------------------------------------------------------===// -// Name binding stress test +// Name lookup stress test //===----------------------------------------------------------------------===// var callee1 : () -> (Int,Int,Int) // Takes nothing, returns tuple. @@ -62,13 +62,12 @@ func test_varname_binding() { // ForwardIndex referencing of types. //===----------------------------------------------------------------------===// -// We allow namebinding to look forward past a var declaration in the -// main module +// Lookup can find a decl declared later in the main module. var x : x_ty typealias x_ty = Int -// We allow namebinding to look forward past a function declaration (and other -// declarations which never have side-effects) in the main module +// We allow name lookup to look forward past a function declaration (and other +// declarations which never have side-effects) in the main module. func fy() -> y_ty { return 1 } typealias y_ty = Int diff --git a/test/NameBinding/scope_map_lookup.swift b/test/NameBinding/scope_map_lookup.swift index ded7bed0b4528..e97d4d7a7d940 100644 --- a/test/NameBinding/scope_map_lookup.swift +++ b/test/NameBinding/scope_map_lookup.swift @@ -1,7 +1,7 @@ // XFAIL: * // RUN: %target-typecheck-verify-swift -enable-astscope-lookup -// Name binding in default arguments +// Name lookup in default arguments // FIXME: Semantic analysis should not recommend 'x' or 'y' here, because they // are not actually available. @@ -12,7 +12,7 @@ func functionParamScopes(x: Int, y: Int = x) -> Int { return x + y } -// Name binding in instance methods. +// Name lookup in instance methods. class C1 { var x = 0 From 5b99c2020f39526c6530b6137506e51fc6ab211b Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Fri, 27 Mar 2020 22:23:18 -0700 Subject: [PATCH 5/5] NFC: Re-organize NameBinding tests The directory currently seems to have a mix of tests for import resolution and name lookup. Therefore split it into two directories; ImportResolution and NameLookup. --- lib/AST/UnqualifiedLookup.cpp | 2 +- .../Inputs/ClangModuleWithOverlay/ClangModuleWithOverlay.h | 0 .../Inputs/ClangModuleWithOverlay/module.modulemap | 0 .../Inputs/DeclsUsedWrongly.swift | 0 .../Inputs/TestableVersusIndirect1.swift | 0 .../Inputs/TestableVersusIndirect2.swift | 0 .../Inputs/TestableVersusIndirectImporter.swift | 0 test/{NameBinding => ImportResolution}/Inputs/abcde.swift | 0 test/{NameBinding => ImportResolution}/Inputs/aeiou.swift | 0 .../Inputs/ambiguous.swift | 0 .../Inputs/ambiguous_left.swift | 0 .../Inputs/ambiguous_right.swift | 0 test/{NameBinding => ImportResolution}/Inputs/asdf.swift | 0 test/{NameBinding => ImportResolution}/Inputs/letters.swift | 0 test/{NameBinding => ImportResolution}/Inputs/overlay.swift | 0 .../Inputs/overload_boolFunctions.swift | 0 .../Inputs/overload_intFunctions.swift | 0 .../Inputs/overload_vars.swift | 0 test/{NameBinding => ImportResolution}/Inputs/sdf.swift | 0 .../import-command-line.swift | 0 .../import-implementation-only.swift | 0 .../import-multiple-command-line.swift | 0 .../import-resolution-2.swift | 0 .../import-resolution-3.swift | 0 .../import-resolution-overload.swift | 0 .../import-resolution-overload_swift4.swift | 0 .../import-resolution-overload_swift5.swift | 0 .../import-resolution.swift | 0 .../import-specific-decl.swift | 0 .../import-specific-fixits.swift | 0 test/{NameBinding => ImportResolution}/scoped_imports.swift | 0 .../testable-vs-indirect-import.swift | 0 .../Dependencies/Inputs/InterestingType.swift | 0 .../Dependencies/private-function-fine.swift | 0 .../Dependencies/private-function-return-type-fine.swift | 0 .../Dependencies/private-function-return-type.swift | 0 .../Dependencies/private-function.swift | 0 .../Dependencies/private-protocol-conformer-ext-fine.swift | 0 .../Dependencies/private-protocol-conformer-ext.swift | 0 .../Dependencies/private-protocol-conformer-fine.swift | 0 .../Dependencies/private-protocol-conformer.swift | 0 .../Dependencies/private-struct-member-fine.swift | 0 .../Dependencies/private-struct-member.swift | 0 .../Dependencies/private-subscript-fine.swift | 0 .../Dependencies/private-subscript.swift | 0 .../Dependencies/private-typealias-fine.swift | 0 .../Dependencies/private-typealias.swift | 0 .../Dependencies/private-var-fine.swift | 0 .../Dependencies/private-var.swift | 0 test/{NameBinding => NameLookup}/InheritedConformance.swift | 0 .../Inputs/HasPrivateAccess1.swift | 0 .../Inputs/HasPrivateAccess2.swift | 0 test/{NameBinding => NameLookup}/Inputs/HasResult.swift | 0 .../Inputs/MemberTypesInClasses.swift | 0 .../Inputs/NIOFoundationCompat.swift | 0 .../Inputs/NamedLazyMembers/NamedLazyMembers.apinotes | 0 .../Inputs/NamedLazyMembers/NamedLazyMembers.h | 0 .../Inputs/NamedLazyMembers/NamedLazyMembers.swift | 0 .../Inputs/NamedLazyMembers/NamedLazyMembersExt.swift | 0 .../Inputs/NamedLazyMembers/module.modulemap | 0 .../Inputs/accessibility_other.swift | 0 test/NameLookup/Inputs/ambiguous_left.swift | 6 ++++++ test/NameLookup/Inputs/ambiguous_right.swift | 6 ++++++ .../Inputs/has_accessibility.swift | 0 .../Inputs/imported_module.swift | 0 .../Inputs/lazy_function_body_expansion_helper.swift | 0 test/{NameBinding => NameLookup}/Inputs/multi-file-2.swift | 0 test/{NameBinding => NameLookup}/Inputs/multi-file-3.swift | 0 .../Inputs/multi-file-with-main/main.swift | 0 .../Inputs/objc_multi_file_2.swift | 0 .../Inputs/property_wrappers_A.swift | 0 .../Inputs/property_wrappers_B.swift | 0 .../Inputs/protocol-inheritance.swift | 0 .../Inputs/reference-dependencies-helper.swift | 0 .../Inputs/reference-dependencies-members-helper.swift | 0 .../Inputs/tilde_tilde_high_precedence.swift | 0 .../Inputs/tilde_tilde_low_precedence.swift | 0 test/{NameBinding => NameLookup}/accessibility.swift | 0 .../custom-attr-on-extension.swift | 0 .../debug-client-discriminator.swift | 0 test/{NameBinding => NameLookup}/disabled_opaque_decl.swift | 0 .../lazy_function_body_expansion.swift | 0 test/{NameBinding => NameLookup}/library.swift | 0 .../{NameBinding => NameLookup}/member_type_shadowing.swift | 0 test/{NameBinding => NameLookup}/multi-file-with-main.swift | 0 test/{NameBinding => NameLookup}/multi-file.swift | 0 test/{NameBinding => NameLookup}/name_lookup.swift | 0 .../name-binding.swift => NameLookup/name_lookup2.swift} | 0 .../name_lookup_min_max_conditional_conformance.swift | 0 .../named_lazy_member_loading_anyobject.swift | 0 .../named_lazy_member_loading_objc_category.swift | 0 .../named_lazy_member_loading_objc_interface.swift | 0 .../named_lazy_member_loading_objc_protocol.swift | 0 .../named_lazy_member_loading_protocol_mirroring.swift | 0 .../named_lazy_member_loading_swift_class.swift | 0 .../named_lazy_member_loading_swift_class_type.swift | 0 .../named_lazy_member_loading_swift_derived_class.swift | 0 ...named_lazy_member_loading_swift_derived_class_type.swift | 0 .../named_lazy_member_loading_swift_enum.swift | 0 .../named_lazy_member_loading_swift_proto.swift | 0 .../named_lazy_member_loading_swift_struct.swift | 0 .../named_lazy_member_loading_swift_struct_ext.swift | 0 .../named_lazy_member_loading_swift_struct_ext_mem.swift | 0 test/{NameBinding => NameLookup}/nio_shadowing.swift | 0 test/{NameBinding => NameLookup}/objc_multi_file.swift | 0 .../property_wrappers_ambig.swift | 0 test/{NameBinding => NameLookup}/protocol-inheritance.swift | 0 .../reference-dependencies-consistency-fine.swift | 0 .../reference-dependencies-consistency.swift | 0 .../reference-dependencies-dynamic-lookup-fine.swift | 0 .../reference-dependencies-dynamic-lookup.swift | 0 .../reference-dependencies-errors.swift | 0 .../reference-dependencies-fine.swift | 0 .../reference-dependencies-members-fine.swift | 0 .../reference-dependencies-members.swift | 0 .../reference-dependencies.swift | 0 .../scope_map-astscopelookup.swift | 0 test/{NameBinding => NameLookup}/scope_map_lookup.swift | 0 .../scope_map_lookup_extension_extension.swift | 0 test/{NameBinding => NameLookup}/scope_map_top_level.swift | 2 +- .../{NameBinding => NameLookup}/stdlib-case-sensitive.swift | 0 test/{NameBinding => NameLookup}/stdlib.swift | 0 test/{NameBinding => NameLookup}/stdlib_shadowing.swift | 0 .../subscript-generic-conjuction-astscope.swift | 0 test/{NameBinding => NameLookup}/warn-if-astscope.swift | 0 125 files changed, 14 insertions(+), 2 deletions(-) rename test/{NameBinding => ImportResolution}/Inputs/ClangModuleWithOverlay/ClangModuleWithOverlay.h (100%) rename test/{NameBinding => ImportResolution}/Inputs/ClangModuleWithOverlay/module.modulemap (100%) rename test/{NameBinding => ImportResolution}/Inputs/DeclsUsedWrongly.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/TestableVersusIndirect1.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/TestableVersusIndirect2.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/TestableVersusIndirectImporter.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/abcde.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/aeiou.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/ambiguous.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/ambiguous_left.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/ambiguous_right.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/asdf.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/letters.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/overlay.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/overload_boolFunctions.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/overload_intFunctions.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/overload_vars.swift (100%) rename test/{NameBinding => ImportResolution}/Inputs/sdf.swift (100%) rename test/{NameBinding => ImportResolution}/import-command-line.swift (100%) rename test/{NameBinding => ImportResolution}/import-implementation-only.swift (100%) rename test/{NameBinding => ImportResolution}/import-multiple-command-line.swift (100%) rename test/{NameBinding => ImportResolution}/import-resolution-2.swift (100%) rename test/{NameBinding => ImportResolution}/import-resolution-3.swift (100%) rename test/{NameBinding => ImportResolution}/import-resolution-overload.swift (100%) rename test/{NameBinding => ImportResolution}/import-resolution-overload_swift4.swift (100%) rename test/{NameBinding => ImportResolution}/import-resolution-overload_swift5.swift (100%) rename test/{NameBinding => ImportResolution}/import-resolution.swift (100%) rename test/{NameBinding => ImportResolution}/import-specific-decl.swift (100%) rename test/{NameBinding => ImportResolution}/import-specific-fixits.swift (100%) rename test/{NameBinding => ImportResolution}/scoped_imports.swift (100%) rename test/{NameBinding => ImportResolution}/testable-vs-indirect-import.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/Inputs/InterestingType.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-function-fine.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-function-return-type-fine.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-function-return-type.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-function.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-protocol-conformer-ext-fine.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-protocol-conformer-ext.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-protocol-conformer-fine.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-protocol-conformer.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-struct-member-fine.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-struct-member.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-subscript-fine.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-subscript.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-typealias-fine.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-typealias.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-var-fine.swift (100%) rename test/{NameBinding => NameLookup}/Dependencies/private-var.swift (100%) rename test/{NameBinding => NameLookup}/InheritedConformance.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/HasPrivateAccess1.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/HasPrivateAccess2.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/HasResult.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/MemberTypesInClasses.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/NIOFoundationCompat.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/NamedLazyMembers/NamedLazyMembers.apinotes (100%) rename test/{NameBinding => NameLookup}/Inputs/NamedLazyMembers/NamedLazyMembers.h (100%) rename test/{NameBinding => NameLookup}/Inputs/NamedLazyMembers/NamedLazyMembers.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/NamedLazyMembers/NamedLazyMembersExt.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/NamedLazyMembers/module.modulemap (100%) rename test/{NameBinding => NameLookup}/Inputs/accessibility_other.swift (100%) create mode 100644 test/NameLookup/Inputs/ambiguous_left.swift create mode 100644 test/NameLookup/Inputs/ambiguous_right.swift rename test/{NameBinding => NameLookup}/Inputs/has_accessibility.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/imported_module.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/lazy_function_body_expansion_helper.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/multi-file-2.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/multi-file-3.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/multi-file-with-main/main.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/objc_multi_file_2.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/property_wrappers_A.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/property_wrappers_B.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/protocol-inheritance.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/reference-dependencies-helper.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/reference-dependencies-members-helper.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/tilde_tilde_high_precedence.swift (100%) rename test/{NameBinding => NameLookup}/Inputs/tilde_tilde_low_precedence.swift (100%) rename test/{NameBinding => NameLookup}/accessibility.swift (100%) rename test/{NameBinding => NameLookup}/custom-attr-on-extension.swift (100%) rename test/{NameBinding => NameLookup}/debug-client-discriminator.swift (100%) rename test/{NameBinding => NameLookup}/disabled_opaque_decl.swift (100%) rename test/{NameBinding => NameLookup}/lazy_function_body_expansion.swift (100%) rename test/{NameBinding => NameLookup}/library.swift (100%) rename test/{NameBinding => NameLookup}/member_type_shadowing.swift (100%) rename test/{NameBinding => NameLookup}/multi-file-with-main.swift (100%) rename test/{NameBinding => NameLookup}/multi-file.swift (100%) rename test/{NameBinding => NameLookup}/name_lookup.swift (100%) rename test/{NameBinding/name-binding.swift => NameLookup/name_lookup2.swift} (100%) rename test/{NameBinding => NameLookup}/name_lookup_min_max_conditional_conformance.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_anyobject.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_objc_category.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_objc_interface.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_objc_protocol.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_protocol_mirroring.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_swift_class.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_swift_class_type.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_swift_derived_class.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_swift_derived_class_type.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_swift_enum.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_swift_proto.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_swift_struct.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_swift_struct_ext.swift (100%) rename test/{NameBinding => NameLookup}/named_lazy_member_loading_swift_struct_ext_mem.swift (100%) rename test/{NameBinding => NameLookup}/nio_shadowing.swift (100%) rename test/{NameBinding => NameLookup}/objc_multi_file.swift (100%) rename test/{NameBinding => NameLookup}/property_wrappers_ambig.swift (100%) rename test/{NameBinding => NameLookup}/protocol-inheritance.swift (100%) rename test/{NameBinding => NameLookup}/reference-dependencies-consistency-fine.swift (100%) rename test/{NameBinding => NameLookup}/reference-dependencies-consistency.swift (100%) rename test/{NameBinding => NameLookup}/reference-dependencies-dynamic-lookup-fine.swift (100%) rename test/{NameBinding => NameLookup}/reference-dependencies-dynamic-lookup.swift (100%) rename test/{NameBinding => NameLookup}/reference-dependencies-errors.swift (100%) rename test/{NameBinding => NameLookup}/reference-dependencies-fine.swift (100%) rename test/{NameBinding => NameLookup}/reference-dependencies-members-fine.swift (100%) rename test/{NameBinding => NameLookup}/reference-dependencies-members.swift (100%) rename test/{NameBinding => NameLookup}/reference-dependencies.swift (100%) rename test/{NameBinding => NameLookup}/scope_map-astscopelookup.swift (100%) rename test/{NameBinding => NameLookup}/scope_map_lookup.swift (100%) rename test/{NameBinding => NameLookup}/scope_map_lookup_extension_extension.swift (100%) rename test/{NameBinding => NameLookup}/scope_map_top_level.swift (97%) rename test/{NameBinding => NameLookup}/stdlib-case-sensitive.swift (100%) rename test/{NameBinding => NameLookup}/stdlib.swift (100%) rename test/{NameBinding => NameLookup}/stdlib_shadowing.swift (100%) rename test/{NameBinding => NameLookup}/subscript-generic-conjuction-astscope.swift (100%) rename test/{NameBinding => NameLookup}/warn-if-astscope.swift (100%) diff --git a/lib/AST/UnqualifiedLookup.cpp b/lib/AST/UnqualifiedLookup.cpp index 2f17010821790..7978e1d9f7ec9 100644 --- a/lib/AST/UnqualifiedLookup.cpp +++ b/lib/AST/UnqualifiedLookup.cpp @@ -1448,7 +1448,7 @@ bool UnqualifiedLookupFactory::shouldDiffer() const { "swift/test/TypeCoercion/overload_noncall.swift", "swift/test/expr/capture/nested_class.swift", "swift/test/expr/capture/order.swift", - "swift/test/NameBinding/name-binding.swift" + "swift/test/NameLookup/name_lookup2.swift" }; StringRef fileName = SF->getFilename(); return llvm::any_of(testsThatShouldDiffer, [&](const char *testFile) { diff --git a/test/NameBinding/Inputs/ClangModuleWithOverlay/ClangModuleWithOverlay.h b/test/ImportResolution/Inputs/ClangModuleWithOverlay/ClangModuleWithOverlay.h similarity index 100% rename from test/NameBinding/Inputs/ClangModuleWithOverlay/ClangModuleWithOverlay.h rename to test/ImportResolution/Inputs/ClangModuleWithOverlay/ClangModuleWithOverlay.h diff --git a/test/NameBinding/Inputs/ClangModuleWithOverlay/module.modulemap b/test/ImportResolution/Inputs/ClangModuleWithOverlay/module.modulemap similarity index 100% rename from test/NameBinding/Inputs/ClangModuleWithOverlay/module.modulemap rename to test/ImportResolution/Inputs/ClangModuleWithOverlay/module.modulemap diff --git a/test/NameBinding/Inputs/DeclsUsedWrongly.swift b/test/ImportResolution/Inputs/DeclsUsedWrongly.swift similarity index 100% rename from test/NameBinding/Inputs/DeclsUsedWrongly.swift rename to test/ImportResolution/Inputs/DeclsUsedWrongly.swift diff --git a/test/NameBinding/Inputs/TestableVersusIndirect1.swift b/test/ImportResolution/Inputs/TestableVersusIndirect1.swift similarity index 100% rename from test/NameBinding/Inputs/TestableVersusIndirect1.swift rename to test/ImportResolution/Inputs/TestableVersusIndirect1.swift diff --git a/test/NameBinding/Inputs/TestableVersusIndirect2.swift b/test/ImportResolution/Inputs/TestableVersusIndirect2.swift similarity index 100% rename from test/NameBinding/Inputs/TestableVersusIndirect2.swift rename to test/ImportResolution/Inputs/TestableVersusIndirect2.swift diff --git a/test/NameBinding/Inputs/TestableVersusIndirectImporter.swift b/test/ImportResolution/Inputs/TestableVersusIndirectImporter.swift similarity index 100% rename from test/NameBinding/Inputs/TestableVersusIndirectImporter.swift rename to test/ImportResolution/Inputs/TestableVersusIndirectImporter.swift diff --git a/test/NameBinding/Inputs/abcde.swift b/test/ImportResolution/Inputs/abcde.swift similarity index 100% rename from test/NameBinding/Inputs/abcde.swift rename to test/ImportResolution/Inputs/abcde.swift diff --git a/test/NameBinding/Inputs/aeiou.swift b/test/ImportResolution/Inputs/aeiou.swift similarity index 100% rename from test/NameBinding/Inputs/aeiou.swift rename to test/ImportResolution/Inputs/aeiou.swift diff --git a/test/NameBinding/Inputs/ambiguous.swift b/test/ImportResolution/Inputs/ambiguous.swift similarity index 100% rename from test/NameBinding/Inputs/ambiguous.swift rename to test/ImportResolution/Inputs/ambiguous.swift diff --git a/test/NameBinding/Inputs/ambiguous_left.swift b/test/ImportResolution/Inputs/ambiguous_left.swift similarity index 100% rename from test/NameBinding/Inputs/ambiguous_left.swift rename to test/ImportResolution/Inputs/ambiguous_left.swift diff --git a/test/NameBinding/Inputs/ambiguous_right.swift b/test/ImportResolution/Inputs/ambiguous_right.swift similarity index 100% rename from test/NameBinding/Inputs/ambiguous_right.swift rename to test/ImportResolution/Inputs/ambiguous_right.swift diff --git a/test/NameBinding/Inputs/asdf.swift b/test/ImportResolution/Inputs/asdf.swift similarity index 100% rename from test/NameBinding/Inputs/asdf.swift rename to test/ImportResolution/Inputs/asdf.swift diff --git a/test/NameBinding/Inputs/letters.swift b/test/ImportResolution/Inputs/letters.swift similarity index 100% rename from test/NameBinding/Inputs/letters.swift rename to test/ImportResolution/Inputs/letters.swift diff --git a/test/NameBinding/Inputs/overlay.swift b/test/ImportResolution/Inputs/overlay.swift similarity index 100% rename from test/NameBinding/Inputs/overlay.swift rename to test/ImportResolution/Inputs/overlay.swift diff --git a/test/NameBinding/Inputs/overload_boolFunctions.swift b/test/ImportResolution/Inputs/overload_boolFunctions.swift similarity index 100% rename from test/NameBinding/Inputs/overload_boolFunctions.swift rename to test/ImportResolution/Inputs/overload_boolFunctions.swift diff --git a/test/NameBinding/Inputs/overload_intFunctions.swift b/test/ImportResolution/Inputs/overload_intFunctions.swift similarity index 100% rename from test/NameBinding/Inputs/overload_intFunctions.swift rename to test/ImportResolution/Inputs/overload_intFunctions.swift diff --git a/test/NameBinding/Inputs/overload_vars.swift b/test/ImportResolution/Inputs/overload_vars.swift similarity index 100% rename from test/NameBinding/Inputs/overload_vars.swift rename to test/ImportResolution/Inputs/overload_vars.swift diff --git a/test/NameBinding/Inputs/sdf.swift b/test/ImportResolution/Inputs/sdf.swift similarity index 100% rename from test/NameBinding/Inputs/sdf.swift rename to test/ImportResolution/Inputs/sdf.swift diff --git a/test/NameBinding/import-command-line.swift b/test/ImportResolution/import-command-line.swift similarity index 100% rename from test/NameBinding/import-command-line.swift rename to test/ImportResolution/import-command-line.swift diff --git a/test/NameBinding/import-implementation-only.swift b/test/ImportResolution/import-implementation-only.swift similarity index 100% rename from test/NameBinding/import-implementation-only.swift rename to test/ImportResolution/import-implementation-only.swift diff --git a/test/NameBinding/import-multiple-command-line.swift b/test/ImportResolution/import-multiple-command-line.swift similarity index 100% rename from test/NameBinding/import-multiple-command-line.swift rename to test/ImportResolution/import-multiple-command-line.swift diff --git a/test/NameBinding/import-resolution-2.swift b/test/ImportResolution/import-resolution-2.swift similarity index 100% rename from test/NameBinding/import-resolution-2.swift rename to test/ImportResolution/import-resolution-2.swift diff --git a/test/NameBinding/import-resolution-3.swift b/test/ImportResolution/import-resolution-3.swift similarity index 100% rename from test/NameBinding/import-resolution-3.swift rename to test/ImportResolution/import-resolution-3.swift diff --git a/test/NameBinding/import-resolution-overload.swift b/test/ImportResolution/import-resolution-overload.swift similarity index 100% rename from test/NameBinding/import-resolution-overload.swift rename to test/ImportResolution/import-resolution-overload.swift diff --git a/test/NameBinding/import-resolution-overload_swift4.swift b/test/ImportResolution/import-resolution-overload_swift4.swift similarity index 100% rename from test/NameBinding/import-resolution-overload_swift4.swift rename to test/ImportResolution/import-resolution-overload_swift4.swift diff --git a/test/NameBinding/import-resolution-overload_swift5.swift b/test/ImportResolution/import-resolution-overload_swift5.swift similarity index 100% rename from test/NameBinding/import-resolution-overload_swift5.swift rename to test/ImportResolution/import-resolution-overload_swift5.swift diff --git a/test/NameBinding/import-resolution.swift b/test/ImportResolution/import-resolution.swift similarity index 100% rename from test/NameBinding/import-resolution.swift rename to test/ImportResolution/import-resolution.swift diff --git a/test/NameBinding/import-specific-decl.swift b/test/ImportResolution/import-specific-decl.swift similarity index 100% rename from test/NameBinding/import-specific-decl.swift rename to test/ImportResolution/import-specific-decl.swift diff --git a/test/NameBinding/import-specific-fixits.swift b/test/ImportResolution/import-specific-fixits.swift similarity index 100% rename from test/NameBinding/import-specific-fixits.swift rename to test/ImportResolution/import-specific-fixits.swift diff --git a/test/NameBinding/scoped_imports.swift b/test/ImportResolution/scoped_imports.swift similarity index 100% rename from test/NameBinding/scoped_imports.swift rename to test/ImportResolution/scoped_imports.swift diff --git a/test/NameBinding/testable-vs-indirect-import.swift b/test/ImportResolution/testable-vs-indirect-import.swift similarity index 100% rename from test/NameBinding/testable-vs-indirect-import.swift rename to test/ImportResolution/testable-vs-indirect-import.swift diff --git a/test/NameBinding/Dependencies/Inputs/InterestingType.swift b/test/NameLookup/Dependencies/Inputs/InterestingType.swift similarity index 100% rename from test/NameBinding/Dependencies/Inputs/InterestingType.swift rename to test/NameLookup/Dependencies/Inputs/InterestingType.swift diff --git a/test/NameBinding/Dependencies/private-function-fine.swift b/test/NameLookup/Dependencies/private-function-fine.swift similarity index 100% rename from test/NameBinding/Dependencies/private-function-fine.swift rename to test/NameLookup/Dependencies/private-function-fine.swift diff --git a/test/NameBinding/Dependencies/private-function-return-type-fine.swift b/test/NameLookup/Dependencies/private-function-return-type-fine.swift similarity index 100% rename from test/NameBinding/Dependencies/private-function-return-type-fine.swift rename to test/NameLookup/Dependencies/private-function-return-type-fine.swift diff --git a/test/NameBinding/Dependencies/private-function-return-type.swift b/test/NameLookup/Dependencies/private-function-return-type.swift similarity index 100% rename from test/NameBinding/Dependencies/private-function-return-type.swift rename to test/NameLookup/Dependencies/private-function-return-type.swift diff --git a/test/NameBinding/Dependencies/private-function.swift b/test/NameLookup/Dependencies/private-function.swift similarity index 100% rename from test/NameBinding/Dependencies/private-function.swift rename to test/NameLookup/Dependencies/private-function.swift diff --git a/test/NameBinding/Dependencies/private-protocol-conformer-ext-fine.swift b/test/NameLookup/Dependencies/private-protocol-conformer-ext-fine.swift similarity index 100% rename from test/NameBinding/Dependencies/private-protocol-conformer-ext-fine.swift rename to test/NameLookup/Dependencies/private-protocol-conformer-ext-fine.swift diff --git a/test/NameBinding/Dependencies/private-protocol-conformer-ext.swift b/test/NameLookup/Dependencies/private-protocol-conformer-ext.swift similarity index 100% rename from test/NameBinding/Dependencies/private-protocol-conformer-ext.swift rename to test/NameLookup/Dependencies/private-protocol-conformer-ext.swift diff --git a/test/NameBinding/Dependencies/private-protocol-conformer-fine.swift b/test/NameLookup/Dependencies/private-protocol-conformer-fine.swift similarity index 100% rename from test/NameBinding/Dependencies/private-protocol-conformer-fine.swift rename to test/NameLookup/Dependencies/private-protocol-conformer-fine.swift diff --git a/test/NameBinding/Dependencies/private-protocol-conformer.swift b/test/NameLookup/Dependencies/private-protocol-conformer.swift similarity index 100% rename from test/NameBinding/Dependencies/private-protocol-conformer.swift rename to test/NameLookup/Dependencies/private-protocol-conformer.swift diff --git a/test/NameBinding/Dependencies/private-struct-member-fine.swift b/test/NameLookup/Dependencies/private-struct-member-fine.swift similarity index 100% rename from test/NameBinding/Dependencies/private-struct-member-fine.swift rename to test/NameLookup/Dependencies/private-struct-member-fine.swift diff --git a/test/NameBinding/Dependencies/private-struct-member.swift b/test/NameLookup/Dependencies/private-struct-member.swift similarity index 100% rename from test/NameBinding/Dependencies/private-struct-member.swift rename to test/NameLookup/Dependencies/private-struct-member.swift diff --git a/test/NameBinding/Dependencies/private-subscript-fine.swift b/test/NameLookup/Dependencies/private-subscript-fine.swift similarity index 100% rename from test/NameBinding/Dependencies/private-subscript-fine.swift rename to test/NameLookup/Dependencies/private-subscript-fine.swift diff --git a/test/NameBinding/Dependencies/private-subscript.swift b/test/NameLookup/Dependencies/private-subscript.swift similarity index 100% rename from test/NameBinding/Dependencies/private-subscript.swift rename to test/NameLookup/Dependencies/private-subscript.swift diff --git a/test/NameBinding/Dependencies/private-typealias-fine.swift b/test/NameLookup/Dependencies/private-typealias-fine.swift similarity index 100% rename from test/NameBinding/Dependencies/private-typealias-fine.swift rename to test/NameLookup/Dependencies/private-typealias-fine.swift diff --git a/test/NameBinding/Dependencies/private-typealias.swift b/test/NameLookup/Dependencies/private-typealias.swift similarity index 100% rename from test/NameBinding/Dependencies/private-typealias.swift rename to test/NameLookup/Dependencies/private-typealias.swift diff --git a/test/NameBinding/Dependencies/private-var-fine.swift b/test/NameLookup/Dependencies/private-var-fine.swift similarity index 100% rename from test/NameBinding/Dependencies/private-var-fine.swift rename to test/NameLookup/Dependencies/private-var-fine.swift diff --git a/test/NameBinding/Dependencies/private-var.swift b/test/NameLookup/Dependencies/private-var.swift similarity index 100% rename from test/NameBinding/Dependencies/private-var.swift rename to test/NameLookup/Dependencies/private-var.swift diff --git a/test/NameBinding/InheritedConformance.swift b/test/NameLookup/InheritedConformance.swift similarity index 100% rename from test/NameBinding/InheritedConformance.swift rename to test/NameLookup/InheritedConformance.swift diff --git a/test/NameBinding/Inputs/HasPrivateAccess1.swift b/test/NameLookup/Inputs/HasPrivateAccess1.swift similarity index 100% rename from test/NameBinding/Inputs/HasPrivateAccess1.swift rename to test/NameLookup/Inputs/HasPrivateAccess1.swift diff --git a/test/NameBinding/Inputs/HasPrivateAccess2.swift b/test/NameLookup/Inputs/HasPrivateAccess2.swift similarity index 100% rename from test/NameBinding/Inputs/HasPrivateAccess2.swift rename to test/NameLookup/Inputs/HasPrivateAccess2.swift diff --git a/test/NameBinding/Inputs/HasResult.swift b/test/NameLookup/Inputs/HasResult.swift similarity index 100% rename from test/NameBinding/Inputs/HasResult.swift rename to test/NameLookup/Inputs/HasResult.swift diff --git a/test/NameBinding/Inputs/MemberTypesInClasses.swift b/test/NameLookup/Inputs/MemberTypesInClasses.swift similarity index 100% rename from test/NameBinding/Inputs/MemberTypesInClasses.swift rename to test/NameLookup/Inputs/MemberTypesInClasses.swift diff --git a/test/NameBinding/Inputs/NIOFoundationCompat.swift b/test/NameLookup/Inputs/NIOFoundationCompat.swift similarity index 100% rename from test/NameBinding/Inputs/NIOFoundationCompat.swift rename to test/NameLookup/Inputs/NIOFoundationCompat.swift diff --git a/test/NameBinding/Inputs/NamedLazyMembers/NamedLazyMembers.apinotes b/test/NameLookup/Inputs/NamedLazyMembers/NamedLazyMembers.apinotes similarity index 100% rename from test/NameBinding/Inputs/NamedLazyMembers/NamedLazyMembers.apinotes rename to test/NameLookup/Inputs/NamedLazyMembers/NamedLazyMembers.apinotes diff --git a/test/NameBinding/Inputs/NamedLazyMembers/NamedLazyMembers.h b/test/NameLookup/Inputs/NamedLazyMembers/NamedLazyMembers.h similarity index 100% rename from test/NameBinding/Inputs/NamedLazyMembers/NamedLazyMembers.h rename to test/NameLookup/Inputs/NamedLazyMembers/NamedLazyMembers.h diff --git a/test/NameBinding/Inputs/NamedLazyMembers/NamedLazyMembers.swift b/test/NameLookup/Inputs/NamedLazyMembers/NamedLazyMembers.swift similarity index 100% rename from test/NameBinding/Inputs/NamedLazyMembers/NamedLazyMembers.swift rename to test/NameLookup/Inputs/NamedLazyMembers/NamedLazyMembers.swift diff --git a/test/NameBinding/Inputs/NamedLazyMembers/NamedLazyMembersExt.swift b/test/NameLookup/Inputs/NamedLazyMembers/NamedLazyMembersExt.swift similarity index 100% rename from test/NameBinding/Inputs/NamedLazyMembers/NamedLazyMembersExt.swift rename to test/NameLookup/Inputs/NamedLazyMembers/NamedLazyMembersExt.swift diff --git a/test/NameBinding/Inputs/NamedLazyMembers/module.modulemap b/test/NameLookup/Inputs/NamedLazyMembers/module.modulemap similarity index 100% rename from test/NameBinding/Inputs/NamedLazyMembers/module.modulemap rename to test/NameLookup/Inputs/NamedLazyMembers/module.modulemap diff --git a/test/NameBinding/Inputs/accessibility_other.swift b/test/NameLookup/Inputs/accessibility_other.swift similarity index 100% rename from test/NameBinding/Inputs/accessibility_other.swift rename to test/NameLookup/Inputs/accessibility_other.swift diff --git a/test/NameLookup/Inputs/ambiguous_left.swift b/test/NameLookup/Inputs/ambiguous_left.swift new file mode 100644 index 0000000000000..ceeeb209bb0eb --- /dev/null +++ b/test/NameLookup/Inputs/ambiguous_left.swift @@ -0,0 +1,6 @@ +public func funcOrVar() {} + +public struct SomeStruct {} +public var someVar : () = () + +public func overloadedFunc() {} diff --git a/test/NameLookup/Inputs/ambiguous_right.swift b/test/NameLookup/Inputs/ambiguous_right.swift new file mode 100644 index 0000000000000..9c039713de922 --- /dev/null +++ b/test/NameLookup/Inputs/ambiguous_right.swift @@ -0,0 +1,6 @@ +public var funcOrVar : Int = Int() + +public struct SomeStruct {} +public var someVar : () = () + +public func overloadedFunc(x: Int) {} diff --git a/test/NameBinding/Inputs/has_accessibility.swift b/test/NameLookup/Inputs/has_accessibility.swift similarity index 100% rename from test/NameBinding/Inputs/has_accessibility.swift rename to test/NameLookup/Inputs/has_accessibility.swift diff --git a/test/NameBinding/Inputs/imported_module.swift b/test/NameLookup/Inputs/imported_module.swift similarity index 100% rename from test/NameBinding/Inputs/imported_module.swift rename to test/NameLookup/Inputs/imported_module.swift diff --git a/test/NameBinding/Inputs/lazy_function_body_expansion_helper.swift b/test/NameLookup/Inputs/lazy_function_body_expansion_helper.swift similarity index 100% rename from test/NameBinding/Inputs/lazy_function_body_expansion_helper.swift rename to test/NameLookup/Inputs/lazy_function_body_expansion_helper.swift diff --git a/test/NameBinding/Inputs/multi-file-2.swift b/test/NameLookup/Inputs/multi-file-2.swift similarity index 100% rename from test/NameBinding/Inputs/multi-file-2.swift rename to test/NameLookup/Inputs/multi-file-2.swift diff --git a/test/NameBinding/Inputs/multi-file-3.swift b/test/NameLookup/Inputs/multi-file-3.swift similarity index 100% rename from test/NameBinding/Inputs/multi-file-3.swift rename to test/NameLookup/Inputs/multi-file-3.swift diff --git a/test/NameBinding/Inputs/multi-file-with-main/main.swift b/test/NameLookup/Inputs/multi-file-with-main/main.swift similarity index 100% rename from test/NameBinding/Inputs/multi-file-with-main/main.swift rename to test/NameLookup/Inputs/multi-file-with-main/main.swift diff --git a/test/NameBinding/Inputs/objc_multi_file_2.swift b/test/NameLookup/Inputs/objc_multi_file_2.swift similarity index 100% rename from test/NameBinding/Inputs/objc_multi_file_2.swift rename to test/NameLookup/Inputs/objc_multi_file_2.swift diff --git a/test/NameBinding/Inputs/property_wrappers_A.swift b/test/NameLookup/Inputs/property_wrappers_A.swift similarity index 100% rename from test/NameBinding/Inputs/property_wrappers_A.swift rename to test/NameLookup/Inputs/property_wrappers_A.swift diff --git a/test/NameBinding/Inputs/property_wrappers_B.swift b/test/NameLookup/Inputs/property_wrappers_B.swift similarity index 100% rename from test/NameBinding/Inputs/property_wrappers_B.swift rename to test/NameLookup/Inputs/property_wrappers_B.swift diff --git a/test/NameBinding/Inputs/protocol-inheritance.swift b/test/NameLookup/Inputs/protocol-inheritance.swift similarity index 100% rename from test/NameBinding/Inputs/protocol-inheritance.swift rename to test/NameLookup/Inputs/protocol-inheritance.swift diff --git a/test/NameBinding/Inputs/reference-dependencies-helper.swift b/test/NameLookup/Inputs/reference-dependencies-helper.swift similarity index 100% rename from test/NameBinding/Inputs/reference-dependencies-helper.swift rename to test/NameLookup/Inputs/reference-dependencies-helper.swift diff --git a/test/NameBinding/Inputs/reference-dependencies-members-helper.swift b/test/NameLookup/Inputs/reference-dependencies-members-helper.swift similarity index 100% rename from test/NameBinding/Inputs/reference-dependencies-members-helper.swift rename to test/NameLookup/Inputs/reference-dependencies-members-helper.swift diff --git a/test/NameBinding/Inputs/tilde_tilde_high_precedence.swift b/test/NameLookup/Inputs/tilde_tilde_high_precedence.swift similarity index 100% rename from test/NameBinding/Inputs/tilde_tilde_high_precedence.swift rename to test/NameLookup/Inputs/tilde_tilde_high_precedence.swift diff --git a/test/NameBinding/Inputs/tilde_tilde_low_precedence.swift b/test/NameLookup/Inputs/tilde_tilde_low_precedence.swift similarity index 100% rename from test/NameBinding/Inputs/tilde_tilde_low_precedence.swift rename to test/NameLookup/Inputs/tilde_tilde_low_precedence.swift diff --git a/test/NameBinding/accessibility.swift b/test/NameLookup/accessibility.swift similarity index 100% rename from test/NameBinding/accessibility.swift rename to test/NameLookup/accessibility.swift diff --git a/test/NameBinding/custom-attr-on-extension.swift b/test/NameLookup/custom-attr-on-extension.swift similarity index 100% rename from test/NameBinding/custom-attr-on-extension.swift rename to test/NameLookup/custom-attr-on-extension.swift diff --git a/test/NameBinding/debug-client-discriminator.swift b/test/NameLookup/debug-client-discriminator.swift similarity index 100% rename from test/NameBinding/debug-client-discriminator.swift rename to test/NameLookup/debug-client-discriminator.swift diff --git a/test/NameBinding/disabled_opaque_decl.swift b/test/NameLookup/disabled_opaque_decl.swift similarity index 100% rename from test/NameBinding/disabled_opaque_decl.swift rename to test/NameLookup/disabled_opaque_decl.swift diff --git a/test/NameBinding/lazy_function_body_expansion.swift b/test/NameLookup/lazy_function_body_expansion.swift similarity index 100% rename from test/NameBinding/lazy_function_body_expansion.swift rename to test/NameLookup/lazy_function_body_expansion.swift diff --git a/test/NameBinding/library.swift b/test/NameLookup/library.swift similarity index 100% rename from test/NameBinding/library.swift rename to test/NameLookup/library.swift diff --git a/test/NameBinding/member_type_shadowing.swift b/test/NameLookup/member_type_shadowing.swift similarity index 100% rename from test/NameBinding/member_type_shadowing.swift rename to test/NameLookup/member_type_shadowing.swift diff --git a/test/NameBinding/multi-file-with-main.swift b/test/NameLookup/multi-file-with-main.swift similarity index 100% rename from test/NameBinding/multi-file-with-main.swift rename to test/NameLookup/multi-file-with-main.swift diff --git a/test/NameBinding/multi-file.swift b/test/NameLookup/multi-file.swift similarity index 100% rename from test/NameBinding/multi-file.swift rename to test/NameLookup/multi-file.swift diff --git a/test/NameBinding/name_lookup.swift b/test/NameLookup/name_lookup.swift similarity index 100% rename from test/NameBinding/name_lookup.swift rename to test/NameLookup/name_lookup.swift diff --git a/test/NameBinding/name-binding.swift b/test/NameLookup/name_lookup2.swift similarity index 100% rename from test/NameBinding/name-binding.swift rename to test/NameLookup/name_lookup2.swift diff --git a/test/NameBinding/name_lookup_min_max_conditional_conformance.swift b/test/NameLookup/name_lookup_min_max_conditional_conformance.swift similarity index 100% rename from test/NameBinding/name_lookup_min_max_conditional_conformance.swift rename to test/NameLookup/name_lookup_min_max_conditional_conformance.swift diff --git a/test/NameBinding/named_lazy_member_loading_anyobject.swift b/test/NameLookup/named_lazy_member_loading_anyobject.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_anyobject.swift rename to test/NameLookup/named_lazy_member_loading_anyobject.swift diff --git a/test/NameBinding/named_lazy_member_loading_objc_category.swift b/test/NameLookup/named_lazy_member_loading_objc_category.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_objc_category.swift rename to test/NameLookup/named_lazy_member_loading_objc_category.swift diff --git a/test/NameBinding/named_lazy_member_loading_objc_interface.swift b/test/NameLookup/named_lazy_member_loading_objc_interface.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_objc_interface.swift rename to test/NameLookup/named_lazy_member_loading_objc_interface.swift diff --git a/test/NameBinding/named_lazy_member_loading_objc_protocol.swift b/test/NameLookup/named_lazy_member_loading_objc_protocol.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_objc_protocol.swift rename to test/NameLookup/named_lazy_member_loading_objc_protocol.swift diff --git a/test/NameBinding/named_lazy_member_loading_protocol_mirroring.swift b/test/NameLookup/named_lazy_member_loading_protocol_mirroring.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_protocol_mirroring.swift rename to test/NameLookup/named_lazy_member_loading_protocol_mirroring.swift diff --git a/test/NameBinding/named_lazy_member_loading_swift_class.swift b/test/NameLookup/named_lazy_member_loading_swift_class.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_swift_class.swift rename to test/NameLookup/named_lazy_member_loading_swift_class.swift diff --git a/test/NameBinding/named_lazy_member_loading_swift_class_type.swift b/test/NameLookup/named_lazy_member_loading_swift_class_type.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_swift_class_type.swift rename to test/NameLookup/named_lazy_member_loading_swift_class_type.swift diff --git a/test/NameBinding/named_lazy_member_loading_swift_derived_class.swift b/test/NameLookup/named_lazy_member_loading_swift_derived_class.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_swift_derived_class.swift rename to test/NameLookup/named_lazy_member_loading_swift_derived_class.swift diff --git a/test/NameBinding/named_lazy_member_loading_swift_derived_class_type.swift b/test/NameLookup/named_lazy_member_loading_swift_derived_class_type.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_swift_derived_class_type.swift rename to test/NameLookup/named_lazy_member_loading_swift_derived_class_type.swift diff --git a/test/NameBinding/named_lazy_member_loading_swift_enum.swift b/test/NameLookup/named_lazy_member_loading_swift_enum.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_swift_enum.swift rename to test/NameLookup/named_lazy_member_loading_swift_enum.swift diff --git a/test/NameBinding/named_lazy_member_loading_swift_proto.swift b/test/NameLookup/named_lazy_member_loading_swift_proto.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_swift_proto.swift rename to test/NameLookup/named_lazy_member_loading_swift_proto.swift diff --git a/test/NameBinding/named_lazy_member_loading_swift_struct.swift b/test/NameLookup/named_lazy_member_loading_swift_struct.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_swift_struct.swift rename to test/NameLookup/named_lazy_member_loading_swift_struct.swift diff --git a/test/NameBinding/named_lazy_member_loading_swift_struct_ext.swift b/test/NameLookup/named_lazy_member_loading_swift_struct_ext.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_swift_struct_ext.swift rename to test/NameLookup/named_lazy_member_loading_swift_struct_ext.swift diff --git a/test/NameBinding/named_lazy_member_loading_swift_struct_ext_mem.swift b/test/NameLookup/named_lazy_member_loading_swift_struct_ext_mem.swift similarity index 100% rename from test/NameBinding/named_lazy_member_loading_swift_struct_ext_mem.swift rename to test/NameLookup/named_lazy_member_loading_swift_struct_ext_mem.swift diff --git a/test/NameBinding/nio_shadowing.swift b/test/NameLookup/nio_shadowing.swift similarity index 100% rename from test/NameBinding/nio_shadowing.swift rename to test/NameLookup/nio_shadowing.swift diff --git a/test/NameBinding/objc_multi_file.swift b/test/NameLookup/objc_multi_file.swift similarity index 100% rename from test/NameBinding/objc_multi_file.swift rename to test/NameLookup/objc_multi_file.swift diff --git a/test/NameBinding/property_wrappers_ambig.swift b/test/NameLookup/property_wrappers_ambig.swift similarity index 100% rename from test/NameBinding/property_wrappers_ambig.swift rename to test/NameLookup/property_wrappers_ambig.swift diff --git a/test/NameBinding/protocol-inheritance.swift b/test/NameLookup/protocol-inheritance.swift similarity index 100% rename from test/NameBinding/protocol-inheritance.swift rename to test/NameLookup/protocol-inheritance.swift diff --git a/test/NameBinding/reference-dependencies-consistency-fine.swift b/test/NameLookup/reference-dependencies-consistency-fine.swift similarity index 100% rename from test/NameBinding/reference-dependencies-consistency-fine.swift rename to test/NameLookup/reference-dependencies-consistency-fine.swift diff --git a/test/NameBinding/reference-dependencies-consistency.swift b/test/NameLookup/reference-dependencies-consistency.swift similarity index 100% rename from test/NameBinding/reference-dependencies-consistency.swift rename to test/NameLookup/reference-dependencies-consistency.swift diff --git a/test/NameBinding/reference-dependencies-dynamic-lookup-fine.swift b/test/NameLookup/reference-dependencies-dynamic-lookup-fine.swift similarity index 100% rename from test/NameBinding/reference-dependencies-dynamic-lookup-fine.swift rename to test/NameLookup/reference-dependencies-dynamic-lookup-fine.swift diff --git a/test/NameBinding/reference-dependencies-dynamic-lookup.swift b/test/NameLookup/reference-dependencies-dynamic-lookup.swift similarity index 100% rename from test/NameBinding/reference-dependencies-dynamic-lookup.swift rename to test/NameLookup/reference-dependencies-dynamic-lookup.swift diff --git a/test/NameBinding/reference-dependencies-errors.swift b/test/NameLookup/reference-dependencies-errors.swift similarity index 100% rename from test/NameBinding/reference-dependencies-errors.swift rename to test/NameLookup/reference-dependencies-errors.swift diff --git a/test/NameBinding/reference-dependencies-fine.swift b/test/NameLookup/reference-dependencies-fine.swift similarity index 100% rename from test/NameBinding/reference-dependencies-fine.swift rename to test/NameLookup/reference-dependencies-fine.swift diff --git a/test/NameBinding/reference-dependencies-members-fine.swift b/test/NameLookup/reference-dependencies-members-fine.swift similarity index 100% rename from test/NameBinding/reference-dependencies-members-fine.swift rename to test/NameLookup/reference-dependencies-members-fine.swift diff --git a/test/NameBinding/reference-dependencies-members.swift b/test/NameLookup/reference-dependencies-members.swift similarity index 100% rename from test/NameBinding/reference-dependencies-members.swift rename to test/NameLookup/reference-dependencies-members.swift diff --git a/test/NameBinding/reference-dependencies.swift b/test/NameLookup/reference-dependencies.swift similarity index 100% rename from test/NameBinding/reference-dependencies.swift rename to test/NameLookup/reference-dependencies.swift diff --git a/test/NameBinding/scope_map-astscopelookup.swift b/test/NameLookup/scope_map-astscopelookup.swift similarity index 100% rename from test/NameBinding/scope_map-astscopelookup.swift rename to test/NameLookup/scope_map-astscopelookup.swift diff --git a/test/NameBinding/scope_map_lookup.swift b/test/NameLookup/scope_map_lookup.swift similarity index 100% rename from test/NameBinding/scope_map_lookup.swift rename to test/NameLookup/scope_map_lookup.swift diff --git a/test/NameBinding/scope_map_lookup_extension_extension.swift b/test/NameLookup/scope_map_lookup_extension_extension.swift similarity index 100% rename from test/NameBinding/scope_map_lookup_extension_extension.swift rename to test/NameLookup/scope_map_lookup_extension_extension.swift diff --git a/test/NameBinding/scope_map_top_level.swift b/test/NameLookup/scope_map_top_level.swift similarity index 97% rename from test/NameBinding/scope_map_top_level.swift rename to test/NameLookup/scope_map_top_level.swift index ed59389d34b68..e8adaac6e6ca3 100644 --- a/test/NameBinding/scope_map_top_level.swift +++ b/test/NameLookup/scope_map_top_level.swift @@ -26,7 +26,7 @@ var i: Int = b.my_identity() // CHECK-EXPANDED: ***Complete scope map*** -// CHECK-EXPANDED-NEXT: ASTSourceFileScope {{.*}}, (uncached) [1:1 - 6{{.*}}:1] 'SOURCE_DIR{{[/\\]}}test{{[/\\]}}NameBinding{{[/\\]}}scope_map_top_level.swift' +// CHECK-EXPANDED-NEXT: ASTSourceFileScope {{.*}}, (uncached) [1:1 - 6{{.*}}:1] 'SOURCE_DIR{{[/\\]}}test{{[/\\]}}NameLookup{{[/\\]}}scope_map_top_level.swift' // CHECK-EXPANDED-NEXT: |-NominalTypeDeclScope {{.*}}, [4:1 - 4:13] // CHECK-EXPANDED-NEXT: `-NominalTypeBodyScope {{.*}}, [4:11 - 4:13] // CHECK-EXPANDED-NEXT: `-TopLevelCodeScope {{.*}}, [6:1 - 21:28] diff --git a/test/NameBinding/stdlib-case-sensitive.swift b/test/NameLookup/stdlib-case-sensitive.swift similarity index 100% rename from test/NameBinding/stdlib-case-sensitive.swift rename to test/NameLookup/stdlib-case-sensitive.swift diff --git a/test/NameBinding/stdlib.swift b/test/NameLookup/stdlib.swift similarity index 100% rename from test/NameBinding/stdlib.swift rename to test/NameLookup/stdlib.swift diff --git a/test/NameBinding/stdlib_shadowing.swift b/test/NameLookup/stdlib_shadowing.swift similarity index 100% rename from test/NameBinding/stdlib_shadowing.swift rename to test/NameLookup/stdlib_shadowing.swift diff --git a/test/NameBinding/subscript-generic-conjuction-astscope.swift b/test/NameLookup/subscript-generic-conjuction-astscope.swift similarity index 100% rename from test/NameBinding/subscript-generic-conjuction-astscope.swift rename to test/NameLookup/subscript-generic-conjuction-astscope.swift diff --git a/test/NameBinding/warn-if-astscope.swift b/test/NameLookup/warn-if-astscope.swift similarity index 100% rename from test/NameBinding/warn-if-astscope.swift rename to test/NameLookup/warn-if-astscope.swift