[Diagnostics] Port name shadowing diagnostics

Diagnose an attempt to reference a top-level name shadowed by
a local member e.g.

```swift
extension Sequence {
  func test() -> Int {
    return max(1, 2)
  }
}
```

Here `min` refers to a global function `min<T>(_: T, _: T)` in `Swift`
module and can only be accessed by adding `Swift.` to it, because `Sequence`
has a member named `min` which accepts a single argument.
This commit is contained in:
Pavel Yaskevich
2020-01-03 20:31:17 -08:00
parent 7351bfc86f
commit c9c20afe27
4 changed files with 73 additions and 8 deletions

View File

@@ -1219,7 +1219,9 @@ AllowNonClassTypeToConvertToAnyObject::create(ConstraintSystem &cs, Type type,
}
bool AddQualifierToAccessTopLevelName::diagnose(bool asNote) const {
return false;
auto &cs = getConstraintSystem();
MissingQuialifierInMemberRefFailure failure(cs, getLocator());
return failure.diagnose(asNote);
}
AddQualifierToAccessTopLevelName *