Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.1
    • Component/s: Macros
    • Labels:

      Description

      I haven't looked at the cause of this, but it feels like it can only be due to hardcoded handling of "Context" and "PrefixType" somewhere.

      import scala.language.experimental.macros
      import scala.reflect.macros.Context
      import scala.collection.TraversableLike
      
      // This one compiles
      object Test {
        type Alias[T, CC[_]] = Context { type PrefixType = TraversableLike[T, CC[T]] }
        def f() = macro f_impl
        def f_impl(c: Alias[Int, List])() = ???
      }
      
      // This one doesn't
      object Test2 {
        type Ctx = scala.reflect.macros.Context
        type Alias[T, CC[_]] = Ctx { type PrefixType = TraversableLike[T, CC[T]] }
      
        def f() = macro f_impl
        def f_impl(c: Alias[Int, List])() = ???
      }
      

      The error is:

      ./a.scala:15: error: macro implementation has wrong shape:
       required: (c: scala.reflect.macros.Context)(): c.Expr[Any]
       found   : (c: Test2.Alias[Int,List])(): Nothing
      type mismatch for parameter c: scala.reflect.macros.Context does not conform to Test2.Ctx{type PrefixType = scala.collection.TraversableLike[Int,List[Int]]}
        def f() = macro f_impl
                        ^
      one error found
      

        Activity

        Hide
        Eugene Burmako added a comment -
        Show
        Eugene Burmako added a comment - Heh I've already fixed a similar bug back then. But a single dealias wasn't enough: https://github.com/scalamacros/kepler/blob/5b9f4bbf61e0e850a8eb918a278dee7b87628251/src/compiler/scala/tools/nsc/typechecker/Macros.scala#L461
        Hide
        Paul Phillips added a comment -

        I think it will be enough to say "tpe =:= MacroContextClass.tpe" rather than == .

        Show
        Paul Phillips added a comment - I think it will be enough to say "tpe =:= MacroContextClass.tpe" rather than == .
        Hide
        Eugene Burmako added a comment -

        This bug is being fixed

        Show
        Eugene Burmako added a comment - This bug is being fixed
        Show
        Paul Phillips added a comment - https://github.com/scala/scala/pull/2025
        Hide
        Paul Phillips added a comment -

        ccd7abe897a

        Show
        Paul Phillips added a comment - ccd7abe897a

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development