Skip to content

Commit

Permalink
Fixed type visibility when parent is namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ncave committed Apr 5, 2024
1 parent 836ee7a commit 742efe3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/src/Fable.Cli/bin/Debug/net6.0/fable.dll",
"args": ["--outDir", "${workspaceRoot}/../fable-test", "--fableLib", "../../Fable/build/fable-library-rust", "--exclude", "Fable.Core", "--lang", "Rust", "--noCache"],
"args": ["--outDir", "${workspaceRoot}/../fable-test", "--fableLib", "../../Fable/build/fable-library-rust", "--exclude", "Fable.Core", "--lang", "Rust", "--noCache", "--noParallelTypeCheck"],
"cwd": "${workspaceRoot}/../fable-test",
"stopAtEntry": false,
"console": "internalConsole"
Expand Down
20 changes: 11 additions & 9 deletions src/Fable.Transforms/FSharp2Fable.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -826,24 +826,26 @@ module Helpers =
| FSharpInlineAnnotation.AlwaysInline
| FSharpInlineAnnotation.AggressiveInline -> true

let hasOwnSignatureFile (ent: FSharpEntity) =
not ent.IsNamespace

This comment has been minimized.

Copy link
@nojaf

nojaf Apr 23, 2024

Member

Hi @ncave, I'm a little confused by this change.
Why are things different with a namespace?

This comment has been minimized.

Copy link
@ncave

ncave Apr 23, 2024

Author Collaborator

@nojaf For some reason F# compiler re-assigns the signature location for namespaces to be the last file the namespace was declared in. So, in some cases that hides legitimately visible module members (declared in a namespace) that have signature location pointing to another file.

This comment has been minimized.

Copy link
@nojaf

nojaf Apr 23, 2024

Member

Oh, how wonderful 😌. This does make some sense I guess when multiple files contribute to the namespace. Thanks for your input, always appreciated.

&& (
match ent.SignatureLocation with
| None -> false
| Some m -> m.FileName.EndsWith(".fsi", StringComparison.Ordinal)
)

let parentHasSignatureFile (declaringEntity: FSharpEntity option) =
declaringEntity
|> Option.bind (fun p -> p.SignatureLocation)
|> Option.map (fun m -> m.FileName.EndsWith(".fsi", StringComparison.Ordinal))
|> Option.map (fun ent -> hasOwnSignatureFile ent)
|> Option.defaultValue false

let topLevelBindingHiddenBySignatureFile (v: FSharpMemberOrFunctionOrValue) =
v.IsModuleValueOrMember
&& not v.HasSignatureFile
&& parentHasSignatureFile v.DeclaringEntity

let typeIsHiddenBySignatureFile (ent: FSharpEntity) : bool =
let hasOwnSignatureFile =
match ent.SignatureLocation with
| None -> false
| Some m -> m.FileName.EndsWith(".fsi", StringComparison.Ordinal)

not hasOwnSignatureFile && parentHasSignatureFile ent.DeclaringEntity
let typeIsHiddenBySignatureFile (ent: FSharpEntity) =
not (hasOwnSignatureFile ent) && parentHasSignatureFile ent.DeclaringEntity

let isNotPrivate (memb: FSharpMemberOrFunctionOrValue) =
if memb.IsCompilerGenerated then
Expand Down

0 comments on commit 742efe3

Please sign in to comment.