Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created August 28, 2015 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/30532a79ebcbfc54b9dc to your computer and use it in GitHub Desktop.
Save shigemk2/30532a79ebcbfc54b9dc to your computer and use it in GitHub Desktop.
class A {
class B
def f(b: B) = println("Got my B!")
}
val a1 = new A
println(a1)
val a2 = new A
println(a2)
a2.f(new a2.B)
// a2.f(new a1.B)
class A {
class B
def f(b: B) = println("Got my B!")
def g(b: A#B) = println("Got a B.")
}
val a1 = new A
println(a1)
val a2 = new A
println(a2)
a2.f(new a2.B)
// a2.f(new a1.B) // error: type mismatch
a2.g(new a1.B)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment