How can I suppress `RestrictsSuspension` ? I have ...
# compiler
e
How can I suppress
RestrictsSuspension
? I have my own additional dsl on top of sequence building but I cannot call through to the underlying sequence builder from my DSL because of restricts suspension 😞
y
You could make all the methods have a SequenceScope extension receiver. I'd say doing that while also using contexts would probably be the easiest way.
e
I agree (havent tried) but I want to avoid that actually. My dsl also has restricts suspension and should be the only way (I need to intercept the items at that point)
y
If you have a gist or repository or something with some minimal reproducer I could mess around with it and see if I can get it working!
e
Copy code
@RestrictsSuspension
protected sealed interface ProduceOptionsScope {
  suspend fun <T> yield(option: Option<T>): Option<T>
  fun <T> value(block: () -> T): Value<T> = ValueImpl(block)
  fun <T> noValue(): Value<Nothing> = ValueImpl { error("No value provided") }
}

protected sealed interface Value<T>
It was staring me in the face entire time:
@Suppress("ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL")
(its in the printed error message)
y
Just be mindful that suppressing errors is not guaranteed to work in the future, even if it's working right now
e
Yeah thats fine for now.