summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonpj <unknown>2005-05-04 11:23:28 +0000
committersimonpj <unknown>2005-05-04 11:23:28 +0000
commitb528dca34a1c2d539fa40fbf3efc11a0f10b284f (patch)
tree8c05bce82249cadd83e3d6dbf17e79c98f4baa7c
parent00007e64fd17385867ab6b835a2ef77575e86229 (diff)
downloadhaskell-b528dca34a1c2d539fa40fbf3efc11a0f10b284f.tar.gz
[project @ 2005-05-04 11:23:28 by simonpj]
Further wibbles to unused-import reporting; merge to stable
-rw-r--r--ghc/compiler/rename/RnNames.lhs23
1 files changed, 15 insertions, 8 deletions
diff --git a/ghc/compiler/rename/RnNames.lhs b/ghc/compiler/rename/RnNames.lhs
index bd4e0f5a4c..2cc62f8afe 100644
--- a/ghc/compiler/rename/RnNames.lhs
+++ b/ghc/compiler/rename/RnNames.lhs
@@ -898,16 +898,23 @@ warnDuplicateImports gres
| red_imp <- imps
, cov_imp <- take 1 (filter (covers red_imp) imps) ]
+ -- "red_imp" is a putative redundant import
+ -- "cov_imp" potentially covers it
+ -- This test decides
covers red_imp cov_imp
| red_loc == cov_loc
- = False -- The diagonal elements
- | not $ (is_qual red_imp && is_as red_imp == is_as cov_imp)
- || not (is_qual cov_imp)
- = False -- Covering one doesn't cover!
- | is_explicit red_imp -- Tie-breaking
- = not cov_explicit || red_later
- | otherwise
- = not cov_explicit && red_later
+ = False -- Ignore diagonal elements
+ | not (is_as red_imp == is_as cov_imp)
+ = False -- They bring into scope different qualified names
+ | not (is_qual red_imp) && is_qual cov_imp
+ = False -- Covering one doesn't bring unqualified name into scope
+ | is_explicit red_imp
+ = not cov_explicit -- Redundant one is explicit and covering one isn't
+ || red_later -- Both are explicit; tie-break using red_later
+ | otherwise
+ = not cov_explicit -- Neither import is explicit
+ && (is_mod red_imp == is_mod cov_imp) -- They import the same module
+ && red_later -- Tie-break
where
cov_explicit = is_explicit cov_imp
red_loc = is_loc red_imp