If an extension isn't imported either directly or via a transitive
(`@_exported`) import, its members should not be visible to name
lookup. Implement this behavior behind the experimental flag
ExtensionImportVisibility.
[transferring] Implement transferring result and clean up transferring param support by making transferring a bit on param instead of a ParamSpecifier.
This addresses a source compatibility issue with the introduction of
typed throws into the standard library.
Fixes https://github.com/apple/swift/issues/70970 / rdar://121149479.
Instead it is a bit on ParamDecl and SILParameterInfo. I preserve the consuming
behavior by making it so that the type checker changes the ParamSpecifier to
ImplicitlyCopyableConsuming if we have a default param specifier and
transferring is set. NOTE: The user can never write ImplicitlyCopyableConsuming.
NOTE: I had to expand the amount of flags that can be stored in ParamDecl so I
stole bits from TypeRepr and added some logic for packing option bits into
TyRepr and DefaultValue.
rdar://121324715
Previously, if a request R evaluated itself N times, we would emit N
"circular reference" diagnostics. These add no value, so instead let's
cache the user-provided default value on the first circular evaluation.
This changes things slightly so that instead of returning an
llvm::Expected<Request::OutputType>, various evaluator methods take
a callback which can produce the default value.
The existing evaluateOrDefault() interface is unchanged, and a new
evaluateOrFatal() entry point replaces
llvm::cantFail(ctx.evaluator(...)).
Direct callers of the evaluator's operator() were updated to pass in
the callback. The benefit of the callback over evaluateOrDefault() is
that if the default value is expensive to constuct, like a dummy
generic signature, we will only construct it in the case where a
cycle actually happened, otherwise we just delete the callback.
(cherry picked from commit b8fcf1c709efa6cd28e1217bd0efe876f7c0d2b7)
Previously, the lazily-created extensions used for globals imported as members of a type used the lazy module loader, but `ClangImporter::Implementation::loadNamedMembers()` didn’t actually work for them. Other parts of the compiler instead contrived to avoid loading these members by name by forcing all members to load before any selective loading might occur.
This commit modifies that code path to accommodate extensions with no matching clang node, which is how these are represented. With this change, other parts of the compiler can unconditionally use the `LazyMemberLoader` whenever it is present.
There may be performance improvements from this change, but I don’t expect any functional changes.
There are two pieces of code that can add an extension’s members to a type’s lookup table: `NominalTypeDecl::prepareLookupTable()`, which initializes the lookup table before its first use, and `NominalTypeDecl::addedExtension()`, which only updates a lookup table that has already been initialized. The two functions ought to do the same things, but it’s difficult to predict which one will be exercised by a given test, and in practice our current unit tests only seem to use `NominalTypeDecl::prepareLookupTable()` in certain important situations.
Factor the common code into a shared helper method, `MemberLookupTable::addExtension()`, to increase our confidence that both code paths will work correctly even if only one is hit by our unit tests.
Fixes rdar://121479725.
The prior Least Common Ancestor (LCA) implementation in ASTScope, which
is used to search child scopes to find a particular location, assumed
that the source range it was given was contained within a single
buffer and was specific to the child-scope search task. Generalize
this to a more fundamental "is before" operation on source locations
that respects macro expansions, simplifying the code in the process.