Skip to content

Commit 5986427

Browse files
fix for 8351 (/!\ may break other things)
1 parent cccb3da commit 5986427

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

src/fsharp/AccessibilityLogic.fs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,15 @@ let private IsILMethInfoAccessible g amap m adType ad ilminfo =
249249
let GetILAccessOfILPropInfo (ILPropInfo(tinfo, pdef)) =
250250
let tdef = tinfo.RawMetadata
251251
let ilAccess =
252-
match pdef.GetMethod with
253-
| Some mref -> (resolveILMethodRef tdef mref).Access
254-
| None ->
255-
match pdef.SetMethod with
256-
| None -> ILMemberAccess.Public
257-
| Some mref -> (resolveILMethodRef tdef mref).Access
252+
match pdef.GetMethod, pdef.SetMethod with
253+
| Some mref, None
254+
| None, Some mref -> (resolveILMethodRef tdef mref).Access
255+
| Some mrefGet, Some mrefSet ->
256+
let getA = (resolveILMethodRef tdef mrefGet).Access
257+
let setA = (resolveILMethodRef tdef mrefSet).Access
258+
// pick most accessible
259+
max getA setA
260+
| None, None -> ILMemberAccess.Public
258261
ilAccess
259262

260263
let IsILPropInfoAccessible g amap m ad pinfo =
@@ -323,8 +326,11 @@ let IsMethInfoAccessible amap m ad minfo = IsTypeAndMethInfoAccessible amap m ad
323326

324327
let IsPropInfoAccessible g amap m ad = function
325328
| ILProp ilpinfo -> IsILPropInfoAccessible g amap m ad ilpinfo
326-
| FSProp (_, _, Some vref, _)
327-
| FSProp (_, _, _, Some vref) -> IsValAccessible ad vref
329+
| FSProp (_, _, Some vref, None)
330+
| FSProp (_, _, None, Some vref) -> IsValAccessible ad vref
331+
| FSProp (_, _, Some vrefGet, Some vrefSet) ->
332+
// pick most accessible
333+
IsValAccessible ad vrefGet || IsValAccessible ad vrefSet
328334
#if !NO_EXTENSIONTYPING
329335
| ProvidedProp (amap, tppi, m) as pp->
330336
let access =

tests/fsharp/core/members/set-only-property/calls.bsl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11

2-
calls.fsx(9,22,9,27): typecheck error FS0495: The object constructor 'Class' has no argument or settable return property 'Prop1'. The required signature is csharp.Class() : csharp.Class.
3-
4-
calls.fsx(10,26,10,31): typecheck error FS0495: The object constructor 'BasicClass' has no argument or settable return property 'Prop1'. The required signature is basic.BasicClass() : basic.BasicClass.
5-
6-
calls.fsx(13,21,13,26): typecheck error FS0495: The member or object constructor 'mkCs' has no argument or settable return property 'Prop1'. The required signature is static member Maker.mkCs : unit -> csharp.Class.
7-
8-
calls.fsx(14,21,14,26): typecheck error FS0495: The member or object constructor 'mkVb' has no argument or settable return property 'Prop1'. The required signature is static member Maker.mkVb : unit -> basic.BasicClass.
9-
102
calls.fsx(18,30,18,31): typecheck error FS0629: Method 'set_Prop2' is not accessible from this code location
113

124
calls.fsx(19,34,19,35): typecheck error FS0629: Method 'set_Prop2' is not accessible from this code location

0 commit comments

Comments
 (0)