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 4086664
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:45:23+00:00 2026-05-20T18:45:23+00:00

Simple question, I have code like this: class Context[A] { def t: A }

  • 0

Simple question, I have code like this:

class Context[A] {
    def t: A
}

object Context {
    implicit object StandardContext extends Context[SomeObject] {
        def t = SomeObject
    }
}

SomeObject is an object that holds values and functions that I would like to access in my Context. Unfortunately the different types for A I would like to include do not have a common parent class, other than java.lang.Object.

SomeObject is defined like this:

final object SomeObject {
    def func1 = ...
    def func2 = ...
}

In some code that’s not mine. But the Scala compiler complains SomeObject is not a value when I try the thing above. As far as I know it, an object in scala is a singleton class, so it would be a type, yes, but also a value, the only value of its own type.

What I wanna do is stuff like this:

class Foo[A](bar: Int)(implicit context: Context[A]) {
    def baz = context.t.baz
}

Anyone can tell me how to solve this or have a better idea of solving it?

  • 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-20T18:45:24+00:00Added an answer on May 20, 2026 at 6:45 pm
    implicit object StandardContext extends Context[SomeObject] {
        def t = SomeObject
    

    The first SomeObject is a type, a type-parameter for Context, but in the second row it is used as if it were a variable.

    Think of

     ... List [Int] {
         def x = Int // fail
    

    Int is a type, not a variable, so x can’t return Int, it could only return an integer.

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

Sidebar

Related Questions

This is a (hopefully) really simple question - I have been told recently that
Pretty simple question: When i have a persistable object, it usually has a property
Here's a very simple question. I have an SP that inserts a row into
This feels like an extremely n00b question, but here goes... I have a series
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
Simple question: do I have to delete or delete [] c ? Does the
I have a very simple question. I want to test whether a particular port
I have a simple question. Is there a way ( using reflections I suppose
I have a simple question and wish to hear others' experiences regarding which is
I have a simple question related to one-line programming. First an example: function test(a)

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.