mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Adds an associatedtype keyword to the parser tokens, and accepts either typealias or associatedtype to create an AssociatedTypeDecl, warning that the former is deprecated. The ASTPrinter now emits associatedtype for AssociatedTypeDecls. Separated AssociatedType from TypeAlias as two different kinds of CodeCompletionDeclKinds. This part probably doesn’t turn out to be absolutely necessary currently, but it is nice cleanup from formerly specifically glomming the two together. And then many, many changes to tests. The actual new tests for the fixits is at the end of Generics/associated_types.swift.
23 lines
709 B
Swift
23 lines
709 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
protocol SomeProtocol {
|
|
associatedtype T
|
|
}
|
|
|
|
extension SomeProtocol where T == Optional<T> { } // expected-error{{same-type constraint 'Self.T' == 'Optional<Self.T>' is recursive}}
|
|
|
|
// rdar://problem/20000145
|
|
public protocol P {
|
|
associatedtype T
|
|
}
|
|
public struct S<A: P where A.T == S<A>> {}
|
|
|
|
// rdar://problem/19840527
|
|
class X<T where T == X> { // expected-error{{same-type requirement makes generic parameter 'T' non-generic}}
|
|
var type: T { return self.dynamicType } // expected-error{{cannot convert return expression of type 'X<T>.Type' to return type 'T'}}
|
|
}
|
|
|
|
protocol Y {
|
|
associatedtype Z = Z // expected-error{{type alias 'Z' circularly references itself}}
|
|
}
|