Skip to content

Commit 666a42f

Browse files
Chris LattnerChris Lattner
authored andcommitted
Remove the ability to map back from a ParamDecl to its enclosing Pattern. This
is used by precisely one thing (producing a warning in a scenario that is obsolete because we deprecated the entire thing), so the complexity isn't worth it anymore.
1 parent 49cd50d commit 666a42f

File tree

7 files changed

+3
-31
lines changed

7 files changed

+3
-31
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4007,7 +4007,7 @@ class AbstractStorageDecl : public ValueDecl {
40074007
/// VarDecl - 'var' and 'let' declarations.
40084008
class VarDecl : public AbstractStorageDecl {
40094009
protected:
4010-
llvm::PointerUnion3<PatternBindingDecl*, Pattern*, Stmt*> ParentPattern;
4010+
llvm::PointerUnion<PatternBindingDecl*, Stmt*> ParentPattern;
40114011

40124012
VarDecl(DeclKind Kind, bool IsStatic, bool IsLet, SourceLoc NameLoc,
40134013
Identifier Name, Type Ty, DeclContext *DC)
@@ -4186,13 +4186,6 @@ class ParamDecl : public VarDecl {
41864186
return SourceRange(ArgumentNameLoc, getNameLoc());
41874187
}
41884188

4189-
Pattern *getParamParentPattern() const {
4190-
return ParentPattern.dyn_cast<Pattern *>();
4191-
}
4192-
void setParamParentPattern(Pattern *Pat) {
4193-
ParentPattern = Pat;
4194-
}
4195-
41964189
// Implement isa/cast/dyncast/etc.
41974190
static bool classof(const Decl *D) {
41984191
return D->getKind() == DeclKind::Param;

lib/AST/Builtins.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ getBuiltinFunction(Identifier Id, ArrayRef<Type> argTypes, Type ResType,
157157
Pattern *Pat = new (Context) NamedPattern(PD, /*implicit=*/true);
158158
Pat = new (Context) TypedPattern(Pat, TypeLoc::withoutLoc(argType),
159159
/*implicit=*/true);
160-
PD->setParamParentPattern(Pat);
161-
162160
ParamPatternElts.push_back(TuplePatternElt(Pat));
163161
}
164162

@@ -228,7 +226,6 @@ getBuiltinGenericFunction(Identifier Id,
228226
Pattern *Pat = new (Context) NamedPattern(PD, /*implicit=*/true);
229227
Pat = new (Context) TypedPattern(Pat,
230228
TypeLoc::withoutLoc(ArgTupleElt.getType()), /*implicit=*/true);
231-
PD->setParamParentPattern(Pat);
232229

233230
ParamPatternElts.push_back(TuplePatternElt(Pat));
234231
}

lib/AST/Decl.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3154,11 +3154,7 @@ SourceRange VarDecl::getSourceRange() const {
31543154
}
31553155

31563156
SourceRange VarDecl::getTypeSourceRangeForDiagnostics() const {
3157-
Pattern *Pat = nullptr;
3158-
if (ParentPattern.is<Pattern*>())
3159-
Pat = ParentPattern.dyn_cast<Pattern *>();
3160-
else
3161-
Pat = getParentPattern();
3157+
Pattern *Pat = getParentPattern();
31623158

31633159
if (!Pat || Pat->isImplicit())
31643160
return getSourceRange();

lib/AST/Pattern.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ static Pattern *buildImplicitLetParameter(ASTContext &ctx, Identifier name,
310310
P->setType(tyLoc.getType());
311311
P = new (ctx) TypedPattern(P, tyLoc, /*Implicit=*/true);
312312
P->setType(tyLoc.getType());
313-
paramDecl->setParamParentPattern(P);
314313
return P;
315314
}
316315

lib/Parse/ParsePattern.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,6 @@ mapParsedParameters(Parser &parser,
392392
bool isLet = specifierKind == Parser::ParsedParameter::Let;
393393
param = new (ctx) VarPattern(letVarInOutLoc, isLet, param);
394394
}
395-
396-
if (var)
397-
var->setParamParentPattern(param);
398395
return param;
399396
};
400397

lib/Sema/MiscDiagnostics.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,17 +1492,7 @@ VarDeclUsageChecker::~VarDeclUsageChecker() {
14921492
}
14931493

14941494
// If this is a parameter explicitly marked 'var', remove it.
1495-
if (auto *param = dyn_cast<ParamDecl>(var))
1496-
if (auto *pattern = param->getParamParentPattern())
1497-
if (auto *vp = dyn_cast<VarPattern>(pattern)) {
1498-
TC.diagnose(var->getLoc(), diag::variable_never_mutated,
1499-
var->getName(), /*param*/1)
1500-
.fixItRemove(vp->getLoc());
1501-
continue;
1502-
}
1503-
15041495
unsigned varKind = isa<ParamDecl>(var);
1505-
// FIXME: fixit when we can find a pattern binding.
15061496
if (FixItLoc.isInvalid())
15071497
TC.diagnose(var->getLoc(), diag::variable_never_mutated,
15081498
var->getName(), varKind);

test/FixCode/fixits-apply.swift.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func foo() -> Int {
3838
}
3939
}
4040

41-
func goo(e : ErrorType) {}
41+
func goo(var e : ErrorType) {}
4242

4343
struct Test1 : OptionSetType {
4444
init(rawValue: Int) {}

0 commit comments

Comments
 (0)