| // 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 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> |
| protocol p { |
| class func g() |
| } |
| class h: p { |
| class func g() { } |
| } |
| (h() as p).dynamicType.g() |
| protocol p { |
| } |
| protocol h : p { |
| } |
| protocol g : p { |
| } |
| protocol n { |
| o t = p |
| } |
| struct h : n { |
| t : n q m.t == m> (h: m) { |
| } |
| func q<t : n q t.t == g> (h: t) { |
| } |
| q(h()) |
| func r(g: m) -> <s>(() -> s) -> n |
| 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() { |
| ({}) |
| } |
| } |
| } |
| class b<i : b> i: g{ func c {} |
| e g { |
| : g { |
| h 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 {} |
| func b<d-> d { class d:b class b |
| 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 |
| protocol A { |
| typealias B |
| } |
| class C<D> { |
| init <A: A where A.B == D>(e: A.B) { |
| } |
| } |
| 1, g(f, j))) |
| m k { |
| class h k() |
| } |
| struct i { |
| i d: k.l h k() { |
| n k |
| } |
| class g { |
| typealias k = k |
| } |
| func i(f: g) -> <j>(() -> j) -> g { func g |
| k, l { |
| typealias l = m<k<m>, f> |
| } |
| ) |
| func o<t>() -> (t, t -> t) -> t { |
| j j j.o = { |
| } |
| { |
| t) { |
| h } |
| } |
| protocol o { |
| class func o() |
| } |
| class j: o{ class func o {} |
| e o<j : u> { |
| k [] |
| } |
| n=p r n=p |
| func n<q>() { |
| b b { |
| o o |
| } |
| } |
| func n(j: Any, t: Any) -> (((Any, Any) -> Any) -> Any) { |
| k { |
| (s: (Any, Any) -> Any) -> Any l |
| k s(j, t) |
| } |
| } |
| func b(s: (((Any, Any) -> Any) -> Any) |
| 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< |
| protocol l : p { |
| } |
| protocol m { |
| j f = p |
| } |
| f m : m { |
| j f = o |
| } |
| func i<o : o, m : m n m.f == o> (l: m) { |
| } |
| k: m |
| } |
| func p<m>() -> [l<m>] { |
| return [] |
| } |
| f |
| m) |
| func f<o>() -> (o, o -> o) -> o { |
| m o m.i = { |
| } |
| { |
| o) { |
| p } |
| } |
| protocol f { |
| class func i() |
| } |
| class m: f{ class func i {} |
| protocol p { |
| class func l() |
| } |
| class o: p { |
| class func l() { } |
| } |
| class p { |
| u _ = q() { |
| } |
| } |
| u l = r |
| u s: k -> k = { |
| n $h: m.j) { |
| } |
| } |
| o l() { |
| ({}) |
| } |
| struct m<t> { |
| ls 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 f<r>() -> (r, r -> r) -> r { |
| f r f.j = { |
| } |
| { |
| r) { |
| s } |
| } |
| protocol f { |
| class func j() |
| } |
| class f: f{ class func j {} |
| protocol j { |
| class func m() |
| } |
| class r: j { |
| class func m() { } |
| } |
| (r() n j).p.m() |
| j=k n j=k |
| protocol r { |
| class func q() |
| } |
| s m { |
| m f: r.q |
| func q() { |
| f.q() |
| } |
| (l, () -> ()) |
| } |
| func f<l : o>(r: l) |
| func a<d>() -> [c{ enum b { |
| case c |
| w |
| class x<u>: d { |
| l i: u |
| init(i: u) { |
| o.i = j { |
| r { w s "\(f): \(w())" } |
| } |
| protocol h { |
| q k { |
| t w |
| } |
| w |
| protocol k : w { func v <h: h m h.p == k>(l: h.p) { |
| } |
| } |
| protocol h { |
| n func w(w: |
| } |
| class h<u : h> { |
| b |
| protocol c : b { func b |
| 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 d<b: Sequence, e where Optional<e> == b.Iterator.Element>(c : b) -> e? { |
| for (mx : e?) in c { |
| } |
| } |
| 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 |
| f> { |
| c(d ()) |
| } |
| func b(e)-> <d>(() -> d) |
| ) |
| func n<w>() -> (w, w -> w) -> w { |
| o m o.q = { |
| } |
| { |
| w) { |
| k } |
| } |
| protocol n { |
| class func q() |
| } |
| class o: n{ class func q {} |
| func p(e: Int = x) { |
| } |
| let c = p |
| c() |
| func r<o: y, s q n<s> ==(r(t)) |
| protocol p : p { |
| } |
| protocol p { |
| class func c() |
| } |
| class e: p { |
| class func c() { } |
| } |
| (e() u p).v.c() |
| k e.w == l> { |
| } |
| func p(c: Any, m: Any) -> (((Any, Any) -> Any) -> Any) { |
| >) |
| } |
| struct n : C { |
| class p { |
| typealias n = n |
| } |
| l |
| l) |
| func l<u>() -> (u, u -> u) -> u { |
| n j n.q = { |
| } |
| { |
| u) { |
| h } |
| } |
| protocol l { |
| class { |
| func n() -> q { |
| return "" |
| } |
| } |
| class C: s, l { |
| t) { |
| return { |
| (s: (t, t) -> t) -> t o |
| return s(c, u) |
| } |
| } |
| func n(r: (((t, t) -> t) -> t)) -> t { |
| return r({ |
| return k |
| }) |
| protocol a : a { |
| } |
| 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 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> |
| 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 c<b:c |
| func a(b: Int = 0) { |
| } |
| let c = a |
| c() |
| <c b: |
| func b<c { |
| enum b { |
| func b |
| var _ = b |
| 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 f<d : d, j : d k d.l == j> { |
| } |
| protocol d { |
| i l |
| i i |
| } |
| struct l<l : d> : d { |
| i j i() { |
| l.i() |
| } |
| } |
| protocol f { |
| } |
| protocol d : f { |
| struct c<d : Sequence> { |
| var b: dlass 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) - |
| c |
| j) |
| func c<k>() -> (k, > k) -> k { |
| d h d.f 1, k(j, i))) |
| class k { |
| typealias h = h |
| 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 |
| protocol A { |
| typealias E |
| } |
| struct B<T : A> { |
| let h: T |
| let i: T.E |
| } |
| protocol C { |
| typealias F |
| func g<T where T.E == F>(f: B<T>) |
| } |
| struct D : C { |
| typealias F = Int |
| func g<T where T.E == F>(f: B<T>) { |
| } |
| } |
| 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() |
| func b((Any, e))(e: (Any) -> <d>(()-> d) -> f |
| 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 |
| func a<T>() { |
| enum b { |
| case c |
| } |
| } |
| 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 { |
| d "" |
| e} |
| class d { |
| func b((Any, d)typealias b = b |
| protocol A { |
| typealias B |
| func b(B) |
| } |
| struct X<Y> : A { |
| d { func d |
| 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 |
| 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 |
| ({}) |
| struct c<e> { |
| let d: i h |
| } |
| func f(h: b) -> <e>(()-> e |
| ) |
| func t<v>() -> (v, v -> v) -> v { |
| var d: ((v, v -> v) -> v)! |
| q d |
| } |
| protocol t { |
| } |
| protocol d : t { |
| } |
| protocol g : t { |
| } |
| s |
| q l |
| }) |
| } |
| d(t(u, t(w, y))) |
| protocol e { |
| r j |
| } |
| struct m<v : e> { |
| k x: v |
| k x: v.j |
| } |
| protocol n { |
| g == o>(n: m<v>) { |
| } |
| } |
| struct e<v> { |
| k t: [(v, () -> ())] = [](m) |
| } |
| struct d<x> : e { |
| func d(d: d.p) { |
| } |
| } |
| class e<v : e> { |
| } |
| func h<j>() -> (j, j -> j) -> j { |
| var f: ({ (c: e, f: e -> e) -> return f(c) |
| }(k, i) |
| let o: e = { c, g |
| return f(c) |
| }(l) -> m) -> p>, e> |
| } |
| class n<j : n> |
| func j(d: h) -> <k>(() -> k) -> h { |
| return { n n "\(} |
| c i<k : i> { |
| } |
| c i: i { |
| } |
| c e : l { |
| } |
| f = e |
| protocol m : o h = h |
| } |
| 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 |