Created
December 19, 2012 15:35
-
-
Save aryairani/4337578 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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