@@ -157,8 +157,9 @@ class alignas(8) Expr {
157157 HasTrailingClosure : 1
158158 );
159159
160- SWIFT_INLINE_BITFIELD (NumberLiteralExpr, LiteralExpr, 1 ,
161- IsNegative : 1
160+ SWIFT_INLINE_BITFIELD (NumberLiteralExpr, LiteralExpr, 1 +1 ,
161+ IsNegative : 1 ,
162+ IsExplicitConversion : 1
162163 );
163164
164165 SWIFT_INLINE_BITFIELD (StringLiteralExpr, LiteralExpr, 3 +1 +1 ,
@@ -744,7 +745,9 @@ class NumberLiteralExpr : public LiteralExpr {
744745 // / The value of the literal as an ASTContext-owned string. Underscores must
745746 // / be stripped.
746747 StringRef Val; // Use StringRef instead of APInt or APFloat, which leak.
747-
748+ ConcreteDeclRef BuiltinInitializer;
749+ ConcreteDeclRef Initializer;
750+
748751protected:
749752 SourceLoc MinusLoc;
750753 SourceLoc DigitsLoc;
@@ -755,6 +758,7 @@ class NumberLiteralExpr : public LiteralExpr {
755758 : LiteralExpr(Kind, Implicit), Val(Val), DigitsLoc(DigitsLoc)
756759 {
757760 Bits.NumberLiteralExpr .IsNegative = false ;
761+ Bits.NumberLiteralExpr .IsExplicitConversion = false ;
758762 }
759763
760764 bool isNegative () const { return Bits.NumberLiteralExpr .IsNegative ; }
@@ -763,6 +767,13 @@ class NumberLiteralExpr : public LiteralExpr {
763767 Bits.NumberLiteralExpr .IsNegative = true ;
764768 }
765769
770+ bool isExplicitConversion () const {
771+ return Bits.NumberLiteralExpr .IsExplicitConversion ;
772+ }
773+ void setExplicitConversion (bool isExplicitConversion = true ) {
774+ Bits.NumberLiteralExpr .IsExplicitConversion = isExplicitConversion;
775+ }
776+
766777 StringRef getDigitsText () const { return Val; }
767778
768779 SourceRange getSourceRange () const {
@@ -780,6 +791,32 @@ class NumberLiteralExpr : public LiteralExpr {
780791 return DigitsLoc;
781792 }
782793
794+ // / Retrieve the builtin initializer that will be used to construct the
795+ // / boolean literal.
796+ // /
797+ // / Any type-checked boolean literal will have a builtin initializer, which is
798+ // / called first to form a concrete Swift type.
799+ ConcreteDeclRef getBuiltinInitializer () const { return BuiltinInitializer; }
800+
801+ // / Set the builtin initializer that will be used to construct the boolean
802+ // / literal.
803+ void setBuiltinInitializer (ConcreteDeclRef builtinInitializer) {
804+ BuiltinInitializer = builtinInitializer;
805+ }
806+
807+ // / Retrieve the initializer that will be used to construct the boolean
808+ // / literal from the result of the initializer.
809+ // /
810+ // / Only boolean literals that have no builtin literal conformance will have
811+ // / this initializer, which will be called on the result of the builtin
812+ // / initializer.
813+ ConcreteDeclRef getInitializer () const { return Initializer; }
814+
815+ // / Set the initializer that will be used to construct the boolean literal.
816+ void setInitializer (ConcreteDeclRef initializer) {
817+ Initializer = initializer;
818+ }
819+
783820 static bool classof (const Expr *E) {
784821 return E->getKind () >= ExprKind::First_NumberLiteralExpr
785822 && E->getKind () <= ExprKind::Last_NumberLiteralExpr;
@@ -1125,37 +1162,32 @@ class MagicIdentifierLiteralExpr : public LiteralExpr {
11251162 = static_cast <unsigned >(encoding);
11261163 }
11271164
1128- // / Retrieve the builtin initializer that will be used to construct the string
1165+ // / Retrieve the builtin initializer that will be used to construct the
11291166 // / literal.
11301167 // /
1131- // / Any type-checked string literal will have a builtin initializer, which is
1168+ // / Any type-checked literal will have a builtin initializer, which is
11321169 // / called first to form a concrete Swift type.
11331170 ConcreteDeclRef getBuiltinInitializer () const {
1134- assert (isString () && " Magic identifier literal is not a string" );
11351171 return BuiltinInitializer;
11361172 }
11371173
1138- // / Set the builtin initializer that will be used to construct the string
1139- // / literal.
1174+ // / Set the builtin initializer that will be used to construct the literal.
11401175 void setBuiltinInitializer (ConcreteDeclRef builtinInitializer) {
1141- assert (isString () && " Magic identifier literal is not a string" );
11421176 BuiltinInitializer = builtinInitializer;
11431177 }
11441178
1145- // / Retrieve the initializer that will be used to construct the string
1146- // / literal from the result of the initializer.
1179+ // / Retrieve the initializer that will be used to construct the literal from
1180+ // / the result of the initializer.
11471181 // /
1148- // / Only string literals that have no builtin literal conformance will have
1182+ // / Only literals that have no builtin literal conformance will have
11491183 // / this initializer, which will be called on the result of the builtin
11501184 // / initializer.
11511185 ConcreteDeclRef getInitializer () const {
1152- assert (isString () && " Magic identifier literal is not a string" );
11531186 return Initializer;
11541187 }
11551188
1156- // / Set the initializer that will be used to construct the string literal.
1189+ // / Set the initializer that will be used to construct the literal.
11571190 void setInitializer (ConcreteDeclRef initializer) {
1158- assert (isString () && " Magic identifier literal is not a string" );
11591191 Initializer = initializer;
11601192 }
11611193
0 commit comments