|
36 | 36 | #include "swift/Basic/ArrayRefView.h"
|
37 | 37 | #include "swift/Basic/Compiler.h"
|
38 | 38 | #include "swift/Basic/InlineBitfield.h"
|
| 39 | +#include "swift/Basic/NullablePtr.h" |
39 | 40 | #include "swift/Basic/OptionalEnum.h"
|
40 | 41 | #include "swift/Basic/Range.h"
|
41 | 42 | #include "llvm/ADT/DenseMap.h"
|
@@ -4747,8 +4748,32 @@ class VarDecl : public AbstractStorageDecl {
|
4747 | 4748 | /// return this. Otherwise, this VarDecl must belong to a CaseStmt's
|
4748 | 4749 | /// CaseLabelItem. In that case, return the first case label item of the first
|
4749 | 4750 | /// case stmt in a sequence of case stmts that fallthrough into each other.
|
| 4751 | + /// |
| 4752 | + /// NOTE: During type checking, we emit an error if we have a single case |
| 4753 | + /// label item with a pattern that has multiple var decls of the same |
| 4754 | + /// name. This means that during type checking and before type checking, we |
| 4755 | + /// may have a _malformed_ switch stmt var decl linked list since var decls in |
| 4756 | + /// the same case label item that have the same name will point at the same |
| 4757 | + /// canonical var decl, namely the first var decl with the name in the |
| 4758 | + /// canonical case label item's var decl list. This is ok, since we are going |
| 4759 | + /// to emit the error, but it requires us to be more careful/cautious before |
| 4760 | + /// type checking has been complete when relying on canonical var decls |
| 4761 | + /// matching up. |
4750 | 4762 | VarDecl *getCanonicalVarDecl() const;
|
4751 | 4763 |
|
| 4764 | + /// If this is a case stmt var decl, return the var decl that corresponds to |
| 4765 | + /// this var decl in the first case label item of the case stmt. Returns |
| 4766 | + /// nullptr if this isn't a VarDecl that is part of a case stmt. |
| 4767 | + NullablePtr<VarDecl> getCorrespondingFirstCaseLabelItemVarDecl() const; |
| 4768 | + |
| 4769 | + /// If this is a case stmt var decl, return the case body var decl that this |
| 4770 | + /// var decl maps to. |
| 4771 | + NullablePtr<VarDecl> getCorrespondingCaseBodyVariable() const; |
| 4772 | + |
| 4773 | + /// Return true if this var decl is an implicit var decl belonging to a case |
| 4774 | + /// stmt's body. |
| 4775 | + bool isCaseBodyVariable() const; |
| 4776 | + |
4752 | 4777 | /// True if the global stored property requires lazy initialization.
|
4753 | 4778 | bool isLazilyInitializedGlobal() const;
|
4754 | 4779 |
|
|
0 commit comments