File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
testsuite/tests/typing-modules Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -168,3 +168,34 @@ module Ignore_strengthening :
168
168
module M : S
169
169
end
170
170
| }]
171
+
172
+ module Expand_destructive_with = struct
173
+ module type S = sig
174
+ module type T = sig type t val foo : t -> t end
175
+ module M : T
176
+ module N : T with M
177
+ end
178
+
179
+ module F (X :S with type M .t := int ) = struct
180
+ let bar = X .N .foo 1
181
+ end
182
+ end
183
+ [%% expect{|
184
+ module Expand_destructive_with :
185
+ sig
186
+ module type S =
187
+ sig
188
+ module type T = sig type t val foo : t -> t end
189
+ module M : T
190
+ module N : sig type t = M. t val foo : t -> t end
191
+ end
192
+ module F :
193
+ functor
194
+ (X : sig
195
+ module type T = sig type t val foo : t -> t end
196
+ module M : sig val foo : int -> int end
197
+ module N : sig type t = int val foo : t -> t end
198
+ end )
199
+ -> sig val bar : X .N .t end
200
+ end
201
+ | }]
Original file line number Diff line number Diff line change @@ -787,11 +787,15 @@ let merge_constraint initial_env loc sg lid constr =
787
787
in
788
788
let sg = match sub with
789
789
| Some sub ->
790
+ (* Since destructive with is implemented via substitution, we need to
791
+ expand any type abbreviations (like strengthening) where the expanded
792
+ form might contain the thing we need to substitute. See corresponding
793
+ test in strengthening.ml. *)
794
+ let sg = Mtype. expand_to initial_env sg ! real_ids in
790
795
(* This signature will not be used directly, it will always be freshened
791
796
by the caller. So what we do with the scope doesn't really matter. But
792
797
making it local makes it unlikely that we will ever use the result of
793
798
this function unfreshened without issue. *)
794
- let sg = Mtype. expand_to initial_env sg ! real_ids in
795
799
Subst. signature Make_local sub sg
796
800
| None -> sg
797
801
in
You can’t perform that action at this time.
0 commit comments