Skip to content

Commit

Permalink
Expose langVersion from ILGlobals
Browse files Browse the repository at this point in the history
  • Loading branch information
chkn committed Jun 22, 2021
1 parent dfa3331 commit 6885b0b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/fsharp/CompilerImports.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ and [<Sealed>] TcImports(tcConfigP: TcConfigProvider, initialResolutions: TcAsse
let tryFindSysTypeCcu path typeName =
sysCcus |> Array.tryFind (fun ccu -> ccuHasType ccu path typeName)

let ilGlobals = mkILGlobals (primaryScopeRef, assembliesThatForwardToPrimaryAssembly, fsharpCoreAssemblyScopeRef)
let ilGlobals = mkILGlobals (primaryScopeRef, assembliesThatForwardToPrimaryAssembly, fsharpCoreAssemblyScopeRef, tcConfig.langVersion)

// OK, now we have both mscorlib.dll and FSharp.Core.dll we can create TcGlobals
let tcGlobals = TcGlobals(tcConfig.compilingFslib, ilGlobals, fslibCcu,
Expand Down
9 changes: 6 additions & 3 deletions src/fsharp/absil/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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 @@ -2631,7 +2632,7 @@ let tname_UIntPtr = "System.UIntPtr"
let tname_TypedReference = "System.TypedReference"

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

let assembliesThatForwardToPrimaryAssembly = Array.ofList assembliesThatForwardToPrimaryAssembly

Expand Down Expand Up @@ -2671,13 +2672,15 @@ type ILGlobals(primaryScopeRef: ILScopeRef, assembliesThatForwardToPrimaryAssemb
assembliesThatForwardToPrimaryAssembly
|> Array.exists aref.EqualsIgnoringVersion

member _.langVersion = langVersion

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

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

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

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

Expand Down Expand Up @@ -3707,7 +3710,7 @@ let DummyFSharpCoreScopeRef =
Some (parseILVersion "0.0.0.0"), None)
ILScopeRef.Assembly asmRef

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

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

open FSharp.Compiler.IO
open FSharp.Compiler.Features
open Internal.Utilities
open System.Collections.Generic
open System.Reflection
Expand Down Expand Up @@ -1645,6 +1646,8 @@ type internal ILGlobals =

member fsharpCoreAssemblyScopeRef: ILScopeRef

member langVersion: LanguageVersion

/// Is the given assembly possibly a primary assembly?
/// In practice, a primary assembly is an assembly that contains the System.Object type definition
/// and has no referenced assemblies.
Expand All @@ -1656,7 +1659,7 @@ type internal ILGlobals =
member IsPossiblePrimaryAssemblyRef: ILAssemblyRef -> bool

/// Build the table of commonly used references given functions to find types in system assemblies
val internal mkILGlobals: primaryScopeRef: ILScopeRef * assembliesThatForwardToPrimaryAssembly: ILAssemblyRef list * fsharpCoreAssemblyScopeRef: ILScopeRef -> ILGlobals
val internal mkILGlobals: primaryScopeRef: ILScopeRef * assembliesThatForwardToPrimaryAssembly: ILAssemblyRef list * fsharpCoreAssemblyScopeRef: ILScopeRef * langVersion: LanguageVersion -> ILGlobals

val internal PrimaryAssemblyILGlobals: ILGlobals

Expand Down
5 changes: 3 additions & 2 deletions src/fsharp/ilx/EraseUnions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module internal FSharp.Compiler.AbstractIL.ILX.EraseUnions

open System.Collections.Generic
open System.Reflection
open Internal.Utilities.Library
open Internal.Utilities.Library
open FSharp.Compiler.Features
open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler.AbstractIL.ILX.Types

Expand Down Expand Up @@ -684,7 +685,7 @@ let convAlternativeDef (addMethodGeneratedAttrs, addPropertyGeneratedAttrs, addP
| SpecialFSharpListHelpers ->

let baseTesterMeths, baseTesterProps =
if cenv.g.langVersion.SupportsFeature LanguageFeature.UnionIsPropertiesVisible then [], []
if ilg.langVersion.SupportsFeature LanguageFeature.UnionIsPropertiesVisible then [], []
elif cud.cudAlternatives.Length <= 1 then [], []
elif repr.RepresentOneAlternativeAsNull info then [], []
else
Expand Down

0 comments on commit 6885b0b

Please sign in to comment.