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 do not work with type arguments #5451

Closed
scabug opened this issue Feb 9, 2012 · 2 comments
Closed

Macros do not work with type arguments #5451

scabug opened this issue Feb 9, 2012 · 2 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Feb 9, 2012

case class Queryable[T]{
  def macro map[S]( projection: T => S ) : Queryable[S] = ???
}
trait CoffeesTable{
  def name : String
}
object Test extends App{
  val q = new Queryable[CoffeesTable]
  q.map( _.name )
}
TestQueryable.scala:7: error: exception during macro expansion: 
java.lang.IllegalArgumentException: argument type mismatch
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at scala.reflect.runtime.Mirror.invoke(Mirror.scala:46)
  at scala.tools.nsc.typechecker.Macros$class.macroExpand(Macros.scala:151)
  at scala.tools.nsc.Global$$anon$1.macroExpand(Global.scala:437)
  at scala.tools.nsc.typechecker.Typers$Typer.expandMacro(Typers.scala:4503)
  at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:945)
  at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4465)
  at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2117)
  at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$27$$anonfun$28.apply(Typers.scala:2210)
  at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$27$$anonfun$28.apply(Typers.scala:2210)
  at scala.collection.immutable.List.loop$1(List.scala:151)
  at scala.collection.immutable.List.mapConserve(List.scala:167)
  at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$27.apply(Typers.scala:2210)
  at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$27.apply(Typers.scala:2209)
  at scala.tools.nsc.typechecker.Typers$Typer.withSavedContext(Typers.scala:497)
  at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2209)
  at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1538)
  at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$13.apply(Typers.scala:1447)
  at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$13.apply(Typers.scala:1447)
  at scala.tools.nsc.typechecker.Typers$Typer.typerReportAnyContextErrors(Typers.scala:488)
  at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1446)
  at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4124)
  at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4456)
  at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2117)
  at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$27$$anonfun$28.apply(Typers.scala:2210)
  at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$27$$anonfun$28.apply(Typers.scala:2210)
  at scala.collection.immutable.List.loop$1(List.scala:151)
  at scala.collection.immutable.List.mapConserve(List.scala:167)
  at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$27.apply(Typers.scala:2210)
  at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$27.apply(Typers.scala:2209)
  at scala.tools.nsc.typechecker.Typers$Typer.withSavedContext(Typers.scala:497)
  at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2209)
  at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4117)
  at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4456)
  at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4521)
  at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:96)
  at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:408)
  at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:88)
  at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:88)
  at scala.collection.Iterator$class.foreach(Iterator.scala:687)
  at scala.collection.AbstractIterator.foreach(Iterator.scala:1112)
  at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:88)
  at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1196)
  at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1169)
  at scala.tools.nsc.Global$Run.compileSources(Global.scala:1163)
  at scala.tools.nsc.Global$Run.compile(Global.scala:1293)
  at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
  at scala.tools.nsc.Main$.doCompile(Main.scala:81)
  at scala.tools.nsc.Driver.process(Driver.scala:52)
  at scala.tools.nsc.Driver.main(Driver.scala:65)
  at scala.tools.nsc.Main.main(Main.scala)

    q.map( _.name )
         ^
one error found
@scabug
Copy link
Author

scabug commented Feb 9, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5451?orig=1
Reporter: @xeno-by
Affected Versions: 2.10.0
Other Milestones: 2.10.0

@scabug
Copy link
Author

scabug commented Feb 10, 2012

@xeno-by said:
Fixed by scala/scala@34233f0

@scabug scabug closed this as completed Feb 10, 2012
@scabug scabug added the macros label Apr 7, 2017
@scabug scabug added this to the 2.10.0-M1 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