mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Lower UDRE to TypeValue if it references a value generic
This commit is contained in:
@@ -1385,8 +1385,47 @@ public:
|
||||
return E->getKind() == ExprKind::Type;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TypeValueExpr : public Expr {
|
||||
TypeLoc paramTypeLoc;
|
||||
|
||||
public:
|
||||
/// Create a \c TypeValueExpr from an underlying parameter \c TypeRepr.
|
||||
TypeValueExpr(TypeRepr *paramRepr) :
|
||||
Expr(ExprKind::TypeValue, /*implicit*/ false), paramTypeLoc(paramRepr) {}
|
||||
|
||||
/// Create a \c TypeValueExpr for a given \c TypeDecl at the specified
|
||||
/// location.
|
||||
///
|
||||
/// The given location must be valid. If it is not, you must use
|
||||
/// \c TypeExpr::createImplicitForDecl instead.
|
||||
static TypeValueExpr *createForDecl(DeclNameLoc Loc, TypeDecl *D,
|
||||
DeclContext *DC);
|
||||
|
||||
TypeRepr *getParamTypeRepr() const {
|
||||
return paramTypeLoc.getTypeRepr();
|
||||
}
|
||||
|
||||
/// Retrieves the corresponding parameter type of the value referenced by this
|
||||
/// expression.
|
||||
ArchetypeType *getParamType() const {
|
||||
return paramTypeLoc.getType()->castTo<ArchetypeType>();
|
||||
}
|
||||
|
||||
/// Sets the corresponding parameter type of the value referenced by this
|
||||
/// expression.
|
||||
void setParamType(Type paramType) {
|
||||
paramTypeLoc.setType(paramType);
|
||||
}
|
||||
|
||||
SourceRange getSourceRange() const {
|
||||
return paramTypeLoc.getSourceRange();
|
||||
}
|
||||
|
||||
static bool classof(const Expr *E) {
|
||||
return E->getKind() == ExprKind::TypeValue;
|
||||
}
|
||||
};
|
||||
|
||||
/// A reference to another initializer from within a constructor body,
|
||||
/// either to a delegating initializer or to a super.init invocation.
|
||||
@@ -3531,18 +3570,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// The implicit conversion from a variable generic metatype to its underlying
|
||||
/// value type.
|
||||
class TypeValueExpr : public ImplicitConversionExpr {
|
||||
public:
|
||||
TypeValueExpr(Expr *subExpr, Type ty)
|
||||
: ImplicitConversionExpr(ExprKind::TypeValue, subExpr, ty) {}
|
||||
|
||||
static bool classof(const Expr *E) {
|
||||
return E->getKind() == ExprKind::TypeValue;
|
||||
}
|
||||
};
|
||||
|
||||
/// Extracts the isolation of a dynamically isolated function value.
|
||||
class ExtractFunctionIsolationExpr : public Expr {
|
||||
/// The function value expression from which to extract the
|
||||
|
||||
@@ -191,8 +191,7 @@ ABSTRACT_EXPR(ImplicitConversion, Expr)
|
||||
EXPR(LinearFunctionExtractOriginal, ImplicitConversionExpr)
|
||||
EXPR(LinearToDifferentiableFunction, ImplicitConversionExpr)
|
||||
EXPR(ActorIsolationErasure, ImplicitConversionExpr)
|
||||
EXPR(TypeValue, ImplicitConversionExpr)
|
||||
EXPR_RANGE(ImplicitConversion, Load, TypeValue)
|
||||
EXPR_RANGE(ImplicitConversion, Load, ActorIsolationErasure)
|
||||
ABSTRACT_EXPR(ExplicitCast, Expr)
|
||||
ABSTRACT_EXPR(CheckedCast, ExplicitCastExpr)
|
||||
EXPR(ForcedCheckedCast, CheckedCastExpr)
|
||||
@@ -218,8 +217,9 @@ UNCHECKED_EXPR(OneWay, Expr)
|
||||
EXPR(Tap, Expr)
|
||||
UNCHECKED_EXPR(TypeJoin, Expr)
|
||||
EXPR(MacroExpansion, Expr)
|
||||
EXPR(TypeValue, Expr)
|
||||
// Don't forget to update the LAST_EXPR below when adding a new Expr here.
|
||||
LAST_EXPR(MacroExpansion)
|
||||
LAST_EXPR(TypeValue)
|
||||
|
||||
#undef EXPR_RANGE
|
||||
#undef LITERAL_EXPR
|
||||
|
||||
Reference in New Issue
Block a user