Make type contexts expect a value of type Type. (#2357)

In particular, this means that a type can implement `ImplicitAs(Type)` and have values of that type behave like types.

This implies that `()` and `{}` are no longer types. They are now values whose type is the result of converting `()` or `{}` to type `Type`, as has been discussed recently and seems to be the supported direction. This fixes various cases where these types were previously mishandled.
This commit is contained in:
Richard Smith
2022-10-28 08:20:49 -07:00
committed by GitHub
parent f46eaf49a2
commit 0219218b01
40 changed files with 674 additions and 319 deletions
+7
View File
@@ -257,6 +257,12 @@ void Expression::Print(llvm::raw_ostream& out) const {
}
break;
}
case ExpressionKind::BuiltinConvertExpression: {
// These don't represent source syntax, so just print the original
// expression.
out << *cast<BuiltinConvertExpression>(this)->source_expression();
break;
}
case ExpressionKind::UnimplementedExpression: {
const auto& unimplemented = cast<UnimplementedExpression>(*this);
out << "UnimplementedExpression<" << unimplemented.label() << ">(";
@@ -332,6 +338,7 @@ void Expression::PrintID(llvm::raw_ostream& out) const {
case ExpressionKind::CompoundMemberAccessExpression:
case ExpressionKind::IfExpression:
case ExpressionKind::WhereExpression:
case ExpressionKind::BuiltinConvertExpression:
case ExpressionKind::TupleLiteral:
case ExpressionKind::StructLiteral:
case ExpressionKind::StructTypeLiteral: