Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@octavz
Copy link
Contributor

@octavz octavz commented Mar 23, 2021

Resolves #4804

@octavz octavz force-pushed the annotation_for_throwing branch from 76fe861 to 55247e9 Compare March 23, 2021 20:08
adamgfraser
adamgfraser previously approved these changes Mar 24, 2021
Copy link
Contributor

@adamgfraser adamgfraser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Good to go when compilation issues are resolved.

@octavz
Copy link
Contributor Author

octavz commented Mar 27, 2021

I will get back to this these days, it seems is more time consuming than I thought since apparently there is a bug causing that warning in 2.11.
I have to find another way to avoid the warning.

@octavz
Copy link
Contributor Author

octavz commented Apr 1, 2021

@ioleo @adamgfraser

It appears that on scala 211 with java8 it will throw an warning if it finds an annotation on a val or lazy val.

Now, the lazy val worths the treatement because we can still suspend the error however for vals it makes no sense, since the runtime will crash anyway. In order to avoid the warning and keep things simple I would suggest to have @throwing annotations only for defs and not vals lazy or otherwise, and the values by default will have Nothing on the error channel.

This still adds values since:

  1. It fixes my problem of not needing .orDie
  2. for def one can still mark it as @throwing getting the "proper ZIO behavior"

I don't have the resources to go more into macros and fix that warning for scala 211. I suppose that I have to expand that annotation and make it compileTimeonly in order for the compiler to erase it, but I don't know how to do it nor if it's worth the effort IMO.

Please let me know what you think.

Thanks

@adamgfraser
Copy link
Contributor

@octavz I think your proposal makes sense.

@octavz
Copy link
Contributor Author

octavz commented Apr 6, 2021

I removed the @throwing annotation support for vals, and things seem to be in order, if the build passes please have another look on it and we can merge it.

Thank you.

@accessible
object Module {
trait Service {
def pureMethog(v: Something): SomethingElse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def pureMethog(v: Something): SomethingElse
def pureMethod(v: Something): SomethingElse

@octavz octavz force-pushed the annotation_for_throwing branch from 753d959 to db01650 Compare April 6, 2021 15:47
@adamgfraser
Copy link
Contributor

@octavz Can you resolve conflicts?

@octavz
Copy link
Contributor Author

octavz commented Apr 9, 2021

@adamgfraser it is done

@adamgfraser adamgfraser merged commit 709354e into zio:master Apr 9, 2021
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.

ZIO Macros: the error channel could be better controlled when we have to deal with non zio vals/defs

3 participants