Skip to content

Commit

Permalink
AllMethInfosOfTypeInScope with shortcut of extension methods
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Mar 11, 2019
1 parent cfc9f37 commit 984d5da
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 115 deletions.
6 changes: 3 additions & 3 deletions src/fsharp/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ and GetRelevantMethodsForTrait (csenv:ConstraintSolverEnv) permitWeakResolution
| MemberKind.Constructor ->
tys |> List.map (GetIntrinsicConstructorInfosOfType csenv.SolverState.InfoReader m)
| _ ->
tys |> List.map (GetIntrinsicMethInfosOfType csenv.SolverState.InfoReader (Some nm, AccessibleFromSomeFSharpCode, AllowMultiIntfInstantiations.Yes) IgnoreOverrides m)
tys |> List.map (GetIntrinsicMethInfosOfType csenv.SolverState.InfoReader (Some nm) AccessibleFromSomeFSharpCode AllowMultiIntfInstantiations.Yes IgnoreOverrides m)

// Merge the sets so we don't get the same minfo from each side
// We merge based on whether minfos use identical metadata or not.
Expand Down Expand Up @@ -2038,8 +2038,8 @@ and CanMemberSigsMatchUpToCheck
// Check all the argument types.

if calledObjArgTys.Length <> callerObjArgTys.Length then
if (calledObjArgTys.Length <> 0) then
return! ErrorD(Error (FSComp.SR.csMemberIsNotStatic(minfo.LogicalName), m))
if calledObjArgTys.Length <> 0 then
return! ErrorD(Error (FSComp.SR.csMemberIsNotStatic(minfo.LogicalName), m))
else
return! ErrorD(Error (FSComp.SR.csMemberIsNotInstance(minfo.LogicalName), m))
else
Expand Down
18 changes: 9 additions & 9 deletions src/fsharp/InfoReader.fs
Original file line number Diff line number Diff line change
Expand Up @@ -662,22 +662,22 @@ let ExcludeHiddenOfPropInfos g amap m pinfos =
|> List.concat

/// Get the sets of intrinsic methods in the hierarchy (not including extension methods)
let GetIntrinsicMethInfoSetsOfType (infoReader:InfoReader) (optFilter, ad, allowMultiIntfInst) findFlag m ty =
let GetIntrinsicMethInfoSetsOfType (infoReader:InfoReader) optFilter ad allowMultiIntfInst findFlag m ty =
infoReader.GetRawIntrinsicMethodSetsOfType(optFilter, ad, allowMultiIntfInst, m, ty)
|> FilterOverridesOfMethInfos findFlag infoReader.g infoReader.amap m

/// Get the sets intrinsic properties in the hierarchy (not including extension properties)
let GetIntrinsicPropInfoSetsOfType (infoReader:InfoReader) (optFilter, ad, allowMultiIntfInst) findFlag m ty =
let GetIntrinsicPropInfoSetsOfType (infoReader:InfoReader) optFilter ad allowMultiIntfInst findFlag m ty =
infoReader.GetRawIntrinsicPropertySetsOfType(optFilter, ad, allowMultiIntfInst, m, ty)
|> FilterOverridesOfPropInfos findFlag infoReader.g infoReader.amap m

/// Get the flattened list of intrinsic methods in the hierarchy
let GetIntrinsicMethInfosOfType infoReader (optFilter, ad, allowMultiIntfInst) findFlag m ty =
GetIntrinsicMethInfoSetsOfType infoReader (optFilter, ad, allowMultiIntfInst) findFlag m ty |> List.concat
let GetIntrinsicMethInfosOfType infoReader optFilter ad allowMultiIntfInst findFlag m ty =
GetIntrinsicMethInfoSetsOfType infoReader optFilter ad allowMultiIntfInst findFlag m ty |> List.concat

/// Get the flattened list of intrinsic properties in the hierarchy
let GetIntrinsicPropInfosOfType infoReader (optFilter, ad, allowMultiIntfInst) findFlag m ty =
GetIntrinsicPropInfoSetsOfType infoReader (optFilter, ad, allowMultiIntfInst) findFlag m ty |> List.concat
let GetIntrinsicPropInfosOfType infoReader optFilter ad allowMultiIntfInst findFlag m ty =
GetIntrinsicPropInfoSetsOfType infoReader optFilter ad allowMultiIntfInst findFlag m ty |> List.concat

/// Perform type-directed name resolution of a particular named member in an F# type
let TryFindIntrinsicNamedItemOfType (infoReader:InfoReader) (nm, ad) findFlag m ty =
Expand All @@ -695,12 +695,12 @@ let TryFindIntrinsicNamedItemOfType (infoReader:InfoReader) (nm, ad) findFlag m
/// -- getting the Dispose method when resolving the 'use' construct
/// -- getting the various methods used to desugar the computation expression syntax
let TryFindIntrinsicMethInfo infoReader m ad nm ty =
GetIntrinsicMethInfosOfType infoReader (Some nm, ad, AllowMultiIntfInstantiations.Yes) IgnoreOverrides m ty
GetIntrinsicMethInfosOfType infoReader (Some nm) ad AllowMultiIntfInstantiations.Yes IgnoreOverrides m ty

/// Try to find a particular named property on a type. Only used to ensure that local 'let' definitions and property names
/// are distinct, a somewhat adhoc check in tc.fs.
let TryFindPropInfo infoReader m ad nm ty =
GetIntrinsicPropInfosOfType infoReader (Some nm, ad, AllowMultiIntfInstantiations.Yes) IgnoreOverrides m ty
GetIntrinsicPropInfosOfType infoReader (Some nm) ad AllowMultiIntfInstantiations.Yes IgnoreOverrides m ty

//-------------------------------------------------------------------------
// Helpers related to delegates and events - these use method searching hence are in this file
Expand All @@ -717,7 +717,7 @@ let GetSigOfFunctionForDelegate (infoReader:InfoReader) delty m ad =
let g = infoReader.g
let amap = infoReader.amap
let invokeMethInfo =
match GetIntrinsicMethInfosOfType infoReader (Some "Invoke", ad, AllowMultiIntfInstantiations.Yes) IgnoreOverrides m delty with
match GetIntrinsicMethInfosOfType infoReader (Some "Invoke") ad AllowMultiIntfInstantiations.Yes IgnoreOverrides m delty with
| [h] -> h
| [] -> error(Error(FSComp.SR.noInvokeMethodsFound (), m))
| h :: _ -> warning(InternalError(FSComp.SR.moreThanOneInvokeMethodFound (), m)); h
Expand Down
8 changes: 4 additions & 4 deletions src/fsharp/MethodCalls.fs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ type CalledMeth<'T>
let returnedObjTy = if minfo.IsConstructor then minfo.ApparentEnclosingType else methodRetTy
unassignedNamedItems |> List.splitChoose (fun (CallerNamedArg(id, e) as arg) ->
let nm = id.idText
let pinfos = GetIntrinsicPropInfoSetsOfType infoReader (Some(nm), ad, AllowMultiIntfInstantiations.Yes) IgnoreOverrides id.idRange returnedObjTy
let pinfos = GetIntrinsicPropInfoSetsOfType infoReader (Some nm) ad AllowMultiIntfInstantiations.Yes IgnoreOverrides id.idRange returnedObjTy
let pinfos = pinfos |> ExcludeHiddenOfPropInfos g infoReader.amap m
match pinfos with
| [pinfo] when pinfo.HasSetter && not pinfo.IsIndexer ->
Expand All @@ -327,7 +327,7 @@ type CalledMeth<'T>
| _ ->
let epinfos =
match nameEnv with
| Some(ne) -> ExtensionPropInfosOfTypeInScope infoReader ne (Some(nm), ad) m returnedObjTy
| Some ne -> ExtensionPropInfosOfTypeInScope ResultCollectionSettings.AllResults infoReader ne (Some nm) ad m returnedObjTy
| _ -> []
match epinfos with
| [pinfo] when pinfo.HasSetter && not pinfo.IsIndexer ->
Expand All @@ -337,8 +337,8 @@ type CalledMeth<'T>
| _ -> freshenMethInfo m pminfo

let pminst = match tyargsOpt with
| Some(TType.TType_app(_, types)) -> types
| _ -> pminst
| Some(TType.TType_app(_, types)) -> types
| _ -> pminst
Choice1Of2(AssignedItemSetter(id, AssignedPropSetter(pinfo, pminfo, pminst), e))
| _ ->
match infoReader.GetILFieldInfosOfType(Some(nm), ad, m, returnedObjTy) with
Expand Down
8 changes: 4 additions & 4 deletions src/fsharp/MethodOverrides.fs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ module DispatchSlotChecking =

// In the normal case, the requirements for a class are precisely all the abstract slots up the whole hierarchy.
// So here we get and yield all of those.
for minfo in reqdTy |> GetIntrinsicMethInfosOfType infoReader (None, AccessibleFromSomewhere, AllowMultiIntfInstantiations.Yes) IgnoreOverrides reqdTyRange do
for minfo in reqdTy |> GetIntrinsicMethInfosOfType infoReader None AccessibleFromSomewhere AllowMultiIntfInstantiations.Yes IgnoreOverrides reqdTyRange do
if minfo.IsDispatchSlot then
yield RequiredSlot(minfo, (*isOptional=*) not minfo.IsAbstract) ]

Expand Down Expand Up @@ -510,7 +510,7 @@ module DispatchSlotChecking =
isImpliedInterfaceType x.ApparentEnclosingType

let reqdProperties =
GetIntrinsicPropInfosOfType infoReader (None, AccessibleFromSomewhere, AllowMultiIntfInstantiations.Yes) IgnoreOverrides reqdTyRange reqdTy
GetIntrinsicPropInfosOfType infoReader None AccessibleFromSomewhere AllowMultiIntfInstantiations.Yes IgnoreOverrides reqdTyRange reqdTy
|> List.filter isRelevantRequiredProperty

let dispatchSlotsKeyed = dispatchSlots |> NameMultiMap.initBy (fun (RequiredSlot(v, _)) -> v.LogicalName)
Expand Down Expand Up @@ -708,7 +708,7 @@ let GetAbstractMethInfosForSynMethodDecl(infoReader:InfoReader, ad, memberName:I
| _, Some(SlotImplSet(_, dispatchSlotsKeyed, _, _)) ->
NameMultiMap.find memberName.idText dispatchSlotsKeyed |> List.map (fun (RequiredSlot(dispatchSlot, _)) -> dispatchSlot)
| ty, None ->
GetIntrinsicMethInfosOfType infoReader (Some(memberName.idText), ad, AllowMultiIntfInstantiations.Yes) IgnoreOverrides bindm ty
GetIntrinsicMethInfosOfType infoReader (Some memberName.idText) ad AllowMultiIntfInstantiations.Yes IgnoreOverrides bindm ty
let dispatchSlots = minfos |> List.filter (fun minfo -> minfo.IsDispatchSlot)
let topValSynArities = SynInfo.AritiesOfArgs valSynData
let topValSynArities = if List.isEmpty topValSynArities then topValSynArities else topValSynArities.Tail
Expand All @@ -723,7 +723,7 @@ let GetAbstractPropInfosForSynPropertyDecl(infoReader:InfoReader, ad, memberName
| _, Some(SlotImplSet(_, _, _, reqdProps)) ->
reqdProps |> List.filter (fun pinfo -> pinfo.PropertyName = memberName.idText)
| ty, None ->
GetIntrinsicPropInfosOfType infoReader (Some(memberName.idText), ad, AllowMultiIntfInstantiations.Yes) IgnoreOverrides bindm ty
GetIntrinsicPropInfosOfType infoReader (Some memberName.idText) ad AllowMultiIntfInstantiations.Yes IgnoreOverrides bindm ty

let dispatchSlots = pinfos |> List.filter (fun pinfo -> pinfo.IsVirtualProperty)
dispatchSlots
Expand Down
Loading

0 comments on commit 984d5da

Please sign in to comment.