Skip to content

Commit a49f175

Browse files
authored
Merge pull request #14398 from rudkx/some-iuo-deletion
2 parents cfd3225 + 3654dcc commit a49f175

17 files changed

+23
-343
lines changed

include/swift/AST/Types.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,10 +993,6 @@ class alignas(1 << TypeAlignInBits) TypeBase {
993993
/// Return T if this type is Optional<T>; otherwise, return the null type.
994994
Type getOptionalObjectType();
995995

996-
/// Return T if this type is ImplicitlyUnwrappedOptional<T>; otherwise, return
997-
/// the null type.
998-
Type getImplicitlyUnwrappedOptionalObjectType();
999-
1000996
/// Return T if this type is Optional<T> or ImplicitlyUnwrappedOptional<T>;
1001997
/// otherwise, return the null type.
1002998
Type getAnyOptionalObjectType(OptionalTypeKind &kind);

lib/AST/Decl.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,18 +1696,6 @@ static Type mapSignatureType(ASTContext &ctx, Type type) {
16961696

16971697
/// Map a signature type for a parameter.
16981698
static Type mapSignatureParamType(ASTContext &ctx, Type type) {
1699-
// Translate implicitly unwrapped optionals into strict optionals.
1700-
if (auto inOutTy = type->getAs<InOutType>()) {
1701-
if (auto uncheckedOptOf =
1702-
inOutTy->getObjectType()
1703-
->getImplicitlyUnwrappedOptionalObjectType()) {
1704-
type = InOutType::get(OptionalType::get(uncheckedOptOf));
1705-
}
1706-
} else if (auto uncheckedOptOf =
1707-
type->getImplicitlyUnwrappedOptionalObjectType()) {
1708-
type = OptionalType::get(uncheckedOptOf);
1709-
}
1710-
17111699
return mapSignatureType(ctx, type);
17121700
}
17131701

lib/AST/Type.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -502,13 +502,6 @@ Type TypeBase::getOptionalObjectType() {
502502
return Type();
503503
}
504504

505-
Type TypeBase::getImplicitlyUnwrappedOptionalObjectType() {
506-
if (auto boundTy = getAs<BoundGenericEnumType>())
507-
if (boundTy->getDecl()->classifyAsOptionalType() == OTK_ImplicitlyUnwrappedOptional)
508-
return boundTy->getGenericArgs()[0];
509-
return Type();
510-
}
511-
512505
Type TypeBase::getAnyOptionalObjectType(OptionalTypeKind &kind) {
513506
if (auto boundTy = getAs<BoundGenericEnumType>())
514507
if ((kind = boundTy->getDecl()->classifyAsOptionalType()))
@@ -2309,17 +2302,6 @@ static bool matches(CanType t1, CanType t2, TypeMatchOptions matchMode,
23092302
paramsAndResultMatch);
23102303
}
23112304

2312-
if (matchMode.contains(TypeMatchFlags::AllowNonOptionalForIUOParam) &&
2313-
(paramPosition == ParameterPosition::Parameter ||
2314-
paramPosition == ParameterPosition::ParameterTupleElement) &&
2315-
insideOptional == OptionalUnwrapping::None) {
2316-
// Allow T to override T! in certain cases.
2317-
if (auto obj1 = t1->getImplicitlyUnwrappedOptionalObjectType()) {
2318-
t1 = obj1->getCanonicalType();
2319-
if (t1 == t2) return true;
2320-
}
2321-
}
2322-
23232305
// Class-to-class.
23242306
if (matchMode.contains(TypeMatchFlags::AllowOverride))
23252307
if (t2->isExactSuperclassOf(t1))

lib/ClangImporter/ImportType.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ namespace {
177177
using TypeVisitor::Visit;
178178
ImportResult Visit(clang::QualType type) {
179179
auto IR = Visit(type.getTypePtr());
180-
assert(!IR.AbstractType ||
181-
!IR.AbstractType->getImplicitlyUnwrappedOptionalObjectType());
182180
return IR;
183181
}
184182

@@ -1161,10 +1159,6 @@ static ImportedType adjustTypeForConcreteImport(
11611159
bool allowNSUIntegerAsInt, Bridgeability bridging, OptionalTypeKind optKind,
11621160
bool resugarNSErrorPointer) {
11631161

1164-
// We never expect an IUO type to be passed in.
1165-
assert(!importedType ||
1166-
!importedType->getImplicitlyUnwrappedOptionalObjectType());
1167-
11681162
if (importKind == ImportTypeKind::Abstract) {
11691163
return {importedType, false};
11701164
}
@@ -1188,8 +1182,6 @@ static ImportedType adjustTypeForConcreteImport(
11881182
if (!importedType)
11891183
return {Type(), false};
11901184

1191-
assert(!importedType->getImplicitlyUnwrappedOptionalObjectType());
1192-
11931185
// Special case AutoreleasingUnsafeMutablePointer<NSError?> parameters.
11941186
auto maybeImportNSErrorPointer = [&]() -> Type {
11951187
if (importKind != ImportTypeKind::Parameter)
@@ -1232,7 +1224,6 @@ static ImportedType adjustTypeForConcreteImport(
12321224
};
12331225

12341226
if (Type result = maybeImportNSErrorPointer()) {
1235-
assert(!result->getImplicitlyUnwrappedOptionalObjectType());
12361227
return {result, false};
12371228
}
12381229

@@ -1278,11 +1269,9 @@ static ImportedType adjustTypeForConcreteImport(
12781269
resultTy = impl.getNamedSwiftTypeSpecialization(impl.getStdlibModule(),
12791270
pointerName,
12801271
resultTy);
1281-
assert(!resultTy->getImplicitlyUnwrappedOptionalObjectType());
12821272
return resultTy;
12831273
};
12841274
if (Type outParamTy = maybeImportCFOutParameter()) {
1285-
assert(!outParamTy->getImplicitlyUnwrappedOptionalObjectType());
12861275
importedType = outParamTy;
12871276
}
12881277

@@ -1381,9 +1370,6 @@ static ImportedType adjustTypeForConcreteImport(
13811370
importedType = OptionalType::get(importedType);
13821371
}
13831372

1384-
// We do not expect to return actual IUO types.
1385-
assert(!importedType->getImplicitlyUnwrappedOptionalObjectType());
1386-
13871373
return {importedType, isIUO};
13881374
}
13891375

@@ -1437,10 +1423,6 @@ ImportedType ClangImporter::Implementation::importType(
14371423
*this, type, importResult.AbstractType, importKind, importResult.Hint,
14381424
allowNSUIntegerAsInt, bridging, optionality, resugarNSErrorPointer);
14391425

1440-
// We should never get an actual IUO type back.
1441-
assert(!adjustedType ||
1442-
!adjustedType.getType()->getImplicitlyUnwrappedOptionalObjectType());
1443-
14441426
return adjustedType;
14451427
}
14461428

@@ -1452,9 +1434,6 @@ Type ClangImporter::Implementation::importTypeIgnoreIUO(
14521434
auto importedType = importType(type, importKind, allowNSUIntegerAsInt,
14531435
bridging, optionality, resugarNSErrorPointer);
14541436

1455-
assert(!importedType ||
1456-
!importedType.getType()->getImplicitlyUnwrappedOptionalObjectType());
1457-
14581437
return importedType.getType();
14591438
}
14601439

@@ -1569,9 +1548,6 @@ ImportedType ClangImporter::Implementation::importFunctionReturnType(
15691548
switch (getClangASTContext().BuiltinInfo.getTypeString(builtinID)[0]) {
15701549
case 'z': // size_t
15711550
case 'Y': // ptrdiff_t
1572-
assert(!SwiftContext.getIntDecl()
1573-
->getDeclaredType()
1574-
->getImplicitlyUnwrappedOptionalObjectType());
15751551
return {SwiftContext.getIntDecl()->getDeclaredType(), false};
15761552
default:
15771553
break;

lib/ClangImporter/ImporterImpl.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -639,12 +639,10 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
639639
}
640640
#endif
641641

642-
if (!isIUO) {
643-
assert(!ty->getImplicitlyUnwrappedOptionalObjectType());
642+
if (!isIUO)
644643
return;
645-
} else {
646-
assert(ty->getAnyOptionalObjectType());
647-
}
644+
645+
assert(ty->getOptionalObjectType());
648646

649647
auto *IUOAttr = new (SwiftContext)
650648
ImplicitlyUnwrappedOptionalAttr(/* implicit= */ true);

lib/IDE/CodeCompletion.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3158,6 +3158,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
31583158
// FIXME: consider types convertible to T?.
31593159

31603160
ExprType = ExprType->getRValueType();
3161+
// FIXME: We don't always pass down whether a type is from an
3162+
// unforced IUO.
31613163
if (isIUO) {
31623164
if (Type Unwrapped = ExprType->getAnyOptionalObjectType()) {
31633165
lookupVisibleMemberDecls(*this, Unwrapped, CurrDeclContext,
@@ -3184,12 +3186,6 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
31843186
IncludeInstanceMembers);
31853187
}
31863188
}
3187-
} else if (Type Unwrapped = ExprType->getImplicitlyUnwrappedOptionalObjectType()) {
3188-
// FIXME: This can go away when IUOs have been removed from the type
3189-
// system.
3190-
lookupVisibleMemberDecls(*this, Unwrapped, CurrDeclContext,
3191-
TypeResolver.get(),
3192-
IncludeInstanceMembers);
31933189
} else {
31943190
return false;
31953191
}

lib/SILGen/SILGenBridging.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,6 @@ static ManagedValue emitNativeToCBridgedNonoptionalValue(SILGenFunction &SGF,
631631
loweredBridgedTy.castTo<SILFunctionType>());
632632
}
633633

634-
// Erase IUO at this point, because there aren't any conformances for
635-
// IUO anymore. Note that the value representation stays the same
636-
// because SIL erases the difference.
637-
if (auto obj = nativeType->getImplicitlyUnwrappedOptionalObjectType()) {
638-
nativeType = OptionalType::get(obj)->getCanonicalType();
639-
}
640-
641634
// If the native type conforms to _ObjectiveCBridgeable, use its
642635
// _bridgeToObjectiveC witness.
643636
if (auto conformance =

0 commit comments

Comments
 (0)