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

c.typeOf doesn't work #6047

Closed
scabug opened this issue Jul 8, 2012 · 4 comments
Closed

c.typeOf doesn't work #6047

scabug opened this issue Jul 8, 2012 · 4 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Jul 8, 2012

import language.experimental.macros
import scala.reflect.makro.Context
import java.io.InputStream

object Macros {
   def unpack[A](input: InputStream): A = macro unpack_impl[A]

   def unpack_impl[A: c.TypeTag](c: Context)(input:
 c.Expr[InputStream]): c.Expr[A] = {
     import c.universe._

     def unpackcode(tpe: c.Type): c.Expr[_] = {
       if (tpe <:< implicitly[c.AbsTypeTag[Traversable[_]]].tpe) {

       }
       ???
     }

     unpackcode(c.typeOf[A])
     ???
   }
 }
typechecking macro def macro method unpack at source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-5,offset=86
generating macroImplSigs for: macro method unpack
tparams are: List(type A >: _root_.scala.Nothing <: _root_.scala.Any)
vparamss are: List(List(val input: InputStream = _))
retTpe is: A
macroImplSigs are: (List(List(List(value c), List(value input))),c.universe.Expr[A])
considering 1 possibilities of compatible macro impl signatures for macro def: unpack
scala.reflect.makro.Context <: scala.reflect.makro.Context?
true
c.universe.Expr[java.io.InputStream] <: c.universe.Expr[java.io.InputStream]?
true
c.universe.Expr[?A] <: c.universe.Expr[A]?
true
[  OK  ] List(List(value c), List(value input))
typechecked macro impl as: List(List(value c), List(value input))
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for c.TypeTag[Traversable[_]] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
materializing requested c.universe.type.TypeTag[Traversable[_]] using `package`.this.materializeTypeTag[Traversable[_]](c.universe)
looking for macro implementation: macro method materializeTypeTag
macro expansion is serviced by a fast track
calculateUndetparams: Set()
typechecking macro expansion `package`.this.materializeTypeTag[Traversable[_]](c.universe) at source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402
looking for macro implementation: macro method materializeTypeTag
macro expansion is serviced by a fast track
argss: List(List(MacroContext(materializeTypeTag@source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402 +0)), List(Expr[Nothing](c.universe)))
rawArgs: List(MacroContext(materializeTypeTag@source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402 +0), Expr[Nothing](c.universe))
inferring implicit value of type scala.reflect.base.Universe#TypeTag[Traversable[_]], macros = false
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for scala.reflect.base.Universe#TypeTag[Traversable[_]] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
implicit search has failed. to find out the reason, turn on -Xlog-implicits
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for c.universe.TypeTag[c.Type] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
materializing requested c.universe.type.TypeTag[c.Type] using `package`.this.materializeTypeTag[c.Type](c.universe)
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for scala.reflect.base.Universe#TypeTag[c.Type] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
macro expansion has failed: cannot reify TypeTag having unresolved type parameter c.Type at source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402
Macros_1.scala:13: `package`.this.materializeTypeTag[Traversable[_]](c.universe) is not a valid implicit value for c.TypeTag[Traversable[_]] because:
failed to typecheck the materialized tag: 
cannot reify TypeTag having unresolved type parameter c.Type
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for c.TypeTag[Traversable[_]] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
materializing requested c.universe.type.TypeTag[Traversable[_]] using `package`.this.materializeTypeTag[Traversable[_]](c.universe)
looking for macro implementation: macro method materializeTypeTag
macro expansion is serviced by a fast track
calculateUndetparams: Set()
typechecking macro expansion `package`.this.materializeTypeTag[Traversable[_]](c.universe) at source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402
looking for macro implementation: macro method materializeTypeTag
macro expansion is serviced by a fast track
argss: List(List(MacroContext(materializeTypeTag@source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402 +0)), List(Expr[Nothing](c.universe)))
rawArgs: List(MacroContext(materializeTypeTag@source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402 +0), Expr[Nothing](c.universe))
inferring implicit value of type scala.reflect.base.Universe#TypeTag[Traversable[_]], macros = false
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for scala.reflect.base.Universe#TypeTag[Traversable[_]] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
implicit search has failed. to find out the reason, turn on -Xlog-implicits
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for c.universe.TypeTag[c.Type] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
materializing requested c.universe.type.TypeTag[c.Type] using `package`.this.materializeTypeTag[c.Type](c.universe)
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for scala.reflect.base.Universe#TypeTag[c.Type] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
macro expansion has failed: cannot reify TypeTag having unresolved type parameter c.Type at source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402
Macros_1.scala:13: `package`.this.materializeTypeTag[Traversable[_]](c.universe) is not a valid implicit value for c.TypeTag[Traversable[_]] because:
failed to typecheck the materialized tag: 
cannot reify TypeTag having unresolved type parameter c.Type
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for c.TypeTag[Traversable[_]] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
materializing requested c.universe.type.TypeTag[Traversable[_]] using `package`.this.materializeTypeTag[Traversable[_]](c.universe)
looking for macro implementation: macro method materializeTypeTag
macro expansion is serviced by a fast track
calculateUndetparams: Set()
typechecking macro expansion `package`.this.materializeTypeTag[Traversable[_]](c.universe) at source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402
looking for macro implementation: macro method materializeTypeTag
macro expansion is serviced by a fast track
argss: List(List(MacroContext(materializeTypeTag@source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402 +0)), List(Expr[Nothing](c.universe)))
rawArgs: List(MacroContext(materializeTypeTag@source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402 +0), Expr[Nothing](c.universe))
inferring implicit value of type scala.reflect.base.Universe#TypeTag[Traversable[_]], macros = false
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for scala.reflect.base.Universe#TypeTag[Traversable[_]] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
implicit search has failed. to find out the reason, turn on -Xlog-implicits
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for c.universe.TypeTag[c.Type] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
materializing requested c.universe.type.TypeTag[c.Type] using `package`.this.materializeTypeTag[c.Type](c.universe)
Macros_1.scala:13: <evidence$1: error> is not a valid implicit value for scala.reflect.base.Universe#TypeTag[c.Type] because:
hasMatchingSymbol reported threw error(s)
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
macro expansion has failed: cannot reify TypeTag having unresolved type parameter c.Type at source-C:\Projects\Kepler\sandbox\Macros_1.scala,line-13,offset=402
Macros_1.scala:13: `package`.this.materializeTypeTag[Traversable[_]](c.universe) is not a valid implicit value for c.TypeTag[Traversable[_]] because:
failed to typecheck the materialized tag: 
cannot reify TypeTag having unresolved type parameter c.Type
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
Macros_1.scala:13: error: No TypeTag available for Traversable[_]
       if (tpe <:< c.typeOf[Traversable[_]]) {
                           ^
one error found
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 8, 2012

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

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 17, 2012

@xeno-by said:
No longer reproducible in M5.

@scabug scabug closed this Jul 17, 2012
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 17, 2012

@hubertp said:
I guess it still warrants a test case, right?

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 17, 2012

@xeno-by said:
Sure thing: scala/scala#923.

@scabug scabug added this to the 2.10.0-M5 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.