Skip to content

Commit d5edee8

Browse files
committed
[Gardening] Redocument TypeExpr's Implicit Constructors
1 parent 0c4bef4 commit d5edee8

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

include/swift/AST/Expr.h

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,13 +1331,13 @@ class SuperRefExpr : public Expr {
13311331
}
13321332
};
13331333

1334-
/// A reference to a type in expression context, spelled out as a TypeLoc.
1334+
/// A reference to a type in expression context.
13351335
///
1336-
/// The type of this expression is always \c MetaTypeType.
1336+
/// The type of this expression is always \c MetatypeType.
13371337
class TypeExpr : public Expr {
13381338
TypeRepr *Repr;
13391339
public:
1340-
// Create a TypeExpr with location information.
1340+
/// Create a \c TypeExpr from a parsed \c TypeRepr.
13411341
TypeExpr(TypeRepr *Ty);
13421342

13431343
/// Retrieves the corresponding instance type of the type referenced by this
@@ -1348,21 +1348,47 @@ class TypeExpr : public Expr {
13481348
/// resulting instance type is \c ErrorType.
13491349
Type getInstanceType() const;
13501350

1351-
// Create an implicit TypeExpr, which has no location information.
1351+
public:
1352+
/// Create an implicit \c TypeExpr.
1353+
///
1354+
/// The given type is required to be non-null and must be not be
1355+
/// a \c MetatypeType as this function will wrap the given type in one.
1356+
///
1357+
/// FIXME: This behavior is bizarre.
13521358
static TypeExpr *createImplicit(Type Ty, ASTContext &C);
13531359

1354-
// Create an implicit TypeExpr, with location information even though it
1355-
// shouldn't have one. This is presently used to work around other location
1356-
// processing bugs. If you have an implicit location, use createImplicit.
1360+
/// Create an implicit \c TypeExpr that has artificial
1361+
/// location information attached.
1362+
///
1363+
/// The given type is required to be non-null and must be not be
1364+
/// a \c MetatypeType as this function will wrap the given type in one.
1365+
///
1366+
/// FIXME: This behavior is bizarre.
1367+
///
1368+
/// Due to limitations in the modeling of certain AST elements, implicit
1369+
/// \c TypeExpr nodes are often the only source of location information the
1370+
/// expression checker has when it comes time to diagnose an error.
13571371
static TypeExpr *createImplicitHack(SourceLoc Loc, Type Ty, ASTContext &C);
13581372

1359-
1360-
/// Create a TypeExpr for a TypeDecl at the specified location.
1361-
static TypeExpr *createForDecl(DeclNameLoc Loc, TypeDecl *D, DeclContext *DC);
1362-
1373+
/// Create an implicit \c TypeExpr for a given \c TypeDecl at the specified location.
1374+
///
1375+
/// The given type is required to be non-null and must be not be
1376+
/// a \c MetatypeType as this function will wrap the given type in one.
1377+
///
1378+
/// FIXME: This behavior is bizarre.
1379+
///
1380+
/// Unlike the non-implicit case, the given location is not required to be
1381+
/// valid.
13631382
static TypeExpr *createImplicitForDecl(DeclNameLoc Loc, TypeDecl *D,
13641383
DeclContext *DC, Type ty);
13651384

1385+
public:
1386+
/// Create a \c TypeExpr for a given \c TypeDecl at the specified location.
1387+
///
1388+
/// The given location must be valid. If it is not, you must use
1389+
/// \c TypeExpr::createImplicitForDecl instead.
1390+
static TypeExpr *createForDecl(DeclNameLoc Loc, TypeDecl *D, DeclContext *DC);
1391+
13661392
/// Create a TypeExpr for a member TypeDecl of the given parent TypeDecl.
13671393
static TypeExpr *createForMemberDecl(DeclNameLoc ParentNameLoc,
13681394
TypeDecl *Parent,

0 commit comments

Comments
 (0)