Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRansom committed Jul 5, 2023
1 parent 42bc2ad commit 7b951fc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
11 changes: 6 additions & 5 deletions src/Compiler/Checking/PostInferenceChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1965,11 +1965,11 @@ and CheckValSpecAux permitByRefLike cenv env (v: Val) onInnerByrefError =
and CheckValSpec permitByRefLike cenv env v =
CheckValSpecAux permitByRefLike cenv env v (fun () -> errorR(Error(FSComp.SR.chkErrorUseOfByref(), v.Range)))

and AdjustAccess isHidden (cpath: unit -> CompilationPath) access =
and AdjustAccess isHidden (cpath: CompilationPath) access =
if isHidden then
let (TAccess l) = access
// FSharp 1.0 bug 1908: Values hidden by signatures are implicitly at least 'internal'
let scoref = cpath().ILScopeRef
let scoref = cpath.ILScopeRef
TAccess(CompPath(scoref, []) :: l)
else
access
Expand Down Expand Up @@ -2001,7 +2001,7 @@ and CheckBinding cenv env alwaysCheckNoReraise ctxt (TBind(v, bindRhs, _) as bin

// Check accessibility
if (v.IsMemberOrModuleBinding || v.IsMember) && not v.IsIncrClassGeneratedMember then
let access = AdjustAccess (IsHiddenVal env.sigToImplRemapInfo v) (fun () -> v.DeclaringEntity.CompilationPath) v.Accessibility
let access = AdjustAccess (IsHiddenVal env.sigToImplRemapInfo v) v.DeclaringEntity.CompilationPath v.Accessibility
CheckTypeForAccess cenv env (fun () -> NicePrint.stringOfQualifiedValOrMember cenv.denv cenv.infoReader vref) access v.Range v.Type

if cenv.reportErrors then
Expand Down Expand Up @@ -2230,7 +2230,7 @@ let CheckRecdField isUnion cenv env (tycon: Tycon) (rfield: RecdField) =
IsHiddenTycon env.sigToImplRemapInfo tycon ||
IsHiddenTyconRepr env.sigToImplRemapInfo tycon ||
(not isUnion && IsHiddenRecdField env.sigToImplRemapInfo (tcref.MakeNestedRecdFieldRef rfield))
let access = AdjustAccess isHidden (fun () -> tycon.CompilationPath) rfield.Accessibility
let access = AdjustAccess isHidden tycon.CompilationPath rfield.Accessibility
CheckTypeForAccess cenv env (fun () -> rfield.LogicalName) access m fieldTy

if isByrefLikeTyconRef g m tcref then
Expand Down Expand Up @@ -2490,7 +2490,8 @@ let CheckEntityDefn cenv env (tycon: Entity) =
ucase.RecdFieldsArray |> Array.iter (CheckRecdField true cenv env tycon)

// Access checks
let access = AdjustAccess (IsHiddenTycon env.sigToImplRemapInfo tycon) (fun () -> tycon.CompilationPath) tycon.Accessibility
let access = AdjustAccess (IsHiddenTycon env.sigToImplRemapInfo tycon) tycon.CompilationPath tycon.Accessibility

let visitType ty = CheckTypeForAccess cenv env (fun () -> tycon.DisplayNameWithStaticParametersAndUnderscoreTypars) access tycon.Range ty

abstractSlotValsOfTycons [tycon] |> List.iter (typeOfVal >> visitType)
Expand Down
33 changes: 16 additions & 17 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -489,23 +489,22 @@ let rec TypeRefForCompLoc cloc =
let mkILTyForCompLoc cloc =
mkILNonGenericBoxedTy (TypeRefForCompLoc cloc)

let ComputeMemberAccess hidden =
let ComputeMemberAccess hidden (access: ILMemberAccess option) =
if hidden then
ILMemberAccess.Assembly
match access with
| None -> ILMemberAccess.Assembly
| Some access -> access
else
ILMemberAccess.Public

// Under --publicasinternal change types from Public to Private (internal for types)
let ComputePublicTypeAccess () = ILTypeDefAccess.Public

let ComputeTypeAccess (tref: ILTypeRef) hidden =
match tref.Enclosing with
| [] ->
if hidden then
ILTypeDefAccess.Private
else
ComputePublicTypeAccess()
| _ -> ILTypeDefAccess.Nested(ComputeMemberAccess hidden)
ILTypeDefAccess.Public
| _ -> ILTypeDefAccess.Nested(ComputeMemberAccess hidden None) //@@@@@@@@@@@@@@@@@@@@@@@@

//--------------------------------------------------------------------------
// TypeReprEnv
Expand Down Expand Up @@ -6065,7 +6064,7 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel
) do
// Suppress the "ResumptionDynamicInfo" from generated state machines
if templateFld.LogicalName <> "ResumptionDynamicInfo" then
let access = ComputeMemberAccess false
let access = ComputeMemberAccess false None //@@@@@@@@@@@@@@@@@@@@@@@@
let fty = GenType cenv m eenvinner.tyenv templateFld.FieldType

let fdef =
Expand All @@ -6086,7 +6085,7 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel

// Fields for captured variables
for ilCloFreeVar in ilCloFreeVars do
let access = ComputeMemberAccess false
let access = ComputeMemberAccess false None //@@@@@@@@@@@@@@@@@@@@@@@@

let fdef =
ILFieldDef(
Expand Down Expand Up @@ -8168,7 +8167,7 @@ and ComputeMethodAccessRestrictedBySig eenv vspec =
// Compiler generated members for class function 'let' bindings get assembly visibility
vspec.IsIncrClassGeneratedMember

ComputeMemberAccess isHidden
ComputeMemberAccess isHidden None //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

and GenBindingAfterDebugPoint cenv cgbuf eenv bind isStateVar startMarkOpt =
let g = cenv.g
Expand Down Expand Up @@ -8354,7 +8353,7 @@ and GenBindingAfterDebugPoint cenv cgbuf eenv bind isStateVar startMarkOpt =
/// Generate a static field definition...
let ilFieldDefs =
let access =
ComputeMemberAccess(not hasLiteralAttr || IsHiddenVal eenv.sigToImplRemapInfo vspec)
ComputeMemberAccess(not hasLiteralAttr || IsHiddenVal eenv.sigToImplRemapInfo vspec) None //@@@@@@@@@@@@@@@@@@@@@@@@

let ilFieldDef = mkILStaticField (fspec.Name, fty, None, None, access)

Expand Down Expand Up @@ -10219,7 +10218,7 @@ and GenImplFile cenv (mgbuf: AssemblyBuilder) mainInfoOpt eenv (implFile: Checke
let initFieldName = CompilerGeneratedName "init"

let ilFieldDef =
mkILStaticField (initFieldName, g.ilg.typ_Int32, None, None, ComputeMemberAccess true)
mkILStaticField (initFieldName, g.ilg.typ_Int32, None, None, ComputeMemberAccess true None) //@@@@@@@@@@@@@@@@@@@@@@@@
|> g.AddFieldNeverAttributes
|> g.AddFieldGeneratedAttributes

Expand Down Expand Up @@ -10621,7 +10620,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) =

let tyconRepr = tycon.TypeReprInfo

let reprAccess = ComputeMemberAccess hiddenRepr
let reprAccess = ComputeMemberAccess hiddenRepr None //@@@@@@@@@@@@@@@@@@@@@@@@

// DebugDisplayAttribute gets copied to the subtypes generated as part of DU compilation
let debugDisplayAttrs, normalAttrs =
Expand Down Expand Up @@ -10783,7 +10782,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) =
[ g.CompilerGeneratedAttribute; g.DebuggerBrowsableNeverAttribute ]
| _ -> [] // don't hide fields in classes in debug display

let access = ComputeMemberAccess isFieldHidden
let access = ComputeMemberAccess isFieldHidden None //@@@@@@@@@@@@@@@@@@@@@@@@

let literalValue = Option.map (GenFieldInit m) fspec.LiteralValue

Expand Down Expand Up @@ -10853,7 +10852,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) =
if not useGenuineField then
let ilPropName = fspec.LogicalName
let ilMethName = "get_" + ilPropName
let access = ComputeMemberAccess isPropHidden
let access = ComputeMemberAccess isPropHidden None //@@@@@@@@@@@@@@@@@@@@@@@@
let isStruct = isStructTyconRef tcref

let attrs =
Expand All @@ -10876,7 +10875,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) =
let ilMethName = "set_" + ilPropName
let ilParams = [ mkILParamNamed ("value", ilPropType) ]
let ilReturn = mkILReturn ILType.Void
let iLAccess = ComputeMemberAccess isPropHidden
let iLAccess = ComputeMemberAccess isPropHidden None //@@@@@@@@@@@@@@@@@@@@@@@@

let ilMethodDef =
if isStatic then
Expand Down Expand Up @@ -11388,7 +11387,7 @@ and GenExnDef cenv mgbuf eenv m (exnc: Tycon) =
let tref = ilThisTy.TypeRef
let isHidden = IsHiddenTycon eenv.sigToImplRemapInfo exnc
let access = ComputeTypeAccess tref isHidden
let reprAccess = ComputeMemberAccess isHidden
let reprAccess = ComputeMemberAccess isHidden None //@@@@@@@@@@@@@@@@@@@@@@@@
let fspecs = exnc.TrueInstanceFieldsAsList

let ilMethodDefsForProperties, ilFieldDefs, ilPropertyDefs, fieldNamesAndTypes =
Expand Down
7 changes: 7 additions & 0 deletions src/Compiler/TypedTree/TypedTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2150,6 +2150,12 @@ type Accessibility =
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

member x.AsILMemberAccess =
match x with
| Public -> ILMemberAccess.Public
| Internal -> ILMemberAccess.Assembly
| Private -> ILMemberAccess.Private

override x.ToString() =
match x with
| TAccess (paths) ->
Expand All @@ -2164,6 +2170,7 @@ type Accessibility =
else
$"{scopename} {paths}"


/// Represents less-frequently-required data about a type parameter of type inference variable
[<NoEquality; NoComparison; StructuredFormatDisplay("{DebugText}")>]
type TyparOptionalData =
Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/TypedTree/TypedTree.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,8 @@ type Accessibility =
/// Indicates whether the Accessability is private
member IsPrivate: bool

member AsILMemberAccess: ILMemberAccess

/// Readable rendering of Accessibility
override ToString: unit -> string

Expand Down

0 comments on commit 7b951fc

Please sign in to comment.