WiseIndian / Coroutines-for-Scala-3

3 stars 2 forks source link

Type inference of coroutines #14

Open WiseIndian opened 4 years ago

WiseIndian commented 4 years ago

It would be nice if we could create coroutines like so:

class A 
class B extends A
coroutine {
  yieldval(new A()) 
  yieldval(new B())
}

so that this code would return a coroutine with the tightest type (Coroutine[A] in this case) out of the yieldval and join operations within that coroutine body.

liufengyun commented 4 years ago

It can be done with white-box macros. Maybe make it low priority, and focus on other use cases.

liufengyun commented 4 years ago

Another subtlety with inference in Dotty is that you can always produce a union type A | B, even if A and B are disjoint.

WiseIndian commented 4 years ago

thanks for the feedback.