Add an entry point for id-style lookup of a known name.

This will be used to resolve properties and method calls on objects with
dynamic-lookup ("id") type. For now, this is tested in swift-ide-test
by using the -dynamic-lookup-completion option and providing a
-code-completion-token value.

Caveats/TODOs:
- As before, since we're using the global method pool, this isn't scoped by
  module. We could do a per-module filter, but I don't know if that will
  actually buy us much.
- Again, Clang's method pool does not include methods from protocols.
- Lookup by selector name cannot find properties with a customized getter
  name. <rdar://problem/14776565>
- The Clang-side method pool is keyed by selector, but Swift wants to look
  things up by method name, which maps to the first selector piece, so we
  end up having to do a scan of all the selectors in the pool.

Swift SVN r7330
This commit is contained in:
Jordan Rose
2013-08-19 21:33:33 +00:00
parent 49d8b2c584
commit 2c7858bfb2
9 changed files with 179 additions and 11 deletions

View File

@@ -289,3 +289,14 @@ void SerializedModuleLoader::lookupClassMembers(const Module *module,
return;
moduleFile->lookupClassMembers(accessPath, consumer);
}
void
SerializedModuleLoader::lookupClassMember(const Module *module,
Module::AccessPathTy accessPath,
Identifier name,
SmallVectorImpl<ValueDecl*> &decls) {
ModuleFile *moduleFile = cast<SerializedModule>(module)->File;
if (!moduleFile)
return;
moduleFile->lookupClassMember(accessPath, name, decls);
}