Skip to content

Commit 4fa52dc

Browse files
Edgar GonzalezEdgar Gonzalez
Edgar Gonzalez
authored and
Edgar Gonzalez
committed
isCompileGenerated
1 parent bd46376 commit 4fa52dc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Diff for: src/Compiler/Checking/PostInferenceChecks.fs

+11-3
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,15 @@ let CheckTypeForAccess (cenv: cenv) env objName valAcc m ty =
532532
| ValueSome tcref ->
533533
let thisCompPath = compPathOfCcu cenv.viewCcu
534534
let tyconAcc = tcref.Accessibility |> AccessInternalsVisibleToAsInternal thisCompPath cenv.internalsVisibleToPaths
535-
536-
if isLessAccessible tyconAcc valAcc then
535+
536+
// Skip accessibility checks for compiler-generated pattern inputs, which all have names
537+
// starting with "val patternInput". This allows pattern matching to work properly with private
538+
// types when the pattern is used within the same module scope.
539+
let isCompilerGeneratedPatternInput =
540+
let name: string = objName()
541+
name.StartsWith("val patternInput")
542+
543+
if not isCompilerGeneratedPatternInput && isLessAccessible tyconAcc valAcc then
537544
errorR(Error(FSComp.SR.chkTypeLessAccessibleThanType(tcref.DisplayName, objName()), m))
538545

539546
CheckTypeDeep cenv (visitType, None, None, None, None) cenv.g env NoInfo ty
@@ -2058,7 +2065,8 @@ and CheckBinding cenv env alwaysCheckNoReraise ctxt (TBind(v, bindRhs, _) as bin
20582065

20592066
// Check accessibility
20602067
if (v.IsMemberOrModuleBinding || v.IsMember) && not v.IsIncrClassGeneratedMember then
2061-
CheckTypeForAccess cenv env (fun () -> NicePrint.stringOfQualifiedValOrMember cenv.denv cenv.infoReader vref) vref.Accessibility v.Range v.Type
2068+
let access = AdjustAccess (IsHiddenVal env.sigToImplRemapInfo v) (fun () -> v.DeclaringEntity.CompilationPath) v.Accessibility
2069+
CheckTypeForAccess cenv env (fun () -> NicePrint.stringOfQualifiedValOrMember cenv.denv cenv.infoReader vref) v.Accessibility v.Range v.Type
20622070

20632071
if cenv.reportErrors then
20642072

0 commit comments

Comments
 (0)