portals icon indicating copy to clipboard operation
portals copied to clipboard

Integrate Spores3 into the Portals Actor library

Open jspenger opened this issue 1 year ago • 3 comments

It would be a great addition to integrate Spores3 into the actor library, such that the "behaviors" are "spores".

An issue was encountered on a small test, as there seemed to be some issues to integrated typed ActorRefs. The following example illustrates this (at the time of writing, the example would cause an error for the Spore with the typed actor ref).

import com.phaller.spores.Spore

object Untyped extends App:
  case class ActorRef(key: Int)
  case class Message(msg: Int, aref: ActorRef)

  val sp = Spore[Message, Unit] {x => x match
    case Message(key, aref) => 
      println(x)
  }

  val aref = ActorRef(0)
  sp(Message(1, aref))

object Typed extends App:
  case class ActorRef[T](key: Int)
  case class Message(msg: Int, aref: ActorRef[Message])
  
  val sp = Spore[Message, Unit] {x => x match
    case Message(key, aref) => 
      println(x)
  }

  val aref = ActorRef[Message](0)
  sp(Message(1, aref))

Error message:

Exception occurred while executing macro expansion.
java.lang.AssertionError: NoDenotation.owner
	at dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:2511)
	at scala.quoted.runtime.impl.QuotesImpl$reflect$SymbolMethods$.owner(QuotesImpl.scala:2497)
	at scala.quoted.runtime.impl.QuotesImpl$reflect$SymbolMethods$.owner(QuotesImpl.scala:2497)
	at com.phaller.spores.Spore$package$.$anonfun$3(Spore.scala:76)
	at scala.collection.immutable.List.map(List.scala:250)
	at com.phaller.spores.Spore$package$.checkCaptures$1(Spore.scala:76)
	at com.phaller.spores.Spore$package$.checkBodyExpr(Spore.scala:121)
	at com.phaller.spores.Spore$.applyCode(Spore.scala:299)
	at com.phaller.spores.Spore$.inline$applyCode(Spore.scala:298)

jspenger avatar Apr 06 '23 21:04 jspenger