mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SIL: Capture generic parameters through nested closures.
We were failing to capture generic parameters from closure contexts that themselves capture generic parameters from context. This fixes <rdar://problem/15417783>. While we're here, eliminate some unnecessary splitting of 'ClosureExpr' and 'AutoClosureExpr' in the SILDeclRef::Loc PointerUnion; we can just use their base class AbstractClosureExpr in the PointerUnion. Swift SVN r10031
This commit is contained in:
@@ -30,6 +30,7 @@ namespace llvm {
|
||||
|
||||
namespace swift {
|
||||
class ValueDecl;
|
||||
class AbstractClosureExpr;
|
||||
class ClosureExpr;
|
||||
class AutoClosureExpr;
|
||||
class ASTContext;
|
||||
@@ -48,8 +49,7 @@ namespace swift {
|
||||
/// initializing entry points of a constructor, the getter and setter for
|
||||
/// a computed variable, etc.
|
||||
struct SILDeclRef {
|
||||
typedef llvm::PointerUnion3<ValueDecl *, ClosureExpr *,
|
||||
AutoClosureExpr *> Loc;
|
||||
typedef llvm::PointerUnion<ValueDecl *, AbstractClosureExpr *> Loc;
|
||||
|
||||
/// Represents the "kind" of the SILDeclRef. For some Swift decls there
|
||||
/// are multiple SIL entry points, and the kind is used to distinguish them.
|
||||
@@ -142,18 +142,23 @@ struct SILDeclRef {
|
||||
|
||||
bool hasDecl() const { return loc.is<ValueDecl *>(); }
|
||||
bool hasClosureExpr() const {
|
||||
return loc.is<ClosureExpr *>();
|
||||
return loc.is<AbstractClosureExpr *>()
|
||||
&& isa<ClosureExpr>(getAbstractClosureExpr() );
|
||||
}
|
||||
bool hasAutoClosureExpr() const {
|
||||
return loc.is<AutoClosureExpr *>();
|
||||
return loc.is<AbstractClosureExpr *>()
|
||||
&& isa<AutoClosureExpr>(getAbstractClosureExpr());
|
||||
}
|
||||
|
||||
ValueDecl *getDecl() const { return loc.get<ValueDecl *>(); }
|
||||
AbstractClosureExpr *getAbstractClosureExpr() const {
|
||||
return loc.dyn_cast<AbstractClosureExpr *>();
|
||||
}
|
||||
ClosureExpr *getClosureExpr() const {
|
||||
return loc.dyn_cast<ClosureExpr *>();
|
||||
return dyn_cast<ClosureExpr>(getAbstractClosureExpr());
|
||||
}
|
||||
AutoClosureExpr *getAutoClosureExpr() const {
|
||||
return loc.dyn_cast<AutoClosureExpr *>();
|
||||
return dyn_cast<AutoClosureExpr>(getAbstractClosureExpr());
|
||||
}
|
||||
|
||||
/// True if the SILDeclRef references a function.
|
||||
|
||||
Reference in New Issue
Block a user