Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC FS-1079] Make .Is* discriminated union properties visible from F# #11394

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 13 additions & 4 deletions src/Compiler/AbstractIL/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ open System.Text
open System.Threading

open FSharp.Compiler.AbstractIL.Diagnostics
open FSharp.Compiler.Features
open Internal.Utilities.Library
open Internal.Utilities

Expand Down Expand Up @@ -3356,7 +3357,13 @@ let tname_UIntPtr = "System.UIntPtr"
let tname_TypedReference = "System.TypedReference"

[<NoEquality; NoComparison; StructuredFormatDisplay("{DebugText}")>]
type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssemblyRef list, fsharpCoreAssemblyScopeRef: ILScopeRef) =
type ILGlobals
(
primaryScopeRef: ILScopeRef,
equivPrimaryAssemblyRefs: ILAssemblyRef list,
fsharpCoreAssemblyScopeRef: ILScopeRef,
langVersion: LanguageVersion
) =

let equivPrimaryAssemblyRefs = Array.ofList equivPrimaryAssemblyRefs

Expand Down Expand Up @@ -3421,14 +3428,16 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly
aref.EqualsIgnoringVersion x.primaryAssemblyRef
|| equivPrimaryAssemblyRefs |> Array.exists aref.EqualsIgnoringVersion

member _.langVersion = langVersion

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = "<ILGlobals>"

let mkILGlobals (primaryScopeRef, equivPrimaryAssemblyRefs, fsharpCoreAssemblyScopeRef) =
ILGlobals(primaryScopeRef, equivPrimaryAssemblyRefs, fsharpCoreAssemblyScopeRef)
let mkILGlobals (primaryScopeRef, equivPrimaryAssemblyRefs, fsharpCoreAssemblyScopeRef, langVersion) =
ILGlobals(primaryScopeRef, equivPrimaryAssemblyRefs, fsharpCoreAssemblyScopeRef, langVersion)

let mkNormalCall mspec = I_call(Normalcall, mspec, None)

Expand Down Expand Up @@ -4686,7 +4695,7 @@ let DummyFSharpCoreScopeRef =
ILScopeRef.Assembly asmRef

let PrimaryAssemblyILGlobals =
mkILGlobals (ILScopeRef.PrimaryAssembly, [], DummyFSharpCoreScopeRef)
mkILGlobals (ILScopeRef.PrimaryAssembly, [], DummyFSharpCoreScopeRef, LanguageVersion("default"))

let rec decodeCustomAttrElemType bytes sigptr x =
match x with
Expand Down
8 changes: 7 additions & 1 deletion src/Compiler/AbstractIL/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

module rec FSharp.Compiler.AbstractIL.IL

open FSharp.Compiler.Features
open FSharp.Compiler.IO
open System.Collections.Generic
open System.Reflection
Expand Down Expand Up @@ -1816,6 +1817,7 @@ type internal ILGlobals =
member primaryAssemblyRef: ILAssemblyRef
member primaryAssemblyName: string
member fsharpCoreAssemblyScopeRef: ILScopeRef
member langVersion: LanguageVersion

member typ_Attribute: ILType
member typ_Enum: ILType
Expand Down Expand Up @@ -1855,7 +1857,10 @@ type internal ILGlobals =
/// primaryScopeRef is the primary assembly we are emitting
/// equivPrimaryAssemblyRefs are ones regarded as equivalent
val internal mkILGlobals:
primaryScopeRef: ILScopeRef * equivPrimaryAssemblyRefs: ILAssemblyRef list * fsharpCoreAssemblyScopeRef: ILScopeRef ->
primaryScopeRef: ILScopeRef *
equivPrimaryAssemblyRefs: ILAssemblyRef list *
fsharpCoreAssemblyScopeRef: ILScopeRef *
langVersion: LanguageVersion ->
ILGlobals

val internal PrimaryAssemblyILGlobals: ILGlobals
Expand Down Expand Up @@ -1929,6 +1934,7 @@ val internal mkILNonGenericStaticMethSpecInTy: ILType * string * ILType list * I

/// Construct references to constructors.
val internal mkILCtorMethSpecForTy: ILType * ILType list -> ILMethodSpec
val internal mkILNonGenericCtorMethSpec: ILTypeRef * ILType list -> ILMethodSpec

/// Construct references to fields.
val internal mkILFieldRef: ILTypeRef * string * ILType -> ILFieldRef
Expand Down
Loading