AST/SILGen: Requestify var initializer expression typechecking.

Allow initializer expressions to be emitted during SILGen when
`-experimental-lazy-typecheck` is specified by introducing a new request that
fully typechecks the init expressions of pattern binding declarations
on-demand.

There are still a few rough edges, like missing support for wrapped properties
and incomplete handling of subsumed initializers. Fixing these issues is not an
immediate priority because in the short term `-experimental-lazy-typecheck`
will always be accompanied by `-enable-library-evolution` and
`-experimental-skip-non-exportable-decls`. This means that only the
initializers of properties on `@frozen` types will need to be emitted and
property wrappers are not yet fully supported on properties belonging to
`@frozen` types.

Resolves rdar://117448868
This commit is contained in:
Allan Shortlidge
2023-11-13 21:39:08 -08:00
parent 89bda715ce
commit 111eea7f5d
13 changed files with 189 additions and 22 deletions

View File

@@ -68,10 +68,11 @@ protected:
// clang-format off
union { uint64_t OpaqueBits;
SWIFT_INLINE_BITFIELD_BASE(Pattern, bitmax(NumPatternKindBits,8)+1+1,
SWIFT_INLINE_BITFIELD_BASE(Pattern, bitmax(NumPatternKindBits,8)+1+1+1,
Kind : bitmax(NumPatternKindBits,8),
isImplicit : 1,
hasInterfaceType : 1
hasInterfaceType : 1,
executableInitChecked : 1
);
SWIFT_INLINE_BITFIELD_FULL(TuplePattern, Pattern, 32,
@@ -104,6 +105,7 @@ protected:
Bits.Pattern.Kind = unsigned(kind);
Bits.Pattern.isImplicit = false;
Bits.Pattern.hasInterfaceType = false;
Bits.Pattern.executableInitChecked = false;
}
private:
@@ -136,6 +138,11 @@ public:
bool isImplicit() const { return Bits.Pattern.isImplicit; }
void setImplicit() { Bits.Pattern.isImplicit = true; }
bool executableInitChecked() const {
return Bits.Pattern.executableInitChecked;
}
void setExecutableInitChecked() { Bits.Pattern.executableInitChecked = true; }
/// Find the smallest subpattern which obeys the property that matching it is
/// equivalent to matching this pattern.
///