Commit ada29f5c authored by Matthew Pickering's avatar Matthew Pickering Committed by Marge Bot
Browse files

Finder: Look in current unit before looking in any home package dependencies

In order to preserve existing behaviour it's important to look within the current component before consideirng a module might come from an external component.

This already happened by accident in `downsweep`, (because roots are used to repopulated the cache) but in the `Finder` the logic was the wrong way around.

Fixes #22680

Metric Decrease:
parent 4fe9eaff
......@@ -180,7 +180,10 @@ findImportedModuleNoHsc fc fopts ue mhome_unit mod_name mb_pkg =
| otherwise =
findHomePackageModule fc opts uid mod_name
any_home_import = foldr orIfNotFound home_import (map home_pkg_import other_fopts)
-- Do not be smart and change this to `foldr orIfNotFound home_import hs` as
-- that is not the same!! home_import is first because we need to look within ourselves
-- first before looking at the packages in order.
any_home_import = foldr1 orIfNotFound (home_import: map home_pkg_import other_fopts)
pkg_import = findExposedPackageModule fc fopts units mod_name mb_pkg
......@@ -62,6 +62,9 @@ test('MHU_OptionsGHC', normal, compile_fail, [''])
test('multipleHomeUnits_loop', [extra_files([ 'a/', 'unitA', 'loop', 'unitLoop'])], multiunit_compile, [['unitA', 'unitLoop'], '-fhide-source-paths'])
# This test checks that we look for things in our home unit before looking in dependencies
test('multipleHomeUnits_import_order', [extra_files([ 'unitOrder1', 'unitOrder2', 'order-matters1', 'order-matters2'])], multiunit_compile, [['unitOrder1', 'unitOrder2'], '-fhide-source-paths'])
test('multipleHomeUnits_recomp', [copy_files,extra_files([ 'Recomp.hs', 'unitRecomp', 'unitDep', 'Dep.hs'])], makefile_test, [])
test('multipleHomeUnits_recomp_th', [filter_stdout_lines(r'.*Compiling.*'), copy_files, extra_files(['thRecomp.script', 'unitRecompTH', 'unitDep', 'RecompTH.hs', 'Dep.hs', '../../ghci/shell.hs']) , extra_run_opts('-v1 -unit @unitRecompTH -unit @unitDep')], ghci_script, ['thRecomp.script'])
[1 of 4] Compiling A[order-matters1]
[2 of 4] Compiling A[order-matters2]
[3 of 4] Compiling B[order-matters1]
[4 of 4] Compiling B[order-matters2]
module B where
-- Refers to A from current unit
import A
foo = a2
-i -iorder-matters1 A B -this-unit-id order-matters1
-i -iorder-matters2 A B -package-id order-matters1 -this-unit-id order-matters2
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment