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

Nested nullary spores #27

Open
aleloi opened this issue Feb 11, 2016 · 0 comments
Open

Nested nullary spores #27

aleloi opened this issue Feb 11, 2016 · 0 comments

Comments

@aleloi
Copy link
Contributor

aleloi commented Feb 11, 2016

This test does not compile:

@Test
def nestedPTTCaptureNullary(): Unit = {
  val s = spore{
    delayed {
      spore {
        (_: Unit) => ()
      }
      ()
    }
  }
}

If the outer nullary spore is replaced by Spore[Unit, ...] as below, it compiles:

  @Test
  def nestedPTTCapture(): Unit = {
    val s = spore{
      (_: Unit) => {
        spore {
          (_: Unit) => ()
        }
        ()
      }
    }
  }

In both cases, traverser.traverse(body) (here) is called when checking the outer spore. In both cases, the value of body is a tree that looks like (something alpha-convertible to) this when printed with showRaw:

{
  {
    class anonspore$macro$62 extends AnyRef with scala.spores.Spore[Unit,Unit] { 
      def <init>(): anonspore$macro$62 = {
        anonspore$macro$62.super.<init>();
        ()
      };
      this._className_=(this.getClass().getName());
      def apply(x$macro$61: Unit): Unit = ()
    };
    new anonspore$macro$62()
  };
  ()
}

The difference is that when the traverser goes through the constructor call anonspore$macro$62.super.<init>(), it finds an illegal This reference here in the nullary spore case. This does not happen for (_: Unit) => ...-spores.

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

No branches or pull requests

1 participant