Skip to content

Commit 335d6ff

Browse files
committed
Frontend: Add -disable-experimental-associated-type-inference flag
1 parent d5bf5e3 commit 335d6ff

14 files changed

+23
-16
lines changed

include/swift/Basic/Features.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ EXPERIMENTAL_FEATURE(MoveOnlyTuples, true)
151151
EXPERIMENTAL_FEATURE(MoveOnlyPartialConsumption, true)
152152

153153
EXPERIMENTAL_FEATURE(OneWayClosureParameters, false)
154-
EXPERIMENTAL_FEATURE(TypeWitnessSystemInference, false)
155154
EXPERIMENTAL_FEATURE(LayoutPrespecialization, true)
156155

157156
EXPERIMENTAL_FEATURE(AccessLevelOnImport, true)

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,9 @@ namespace swift {
585585
/// Enable warnings for redundant requirements in generic signatures.
586586
bool WarnRedundantRequirements = false;
587587

588+
/// Enable experimental associated type inference improvements.
589+
bool EnableExperimentalAssociatedTypeInference = false;
590+
588591
/// Enables dumping type witness systems from associated type inference.
589592
bool DumpTypeWitnessSystems = false;
590593

include/swift/Option/FrontendOptions.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,11 @@ def disable_experimental_string_processing :
654654

655655
def enable_experimental_associated_type_inference :
656656
Flag<["-"], "enable-experimental-associated-type-inference">,
657-
HelpText<"Enable experimental associated type inference via type witness systems">;
657+
HelpText<"Enable experimental associated type inference improvements">;
658+
659+
def disable_experimental_associated_type_inference :
660+
Flag<["-"], "disable-experimental-associated-type-inference">,
661+
HelpText<"Disable experimental associated type inference improvements">;
658662

659663
def disable_availability_checking : Flag<["-"],
660664
"disable-availability-checking">,

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,10 +3479,6 @@ static bool usesFeatureOneWayClosureParameters(Decl *decl) {
34793479
return false;
34803480
}
34813481

3482-
static bool usesFeatureTypeWitnessSystemInference(Decl *decl) {
3483-
return false;
3484-
}
3485-
34863482
static bool usesFeatureOpaqueTypeErasure(Decl *decl) {
34873483
return false;
34883484
}

lib/AST/ProtocolConformance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ NormalProtocolConformance::getAssociatedConformance(Type assocType,
548548
forEachAssociatedConformance(
549549
[&](Type t, ProtocolDecl *p, unsigned index) {
550550
if (t->isEqual(assocType) && p == protocol) {
551-
if (!ctx.LangOpts.hasFeature(Feature::TypeWitnessSystemInference)) {
551+
if (!ctx.LangOpts.EnableExperimentalAssociatedTypeInference) {
552552
// Fill in the signature conformances, if we haven't done so yet.
553553
if (!hasComputedAssociatedConformances()) {
554554
const_cast<NormalProtocolConformance *>(this)

lib/Frontend/CompilerInvocation.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
910910
}
911911
if (Args.hasArg(OPT_experimental_one_way_closure_params))
912912
Opts.Features.insert(Feature::OneWayClosureParameters);
913-
if (Args.hasArg(OPT_enable_experimental_associated_type_inference))
914-
Opts.Features.insert(Feature::TypeWitnessSystemInference);
915913
if (Args.hasArg(OPT_enable_experimental_forward_mode_differentiation))
916914
Opts.Features.insert(Feature::ForwardModeDifferentiation);
917915
if (Args.hasArg(OPT_enable_experimental_additive_arithmetic_derivation))
@@ -1351,6 +1349,11 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
13511349
if (Args.hasArg(OPT_warn_redundant_requirements))
13521350
Opts.WarnRedundantRequirements = true;
13531351

1352+
if (Args.hasArg(OPT_enable_experimental_associated_type_inference))
1353+
Opts.EnableExperimentalAssociatedTypeInference = true;
1354+
if (Args.hasArg(OPT_disable_experimental_associated_type_inference))
1355+
Opts.EnableExperimentalAssociatedTypeInference = false;
1356+
13541357
Opts.DumpTypeWitnessSystems = Args.hasArg(OPT_dump_type_witness_systems);
13551358

13561359
for (auto &block: FrontendOpts.BlocklistConfigFilePaths)

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ AssociatedTypeDecl *AssociatedTypeInference::inferAbstractTypeWitnesses(
13741374
// not resolve otherwise.
13751375
llvm::SmallVector<AbstractTypeWitness, 2> abstractTypeWitnesses;
13761376

1377-
if (ctx.LangOpts.hasFeature(Feature::TypeWitnessSystemInference)) {
1377+
if (ctx.LangOpts.EnableExperimentalAssociatedTypeInference) {
13781378
TypeWitnessSystem system(unresolvedAssocTypes);
13791379
collectAbstractTypeWitnesses(system, unresolvedAssocTypes);
13801380

test/decl/protocol/req/associated_type_inference_fixed_type.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift
1+
// RUN: %target-typecheck-verify-swift -disable-experimental-associated-type-inference
22

33
protocol P1 where A == Never {
44
associatedtype A

test/decl/protocol/req/associated_type_inference_stdlib.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -enable-experimental-associated-type-inference
2-
// RUN: %target-typecheck-verify-swift
2+
// RUN: %target-typecheck-verify-swift -disable-experimental-associated-type-inference
33

44
// We would fail here when Indices was explicitly specified, as in X2.
55

test/decl/protocol/req/associated_type_inference_stdlib_2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -enable-experimental-associated-type-inference
2-
// RUN: not %target-typecheck-verify-swift
2+
// RUN: not %target-typecheck-verify-swift -disable-experimental-associated-type-inference
33

44
protocol IP {
55
associatedtype E

test/decl/protocol/req/rdar118998138.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -enable-experimental-associated-type-inference
2-
// RUN: not %target-typecheck-verify-swift
2+
// RUN: not %target-typecheck-verify-swift -disable-experimental-associated-type-inference
33

44
public protocol FakeCopyable {}
55

test/decl/protocol/req/rdar90402522.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -enable-experimental-associated-type-inference
2-
// RUN: %target-typecheck-verify-swift
2+
// RUN: %target-typecheck-verify-swift -disable-experimental-associated-type-inference
33

44
public typealias A = UInt32
55

validation-test/compiler_crashers_2_fixed/issue-53793.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -verify -emit-ir %s
1+
// RUN: %target-swift-frontend -disable-experimental-associated-type-inference -verify -emit-ir %s
22

33
// Works with experimental associated type inference.
44
// RUN: %target-swift-frontend -enable-experimental-associated-type-inference -emit-ir %s

validation-test/compiler_crashers_2_fixed/rdar110806272.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: not %target-swift-frontend -typecheck %s -enable-experimental-associated-type-inference
22

3+
// This code is invalid, but we shouldn't crash.
4+
35
struct SyntaxCollectionIterator<E: SyntaxProtocol>: IteratorProtocol {
46
typealias Element = E
57
}

0 commit comments

Comments
 (0)