| 73 | | Here is an attempt at a specification: |
| 74 | | 1. Say that an ''import-item'' is either an entire import-all decl (eg `import Foo`), |
| 75 | | or a particular item in an import list (eg `import Foo( ..., x, ...)`). |
| 76 | | 2. For every `RdrName` in the program text, choose one of the import-items |
| 77 | | that brought it into scope, the "chosen import-item", |
| 78 | | and mark it "used". |
| | 69 | Say that an ''import-item'' is either an entire import-all decl (eg `import Foo`), |
| | 70 | or a particular item in an import list (eg `import Foo( ..., x, ...)`). |
| | 71 | The general idea is that for each use of an imported name, we will attribute |
| | 72 | that use to one (or possibly more) import-items. Then, any import items with no |
| | 73 | uses attributed to them are unused, and are warned about. |
| | 74 | More precisely: |
| | 75 | |
| | 76 | 1. For every `RdrName` in the program text, find all the import-items that brought it into scope. The lookup mechanism on `RdrNames` already takes account of whether the `RdrName` was qualified, and which imports have the right qualification etc, so this step is very easy. |
| | 77 | |
| | 78 | 2. Choose one of these, the "chosen import-item", and mark it "used". |
| | 79 | |
| 97 | | Note that if we have an import item `import Foo (Bar(bar))`, then |
| 98 | | it's marked as used if either `Bar` or `bar` are used. We could have yet finer |
| 99 | | resolution and report even unused sub-items. |
| | 96 | * Note that if we have an import item `import Foo (Bar(bar))`, then |
| | 97 | it's marked as used if either `Bar` or `bar` are used. We could have yet finer |
| | 98 | resolution and report even unused sub-items. |
| | 99 | |
| | 100 | * We should retain the special case of not warning about `import Foo ()`, which implies "instance declarations only". |