Skip to content

Commit 1e7e733

Browse files
authored
Merge pull request #20161 from slavapestov/remove-swift3
Remove remaining isSwiftVersion3() checks
2 parents 65a04a7 + 4063124 commit 1e7e733

File tree

12 files changed

+17
-59
lines changed

12 files changed

+17
-59
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,6 @@ class ASTContext final {
924924
CanGenericSignature getExistentialSignature(CanType existential,
925925
ModuleDecl *mod);
926926

927-
/// Whether our effective Swift version is in the Swift 3 family.
928-
bool isSwiftVersion3() const { return LangOpts.isSwiftVersion3(); }
929-
930927
/// Whether our effective Swift version is at least 'major'.
931928
///
932929
/// This is usually the check you want; for example, when introducing

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,9 +1865,6 @@ NOTE(declared_protocol_conformance_here,none,
18651865
"%0 implicitly conforms to protocol %2}1 here",
18661866
(Type, unsigned, DeclName, DeclName))
18671867

1868-
WARNING(witness_unavailable_warn,none,
1869-
"unavailable %0 %1 was used to satisfy a requirement of protocol %2",
1870-
(DescriptiveDeclKind, DeclName, DeclName))
18711868
ERROR(witness_unavailable,none,
18721869
"unavailable %0 %1 was used to satisfy a requirement of protocol %2",
18731870
(DescriptiveDeclKind, DeclName, DeclName))

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,6 @@ namespace swift {
358358
return CustomConditionalCompilationFlags;
359359
}
360360

361-
/// Whether our effective Swift version is in the Swift 3 family
362-
bool isSwiftVersion3() const {
363-
return EffectiveLanguageVersion.isVersion3();
364-
}
365-
366361
/// Whether our effective Swift version is at least 'major'.
367362
///
368363
/// This is usually the check you want; for example, when introducing

include/swift/Basic/Version.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ class Version {
107107
/// compiler to act as if it is version 3.1.
108108
Optional<Version> getEffectiveLanguageVersion() const;
109109

110-
/// Whether this version is in the Swift 3 family
111-
bool isVersion3() const { return !empty() && Components[0] == 3; }
112-
113110
/// Whether this version is greater than or equal to the given major version
114111
/// number.
115112
bool isVersionAtLeast(unsigned major, unsigned minor = 0) const {

lib/ClangImporter/ClangAdapter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,11 +741,10 @@ OptionalTypeKind importer::getParamOptionality(version::Version swiftVersion,
741741
return OTK_None;
742742

743743
// Check for the 'static' annotation on C arrays.
744-
if (!swiftVersion.isVersion3())
745-
if (const auto *DT = dyn_cast<clang::DecayedType>(paramTy))
746-
if (const auto *AT = DT->getOriginalType()->getAsArrayTypeUnsafe())
747-
if (AT->getSizeModifier() == clang::ArrayType::Static)
748-
return OTK_None;
744+
if (const auto *DT = dyn_cast<clang::DecayedType>(paramTy))
745+
if (const auto *AT = DT->getOriginalType()->getAsArrayTypeUnsafe())
746+
if (AT->getSizeModifier() == clang::ArrayType::Static)
747+
return OTK_None;
749748

750749
// Default to implicitly unwrapped optionals.
751750
return OTK_ImplicitlyUnwrappedOptional;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
364364

365365
Opts.EnableSwift3ObjCInference =
366366
Args.hasFlag(OPT_enable_swift3_objc_inference,
367-
OPT_disable_swift3_objc_inference,
368-
Opts.isSwiftVersion3());
367+
OPT_disable_swift3_objc_inference, false);
369368

370369
if (Opts.EnableSwift3ObjCInference) {
371370
if (const Arg *A = Args.getLastArg(

lib/Migrator/Migrator.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,6 @@ Migrator::performAFixItMigration(version::Version SwiftLanguageVersion) {
132132
LLVMArgs.erase(aarch64_use_tbi);
133133
}
134134

135-
if (StartInvocation.getLangOptions().EffectiveLanguageVersion.isVersion3()) {
136-
// SE-0160: When migrating, always use the Swift 3 @objc inference rules,
137-
// which drives warnings with the "@objc" Fix-Its.
138-
Invocation.getLangOptions().EnableSwift3ObjCInference = true;
139-
140-
// The default behavior of the migrator, referred to as "minimal" migration
141-
// in SE-0160, only adds @objc Fix-Its to those cases where the Objective-C
142-
// entry point is explicitly used somewhere in the source code. The user
143-
// may also select a workflow that adds @objc for every declaration that
144-
// would infer @objc under the Swift 3 rules but would no longer infer
145-
// @objc in Swift 4.
146-
Invocation.getLangOptions().WarnSwift3ObjCInference =
147-
getMigratorOptions().KeepObjcVisibility
148-
? Swift3ObjCInferenceWarnings::Complete
149-
: Swift3ObjCInferenceWarnings::Minimal;
150-
}
151-
152135
const auto &OrigFrontendOpts = StartInvocation.getFrontendOptions();
153136

154137
assert(OrigFrontendOpts.InputsAndOutputs.hasPrimaryInputs() &&

lib/SIL/SILDeclRef.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,8 @@ SubclassScope SILDeclRef::getSubclassScope() const {
887887
if (isThunk() || isForeign)
888888
return SubclassScope::NotApplicable;
889889

890-
// Default arg generators only need to be visible in Swift 3.
891-
if (isDefaultArgGenerator() && !context->getASTContext().isSwiftVersion3())
890+
// Default arg generators are not visible.
891+
if (isDefaultArgGenerator())
892892
return SubclassScope::NotApplicable;
893893

894894
auto *classType = context->getSelfClassDecl();

lib/SILGen/SILGenBridging.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,14 +1425,10 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
14251425
}
14261426

14271427
if (auto attr = decl->getAttrs().getAttribute<ObjCAttr>()) {
1428-
// If @objc was inferred based on the Swift 3 @objc inference rules, but
1429-
// we aren't compiling in Swift 3 compatibility mode, emit a call to
1430-
// Builtin.swift3ImplicitObjCEntrypoint() to enable runtime logging of
1431-
// the uses of such entrypoints.
1432-
if (attr->isSwift3Inferred() &&
1433-
!decl->isDynamic() &&
1434-
!getASTContext().LangOpts.isSwiftVersion3()) {
1435-
1428+
// If @objc was inferred based on the Swift 3 @objc inference rules, emit
1429+
// a call to Builtin.swift3ImplicitObjCEntrypoint() to enable runtime
1430+
// logging of the uses of such entrypoints.
1431+
if (attr->isSwift3Inferred() && !decl->isDynamic()) {
14361432
// Get the starting source location of the declaration so we can say
14371433
// exactly where to stick '@objc'.
14381434
SourceLoc objcInsertionLoc =

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3084,16 +3084,14 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
30843084

30853085
break;
30863086

3087-
case CheckKind::WitnessUnavailable: {
3088-
bool emitError = !witness->getASTContext().LangOpts.isSwiftVersion3();
3089-
diagnoseOrDefer(requirement, /*isError=*/emitError,
3090-
[witness, requirement, emitError](
3087+
case CheckKind::WitnessUnavailable:
3088+
diagnoseOrDefer(requirement, /*isError=*/true,
3089+
[witness, requirement](
30913090
NormalProtocolConformance *conformance) {
30923091
auto &diags = witness->getASTContext().Diags;
30933092
SourceLoc diagLoc = getLocForDiagnosingWitness(conformance, witness);
30943093
diags.diagnose(diagLoc,
3095-
emitError ? diag::witness_unavailable
3096-
: diag::witness_unavailable_warn,
3094+
diag::witness_unavailable,
30973095
witness->getDescriptiveKind(),
30983096
witness->getFullName(),
30993097
conformance->getProtocol()->getFullName());
@@ -3104,7 +3102,6 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
31043102
});
31053103
break;
31063104
}
3107-
}
31083105

31093106
if (auto *classDecl = Adoptee->getClassOrBoundGenericClass()) {
31103107
if (!classDecl->isFinal()) {

lib/Sema/TypeCheckStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ void TypeChecker::checkDefaultArguments(ParameterList *params,
14951495
// caller.
14961496
if (auto *func = dyn_cast<AbstractFunctionDecl>(VD)) {
14971497
auto expansion = func->getResilienceExpansion();
1498-
if (!Context.isSwiftVersion3() && access.isPublic())
1498+
if (access.isPublic())
14991499
expansion = ResilienceExpansion::Minimal;
15001500

15011501
func->setDefaultArgumentResilienceExpansion(expansion);

lib/TBDGen/TBDGen.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
170170
addSymbol(SILDeclRef(AFD).asForeign());
171171
}
172172

173-
auto publicDefaultArgGenerators =
174-
SwiftModule->getASTContext().isSwiftVersion3() ||
175-
SwiftModule->isTestingEnabled();
173+
auto publicDefaultArgGenerators = SwiftModule->isTestingEnabled();
176174
if (!publicDefaultArgGenerators)
177175
return;
178176

0 commit comments

Comments
 (0)