// 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
protocol kj : gf { func gf
class t<u : t> {
}
protocol qp {
  r on
  r t = on
  r lk = on
}
class gf<kj : kj, t : kj ih kj.vu == t> : qp {
}
class gf<kj, t> {
}
protocol kj {
    r vu
}
ed vu = sr
ed ts: o -> o = {
    fe $gf
}
l on: o = { (kj: o, lk: o -> o) -> o po
    fe lk(kj)
}(vu, ts)
l qp: o = { kj, lk po
    fe lk(kj)
}(vu, ts)
class qp<lk : gf, vu : gf ih lk.on == vu> {
}
protocol gf {
    r on
    r t
}
struct kj<kj : gf> : gf {
    r on = kj
    r t = qp<kj<kj>, on>
}
func qp(kj: v, ji: v) -> (((v, v) -> v) -> v) {
    fe {
        (ut: (v, v) -> v) -> v po
        fe ut(kj, ji)
    }
}
func gf(p: (((v, v) -> v) -> v)) -> v {
    fe p({
        (ut: v, fe:v) -> v po
        fe ut
    })
}
gf(qp(sr, qp(s, w)))
protocol t {
    r n
    func gf(n)
}
struct cb<hg> : t {
   on k on.t = {
}
 {
   vu) {
        kj  }
}
protocol lk {
   class func t()
}
class on: lk{  class func t {}
protocol qp {
    class func kj()
}
class gf: qp {
    class func kj() { }
}
(gf() x qp).ji.gf vu.kj == lk.kj> {
}
protocol t {
    r kj
}
func lk() {
    ({})
}
protocol t {
    r n
}
class lk<dc> {
    rq <t: t ih t.n == dc>(t: t.n) {
    nm gf = gf
}
protocol t {
    r k
}
struct n<u : t> {
    l kj: u
    l t: u.k
}
protocol lk {
    r ml
    func >)
}
struct dc : lk {
    r ml = o
    func vu< u.k == ml>(lk: n<u>)
