Replace two prominent uses of SubstitutionList, in ConcreteDeclRef and
Witness, with SubstitutionMap. Deal with the myriad places where we
now have substitution maps and need substitution lists (or vice versa)
caused by this change.
Overall, removes ~50 explicit uses of SubstitutionList (of ~400).
The condition we want to test for emitting a downcast is isRequired(),
not isInheritable(). The latter is only true for convenience
initializers.
The other fix is that we actually have to emit a class_method
dispatch here to support class hierarchies conforming to literal
protocols.
closure lifetimes.
SILGen will now unconditionally emit
%cvt = convert_escape_to_noescape [guaranteed] %op
instructions. The mandatory ClosureLifetimeFixup pass ensures that %op's
lifetime spans %cvt's uses.
The code in DefiniteInitialization that handled a subset of cases is
removed.
If a property or subscript is referenceable from other modules, we need to give it a descriptor so that we can reliably build an equivalent key path in or out of that module.
There are some cases that we should handle but don't yet:
- Global and static properties ought to be key-path-able someday, so we should make descriptors for them, but this might need a new key path component kind.
- Subscripts with indexes that aren't Hashable in the current module ought to get descriptors too, in case we ever support non-hashable key path components, and also because a generic subscript might be substituted with Hashable types by an external user, or an external module might post-hoc extend a type to be Hashable, so we really need to change things so that the client supplies the hashing and equality implementations for the indexes instead of the descriptor.
Factor out the code to lower an individual key path component to be independent of overall KeyPathExpr lowering, so that we can soon reuse the same code paths to build property descriptors for resilient properties. NFC intended.
Since I used ensurePlusOne, this should not have any effect on the compiler
today. This happens quite often once "normal arguments" are at +0 though.
I also changed this code to use SILGenBuilder APIs to ensure that ownership is
forwarded correctly.
Found when updating SILGen tests for +0.
rdar://34222540
Some of the classes in this file were using LLVM style for long classes, i.e.:
```
namespace {
class Foo {
... long class ...
};
} // end anonymous namespace
```
Other places, we were adding a level of indentation, i.e.:
```
namespace {
class Foo {
... long class ...
};
} // end anonymous namespace
```
This PR just standardizes the classes in this file that follow the later style,
to instead follow the former style.
prepareApplyExpr is a static function that changes an expr into a CallEmission
and has no other uses beyond that purpose. This is the definition of a static
factory method. This PR performs that refactor.
NFC.
- Emit a withoutActuallyEscapingClosure partial apply
This is to convert an @noescape closure to an escaping closure.
This needs to be done in preparation of @noescape closure contexts
becoming trivial.
- Insert escaping to noescape conversions
- Fix SILGen for @noescape
- Postpone closure cleanups to outside the argument scope
- Apply postponement recursively for closures passed to subscripts
- Only skip applying escapeness conversions for Swift thick functions
- Fix parameter convention for noescape closures in thunks
Part of:
SR-5441
rdar://36116691
i.e for:
enum Indirect<T> {
indirect cast payload(first: T, second :T)
}
let _ = Indirect<X>
The payload's SIL box type will be:
$<t_0_0> { var (first: t_0_0, second: t_0_0) } <X>
rdar: //36799330
This has three principal advantages:
- It gives some additional type-safety when working
with known accessors.
- It makes it significantly easier to test whether a declaration
is an accessor and encourages the use of a common idiom.
- It saves a small amount of memory in both FuncDecl and its
serialized form.
This expression node is only used when applying the results of
expression type checking. It initially appears above the function
reference that returns an optional that needs to be unwrapped, and
then when dealing with function application we remove this and insert
a node to force-unwrap the result of the function application.
Use the LValue formal evaluation scope to destroy temporary lvalues that aren't
part of the expression's resulting value.
Disable an old hack that destroyed call site arguments after the call.
This is the first step in cleanup up LValue materialization.
Sometimes we need to copy/borrow now.
*NOTE* right now it is basically impossible to test this using a fake stdlib
since I would need to implement Array or String in my local stdlib since this
comes up via ArrayToPointer/friends. If/when we flip the switch though, this is
guaranteed to be tested by stdlib dependent tests that we already have in tree.
rdar://34222540