Skip to content

Instantly share code, notes, and snippets.

@barbosa
Created April 25, 2016 15:37
Show Gist options
  • Select an option

  • Save barbosa/681e2fedeba2cc8c576350fbc7d57fe1 to your computer and use it in GitHub Desktop.

Select an option

Save barbosa/681e2fedeba2cc8c576350fbc7d57fe1 to your computer and use it in GitHub Desktop.

Revisions

  1. barbosa created this gist Apr 25, 2016.
    26 changes: 26 additions & 0 deletions bug.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    protocol Resource {
    associatedtype ResourceFinderType
    static var localObjects: ResourceFinderType { get }
    }

    extension Resource {
    static var localObjects: ResourceFinder<Self> {
    return ResourceFinder()
    }
    }

    public protocol ResourceFinderProtocol {
    associatedtype ResourceType
    func all() -> [ResourceType]
    }


    struct ResourceFinder<T:Resource>: ResourceFinderProtocol {
    func all() -> [T] {
    return []
    }
    }

    struct Model: Resource {}

    Model.localObjects.all()