Skip to content

Remove remaining isSwiftVersion3() checks #20161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 31, 2018
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
3 changes: 0 additions & 3 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,6 @@ class ASTContext final {
CanGenericSignature getExistentialSignature(CanType existential,
ModuleDecl *mod);

/// Whether our effective Swift version is in the Swift 3 family.
bool isSwiftVersion3() const { return LangOpts.isSwiftVersion3(); }

/// Whether our effective Swift version is at least 'major'.
///
/// This is usually the check you want; for example, when introducing
Expand Down
3 changes: 0 additions & 3 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -1865,9 +1865,6 @@ NOTE(declared_protocol_conformance_here,none,
"%0 implicitly conforms to protocol %2}1 here",
(Type, unsigned, DeclName, DeclName))

WARNING(witness_unavailable_warn,none,
"unavailable %0 %1 was used to satisfy a requirement of protocol %2",
(DescriptiveDeclKind, DeclName, DeclName))
ERROR(witness_unavailable,none,
"unavailable %0 %1 was used to satisfy a requirement of protocol %2",
(DescriptiveDeclKind, DeclName, DeclName))
Expand Down
5 changes: 0 additions & 5 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,6 @@ namespace swift {
return CustomConditionalCompilationFlags;
}

/// Whether our effective Swift version is in the Swift 3 family
bool isSwiftVersion3() const {
return EffectiveLanguageVersion.isVersion3();
}

/// Whether our effective Swift version is at least 'major'.
///
/// This is usually the check you want; for example, when introducing
Expand Down
3 changes: 0 additions & 3 deletions include/swift/Basic/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ class Version {
/// compiler to act as if it is version 3.1.
Optional<Version> getEffectiveLanguageVersion() const;

/// Whether this version is in the Swift 3 family
bool isVersion3() const { return !empty() && Components[0] == 3; }

/// Whether this version is greater than or equal to the given major version
/// number.
bool isVersionAtLeast(unsigned major, unsigned minor = 0) const {
Expand Down
9 changes: 4 additions & 5 deletions lib/ClangImporter/ClangAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,11 +741,10 @@ OptionalTypeKind importer::getParamOptionality(version::Version swiftVersion,
return OTK_None;

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

// Default to implicitly unwrapped optionals.
return OTK_ImplicitlyUnwrappedOptional;
Expand Down
3 changes: 1 addition & 2 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,

Opts.EnableSwift3ObjCInference =
Args.hasFlag(OPT_enable_swift3_objc_inference,
OPT_disable_swift3_objc_inference,
Opts.isSwiftVersion3());
OPT_disable_swift3_objc_inference, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope we can kill this, too. Is that a separate task?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I’d like to consider it separate since it’s pretty self contained.


if (Opts.EnableSwift3ObjCInference) {
if (const Arg *A = Args.getLastArg(
Expand Down
17 changes: 0 additions & 17 deletions lib/Migrator/Migrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,6 @@ Migrator::performAFixItMigration(version::Version SwiftLanguageVersion) {
LLVMArgs.erase(aarch64_use_tbi);
}

if (StartInvocation.getLangOptions().EffectiveLanguageVersion.isVersion3()) {
// SE-0160: When migrating, always use the Swift 3 @objc inference rules,
// which drives warnings with the "@objc" Fix-Its.
Invocation.getLangOptions().EnableSwift3ObjCInference = true;

// The default behavior of the migrator, referred to as "minimal" migration
// in SE-0160, only adds @objc Fix-Its to those cases where the Objective-C
// entry point is explicitly used somewhere in the source code. The user
// may also select a workflow that adds @objc for every declaration that
// would infer @objc under the Swift 3 rules but would no longer infer
// @objc in Swift 4.
Invocation.getLangOptions().WarnSwift3ObjCInference =
getMigratorOptions().KeepObjcVisibility
? Swift3ObjCInferenceWarnings::Complete
: Swift3ObjCInferenceWarnings::Minimal;
}

const auto &OrigFrontendOpts = StartInvocation.getFrontendOptions();

assert(OrigFrontendOpts.InputsAndOutputs.hasPrimaryInputs() &&
Expand Down
4 changes: 2 additions & 2 deletions lib/SIL/SILDeclRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,8 @@ SubclassScope SILDeclRef::getSubclassScope() const {
if (isThunk() || isForeign)
return SubclassScope::NotApplicable;

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

auto *classType = context->getSelfClassDecl();
Expand Down
12 changes: 4 additions & 8 deletions lib/SILGen/SILGenBridging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,14 +1425,10 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
}

if (auto attr = decl->getAttrs().getAttribute<ObjCAttr>()) {
// If @objc was inferred based on the Swift 3 @objc inference rules, but
// we aren't compiling in Swift 3 compatibility mode, emit a call to
// Builtin.swift3ImplicitObjCEntrypoint() to enable runtime logging of
// the uses of such entrypoints.
if (attr->isSwift3Inferred() &&
!decl->isDynamic() &&
!getASTContext().LangOpts.isSwiftVersion3()) {

// If @objc was inferred based on the Swift 3 @objc inference rules, emit
// a call to Builtin.swift3ImplicitObjCEntrypoint() to enable runtime
// logging of the uses of such entrypoints.
if (attr->isSwift3Inferred() && !decl->isDynamic()) {
// Get the starting source location of the declaration so we can say
// exactly where to stick '@objc'.
SourceLoc objcInsertionLoc =
Expand Down
11 changes: 4 additions & 7 deletions lib/Sema/TypeCheckProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3084,16 +3084,14 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {

break;

case CheckKind::WitnessUnavailable: {
bool emitError = !witness->getASTContext().LangOpts.isSwiftVersion3();
diagnoseOrDefer(requirement, /*isError=*/emitError,
[witness, requirement, emitError](
case CheckKind::WitnessUnavailable:
diagnoseOrDefer(requirement, /*isError=*/true,
[witness, requirement](
NormalProtocolConformance *conformance) {
auto &diags = witness->getASTContext().Diags;
SourceLoc diagLoc = getLocForDiagnosingWitness(conformance, witness);
diags.diagnose(diagLoc,
emitError ? diag::witness_unavailable
: diag::witness_unavailable_warn,
diag::witness_unavailable,
witness->getDescriptiveKind(),
witness->getFullName(),
conformance->getProtocol()->getFullName());
Expand All @@ -3104,7 +3102,6 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
});
break;
}
}

if (auto *classDecl = Adoptee->getClassOrBoundGenericClass()) {
if (!classDecl->isFinal()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ void TypeChecker::checkDefaultArguments(ParameterList *params,
// caller.
if (auto *func = dyn_cast<AbstractFunctionDecl>(VD)) {
auto expansion = func->getResilienceExpansion();
if (!Context.isSwiftVersion3() && access.isPublic())
if (access.isPublic())
expansion = ResilienceExpansion::Minimal;

func->setDefaultArgumentResilienceExpansion(expansion);
Expand Down
4 changes: 1 addition & 3 deletions lib/TBDGen/TBDGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
addSymbol(SILDeclRef(AFD).asForeign());
}

auto publicDefaultArgGenerators =
SwiftModule->getASTContext().isSwiftVersion3() ||
SwiftModule->isTestingEnabled();
auto publicDefaultArgGenerators = SwiftModule->isTestingEnabled();
if (!publicDefaultArgGenerators)
return;

Expand Down