Repository navigation
Commit 623d80d
authored
Import: Don't walk non-F# assemblies when labelling trait constraint sources (#20090)
* Don't walk non-F# assemblies when labelling trait constraint sources
`addConstraintSources` (added in #16304, so that a failed member constraint
names the member it came from) is applied to every imported assembly, and
recurses through `e.ModuleOrNamespaceType` for every module and namespace
entity it finds.
For an assembly imported from IL there is nothing to find: the walk only
reads `AllValsAndMembers`, and `ImportILTypeDefs` gives every namespace and
type entity an empty val list; only an F# trait constraint produces a
`TyparConstraint.MayResolveMember` to label in the first place. Meanwhile the
recursion forces each namespace entity's `ModuleOrNamespaceType`, which
imports that namespace - so referencing an assembly ends up importing every
namespace in it, and reading every type definition, whether or not the code
touches it.
Skip the CCUs that aren't F#. FSharp.Core and F# references are still walked,
so the error messages are unchanged.
Measured with FSharpChecker.ParseAndCheckProject, keeping the results alive so
the imported assembly structures stay on the heap (averages of 3 runs, one per
process): a 486-reference F# project retains 1319.2 -> 952.1 MB (-27.8%), and
a 168-reference console project 77.7 -> 69.8 MB (-10.2%). Checking
FSharp.Compiler.Service itself (124 references, 397 sources) goes 2301.7 ->
2298.0 MB, i.e. within the noise at that size - what the imports cost there is
dwarfed by the trees of the project's own code.1 parent 9f19d64 commit 623d80d
2 files changed
Lines changed: 7 additions & 0 deletions
File tree
- docs/release-notes/.FSharp.Compiler.Service
- src/Compiler/Driver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2341 | 2341 | | |
2342 | 2342 | | |
2343 | 2343 | | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
2344 | 2350 | | |
2345 | 2351 | | |
2346 | 2352 | | |
| |||
0 commit comments