Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 877233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:34:22+00:00 2026-05-15T11:34:22+00:00

Warning: I’m cross-posting from #scala The book Programming in Scala states that path-dependent types

  • 0

Warning: I’m cross-posting from #scala

The book Programming in Scala states that path-dependent types are different depending on the exact instance of the path in question. If so, I don’t understand why all the following predicates return true:

class Outer {
  val in = new Inner
  class Inner
}

val o1 = new Outer
val o2 = new Outer

o1.in.isInstanceOf[Outer#Inner] //makes perfect sense
o1.in.isInstanceOf[o1.Inner]    //still makes sense, the path-dependent type is o1's own
o1.in.isInstanceOf[o2.Inner]    //why is this true? PiS p.423 says the path-dependent types are different, they only share a common supertype Outer#Inner
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:34:22+00:00Added an answer on May 15, 2026 at 11:34 am

    o1.Inner and o2.Inner are different types, but their erasures are the same:

    scala> class Outer {
         |   val in = new Inner
         |   class Inner
         | }
    defined class Outer
    
    scala> val o1 = new Outer
    o1: Outer = Outer@1d16ecf
    
    scala> val m1 = implicitly[Manifest[o1.Inner]]
    m1: Manifest[o1.Inner] = Outer@1d16ecf.type#Outer$Inner
    
    scala> m1.erasure
    res0: java.lang.Class[_] = class Outer$Inner
    
    scala> val o2 = new Outer
    o2: Outer = Outer@138ef1d
    
    scala> val m2 = implicitly[Manifest[o2.Inner]]
    m2: Manifest[o2.Inner] = Outer@138ef1d.type#Outer$Inner
    
    scala> m2.erasure
    res1: java.lang.Class[_] = class Outer$Inner
    

    and o1.in.isInstanceOf[o2.Inner] can only check that o1.in is an instance of the erasure of o2.Inner.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Warning: This is a not very serious question/discussion that I am posting... but I
Warning: Note that this is a dumb question of something that I would probably
Warning: touch() [function.touch]: open_basedir restriction in effect. File() is not within the allowed path(s):
Warning: This is inherited legacy code that was initially put together in the early
warning: passing argument 1 of 'bsearch' makes pointer from integer without a cast and
Warning text: warning: [options] bootstrap class path not set in conjunction with -source 1.6
(WARNING: this is my first java application, coming from .NET, so don't bash me
Warning: In DOM Core 1, 2 and 3, Attr inherited from Node. This is
Warning: is_writable() [function.is-writable]: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s):
Warning: I'm a Cocoa newbie. I'm reading Cocoa Programming For Mac OS X by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.