@@ -141,24 +141,24 @@ class RecursiveTypeProperties {
141
141
// / This type expression contains a GenericTypeParamType.
142
142
HasTypeParameter = 0x04 ,
143
143
144
- // / This type expression contains an UnresolvedType.
145
- HasUnresolvedType = 0x08 ,
146
-
147
144
// / Whether this type expression contains an unbound generic type.
148
- HasUnboundGeneric = 0x10 ,
145
+ HasUnboundGeneric = 0x08 ,
149
146
150
147
// / This type expression contains an LValueType other than as a
151
148
// / function input, and can be loaded to convert to an rvalue.
152
- IsLValue = 0x20 ,
149
+ IsLValue = 0x10 ,
153
150
154
151
// / This type expression contains an opened existential ArchetypeType.
155
- HasOpenedExistential = 0x40 ,
152
+ HasOpenedExistential = 0x20 ,
156
153
157
154
// / This type expression contains a DynamicSelf type.
158
- HasDynamicSelf = 0x80 ,
155
+ HasDynamicSelf = 0x40 ,
159
156
160
157
// / This type contains an Error type.
161
- HasError = 0x100 ,
158
+ HasError = 0x80 ,
159
+
160
+ // / This type contains an Error type without an underlying original type.
161
+ HasBareError = 0x100 ,
162
162
163
163
// / This type contains a DependentMemberType.
164
164
HasDependentMember = 0x200 ,
@@ -225,15 +225,15 @@ class RecursiveTypeProperties {
225
225
// / Does a type with these properties have a type parameter somewhere in it?
226
226
bool hasTypeParameter () const { return Bits & HasTypeParameter; }
227
227
228
- // / Does a type with these properties have an unresolved type somewhere in it?
229
- bool hasUnresolvedType () const { return Bits & HasUnresolvedType; }
230
-
231
228
// / Is a type with these properties an lvalue?
232
229
bool isLValue () const { return Bits & IsLValue; }
233
230
234
231
// / Does this type contain an error?
235
232
bool hasError () const { return Bits & HasError; }
236
233
234
+ // / Does this type contain an error without an original type?
235
+ bool hasBareError () const { return Bits & HasBareError; }
236
+
237
237
// / Does this type contain a dependent member type, possibly with a
238
238
// / non-type parameter base, such as a type variable or concrete type?
239
239
bool hasDependentMember () const { return Bits & HasDependentMember; }
@@ -750,11 +750,6 @@ class alignas(1 << TypeAlignInBits) TypeBase
750
750
// / member root in a type variable.
751
751
bool isTypeVariableOrMember ();
752
752
753
- // / Determine whether this type involves a UnresolvedType.
754
- bool hasUnresolvedType () const {
755
- return getRecursiveProperties ().hasUnresolvedType ();
756
- }
757
-
758
753
// / Determine whether this type involves a \c PlaceholderType.
759
754
bool hasPlaceholder () const {
760
755
return getRecursiveProperties ().hasPlaceholder ();
@@ -949,6 +944,16 @@ class alignas(1 << TypeAlignInBits) TypeBase
949
944
return getRecursiveProperties ().hasError ();
950
945
}
951
946
947
+ // / Determine whether this type contains an error type without an
948
+ // / underlying original type, i.e prints as `_`.
949
+ bool hasBareError () const {
950
+ return getRecursiveProperties ().hasBareError ();
951
+ }
952
+
953
+ // / Whether this is a top-level ErrorType without an underlying original
954
+ // / type, i.e prints as `_`.
955
+ bool isBareErrorType () const ;
956
+
952
957
// / Does this type contain a dependent member type, possibly with a
953
958
// / non-type parameter base, such as a type variable or concrete type?
954
959
bool hasDependentMember () const {
@@ -1654,11 +1659,18 @@ DEFINE_EMPTY_CAN_TYPE_WRAPPER(NominalOrBoundGenericNominalType, AnyGenericType)
1654
1659
// / have to emit further diagnostics to abort compilation.
1655
1660
class ErrorType final : public TypeBase {
1656
1661
friend class ASTContext ;
1662
+
1663
+ static RecursiveTypeProperties getProperties (Type originalType) {
1664
+ RecursiveTypeProperties props = RecursiveTypeProperties::HasError;
1665
+ if (!originalType || originalType->hasBareError ())
1666
+ props |= RecursiveTypeProperties::HasBareError;
1667
+
1668
+ return props;
1669
+ }
1670
+
1657
1671
// The Error type is always canonical.
1658
- ErrorType (ASTContext &C, Type originalType,
1659
- RecursiveTypeProperties properties)
1660
- : TypeBase(TypeKind::Error, &C, properties) {
1661
- assert (properties.hasError ());
1672
+ ErrorType (ASTContext &C, Type originalType)
1673
+ : TypeBase(TypeKind::Error, &C, getProperties(originalType)) {
1662
1674
if (originalType) {
1663
1675
Bits.ErrorType .HasOriginalType = true ;
1664
1676
*reinterpret_cast <Type *>(this + 1 ) = originalType;
@@ -1689,25 +1701,6 @@ class ErrorType final : public TypeBase {
1689
1701
}
1690
1702
};
1691
1703
DEFINE_EMPTY_CAN_TYPE_WRAPPER (ErrorType, Type)
1692
-
1693
- // / UnresolvedType - This represents a type variable that cannot be resolved to
1694
- // / a concrete type because the expression is ambiguous. This is produced when
1695
- // / parsing expressions and producing diagnostics. Any instance of this should
1696
- // / cause the entire expression to be ambiguously typed.
1697
- class UnresolvedType : public TypeBase {
1698
- friend class ASTContext ;
1699
- // The Unresolved type is always canonical.
1700
- UnresolvedType (ASTContext &C)
1701
- : TypeBase(TypeKind::Unresolved, &C,
1702
- RecursiveTypeProperties (RecursiveTypeProperties::HasUnresolvedType)) { }
1703
- public:
1704
- // Implement isa/cast/dyncast/etc.
1705
- static bool classof (const TypeBase *T) {
1706
- return T->getKind () == TypeKind::Unresolved;
1707
- }
1708
- };
1709
- DEFINE_EMPTY_CAN_TYPE_WRAPPER (UnresolvedType, Type)
1710
-
1711
1704
1712
1705
// / BuiltinType - An abstract class for all the builtin types.
1713
1706
class BuiltinType : public TypeBase {
@@ -8124,6 +8117,17 @@ inline ASTContext &TypeBase::getASTContext() const {
8124
8117
return *const_cast <ASTContext*>(getCanonicalType ()->Context );
8125
8118
}
8126
8119
8120
+ inline bool TypeBase::isBareErrorType () const {
8121
+ auto *errTy = dyn_cast<ErrorType>(this );
8122
+ if (!errTy)
8123
+ return false ;
8124
+
8125
+ // FIXME: We shouldn't need to check for a recursive bare error type, we can
8126
+ // remove this once we flatten them.
8127
+ auto originalTy = errTy->getOriginalType ();
8128
+ return !originalTy || originalTy->isBareErrorType ();
8129
+ }
8130
+
8127
8131
// TODO: This will become redundant once InOutType is removed.
8128
8132
inline bool TypeBase::isMaterializable () {
8129
8133
return !(hasLValueType () || is<InOutType>());
0 commit comments