Skip to content

Instantly share code, notes, and snippets.

@jorgeortiz85
Created September 21, 2011 16:29
Show Gist options
  • Select an option

  • Save jorgeortiz85/1232550 to your computer and use it in GitHub Desktop.

Select an option

Save jorgeortiz85/1232550 to your computer and use it in GitHub Desktop.

Revisions

  1. jorgeortiz85 revised this gist Sep 21, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion FK.scala
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ object Main {
    def fetch[A](id: Int @ FK[A]): A = null.asInstanceOf[A]

    def main(args: Array[String]): Unit = {
    val id: Int @ FK[Venue] = 10
    val id: Int @ FK[Checkin] = 10

    // Why does this type check?
    fetch[User](id)
  2. jorgeortiz85 created this gist Sep 21, 2011.
    15 changes: 15 additions & 0 deletions FK.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    class FK[A] extends StaticAnnotation

    class User
    class Checkin

    object Main {
    def fetch[A](id: Int @ FK[A]): A = null.asInstanceOf[A]

    def main(args: Array[String]): Unit = {
    val id: Int @ FK[Venue] = 10

    // Why does this type check?
    fetch[User](id)
    }
    }