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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:25:49+00:00 2026-06-04T19:25:49+00:00

How can def someA (in trait B ) use trait A with the same

  • 0

How can def someA (in trait B) use trait A with the same C#MyType as in B ? (Then A#MyType =:= B#MyType)

trait C {
  type MyType
}


trait A {
  self: C =>
  def doSomething(s: MyType) { println(s.toString)}
}

trait B {
  self: C =>  

  def someA: A
  def myType: MyType

  def action = someA.doSomething(myType)
}

// Mix part

case class Ahoy(value: String)

trait ConcreteC extends C {  
  type MyType = Ahoy
}


class PieceOfCake extends B with ConcreteC {
  val someA = new A with ConcreteC
  val myType = Ahoy("MyType")

}

It doesn’t compile : type mismatch;

[error]  found   : B.this.MyType
[error]  required: _1.MyType where val _1: A
[error]   def action = someA.doSomething(myType))
  • 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-04T19:25:50+00:00Added an answer on June 4, 2026 at 7:25 pm

    You can declare doSomething and myType to use the path independent version of MyType, SomeType#MyType:

    trait SomeType {
      type MyType
    }
    
    
    trait A {
      self: SomeType =>
      def doSomething(s: SomeType#MyType) { println(s.toString)}
    }
    
    trait B {
      self: SomeType =>  
    
      def someA: A
      def myType: SomeType#MyType
    
      def action = someA.doSomething(myType)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I use type as a name for a python function argument? def fun(name,
I have a model, smth like this: class Action(models.Model): def can_be_applied(self, user): #whatever return
How can it be that this test case import unittest class PropTest(unittest.TestCase): def test(self):
Can I use form_for orbinary object? Controller: class AgendaState attr_accessor :base_date def initialize(date) @base_date
How can I make this code work? class Meta @array = [:a,:b] def self.method_missing(name,
With pytest, one can mark tests using a decorator @pytest.mark.slow def some_slow_test(): pass Then,
In Python I can define a function as follows: def func(kw1=None,kw2=None,**kwargs): ... In this
is there any way I can reproduce this ruby function: def Password.hash(password,salt) Digest::SHA512.hexdigest(#{password}:#{salt}) end
Proxy configuration of a machine can be easily fetched using def check_proxy(): import urllib2
I know i can do something like ab[^c]+def which should match ab_blah_hi_blah_def but is

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.