Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
+ Multilevel test
  • Loading branch information
gusty committed Oct 28, 2023
commit cbcbf5cc5adf3d0a744a4d95e491325db8368b9f
Original file line number Diff line number Diff line change
Expand Up @@ -858,3 +858,42 @@ let main _ =
|> withLangVersion70
|> compile
|> shouldSucceed

[<FactForNETCOREAPP>]
let ``Static abstracts can be inherited through multiple levels in lang version70`` () =
Fsx """
type IParseable<'T when 'T :> IParseable<'T>> =
static abstract member Parse : string -> 'T

type IAction1<'T when 'T :> IAction1<'T>> =
inherit IParseable<'T>

type IAction2<'T when 'T :> IAction2<'T>> =
inherit IAction1<'T>
static abstract member AltParse : string -> 'T

type IAction3<'T when 'T :> IAction3<'T>> =
inherit IAction2<'T>

type SomeAction = A | B with
interface IAction3<SomeAction> with
static member AltParse (s: string) : SomeAction = A
static member Parse (s: string) : SomeAction =
match s with
| "A" -> A
| "B" -> B
| _ -> failwith "can't parse"

let parse<'T when 'T :> IParseable<'T>> (x: string) : 'T = 'T.Parse x
let altParse<'T when 'T :> IAction3<'T>> (x: string) : 'T = 'T.AltParse x

let x: SomeAction = parse "A"
let y: SomeAction = altParse "A"

if x <> A || y <> A then
failwith "failed"
"""
|> withNoWarn 3535
|> withLangVersion70
|> compile
|> shouldSucceed