Check operator declaration binding in the first pass for FuncDecls.

This eliminates the pre-pass we were performing to bind the operator
decls, which was only a pre-pass because we used to bind unresolved
declaration references too early. In the process, fixed some bugs
(e.g., it wasn't checking methods at all) and improved the QoI with
Fix-Its and notes:

t.swift:2:6: error: prefix unary operator missing 'prefix' attribute
func ~~~(x : Float) {}
     ^
     [prefix] 
t.swift:1:17: note: prefix operator found here
operator prefix ~~~ {}
                ^



Swift SVN r7099
This commit is contained in:
Doug Gregor
2013-08-09 21:01:47 +00:00
parent 48faba29f3
commit f736e1711c
4 changed files with 96 additions and 48 deletions

View File

@@ -238,12 +238,12 @@ Optional<OP_DECL *> lookupOperatorDeclForName(Module *M,
auto *TU = dyn_cast<TranslationUnit>(M);
if (!TU)
return nullptr;
return Nothing;
// Look for an operator declaration in the current module.
auto found = (TU->*OP_MAP).find(Name.get());
if (found != (TU->*OP_MAP).end())
return found->getValue();
return found->getValue()? Optional<OP_DECL *>(found->getValue()) : Nothing;
// Look for imported operator decls.
@@ -262,7 +262,7 @@ Optional<OP_DECL *> lookupOperatorDeclForName(Module *M,
if (importedOperators.empty()) {
// Cache the mapping so we don't need to troll imports next time.
(TU->*OP_MAP)[Name.get()] = nullptr;
return nullptr;
return Nothing;
}
if (importedOperators.size() == 1) {
// Cache the mapping so we don't need to troll imports next time.