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

incorrect reification of free types #5738

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

Comments

@scabug
Copy link

commented May 3, 2012

import scala.reflect.mirror._

object Test extends App {
  def f[T](a: T, b: T) = {
    reify(a.toString + b)
    reify(a + b.toString)
  }
}
reifying = 
a.toString().+(b)
Apply(Select(Apply(Select(Ident(newTermName("a")), newTermName("toString")), List()), newTermName("$plus")), List(Ident(newTermName("b"))))
reifee is located at: source-C:\Projects\Kepler\sandbox\Test.scala,line-5,offset=105
prefix = scala.reflect.`package`.mirror
[calculate phase]
[reshape phase]
[metalevels phase]
[interlude]
symbol table = <empty>
reifee = 
a.toString().+(b)
Apply(Select(Apply(Select(Ident(newTermName("a")), newTermName("toString")), List()), newTermName("$plus")), List(Ident(newTermName("b"))))
[reify phase]
Free term: value a(value)
splicing T
launching implicit search for scala.reflect.`package`.mirror.TypeTag[T]
reifying = T
prefix = scala.reflect.`package`.mirror
splicing T
splicing has been cancelled: spliceTypesEnabled = false
Free type: type T (type)
Filling in: type T (type)
reified = {
  val $mr: scala.reflect.`package`.mirror.type = scala.reflect.`package`.mirror;
  val free$T1 = $mr.newFreeType("T", $mr.TypeBounds($mr.staticClass("scala.Nothing").asTypeConstructor, $mr.staticClass("scala.Any").asTypeConstructor), $mr.TypeTag[T](null, null), 8208L, "defined by f in Test.scala:4:9");
  $mr.TypeTag[T]($mr.TypeRef($mr.NoPrefix, free$T1, scala.collection.immutable.List.apply()), Predef.this.classOf[Object])
}
implicit search has produced a result: {
  val $mr: reflect.mirror.type = scala.reflect.`package`.mirror;
  val free$T1: $mr.Symbol = $mr.newFreeType("T", $mr.TypeBounds.apply($mr.staticClass("scala.Nothing").asTypeConstructor, $mr.staticClass("scala.Any").asTypeConstructor), $mr.TypeTag.apply[T](null, null), 8208L, "defined by f in Test.scala:4:9");
  $mr.TypeTag.apply[T]($mr.TypeRef.apply($mr.NoPrefix, free$T1, immutable.this.Nil), classOf[java.lang.Object])
}
inlined the splicee: $mr.TypeRef.apply($mr.NoPrefix, free$T1, immutable.this.Nil)
Free term: value b(value)
splicing T
cache hit: $mr.TypeRef.apply($mr.NoPrefix, free$T1, immutable.this.Nil)
Filling in: type T (type)
Filling in: value a (value)
Filling in: value b (value)
reified = {
  val $mr: scala.reflect.`package`.mirror.type = scala.reflect.`package`.mirror;
  val free$T1: $mr.Symbol = $mr.newFreeType("T", $mr.TypeBounds.apply($mr.staticClass("scala.Nothing").asTypeConstructor, $mr.staticClass("scala.Any").asTypeConstructor), $mr.TypeTag.apply[T](null, null), 8208L, "defined by f in Test.scala:4:9");
  val free$a1 = $mr.newFreeTerm("a", $mr.TypeRef.apply($mr.NoPrefix, free$T1, immutable.this.Nil), a, 17592186052608L, "defined by f in Test.scala:4:12");
  val free$b1 = $mr.newFreeTerm("b", $mr.TypeRef.apply($mr.NoPrefix, free$T1, immutable.this.Nil), b, 17592186052608L, "defined by f in Test.scala:4:18");
  $mr.Expr[String]($mr.Apply($mr.Select($mr.Apply($mr.Select($mr.Ident(free$a1), $mr.newTermName("toString")), scala.collection.immutable.List.apply()), $mr.newTermName("$plus")), scala.collection.immutable.List.apply($mr.Ident(free$b1))))($mr.TypeTag[String]($mr.staticClass("java.lang.String").asTypeConstructor, Predef.this.classOf[String]))
}
reifying = 
scala.this.Predef.any2stringadd(a).+(b.toString())
Apply(Select(Apply(Select(Select(This(newTypeName("scala")), newTermName("Predef")), newTermName("any2stringadd")), List(Ident(newTermName("a")))), newTermName("$plus")), List(Apply(Select(Ident(newTermName("b")), newTermName("toString")), List())))
reifee is located at: source-C:\Projects\Kepler\sandbox\Test.scala,line-6,offset=122
prefix = scala.reflect.`package`.mirror
[calculate phase]
[reshape phase]
[metalevels phase]
[interlude]
symbol table = <empty>
reifee = 
scala.this.Predef.any2stringadd(a).+(b.toString())
Apply(Select(Apply(Select(Select(This(newTypeName("scala")), newTermName("Predef")), newTermName("any2stringadd")), List(Ident(newTermName("a")))), newTermName("$plus")), List(Apply(Select(Ident(newTermName("b")), newTermName("toString")), List())))
[reify phase]
This for package scala, reified as This
Free term: value a(value)
splicing T
cache hit: $mr.TypeRef.apply($mr.NoPrefix, free$T1, immutable.this.Nil)
Free term: value b(value)
splicing T
cache hit: $mr.TypeRef.apply($mr.NoPrefix, free$T1, immutable.this.Nil)
Filling in: value a (value)
Filling in: value b (value)
reified = {
  val $mr: scala.reflect.`package`.mirror.type = scala.reflect.`package`.mirror;
  val free$a2 = $mr.newFreeTerm("a", $mr.TypeRef.apply($mr.NoPrefix, free$T1, immutable.this.Nil), a, 17592186052608L, "defined by f in Test.scala:4:12");
  val free$b2 = $mr.newFreeTerm("b", $mr.TypeRef.apply($mr.NoPrefix, free$T1, immutable.this.Nil), b, 17592186052608L, "defined by f in Test.scala:4:18");
  $mr.Expr[String]($mr.Apply($mr.Select($mr.Apply($mr.Select($mr.Select($mr.This($mr.staticModule("scala").moduleClass), $mr.newTermName("Predef")), $mr.newTermName("any2stringadd")), scala.collection.immutable.List.apply($mr.Ident(free$a2))), $mr.newTermName("$plus")), scala.collection.immutable.List.apply($mr.Apply($mr.Select($mr.Ident(free$b2), $mr.newTermName("toString")), scala.collection.immutable.List.apply()))))($mr.ConcreteTypeTag[String]($mr.staticClass("java.lang.String").asTypeConstructor, Predef.this.classOf[String]))
}

Test.scala:6: error: Cannot materialize Expr because:
scala.reflect.internal.Types$TypeError: not found: value free$T1
    reify(a + b.toString)
         ^
one error found
@scabug

This comment has been minimized.

Copy link
Author

commented May 3, 2012

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

@scabug

This comment has been minimized.

Copy link
Author

commented Jun 9, 2012

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

@scabug scabug closed this Jun 9, 2012

@scabug scabug added the reflection label Apr 7, 2017

@scabug scabug added this to the 2.10.0-M3 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
2 participants
You can’t perform that action at this time.