@@ -639,6 +639,50 @@ type StaticClass =
639639 static member DefaultNullParam ( [<Optional; DefaultParameterValue( null : obj) >] x : obj ) = x
640640 static member inline InlineAdd ( x : int , ? y : int ) = x + ( defaultArg y 2 )
641641
642+ // Test types for generic parameter static member resolution
643+ type TestTypeA =
644+ static member GetValue () = " A"
645+ static member Combine ( x : int , y : int ) = x + y + 100
646+
647+ type TestTypeB =
648+ static member GetValue () = " B"
649+ static member Combine ( x : int , y : int ) = x + y + 200
650+
651+ type TestTypeC =
652+ static member GetValue () = " C"
653+ static member Combine ( x : int , y : int ) = x + y + 300
654+
655+ // Inline functions for testing multiple generic parameters with static member constraints
656+ let inline getTwoValues < 'a , 'b when 'a : ( static member GetValue : unit -> string )
657+ and 'b : ( static member GetValue : unit -> string )> () =
658+ 'a.GetValue(), 'b.GetValue()
659+
660+ let inline getThreeValues < 'a , 'b , 'c when 'a : ( static member GetValue : unit -> string )
661+ and 'b : ( static member GetValue : unit -> string )
662+ and 'c : ( static member GetValue : unit -> string )> () =
663+ 'a.GetValue(), 'b.GetValue(), 'c.GetValue()
664+
665+ let inline getValuesAndCombine < 'a , 'b when 'a : ( static member GetValue : unit -> string )
666+ and 'a : ( static member Combine : int * int -> int )
667+ and 'b : ( static member GetValue : unit -> string )
668+ and 'b : ( static member Combine : int * int -> int )> x y =
669+ let aVal = 'a.GetValue()
670+ let bVal = 'b.GetValue()
671+ let aCombined = 'a.Combine( x, y)
672+ let bCombined = 'b.Combine( x, y)
673+ ( aVal, aCombined), ( bVal, bCombined)
674+
675+ let inline getReversed < 'x , 'y when 'x : ( static member GetValue : unit -> string )
676+ and 'y : ( static member GetValue : unit -> string )> () =
677+ 'y.GetValue(), 'x.GetValue()
678+
679+ let inline innerGet < 't when 't : ( static member GetValue : unit -> string )> () =
680+ 't.GetValue()
681+
682+ let inline outerGet < 'a , 'b when 'a : ( static member GetValue : unit -> string )
683+ and 'b : ( static member GetValue : unit -> string )> () =
684+ innerGet< 'a>(), innerGet< 'b>()
685+
642686let tests =
643687 testList " Types" [
644688
@@ -1393,4 +1437,36 @@ let tests =
13931437 ( upper :> IGenericMangledInterface< string>) .ReadOnlyValue |> equal " value"
13941438 ( upper :> IGenericMangledInterface< string>) .SetterOnlyValue <- " setter only value"
13951439 ( upper :> IGenericMangledInterface< string>) .Value |> equal " setter only value"
1440+
1441+ // Test for generic type parameter static member resolution in inline functions
1442+ // https://github.com/fable-compiler/Fable/issues/4093
1443+ testCase " Inline function with two generic parameters resolves static members correctly" <| fun () ->
1444+ let result = getTwoValues< TestTypeA, TestTypeB>()
1445+ result |> equal ( " A" , " B" )
1446+
1447+ testCase " Inline function with three generic parameters resolves static members correctly" <| fun () ->
1448+ let result = getThreeValues< TestTypeA, TestTypeB, TestTypeC>()
1449+ result |> equal ( " A" , " B" , " C" )
1450+
1451+ testCase " Inline function with multiple constraints per type parameter works" <| fun () ->
1452+ let result = getValuesAndCombine< TestTypeA, TestTypeB> 10 20
1453+ result |> equal (( " A" , 130 ), ( " B" , 230 ))
1454+
1455+ testCase " Inline function with reversed type parameter order works" <| fun () ->
1456+ let result = getReversed< TestTypeA, TestTypeB>()
1457+ result |> equal ( " B" , " A" )
1458+
1459+ testCase " Nested inline functions resolve generic parameters correctly" <| fun () ->
1460+ let result = outerGet< TestTypeA, TestTypeB>()
1461+ result |> equal ( " A" , " B" )
1462+
1463+ testCase " Different type parameter combinations work correctly" <| fun () ->
1464+ let result1 = getTwoValues< TestTypeB, TestTypeA>()
1465+ result1 |> equal ( " B" , " A" )
1466+
1467+ let result2 = getTwoValues< TestTypeC, TestTypeA>()
1468+ result2 |> equal ( " C" , " A" )
1469+
1470+ let result3 = getTwoValues< TestTypeB, TestTypeC>()
1471+ result3 |> equal ( " B" , " C" )
13961472 ]
0 commit comments