mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #14299 from rudkx/iuo-remove-the-type
IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>
This commit is contained in:
@@ -303,6 +303,10 @@ protected:
|
||||
NumVariadicArgs : 16
|
||||
);
|
||||
|
||||
SWIFT_INLINE_BITFIELD(ForceValueExpr, Expr, 1,
|
||||
ForcedIUO : 1
|
||||
);
|
||||
|
||||
SWIFT_INLINE_BITFIELD(InOutToPointerExpr, ImplicitConversionExpr, 1,
|
||||
IsNonAccessing : 1
|
||||
);
|
||||
@@ -2507,9 +2511,11 @@ class ForceValueExpr : public Expr {
|
||||
SourceLoc ExclaimLoc;
|
||||
|
||||
public:
|
||||
ForceValueExpr(Expr *subExpr, SourceLoc exclaimLoc)
|
||||
ForceValueExpr(Expr *subExpr, SourceLoc exclaimLoc, bool forcedIUO = false)
|
||||
: Expr(ExprKind::ForceValue, /*Implicit=*/exclaimLoc.isInvalid(), Type()),
|
||||
SubExpr(subExpr), ExclaimLoc(exclaimLoc) {}
|
||||
SubExpr(subExpr), ExclaimLoc(exclaimLoc) {
|
||||
Bits.ForceValueExpr.ForcedIUO = forcedIUO;
|
||||
}
|
||||
|
||||
SourceRange getSourceRange() const {
|
||||
if (ExclaimLoc.isInvalid())
|
||||
@@ -2534,6 +2540,10 @@ public:
|
||||
Expr *getSubExpr() const { return SubExpr; }
|
||||
void setSubExpr(Expr *expr) { SubExpr = expr; }
|
||||
|
||||
bool isForceOfImplicitlyUnwrappedOptional() const {
|
||||
return Bits.ForceValueExpr.ForcedIUO;
|
||||
}
|
||||
|
||||
static bool classof(const Expr *E) {
|
||||
return E->getKind() == ExprKind::ForceValue;
|
||||
}
|
||||
|
||||
@@ -4114,7 +4114,9 @@ class ImplicitlyUnwrappedOptionalType : public UnarySyntaxSugarType {
|
||||
ImplicitlyUnwrappedOptionalType(const ASTContext &ctx, Type base,
|
||||
RecursiveTypeProperties properties)
|
||||
: UnarySyntaxSugarType(TypeKind::ImplicitlyUnwrappedOptional, ctx, base,
|
||||
properties) {}
|
||||
properties) {
|
||||
//llvm_unreachable("ImplicitlyUnwrappedOptionalType::ImplicitlyUnwrappedOptionalType");
|
||||
}
|
||||
|
||||
public:
|
||||
/// Return a uniqued optional type with the specified base type.
|
||||
|
||||
Reference in New Issue
Block a user