@@ -19,6 +19,7 @@ open Microsoft.FSharp.Compiler.Tastops
1919open Microsoft.FSharp .Compiler .Tastops .DebugPrint
2020open Microsoft.FSharp .Compiler .TcGlobals
2121open Microsoft.FSharp .Compiler .TypeRelations
22+ open Microsoft.FSharp .Compiler .AttributeChecking
2223
2324#if ! NO_ EXTENSIONTYPING
2425open Microsoft.FSharp .Compiler .ExtensionTyping
@@ -1218,3 +1219,54 @@ module ProvidedMethodCalls =
12181219let methName = mi.PUntaint(( fun mb -> mb.Name), m)
12191220 raise( tpe.WithContext( typeName, methName) ) // loses original stack trace
12201221#endif
1222+
1223+
1224+
1225+ let RecdFieldInstanceChecks g amap ad m ( rfinfo : RecdFieldInfo ) =
1226+ if rfinfo.IsStaticthen error( Error( FSComp.SR.tcStaticFieldUsedWhenInstanceFieldExpected(), m))
1227+ CheckRecdFieldInfoAttributes g rfinfo m|> CommitOperationResult
1228+ CheckRecdFieldInfoAccessible amap m ad rfinfo
1229+
1230+ let ILFieldInstanceChecks g amap ad m ( finfo : ILFieldInfo ) =
1231+ if finfo.IsStaticthen error( Error( FSComp.SR.tcStaticFieldUsedWhenInstanceFieldExpected(), m))
1232+ CheckILFieldInfoAccessible g amap m ad finfo
1233+ CheckILFieldAttributes g finfo m
1234+
1235+ let MethInfoChecks g amap isInstance tyargsOpt objArgs ad m ( minfo : MethInfo ) =
1236+ if minfo.IsInstance<> isInstancethen
1237+ if isInstancethen
1238+ error( Error( FSComp.SR.csMethodIsNotAnInstanceMethod( minfo.LogicalName), m))
1239+ else
1240+ error( Error( FSComp.SR.csMethodIsNotAStaticMethod( minfo.LogicalName), m))
1241+
1242+ // keep the original accessibility domain to determine type accessibility
1243+ let adOriginal = ad
1244+ // Eliminate the 'protected' portion of the accessibility domain for instance accesses
1245+ let ad =
1246+ match objArgs, adwith
1247+ | [ objArg], AccessibleFrom( paths, Some tcref) ->
1248+ let objArgTy = tyOfExpr g objArg
1249+ let ty = generalizedTyconRef tcref
1250+ // We get to keep our rights if the type we're in subsumes the object argument type
1251+ if TypeFeasiblySubsumesType0 g amap m ty CanCoerce objArgTythen
1252+ ad
1253+ // We get to keep our rights if this is a base call
1254+ elif IsBaseCall objArgsthen
1255+ ad
1256+ else
1257+ AccessibleFrom( paths, None)
1258+ | _ -> ad
1259+
1260+ if not ( IsTypeAndMethInfoAccessible amap m adOriginal ad minfo) then
1261+ error( Error( FSComp.SR.tcMethodNotAccessible( minfo.LogicalName), m))
1262+
1263+ if isAnyTupleTy g minfo.ApparentEnclosingType&& not minfo.IsExtensionMember&& ( minfo.LogicalName.StartsWith" get_Item" || minfo.LogicalName.StartsWith" get_Rest" ) then
1264+ warning( Error( FSComp.SR.tcTupleMemberNotNormallyUsed(), m))
1265+
1266+ CheckMethInfoAttributes g m tyargsOpt minfo|> CommitOperationResult
1267+
1268+ exception FieldNotMutableof DisplayEnv * Tast.RecdFieldRef * range
1269+
1270+ let CheckRecdFieldMutation m denv ( rfinfo : RecdFieldInfo ) =
1271+ if not rfinfo.RecdField.IsMutablethen error( FieldNotMutable( denv, rfinfo.RecdFieldRef, m))
1272+