Skip to content

Commit 8ebef22

Browse files
author
Roman Leshchinskiy
committed
More tests
1 parent 45052d7 commit 8ebef22

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

ocaml/testsuite/tests/typing-modules/strengthening.ml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,70 @@ module Unaliasable :
101101
module X : (A.S with A.M [@unaliasable])
102102
end
103103
|}]
104+
105+
module Subtype = struct
106+
module type S
107+
module F(G:functor(X:S) -> S)(X:S)(Y:S with X) = G(Y)
108+
end
109+
[%%expect{|
110+
module Subtype :
111+
sig
112+
module type S
113+
module F :
114+
functor (G : functor (X : S) -> S) (X : S) (Y : (S with X)) ->
115+
(S with G(Y))
116+
end
117+
|}]
118+
119+
module Can_use_type = struct
120+
module type S = sig type t end
121+
module A : sig
122+
module M : S
123+
module N : S with M
124+
val foo : M.t -> M.t
125+
val bar : N.t
126+
end = struct
127+
module M = struct type t = int end
128+
module N = M
129+
let foo x = x
130+
let bar = 0
131+
end
132+
133+
let x = A.foo A.bar
134+
end
135+
[%%expect{|
136+
module Can_use_type :
137+
sig
138+
module type S = sig type t end
139+
module A :
140+
sig
141+
module M : S
142+
module N : sig type t = M.t end
143+
val foo : M.t -> M.t
144+
val bar : N.t
145+
end
146+
val x : A.M.t
147+
end
148+
|}]
149+
150+
module Ignore_strengthening = struct
151+
module type S = sig type t = int end
152+
module A : sig
153+
module M : S
154+
module F(X : S with M) : S
155+
end = struct
156+
module M = struct type t = int end
157+
module F(X : S with M) = X
158+
end
159+
160+
module M = A.F(struct type t = int end)
161+
end
162+
[%%expect{|
163+
module Ignore_strengthening :
164+
sig
165+
module type S = sig type t = int end
166+
module A :
167+
sig module M : S module F : functor (X : sig type t = int end) -> S end
168+
module M : S
169+
end
170+
|}]

0 commit comments

Comments
 (0)