Skip to content

Commit 268ce83

Browse files
committed
Revert "Turn off typealiases in protocols."
This reverts commit bda3983. It breaks the internal compiler build
1 parent 4c63b0a commit 268ce83

File tree

6 files changed

+13
-21
lines changed

6 files changed

+13
-21
lines changed

include/swift/AST/DiagnosticsParse.def

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

773773
/// Associatedtype Statement
774-
WARNING(typealias_in_protocol_deprecated,none,
775-
"use of 'typealias' to declare associated types is deprecated; use 'associatedtype' instead", ())
776774
ERROR(typealias_inside_protocol_without_type,none,
777775
"typealias is missing an assigned type; use 'associatedtype' to define an associated type requirement", ())
778776
ERROR(associatedtype_outside_protocol,none,

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,11 +2175,7 @@ ParserStatus Parser::parseDecl(ParseDeclOptions Flags,
21752175
break;
21762176
}
21772177
case tok::kw_typealias:
2178-
if (Flags.contains(PD_InProtocol)) {
2179-
DeclResult = parseDeclAssociatedType(Flags, Attributes);
2180-
} else {
2181-
DeclResult = parseDeclTypeAlias(Flags, Attributes);
2182-
}
2178+
DeclResult = parseDeclTypeAlias(Flags, Attributes);
21832179
Status = DeclResult;
21842180
break;
21852181
case tok::kw_associatedtype:
@@ -3025,7 +3021,7 @@ ParserResult<TypeDecl> Parser::parseDeclAssociatedType(Parser::ParseDeclOptions
30253021
// ask us to fix up leftover Swift 2 code intending to be an associatedtype.
30263022
if (Tok.is(tok::kw_typealias)) {
30273023
AssociatedTypeLoc = consumeToken(tok::kw_typealias);
3028-
diagnose(AssociatedTypeLoc, diag::typealias_in_protocol_deprecated)
3024+
diagnose(AssociatedTypeLoc, diag::typealias_inside_protocol_without_type)
30293025
.fixItReplace(AssociatedTypeLoc, "associatedtype");
30303026
} else {
30313027
AssociatedTypeLoc = consumeToken(tok::kw_associatedtype);

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/typealias.swift

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ struct MyType<TyA, TyB> {
2929

3030
protocol P {
3131
associatedtype X<T> // expected-error {{associated types may not have a generic parameter list}}
32-
// FIXME Disabled until typealiases in protocols are entirely fixed
33-
// typealias Y<T> // fixme-error {{expected '=' in typealias declaration}}
32+
33+
typealias Y<T> // expected-error {{expected '=' in typealias declaration}}
3434
}
3535

3636
typealias basicTypealias = Int
@@ -148,8 +148,6 @@ extension C<Int> {} // expected-error {{constrained extension must be declared
148148

149149

150150
// Allow typealias inside protocol, but don't allow it in where clauses (at least not yet)
151-
// FIXME Disabled until typealiases in protocols are entirely fixed
152-
/*
153151
protocol Col {
154152
associatedtype Elem
155153
var elem: Elem { get }
@@ -229,23 +227,23 @@ protocol P2 {
229227
associatedtype B
230228
}
231229

232-
func go3<T : P1, U : P2 where T.F == U.B>(_ x: T) -> U { // fixme-error {{typealias 'F' is too complex to be used as a generic constraint; use an associatedtype instead}} fixme-error {{'F' is not a member type of 'T'}}
230+
func go3<T : P1, U : P2 where T.F == U.B>(_ x: T) -> U { // expected-error {{typealias 'F' is too complex to be used as a generic constraint; use an associatedtype instead}} expected-error {{'F' is not a member type of 'T'}}
233231
}
234232

235233
// Specific diagnosis for things that look like Swift 2.x typealiases
236234
protocol P3 {
237-
typealias T // fixme-error {{typealias is missing an assigned type; use 'associatedtype' to define an associated type requirement}}
238-
typealias U : P2 // fixme-error {{typealias is missing an assigned type; use 'associatedtype' to define an associated type requirement}}
235+
typealias T // expected-error {{typealias is missing an assigned type; use 'associatedtype' to define an associated type requirement}}
236+
typealias U : P2 // expected-error {{typealias is missing an assigned type; use 'associatedtype' to define an associated type requirement}}
239237

240-
associatedtype V : P2 = // fixme-error {{expected type in associatedtype declaration}}
238+
associatedtype V : P2 = // expected-error {{expected type in associatedtype declaration}}
241239
}
242240

243241
// Test for not crashing on self and recursive aliases
244242
protocol P4 {
245243
typealias X = Self
246-
typealias Y = Self.Y // fixme-error {{type alias 'Y' circularly references itself}}
244+
typealias Y = Self.Y // expected-error {{type alias 'Y' circularly references itself}}
247245

248246
func getSelf() -> X
249247
}
250-
*/
248+
251249

validation-test/compiler_crashers_fixed/28288-swift-genericparamlist-getsubstitutionmap.swift renamed to validation-test/compiler_crashers/28288-swift-genericparamlist-getsubstitutionmap.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 %target-swift-frontend %s -parse
8+
// RUN: not --crash %target-swift-frontend %s -parse
99
// REQUIRES: asserts
1010
protocol A{
1111
typealias B<a>:A

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

0 commit comments

Comments
 (0)