Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

No output for reflection expression #113

Open
dotta opened this Issue · 2 comments

1 participant

@dotta
Owner

The following doesn't produce any output

object Reflection {
  import scala.reflect.runtime.{universe => ru }
  ru.reify{ object Test { println("Hello World!") } }
}

While I would expect it to print

res0: reflect.runtime.universe.Expr[Unit] = 
Expr[Unit]({
  object Test extends Object {
    def <init>() = {
      super.<init>();
      ()
    };
    scala.this.Predef.println("Hello World!")
  };
  ()
})

Just like in the REPL.

Here is the the instrumented code

object Reflection {;import org.scalaide.worksheet.runtime.library.WorksheetSupport._; def main(args: Array[String])=$execute{;$skip(63);
  import scala.reflect.runtime.{universe => ru }
  ru.reify{ object Test { println("Hello World!") } }
}}

Which makes it pretty clear that this is a bug in the instrumentation. What I'd expect to see is something like the following:

object Reflection {;import org.scalaide.worksheet.runtime.library.WorksheetSupport._; def main(args: Array[String])=$execute{;$skip(63)
  import scala.reflect.runtime.{universe => ru }; val res$0 =
  ru.reify{ object Test { println("Hello World!") } };System.out.println("""res0: reflect.runtime.universe.Expr[Unit] = """ + $show(res$0))}
}}
@dotta
Owner

And, of course, this is now working fine. I'm puzzled.

@dotta dotta closed this
@dotta
Owner

Oh, I see! Apparently, this always breaks (consistently) on a freshly created project!

Bottom line, to reproduce the issue, create a new Scala project, then create a worksheet and paste the snippet provided in the description, and you'll see the issue.

Then, if you play around enough time with the same worksheet, you may eventually get it to a state where it starts doing the right thing. Don't ask why, I'm still trying to figure this out.

@dotta dotta reopened this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.