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

Cannot reify compound type trees #5840

Closed
scabug opened this issue May 27, 2012 · 3 comments

Comments

@scabug
Copy link

commented May 27, 2012

import scala.reflect.runtime.universe._

object Test extends App {
  reify {
    class C[T <: String with Singleton]
  }
}
myke compile C:\Projects\KeplerUnderRefactoring\sandbox\Test.scala 
git: branch = topic/reflection, commit = 1dffbf64ab2176da881e1a4925093543801bcb8c
psi: filename = cmd.exe, arguments = /C c:\PROGRA~1\Java\JDK16~1.0_2\bin\java.exe -cp "C:\Projects\KeplerUnderRefactoring\test\files\codelib\code.jar;C:\Projects\KeplerUnderRefactoring\lib\jline.jar;C:\Projects\KeplerUnderRefactoring\lib\fjbg.jar;C:\Projects\KeplerUnderRefactoring\build\locker\classes\compiler;C:\Projects\KeplerUnderRefactoring\build\locker\classes\library" -Dscala.usejavacp=true -Dscala.repl.vids=1 -Dscala.repl.autoruncode=C:\Users\xeno.by/.scala_autorun -Dscala.repl.maxprintstring=0 scala.tools.nsc.Main -deprecation -unchecked -Xexperimental -language:experimental.macros -Yreify-debug -Ymacro-debug-verbose -Xlog-implicits -Yshow-trees-compact -Yshow-trees-stringified -g:vars Test.scala, home = C:\Projects\KeplerUnderRefactoring\sandbox
undetParam added: type T
undetParam inferred: type T as Unit
looking for macro implementation: macro method reify
macro expansion is serviced by a fast track
calculateUndetparams: Set()
typechecking macro expansion scala.reflect.runtime.`package`.universe.reify[Unit]({
  class C[T >: Nothing <: String with Singleton] extends scala.AnyRef {
    def <init>(): C[T] = {
      C.super.<init>();
      ()
    }
  };
  ()
}) at source-C:\Projects\KeplerUnderRefactoring\sandbox\Test.scala,line-4,offset=75
looking for macro implementation: macro method reify
macro expansion is serviced by a fast track
argss: List(List(MacroContext(reify@source-C:\Projects\KeplerUnderRefactoring\sandbox\Test.scala,line-4,offset=75 +0)), List(Expr[Nothing]({
  class C[T >: Nothing <: String with Singleton] extends scala.AnyRef {
    def <init>(): C[T] = {
      C.super.<init>();
      ()
    }
  };
  ()
})))
paramss: List(List(value c), List(value expr))
rawArgs: List(MacroContext(reify@source-C:\Projects\KeplerUnderRefactoring\sandbox\Test.scala,line-4,offset=75 +0), Expr[Nothing]({
  class C[T >: Nothing <: String with Singleton] extends scala.AnyRef {
    def <init>(): C[T] = {
      C.super.<init>();
      ()
    }
  };
  ()
}))
reifying = 
{
  class C[T >: Nothing <: String with Singleton] extends scala.AnyRef {
    def <init>(): C[T] = {
      C.super.<init>();
      ()
    }
  };
  ()
}
Block(List(ClassDef(Modifiers(), newTypeName("C"), List(TypeDef(Modifiers(<param>), newTypeName("T"), List(), TypeTree().setType( <: String with Singleton))), Template(List(Select(Ident(newTermName("scala")), newTypeName("AnyRef"))), ValDef(Modifiers(private), newTermName("_"), TypeTree().setType(<notype>), EmptyTree), List(DefDef(Modifiers(), newTermName("<init>"), List(), List(List()), TypeTree().setType(C[T]), Block(List(Apply(Select(Super(This(newTypeName("")), newTypeName("")), newTermName("<init>")), List())), Literal(Constant(())))))))), Literal(Constant(())))
reifee is located at: source-C:\Projects\KeplerUnderRefactoring\sandbox\Test.scala,line-4,offset=75
prefix = scala.reflect.runtime.`package`.universe
[calculate phase]
boundSym: class C of type <notype>
boundSym: type T of type  <: String with Singleton
boundSym: constructor C of type C[T]
[reshape phase]
TypeTree, essential:  <: String with Singleton (TypeBoundsType)
verdict: rolled back to original  >: Nothing <: String with Singleton
TypeTree, essential: Nothing (TypeRef)
verdict: rolled back to original _root_.scala.Nothing
TypeTree, essential: String with Singleton (RefinedType)
verdict: rolled back to original String with Singleton
TypeTree, non-essential: C[T] (TypeRef)
verdict: discarded
[metalevels phase]
[interlude]
symbol table = <empty>

reifee = 
{
  class C[T >: Nothing <: String with Singleton] extends scala.AnyRef {
    def <init>(): C[T] = {
      C.super.<init>();
      ()
    }
  };
  ()
}
Block(List(ClassDef(Modifiers(), newTypeName("C"), List(TypeDef(Modifiers(<param>), newTypeName("T"), List(), TypeBoundsTree(Select(Select(Ident(newTermName("_root_")), newTermName("scala")), newTypeName("Nothing")), CompoundTypeTree(Template(List(Ident(newTypeName("String")), Ident(newTypeName("Singleton"))), ValDef(Modifiers(private), newTermName("_"), TypeTree().setType(<notype>), EmptyTree), List()))))), Template(List(Select(Ident(newTermName("scala")), newTypeName("AnyRef"))), ValDef(Modifiers(private), newTermName("_"), TypeTree().setType(<notype>), EmptyTree), List(DefDef(Modifiers(), newTermName("<init>"), List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(newTypeName("")), newTypeName("")), newTermName("<init>")), List())), Literal(Constant(())))))))), Literal(Constant(())))
[reify phase]
reifying bound type class Nothing (underlying type is Nothing, dealiased is Nothing)
tpe is locatable: reify as Ident(class Nothing)
macro expansion has failed: java.lang.Error: unexpected: bound type that doesn't have a tpe: Ident(newTypeName("String"))
Test.scala:4: error: exception during macro expansion: 
java.lang.Error: unexpected: bound type that doesn't have a tpe: Ident(newTypeName("String"))
	at scala.reflect.reify.codegen.GenTrees$class.reifyBoundType$1(GenTrees.scala:165)
	at scala.reflect.reify.codegen.GenTrees$class.reifyBoundType(GenTrees.scala:214)
	at scala.reflect.reify.codegen.GenTrees$class.reifyTree(GenTrees.scala:56)
	at scala.reflect.reify.Reifier.reifyTree(Reifier.scala:14)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:45)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:38)
	at scala.reflect.reify.phases.Reify$reifyStack$.push(Reify.scala:27)
	at scala.reflect.reify.phases.Reify$class.reify(Reify.scala:38)
	at scala.reflect.reify.Reifier.reify(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyList$1.apply(GenUtils.scala:11)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyList$1.apply(GenUtils.scala:11)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:237)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at scala.reflect.reify.codegen.GenUtils$class.reifyList(GenUtils.scala:11)
	at scala.reflect.reify.Reifier.reifyList(Reifier.scala:14)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:51)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:38)
	at scala.reflect.reify.phases.Reify$reifyStack$.push(Reify.scala:27)
	at scala.reflect.reify.phases.Reify$class.reify(Reify.scala:38)
	at scala.reflect.reify.Reifier.reify(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:237)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:19)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:14)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenTrees$class.reifyTree(GenTrees.scala:65)
	at scala.reflect.reify.Reifier.reifyTree(Reifier.scala:14)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:45)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:38)
	at scala.reflect.reify.phases.Reify$reifyStack$.push(Reify.scala:27)
	at scala.reflect.reify.phases.Reify$class.reify(Reify.scala:38)
	at scala.reflect.reify.Reifier.reify(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:237)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:19)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:14)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenTrees$class.reifyTree(GenTrees.scala:65)
	at scala.reflect.reify.Reifier.reifyTree(Reifier.scala:14)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:45)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:38)
	at scala.reflect.reify.phases.Reify$reifyStack$.push(Reify.scala:27)
	at scala.reflect.reify.phases.Reify$class.reify(Reify.scala:38)
	at scala.reflect.reify.Reifier.reify(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:237)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:19)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:14)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenTrees$class.reifyTree(GenTrees.scala:65)
	at scala.reflect.reify.Reifier.reifyTree(Reifier.scala:14)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:45)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:38)
	at scala.reflect.reify.phases.Reify$reifyStack$.push(Reify.scala:27)
	at scala.reflect.reify.phases.Reify$class.reify(Reify.scala:38)
	at scala.reflect.reify.Reifier.reify(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:237)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:19)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:14)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenTrees$class.reifyTree(GenTrees.scala:65)
	at scala.reflect.reify.Reifier.reifyTree(Reifier.scala:14)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:45)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:38)
	at scala.reflect.reify.phases.Reify$reifyStack$.push(Reify.scala:27)
	at scala.reflect.reify.phases.Reify$class.reify(Reify.scala:38)
	at scala.reflect.reify.Reifier.reify(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyList$1.apply(GenUtils.scala:11)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyList$1.apply(GenUtils.scala:11)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:237)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at scala.reflect.reify.codegen.GenUtils$class.reifyList(GenUtils.scala:11)
	at scala.reflect.reify.Reifier.reifyList(Reifier.scala:14)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:51)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:38)
	at scala.reflect.reify.phases.Reify$reifyStack$.push(Reify.scala:27)
	at scala.reflect.reify.phases.Reify$class.reify(Reify.scala:38)
	at scala.reflect.reify.Reifier.reify(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:237)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:19)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:14)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenTrees$class.reifyTree(GenTrees.scala:65)
	at scala.reflect.reify.Reifier.reifyTree(Reifier.scala:14)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:45)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:38)
	at scala.reflect.reify.phases.Reify$reifyStack$.push(Reify.scala:27)
	at scala.reflect.reify.phases.Reify$class.reify(Reify.scala:38)
	at scala.reflect.reify.Reifier.reify(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyList$1.apply(GenUtils.scala:11)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyList$1.apply(GenUtils.scala:11)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:237)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at scala.reflect.reify.codegen.GenUtils$class.reifyList(GenUtils.scala:11)
	at scala.reflect.reify.Reifier.reifyList(Reifier.scala:14)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:51)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:38)
	at scala.reflect.reify.phases.Reify$reifyStack$.push(Reify.scala:27)
	at scala.reflect.reify.phases.Reify$class.reify(Reify.scala:38)
	at scala.reflect.reify.Reifier.reify(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.reflect.reify.codegen.GenUtils$$anonfun$reifyProduct$2.apply(GenUtils.scala:19)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:237)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:237)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:19)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenUtils$class.reifyProduct(GenUtils.scala:14)
	at scala.reflect.reify.Reifier.reifyProduct(Reifier.scala:14)
	at scala.reflect.reify.codegen.GenTrees$class.reifyTree(GenTrees.scala:65)
	at scala.reflect.reify.Reifier.reifyTree(Reifier.scala:14)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:45)
	at scala.reflect.reify.phases.Reify$$anonfun$reify$1.apply(Reify.scala:38)
	at scala.reflect.reify.phases.Reify$reifyStack$.push(Reify.scala:27)
	at scala.reflect.reify.phases.Reify$class.reify(Reify.scala:38)
	at scala.reflect.reify.Reifier.reify(Reifier.scala:14)
	at scala.reflect.reify.Phases$$anonfun$mkReificationPipeline$1.apply(Phases.scala:35)
	at scala.reflect.reify.Phases$$anonfun$mkReificationPipeline$1.apply(Phases.scala:16)
	at scala.reflect.reify.Reifier.liftedTree1$1(Reifier.scala:62)
	at scala.reflect.reify.Reifier.reification(Reifier.scala:48)
	at scala.reflect.reify.package$.reifyTree(package.scala:26)
	at scala.reflect.makro.runtime.Reifiers$class.reifyTree(Reifiers.scala:22)
	at scala.reflect.makro.runtime.Context.reifyTree(Context.scala:6)
	at scala.reflect.makro.runtime.Context.reifyTree(Context.scala:6)
	at scala.reflect.reify.Taggers$$anonfun$1.apply(Taggers.scala:77)
	at scala.reflect.reify.Taggers$$anonfun$1.apply(Taggers.scala:77)
	at scala.reflect.reify.Taggers.translatingReificationErrors(Taggers.scala:83)
	at scala.reflect.reify.Taggers.materializeExpr(Taggers.scala:77)

  reify {
        ^
one error found
@scabug

This comment has been minimized.

Copy link
Author

commented May 27, 2012

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

@scabug

This comment has been minimized.

Copy link
Author

commented May 27, 2012

@xeno-by said (edited on May 27, 2012 1:35:42 PM UTC):
The problem is that parents of a Template are both symless and typeless. Unfortunately, body isn't perfect either.

A (meaningless) example:

import scala.reflect.runtime.universe._

object Test extends App {
  reify {
    val x: String with Singleton { def foo: Int } = ???
  }
}
@scabug

This comment has been minimized.

Copy link
Author

commented Jun 9, 2012

@xeno-by said:
Fixed in scala/scala@6355d1a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.