@@ -16,6 +16,10 @@ module Inlining =
1616 |> ignoreWarnings
1717 |> verifyILBaseline
1818
19+ let withRealInternalSignature realSig compilation =
20+ compilation
21+ |> withOptions [ if realSig then " --realsig+" else " --realsig-" ]
22+
1923 // SOURCE=Match01.fs SCFLAGS="-a --optimize+" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Match01.dll" # Match01.fs
2024 [<Theory; Directory(__ SOURCE_ DIRECTORY__, Includes=[| " Match01_RealInternalSignatureOn.fs" |]) >]
2125 let ``Match01_RealInternalSignatureOn_fs`` compilation =
@@ -139,3 +143,82 @@ let found = data |> List.contains nan
139143 }""" ]
140144#endif
141145
146+ [<InlineData( true ) >] // RealSig
147+ [<InlineData( false ) >] // Regular
148+ [<Theory>]
149+ let ``Inlining field with private module`` ( realSig ) =
150+ Fsx """
151+ module private PrivateModule =
152+ let moduleValue = 1
153+
154+ let inline getModuleValue () =
155+ moduleValue
156+
157+ [<EntryPoint>]
158+ let main argv =
159+ // [FS1118] Failed to inline the value 'getModuleValue' marked 'inline', perhaps because a recursive value was marked 'inline'
160+ // (fixed by making PrivateModule internal instead of private)
161+ PrivateModule.getModuleValue () |> ignore
162+ 0
163+ """
164+ |> withOptimize
165+ |> withRealInternalSignature realSig
166+ |> asExe
167+ |> compileAndRun
168+ |> shouldSucceed
169+
170+ [<InlineData( true ) >] // RealSig
171+ [<InlineData( false ) >] // Regular
172+ [<Theory>]
173+ let ``Inlining field with private class`` ( realSig ) =
174+ Fsx """
175+ type private FirstType () =
176+ member this.FirstMethod () = ()
177+
178+ type private SecondType () =
179+ member this.SecondMethod () =
180+ let inline callFirstMethod (first: FirstType) =
181+ first.FirstMethod ()
182+
183+ callFirstMethod (FirstType())
184+
185+ printfn $"{(SecondType ()).SecondMethod()}"
186+ """
187+ |> withOptimize
188+ |> withRealInternalSignature realSig
189+ |> asExe
190+ |> compileAndRun
191+ |> shouldSucceed
192+
193+ [<InlineData( true ) >] // RealSig
194+ [<InlineData( false ) >] // Regular
195+ [<Theory>]
196+ let ``Inlining deep local functions field with private class`` ( realSig ) =
197+ Fsx """
198+ type private FirstType () =
199+ member this.FirstMethod () = ()
200+
201+ type private SecondType () =
202+ member this.SecondMethod () =
203+ let inline callFirstMethod (first: FirstType) =
204+ first.FirstMethod ()
205+
206+ let inline callFirstMethodDeeper (first: FirstType) =
207+ callFirstMethod (first)
208+
209+ let inline callFirstMethodMoreDeeper (first: FirstType) =
210+ callFirstMethodDeeper (first)
211+
212+ let inline callFirstMethodMostDeeply (first: FirstType) =
213+ callFirstMethodMoreDeeper (first)
214+
215+ callFirstMethodMostDeeply (FirstType())
216+
217+ printfn $"{(SecondType ()).SecondMethod()}"
218+ """
219+ |> withOptimize
220+ |> withRealInternalSignature realSig
221+ |> asExe
222+ |> compileAndRun
223+ |> shouldSucceed
224+
0 commit comments