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

  • Home
  • SEARCH
  • 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 7793663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:33:31+00:00 2026-06-01T22:33:31+00:00

Getting hung up on an apparently simple problem, for which there is plenty of

  • 0

Getting hung up on an apparently simple problem, for which there is plenty of information (too much to sift through to know what on earth the current status is).

At any rate, here goes.

trait _Foo
class Foo Extends _Foo with WhoAmI
trait WhoAmI {
  def who = {
    getClass match {
      case x: _Foo => "should be Foo instance, which extends _Foo"
      case _ => "why?"
    }
  }
}
val foo = new Foo
foo.who

have tried a guard with classOf and isAssignableFrom, as well as looping through x.getInterfaces (I do at least see _Foo there), but no luck in terms of a direct “lean” match.

Is this erasure “at work” or am I missing an obvious 1-liner?

If this is a duplicate of many other threads, we can close, but please point me in the right direction! 😉

Thanks

  • 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-06-01T22:33:33+00:00Added an answer on June 1, 2026 at 10:33 pm

    You should use this instead of getClass:

    this match {
    

    Currently you are calling getClass (which returns object of Class[T] type) – for sure the java.lang.Class class does not extend your _Foo trait – that’s “why?“

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

Sidebar

Related Questions

Without getting in to too much detail and without people getting too hung up
Ruby-debug is getting hung up by breaking on the break ruby reserved word on
Getting a 'marshal data too short' error when trying to install the mysql gem
I am trying to use the conditional operator, but I am getting hung up
I'm a novice/beginner programmer having problems getting some simple client/server C code working. My
I'm new to xslt, and I fear that this problem hinges on me getting
I'm struggling with a homework assignment and am getting hung up on some SQL
I'm trying to do some very basic arithmetic and am getting hung up. I'm
I am facing an issue that WAS threads are getting hung. Configurations: OS: AIX,
Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo

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.