Skip to content

Commit

Permalink
looking ok
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRansom committed Feb 20, 2025
1 parent 3623013 commit 6331aa0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 32 deletions.
1 change: 0 additions & 1 deletion src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4352,7 +4352,6 @@ and GenApp (cenv: cenv) cgbuf eenv (f, fty, tyargs, curriedArgs, m) sequel =

let ilTyArgs =
(GenTypeArgs cenv m eenv.tyenv tyargs)
|> List.distinct

// For instance method calls chop off some type arguments, which are already
// carried by the class. Also work out if it's a virtual call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,7 @@ printfn "%A" (MyClass.result())
"All Classes and Methods in*NestedGenericClosure.exe Verified."
]

[<InlineData(true, false)>] // RealSig NoOptimize
[<InlineData(false, true)>] // Regular Optimize
[<InlineData(false, false)>] // Regular NoOptimize
[<Theory>]
let ``Generic nested class with closure`` (realSig, optimize) =
let ``Generic nested class with closure - source`` =

FSharp """
module RuntimeHelpers =
Expand All @@ -592,6 +588,14 @@ module doIt =
let enumerator = x |> MyType<_,_>
enumerator.MoveNext() |> ignore
"""

[<InlineData(true, false)>] // RealSig NoOptimize
[<InlineData(false, true)>] // Regular Optimize
[<InlineData(false, false)>] // Regular NoOptimize
[<Theory>]
let ``Generic nested class with closure`` (realSig, optimize) =

``Generic nested class with closure - source``
|> withName "GenericClassWithClosureWithConstraints"
|> asExe
|> withRealInternalSignature realSig
Expand All @@ -603,13 +607,25 @@ module doIt =
"All Classes and Methods in*GenericClassWithClosureWithConstraints.exe Verified."
]

[<InlineData(true, false)>] // RealSig NoOptimize
[<InlineData(false, true)>] // Regular Optimize
[<InlineData(false, false)>] // Regular NoOptimize
[<InlineData(true, true)>] // RealSig Optimize
[<Theory>]
let ``Generic nested class with interface implemented and closure`` (realSig, optimize) =
let ``Generic nested class with closure optimized`` (realSig, optimize) =

``Generic nested class with closure - source``
|> withName "GenericStructWithClosureWithConstraints"
|> asExe
|> withRealInternalSignature realSig
|> withOptimization optimize
|> compileAndRun
|> shouldSucceed
|> verifyPEFileWithSystemDlls
|> withOutputContainsAllInOrderWithRegexPatterns [
@"Verifying \[GenericStructWithClosureWithConstraints\]MyType`2\.MoveNext"
@"\[IL\]: Error \[StackUnexpected\]: \[.*? : .*?::MoveNext\(\)\]\[offset 0x[0-9A-Fa-f]+\]\[found \w+\]\[expected value '.*?'\] Unexpected type on the stack\."
@"Verifying \[GenericStructWithClosureWithConstraints\]<StartupCode\$GenericStructWithClosureWithConstraints>\.\$Test\.main@"
]

let ``Generic nested class with interface implemented and closure - source`` =
FSharp """
module RuntimeHelpers =
open System
Expand Down Expand Up @@ -646,6 +662,14 @@ module doIt =
let x = seq { seq { 1uy } }
let enumerator = x |> MyType<_,_> :> IEnumerator<_>
enumerator.MoveNext() |> ignore"""

[<InlineData(true, false)>] // RealSig NoOptimize
[<InlineData(false, true)>] // Regular Optimize
[<InlineData(false, false)>] // Regular NoOptimize
[<Theory>]
let ``Generic nested class with interface implemented and closure`` (realSig, optimize) =

``Generic nested class with interface implemented and closure - source``
|> withName "GenericClassWithInterfaceAndClosure"
|> asExe
|> withRealInternalSignature realSig
Expand All @@ -659,36 +683,22 @@ module doIt =

[<InlineData(true, true)>] // RealSig Optimize
[<Theory>]
let ``Generic nested class with closure optimized`` (realSig, optimize) =
let ``Generic nested class with interface implemented and closure optimized`` (realSig, optimize) =

FSharp """
module RuntimeHelpers =
type MyType<'A,'B when 'B :> seq<'A>>(sources: seq<'B>) =
member x.MoveNext() =
let rec takeInner c =
if c.ToString() = "1" then failwith "Oops"
sources |> ignore
true
takeInner 3
module doIt =
open RuntimeHelpers
let x = seq { seq { 1uy } }
let enumerator = x |> MyType<_,_>
enumerator.MoveNext() |> ignore
"""
|> withName "GenericStructWithClosureWithConstraints"
``Generic nested class with interface implemented and closure - source``
|> withName "GenericClassWithInterfaceAndClosure"
|> asExe
|> withRealInternalSignature realSig
|> withOptimization optimize
|> compileAndRun
|> shouldSucceed
|> verifyPEFileWithSystemDlls
|> withOutputContainsAllInOrderWithRegexPatterns [
@"Verifying \[GenericStructWithClosureWithConstraints\]MyType`2\.MoveNext"
@"\[IL\]: Error \[StackUnexpected\]: \[.*? : .*?::MoveNext\(\)\]\[offset 0x[0-9A-Fa-f]+\]\[found \w+\]\[expected value '.*?'\] Unexpected type on the stack\."
@"Verifying \[GenericStructWithClosureWithConstraints\]<StartupCode\$GenericStructWithClosureWithConstraints>\.\$Test\.main@"
@"Verifying \[GenericClassWithInterfaceAndClosure\]MyType`2\.System\.Collections\.IEnumerator\.MoveNext"
@"\[IL\]: Error \[StackUnexpected\]: \[.*? : .*?::System\.Collections\.IEnumerator\.MoveNext\(\)\]\[offset 0x[0-9A-Fa-f]+\]\[found \w+\]\[expected value '.*?'\] Unexpected type on the stack\."
@"Verifying \[GenericClassWithInterfaceAndClosure\]MyType`2\.System\.Collections\.IEnumerator\.Reset"
@"Verifying \[GenericClassWithInterfaceAndClosure\]MyType`2\.System\.IDisposable\.Dispose"
@"1 Error\(s\) Verifying [A-Z]:\\[^\s]+\.exe"
]

[<InlineData(true, true)>] // RealSig Optimize
Expand Down

0 comments on commit 6331aa0

Please sign in to comment.