mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Remove TypeOf*Type for types whose type-of-type can just be Type (#2302)
We don't seem to have any need for `TypeOf*Type` types, and having them introduces the temptation to use them during type-checking, which would lead to types having different behavior when their type-of-type is `Type` versus when it's a more precise type. Remove these types for now. If we later decide that we want each type literal to have a unique type, as we do for value literals, we can introduce a single value kind for that rather than one for each kind of type. No changes to `TypeOfMemberName`, `TypeOfParameterizedEntityName`, and `TypeOfMixinPseudoType`, which are placeholders, not real types.
This commit is contained in:
@@ -530,9 +530,6 @@ void Value::Print(llvm::raw_ostream& out) const {
|
||||
out.write_escaped(cast<StringValue>(*this).value());
|
||||
out << "\"";
|
||||
break;
|
||||
case Value::Kind::TypeOfClassType:
|
||||
out << "typeof(" << cast<TypeOfClassType>(*this).class_type() << ")";
|
||||
break;
|
||||
case Value::Kind::TypeOfMixinPseudoType:
|
||||
out << "typeof("
|
||||
<< cast<TypeOfMixinPseudoType>(*this)
|
||||
@@ -541,22 +538,6 @@ void Value::Print(llvm::raw_ostream& out) const {
|
||||
.name()
|
||||
<< ")";
|
||||
break;
|
||||
case Value::Kind::TypeOfInterfaceType:
|
||||
out << "typeof("
|
||||
<< cast<TypeOfInterfaceType>(*this)
|
||||
.interface_type()
|
||||
.declaration()
|
||||
.name()
|
||||
<< ")";
|
||||
break;
|
||||
case Value::Kind::TypeOfConstraintType:
|
||||
out << "typeof(" << cast<TypeOfConstraintType>(*this).constraint_type()
|
||||
<< ")";
|
||||
break;
|
||||
case Value::Kind::TypeOfChoiceType:
|
||||
out << "typeof(" << cast<TypeOfChoiceType>(*this).choice_type().name()
|
||||
<< ")";
|
||||
break;
|
||||
case Value::Kind::TypeOfParameterizedEntityName:
|
||||
out << "parameterized entity name "
|
||||
<< cast<TypeOfParameterizedEntityName>(*this).name();
|
||||
@@ -743,21 +724,6 @@ auto TypeEqual(Nonnull<const Value*> t1, Nonnull<const Value*> t2,
|
||||
case Value::Kind::VariableType:
|
||||
return &cast<VariableType>(*t1).binding() ==
|
||||
&cast<VariableType>(*t2).binding();
|
||||
case Value::Kind::TypeOfClassType:
|
||||
return TypeEqual(&cast<TypeOfClassType>(*t1).class_type(),
|
||||
&cast<TypeOfClassType>(*t2).class_type(), equality_ctx);
|
||||
case Value::Kind::TypeOfInterfaceType:
|
||||
return TypeEqual(&cast<TypeOfInterfaceType>(*t1).interface_type(),
|
||||
&cast<TypeOfInterfaceType>(*t2).interface_type(),
|
||||
equality_ctx);
|
||||
case Value::Kind::TypeOfConstraintType:
|
||||
return TypeEqual(&cast<TypeOfConstraintType>(*t1).constraint_type(),
|
||||
&cast<TypeOfConstraintType>(*t2).constraint_type(),
|
||||
equality_ctx);
|
||||
case Value::Kind::TypeOfChoiceType:
|
||||
return TypeEqual(&cast<TypeOfChoiceType>(*t1).choice_type(),
|
||||
&cast<TypeOfChoiceType>(*t2).choice_type(),
|
||||
equality_ctx);
|
||||
case Value::Kind::StaticArrayType: {
|
||||
const auto& array1 = cast<StaticArrayType>(*t1);
|
||||
const auto& array2 = cast<StaticArrayType>(*t2);
|
||||
@@ -904,11 +870,7 @@ auto ValueStructurallyEqual(
|
||||
case Value::Kind::ContinuationType:
|
||||
case Value::Kind::VariableType:
|
||||
case Value::Kind::StringType:
|
||||
case Value::Kind::TypeOfClassType:
|
||||
case Value::Kind::TypeOfMixinPseudoType:
|
||||
case Value::Kind::TypeOfInterfaceType:
|
||||
case Value::Kind::TypeOfConstraintType:
|
||||
case Value::Kind::TypeOfChoiceType:
|
||||
case Value::Kind::TypeOfParameterizedEntityName:
|
||||
case Value::Kind::TypeOfMemberName:
|
||||
case Value::Kind::StaticArrayType:
|
||||
|
||||
Reference in New Issue
Block a user