mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user