Skip to content

Remove -enable-protocol-typealiases staging flag #3738

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
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
2 changes: 0 additions & 2 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,6 @@ ERROR(expected_close_after_else_directive,none,
"further conditions after #else are unreachable", ())

/// Associatedtype Statement
WARNING(typealias_in_protocol_deprecated,none,
"use of 'typealias' to declare associated types is deprecated; use 'associatedtype' instead", ())
ERROR(typealias_inside_protocol_without_type,none,
"typealias is missing an assigned type; use 'associatedtype' to define an associated type requirement", ())
ERROR(associatedtype_outside_protocol,none,
Expand Down
3 changes: 0 additions & 3 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ namespace swift {
/// Enable the Swift 3 migration via Fix-Its.
bool Swift3Migration = false;

/// Enable typealiases in protocols.
bool EnableProtocolTypealiases = false;

/// Sets the target we are building for and updates platform conditions
/// to match.
///
Expand Down
3 changes: 0 additions & 3 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,6 @@ def enable_resilience : Flag<["-"], "enable-resilience">,
def group_info_path : Separate<["-"], "group-info-path">,
HelpText<"The path to collect the group information of the compiled module">;

def enable_protocol_typealiases: Flag<["-"], "enable-protocol-typealiases">,
HelpText<"Enable typealiases inside protocol declarations">;

def enable_id_as_any: Flag<["-"], "enable-id-as-any">,
HelpText<"Enable importing ObjC 'id' as Swift 'Any' type">;

Expand Down
1 change: 0 additions & 1 deletion lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.InferImportAsMember |= Args.hasArg(OPT_enable_infer_import_as_member);

Opts.EnableThrowWithoutTry |= Args.hasArg(OPT_enable_throw_without_try);
Opts.EnableProtocolTypealiases |= Args.hasArg(OPT_enable_protocol_typealiases);
Opts.EnableIdAsAny |= Args.hasArg(OPT_enable_id_as_any);

if (auto A = Args.getLastArg(OPT_enable_objc_attr_requires_foundation_module,
Expand Down
12 changes: 2 additions & 10 deletions lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2083,12 +2083,7 @@ ParserStatus Parser::parseDecl(ParseDeclOptions Flags,
break;
}
case tok::kw_typealias:
if (Flags.contains(PD_InProtocol) &&
!Context.LangOpts.EnableProtocolTypealiases) {
DeclResult = parseDeclAssociatedType(Flags, Attributes);
} else {
DeclResult = parseDeclTypeAlias(Flags, Attributes);
}
DeclResult = parseDeclTypeAlias(Flags, Attributes);
Status = DeclResult;
break;
case tok::kw_associatedtype:
Expand Down Expand Up @@ -2979,10 +2974,7 @@ ParserResult<TypeDecl> Parser::parseDeclAssociatedType(Parser::ParseDeclOptions
// ask us to fix up leftover Swift 2 code intending to be an associatedtype.
if (Tok.is(tok::kw_typealias)) {
AssociatedTypeLoc = consumeToken(tok::kw_typealias);
auto diagnosis = Context.LangOpts.EnableProtocolTypealiases ?
diag::typealias_inside_protocol_without_type :
diag::typealias_in_protocol_deprecated;
diagnose(AssociatedTypeLoc, diagnosis)
diagnose(AssociatedTypeLoc, diag::typealias_inside_protocol_without_type)
.fixItReplace(AssociatedTypeLoc, "associatedtype");
} else {
AssociatedTypeLoc = consumeToken(tok::kw_associatedtype);
Expand Down
4 changes: 4 additions & 0 deletions lib/Sema/TypeCheckType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ static Type resolveTypeDecl(TypeChecker &TC, TypeDecl *typeDecl, SourceLoc loc,
} else {
// Validate the declaration.
TC.validateDecl(typeDecl);

// FIXME: More principled handling of circularity.
if (!isa<AssociatedTypeDecl>(typeDecl) && !typeDecl->hasType())
return ErrorType::get(TC.Context);
}

// Resolve the type declaration to a specific type. How this occurs
Expand Down
2 changes: 1 addition & 1 deletion test/Generics/associated_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ struct C<a : B> : B { // expected-error {{type 'C<a>' does not conform to protoc

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

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}}
Expand Down
2 changes: 1 addition & 1 deletion test/decl/typealias/protocol.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-parse-verify-swift -enable-protocol-typealiases
// RUN: %target-parse-verify-swift

// Tests for typealias inside protocols

Expand Down
6 changes: 3 additions & 3 deletions utils/resolve-crashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def execute_cmd(cmd):

# The regular expression we use to match compiler-crasher lines.
regex = re.compile(
'.*Swift :: '
'.*Swift(.*) :: '
'(compiler_crashers|compiler_crashers_2|IDE/crashers)/(.*\.swift).*')

# Take the output of lit as standard input.
for line in sys.stdin:
match = regex.match(line)
if match:
suffix = match.group(1)
filename = match.group(2)
suffix = match.group(2)
filename = match.group(3)

# Move the test over to the fixed suite.
from_filename = 'validation-test/%s/%s' % (suffix, filename)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

// RUN: not --crash %target-swift-frontend %s -parse
// RUN: not %target-swift-frontend %s -parse
var:{protocol a{struct A:a
typealias e=A.e
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

// RUN: not --crash %target-swift-frontend %s -parse
// RUN: not %target-swift-frontend %s -parse
// REQUIRES: asserts
protocol c{{}
func c:f.a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

// RUN: not --crash %target-swift-frontend %s -parse
// RUN: not %target-swift-frontend %s -parse
// REQUIRES: asserts
struct A<f{protocol a{typealias f=B}struct B{let c=A.a as a
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

// RUN: not --crash %target-swift-frontend %s -parse
// RUN: not %target-swift-frontend %s -parse
// REQUIRES: asserts
{
protocol d{
Expand Down