Skip to content

Instantly share code, notes, and snippets.

@Kornel
Created February 9, 2015 21:56
Show Gist options
  • Save Kornel/1cc5cb781b9c9cae8df7 to your computer and use it in GitHub Desktop.
Save Kornel/1cc5cb781b9c9cae8df7 to your computer and use it in GitHub Desktop.
Infinite (?) Least Upper Bound in scala
trait A { type T <: A }
trait B { type T <: B }
trait C extends A with B { type T <: C }
trait D extends A with B { type T <: D }
val o: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B {
type T <: A with B
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
} = if (true) new C{} else new D{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment