@@ -1291,13 +1291,27 @@ where
12911291 logWarningAt attr.stx m!"Redundant `[expose]` attribute, it is meaningful on public \
12921292 definitions only"
12931293
1294+ -- Switch to private scope if...
12941295 withoutExporting (when :=
1295- headers.all (fun header =>
1296- header.modifiers.isMeta && !header.modifiers.attrs.any (·.name == `expose) ||
1297- header.modifiers.attrs.any (·.name == `no_expose) ||
1298- (!(header.kind == .def && sc.attrs.any (· matches `(attrInstance| expose))) &&
1299- !header.modifiers.attrs.any (·.name == `expose) &&
1300- !header.kind matches .abbrev | .instance))) do
1296+ (← headers.allM (fun header => do
1297+ -- ... there is a `@[no_expose]` attribute
1298+ if header.modifiers.attrs.any (·.name == `no_expose) then
1299+ return true
1300+ -- ... or NONE of the following:
1301+ -- ... this is a non-`meta` `def` inside a `@[expose] section`
1302+ if header.kind == .def && !header.modifiers.isMeta && sc.attrs.any (· matches `(attrInstance| expose)) then
1303+ return false
1304+ -- ... there is an `@[expose]` attribute directly on the def (of any kind or phase)
1305+ if header.modifiers.attrs.any (·.name == `expose) then
1306+ return false
1307+ -- ... this is an `abbrev`
1308+ if header.kind == .abbrev then
1309+ return false
1310+ -- ... this is a data instance
1311+ if header.kind == .instance then
1312+ if !(← isProp header.type) then
1313+ return false
1314+ return true ))) do
13011315 let headers := headers.map fun header =>
13021316 { header with modifiers.attrs := header.modifiers.attrs.filter (!·.name ∈ [`expose, `no_expose]) }
13031317 let values ← try
0 commit comments