File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -1668,9 +1668,10 @@ class ErrorType final : public TypeBase {
1668
1668
return props;
1669
1669
}
1670
1670
1671
- // The Error type is always canonical.
1672
1671
ErrorType (ASTContext &C, Type originalType)
1673
- : TypeBase(TypeKind::Error, &C, getProperties(originalType)) {
1672
+ : TypeBase(TypeKind::Error,
1673
+ (!originalType || originalType->isCanonical ()) ? &C : nullptr,
1674
+ getProperties(originalType)) {
1674
1675
if (originalType) {
1675
1676
Bits.ErrorType .HasOriginalType = true ;
1676
1677
*reinterpret_cast <Type *>(this + 1 ) = originalType;
Original file line number Diff line number Diff line change @@ -1765,7 +1765,6 @@ CanType TypeBase::computeCanonicalType() {
1765
1765
#define ALWAYS_CANONICAL_TYPE (id, parent ) case TypeKind::id:
1766
1766
#define TYPE (id, parent )
1767
1767
#include " swift/AST/TypeNodes.def"
1768
- case TypeKind::Error:
1769
1768
case TypeKind::TypeVariable:
1770
1769
case TypeKind::Placeholder:
1771
1770
case TypeKind::BuiltinTuple:
@@ -1779,6 +1778,14 @@ CanType TypeBase::computeCanonicalType() {
1779
1778
#define TYPE (id, parent )
1780
1779
#include " swift/AST/TypeNodes.def"
1781
1780
1781
+ case TypeKind::Error: {
1782
+ auto errTy = cast<ErrorType>(this );
1783
+ auto originalTy = errTy->getOriginalType ();
1784
+ ASSERT (originalTy && " The bare ErrorType singleton is already canonical" );
1785
+ Result = ErrorType::get (originalTy->getCanonicalType ()).getPointer ();
1786
+ break ;
1787
+ }
1788
+
1782
1789
case TypeKind::Enum:
1783
1790
case TypeKind::Struct:
1784
1791
case TypeKind::Class:
Original file line number Diff line number Diff line change @@ -1728,7 +1728,7 @@ do {
1728
1728
do {
1729
1729
func f( _: Int ... ) { }
1730
1730
let _ = [ ( 1 , 2 , 3 ) ] . map ( f) // expected-error {{no exact matches in call to instance method 'map'}}
1731
- // expected-note@-1 2 {{found candidate with type '(((Int, Int, Int)) -> T) -> [T]'}}
1731
+ // expected-note@-1 {{found candidate with type '(((Int, Int, Int)) -> T) -> [T]'}}
1732
1732
}
1733
1733
1734
1734
// rdar://problem/48443263 - cannot convert value of type '() -> Void' to expected argument type '(_) -> Void'
You can’t perform that action at this time.
0 commit comments