@@ -1677,3 +1677,83 @@ let ``test Type test decimal`` () =
16771677
16781678 box 5 M |> isDecimal |> equal true
16791679 box 5 |> isDecimal |> equal false
1680+
1681+ // Test types for generic parameter static member resolution
1682+ type TestTypeA =
1683+ static member GetValue () = " A"
1684+ static member Combine ( x : int , y : int ) = x + y + 100
1685+
1686+ type TestTypeB =
1687+ static member GetValue () = " B"
1688+ static member Combine ( x : int , y : int ) = x + y + 200
1689+
1690+ type TestTypeC =
1691+ static member GetValue () = " C"
1692+ static member Combine ( x : int , y : int ) = x + y + 300
1693+
1694+ // Inline functions for testing multiple generic parameters with static member constraints
1695+ let inline getTwoValues < 'a , 'b when 'a : ( static member GetValue : unit -> string )
1696+ and 'b : ( static member GetValue : unit -> string )> () =
1697+ 'a.GetValue(), 'b.GetValue()
1698+
1699+ let inline getThreeValues < 'a , 'b , 'c when 'a : ( static member GetValue : unit -> string )
1700+ and 'b : ( static member GetValue : unit -> string )
1701+ and 'c : ( static member GetValue : unit -> string )> () =
1702+ 'a.GetValue(), 'b.GetValue(), 'c.GetValue()
1703+
1704+ let inline getValuesAndCombine < 'a , 'b when 'a : ( static member GetValue : unit -> string )
1705+ and 'a : ( static member Combine : int * int -> int )
1706+ and 'b : ( static member GetValue : unit -> string )
1707+ and 'b : ( static member Combine : int * int -> int )> x y =
1708+ let aVal = 'a.GetValue()
1709+ let bVal = 'b.GetValue()
1710+ let aCombined = 'a.Combine( x, y)
1711+ let bCombined = 'b.Combine( x, y)
1712+ ( aVal, aCombined), ( bVal, bCombined)
1713+
1714+ let inline getReversed < 'x , 'y when 'x : ( static member GetValue : unit -> string )
1715+ and 'y : ( static member GetValue : unit -> string )> () =
1716+ 'y.GetValue(), 'x.GetValue()
1717+
1718+ let inline innerGet < 't when 't : ( static member GetValue : unit -> string )> () =
1719+ 't.GetValue()
1720+
1721+ let inline outerGet < 'a , 'b when 'a : ( static member GetValue : unit -> string )
1722+ and 'b : ( static member GetValue : unit -> string )> () =
1723+ innerGet< 'a>(), innerGet< 'b>()
1724+
1725+ [<Fact>]
1726+ let ``test Inline function with two generic parameters resolves static members correctly`` () =
1727+ let result = getTwoValues< TestTypeA, TestTypeB>()
1728+ result |> equal ( " A" , " B" )
1729+
1730+ [<Fact>]
1731+ let ``test Inline function with three generic parameters resolves static members correctly`` () =
1732+ let result = getThreeValues< TestTypeA, TestTypeB, TestTypeC>()
1733+ result |> equal ( " A" , " B" , " C" )
1734+
1735+ [<Fact>]
1736+ let ``test Inline function with multiple constraints per type parameter works`` () =
1737+ let result = getValuesAndCombine< TestTypeA, TestTypeB> 10 20
1738+ result |> equal (( " A" , 130 ), ( " B" , 230 ))
1739+
1740+ [<Fact>]
1741+ let ``test Inline function with reversed type parameter order works`` () =
1742+ let result = getReversed< TestTypeA, TestTypeB>()
1743+ result |> equal ( " B" , " A" )
1744+
1745+ [<Fact>]
1746+ let ``test Nested inline functions resolve generic parameters correctly`` () =
1747+ let result = outerGet< TestTypeA, TestTypeB>()
1748+ result |> equal ( " A" , " B" )
1749+
1750+ [<Fact>]
1751+ let ``test Different type parameter combinations work correctly`` () =
1752+ let result1 = getTwoValues< TestTypeB, TestTypeA>()
1753+ result1 |> equal ( " B" , " A" )
1754+
1755+ let result2 = getTwoValues< TestTypeC, TestTypeA>()
1756+ result2 |> equal ( " C" , " A" )
1757+
1758+ let result3 = getTwoValues< TestTypeB, TestTypeC>()
1759+ result3 |> equal ( " B" , " C" )
0 commit comments