@@ -670,6 +670,30 @@ type AbstractClassWithResizeArrayProp() =
670670type ConcreteClass1 () =
671671 inherit MangledAbstractClass5( 2 )
672672
673+ // See #3895 - super call with generic class hierarchy uses wrong overload hash
674+ type IGenericAttach3895 < 'C > =
675+ abstract Attach: 'C -> unit
676+
677+ [<AbstractClass>]
678+ type GenericAttachBase3895 < 'C >( log : ResizeArray < string >) =
679+ abstract Attach: 'C -> unit
680+ default _.Attach ( _owner : 'C ) = log.Add( " Base" )
681+
682+ interface IGenericAttach3895< 'C> with
683+ member this.Attach ( owner : 'C ) = this.Attach( owner)
684+
685+ type GenericAttachMid3895 < 'Container >( log : ResizeArray < string >) =
686+ inherit GenericAttachBase3895< 'Container>( log)
687+ override this.Attach ( owner ) =
688+ base .Attach( owner)
689+ log.Add( " Mid" )
690+
691+ type GenericAttachLeaf3895 ( log : ResizeArray < string >) =
692+ inherit GenericAttachMid3895< string>( log)
693+ override this.Attach ( owner ) =
694+ base .Attach( owner)
695+ log.Add( " Leaf" )
696+
673697type IndexedProps ( v : int ) =
674698 let mutable v = v
675699 member _.Item with get ( v2 : int ) = v + v2 and set v2 ( s : string ) = v <- v2 + int s
@@ -1552,6 +1576,14 @@ let tests =
15521576 let c = ConcreteClass1()
15531577 c.MyMethod( 4 ) |> equal 58
15541578
1579+ // See #3895 - super call in generic class hierarchy was using wrong mangled name
1580+ testCase " Super call works correctly in multi-level generic class hierarchy" <| fun () ->
1581+ let log = ResizeArray< string>()
1582+ let obj = GenericAttachLeaf3895( log)
1583+ obj.Attach( " hello" )
1584+ // Each override delegates to base before logging, so the chain unwinds Base -> Mid -> Leaf
1585+ log |> List.ofSeq |> equal [ " Base" ; " Mid" ; " Leaf" ]
1586+
15551587 // See #3328
15561588 testCase " SRTP works with byref" <| fun () ->
15571589 let result = doubleIntByRef ( TypeWithByRefMember()) 7
0 commit comments