Skip to content

Commit ddf520b

Browse files
forkibaronfel
authored andcommitted
tryDestAppTy instead of isAppTy (#8285)
1 parent de49b59 commit ddf520b

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/fsharp/NameResolution.fs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,11 @@ let ExtensionPropInfosOfTypeInScope collectionSettings (infoReader:InfoReader) (
536536
let extMemsFromHierarchy =
537537
infoReader.GetEntireTypeHierarchy(AllowMultiIntfInstantiations.Yes, m, ty)
538538
|> List.collect (fun ty ->
539-
if isAppTy g ty then
540-
let tcref = tcrefOfAppTy g ty
539+
match tryDestAppTy g ty with
540+
| ValueSome tcref ->
541541
let extMemInfos = nenv.eIndexedExtensionMembers.Find tcref
542542
SelectPropInfosFromExtMembers infoReader ad optFilter ty m extMemInfos
543-
else [])
543+
| _ -> [])
544544

545545
extMemsDangling @ extMemsFromHierarchy
546546

@@ -606,11 +606,11 @@ let ExtensionMethInfosOfTypeInScope (collectionSettings: ResultCollectionSetting
606606
infoReader.GetEntireTypeHierarchy(AllowMultiIntfInstantiations.Yes, m, ty)
607607
|> List.collect (fun ty ->
608608
let g = infoReader.g
609-
if isAppTy g ty then
610-
let tcref = tcrefOfAppTy g ty
609+
match tryDestAppTy g ty with
610+
| ValueSome tcref ->
611611
let extValRefs = nenv.eIndexedExtensionMembers.Find tcref
612612
SelectMethInfosFromExtMembers infoReader optFilter ty m extValRefs
613-
else [])
613+
| _ -> [])
614614
extMemsDangling @ extMemsFromHierarchy
615615

616616
/// Get all the available methods of a type (both intrinsic and extension)
@@ -2352,18 +2352,24 @@ let rec ResolveLongIdentInTypePrim (ncenv: NameResolver) nenv lookupKind (resInf
23522352

23532353
match lookupKind with
23542354
| LookupKind.Expr | LookupKind.Pattern ->
2355-
if isAppTy g ty then
2356-
let tcref = tcrefOfAppTy g ty
2355+
match tryDestAppTy g ty with
2356+
| ValueSome tcref ->
23572357
for uc in tcref.UnionCasesArray do
23582358
addToBuffer uc.DisplayName
2359+
| _ -> ()
23592360
| _ -> ()
23602361

23612362
raze (UndefinedName (depth, FSComp.SR.undefinedNameFieldConstructorOrMember, id, suggestMembers))
23622363

23632364
and ResolveLongIdentInNestedTypes (ncenv: NameResolver) nenv lookupKind resInfo depth id m ad (id2: Ident) (rest: Ident list) findFlag typeNameResInfo tys =
23642365
tys
23652366
|> CollectAtMostOneResult (fun ty ->
2366-
let resInfo = if isAppTy ncenv.g ty then resInfo.AddEntity(id.idRange, tcrefOfAppTy ncenv.g ty) else resInfo
2367+
let resInfo =
2368+
match tryDestAppTy ncenv.g ty with
2369+
| ValueSome tcref ->
2370+
resInfo.AddEntity(id.idRange, tcref)
2371+
| _ ->
2372+
resInfo
23672373
ResolveLongIdentInTypePrim ncenv nenv lookupKind resInfo depth m ad id2 rest findFlag typeNameResInfo ty
23682374
|> AtMostOneResult m)
23692375

@@ -2878,8 +2884,10 @@ let ResolvePatternLongIdent sink (ncenv: NameResolver) warnOnUpper newDef m ad n
28782884
// X.ListEnumerator // does not resolve
28792885
//
28802886
let ResolveNestedTypeThroughAbbreviation (ncenv: NameResolver) (tcref: TyconRef) m =
2881-
if tcref.IsTypeAbbrev && tcref.Typars(m).IsEmpty && isAppTy ncenv.g tcref.TypeAbbrev.Value && isNil (argsOfAppTy ncenv.g tcref.TypeAbbrev.Value) then
2882-
tcrefOfAppTy ncenv.g tcref.TypeAbbrev.Value
2887+
if tcref.IsTypeAbbrev && tcref.Typars(m).IsEmpty then
2888+
match tryAppTy ncenv.g tcref.TypeAbbrev.Value with
2889+
| ValueSome (abbrevTcref, []) -> abbrevTcref
2890+
| _ -> tcref
28832891
else
28842892
tcref
28852893

@@ -3527,7 +3535,10 @@ let ItemOfTyconRef ncenv m (x: TyconRef) =
35273535
Item.Types (x.DisplayName, [FreshenTycon ncenv m x])
35283536

35293537
let ItemOfTy g x =
3530-
let nm = if isAppTy g x then (tcrefOfAppTy g x).DisplayName else "?"
3538+
let nm =
3539+
match tryDestAppTy g x with
3540+
| ValueSome tcref -> tcref.DisplayName
3541+
| _ -> "?"
35313542
Item.Types (nm, [x])
35323543

35333544
// Filter out 'PrivateImplementationDetail' classes

0 commit comments

Comments
 (0)