portable-scala / portable-scala-reflect

Platform independent reflection for Scala
BSD 3-Clause "New" or "Revised" License
42 stars 14 forks source link

WIP: Add experimental support for ScalaNative #20

Closed LeeTibbert closed 3 years ago

LeeTibbert commented 4 years ago

This is a first cut, brute force, obvious port of portablescala.reflect to ScalaNative. I believe it raises some engineering and/or maintenance issues which deserve at least a small amount of discussion.

I appreciate kind suggestions & recommendations. Thank you.

I can not tell if it actually works in Zio because of NIR binary version issues. The latter probably will need to wait for an 0.4.0-M3 release.

sjrd commented 4 years ago

Thanks for the PR @LeeTibbert.

It's very good that we could validate the implementation in Scala Native master through the work you did here so far! Thank you for that.

However, it is a bit early to merge the changes in this repo, for several reasons that you identified, but crucially the fact we can't really depend on a SNAPSHOT version of Scala Native.

For the duplication and changes in tests, I hope that by the next release of Scala Native we'll have JUnit support, which will allow to apply the existing tests without any change.

For the duplication in the source of the JS and Native implementation, my recommendation for this specific case is to just duplicate, without trying to be fancy with rewrites/preprocessing. Preprocessing comes with limitations for links to the sources online, that are stored in the SJSIR and NIR for debugging purposes. Since the duplication is very shallow (there is no logic in those implementation, only Scaladocs and dumb forwarders), plus the fact that the tests will be 100% shared, there is no chance to introduce a fix in one version but not the other.

All that said, I suggest we leave this PR dormant until a true release of SN is out, including with JUnit support.

LeeTibbert commented 3 years ago

A lot has changed in the SN world since April. In particular, SN now has support for the JUnit environment.

When SN 0.next is announced, I hope to revisit the top of this PR, probably in a new one.

In my Proof of concept sandbox work to help a number of other projects publish for 0.next soon after it releases, I found the availability of portable-scala-reflect to reduce the amount of fiddling: exactly the intent of portable-scala-reflect in the first place.

LeeTibbert commented 3 years ago

@lolgab @sideeffffect Thank you for the suggested edits.

I will dust this off and see what other edits the passage of time requires. I suspect that it needs more than point edits. I do not want to embarrass myself and waste other people's time by submitting an obviously flawed PR.

Yes, the recent release of Scala Native 0.4.0 means that other people may be looking for portable-scala reflect support, so time is an issue.

lolgab commented 3 years ago

@LeeTibbert This library can simplify implementations of testing libraries, so it comes in very handy :-)

LeeTibbert commented 3 years ago

@lolgab Indeed, I got to this PR in the first place by trying to extend your Zio port ;-) That is, you lead me here!

After 5 minutes on the task, it looks like I should do two new PRs, in rapid succession. One would update these changes (i.e. JUnit is now available in SN). The second would bump the version in this repository.

Today is Inauguration Day in the US, so I might not get much done today but I also do not want to block others. (I know the curses I used when I had to do SN-only code in my private Zio work).

LeeTibbert commented 3 years ago

PR #24 is required to get Scala versions supported by Scala Native (and blocks further work here).

I have the required current changes working in my sandbox. I will create a superseding PR after PR #24 is merged.

sideeffffect commented 3 years ago

Another attempt https://github.com/portable-scala/portable-scala-reflect/pull/27

LeeTibbert commented 3 years ago

This WIP was good at the time it was created but needs a new PR, due to the passage of time. JUnit tests etc are no longer needed, & other changes.

I have the changes for the new PR. When PR #27 or such sorts out I can create that new PR (or someone else can get thru the gate before me, no problem at my end).

Right now, I am trying to work out the required .travis.yml changes (which are still evolving). Step by step, for something that should be simple...

It looks like in the very near future this Repository will need to move off Travis, so I am striving for timeliness of .yml change, rather than perfection.

LeeTibbert commented 3 years ago

This was a step on the path towards PR #31. Closing in favor of that PR.