@@ -1917,7 +1917,7 @@ class TypeAliasType final
19171917// / Provide parameter type relevant flags, i.e. variadic, autoclosure, and
19181918// / escaping.
19191919class ParameterTypeFlags {
1920- enum ParameterFlags : uint8_t {
1920+ enum ParameterFlags : uint16_t {
19211921 None = 0 ,
19221922 Variadic = 1 << 0 ,
19231923 AutoClosure = 1 << 1 ,
@@ -1926,32 +1926,36 @@ class ParameterTypeFlags {
19261926 Ownership = 7 << OwnershipShift,
19271927 NoDerivative = 1 << 6 ,
19281928 Isolated = 1 << 7 ,
1929- NumBits = 8
1929+ CompileTimeConst = 1 << 8 ,
1930+ NumBits = 9
19301931 };
19311932 OptionSet<ParameterFlags> value;
19321933 static_assert (NumBits <= 8 *sizeof (OptionSet<ParameterFlags>), " overflowed" );
19331934
1934- ParameterTypeFlags (OptionSet<ParameterFlags, uint8_t > val) : value(val) {}
1935+ ParameterTypeFlags (OptionSet<ParameterFlags, uint16_t > val) : value(val) {}
19351936
19361937public:
19371938 ParameterTypeFlags () = default ;
1938- static ParameterTypeFlags fromRaw (uint8_t raw) {
1939+ static ParameterTypeFlags fromRaw (uint16_t raw) {
19391940 return ParameterTypeFlags (OptionSet<ParameterFlags>(raw));
19401941 }
19411942
19421943 ParameterTypeFlags (bool variadic, bool autoclosure, bool nonEphemeral,
1943- ValueOwnership ownership, bool isolated, bool noDerivative)
1944+ ValueOwnership ownership, bool isolated, bool noDerivative,
1945+ bool compileTimeConst)
19441946 : value((variadic ? Variadic : 0 ) | (autoclosure ? AutoClosure : 0 ) |
19451947 (nonEphemeral ? NonEphemeral : 0 ) |
19461948 uint8_t (ownership) << OwnershipShift |
19471949 (isolated ? Isolated : 0 ) |
1948- (noDerivative ? NoDerivative : 0 )) {}
1950+ (noDerivative ? NoDerivative : 0 ) |
1951+ (compileTimeConst ? CompileTimeConst : 0 )){}
19491952
19501953 // / Create one from what's present in the parameter type
19511954 inline static ParameterTypeFlags
19521955 fromParameterType (Type paramTy, bool isVariadic, bool isAutoClosure,
19531956 bool isNonEphemeral, ValueOwnership ownership,
1954- bool isolated, bool isNoDerivative);
1957+ bool isolated, bool isNoDerivative,
1958+ bool compileTimeConst);
19551959
19561960 bool isNone () const { return !value; }
19571961 bool isVariadic () const { return value.contains (Variadic); }
@@ -1961,6 +1965,7 @@ class ParameterTypeFlags {
19611965 bool isShared () const { return getValueOwnership () == ValueOwnership::Shared;}
19621966 bool isOwned () const { return getValueOwnership () == ValueOwnership::Owned; }
19631967 bool isIsolated () const { return value.contains (Isolated); }
1968+ bool isCompileTimeConst () const { return value.contains (CompileTimeConst); }
19641969 bool isNoDerivative () const { return value.contains (NoDerivative); }
19651970
19661971 ValueOwnership getValueOwnership () const {
@@ -1976,6 +1981,11 @@ class ParameterTypeFlags {
19761981 return withValueOwnership (isInout ? ValueOwnership::InOut
19771982 : ValueOwnership::Default);
19781983 }
1984+
1985+ ParameterTypeFlags withCompileTimeConst (bool isConst) const {
1986+ return ParameterTypeFlags (isConst ? value | ParameterTypeFlags::CompileTimeConst
1987+ : value | ParameterTypeFlags::CompileTimeConst);
1988+ }
19791989
19801990 ParameterTypeFlags withShared (bool isShared) const {
19811991 return withValueOwnership (isShared ? ValueOwnership::Shared
@@ -2083,7 +2093,8 @@ class YieldTypeFlags {
20832093 return ParameterTypeFlags (/* variadic*/ false ,
20842094 /* autoclosure*/ false ,
20852095 /* nonEphemeral*/ false , getValueOwnership (),
2086- /* isolated*/ false , /* noDerivative*/ false );
2096+ /* isolated*/ false , /* noDerivative*/ false ,
2097+ /* compileTimeConst*/ false );
20872098 }
20882099
20892100 bool operator ==(const YieldTypeFlags &other) const {
@@ -2882,6 +2893,9 @@ class AnyFunctionType : public TypeBase {
28822893 // / Whether the parameter is 'isolated'.
28832894 bool isIsolated () const { return Flags.isIsolated (); }
28842895
2896+ // / Whether the parameter is 'isCompileTimeConst'.
2897+ bool isCompileTimeConst () const { return Flags.isCompileTimeConst (); }
2898+
28852899 // / Whether the parameter is marked '@noDerivative'.
28862900 bool isNoDerivative () const { return Flags.isNoDerivative (); }
28872901
@@ -6325,7 +6339,8 @@ inline TupleTypeElt TupleTypeElt::getWithType(Type T) const {
63256339// / Create one from what's present in the parameter decl and type
63266340inline ParameterTypeFlags ParameterTypeFlags::fromParameterType (
63276341 Type paramTy, bool isVariadic, bool isAutoClosure, bool isNonEphemeral,
6328- ValueOwnership ownership, bool isolated, bool isNoDerivative) {
6342+ ValueOwnership ownership, bool isolated, bool isNoDerivative,
6343+ bool compileTimeConst) {
63296344 // FIXME(Remove InOut): The last caller that needs this is argument
63306345 // decomposition. Start by enabling the assertion there and fixing up those
63316346 // callers, then remove this, then remove
@@ -6336,7 +6351,7 @@ inline ParameterTypeFlags ParameterTypeFlags::fromParameterType(
63366351 ownership = ValueOwnership::InOut;
63376352 }
63386353 return {isVariadic, isAutoClosure, isNonEphemeral, ownership, isolated,
6339- isNoDerivative};
6354+ isNoDerivative, compileTimeConst };
63406355}
63416356
63426357inline const Type *BoundGenericType::getTrailingObjectsPointer () const {
0 commit comments