Skip to content

Commit

Permalink
instantiate module resolutions for meta-predicate lookups when expand…
Browse files Browse the repository at this point in the history
  • Loading branch information
mthom committed Dec 7, 2024
1 parent ea02b54 commit dba9c9a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/loader.pl
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,12 @@
UnexpandedGoals = ExpandedGoals),
!.

module_instantiated(M, EM) :-
( var(M) ->
EM = user
; M = EM
).

:- non_counted_backtracking expand_goal/5.

expand_goal(UnexpandedGoals, Module, ExpandedGoals, HeadVars, TGs) :-
Expand All @@ -856,9 +862,10 @@
),
( expand_goal_cases(Goals, Module, ExpandedGoals, HeadVars, TGs) ->
true
; predicate_property(Module:Goals, meta_predicate(MetaSpecs0)),
; module_instantiated(Module, InstantiatedModule),
predicate_property(InstantiatedModule:Goals, meta_predicate(MetaSpecs0)),
MetaSpecs0 =.. [_ | MetaSpecs] ->
expand_module_names(Goals, MetaSpecs, Module, ExpandedGoals, HeadVars, TGs)
expand_module_names(Goals, MetaSpecs, InstantiatedModule, ExpandedGoals, HeadVars, TGs)
; thread_goals(Goals, ExpandedGoals, (','))
; Goals = ExpandedGoals
)
Expand Down Expand Up @@ -886,14 +893,16 @@
UnexpandedGoals = ExpandedGoals
; goal_expansion(UnexpandedGoals, Module, UnexpandedGoals1),
( Module \== user ->
goal_expansion(UnexpandedGoals1, user, Goals),
( predicate_property(Module:Goals, meta_predicate(MetaSpecs0)),
MetaSpecs0 =.. [_ | MetaSpecs] ->
expand_module_names(Goals, MetaSpecs, Module, ExpandedGoals, [], [])
; ExpandedGoals = Goals
)
; ExpandedGoals = UnexpandedGoals1
goal_expansion(UnexpandedGoals1, user, Goals)
; Goals = UnexpandedGoals1
),
module_instantiated(Module, InstantiatedModule),
( predicate_property(InstantiatedModule:Goals, meta_predicate(MetaSpecs0)),
MetaSpecs0 =.. [_ | MetaSpecs] ->
expand_module_names(Goals, MetaSpecs, InstantiatedModule, ExpandedGoals, [], [])
; ExpandedGoals = Goals
)
; ExpandedGoals = UnexpandedGoals1
).

:- non_counted_backtracking transitive_goal/3.
Expand Down

0 comments on commit dba9c9a

Please sign in to comment.