Change ImplicitlyUnwrappedOptional to be an enum type itself,

not a struct wrapping an Optional.

Among other things, this means you can now pattern-match on
an IUO.  It also makes it more convenient to build and destroy
them.

SILGen's type lowering should probably canonicalize one kind
of optional to the other so that we don't get silly abstraction
costs from conversion.

Swift SVN r18991
This commit is contained in:
John McCall
2014-06-18 23:27:08 +00:00
parent 89fb9c8bea
commit 7effec113c
8 changed files with 158 additions and 73 deletions

View File

@@ -1291,7 +1291,7 @@ static bool isPrivilegedAccessToImplicitlyUnwrappedOptional(DeclContext *DC,
}
Type ConstraintSystem::lookThroughImplicitlyUnwrappedOptionalType(Type type) {
if (auto boundTy = type->getAs<BoundGenericStructType>()) {
if (auto boundTy = type->getAs<BoundGenericEnumType>()) {
auto boundDecl = boundTy->getDecl();
if (boundDecl == TC.Context.getImplicitlyUnwrappedOptionalDecl() &&
!isPrivilegedAccessToImplicitlyUnwrappedOptional(DC, boundDecl))