From 432d19fd08ea8266ee16ce264dc0fb362580bc14 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 26 May 2020 22:50:02 +0200 Subject: [PATCH] Remove isAppTy (#9246) --- src/fsharp/AccessibilityLogic.fs | 11 ++++++----- src/fsharp/LowerCallsAndSeqs.fs | 6 +++++- src/fsharp/MethodCalls.fs | 6 +++--- src/fsharp/NameResolution.fs | 6 +++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/fsharp/AccessibilityLogic.fs b/src/fsharp/AccessibilityLogic.fs index 8a8fe7028..05325646d 100644 --- a/src/fsharp/AccessibilityLogic.fs +++ b/src/fsharp/AccessibilityLogic.fs @@ -208,12 +208,13 @@ and IsTypeInstAccessible g amap m ad tinst = /// Indicate if a provided member is accessible let IsProvidedMemberAccessible (amap:Import.ImportMap) m ad ty access = let g = amap.g - let isTyAccessible = IsTypeAccessible g amap m ad ty - if not isTyAccessible then false + if IsTypeAccessible g amap m ad ty then + match tryTcrefOfAppTy g ty with + | ValueNone -> true + | ValueSome tcrefOfViewedItem -> + IsILMemberAccessible g amap m tcrefOfViewedItem ad access else - not (isAppTy g ty) || - let tcrefOfViewedItem = tcrefOfAppTy g ty - IsILMemberAccessible g amap m tcrefOfViewedItem ad access + false /// Compute the accessibility of a provided member let ComputeILAccess isPublic isFamily isFamilyOrAssembly isFamilyAndAssembly = diff --git a/src/fsharp/LowerCallsAndSeqs.fs b/src/fsharp/LowerCallsAndSeqs.fs index b4dac49c0..afb3a536d 100644 --- a/src/fsharp/LowerCallsAndSeqs.fs +++ b/src/fsharp/LowerCallsAndSeqs.fs @@ -542,7 +542,11 @@ let ConvertSequenceExprToObject g amap overallExpr = // printfn "FAILED - not worth compiling an unrecognized immediate yield! %s " (stringOfRange m) None else - let tyConfirmsToSeq g ty = isAppTy g ty && tyconRefEq g (tcrefOfAppTy g ty) g.tcref_System_Collections_Generic_IEnumerable + let tyConfirmsToSeq g ty = + match tryTcrefOfAppTy g ty with + | ValueSome tcref -> + tyconRefEq g tcref g.tcref_System_Collections_Generic_IEnumerable + | _ -> false match SearchEntireHierarchyOfType (tyConfirmsToSeq g) g amap m (tyOfExpr g arbitrarySeqExpr) with | None -> // printfn "FAILED - yield! did not yield a sequence! %s" (stringOfRange m) diff --git a/src/fsharp/MethodCalls.fs b/src/fsharp/MethodCalls.fs index 829e7b055..1d2d89103 100644 --- a/src/fsharp/MethodCalls.fs +++ b/src/fsharp/MethodCalls.fs @@ -848,8 +848,8 @@ let MakeMethInfoCall amap m minfo minst args = let TryImportProvidedMethodBaseAsLibraryIntrinsic (amap: Import.ImportMap, m: range, mbase: Tainted) = let methodName = mbase.PUntaint((fun x -> x.Name), m) let declaringType = Import.ImportProvidedType amap m (mbase.PApply((fun x -> x.DeclaringType), m)) - if isAppTy amap.g declaringType then - let declaringEntity = tcrefOfAppTy amap.g declaringType + match tryTcrefOfAppTy amap.g declaringType with + | ValueSome declaringEntity -> if not declaringEntity.IsLocalRef && ccuEq declaringEntity.nlr.Ccu amap.g.fslibCcu then match amap.g.knownIntrinsics.TryGetValue ((declaringEntity.LogicalName, methodName)) with | true, vref -> Some vref @@ -861,7 +861,7 @@ let TryImportProvidedMethodBaseAsLibraryIntrinsic (amap: Import.ImportMap, m: ra | _ -> None else None - else + | _ -> None #endif diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 368b6c3fb..029769e4d 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -2398,10 +2398,10 @@ let rec ResolveLongIdentInTypePrim (ncenv: NameResolver) nenv lookupKind (resInf | _ -> () let errorTextF s = - if isAppTy g ty then - let tcref = tcrefOfAppTy g ty + match tryTcrefOfAppTy g ty with + | ValueSome tcref -> FSComp.SR.undefinedNameFieldConstructorOrMemberWhenTypeIsKnown(tcref.DisplayNameWithStaticParametersAndTypars, s) - else + | _ -> FSComp.SR.undefinedNameFieldConstructorOrMember(s) raze (UndefinedName (depth, errorTextF, id, suggestMembers)) -- GitLab