From b528dca34a1c2d539fa40fbf3efc11a0f10b284f Mon Sep 17 00:00:00 2001 From: simonpj Date: Wed, 4 May 2005 11:23:28 +0000 Subject: [PATCH] [project @ 2005-05-04 11:23:28 by simonpj] Further wibbles to unused-import reporting; merge to stable --- ghc/compiler/rename/RnNames.lhs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ghc/compiler/rename/RnNames.lhs b/ghc/compiler/rename/RnNames.lhs index bd4e0f5..2cc62f8 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 -- 1.7.10.4