Skip to content

Instantly share code, notes, and snippets.

@aryairani
Created December 19, 2012 15:35
Show Gist options
  • Save aryairani/4337578 to your computer and use it in GitHub Desktop.
Save aryairani/4337578 to your computer and use it in GitHub Desktop.
// Foo can be extended, and `step` should return the extended type
trait Foo[S,A] {
type Self = Foo[S,A]
def step(s: S): Self
}
// Bar can be extended, fixing a more specific F
trait Bar {
type S
type A
type F <: Foo[S, A]
}
// Should run on any subtype of Bar, and operate with its derived Foos
case class Sim[G<:Bar with Singleton]( f: G#F, s: G#S) {
def step: Sim[G] = {
def newF = f.step(s): G#F // fail
copy(f = newF)
}
}
/*
type mismatch;
[error] found : Sim.this.f.Self
[error] (which expands to) bugs.ExpandedTypeMismatch2.Foo[G#S,G#A]
[error] required: G#F
[error] def newF = f.step(s): G#F
[error] ^
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment