Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1668,9 +1668,10 @@ class ErrorType final : public TypeBase {
return props;
}

// The Error type is always canonical.
ErrorType(ASTContext &C, Type originalType)
: TypeBase(TypeKind::Error, &C, getProperties(originalType)) {
: TypeBase(TypeKind::Error,
(!originalType || originalType->isCanonical()) ? &C : nullptr,
getProperties(originalType)) {
if (originalType) {
Bits.ErrorType.HasOriginalType = true;
*reinterpret_cast<Type *>(this + 1) = originalType;
Expand Down
9 changes: 8 additions & 1 deletion lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,6 @@ CanType TypeBase::computeCanonicalType() {
#define ALWAYS_CANONICAL_TYPE(id, parent) case TypeKind::id:
#define TYPE(id, parent)
#include "swift/AST/TypeNodes.def"
case TypeKind::Error:
case TypeKind::TypeVariable:
case TypeKind::Placeholder:
case TypeKind::BuiltinTuple:
Expand All @@ -1779,6 +1778,14 @@ CanType TypeBase::computeCanonicalType() {
#define TYPE(id, parent)
#include "swift/AST/TypeNodes.def"

case TypeKind::Error: {
auto errTy = cast<ErrorType>(this);
auto originalTy = errTy->getOriginalType();
ASSERT(originalTy && "The bare ErrorType singleton is already canonical");
Result = ErrorType::get(originalTy->getCanonicalType()).getPointer();
break;
}

case TypeKind::Enum:
case TypeKind::Struct:
case TypeKind::Class:
Expand Down
2 changes: 1 addition & 1 deletion test/Constraints/tuple_arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ do {
do {
func f(_: Int...) {}
let _ = [(1, 2, 3)].map(f) // expected-error {{no exact matches in call to instance method 'map'}}
// expected-note@-1 2{{found candidate with type '(((Int, Int, Int)) -> T) -> [T]'}}
// expected-note@-1 {{found candidate with type '(((Int, Int, Int)) -> T) -> [T]'}}
}

// rdar://problem/48443263 - cannot convert value of type '() -> Void' to expected argument type '(_) -> Void'
Expand Down