Skip to content

Conversation

@xeno-by
Copy link
Contributor

@xeno-by xeno-by commented Dec 7, 2011

Adjust toolbox to escalate errors reported during reflective compilation.

Without this functionality, errors get swallowed and lead to weirdness
like https://issues.scala-lang.org/browse/SI-5274. The only meaningful
part of the output in the bug report linked above is the first line.
Subsequent stack trace is at best useless and at worst misleading.
Now the error report is much more sane: https://gist.github.com/1443232

Review by @odersky.

Adjust toolbox to escalate errors reported during reflective compilation.

Without this functionality, errors get swallowed and lead to weirdness
like https://issues.scala-lang.org/browse/SI-5274. The only meaningful
part of the output in the bug report linked above is the first line.
Subsequent stack trace is at best useless and at worst misleading.
Now the error report is much more sane: https://gist.github.com/1443232

Review by @odersky.
@paulp paulp merged commit 1f8d642 into scala:master Dec 7, 2011
gkossakowski added a commit to gkossakowski/scala that referenced this pull request Jan 11, 2012
When emitting Jribble for a catch clause, use the symbol's name
rssh pushed a commit to rssh/scala that referenced this pull request Mar 19, 2013
New starr with latest version of quasiquotes
retronym referenced this pull request in retronym/scala Aug 19, 2016
  - Avoid boxing the {Object, Int, ...}Ref itself by storing it in
    a val, not a var
  - Avoid box/unbox of primitive lazy expressions due which are added
    to "adapt" it to the erased type of the fictional syncronized
    method, by using a `return`. We have to add a dummy throw after
    the synchronized block, but this is elimnated by the always-on
    DCE in the code generator.

```
⚡  qscalac -Xprint:mixin $(f "class C { def foo = { lazy val x = 42; x }}"); javap -private -c -cp . C
[[syntax trees at end of                     mixin]] // a.scala
package <empty> {
  class C extends Object {
    def foo(): Int = {
      lazy <artifact> val x$lzy: scala.runtime.LazyInt = new scala.runtime.LazyInt();
      C.this.x$1(x$lzy)
    };
    final private[this] def x$1(x$lzy$1: scala.runtime.LazyInt): Int = {
      x$lzy$1.synchronized({
        if (x$lzy$1.initialized().unary_!())
          {
            x$lzy$1.initialized_=(true);
            x$lzy$1.value_=(42)
          };
        return x$lzy$1.value()
      });
      throw null
    };
    def <init>(): C = {
      C.super.<init>();
      ()
    }
  }
}

Compiled from "a.scala"
public class C {
  public int foo();
    Code:
       0: new           #12                 // class scala/runtime/LazyInt
       3: dup
       4: invokespecial #16                 // Method scala/runtime/LazyInt."<init>":()V
       7: astore_1
       8: aload_1
       9: invokestatic  #20                 // Method x$1:(Lscala/runtime/LazyInt;)I
      12: ireturn

  private static final int x$1(scala.runtime.LazyInt);
    Code:
       0: aload_0
       1: dup
       2: astore_1
       3: monitorenter
       4: aload_0
       5: invokevirtual #31                 // Method scala/runtime/LazyInt.initialized:()Z
       8: ifne          22
      11: aload_0
      12: iconst_1
      13: invokevirtual #35                 // Method scala/runtime/LazyInt.initialized_$eq:(Z)V
      16: aload_0
      17: bipush        42
      19: invokevirtual #39                 // Method scala/runtime/LazyInt.value_$eq:(I)V
      22: aload_0
      23: invokevirtual #42                 // Method scala/runtime/LazyInt.value:()I
      26: istore_2
      27: goto          33
      30: aload_1
      31: monitorexit
      32: athrow
      33: aload_1
      34: monitorexit
      35: iload_2
      36: ireturn
    Exception table:
       from    to  target type
           4    30    30   Class java/lang/Throwable

  public C();
    Code:
       0: aload_0
       1: invokespecial #43                 // Method java/lang/Object."<init>":()V
       4: return
}
```
da-liii pushed a commit to da-liii/scala that referenced this pull request Nov 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants