Skip to content

[AST] Remove 'is super' bit on ApplyExpr #37062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4444,16 +4444,16 @@ class ApplyExpr : public Expr {
/// The function being called.
Expr *Fn;

/// The argument being passed to it, and whether it's a 'super' argument.
llvm::PointerIntPair<Expr *, 1, bool> ArgAndIsSuper;
/// The argument being passed to it.
Expr *Arg;

/// Returns true if \c e could be used as the call's argument. For most \c ApplyExpr
/// subclasses, this means it is a \c ParenExpr or \c TupleExpr.
bool validateArg(Expr *e) const;

protected:
ApplyExpr(ExprKind Kind, Expr *Fn, Expr *Arg, bool Implicit, Type Ty = Type())
: Expr(Kind, Implicit, Ty), Fn(Fn), ArgAndIsSuper(Arg, false) {
: Expr(Kind, Implicit, Ty), Fn(Fn), Arg(Arg) {
assert(classof((Expr*)this) && "ApplyExpr::classof out of date");
assert(validateArg(Arg) && "Arg is not a permitted expr kind");
Bits.ApplyExpr.ThrowsIsSet = false;
Expand All @@ -4466,15 +4466,10 @@ class ApplyExpr : public Expr {
void setFn(Expr *e) { Fn = e; }
Expr *getSemanticFn() const { return Fn->getSemanticsProvidingExpr(); }

Expr *getArg() const { return ArgAndIsSuper.getPointer(); }
Expr *getArg() const { return Arg; }
void setArg(Expr *e) {
assert(validateArg(e) && "Arg is not a permitted expr kind");
ArgAndIsSuper = {e, ArgAndIsSuper.getInt()};
}

bool isSuper() const { return ArgAndIsSuper.getInt(); }
void setIsSuper(bool super) {
ArgAndIsSuper = {ArgAndIsSuper.getPointer(), super};
Arg = e;
}

/// Has the type-checker set the 'throws' bit yet?
Expand Down
2 changes: 0 additions & 2 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2621,8 +2621,6 @@ class PrintExpr : public ExprVisitor<PrintExpr> {

void printApplyExpr(ApplyExpr *E, const char *NodeName) {
printCommon(E, NodeName);
if (E->isSuper())
PrintWithColorRAII(OS, ExprModifierColor) << " super";
if (E->isThrowsSet()) {
PrintWithColorRAII(OS, ExprModifierColor)
<< (E->throws() ? " throws" : " nothrow");
Expand Down
6 changes: 0 additions & 6 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1821,12 +1821,6 @@ class Verifier : public ASTWalker {
}
}

if (E->isSuper() != E->getArg()->isSuperExpr()) {
Out << "Function application's isSuper() bit mismatch.\n";
E->dump(Out);
Out << "\n";
abort();
}
verifyCheckedBase(E);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/SILGen/SILGenApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
if (isMethodSelfApply(e->getFn())) {
selfApply = cast<ApplyExpr>(e->getFn());

if (selfApply->isSuper()) {
if (selfApply->getArg()->isSuperExpr()) {
applySuper(selfApply);
return;
}
Expand Down
7 changes: 0 additions & 7 deletions lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,9 +1179,6 @@ namespace {
selfCall->setType(refTy->getResult());
cs.cacheType(selfCall);

if (selfParamRef->isSuperExpr())
selfCall->setIsSuper(true);

auto &appliedWrappers = solution.appliedPropertyWrappers[locator.getAnchor()];
if (!appliedWrappers.empty()) {
auto fnDecl = AnyFunctionRef(dyn_cast<AbstractFunctionDecl>(member));
Expand Down Expand Up @@ -7749,9 +7746,6 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,

apply->setFn(fn);

// Check whether the argument is 'super'.
bool isSuper = apply->getArg()->isSuperExpr();

// For function application, convert the argument to the input type of
// the function.
SmallVector<Identifier, 2> argLabelsScratch;
Expand All @@ -7768,7 +7762,6 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,

apply->setArg(arg);
cs.setType(apply, fnType->getResult());
apply->setIsSuper(isSuper);

solution.setExprTypes(apply);
Expr *result = TypeChecker::substituteInputSugarTypeForResult(apply);
Expand Down
1 change: 0 additions & 1 deletion lib/Sema/CodeSynthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ synthesizeDesignatedInitOverride(AbstractFunctionDecl *fn, void *context) {
type = funcTy->getResult();
auto *superclassCtorRefExpr =
new (ctx) DotSyntaxCallExpr(ctorRefExpr, SourceLoc(), superRef, type);
superclassCtorRefExpr->setIsSuper(true);
superclassCtorRefExpr->setThrows(false);

auto *bodyParams = ctor->getParameters();
Expand Down