-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: SplitByType
macros
#133
Conversation
@raquo the CI survived |
Thanks! Everything looks good now, I've tested it in the laminar-demo, and it behaves as expected. I made one small change – handleValue(Foo)(...) now accepts I still need to do a bunch more work on this, incl. writing docs and ideally a test in Laminar repo, but I plan to release this and some other changes in 17.2 soon. |
Yall can try this in 17.2.0-M1 preview. More info in discord |
@HollandDM Currently the macros require an import, but I would like to make them available without any special imports. To make extension methods available without an import, typically I would for example move I would do the same for My question for you is – would it be ok to move your macro extension methods this way, or is there some reason, whether functional or conventional / stylistic, where this approach would be frowned upon? If it weren't for macros, I would be fine with this, just wanted to check with you if there are any macro-specific considerations for this. I haven't started on this yet. |
that is how we all do it :) |
@raquo scala 3 macros tend to be in the same files as the inline def which translated into them. So maybe you will have to move some macro functions as well. I'm not sure what would happen if they are separated, you can try it if you want. |
@HollandDM I made In SplitMatchOneMacros, we have both extension [Self[+_] <: Observable[_], I, O](
inline matchSplitObservable: SplitMatchOneObservable[Self, I, O]
) { ... } into However, I can't figure out how to accomplish that. Naively moving the extension methods and updating impl method references with
And they're stubborn. I tried various strategies with importing, exporting, extending, but none solved the issue. "Best" I got was when trying to export SplitMatchOneMacros.{*, given} from SplitMatchOneObservable (I was trying to export the extension methods):
Normally I can sort such things out, but I don't understand macros or their concepts and constraints, so I'm poking at things blindly. Any ideas how to make this work? Would be a bummer if the new feature required additional imports... |
@raquo let's me have a look, will contact back to you later |
This is the continuation of #116 and addresses these issues
Varargs
, which should be more durable than our previous ad-hoc mechanism. Compiled with scala 3.3.3, 3.3.4 and 3.5.2, so it should be good now.{ case t: T => t}
and{ case _: V => v }
partial function that we inlined into our macros. As @raquo said, this should not be a problem for us, becausePartialFunction
in scala is atrait
, so it always initiates new instance when defined, inlined or not. IMO, we don't have to fix this. But to please the compiler, I've created some dummy classes that act as the placeholders for those partial functions. The macro implementation will replace them with the actual partial functions.handleCase
was added. The new mechanism takes advantage of scala's internalVarargs
, so the extraction will be a lot quicker. I added a test which contains 100handleCase
s and run it in sbt with -javaopt = -Xmx1024m -Xms1024m and everything seems to be fine.