diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs index 1cd69a223fa7..de229956a15f 100644 --- a/src/fsharp/ConstraintSolver.fs +++ b/src/fsharp/ConstraintSolver.fs @@ -1482,7 +1482,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. @@ -1997,8 +1997,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 diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index e04485887e17..66d0fbc0e418 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -649,22 +649,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 = @@ -682,12 +682,12 @@ let TryFindIntrinsicNamedItemOfType (infoReader:InfoReader) (nm,ad) findFlag m t /// -- 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 @@ -704,7 +704,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 diff --git a/src/fsharp/MethodCalls.fs b/src/fsharp/MethodCalls.fs index de5271eb6740..ae73bcb8c864 100644 --- a/src/fsharp/MethodCalls.fs +++ b/src/fsharp/MethodCalls.fs @@ -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 -> @@ -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 -> @@ -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 diff --git a/src/fsharp/MethodOverrides.fs b/src/fsharp/MethodOverrides.fs index 77b98010d316..fdf2bfd43f96 100644 --- a/src/fsharp/MethodOverrides.fs +++ b/src/fsharp/MethodOverrides.fs @@ -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) ] @@ -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) @@ -708,7 +708,7 @@ let GetAbstractMethInfosForSynMethodDecl(infoReader:InfoReader,ad,memberName:Ide | _,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 @@ -723,7 +723,7 @@ let GetAbstractPropInfosForSynPropertyDecl(infoReader:InfoReader,ad,memberName:I | _,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 diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 9434740d3146..1331a9f15314 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -1941,15 +1941,15 @@ let ResolveObjectConstructor (ncenv:NameResolver) edenv m ad ty = //------------------------------------------------------------------------- /// Query the declared properties of a type (including inherited properties) -let IntrinsicPropInfosOfTypeInScope (infoReader:InfoReader) (optFilter, ad) findFlag m ty = +let IntrinsicPropInfosOfTypeInScope (infoReader:InfoReader) optFilter ad findFlag m ty = let g = infoReader.g let amap = infoReader.amap - let pinfos = GetIntrinsicPropInfoSetsOfType infoReader (optFilter, ad, AllowMultiIntfInstantiations.Yes) findFlag m ty + let pinfos = GetIntrinsicPropInfoSetsOfType infoReader optFilter ad AllowMultiIntfInstantiations.Yes findFlag m ty let pinfos = pinfos |> ExcludeHiddenOfPropInfos g amap m pinfos /// Select from a list of extension properties -let SelectPropInfosFromExtMembers (infoReader:InfoReader,ad,optFilter) declaringTy m extMemInfos = +let SelectPropInfosFromExtMembers (infoReader:InfoReader) ad optFilter declaringTy m extMemInfos = let g = infoReader.g let amap = infoReader.amap // NOTE: multiple "open"'s push multiple duplicate values into eIndexedExtensionMembers, hence setify. @@ -1958,7 +1958,7 @@ let SelectPropInfosFromExtMembers (infoReader:InfoReader,ad,optFilter) declaring for emem in extMemInfos do if seen.Add emem then match emem with - | FSExtMem (vref,_pri) -> + | FSExtMem (vref,_pri) -> match vref.MemberInfo with | None -> () | Some membInfo -> propCollector.Collect(membInfo,vref) @@ -1968,31 +1968,35 @@ let SelectPropInfosFromExtMembers (infoReader:InfoReader,ad,optFilter) declaring propCollector.Close() /// Query the available extension properties of a type (including extension properties for inherited types) -let ExtensionPropInfosOfTypeInScope (infoReader:InfoReader) (nenv: NameResolutionEnv) (optFilter, ad) m ty = +let ExtensionPropInfosOfTypeInScope (collectionSettings:ResultCollectionSettings) (infoReader:InfoReader) (nenv: NameResolutionEnv) optFilter ad m ty = let g = infoReader.g - let extMemsFromHierarchy = - infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.Yes,m,ty) |> List.collect (fun ty -> - if isAppTy g ty then - let tcref = tcrefOfAppTy g ty - let extMemInfos = nenv.eIndexedExtensionMembers.Find tcref - SelectPropInfosFromExtMembers (infoReader,ad,optFilter) ty m extMemInfos - else []) + let extMemsDangling = SelectPropInfosFromExtMembers infoReader ad optFilter ty m nenv.eUnindexedExtensionMembers - let extMemsDangling = SelectPropInfosFromExtMembers (infoReader,ad,optFilter) ty m nenv.eUnindexedExtensionMembers - extMemsDangling @ extMemsFromHierarchy + if collectionSettings = ResultCollectionSettings.AtMostOneResult && not (isNil extMemsDangling) then + extMemsDangling + else + let extMemsFromHierarchy = + infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.Yes,m,ty) + |> List.collect (fun ty -> + if isAppTy g ty then + let tcref = tcrefOfAppTy g ty + let extMemInfos = nenv.eIndexedExtensionMembers.Find tcref + SelectPropInfosFromExtMembers infoReader ad optFilter ty m extMemInfos + else []) + extMemsDangling @ extMemsFromHierarchy /// Get all the available properties of a type (both intrinsic and extension) -let AllPropInfosOfTypeInScope infoReader nenv (optFilter, ad) findFlag m ty = - IntrinsicPropInfosOfTypeInScope infoReader (optFilter, ad) findFlag m ty - @ ExtensionPropInfosOfTypeInScope infoReader nenv (optFilter, ad) m ty +let AllPropInfosOfTypeInScope collectionSettings infoReader nenv optFilter ad findFlag m ty = + IntrinsicPropInfosOfTypeInScope infoReader optFilter ad findFlag m ty + @ ExtensionPropInfosOfTypeInScope collectionSettings infoReader nenv optFilter ad m ty /// Get the available methods of a type (both declared and inherited) -let IntrinsicMethInfosOfType (infoReader:InfoReader) (optFilter,ad,allowMultiIntfInst) findFlag m ty = +let IntrinsicMethInfosOfType (infoReader:InfoReader) optFilter ad allowMultiIntfInst findFlag m ty = let g = infoReader.g let amap = infoReader.amap - let minfos = GetIntrinsicMethInfoSetsOfType infoReader (optFilter,ad,allowMultiIntfInst) findFlag m ty + let minfos = GetIntrinsicMethInfoSetsOfType infoReader optFilter ad allowMultiIntfInst findFlag m ty let minfos = minfos |> ExcludeHiddenOfMethInfos g amap m minfos @@ -2031,22 +2035,29 @@ let SelectMethInfosFromExtMembers (infoReader:InfoReader) optFilter apparentTy m ] /// Query the available extension properties of a methods (including extension methods for inherited types) -let ExtensionMethInfosOfTypeInScope (infoReader:InfoReader) (nenv: NameResolutionEnv) optFilter m ty = - let extMemsDangling = SelectMethInfosFromExtMembers infoReader optFilter ty m nenv.eUnindexedExtensionMembers - let extMemsFromHierarchy = - infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.Yes,m,ty) |> List.collect (fun ty -> - let g = infoReader.g - if isAppTy g ty then - let tcref = tcrefOfAppTy g ty - let extValRefs = nenv.eIndexedExtensionMembers.Find tcref - SelectMethInfosFromExtMembers infoReader optFilter ty m extValRefs - else []) - extMemsDangling @ extMemsFromHierarchy +let ExtensionMethInfosOfTypeInScope (collectionSettings:ResultCollectionSettings) (infoReader:InfoReader) (nenv: NameResolutionEnv) optFilter m ty = + let extMemsDangling = SelectMethInfosFromExtMembers infoReader optFilter ty m nenv.eUnindexedExtensionMembers + if collectionSettings = ResultCollectionSettings.AtMostOneResult && not (isNil extMemsDangling) then + extMemsDangling + else + let extMemsFromHierarchy = + infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.Yes,m,ty) + |> List.collect (fun ty -> + let g = infoReader.g + if isAppTy g ty then + let tcref = tcrefOfAppTy g ty + let extValRefs = nenv.eIndexedExtensionMembers.Find tcref + SelectMethInfosFromExtMembers infoReader optFilter ty m extValRefs + else []) + extMemsDangling @ extMemsFromHierarchy /// Get all the available methods of a type (both intrinsic and extension) -let AllMethInfosOfTypeInScope infoReader nenv (optFilter,ad) findFlag m ty = - IntrinsicMethInfosOfType infoReader (optFilter,ad,AllowMultiIntfInstantiations.Yes) findFlag m ty - @ ExtensionMethInfosOfTypeInScope infoReader nenv optFilter m ty +let AllMethInfosOfTypeInScope collectionSettings infoReader nenv optFilter ad findFlag m ty = + let intrinsic = IntrinsicMethInfosOfType infoReader optFilter ad AllowMultiIntfInstantiations.Yes findFlag m ty + if collectionSettings = ResultCollectionSettings.AtMostOneResult && not (isNil intrinsic) then + intrinsic + else + intrinsic @ ExtensionMethInfosOfTypeInScope collectionSettings infoReader nenv optFilter m ty /// Used to report an error condition where name resolution failed due to an indeterminate type @@ -2152,7 +2163,7 @@ let rec ResolveLongIdentInTypePrim (ncenv:NameResolver) nenv lookupKind (resInfo let pinfos = psets |> ExcludeHiddenOfPropInfos g ncenv.amap m // fold the available extension members into the overload resolution - let extensionPropInfos = ExtensionPropInfosOfTypeInScope ncenv.InfoReader nenv (optFilter,ad) m ty + let extensionPropInfos = ExtensionPropInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv optFilter ad m ty // make sure to keep the intrinsic pinfos before the extension pinfos in the list, // since later on this logic is used when giving preference to intrinsic definitions @@ -2164,7 +2175,7 @@ let rec ResolveLongIdentInTypePrim (ncenv:NameResolver) nenv lookupKind (resInfo let minfos = msets |> ExcludeHiddenOfMethInfos g ncenv.amap m // fold the available extension members into the overload resolution - let extensionMethInfos = ExtensionMethInfosOfTypeInScope ncenv.InfoReader nenv optFilter m ty + let extensionMethInfos = ExtensionMethInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv optFilter m ty success [resInfo,Item.MakeMethGroup (nm,minfos@extensionMethInfos),rest] | Some (ILFieldItem (finfo:: _)) when (match lookupKind with LookupKind.Expr | LookupKind.Pattern -> true | _ -> false) -> @@ -2178,9 +2189,9 @@ let rec ResolveLongIdentInTypePrim (ncenv:NameResolver) nenv lookupKind (resInfo | _ -> - let pinfos = ExtensionPropInfosOfTypeInScope ncenv.InfoReader nenv (optFilter, ad) m ty + let pinfos = ExtensionPropInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv optFilter ad m ty if not (isNil pinfos) && isLookUpExpr then OneResult(success (resInfo,Item.Property (nm,pinfos),rest)) else - let minfos = ExtensionMethInfosOfTypeInScope ncenv.InfoReader nenv optFilter m ty + let minfos = ExtensionMethInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv optFilter m ty if not (isNil minfos) && isLookUpExpr then success [resInfo,Item.MakeMethGroup (nm,minfos),rest] @@ -2215,19 +2226,19 @@ let rec ResolveLongIdentInTypePrim (ncenv:NameResolver) nenv lookupKind (resInfo | _ -> let suggestMembers() = let suggestions1 = - ExtensionPropInfosOfTypeInScope ncenv.InfoReader nenv (None, ad) m ty + ExtensionPropInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv None ad m ty |> List.map (fun p -> p.PropertyName) let suggestions2 = - ExtensionMethInfosOfTypeInScope ncenv.InfoReader nenv None m ty + ExtensionMethInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv None m ty |> List.map (fun m -> m.DisplayName) let suggestions3 = - GetIntrinsicPropInfosOfType ncenv.InfoReader (None, ad, AllowMultiIntfInstantiations.No) findFlag m ty + GetIntrinsicPropInfosOfType ncenv.InfoReader None ad AllowMultiIntfInstantiations.No findFlag m ty |> List.map (fun p -> p.PropertyName) let suggestions4 = - GetIntrinsicMethInfosOfType ncenv.InfoReader (None, ad, AllowMultiIntfInstantiations.No) findFlag m ty + GetIntrinsicMethInfosOfType ncenv.InfoReader None ad AllowMultiIntfInstantiations.No findFlag m ty |> List.filter (fun m -> not m.IsClassConstructor && not m.IsConstructor) |> List.map (fun m -> m.DisplayName) @@ -3521,7 +3532,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso IsILFieldInfoAccessible g amap m ad x) let pinfosIncludingUnseen = - AllPropInfosOfTypeInScope ncenv.InfoReader nenv (None,ad) PreferOverrides m ty + AllPropInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv None ad PreferOverrides m ty |> List.filter (fun x -> x.IsStatic = statics && IsPropInfoAccessible g amap m ad x) @@ -3612,7 +3623,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso // REVIEW: add a name filter here in the common cases? let minfos = if completionTargets.ResolveAll then - let minfos = AllMethInfosOfTypeInScope ncenv.InfoReader nenv (None,ad) PreferOverrides m ty + let minfos = AllMethInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv None ad PreferOverrides m ty if isNil minfos then [] else @@ -3714,7 +3725,7 @@ let rec ResolvePartialLongIdentInType (ncenv: NameResolver) nenv isApplicableMet rty (ty - |> AllPropInfosOfTypeInScope ncenv.InfoReader nenv (Some id,ad) IgnoreOverrides m + |> AllPropInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv (Some id) ad IgnoreOverrides m |> List.filter (fun pinfo -> pinfo.IsStatic = statics && IsPropInfoAccessible g amap m ad pinfo) |> List.collect (fun pinfo -> (FullTypeOfPinfo pinfo) |> ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest)) @ @@ -4228,7 +4239,7 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics ty ( | _ -> () let pinfosIncludingUnseen = - AllPropInfosOfTypeInScope ncenv.InfoReader nenv (None,ad) PreferOverrides m ty + AllPropInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv None ad PreferOverrides m ty |> List.filter (fun x -> x.IsStatic = statics && IsPropInfoAccessible g amap m ad x) @@ -4314,7 +4325,7 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics ty ( | Item.MethodGroup _ -> // REVIEW: add a name filter here in the common cases? let minfos = - let minfos = AllMethInfosOfTypeInScope ncenv.InfoReader nenv (None,ad) PreferOverrides m ty + let minfos = AllMethInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv None ad PreferOverrides m ty if isNil minfos then [] else let suppressedMethNames = Zset.ofList String.order (pinfoMethNames @ einfoMethNames) @@ -4397,7 +4408,7 @@ let rec ResolvePartialLongIdentInTypeForItem (ncenv: NameResolver) nenv m ad sta let pinfos = ty - |> AllPropInfosOfTypeInScope ncenv.InfoReader nenv (Some id,ad) IgnoreOverrides m + |> AllPropInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv (Some id) ad IgnoreOverrides m |> List.filter (fun pinfo -> pinfo.IsStatic = statics && IsPropInfoAccessible g amap m ad pinfo) for pinfo in pinfos do diff --git a/src/fsharp/NameResolution.fsi b/src/fsharp/NameResolution.fsi index a302e22ef173..b8be6d1d2f11 100755 --- a/src/fsharp/NameResolution.fsi +++ b/src/fsharp/NameResolution.fsi @@ -1,541 +1,541 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. - -module internal Microsoft.FSharp.Compiler.NameResolution - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.PrettyNaming - -/// A NameResolver is a context for name resolution. It primarily holds an InfoReader. -type NameResolver = - new : g:TcGlobals * amap:ImportMap * infoReader:InfoReader * instantiationGenerator:(range -> Typars -> TypeInst) -> NameResolver - member InfoReader : InfoReader - member amap : ImportMap - member g : TcGlobals - -/// Get the active pattern elements defined in a module, if any. Cache in the slot in the module type. -val ActivePatternElemsOfModuleOrNamespace : ModuleOrNamespaceRef -> NameMap - -[] -/// Represents the item with which a named argument is associated. -type ArgumentContainer = - /// The named argument is an argument of a method - | Method of MethInfo - /// The named argument is a static parameter to a provided type or a parameter to an F# exception constructor - | Type of TyconRef - /// The named argument is a static parameter to a union case constructor - | UnionCase of UnionCaseInfo - -//--------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- - -/// Detect a use of a nominal type, including type abbreviations. -/// When reporting symbols, we care about abbreviations, e.g. 'int' and 'int32' count as two separate symbols. -val (|AbbrevOrAppTy|_|) : TType -> TyconRef option - -[] -/// Represents an item that results from name resolution -type Item = - /// Represents the resolution of a name to an F# value or function. - | Value of ValRef - - /// Represents the resolution of a name to an F# union case. - | UnionCase of UnionCaseInfo * bool - - /// Represents the resolution of a name to an F# active pattern result. - | ActivePatternResult of ActivePatternInfo * TType * int * range - - /// Represents the resolution of a name to an F# active pattern case within the body of an active pattern. - | ActivePatternCase of ActivePatternElemRef - - /// Represents the resolution of a name to an F# exception definition. - | ExnCase of TyconRef - - /// Represents the resolution of a name to an F# record field. - | RecdField of RecdFieldInfo - - /// Represents the resolution of a name to a field of an anonymous record type. - | AnonRecdField of AnonRecdTypeInfo * TTypes * int * range - - // The following are never in the items table but are valid results of binding - // an identifier in different circumstances. - - /// Represents the resolution of a name at the point of its own definition. - | NewDef of Ident - - /// Represents the resolution of a name to a .NET field - | ILField of ILFieldInfo - - /// Represents the resolution of a name to an event - | Event of EventInfo - - /// Represents the resolution of a name to a property - | Property of string * PropInfo list - - /// Represents the resolution of a name to a group of methods. - | MethodGroup of displayName: string * methods: MethInfo list * uninstantiatedMethodOpt: MethInfo option - - /// Represents the resolution of a name to a constructor - | CtorGroup of string * MethInfo list - - /// Represents the resolution of a name to the fake constructor simulated for an interface type. - | FakeInterfaceCtor of TType - - /// Represents the resolution of a name to a delegate - | DelegateCtor of TType - - /// Represents the resolution of a name to a group of types - | Types of string * TType list - - /// CustomOperation(nm, helpText, methInfo) - /// - /// Used to indicate the availability or resolution of a custom query operation such as 'sortBy' or 'where' in computation expression syntax - | CustomOperation of string * (unit -> string option) * MethInfo option - - /// Represents the resolution of a name to a custom builder in the F# computation expression syntax - | CustomBuilder of string * ValRef - - /// Represents the resolution of a name to a type variable - | TypeVar of string * Typar - - /// Represents the resolution of a name to a module or namespace - | ModuleOrNamespaces of Tast.ModuleOrNamespaceRef list - - /// Represents the resolution of a name to an operator - | ImplicitOp of Ident * TraitConstraintSln option ref - - /// Represents the resolution of a name to a named argument - | ArgName of Ident * TType * ArgumentContainer option - - /// Represents the resolution of a name to a named property setter - | SetterArg of Ident * Item - - /// Represents the potential resolution of an unqualified name to a type. - | UnqualifiedType of TyconRef list - - member DisplayName : string - -[] -/// Pairs an Item with a TyparInst showing how generic type variables of the item are instantiated at -/// a particular usage point. -type ItemWithInst = - { Item : Item - TyparInst: TyparInst } - -val (|ItemWithInst|) : ItemWithInst -> Item * TyparInst -val ItemWithNoInst : Item -> ItemWithInst - -/// Represents a record field resolution and the information if the usage is deprecated. -type FieldResolution = FieldResolution of RecdFieldRef * bool - -/// Information about an extension member held in the name resolution environment -[] -type ExtensionMember - -/// The environment of information used to resolve names -[] -type NameResolutionEnv = - {eDisplayEnv: DisplayEnv - eUnqualifiedItems: LayeredMap - ePatItems: NameMap - eModulesAndNamespaces: NameMultiMap - eFullyQualifiedModulesAndNamespaces: NameMultiMap - eFieldLabels: NameMultiMap - eTyconsByAccessNames: LayeredMultiMap - eFullyQualifiedTyconsByAccessNames: LayeredMultiMap - eTyconsByDemangledNameAndArity: LayeredMap - eFullyQualifiedTyconsByDemangledNameAndArity: LayeredMap - eIndexedExtensionMembers: TyconRefMultiMap - eUnindexedExtensionMembers: ExtensionMember list - eTypars: NameMap } - static member Empty : g:TcGlobals -> NameResolutionEnv - member DisplayEnv : DisplayEnv - member FindUnqualifiedItem : string -> Item - -type FullyQualifiedFlag = - | FullyQualified - | OpenQualified - -[] -type BulkAdd = Yes | No - -/// Find a field in anonymous record type -val internal TryFindAnonRecdFieldOfType : TcGlobals -> TType -> string -> Item option - -/// Add extra items to the environment for Visual Studio, e.g. static members -val internal AddFakeNamedValRefToNameEnv : string -> NameResolutionEnv -> ValRef -> NameResolutionEnv - -/// Add some extra items to the environment for Visual Studio, e.g. record members -val internal AddFakeNameToNameEnv : string -> NameResolutionEnv -> Item -> NameResolutionEnv - -/// Add a single F# value to the environment. -val internal AddValRefToNameEnv : NameResolutionEnv -> ValRef -> NameResolutionEnv - -/// Add active pattern result tags to the environment. -val internal AddActivePatternResultTagsToNameEnv : ActivePatternInfo -> NameResolutionEnv -> TType -> range -> NameResolutionEnv - -/// Add a list of type definitions to the name resolution environment -val internal AddTyconRefsToNameEnv : BulkAdd -> bool -> TcGlobals -> ImportMap -> range -> bool -> NameResolutionEnv -> TyconRef list -> NameResolutionEnv - -/// Add an F# exception definition to the name resolution environment -val internal AddExceptionDeclsToNameEnv : BulkAdd -> NameResolutionEnv -> TyconRef -> NameResolutionEnv - -/// Add a module abbreviation to the name resolution environment -val internal AddModuleAbbrevToNameEnv : Ident -> NameResolutionEnv -> ModuleOrNamespaceRef list -> NameResolutionEnv - -/// Add a list of module or namespace to the name resolution environment, including any sub-modules marked 'AutoOpen' -val internal AddModuleOrNamespaceRefsToNameEnv : TcGlobals -> ImportMap -> range -> bool -> AccessorDomain -> NameResolutionEnv -> ModuleOrNamespaceRef list -> NameResolutionEnv - -/// Add a single modules or namespace to the name resolution environment -val internal AddModuleOrNamespaceRefToNameEnv : TcGlobals -> ImportMap -> range -> bool -> AccessorDomain -> NameResolutionEnv -> ModuleOrNamespaceRef -> NameResolutionEnv - -/// Add a list of modules or namespaces to the name resolution environment -val internal AddModulesAndNamespacesContentsToNameEnv : TcGlobals -> ImportMap -> AccessorDomain -> range -> bool -> NameResolutionEnv -> ModuleOrNamespaceRef list -> NameResolutionEnv - -/// A flag which indicates if it is an error to have two declared type parameters with identical names -/// in the name resolution environment. -type CheckForDuplicateTyparFlag = - | CheckForDuplicateTypars - | NoCheckForDuplicateTypars - -/// Add some declared type parameters to the name resolution environment -val internal AddDeclaredTyparsToNameEnv : CheckForDuplicateTyparFlag -> NameResolutionEnv -> Typar list -> NameResolutionEnv - -/// Qualified lookup of type names in the environment -val internal LookupTypeNameInEnvNoArity : FullyQualifiedFlag -> string -> NameResolutionEnv -> TyconRef list - -/// Indicates whether we are resolving type names to type definitions or to constructor methods. -type TypeNameResolutionFlag = - /// Indicates we are resolving type names to constructor methods. - | ResolveTypeNamesToCtors - /// Indicates we are resolving type names to type definitions - | ResolveTypeNamesToTypeRefs - -/// Represents information about the generic argument count of a type name when resolving it. -/// -/// In some situations we resolve "List" to any type definition with that name regardless of the number -/// of generic arguments. In others, we know precisely how many generic arguments are needed. -[] -type TypeNameResolutionStaticArgsInfo = - /// Indicates definite knowledge of empty type arguments, i.e. the logical equivalent of name< > - static member DefiniteEmpty : TypeNameResolutionStaticArgsInfo - /// Deduce definite knowledge of type arguments - static member FromTyArgs : numTyArgs:int -> TypeNameResolutionStaticArgsInfo - -/// Represents information which guides name resolution of types. -[] -type TypeNameResolutionInfo = - | TypeNameResolutionInfo of TypeNameResolutionFlag * TypeNameResolutionStaticArgsInfo - static member Default : TypeNameResolutionInfo - static member ResolveToTypeRefs : TypeNameResolutionStaticArgsInfo -> TypeNameResolutionInfo - -/// Represents the kind of the occurrence when reporting a name in name resolution +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +module internal Microsoft.FSharp.Compiler.NameResolution + +open Microsoft.FSharp.Compiler +open Microsoft.FSharp.Compiler.AccessibilityLogic +open Microsoft.FSharp.Compiler.Ast +open Microsoft.FSharp.Compiler.Infos +open Microsoft.FSharp.Compiler.Range +open Microsoft.FSharp.Compiler.Import +open Microsoft.FSharp.Compiler.InfoReader +open Microsoft.FSharp.Compiler.Tast +open Microsoft.FSharp.Compiler.Tastops +open Microsoft.FSharp.Compiler.TcGlobals +open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open Microsoft.FSharp.Compiler.PrettyNaming + +/// A NameResolver is a context for name resolution. It primarily holds an InfoReader. +type NameResolver = + new : g:TcGlobals * amap:ImportMap * infoReader:InfoReader * instantiationGenerator:(range -> Typars -> TypeInst) -> NameResolver + member InfoReader : InfoReader + member amap : ImportMap + member g : TcGlobals + +/// Get the active pattern elements defined in a module, if any. Cache in the slot in the module type. +val ActivePatternElemsOfModuleOrNamespace : ModuleOrNamespaceRef -> NameMap + +[] +/// Represents the item with which a named argument is associated. +type ArgumentContainer = + /// The named argument is an argument of a method + | Method of MethInfo + /// The named argument is a static parameter to a provided type or a parameter to an F# exception constructor + | Type of TyconRef + /// The named argument is a static parameter to a union case constructor + | UnionCase of UnionCaseInfo + +//--------------------------------------------------------------------------- +// +//------------------------------------------------------------------------- + +/// Detect a use of a nominal type, including type abbreviations. +/// When reporting symbols, we care about abbreviations, e.g. 'int' and 'int32' count as two separate symbols. +val (|AbbrevOrAppTy|_|) : TType -> TyconRef option + +[] +/// Represents an item that results from name resolution +type Item = + /// Represents the resolution of a name to an F# value or function. + | Value of ValRef + + /// Represents the resolution of a name to an F# union case. + | UnionCase of UnionCaseInfo * bool + + /// Represents the resolution of a name to an F# active pattern result. + | ActivePatternResult of ActivePatternInfo * TType * int * range + + /// Represents the resolution of a name to an F# active pattern case within the body of an active pattern. + | ActivePatternCase of ActivePatternElemRef + + /// Represents the resolution of a name to an F# exception definition. + | ExnCase of TyconRef + + /// Represents the resolution of a name to an F# record field. + | RecdField of RecdFieldInfo + + /// Represents the resolution of a name to a field of an anonymous record type. + | AnonRecdField of AnonRecdTypeInfo * TTypes * int * range + + // The following are never in the items table but are valid results of binding + // an identifier in different circumstances. + + /// Represents the resolution of a name at the point of its own definition. + | NewDef of Ident + + /// Represents the resolution of a name to a .NET field + | ILField of ILFieldInfo + + /// Represents the resolution of a name to an event + | Event of EventInfo + + /// Represents the resolution of a name to a property + | Property of string * PropInfo list + + /// Represents the resolution of a name to a group of methods. + | MethodGroup of displayName: string * methods: MethInfo list * uninstantiatedMethodOpt: MethInfo option + + /// Represents the resolution of a name to a constructor + | CtorGroup of string * MethInfo list + + /// Represents the resolution of a name to the fake constructor simulated for an interface type. + | FakeInterfaceCtor of TType + + /// Represents the resolution of a name to a delegate + | DelegateCtor of TType + + /// Represents the resolution of a name to a group of types + | Types of string * TType list + + /// CustomOperation(nm, helpText, methInfo) + /// + /// Used to indicate the availability or resolution of a custom query operation such as 'sortBy' or 'where' in computation expression syntax + | CustomOperation of string * (unit -> string option) * MethInfo option + + /// Represents the resolution of a name to a custom builder in the F# computation expression syntax + | CustomBuilder of string * ValRef + + /// Represents the resolution of a name to a type variable + | TypeVar of string * Typar + + /// Represents the resolution of a name to a module or namespace + | ModuleOrNamespaces of Tast.ModuleOrNamespaceRef list + + /// Represents the resolution of a name to an operator + | ImplicitOp of Ident * TraitConstraintSln option ref + + /// Represents the resolution of a name to a named argument + | ArgName of Ident * TType * ArgumentContainer option + + /// Represents the resolution of a name to a named property setter + | SetterArg of Ident * Item + + /// Represents the potential resolution of an unqualified name to a type. + | UnqualifiedType of TyconRef list + + member DisplayName : string + +[] +/// Pairs an Item with a TyparInst showing how generic type variables of the item are instantiated at +/// a particular usage point. +type ItemWithInst = + { Item : Item + TyparInst: TyparInst } + +val (|ItemWithInst|) : ItemWithInst -> Item * TyparInst +val ItemWithNoInst : Item -> ItemWithInst + +/// Represents a record field resolution and the information if the usage is deprecated. +type FieldResolution = FieldResolution of RecdFieldRef * bool + +/// Information about an extension member held in the name resolution environment +[] +type ExtensionMember + +/// The environment of information used to resolve names +[] +type NameResolutionEnv = + {eDisplayEnv: DisplayEnv + eUnqualifiedItems: LayeredMap + ePatItems: NameMap + eModulesAndNamespaces: NameMultiMap + eFullyQualifiedModulesAndNamespaces: NameMultiMap + eFieldLabels: NameMultiMap + eTyconsByAccessNames: LayeredMultiMap + eFullyQualifiedTyconsByAccessNames: LayeredMultiMap + eTyconsByDemangledNameAndArity: LayeredMap + eFullyQualifiedTyconsByDemangledNameAndArity: LayeredMap + eIndexedExtensionMembers: TyconRefMultiMap + eUnindexedExtensionMembers: ExtensionMember list + eTypars: NameMap } + static member Empty : g:TcGlobals -> NameResolutionEnv + member DisplayEnv : DisplayEnv + member FindUnqualifiedItem : string -> Item + +type FullyQualifiedFlag = + | FullyQualified + | OpenQualified + +[] +type BulkAdd = Yes | No + +/// Find a field in anonymous record type +val internal TryFindAnonRecdFieldOfType : TcGlobals -> TType -> string -> Item option + +/// Add extra items to the environment for Visual Studio, e.g. static members +val internal AddFakeNamedValRefToNameEnv : string -> NameResolutionEnv -> ValRef -> NameResolutionEnv + +/// Add some extra items to the environment for Visual Studio, e.g. record members +val internal AddFakeNameToNameEnv : string -> NameResolutionEnv -> Item -> NameResolutionEnv + +/// Add a single F# value to the environment. +val internal AddValRefToNameEnv : NameResolutionEnv -> ValRef -> NameResolutionEnv + +/// Add active pattern result tags to the environment. +val internal AddActivePatternResultTagsToNameEnv : ActivePatternInfo -> NameResolutionEnv -> TType -> range -> NameResolutionEnv + +/// Add a list of type definitions to the name resolution environment +val internal AddTyconRefsToNameEnv : BulkAdd -> bool -> TcGlobals -> ImportMap -> range -> bool -> NameResolutionEnv -> TyconRef list -> NameResolutionEnv + +/// Add an F# exception definition to the name resolution environment +val internal AddExceptionDeclsToNameEnv : BulkAdd -> NameResolutionEnv -> TyconRef -> NameResolutionEnv + +/// Add a module abbreviation to the name resolution environment +val internal AddModuleAbbrevToNameEnv : Ident -> NameResolutionEnv -> ModuleOrNamespaceRef list -> NameResolutionEnv + +/// Add a list of module or namespace to the name resolution environment, including any sub-modules marked 'AutoOpen' +val internal AddModuleOrNamespaceRefsToNameEnv : TcGlobals -> ImportMap -> range -> bool -> AccessorDomain -> NameResolutionEnv -> ModuleOrNamespaceRef list -> NameResolutionEnv + +/// Add a single modules or namespace to the name resolution environment +val internal AddModuleOrNamespaceRefToNameEnv : TcGlobals -> ImportMap -> range -> bool -> AccessorDomain -> NameResolutionEnv -> ModuleOrNamespaceRef -> NameResolutionEnv + +/// Add a list of modules or namespaces to the name resolution environment +val internal AddModulesAndNamespacesContentsToNameEnv : TcGlobals -> ImportMap -> AccessorDomain -> range -> bool -> NameResolutionEnv -> ModuleOrNamespaceRef list -> NameResolutionEnv + +/// A flag which indicates if it is an error to have two declared type parameters with identical names +/// in the name resolution environment. +type CheckForDuplicateTyparFlag = + | CheckForDuplicateTypars + | NoCheckForDuplicateTypars + +/// Add some declared type parameters to the name resolution environment +val internal AddDeclaredTyparsToNameEnv : CheckForDuplicateTyparFlag -> NameResolutionEnv -> Typar list -> NameResolutionEnv + +/// Qualified lookup of type names in the environment +val internal LookupTypeNameInEnvNoArity : FullyQualifiedFlag -> string -> NameResolutionEnv -> TyconRef list + +/// Indicates whether we are resolving type names to type definitions or to constructor methods. +type TypeNameResolutionFlag = + /// Indicates we are resolving type names to constructor methods. + | ResolveTypeNamesToCtors + /// Indicates we are resolving type names to type definitions + | ResolveTypeNamesToTypeRefs + +/// Represents information about the generic argument count of a type name when resolving it. +/// +/// In some situations we resolve "List" to any type definition with that name regardless of the number +/// of generic arguments. In others, we know precisely how many generic arguments are needed. +[] +type TypeNameResolutionStaticArgsInfo = + /// Indicates definite knowledge of empty type arguments, i.e. the logical equivalent of name< > + static member DefiniteEmpty : TypeNameResolutionStaticArgsInfo + /// Deduce definite knowledge of type arguments + static member FromTyArgs : numTyArgs:int -> TypeNameResolutionStaticArgsInfo + +/// Represents information which guides name resolution of types. +[] +type TypeNameResolutionInfo = + | TypeNameResolutionInfo of TypeNameResolutionFlag * TypeNameResolutionStaticArgsInfo + static member Default : TypeNameResolutionInfo + static member ResolveToTypeRefs : TypeNameResolutionStaticArgsInfo -> TypeNameResolutionInfo + +/// Represents the kind of the occurrence when reporting a name in name resolution [] -type internal ItemOccurence = - | Binding - | Use - | UseInType - | UseInAttribute - | Pattern - | Implemented - | RelatedText - | Open - -/// Check for equality, up to signature matching -val ItemsAreEffectivelyEqual : TcGlobals -> Item -> Item -> bool - -/// Hash compatible with ItemsAreEffectivelyEqual -val ItemsAreEffectivelyEqualHash : TcGlobals -> Item -> int - -[] -type internal CapturedNameResolution = - /// line and column - member Pos : pos - - /// Named item - member Item : Item - - /// The active instantiation for any generic type parameters - member ItemWithInst: ItemWithInst - - /// Information about the occurrence of the symbol - member ItemOccurence : ItemOccurence - - /// Information about printing. For example, should redundant keywords be hidden? - member DisplayEnv : DisplayEnv - - /// Naming environment--for example, currently open namespaces. - member NameResolutionEnv : NameResolutionEnv - - /// The access rights of code at the location - member AccessorDomain : AccessorDomain - - /// The starting and ending position - member Range : range - -[] -type internal TcResolutions = - - /// Name resolution environments for every interesting region in the file. These regions may - /// overlap, in which case the smallest region applicable should be used. - member CapturedEnvs : ResizeArray - - /// Information of exact types found for expressions, that can be to the left of a dot. - /// typ - the inferred type for an expression - member CapturedExpressionTypings : ResizeArray - - /// Exact name resolutions - member CapturedNameResolutions : ResizeArray - - /// Represents all the resolutions of names to groups of methods. - member CapturedMethodGroupResolutions : ResizeArray - - /// Represents the empty set of resolutions - static member Empty : TcResolutions - - -[] -type TcSymbolUseData = - { Item: Item - ItemOccurence: ItemOccurence - DisplayEnv: DisplayEnv - Range: range } - -[] -/// Represents container for all name resolutions that were met so far when typechecking some particular file -type internal TcSymbolUses = - - /// Get all the uses of a particular item within the file - member GetUsesOfSymbol : Item -> TcSymbolUseData[] - - /// All the uses of all items within the file +type internal ItemOccurence = + | Binding + | Use + | UseInType + | UseInAttribute + | Pattern + | Implemented + | RelatedText + | Open + +/// Check for equality, up to signature matching +val ItemsAreEffectivelyEqual : TcGlobals -> Item -> Item -> bool + +/// Hash compatible with ItemsAreEffectivelyEqual +val ItemsAreEffectivelyEqualHash : TcGlobals -> Item -> int + +[] +type internal CapturedNameResolution = + /// line and column + member Pos : pos + + /// Named item + member Item : Item + + /// The active instantiation for any generic type parameters + member ItemWithInst: ItemWithInst + + /// Information about the occurrence of the symbol + member ItemOccurence : ItemOccurence + + /// Information about printing. For example, should redundant keywords be hidden? + member DisplayEnv : DisplayEnv + + /// Naming environment--for example, currently open namespaces. + member NameResolutionEnv : NameResolutionEnv + + /// The access rights of code at the location + member AccessorDomain : AccessorDomain + + /// The starting and ending position + member Range : range + +[] +type internal TcResolutions = + + /// Name resolution environments for every interesting region in the file. These regions may + /// overlap, in which case the smallest region applicable should be used. + member CapturedEnvs : ResizeArray + + /// Information of exact types found for expressions, that can be to the left of a dot. + /// typ - the inferred type for an expression + member CapturedExpressionTypings : ResizeArray + + /// Exact name resolutions + member CapturedNameResolutions : ResizeArray + + /// Represents all the resolutions of names to groups of methods. + member CapturedMethodGroupResolutions : ResizeArray + + /// Represents the empty set of resolutions + static member Empty : TcResolutions + + +[] +type TcSymbolUseData = + { Item: Item + ItemOccurence: ItemOccurence + DisplayEnv: DisplayEnv + Range: range } + +[] +/// Represents container for all name resolutions that were met so far when typechecking some particular file +type internal TcSymbolUses = + + /// Get all the uses of a particular item within the file + member GetUsesOfSymbol : Item -> TcSymbolUseData[] + + /// All the uses of all items within the file member AllUsesOfSymbols : TcSymbolUseData[][] - - /// Get the locations of all the printf format specifiers in the file - member GetFormatSpecifierLocationsAndArity : unit -> (range * int)[] - -/// Represents open declaration statement. -type internal OpenDeclaration = - { /// Long identifier as it's presented in soruce code. - LongId: Ident list - - /// Full range of the open declaration. - Range : range option - - /// Modules or namespaces which is opened with this declaration. - Modules: ModuleOrNamespaceRef list - - /// Scope in which open declaration is visible. - AppliedScope: range - - /// If it's `namespace Xxx.Yyy` declaration. - IsOwnNamespace: bool } - - /// Create a new instance of OpenDeclaration. - static member Create : longId: Ident list * modules: ModuleOrNamespaceRef list * appliedScope: range * isOwnNamespace: bool -> OpenDeclaration - -/// Source text and an array of line end positions, used for format string parsing -type FormatStringCheckContext = - { /// Source text - Source: string - /// Array of line start positions - LineStartPositions: int[] } - -/// An abstract type for reporting the results of name resolution and type checking -type ITypecheckResultsSink = - - /// Record that an environment is active over the given scope range - abstract NotifyEnvWithScope : range * NameResolutionEnv * AccessorDomain -> unit - - /// Record that an expression has a specific type at the given range. - abstract NotifyExprHasType : pos * TType * DisplayEnv * NameResolutionEnv * AccessorDomain * range -> unit - - /// Record that a name resolution occurred at a specific location in the source - abstract NotifyNameResolution : pos * Item * Item * TyparInst * ItemOccurence * DisplayEnv * NameResolutionEnv * AccessorDomain * range * bool -> unit - - /// Record that a printf format specifier occurred at a specific location in the source - abstract NotifyFormatSpecifierLocation : range * int -> unit - - /// Record that an open declaration occured in a given scope range - abstract NotifyOpenDeclaration : OpenDeclaration -> unit - - /// Get the current source - abstract CurrentSource : string option - - /// Cached line-end normalized source text and an array of line end positions, used for format string parsing - abstract FormatStringCheckContext : FormatStringCheckContext option - -/// An implementation of ITypecheckResultsSink to collect information during type checking -type internal TcResultsSinkImpl = - - /// Create a TcResultsSinkImpl - new : tcGlobals : TcGlobals * ?source:string -> TcResultsSinkImpl - - /// Get all the resolutions reported to the sink - member GetResolutions : unit -> TcResolutions - - /// Get all the uses of all symbols reported to the sink - member GetSymbolUses : unit -> TcSymbolUses - - /// Get all open declarations reported to the sink - member GetOpenDeclarations : unit -> OpenDeclaration[] - - interface ITypecheckResultsSink - -/// An abstract type for reporting the results of name resolution and type checking, and which allows -/// temporary suspension and/or redirection of reporting. -type TcResultsSink = - { mutable CurrentSink : ITypecheckResultsSink option } - static member NoSink : TcResultsSink - static member WithSink : ITypecheckResultsSink -> TcResultsSink - -/// Temporarily redirect reporting of name resolution and type checking results -val internal WithNewTypecheckResultsSink : ITypecheckResultsSink * TcResultsSink -> System.IDisposable - -/// Temporarily suspend reporting of name resolution and type checking results -val internal TemporarilySuspendReportingTypecheckResultsToSink : TcResultsSink -> System.IDisposable - -/// Report the active name resolution environment for a source range -val internal CallEnvSink : TcResultsSink -> range * NameResolutionEnv * AccessorDomain -> unit - -/// Report a specific name resolution at a source range -val internal CallNameResolutionSink : TcResultsSink -> range * NameResolutionEnv * Item * Item * TyparInst * ItemOccurence * DisplayEnv * AccessorDomain -> unit - -/// Report a specific name resolution at a source range, replacing any previous resolutions -val internal CallNameResolutionSinkReplacing : TcResultsSink -> range * NameResolutionEnv * Item * Item * TyparInst * ItemOccurence * DisplayEnv * AccessorDomain -> unit - -/// Report a specific name resolution at a source range -val internal CallExprHasTypeSink : TcResultsSink -> range * NameResolutionEnv * TType * DisplayEnv * AccessorDomain -> unit - -/// Report an open declaration -val internal CallOpenDeclarationSink : TcResultsSink -> OpenDeclaration -> unit - -/// Get all the available properties of a type (both intrinsic and extension) -val internal AllPropInfosOfTypeInScope : InfoReader -> NameResolutionEnv -> string option * AccessorDomain -> FindMemberFlag -> range -> TType -> PropInfo list - -/// Get all the available properties of a type (only extension) -val internal ExtensionPropInfosOfTypeInScope : InfoReader -> NameResolutionEnv -> string option * AccessorDomain -> range -> TType -> PropInfo list - -/// Get the available methods of a type (both declared and inherited) -val internal AllMethInfosOfTypeInScope : InfoReader -> NameResolutionEnv -> string option * AccessorDomain -> FindMemberFlag -> range -> TType -> MethInfo list - -/// Used to report an error condition where name resolution failed due to an indeterminate type -exception internal IndeterminateType of range - -/// Used to report a warning condition for the use of upper-case identifiers in patterns -exception internal UpperCaseIdentifierInPattern of range - -/// Generate a new reference to a record field with a fresh type instantiation -val FreshenRecdFieldRef :NameResolver -> Range.range -> Tast.RecdFieldRef -> Item - -/// Indicates the kind of lookup being performed. Note, this type should be made private to nameres.fs. -[] -type LookupKind = - | RecdField - | Pattern - | Expr - | Type - | Ctor - - -/// Indicates if a warning should be given for the use of upper-case identifiers in patterns -type WarnOnUpperFlag = - | WarnOnUpperCase - | AllIdsOK - -/// Indicates whether we permit a direct reference to a type generator. Only set when resolving the -/// right-hand-side of a [] declaration. -[] -type PermitDirectReferenceToGeneratedType = - | Yes - | No - -/// Indicates if we only need one result or all possible results from a resolution. -[] -type ResultCollectionSettings = -| AllResults -| AtMostOneResult - -/// Resolve a long identifier to a namespace or module. -val internal ResolveLongIndentAsModuleOrNamespace : TcResultsSink -> ResultCollectionSettings -> Import.ImportMap -> range -> bool -> FullyQualifiedFlag -> NameResolutionEnv -> AccessorDomain -> Ident -> Ident list -> isOpenDecl: bool -> ResultOrException<(int * ModuleOrNamespaceRef * ModuleOrNamespaceType) list > - -/// Resolve a long identifier to an object constructor. -val internal ResolveObjectConstructor : NameResolver -> DisplayEnv -> range -> AccessorDomain -> TType -> ResultOrException - -/// Resolve a long identifier using type-qualified name resolution. -val internal ResolveLongIdentInType : TcResultsSink -> NameResolver -> NameResolutionEnv -> LookupKind -> range -> AccessorDomain -> Ident -> FindMemberFlag -> TypeNameResolutionInfo -> TType -> Item * Ident list - -/// Resolve a long identifier when used in a pattern. -val internal ResolvePatternLongIdent : TcResultsSink -> NameResolver -> WarnOnUpperFlag -> bool -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> Item - -/// Resolve a long identifier representing a type name -val internal ResolveTypeLongIdentInTyconRef : TcResultsSink -> NameResolver -> NameResolutionEnv -> TypeNameResolutionInfo -> AccessorDomain -> range -> ModuleOrNamespaceRef -> Ident list -> TyconRef - -/// Resolve a long identifier to a type definition -val internal ResolveTypeLongIdent : TcResultsSink -> NameResolver -> ItemOccurence -> FullyQualifiedFlag -> NameResolutionEnv -> AccessorDomain -> Ident list -> TypeNameResolutionStaticArgsInfo -> PermitDirectReferenceToGeneratedType -> ResultOrException - -/// Resolve a long identifier to a field -val internal ResolveField : TcResultsSink -> NameResolver -> NameResolutionEnv -> AccessorDomain -> TType -> Ident list * Ident -> Ident list -> FieldResolution list - -/// Resolve a long identifier occurring in an expression position -val internal ResolveExprLongIdent : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> Item * Ident list - -/// Resolve a (possibly incomplete) long identifier to a loist of possible class or record fields -val internal ResolvePartialLongIdentToClassOrRecdFields : NameResolver -> NameResolutionEnv -> range -> AccessorDomain -> string list -> bool -> Item list - -/// Return the fields for the given class or record -val internal ResolveRecordOrClassFieldsOfType : NameResolver -> range -> AccessorDomain -> TType -> bool -> Item list - -/// Specifies extra work to do after overload resolution -[] -type AfterResolution = - /// Notification is not needed - | DoNothing - - /// Notify the sink of the information needed to complete recording a use of a symbol - /// for the purposes of the language service. One of the callbacks should be called by - /// the checker. - /// - /// The first callback represents a case where we have learned the type - /// instantiation of a generic method or value. - /// - /// The second represents the case where we have resolved overloading and/or - /// a specific override. The 'Item option' contains the candidate overrides. - | RecordResolution of Item option * (TyparInst -> unit) * (MethInfo * PropInfo option * TyparInst -> unit) * (unit -> unit) - -/// Resolve a long identifier occurring in an expression position. -val internal ResolveLongIdentAsExprAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> Item * range * Ident list * AfterResolution - -/// Resolve a long identifier occurring in an expression position, qualified by a type. -val internal ResolveExprDotLongIdentAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TType -> Ident list -> FindMemberFlag -> bool -> Item * range * Ident list * AfterResolution - -/// A generator of type instantiations used when no more specific type instantiation is known. -val FakeInstantiationGenerator : range -> Typar list -> TType list - -/// Try to resolve a long identifier as type. -val TryToResolveLongIdentAsType : NameResolver -> NameResolutionEnv -> range -> string list -> TType option - -/// Resolve a (possibly incomplete) long identifier to a set of possible resolutions. -val ResolvePartialLongIdent : NameResolver -> NameResolutionEnv -> (MethInfo -> TType -> bool) -> range -> AccessorDomain -> string list -> bool -> Item list - -[] -type ResolveCompletionTargets = - | All of (MethInfo -> TType -> bool) - | SettablePropertiesAndFields - -/// Resolve a (possibly incomplete) long identifier to a set of possible resolutions, qualified by type. -val ResolveCompletionsInType : NameResolver -> NameResolutionEnv -> ResolveCompletionTargets -> Range.range -> AccessorDomain -> bool -> TType -> Item list - -val GetVisibleNamespacesAndModulesAtPoint : NameResolver -> NameResolutionEnv -> range -> AccessorDomain -> ModuleOrNamespaceRef list - -val IsItemResolvable : NameResolver -> NameResolutionEnv -> range -> AccessorDomain -> string list -> Item -> bool + + /// Get the locations of all the printf format specifiers in the file + member GetFormatSpecifierLocationsAndArity : unit -> (range * int)[] + +/// Represents open declaration statement. +type internal OpenDeclaration = + { /// Long identifier as it's presented in soruce code. + LongId: Ident list + + /// Full range of the open declaration. + Range : range option + + /// Modules or namespaces which is opened with this declaration. + Modules: ModuleOrNamespaceRef list + + /// Scope in which open declaration is visible. + AppliedScope: range + + /// If it's `namespace Xxx.Yyy` declaration. + IsOwnNamespace: bool } + + /// Create a new instance of OpenDeclaration. + static member Create : longId: Ident list * modules: ModuleOrNamespaceRef list * appliedScope: range * isOwnNamespace: bool -> OpenDeclaration + +/// Source text and an array of line end positions, used for format string parsing +type FormatStringCheckContext = + { /// Source text + Source: string + /// Array of line start positions + LineStartPositions: int[] } + +/// An abstract type for reporting the results of name resolution and type checking +type ITypecheckResultsSink = + + /// Record that an environment is active over the given scope range + abstract NotifyEnvWithScope : range * NameResolutionEnv * AccessorDomain -> unit + + /// Record that an expression has a specific type at the given range. + abstract NotifyExprHasType : pos * TType * DisplayEnv * NameResolutionEnv * AccessorDomain * range -> unit + + /// Record that a name resolution occurred at a specific location in the source + abstract NotifyNameResolution : pos * Item * Item * TyparInst * ItemOccurence * DisplayEnv * NameResolutionEnv * AccessorDomain * range * bool -> unit + + /// Record that a printf format specifier occurred at a specific location in the source + abstract NotifyFormatSpecifierLocation : range * int -> unit + + /// Record that an open declaration occured in a given scope range + abstract NotifyOpenDeclaration : OpenDeclaration -> unit + + /// Get the current source + abstract CurrentSource : string option + + /// Cached line-end normalized source text and an array of line end positions, used for format string parsing + abstract FormatStringCheckContext : FormatStringCheckContext option + +/// An implementation of ITypecheckResultsSink to collect information during type checking +type internal TcResultsSinkImpl = + + /// Create a TcResultsSinkImpl + new : tcGlobals : TcGlobals * ?source:string -> TcResultsSinkImpl + + /// Get all the resolutions reported to the sink + member GetResolutions : unit -> TcResolutions + + /// Get all the uses of all symbols reported to the sink + member GetSymbolUses : unit -> TcSymbolUses + + /// Get all open declarations reported to the sink + member GetOpenDeclarations : unit -> OpenDeclaration[] + + interface ITypecheckResultsSink + +/// An abstract type for reporting the results of name resolution and type checking, and which allows +/// temporary suspension and/or redirection of reporting. +type TcResultsSink = + { mutable CurrentSink : ITypecheckResultsSink option } + static member NoSink : TcResultsSink + static member WithSink : ITypecheckResultsSink -> TcResultsSink + +/// Indicates if we only need one result or all possible results from a resolution. +[] +type ResultCollectionSettings = + | AllResults + | AtMostOneResult + +/// Temporarily redirect reporting of name resolution and type checking results +val internal WithNewTypecheckResultsSink : ITypecheckResultsSink * TcResultsSink -> System.IDisposable + +/// Temporarily suspend reporting of name resolution and type checking results +val internal TemporarilySuspendReportingTypecheckResultsToSink : TcResultsSink -> System.IDisposable + +/// Report the active name resolution environment for a source range +val internal CallEnvSink : TcResultsSink -> range * NameResolutionEnv * AccessorDomain -> unit + +/// Report a specific name resolution at a source range +val internal CallNameResolutionSink : TcResultsSink -> range * NameResolutionEnv * Item * Item * TyparInst * ItemOccurence * DisplayEnv * AccessorDomain -> unit + +/// Report a specific name resolution at a source range, replacing any previous resolutions +val internal CallNameResolutionSinkReplacing : TcResultsSink -> range * NameResolutionEnv * Item * Item * TyparInst * ItemOccurence * DisplayEnv * AccessorDomain -> unit + +/// Report a specific name resolution at a source range +val internal CallExprHasTypeSink : TcResultsSink -> range * NameResolutionEnv * TType * DisplayEnv * AccessorDomain -> unit + +/// Report an open declaration +val internal CallOpenDeclarationSink : TcResultsSink -> OpenDeclaration -> unit + +/// Get all the available properties of a type (both intrinsic and extension) +val internal AllPropInfosOfTypeInScope : ResultCollectionSettings -> InfoReader -> NameResolutionEnv -> string option -> AccessorDomain -> FindMemberFlag -> range -> TType -> PropInfo list + +/// Get all the available properties of a type (only extension) +val internal ExtensionPropInfosOfTypeInScope : ResultCollectionSettings -> InfoReader -> NameResolutionEnv -> string option -> AccessorDomain -> range -> TType -> PropInfo list + +/// Get the available methods of a type (both declared and inherited) +val internal AllMethInfosOfTypeInScope : ResultCollectionSettings -> InfoReader -> NameResolutionEnv -> string option -> AccessorDomain -> FindMemberFlag -> range -> TType -> MethInfo list + +/// Used to report an error condition where name resolution failed due to an indeterminate type +exception internal IndeterminateType of range + +/// Used to report a warning condition for the use of upper-case identifiers in patterns +exception internal UpperCaseIdentifierInPattern of range + +/// Generate a new reference to a record field with a fresh type instantiation +val FreshenRecdFieldRef :NameResolver -> Range.range -> Tast.RecdFieldRef -> Item + +/// Indicates the kind of lookup being performed. Note, this type should be made private to nameres.fs. +[] +type LookupKind = + | RecdField + | Pattern + | Expr + | Type + | Ctor + + +/// Indicates if a warning should be given for the use of upper-case identifiers in patterns +type WarnOnUpperFlag = + | WarnOnUpperCase + | AllIdsOK + +/// Indicates whether we permit a direct reference to a type generator. Only set when resolving the +/// right-hand-side of a [] declaration. +[] +type PermitDirectReferenceToGeneratedType = + | Yes + | No + +/// Resolve a long identifier to a namespace or module. +val internal ResolveLongIndentAsModuleOrNamespace : TcResultsSink -> ResultCollectionSettings -> Import.ImportMap -> range -> bool -> FullyQualifiedFlag -> NameResolutionEnv -> AccessorDomain -> Ident -> Ident list -> isOpenDecl: bool -> ResultOrException<(int * ModuleOrNamespaceRef * ModuleOrNamespaceType) list > + +/// Resolve a long identifier to an object constructor. +val internal ResolveObjectConstructor : NameResolver -> DisplayEnv -> range -> AccessorDomain -> TType -> ResultOrException + +/// Resolve a long identifier using type-qualified name resolution. +val internal ResolveLongIdentInType : TcResultsSink -> NameResolver -> NameResolutionEnv -> LookupKind -> range -> AccessorDomain -> Ident -> FindMemberFlag -> TypeNameResolutionInfo -> TType -> Item * Ident list + +/// Resolve a long identifier when used in a pattern. +val internal ResolvePatternLongIdent : TcResultsSink -> NameResolver -> WarnOnUpperFlag -> bool -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> Item + +/// Resolve a long identifier representing a type name +val internal ResolveTypeLongIdentInTyconRef : TcResultsSink -> NameResolver -> NameResolutionEnv -> TypeNameResolutionInfo -> AccessorDomain -> range -> ModuleOrNamespaceRef -> Ident list -> TyconRef + +/// Resolve a long identifier to a type definition +val internal ResolveTypeLongIdent : TcResultsSink -> NameResolver -> ItemOccurence -> FullyQualifiedFlag -> NameResolutionEnv -> AccessorDomain -> Ident list -> TypeNameResolutionStaticArgsInfo -> PermitDirectReferenceToGeneratedType -> ResultOrException + +/// Resolve a long identifier to a field +val internal ResolveField : TcResultsSink -> NameResolver -> NameResolutionEnv -> AccessorDomain -> TType -> Ident list * Ident -> Ident list -> FieldResolution list + +/// Resolve a long identifier occurring in an expression position +val internal ResolveExprLongIdent : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> Item * Ident list + +/// Resolve a (possibly incomplete) long identifier to a loist of possible class or record fields +val internal ResolvePartialLongIdentToClassOrRecdFields : NameResolver -> NameResolutionEnv -> range -> AccessorDomain -> string list -> bool -> Item list + +/// Return the fields for the given class or record +val internal ResolveRecordOrClassFieldsOfType : NameResolver -> range -> AccessorDomain -> TType -> bool -> Item list + +/// Specifies extra work to do after overload resolution +[] +type AfterResolution = + /// Notification is not needed + | DoNothing + + /// Notify the sink of the information needed to complete recording a use of a symbol + /// for the purposes of the language service. One of the callbacks should be called by + /// the checker. + /// + /// The first callback represents a case where we have learned the type + /// instantiation of a generic method or value. + /// + /// The second represents the case where we have resolved overloading and/or + /// a specific override. The 'Item option' contains the candidate overrides. + | RecordResolution of Item option * (TyparInst -> unit) * (MethInfo * PropInfo option * TyparInst -> unit) * (unit -> unit) + +/// Resolve a long identifier occurring in an expression position. +val internal ResolveLongIdentAsExprAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> Item * range * Ident list * AfterResolution + +/// Resolve a long identifier occurring in an expression position, qualified by a type. +val internal ResolveExprDotLongIdentAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TType -> Ident list -> FindMemberFlag -> bool -> Item * range * Ident list * AfterResolution + +/// A generator of type instantiations used when no more specific type instantiation is known. +val FakeInstantiationGenerator : range -> Typar list -> TType list + +/// Try to resolve a long identifier as type. +val TryToResolveLongIdentAsType : NameResolver -> NameResolutionEnv -> range -> string list -> TType option + +/// Resolve a (possibly incomplete) long identifier to a set of possible resolutions. +val ResolvePartialLongIdent : NameResolver -> NameResolutionEnv -> (MethInfo -> TType -> bool) -> range -> AccessorDomain -> string list -> bool -> Item list + +[] +type ResolveCompletionTargets = + | All of (MethInfo -> TType -> bool) + | SettablePropertiesAndFields + +/// Resolve a (possibly incomplete) long identifier to a set of possible resolutions, qualified by type. +val ResolveCompletionsInType : NameResolver -> NameResolutionEnv -> ResolveCompletionTargets -> Range.range -> AccessorDomain -> bool -> TType -> Item list + +val GetVisibleNamespacesAndModulesAtPoint : NameResolver -> NameResolutionEnv -> range -> AccessorDomain -> ModuleOrNamespaceRef list + +val IsItemResolvable : NameResolver -> NameResolutionEnv -> range -> AccessorDomain -> string list -> Item -> bool diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index 142ccbae0761..416f3658eb7d 100755 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -1562,7 +1562,7 @@ module private TastDefinitionPrinting = GetImmediateInterfacesOfType SkipUnrefInterfaces.Yes g amap m ty |> List.map (fun ity -> wordL (tagKeyword (if isInterfaceTy g ty then "inherit" else "interface")) --- layoutType denv ity) let props = - GetIntrinsicPropInfosOfType infoReader (None,ad,AllowMultiIntfInstantiations.Yes) PreferOverrides m ty + GetIntrinsicPropInfosOfType infoReader None ad AllowMultiIntfInstantiations.Yes PreferOverrides m ty |> List.filter (fun v -> shouldShow v.ArbitraryValRef) let events = diff --git a/src/fsharp/PostInferenceChecks.fs b/src/fsharp/PostInferenceChecks.fs index acc3c0c03a22..ef9227b89fb1 100644 --- a/src/fsharp/PostInferenceChecks.fs +++ b/src/fsharp/PostInferenceChecks.fs @@ -1925,7 +1925,7 @@ let CheckEntityDefn cenv env (tycon:Entity) = let allVirtualMethsInParent = match GetSuperTypeOfType g cenv.amap m ty with | Some super -> - GetIntrinsicMethInfosOfType cenv.infoReader (None,AccessibleFromSomewhere,AllowMultiIntfInstantiations.Yes) IgnoreOverrides m super + GetIntrinsicMethInfosOfType cenv.infoReader None AccessibleFromSomewhere AllowMultiIntfInstantiations.Yes IgnoreOverrides m super |> List.filter (fun minfo -> minfo.IsVirtual) | None -> [] diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 14e9fad77ae9..155a282a7f64 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -3035,16 +3035,16 @@ let BuildPossiblyConditionalMethodCall cenv env isMutable m isProp minfo valUseF BuildMethodCall tcVal cenv.g cenv.amap isMutable m isProp minfo valUseFlags minst objArgs args -let TryFindIntrinsicOrExtensionMethInfo (cenv:cenv) (env: TcEnv) m ad nm ty = - AllMethInfosOfTypeInScope cenv.infoReader env.NameEnv (Some(nm), ad) IgnoreOverrides m ty +let TryFindIntrinsicOrExtensionMethInfo collectionSettings (cenv:cenv) (env: TcEnv) m ad nm ty = + AllMethInfosOfTypeInScope collectionSettings cenv.infoReader env.NameEnv (Some nm) ad IgnoreOverrides m ty /// Build the 'test and dispose' part of a 'use' statement let BuildDisposableCleanup cenv env m (v:Val) = v.SetHasBeenReferenced() let ad = env.eAccessRights let disposeMethod = - match TryFindIntrinsicOrExtensionMethInfo cenv env m ad "Dispose" cenv.g.system_IDisposable_ty with - | [x] -> x + match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AllResults cenv env m ad "Dispose" cenv.g.system_IDisposable_ty with + | [x] -> x | _ -> error(InternalError(FSComp.SR.tcCouldNotFindIDisposable(), m)) @@ -3068,8 +3068,8 @@ let BuildDisposableCleanup cenv env m (v:Val) = let BuildOffsetToStringData cenv env m = let ad = env.eAccessRights let offsetToStringDataMethod = - match TryFindIntrinsicOrExtensionMethInfo cenv env m ad "get_OffsetToStringData" cenv.g.system_RuntimeHelpers_ty with - | [x] -> x + match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AllResults cenv env m ad "get_OffsetToStringData" cenv.g.system_RuntimeHelpers_ty with + | [x] -> x | _ -> error(Error(FSComp.SR.tcCouldNotFindOffsetToStringData(), m)) let offsetExpr, _ = BuildPossiblyConditionalMethodCall cenv env NeverMutates m false offsetToStringDataMethod NormalValUse [] [] [] @@ -3253,10 +3253,9 @@ let AnalyzeArbitraryExprAsEnumerable cenv (env: TcEnv) localAlloc m exprty expr Exception(Error(msg, m)) let findMethInfo k m nm ty = - match TryFindIntrinsicOrExtensionMethInfo cenv env m ad nm ty with + match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env m ad nm ty with | [] -> err k ty - | res :: _ -> Result res - + | res :: _ -> Result res // Ensure there are no curried arguments, and indeed no arguments at all let hasArgs (minfo:MethInfo) minst = @@ -3315,7 +3314,7 @@ let AnalyzeArbitraryExprAsEnumerable cenv (env: TcEnv) localAlloc m exprty expr typeEquiv cenv.g cenv.g.obj_ty ty | _ -> false - match TryFindIntrinsicOrExtensionMethInfo cenv env m ad "get_Item" tyToSearchForGetEnumeratorAndItem with + match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AllResults cenv env m ad "get_Item" tyToSearchForGetEnumeratorAndItem with | (minfo :: others) when (allEquivReturnTypes minfo others && List.exists isInt32OrObjectIndexer (minfo :: others)) -> minfo.GetFSharpReturnTy(cenv.amap, m, []) @@ -3323,7 +3322,7 @@ let AnalyzeArbitraryExprAsEnumerable cenv (env: TcEnv) localAlloc m exprty expr | _ -> // Some types such as XmlNodeList have only an Item method - match TryFindIntrinsicOrExtensionMethInfo cenv env m ad "Item" tyToSearchForGetEnumeratorAndItem with + match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AllResults cenv env m ad "Item" tyToSearchForGetEnumeratorAndItem with | (minfo :: others) when (allEquivReturnTypes minfo others && List.exists isInt32OrObjectIndexer (minfo :: others)) -> minfo.GetFSharpReturnTy(cenv.amap, m, []) @@ -6229,9 +6228,10 @@ and TcIndexerThen cenv env overallTy mWholeExpr mDot tpenv wholeExpr e1 indexArg | ValueSome tcref -> TryFindTyconRefStringAttribute cenv.g mWholeExpr cenv.g.attrib_DefaultMemberAttribute tcref | _ -> - match AllPropInfosOfTypeInScope cenv.infoReader env.NameEnv (Some "Item", ad) IgnoreOverrides mWholeExpr ty with + let item = Some "Item" + match AllPropInfosOfTypeInScope ResultCollectionSettings.AtMostOneResult cenv.infoReader env.NameEnv item ad IgnoreOverrides mWholeExpr ty with | [] -> None - | _ -> Some "Item" + | _ -> item | _ -> acc) cenv.g cenv.amap @@ -7284,7 +7284,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv let builderVal = mkSynIdGet m builderValName mkSynApp1 (SynExpr.DotGet(builderVal, range0, LongIdentWithDots([mkSynId m nm], []), m)) args m - let sourceMethInfo = TryFindIntrinsicOrExtensionMethInfo cenv env mBuilderVal ad "Source" builderTy + let sourceMethInfo = TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mBuilderVal ad "Source" builderTy // Optionally wrap sources of "let!", "yield!", "use!" in "query.Source" let mkSourceExpr callExpr = match sourceMethInfo with @@ -7294,12 +7294,12 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv /// Decide if the builder is an auto-quote builder let isAutoQuote = - match TryFindIntrinsicOrExtensionMethInfo cenv env mBuilderVal ad "Quote" builderTy with + match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mBuilderVal ad "Quote" builderTy with | [] -> false | _ -> true let customOperationMethods = - AllMethInfosOfTypeInScope cenv.infoReader env.NameEnv (None, ad) IgnoreOverrides mBuilderVal builderTy + AllMethInfosOfTypeInScope ResultCollectionSettings.AllResults cenv.infoReader env.NameEnv None ad IgnoreOverrides mBuilderVal builderTy |> List.choose (fun methInfo -> if not (IsMethInfoAccessible cenv.amap mBuilderVal ad methInfo) then None else let nameSearch = @@ -7874,7 +7874,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv let mFor = match spForLoop with SequencePointAtForLoop(m) -> m | _ -> pat.Range let mPat = pat.Range let spBind = match spForLoop with SequencePointAtForLoop(m) -> SequencePointAtBinding(m) | NoSequencePointAtForLoop -> NoSequencePointAtStickyBinding - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env mFor ad "For" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("For"), mFor)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mFor ad "For" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("For"), mFor)) // Add the variables to the query variable space, on demand let varSpace = @@ -7894,23 +7894,23 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv let mGuard = guardExpr.Range let mWhile = match spWhile with SequencePointAtWhileLoop(m) -> m | _ -> mGuard if isQuery then error(Error(FSComp.SR.tcNoWhileInQuery(), mWhile)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env mWhile ad "While" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("While"), mWhile)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env mWhile ad "Delay" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Delay"), mWhile)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mWhile ad "While" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("While"), mWhile)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mWhile ad "Delay" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Delay"), mWhile)) Some(trans true q varSpace innerComp (fun holeFill -> translatedCtxt (mkSynCall "While" mWhile [mkSynDelay2 guardExpr; mkSynCall "Delay" mWhile [mkSynDelay innerComp.Range holeFill]])) ) | SynExpr.TryFinally (innerComp, unwindExpr, mTryToLast, spTry, _spFinally) -> let mTry = match spTry with SequencePointAtTry(m) -> m | _ -> mTryToLast if isQuery then error(Error(FSComp.SR.tcNoTryFinallyInQuery(), mTry)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env mTry ad "TryFinally" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("TryFinally"), mTry)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env mTry ad "Delay" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Delay"), mTry)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mTry ad "TryFinally" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("TryFinally"), mTry)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mTry ad "Delay" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Delay"), mTry)) Some (translatedCtxt (mkSynCall "TryFinally" mTry [mkSynCall "Delay" mTry [mkSynDelay innerComp.Range (transNoQueryOps innerComp)]; mkSynDelay2 unwindExpr])) | SynExpr.Paren (_, _, _, m) -> error(Error(FSComp.SR.tcConstructIsAmbiguousInComputationExpression(), m)) | SynExpr.ImplicitZero m -> - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env m ad "Zero" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Zero"), m)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env m ad "Zero" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Zero"), m)) Some (translatedCtxt (mkSynCall "Zero" m [])) | OptionalSequential (JoinOrGroupJoinOrZipClause (_, _, _, _, _, mClause), _) @@ -8070,8 +8070,8 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv | SynExpr.ForEach (SequencePointAtForLoop mBind, _, _, _, _, _, _) -> mBind | SynExpr.While (SequencePointAtWhileLoop mWhile, _, _, _) -> mWhile | _ -> innerComp1.Range - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env m ad "Combine" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Combine"), m)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env m ad "Delay" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Delay"), m)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env m ad "Combine" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Combine"), m)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env m ad "Delay" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Delay"), m)) Some (translatedCtxt (mkSynCall "Combine" m1 [c; mkSynCall "Delay" m1 [mkSynDelay innerComp2.Range (transNoQueryOps innerComp2)]])) | None -> // "do! expr; cexpr" is treated as { let! () = expr in cexpr } @@ -8094,7 +8094,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv Some (translatedCtxt (SynExpr.IfThenElse(guardExpr, transNoQueryOps thenComp, Some(transNoQueryOps elseComp), spIfToThen, isRecovery, mIfToThen, mIfToEndOfElseBranch))) | None -> let elseComp = - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env mIfToThen ad "Zero" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Zero"), mIfToThen)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mIfToThen ad "Zero" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Zero"), mIfToThen)) mkSynCall "Zero" mIfToThen [] Some (trans true q varSpace thenComp (fun holeFill -> translatedCtxt (SynExpr.IfThenElse(guardExpr, holeFill, Some elseComp, spIfToThen, isRecovery, mIfToThen, mIfToEndOfElseBranch)))) @@ -8135,7 +8135,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv if isQuery then error(Error(FSComp.SR.tcUseMayNotBeUsedInQueries(), bindRange)) let innerCompRange = innerComp.Range let consumeExpr = SynExpr.MatchLambda(false, innerCompRange, [Clause(pat, None, transNoQueryOps innerComp, innerCompRange, SequencePointAtTarget)], spBind, innerCompRange) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env bindRange ad "Using" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Using"), bindRange)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env bindRange ad "Using" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Using"), bindRange)) Some (translatedCtxt (mkSynCall "Using" bindRange [rhsExpr; consumeExpr ])) // 'let! pat = expr in expr' --> build.Bind(e1, (function _argN -> match _argN with pat -> expr)) @@ -8144,7 +8144,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv let bindRange = match spBind with SequencePointAtBinding(m) -> m | _ -> rhsExpr.Range if isQuery then error(Error(FSComp.SR.tcBindMayNotBeUsedInQueries(), bindRange)) let innerRange = innerComp.Range - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env bindRange ad "Bind" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Bind"), bindRange)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env bindRange ad "Bind" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Bind"), bindRange)) // Add the variables to the query variable space, on demand let varSpace = @@ -8164,8 +8164,8 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv let bindRange = match spBind with SequencePointAtBinding(m) -> m | _ -> rhsExpr.Range if isQuery then error(Error(FSComp.SR.tcBindMayNotBeUsedInQueries(), bindRange)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env bindRange ad "Using" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Using"), bindRange)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env bindRange ad "Bind" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Bind"), bindRange)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env bindRange ad "Using" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Using"), bindRange)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env bindRange ad "Bind" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Bind"), bindRange)) let consumeExpr = SynExpr.MatchLambda(false, bindRange, [Clause(pat, None, transNoQueryOps innerComp, innerComp.Range, SequencePointAtTarget)], spBind, bindRange) let consumeExpr = mkSynCall "Using" bindRange [SynExpr.Ident(id); consumeExpr ] let consumeExpr = SynExpr.MatchLambda(false, bindRange, [Clause(pat, None, consumeExpr, id.idRange, SequencePointAtTarget)], spBind, bindRange) @@ -8186,7 +8186,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv | SynExpr.MatchBang (spMatch, expr, clauses, m) -> let mMatch = match spMatch with SequencePointAtBinding mMatch -> mMatch | _ -> m if isQuery then error(Error(FSComp.SR.tcMatchMayNotBeUsedWithQuery(), mMatch)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env mMatch ad "Bind" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Bind"), mMatch)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mMatch ad "Bind" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Bind"), mMatch)) let clauses = clauses |> List.map (fun (Clause(pat, cond, innerComp, patm, sp)) -> Clause(pat, cond, transNoQueryOps innerComp, patm, sp)) let consumeExpr = SynExpr.MatchLambda(false, mMatch, clauses, spMatch, mMatch) Some(translatedCtxt (mkSynCall "Bind" mMatch [expr; consumeExpr])) @@ -8197,19 +8197,19 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv if isQuery then error(Error(FSComp.SR.tcTryWithMayNotBeUsedInQueries(), mTry)) let clauses = clauses |> List.map (fun (Clause(pat, cond, clauseComp, patm, sp)) -> Clause(pat, cond, transNoQueryOps clauseComp, patm, sp)) let consumeExpr = SynExpr.MatchLambda(true, mTryToLast, clauses, NoSequencePointAtStickyBinding, mTryToLast) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env mTry ad "TryWith" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("TryWith"), mTry)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env mTry ad "Delay" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Delay"), mTry)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mTry ad "TryWith" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("TryWith"), mTry)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mTry ad "Delay" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("Delay"), mTry)) Some(translatedCtxt (mkSynCall "TryWith" mTry [mkSynCall "Delay" mTry [mkSynDelay2 (transNoQueryOps innerComp)]; consumeExpr])) | SynExpr.YieldOrReturnFrom((isYield, _), yieldExpr, m) -> let yieldExpr = mkSourceExpr yieldExpr if isYield then - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env m ad "YieldFrom" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("YieldFrom"), m)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env m ad "YieldFrom" builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod("YieldFrom"), m)) Some (translatedCtxt (mkSynCall "YieldFrom" m [yieldExpr])) else if isQuery then error(Error(FSComp.SR.tcReturnMayNotBeUsedInQueries(), m)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env m ad "ReturnFrom" builderTy) then + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env m ad "ReturnFrom" builderTy) then errorR(Error(FSComp.SR.tcRequireBuilderMethod("ReturnFrom"), m)) Some (translatedCtxt yieldExpr) else @@ -8219,7 +8219,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv | SynExpr.YieldOrReturn((isYield, _), yieldExpr, m) -> let methName = (if isYield then "Yield" else "Return") if isQuery && not isYield then error(Error(FSComp.SR.tcReturnMayNotBeUsedInQueries(), m)) - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env m ad methName builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod(methName), m)) + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env m ad methName builderTy) then error(Error(FSComp.SR.tcRequireBuilderMethod(methName), m)) Some(translatedCtxt (mkSynCall methName m [yieldExpr])) | _ -> None @@ -8237,7 +8237,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv let rhsExpr = mkSourceExpr rhsExpr if isQuery then error(Error(FSComp.SR.tcBindMayNotBeUsedInQueries(), m)) let bodyExpr = - if isNil (TryFindIntrinsicOrExtensionMethInfo cenv env m ad "Return" builderTy) then + if isNil (TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env m ad "Return" builderTy) then SynExpr.ImplicitZero m else SynExpr.YieldOrReturn((false, true), SynExpr.Const(SynConst.Unit, m), m) @@ -8258,7 +8258,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv let basicSynExpr = trans true (hasCustomOperations ()) (LazyWithContext.NotLazy ([], env)) comp (fun holeFill -> holeFill) let delayedExpr = - match TryFindIntrinsicOrExtensionMethInfo cenv env mBuilderVal ad "Delay" builderTy with + match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mBuilderVal ad "Delay" builderTy with | [] -> basicSynExpr | _ -> mkSynCall "Delay" mBuilderVal [(mkSynDelay2 basicSynExpr)] @@ -8270,7 +8270,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv let runExpr = - match TryFindIntrinsicOrExtensionMethInfo cenv env mBuilderVal ad "Run" builderTy with + match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env mBuilderVal ad "Run" builderTy with | [] -> quotedSynExpr | _ -> mkSynCall "Run" mBuilderVal [quotedSynExpr]