Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macros: paying the hardcoding piper #6516

Closed
scabug opened this issue Oct 11, 2012 · 6 comments
Closed

macros: paying the hardcoding piper #6516

scabug opened this issue Oct 11, 2012 · 6 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Oct 11, 2012

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
@scabug
Copy link
Author

scabug commented Oct 11, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6516?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Oct 11, 2012

@xeno-by said:
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

@scabug
Copy link
Author

scabug commented Oct 11, 2012

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

@scabug
Copy link
Author

scabug commented Nov 9, 2012

@xeno-by said:
This bug is being fixed

@scabug
Copy link
Author

scabug commented Jan 30, 2013

@paulp said:
scala/scala#2025

@scabug
Copy link
Author

scabug commented Jan 31, 2013

@paulp said:
ccd7abe897a

@scabug scabug closed this as completed Jan 31, 2013
@scabug scabug added the macros label Apr 7, 2017
@scabug scabug added this to the 2.10.1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants