@@ -532,8 +532,15 @@ let CheckTypeForAccess (cenv: cenv) env objName valAcc m ty =
532
532
| ValueSome tcref ->
533
533
let thisCompPath = compPathOfCcu cenv.viewCcu
534
534
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
537
544
errorR( Error( FSComp.SR.chkTypeLessAccessibleThanType( tcref.DisplayName, objName()), m))
538
545
539
546
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
2058
2065
2059
2066
// Check accessibility
2060
2067
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
2062
2070
2063
2071
if cenv.reportErrors then
2064
2072
0 commit comments