Unexpected compile error with reflective calls

Steven Heidel <[email protected]>
Newsgroups gmane.comp.lang.scala
Message-ID <[email protected]>
Take a look at the following code:

import scala.language.reflectiveCalls

trait A {
  def sameName: Object
}

object B extends A {
  def sameName = new Object {
    def method = ???
  }

  def differentName = new Object {
    def method = ???
  }

  def main = {
    sameName.method // doesn't compile, "value call is not a member of 
Object"
    differentName.method // compiles
  }
}

I expected this to compile because I'm refining both the method sameName 
and differentName's Object with "method". The only difference is that 
sameName implements a method in trait A whereas differentName does not.

I'm assuming this is because type inference picks up Object for the return 
type of sameName from trait A instead of its actual type Object{def method: 
Nothing}. Is this a bug or a feature?

-- 
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.