Skip to content

Commit 1ae8e37

Browse files
committed
Remove -enable-protocol-typealiases staging flag
It looks like migration fixits are done, and this doesn't expose any new bugs that were not possible before, because you could already define typealiases inside protocol extensions. To prevent some compiler_crasher regressions, add a simple circularity-breaking hack. I'll need to do a sweep to clean these up some day soon.
1 parent d7a95e7 commit 1ae8e37

12 files changed

+12
-25
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,6 @@ ERROR(expected_close_after_else_directive,none,
778778
"further conditions after #else are unreachable", ())
779779

780780
/// Associatedtype Statement
781-
WARNING(typealias_in_protocol_deprecated,none,
782-
"use of 'typealias' to declare associated types is deprecated; use 'associatedtype' instead", ())
783781
ERROR(typealias_inside_protocol_without_type,none,
784782
"typealias is missing an assigned type; use 'associatedtype' to define an associated type requirement", ())
785783
ERROR(associatedtype_outside_protocol,none,

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ namespace swift {
170170
/// Enable the Swift 3 migration via Fix-Its.
171171
bool Swift3Migration = false;
172172

173-
/// Enable typealiases in protocols.
174-
bool EnableProtocolTypealiases = false;
175-
176173
/// Sets the target we are building for and updates platform conditions
177174
/// to match.
178175
///

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,6 @@ def enable_resilience : Flag<["-"], "enable-resilience">,
352352
def group_info_path : Separate<["-"], "group-info-path">,
353353
HelpText<"The path to collect the group information of the compiled module">;
354354

355-
def enable_protocol_typealiases: Flag<["-"], "enable-protocol-typealiases">,
356-
HelpText<"Enable typealiases inside protocol declarations">;
357-
358355
def enable_id_as_any: Flag<["-"], "enable-id-as-any">,
359356
HelpText<"Enable importing ObjC 'id' as Swift 'Any' type">;
360357

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
778778
Opts.InferImportAsMember |= Args.hasArg(OPT_enable_infer_import_as_member);
779779

780780
Opts.EnableThrowWithoutTry |= Args.hasArg(OPT_enable_throw_without_try);
781-
Opts.EnableProtocolTypealiases |= Args.hasArg(OPT_enable_protocol_typealiases);
782781
Opts.EnableIdAsAny |= Args.hasArg(OPT_enable_id_as_any);
783782

784783
if (auto A = Args.getLastArg(OPT_enable_objc_attr_requires_foundation_module,

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,12 +2083,7 @@ ParserStatus Parser::parseDecl(ParseDeclOptions Flags,
20832083
break;
20842084
}
20852085
case tok::kw_typealias:
2086-
if (Flags.contains(PD_InProtocol) &&
2087-
!Context.LangOpts.EnableProtocolTypealiases) {
2088-
DeclResult = parseDeclAssociatedType(Flags, Attributes);
2089-
} else {
2090-
DeclResult = parseDeclTypeAlias(Flags, Attributes);
2091-
}
2086+
DeclResult = parseDeclTypeAlias(Flags, Attributes);
20922087
Status = DeclResult;
20932088
break;
20942089
case tok::kw_associatedtype:
@@ -2979,10 +2974,7 @@ ParserResult<TypeDecl> Parser::parseDeclAssociatedType(Parser::ParseDeclOptions
29792974
// ask us to fix up leftover Swift 2 code intending to be an associatedtype.
29802975
if (Tok.is(tok::kw_typealias)) {
29812976
AssociatedTypeLoc = consumeToken(tok::kw_typealias);
2982-
auto diagnosis = Context.LangOpts.EnableProtocolTypealiases ?
2983-
diag::typealias_inside_protocol_without_type :
2984-
diag::typealias_in_protocol_deprecated;
2985-
diagnose(AssociatedTypeLoc, diagnosis)
2977+
diagnose(AssociatedTypeLoc, diag::typealias_inside_protocol_without_type)
29862978
.fixItReplace(AssociatedTypeLoc, "associatedtype");
29872979
} else {
29882980
AssociatedTypeLoc = consumeToken(tok::kw_associatedtype);

lib/Sema/TypeCheckType.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,10 @@ static Type resolveTypeDecl(TypeChecker &TC, TypeDecl *typeDecl, SourceLoc loc,
651651
} else {
652652
// Validate the declaration.
653653
TC.validateDecl(typeDecl);
654+
655+
// FIXME: More principled handling of circularity.
656+
if (!isa<AssociatedTypeDecl>(typeDecl) && !typeDecl->hasType())
657+
return ErrorType::get(TC.Context);
654658
}
655659

656660
// Resolve the type declaration to a specific type. How this occurs

test/Generics/associated_types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ struct C<a : B> : B { // expected-error {{type 'C<a>' does not conform to protoc
173173

174174
// SR-511
175175
protocol sr511 {
176-
typealias Foo // expected-warning {{use of 'typealias' to declare associated types is deprecated; use 'associatedtype' instead}}
176+
typealias Foo // expected-error {{typealias is missing an assigned type; use 'associatedtype' to define an associated type requirement}}
177177
}
178178

179179
associatedtype Foo = Int // expected-error {{associated types can only be defined in a protocol; define a type or introduce a 'typealias' to satisfy an associated type requirement}}

test/decl/typealias/protocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-parse-verify-swift -enable-protocol-typealiases
1+
// RUN: %target-parse-verify-swift
22

33
// Tests for typealias inside protocols
44

validation-test/compiler_crashers/28268-swift-type-transform.swift renamed to validation-test/compiler_crashers_fixed/28268-swift-type-transform.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
// See http://swift.org/LICENSE.txt for license information
66
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -parse
8+
// RUN: not %target-swift-frontend %s -parse
99
var:{protocol a{struct A:a
1010
typealias e=A.e

validation-test/compiler_crashers/28333-swift-typedecl-getdeclaredtype.swift renamed to validation-test/compiler_crashers_fixed/28333-swift-typedecl-getdeclaredtype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// See http://swift.org/LICENSE.txt for license information
66
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -parse
8+
// RUN: not %target-swift-frontend %s -parse
99
// REQUIRES: asserts
1010
protocol c{{}
1111
func c:f.a

validation-test/compiler_crashers/28360-swift-archetypebuilder-maptypeoutofcontext.swift renamed to validation-test/compiler_crashers_fixed/28360-swift-archetypebuilder-maptypeoutofcontext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
// See http://swift.org/LICENSE.txt for license information
66
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -parse
8+
// RUN: not %target-swift-frontend %s -parse
99
// REQUIRES: asserts
1010
struct A<f{protocol a{typealias f=B}struct B{let c=A.a as a

validation-test/compiler_crashers/28364-swift-typechecker-addimplicitconstructors.swift renamed to validation-test/compiler_crashers_fixed/28364-swift-typechecker-addimplicitconstructors.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// See http://swift.org/LICENSE.txt for license information
66
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -parse
8+
// RUN: not %target-swift-frontend %s -parse
99
// REQUIRES: asserts
1010
{
1111
protocol d{

0 commit comments

Comments
 (0)