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 {
16681668 return props;
16691669 }
16701670
1671- // The Error type is always canonical.
16721671 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)) {
16741675 if (originalType) {
16751676 Bits.ErrorType .HasOriginalType = true ;
16761677 *reinterpret_cast <Type *>(this + 1 ) = originalType;
Original file line number Diff line number Diff line change @@ -1765,7 +1765,6 @@ CanType TypeBase::computeCanonicalType() {
17651765#define ALWAYS_CANONICAL_TYPE (id, parent ) case TypeKind::id:
17661766#define TYPE (id, parent )
17671767#include " swift/AST/TypeNodes.def"
1768- case TypeKind::Error:
17691768 case TypeKind::TypeVariable:
17701769 case TypeKind::Placeholder:
17711770 case TypeKind::BuiltinTuple:
@@ -1779,6 +1778,14 @@ CanType TypeBase::computeCanonicalType() {
17791778#define TYPE (id, parent )
17801779#include " swift/AST/TypeNodes.def"
17811780
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+
17821789 case TypeKind::Enum:
17831790 case TypeKind::Struct:
17841791 case TypeKind::Class:
Original file line number Diff line number Diff line change @@ -1728,7 +1728,7 @@ do {
17281728do {
17291729 func f( _: Int ... ) { }
17301730 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]'}}
17321732}
17331733
17341734// 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