Skip to content

Commit cbcbf5c

Browse files
committed
+ Multilevel test
1 parent 769710e commit cbcbf5c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/FSharp.Compiler.ComponentTests/Conformance/Types/TypeConstraints/IWSAMsAndSRTPs/IWSAMsAndSRTPsTests.fs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,3 +858,42 @@ let main _ =
858858
|> withLangVersion70
859859
|> compile
860860
|> shouldSucceed
861+
862+
[<FactForNETCOREAPP>]
863+
let ``Static abstracts can be inherited through multiple levels in lang version70`` () =
864+
Fsx """
865+
type IParseable<'T when 'T :> IParseable<'T>> =
866+
static abstract member Parse : string -> 'T
867+
868+
type IAction1<'T when 'T :> IAction1<'T>> =
869+
inherit IParseable<'T>
870+
871+
type IAction2<'T when 'T :> IAction2<'T>> =
872+
inherit IAction1<'T>
873+
static abstract member AltParse : string -> 'T
874+
875+
type IAction3<'T when 'T :> IAction3<'T>> =
876+
inherit IAction2<'T>
877+
878+
type SomeAction = A | B with
879+
interface IAction3<SomeAction> with
880+
static member AltParse (s: string) : SomeAction = A
881+
static member Parse (s: string) : SomeAction =
882+
match s with
883+
| "A" -> A
884+
| "B" -> B
885+
| _ -> failwith "can't parse"
886+
887+
let parse<'T when 'T :> IParseable<'T>> (x: string) : 'T = 'T.Parse x
888+
let altParse<'T when 'T :> IAction3<'T>> (x: string) : 'T = 'T.AltParse x
889+
890+
let x: SomeAction = parse "A"
891+
let y: SomeAction = altParse "A"
892+
893+
if x <> A || y <> A then
894+
failwith "failed"
895+
"""
896+
|> withNoWarn 3535
897+
|> withLangVersion70
898+
|> compile
899+
|> shouldSucceed

0 commit comments

Comments
 (0)