Skip to content

Transparent Compiler/Completion: suggest symbols from files the checked file doesn't depend on - #20999

Draft
DedSec256 wants to merge 1 commit into
dotnet:mainfrom
DedSec256:ber.a/fixCompletionTransparentCompiler
Draft

DedSec256 wants to merge 1 commit into
dotnet:mainfrom
DedSec256:ber.a/fixCompletionTransparentCompiler

Conversation

@DedSec256

@DedSec256 DedSec256 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #21000

Problem

Completion on the Transparent Compiler's check results doesn't offer symbols from previous files the checked file doesn't depend on. The Background Compiler offers them.

It's made more confusing by the fact that every file before the checked one is already type checked (#20850). Even so, what gets into the file's NameResolutionEnv still follows the dependency graph: the file is checked against the state of its dependencies only.

Relation to #20889

#20889 by @nojaf adds the checkDependenciesOnly flag to ParseAndCheckFileInProject and fixes the cost of analysis: with checkDependenciesOnly = true, only the dependencies are checked. With checkDependenciesOnly = false, abovementioned PR checks every file before the checked one, but the state the file is checked against is still built from its dependencies only.

This PR fixes the other side: it makes the file's node depend on all the previous nodes, so the symbols of files the checked file doesn't depend on get into its name resolution environment. Combined with #20889, checkDependenciesOnly = false can then be used to get full results before completion.

This PR doesn't add the flag, so for now every check of a file is a full one. Once it's combined with #20889, the graph isn't extended for checkDependenciesOnly = true. That place is marked with a TODO.

Changes

  • When the checked file doesn't depend on all the files before it, its node in the graph is made to depend on all of them, so it's checked against the same state as in the Background Compiler.
  • An extra flag in the version of the TcIntermediate key tells the full result of a file from the dependencies-only one. A new version weakens the other versions of the same file only.
  • If the file already depends on all the other files, the graph isn't changed and nothing extra is computed.
  • The results of the other files aren't checked again: only the checked file gets a full check.
  • A file checked against its dependencies only first looks for its full result and takes it if there is one. Its dependents only take its signature, which doesn't depend on what it's checked against, and a repeated dependencies-only check of the file itself gets more symbols, not wrong ones. So a dependencies-only check after a full one neither checks the file again nor weakens its full result.

Open questions

Caching of ParseAndCheckFileInProject results

When the flag is combined with this PR, it has to go into the version of the ParseAndCheckFileInProject key too, or full and dependencies-only results would be mixed under one version. Then, because of how the LRU cache works, a following request for the same file with checkDependenciesOnly = true, with no real changes, stores its result under another version of the same key and weakens the full one.

Two strategies:

  1. Leave it to the caller to pass the flag it needs on each request (this can be done as some kind of sessions on top, for example).
  2. For each request, first look for the full result, and only then for the one under the requested version, since the full result can serve a dependencies-only request. TcIntermediate already does this.

Tests

  • Unreferenced symbol from a previous file in CompletionTests.Namespaces.fs: completion offers a module from a previous file the checked file doesn't reference, with both compilers.
  • ...

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ Release notes checked


✅ Found changes and release notes in following paths:

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.200.md

@DedSec256
DedSec256 force-pushed the ber.a/fixCompletionTransparentCompiler branch from b8943a4 to 0049c28 Compare November 19, 2026 01:26

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Transparent Compiler: completion misses symbols from previous files the checked file doesn't depend on

1 participant