mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
This commit is contained in:
@@ -4007,7 +4007,7 @@ public:
|
||||
/// VarDecl - 'var' and 'let' declarations.
|
||||
class VarDecl : public AbstractStorageDecl {
|
||||
protected:
|
||||
llvm::PointerUnion3<PatternBindingDecl*, Pattern*, Stmt*> ParentPattern;
|
||||
llvm::PointerUnion<PatternBindingDecl*, Stmt*> ParentPattern;
|
||||
|
||||
VarDecl(DeclKind Kind, bool IsStatic, bool IsLet, SourceLoc NameLoc,
|
||||
Identifier Name, Type Ty, DeclContext *DC)
|
||||
@@ -4186,13 +4186,6 @@ public:
|
||||
return SourceRange(ArgumentNameLoc, getNameLoc());
|
||||
}
|
||||
|
||||
Pattern *getParamParentPattern() const {
|
||||
return ParentPattern.dyn_cast<Pattern *>();
|
||||
}
|
||||
void setParamParentPattern(Pattern *Pat) {
|
||||
ParentPattern = Pat;
|
||||
}
|
||||
|
||||
// Implement isa/cast/dyncast/etc.
|
||||
static bool classof(const Decl *D) {
|
||||
return D->getKind() == DeclKind::Param;
|
||||
|
||||
@@ -157,8 +157,6 @@ getBuiltinFunction(Identifier Id, ArrayRef<Type> argTypes, Type ResType,
|
||||
Pattern *Pat = new (Context) NamedPattern(PD, /*implicit=*/true);
|
||||
Pat = new (Context) TypedPattern(Pat, TypeLoc::withoutLoc(argType),
|
||||
/*implicit=*/true);
|
||||
PD->setParamParentPattern(Pat);
|
||||
|
||||
ParamPatternElts.push_back(TuplePatternElt(Pat));
|
||||
}
|
||||
|
||||
@@ -228,7 +226,6 @@ getBuiltinGenericFunction(Identifier Id,
|
||||
Pattern *Pat = new (Context) NamedPattern(PD, /*implicit=*/true);
|
||||
Pat = new (Context) TypedPattern(Pat,
|
||||
TypeLoc::withoutLoc(ArgTupleElt.getType()), /*implicit=*/true);
|
||||
PD->setParamParentPattern(Pat);
|
||||
|
||||
ParamPatternElts.push_back(TuplePatternElt(Pat));
|
||||
}
|
||||
|
||||
@@ -3154,11 +3154,7 @@ SourceRange VarDecl::getSourceRange() const {
|
||||
}
|
||||
|
||||
SourceRange VarDecl::getTypeSourceRangeForDiagnostics() const {
|
||||
Pattern *Pat = nullptr;
|
||||
if (ParentPattern.is<Pattern*>())
|
||||
Pat = ParentPattern.dyn_cast<Pattern *>();
|
||||
else
|
||||
Pat = getParentPattern();
|
||||
Pattern *Pat = getParentPattern();
|
||||
|
||||
if (!Pat || Pat->isImplicit())
|
||||
return getSourceRange();
|
||||
|
||||
@@ -310,7 +310,6 @@ static Pattern *buildImplicitLetParameter(ASTContext &ctx, Identifier name,
|
||||
P->setType(tyLoc.getType());
|
||||
P = new (ctx) TypedPattern(P, tyLoc, /*Implicit=*/true);
|
||||
P->setType(tyLoc.getType());
|
||||
paramDecl->setParamParentPattern(P);
|
||||
return P;
|
||||
}
|
||||
|
||||
|
||||
@@ -392,9 +392,6 @@ mapParsedParameters(Parser &parser,
|
||||
bool isLet = specifierKind == Parser::ParsedParameter::Let;
|
||||
param = new (ctx) VarPattern(letVarInOutLoc, isLet, param);
|
||||
}
|
||||
|
||||
if (var)
|
||||
var->setParamParentPattern(param);
|
||||
return param;
|
||||
};
|
||||
|
||||
|
||||
@@ -1492,17 +1492,7 @@ VarDeclUsageChecker::~VarDeclUsageChecker() {
|
||||
}
|
||||
|
||||
// If this is a parameter explicitly marked 'var', remove it.
|
||||
if (auto *param = dyn_cast<ParamDecl>(var))
|
||||
if (auto *pattern = param->getParamParentPattern())
|
||||
if (auto *vp = dyn_cast<VarPattern>(pattern)) {
|
||||
TC.diagnose(var->getLoc(), diag::variable_never_mutated,
|
||||
var->getName(), /*param*/1)
|
||||
.fixItRemove(vp->getLoc());
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned varKind = isa<ParamDecl>(var);
|
||||
// FIXME: fixit when we can find a pattern binding.
|
||||
if (FixItLoc.isInvalid())
|
||||
TC.diagnose(var->getLoc(), diag::variable_never_mutated,
|
||||
var->getName(), varKind);
|
||||
|
||||
@@ -38,7 +38,7 @@ func foo() -> Int {
|
||||
}
|
||||
}
|
||||
|
||||
func goo(e : ErrorType) {}
|
||||
func goo(var e : ErrorType) {}
|
||||
|
||||
struct Test1 : OptionSetType {
|
||||
init(rawValue: Int) {}
|
||||
|
||||
Reference in New Issue
Block a user