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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:18:04+00:00 2026-06-11T23:18:04+00:00

I am migrating some code from Scala 2.10-M5 to Scala 2.10-M7 . I have

  • 0

I am migrating some code from Scala 2.10-M5 to Scala 2.10-M7. I have found that the Type API in the macro context has been notably reduced. In particular, I am wondering how to get the underlying and typeArgs defs.

—

UPDATED

As requested by @EugeneBurmako, I am going to show the whole picture. Suppose we have this state:

class Attribute[C[_], E]

class Id[E]

trait Entity {
  val att1: List[Int]
  val att2: Int
}

object Entity {
  val att1reif = new Attribute[List, Int]
  val att2reif = new Attribute[Id, Int]
}

def Let[T <: Entity, C[_], E](en: T, att: Attribute[C, E], ce: C[E]): T =
  /* Updates the whole attribute */

def Let[T <: Entity, C[_], E](en: Entity, att: Attribute[C, E], e: E, mode: Boolean): T = 
  /* Adds or removes (mode) an item */

where we have an Entity hosting some attributes. The entity companion object contains meta-information (reifications) about those attributes. The Let family allows updating the entities (by creating new copies).

So far, so good. We can use the Let methods as follows:

val ent = new Entity { val att1 = List(); val att2 = 3 }
Let(ent, Entity.att1reif, List(1, 2, 3)) // att1 = List(1, 2, 3)
Let(ent, Entity.att1reif, 4, true)       // att1 = List(1, 2, 3, 4)
Let(ent, Entity.att1reif, 1, false)      // att1 = List(2, 3, 4)

The reification attribute is redundant, so we’d like our users to have a simpler API. In particular, the next one:

// Same code as DSL
ent.att1 := List(1, 2, 3)
ent.att1 :+ 4
ent.att1 :- 1

Notice that there isn’t information about the reification anywhere. So, we need some Helpers and a macro view to reach our goal.

trait AttributeHelper {
  type T <: Entity
  type C[_]
  type E
  val ent: T
  val att: Attribute[C, E]
  def :=(ce: C[E]): T = Let(ent, att, ce)
  def :+(e: E): T = Let(ent, att, e, true)
  def :-(e: E): T = Let(ent, att, e, false)
}

def toAttributeHelperImpl[V: c.AbsTypeTag](c: Context)(expr: c.Expr[V]): c.Expr[AttributeHelper] = 
  /* A looong macro (currently broken), since I can't split V into C[_] and E,
   * which are needed to generate the expression that instantiates an *AttributeHelper*.
   * The macro is responsible of finding the attribute reification.
   */

Our macro definition is, in fact, a view, and it does the magic to allow the DSL expression:

implicit def toAttributeHelper[V](expr: V): AttributeHelper = macro toAttributeHelperImpl[V]

I have been trying to go on with a macro which uses two type params, but while doing so, the implicit view is not applied (because the compiler can’t infer both types).

So, as I mentioned at the beginning, the lack of typeArgs which was available in M5, but does not in M7, has broken the previous macro. How can I generate the AttributeHelper construction without having that def?

Finally, I must say that the previous code is just a simplification. There are some other involved evidences, that’s why I need to use the underlying.

  • 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-11T23:18:05+00:00Added an answer on June 11, 2026 at 11:18 pm

    The general idea behind the reflection API cleanup, which happened somewhen around M5, was to remove extremely specialized methods.

    For example, typeArgs is only applicable to TypeRef types, so it doesn’t make much sense to keep it in the base type Type. The replacement is a simple pattern match: tpe match { case TypeRef(_, _, args) => arg; case _ => Nil }.

    underlying is different, though, since it’s an internal implementation concept that means a lot of things depending on a concrete flavor of the type. If you elaborate on your use case, I might help with finding an alternative for underlying.

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

Sidebar

Related Questions

We are migrating some code to use Entity Framework and have a query that
I am migrating some C++ code from structures to classes. I was using structures
I'm migrating some code from VB.NET to C# (3.5). I find structures like: Public
I am migrating some code and have nicely formatted Look-up Tables but they have
I'm migrating some code from the ASPX view engine to Razor and I've run
I have been working on migrating our code base onto Glassfish 3.1.2 using Java
OK, so I have a database field of type char(1) that has a small
So I am migrating some code from VB.NET to C# however it fails when
I'm migrating some of our code from LINQ-to-SQL to Entity Framework. Previously, when run
We have a system that is migrating from an older VARCHAR using LIKE setup

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.