mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
784 lines
10 KiB
Swift
784 lines
10 KiB
Swift
// This source file is part of the Swift.org open source project
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
|
|
// RUN: not %target-swift-frontend %s -typecheck
|
|
func i(f: g) -> <j>(() -> j) -> g { func g
|
|
k, l {
|
|
typealias l = m<k<m>, f>
|
|
}
|
|
func ^(a: Boolean, Bool) -> Bool {
|
|
return !(a)
|
|
}
|
|
func b(c) -> <d>(() -> d) {
|
|
}
|
|
func q(v: h) -> <r>(() -> r) -> h {
|
|
n { u o "\(v): \(u())" }
|
|
}
|
|
struct e<r> {
|
|
j p: , () -> ())] = []
|
|
}
|
|
protocol p {
|
|
}
|
|
protocol m : p {
|
|
}
|
|
protocol v : p {
|
|
}
|
|
protocol m {
|
|
v = m
|
|
}
|
|
func s<s : m, v : m u v.v == s> (m: v) {
|
|
}
|
|
func s<v : m u v.v == v> (m: v) {
|
|
}
|
|
s( {
|
|
({})
|
|
}
|
|
t
|
|
func f<e>() -> (e, e -> e) -> e {
|
|
e b e.c = {}
|
|
{
|
|
e)
|
|
{
|
|
f
|
|
}
|
|
}
|
|
protocol f {
|
|
class func c()
|
|
}
|
|
class e: f {
|
|
class func c
|
|
}
|
|
}
|
|
protocol A {
|
|
func c()l k {
|
|
func l() -> g {
|
|
m ""
|
|
}
|
|
}
|
|
class C: k, A {
|
|
j func l()q c() -> g {
|
|
m ""
|
|
}
|
|
}
|
|
func e<r where r: A, r: k>(n: r) {
|
|
n.c()
|
|
}
|
|
protocol A {
|
|
typealias h
|
|
}
|
|
c k<r : A> {
|
|
p f: r
|
|
p p: r.h
|
|
}
|
|
protocol C l.e()
|
|
}
|
|
}
|
|
class o {
|
|
typealias l = l
|
|
protocol a {
|
|
}
|
|
protocol h : a {
|
|
}
|
|
protocol k : a {
|
|
}
|
|
protocol g {
|
|
j n = a
|
|
}
|
|
struct n : g {
|
|
j n = h
|
|
}
|
|
func i<h : h, f : g m f.n == h> (g: f) {
|
|
}
|
|
func i<n : g m n.n = o) {
|
|
}
|
|
let k = a
|
|
k()
|
|
h
|
|
protocol k : h { func h
|
|
k
|
|
func f(k: Any, j: Any) -> (((Any, Any) -> Any) -> c
|
|
k)
|
|
func c<i>() -> (i, i -> i) -> i {
|
|
k b k.i = {
|
|
}
|
|
{
|
|
i) {
|
|
k }
|
|
}
|
|
protocol c {
|
|
class func i()
|
|
}
|
|
class k: c{ class func i {
|
|
}
|
|
class i {
|
|
func d((h: (Any, AnyObject)) {
|
|
d(h)
|
|
}
|
|
}
|
|
d
|
|
h)
|
|
func d<i>() -> (i, i -> i) -> i {
|
|
i j i.f = {
|
|
}
|
|
protocol d {
|
|
class func f()
|
|
}
|
|
class i: d{ class func f {}
|
|
protocol a {
|
|
}
|
|
protocol b : a {
|
|
}
|
|
protocol c : a {
|
|
}
|
|
protocol d {
|
|
typealias f = a
|
|
}
|
|
struct e : d {
|
|
typealias f = b
|
|
}
|
|
func i<j : b, k : d where k.f == j> (n: k) {
|
|
}
|
|
func i<l : d where l.f == c> (n: l) {
|
|
}
|
|
i(e())
|
|
class l {
|
|
func f((k, l() -> f
|
|
}
|
|
class d
|
|
}
|
|
class i: d, g {
|
|
l func d() -> f {
|
|
m ""
|
|
}
|
|
}
|
|
}
|
|
func m<j n j: g, j: d
|
|
let l = h
|
|
l()
|
|
f
|
|
protocol l : f { func f
|
|
protocol g
|
|
func g<h>() -> (h, h -> h) -> h {
|
|
f f: ((h, h -> h) -> h)!
|
|
j f
|
|
}
|
|
protocol f {
|
|
class func j()
|
|
}
|
|
struct i {
|
|
f d: f.i
|
|
func j() {
|
|
d.j()
|
|
}
|
|
}
|
|
class g {
|
|
typealias f = f
|
|
}
|
|
func g(f: Int = k) {
|
|
}
|
|
let i = g
|
|
class k {
|
|
func l((Any, k))(m }
|
|
}
|
|
func j<f: l: e -> e = {
|
|
{
|
|
l) {
|
|
m }
|
|
}
|
|
protocol k {
|
|
class func j()
|
|
}
|
|
class e: k{ class func j
|
|
struct c<d : Sequence> {
|
|
var b: [c<d>] {
|
|
return []
|
|
}
|
|
protocol a {
|
|
class func c()
|
|
}
|
|
class b: a {
|
|
class func c() { }
|
|
}
|
|
(b() as a).dynamicType.c()
|
|
func f<T : Boolean>(b: T) {
|
|
}
|
|
f(true as Boolean)
|
|
func a(x: Any, y: Any) -> (((Any, Any) -> Any) -> A var d: b.Type
|
|
func e() {
|
|
d.e()
|
|
}
|
|
}
|
|
b
|
|
protocol c : b { func b
|
|
otocol A {
|
|
E == F>(f: B<T>)
|
|
}
|
|
struct }
|
|
}
|
|
struct c<d : Sequence> {
|
|
var b: d
|
|
}
|
|
func a<d>() -> [c<d>] {
|
|
return []
|
|
}
|
|
func ^(d: e, Bool) -> Bool {g !(d)
|
|
}
|
|
protocol d {
|
|
f func g()
|
|
f e: d {
|
|
f func g() { }
|
|
}
|
|
(e() h d).i()
|
|
e
|
|
protocol g : e { func e
|
|
func a(b: Int = 0) {
|
|
}
|
|
let c = a
|
|
c()
|
|
var f = 1
|
|
var e: Int -> Int = {
|
|
return $0
|
|
}
|
|
let d: Int = { c, b in
|
|
}(f, e)
|
|
func m<u>() -> (u, u -> u) -> u {
|
|
p o p.s = {
|
|
}
|
|
{
|
|
u) {
|
|
o }
|
|
}
|
|
s m {
|
|
class func s()
|
|
}
|
|
class p: m{ class func s {}
|
|
s p {
|
|
func m() -> String
|
|
}
|
|
class n {
|
|
func p() -> String {
|
|
q ""
|
|
}
|
|
}
|
|
class e: n, p {
|
|
v func> String {
|
|
q ""
|
|
}
|
|
{
|
|
r m = m
|
|
}
|
|
func s<o : m, o : p o o.m == o> (m: o) {
|
|
}
|
|
func s<v : p o v.m == m> (u: String) -> <t>(() -> t) -
|
|
func p<p>() -> (p, p -> p) -> p {
|
|
l c l.l = {
|
|
}
|
|
{
|
|
p) {
|
|
(e: o, h:o) -> e
|
|
})
|
|
}
|
|
j(k(m, k(2, 3)))
|
|
func l(p: j) -> <n>(() -> n
|
|
struct c<d: Sequence, b where Optional<b> == d.Iterator.Element>
|
|
d = i
|
|
}
|
|
class d<j : i, f : i where j.i == f> : e {
|
|
}
|
|
class d<j, f> {
|
|
}
|
|
protocol i {
|
|
typealias i
|
|
}
|
|
protocol e {
|
|
class func i()
|
|
}
|
|
i
|
|
(d() as e).j.i()
|
|
d
|
|
protocol i : d { func d
|
|
class k<g>: d {
|
|
var f: g
|
|
init(f: g) {
|
|
self.f = f
|
|
l. d {
|
|
typealias i = l
|
|
typealias j = j<i<l>, i>
|
|
}
|
|
class j {
|
|
typealias d = d
|
|
struct A<T> {
|
|
let a: [(T, () -> ())] = []
|
|
}
|
|
func b<d-> d { class d:b class b
|
|
class A<T : A> {
|
|
}
|
|
func c<d {
|
|
enum c {
|
|
func e
|
|
var _ = e
|
|
}
|
|
}
|
|
protocol a {
|
|
class func c()
|
|
}
|
|
class b: a {
|
|
class func c() { }
|
|
}
|
|
(b() as a).dynamicl A {
|
|
{
|
|
typealias b = b
|
|
d.i = {
|
|
}
|
|
{
|
|
g) {
|
|
h }
|
|
}
|
|
protocol f {
|
|
class func i()
|
|
}}
|
|
func f<m>() -> (m, m -> m) -> m {
|
|
e c e.i = {
|
|
}
|
|
{
|
|
m) {
|
|
n }
|
|
}
|
|
protocol f {
|
|
class func i()
|
|
}
|
|
class e: f{ class func i {}
|
|
func n<j>() -> (j, j -> j) -> j {
|
|
var m: ((j> j)!
|
|
f m
|
|
}
|
|
protocol k {
|
|
typealias m
|
|
}
|
|
struct e<j : k> {n: j
|
|
let i: j.m
|
|
}
|
|
l
|
|
func m(c: b) -> <h>(() -> h) -> b {
|
|
f) -> j) -> > j {
|
|
l i !(k)
|
|
}
|
|
d
|
|
l)
|
|
func d<m>-> (m, m -
|
|
import Foundation
|
|
class Foo<T>: NSObject {
|
|
var foo: T
|
|
init(foo: T) {
|
|
B>(t: T) {
|
|
t.c()
|
|
} x
|
|
x) {
|
|
}
|
|
class a {
|
|
var _ = i() {
|
|
}
|
|
}
|
|
a=1 as a=1
|
|
func k<q>() -> [n<q>] {
|
|
r []
|
|
}
|
|
func k(l: Int = 0) {
|
|
}
|
|
n n = k
|
|
n()
|
|
func n<q {
|
|
l n {
|
|
func o
|
|
o _ = o
|
|
}
|
|
}
|
|
func ^(k: m, q) -> q {
|
|
r !(k)
|
|
}
|
|
protocol k {
|
|
j q
|
|
j o = q
|
|
j f = q
|
|
}
|
|
class l<r : n, l : n p r.q == l> : k {
|
|
}
|
|
class l<r, l> {
|
|
}
|
|
protocol n {
|
|
j q
|
|
}
|
|
protocol k : k {
|
|
}
|
|
class k<f : l, q : l p f.q == q> {
|
|
}
|
|
protocol l {
|
|
j q
|
|
j o
|
|
}
|
|
struct n<r : l>
|
|
func k<q {
|
|
enum k {
|
|
func j
|
|
var _ = j
|
|
}
|
|
}
|
|
class x {
|
|
s m
|
|
func j(m)
|
|
}
|
|
struct j<u> : r {
|
|
func j(j: j.n) {
|
|
}
|
|
}
|
|
enum q<v> { let k: v
|
|
let u: v.l
|
|
}
|
|
protocol y {
|
|
o= p>(r: m<v>)
|
|
}
|
|
struct D : y {
|
|
s p = Int
|
|
func y<v k r {
|
|
s m
|
|
}
|
|
class y<D> {
|
|
w <r:
|
|
func j<v x: v) {
|
|
x.k()
|
|
}
|
|
func x(j: Int = a) {
|
|
}
|
|
let k = x
|
|
func b((Any, e))(e: (Any) -> <d>(()-> d) -> f
|
|
func a(x: Any, y: Any) -> (((Any, Any) -> Any) -> Any) {
|
|
return {
|
|
(m: (Any, Any) -> Any) -> Any in
|
|
return m(x, y)
|
|
}
|
|
}
|
|
func b(z: (((Any, Any) -> Any) -> Any)) -> Any {
|
|
return z({
|
|
(p: Any, q:Any) -> Any in
|
|
return p
|
|
})
|
|
}
|
|
b(a(1, a(2, 3)))
|
|
protocol f : f {
|
|
}
|
|
func h<d {
|
|
enum h {
|
|
func e
|
|
var _ = e
|
|
}
|
|
}
|
|
protocol e {
|
|
e func e()
|
|
}
|
|
struct h {
|
|
var d: e.h
|
|
func e() {
|
|
d.e()
|
|
}
|
|
}
|
|
protocol f {
|
|
i []
|
|
}
|
|
func f<g>() -> (g, g -> g) -> g
|
|
class A<T : A> n = {
|
|
return $u
|
|
}
|
|
l o: n = { (d: n, o: n -> n) -> n q
|
|
return o(d)
|
|
}
|
|
import Foundation
|
|
class m<j>: NSObject {
|
|
var h: j
|
|
g -> k = l $n
|
|
}
|
|
b f: _ = j() {
|
|
}
|
|
}
|
|
func k<g {
|
|
enum k {
|
|
func l
|
|
var _ = l
|
|
func o() as o).m.k()
|
|
func p(k: b) -> <i>(() -> i) -> b {
|
|
n { o f "\(k): \(o())" }
|
|
}
|
|
struct d<d : n, o:j n {
|
|
l p
|
|
}
|
|
protocol o : o {
|
|
}
|
|
func o<
|
|
class a<f : b, g : b where f.d == g> {
|
|
}
|
|
protocol b {
|
|
typealias d
|
|
typealias e
|
|
}
|
|
struct c<h : b> : b {
|
|
typealias d = h
|
|
typealias e = a<c<h>, d>
|
|
}
|
|
func c<g>() -> (g, g -> g) -> g {
|
|
d b d.f = {
|
|
}
|
|
{
|
|
g) {
|
|
i }
|
|
}
|
|
i c {
|
|
class func f()
|
|
}
|
|
class d: c{ class func f {}
|
|
struct d<c : f,f where g.i == c.i>
|
|
struct l<e : Sequence> {
|
|
l g: e
|
|
}
|
|
func h<e>() -> [l<e>] {
|
|
f []
|
|
}
|
|
func i(e: g) -> <j>(() -> j) -> k
|
|
struct c<e> {
|
|
let d: [( h
|
|
}
|
|
func b(g: f) -> <e>(()-> e) -> i
|
|
h
|
|
}
|
|
func e<l {
|
|
enum e {
|
|
func e
|
|
j {
|
|
class func n()
|
|
}
|
|
class l: j{ k() -> ())
|
|
}
|
|
({})
|
|
func j<o : Boolean>(l: o) {
|
|
}
|
|
j(j q Boolean)
|
|
func p(l: Any, g: Any) -> (((Any, Any) -> Any) -> Any) {
|
|
return {
|
|
(p: (Any, Any) -> Any) -> Any in
|
|
func n<n : l,) {
|
|
}
|
|
n(e())
|
|
e
|
|
func a<T>() {
|
|
enum b {
|
|
case c
|
|
}
|
|
}
|
|
o
|
|
class w<r>: c {
|
|
init(g: r) {
|
|
n.g = g
|
|
s.init()
|
|
(t: o
|
|
struct t : o {
|
|
p v = t
|
|
}
|
|
q t<where n.v == t<v : o u m : v {
|
|
}
|
|
struct h<t, j: v where t.h == j
|
|
f> {
|
|
c(d ())
|
|
}
|
|
func b(e)-> <d>(() -> d)
|
|
func f<T : Boolean>(b: T) {
|
|
}
|
|
f(true as Boolean)
|
|
class A: A {
|
|
}
|
|
class B : C {
|
|
}
|
|
typealias C = B
|
|
protocol A {
|
|
typealias E
|
|
}
|
|
struct B<T : As a {
|
|
typealias b = b
|
|
}
|
|
func a<T>() {f {
|
|
class func i()
|
|
}
|
|
class d: f{ class func i {}
|
|
func f() {
|
|
({})
|
|
}
|
|
func prefix(with: String) -> <T>(() -> T) -> String {
|
|
return { g in "\(with): \(g())" }
|
|
}
|
|
protocol a : a {
|
|
}
|
|
class j {
|
|
func y((Any, j))(v: (Any, AnyObject)) {
|
|
y(v)
|
|
}
|
|
}
|
|
func w(j: () -> ()) {
|
|
}
|
|
class v {
|
|
l _ = w() {
|
|
}
|
|
}
|
|
({})
|
|
func v<x>() -> (x, x -> x) -> x {
|
|
l y j s<q : l, y: l m y.n == q.n> {
|
|
}
|
|
o l {
|
|
u n
|
|
}
|
|
y q<x> {
|
|
s w(x, () -> ())
|
|
}
|
|
o n {
|
|
func j() p
|
|
}
|
|
class r {
|
|
func s() -> p {
|
|
t ""
|
|
}
|
|
}
|
|
class w: r, n {
|
|
k v: ))] = []
|
|
}
|
|
class n<x : n>
|
|
w
|
|
class x<u>: d {
|
|
l i: u
|
|
init(i: u) {
|
|
o.i = j {
|
|
r { w s "\(f): \(w())" }
|
|
}
|
|
protoc
|
|
protocol f : b { func b
|
|
() {
|
|
g g h g
|
|
}
|
|
}
|
|
func e(i: d) -> <f>(() -> f)>
|
|
import Foundation
|
|
class k<f>: NSObject {
|
|
d e: f
|
|
g(e: f) {
|
|
j h.g()
|
|
}
|
|
}
|
|
d
|
|
protocol i : d { func d
|
|
i
|
|
b
|
|
protocol d : b { func b
|
|
func d(e: = { (g: h, f: h -> h) -> h in
|
|
return f(g)
|
|
}
|
|
}
|
|
}
|
|
class b<i : b> i: g{ func c {}
|
|
e g {
|
|
: g {
|
|
h func i() -> }
|
|
struct j<l : o> {
|
|
k b: l
|
|
}
|
|
func a<l>() -> [j<l>] {
|
|
return []
|
|
}
|
|
f
|
|
k)
|
|
func f<l>() -> (l, l -> l) -> l {
|
|
l j l.n = {
|
|
}
|
|
{
|
|
l) {
|
|
n }
|
|
}
|
|
protocol f {
|
|
class func n()
|
|
}
|
|
class l: f{ class func n {}
|
|
func a<i>() {
|
|
b b {
|
|
l j
|
|
}
|
|
}
|
|
class a<f : b, l : b m f.l == l> {
|
|
}
|
|
protocol b {
|
|
typealias l
|
|
typealias k
|
|
}
|
|
struct j<n : b> : b {
|
|
typealias l = n
|
|
typealias k = a<j<n>, l>
|
|
}
|
|
protocol a {
|
|
typealias d
|
|
typealias e = d
|
|
typealias f = d
|
|
}
|
|
class b<h : c, i : c where h.g == i> : a {
|
|
}
|
|
class b<h, i> {
|
|
}
|
|
protocol c {
|
|
typealias g
|
|
}
|
|
a=1 as a=1
|
|
enum S<T> {
|
|
case C(T, () -> ())
|
|
}
|
|
n)
|
|
func f<o>() -> (o, o -> o) -> o {
|
|
o m o.j = {
|
|
}
|
|
{
|
|
o) {
|
|
r }
|
|
}
|
|
p q) {
|
|
}
|
|
o m = j
|
|
m()
|
|
class m {
|
|
func r((Any, m))(j: (Any, AnyObject)) {
|
|
r(j)
|
|
}
|
|
}
|
|
func m<o {
|
|
r m {
|
|
func n
|
|
n _ = n
|
|
}
|
|
}
|
|
class k<l : k
|
|
<c b:
|
|
func b<c {
|
|
enum b {
|
|
func b
|
|
var _ = b
|
|
func n<p>() -> (p, p -> p) -> p {
|
|
b, l]
|
|
g(o(q))
|
|
h e {
|
|
j class func r()
|
|
}
|
|
class k: h{ class func r {}
|
|
var k = 1
|
|
var s: r -> r t -> r) -> r m
|
|
u h>] {
|
|
u []
|
|
}
|
|
func r(e: () -> ()) {
|
|
}
|
|
class n {
|
|
var _ = r()
|