From ed8ea8d0c714f9fff8624ee2701a87f2ccd4d315 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sat, 18 Jan 2020 14:37:05 +0100 Subject: [PATCH] tryDestAppTy instead of isAppTy --- src/fsharp/NameResolution.fs | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 10e330f2070..a63c8e6e138 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -536,11 +536,11 @@ let ExtensionPropInfosOfTypeInScope collectionSettings (infoReader:InfoReader) ( let extMemsFromHierarchy = infoReader.GetEntireTypeHierarchy(AllowMultiIntfInstantiations.Yes, m, ty) |> List.collect (fun ty -> - if isAppTy g ty then - let tcref = tcrefOfAppTy g ty + match tryDestAppTy g ty with + | ValueSome tcref -> let extMemInfos = nenv.eIndexedExtensionMembers.Find tcref SelectPropInfosFromExtMembers infoReader ad optFilter ty m extMemInfos - else []) + | _ -> []) extMemsDangling @ extMemsFromHierarchy @@ -606,11 +606,11 @@ let ExtensionMethInfosOfTypeInScope (collectionSettings: ResultCollectionSetting infoReader.GetEntireTypeHierarchy(AllowMultiIntfInstantiations.Yes, m, ty) |> List.collect (fun ty -> let g = infoReader.g - if isAppTy g ty then - let tcref = tcrefOfAppTy g ty + match tryDestAppTy g ty with + | ValueSome tcref -> 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) @@ -2352,10 +2352,11 @@ let rec ResolveLongIdentInTypePrim (ncenv: NameResolver) nenv lookupKind (resInf match lookupKind with | LookupKind.Expr | LookupKind.Pattern -> - if isAppTy g ty then - let tcref = tcrefOfAppTy g ty + match tryDestAppTy g ty with + | ValueSome tcref -> for uc in tcref.UnionCasesArray do addToBuffer uc.DisplayName + | _ -> () | _ -> () raze (UndefinedName (depth, FSComp.SR.undefinedNameFieldConstructorOrMember, id, suggestMembers)) @@ -2363,7 +2364,12 @@ let rec ResolveLongIdentInTypePrim (ncenv: NameResolver) nenv lookupKind (resInf and ResolveLongIdentInNestedTypes (ncenv: NameResolver) nenv lookupKind resInfo depth id m ad (id2: Ident) (rest: Ident list) findFlag typeNameResInfo tys = tys |> CollectAtMostOneResult (fun ty -> - let resInfo = if isAppTy ncenv.g ty then resInfo.AddEntity(id.idRange, tcrefOfAppTy ncenv.g ty) else resInfo + let resInfo = + match tryDestAppTy ncenv.g ty with + | ValueSome tcref -> + resInfo.AddEntity(id.idRange, tcref) + | _ -> + resInfo ResolveLongIdentInTypePrim ncenv nenv lookupKind resInfo depth m ad id2 rest findFlag typeNameResInfo ty |> AtMostOneResult m) @@ -2878,8 +2884,10 @@ let ResolvePatternLongIdent sink (ncenv: NameResolver) warnOnUpper newDef m ad n // X.ListEnumerator // does not resolve // let ResolveNestedTypeThroughAbbreviation (ncenv: NameResolver) (tcref: TyconRef) m = - if tcref.IsTypeAbbrev && tcref.Typars(m).IsEmpty && isAppTy ncenv.g tcref.TypeAbbrev.Value && isNil (argsOfAppTy ncenv.g tcref.TypeAbbrev.Value) then - tcrefOfAppTy ncenv.g tcref.TypeAbbrev.Value + if tcref.IsTypeAbbrev && tcref.Typars(m).IsEmpty then + match tryAppTy ncenv.g tcref.TypeAbbrev.Value with + | ValueSome (abbrevTcref, []) -> abbrevTcref + | _ -> tcref else tcref @@ -3527,7 +3535,10 @@ let ItemOfTyconRef ncenv m (x: TyconRef) = Item.Types (x.DisplayName, [FreshenTycon ncenv m x]) let ItemOfTy g x = - let nm = if isAppTy g x then (tcrefOfAppTy g x).DisplayName else "?" + let nm = + match tryDestAppTy g x with + | ValueSome tcref -> tcref.DisplayName + | _ -> "?" Item.Types (nm, [x]) // Filter out 'PrivateImplementationDetail' classes