-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Checking flags for new symbols using Quotes API is too restrictive #17764
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
Comments
Hi @pweisenburger. The code will still work if the val allowedFlags = Flags.Deferred | Flags.Final | Flags.Given | Flags.Implicit | Flags.JavaStatic | Flags.Local |
Flags.Method | Flags.Override | Flags.Private | Flags.PrivateLocal | Flags.Protected
val newFlags = stat.symbol.flags & allowedFlags
val symbol = Symbol.newMethod(owner, name, info, newFlags, privateWithin.fold(Symbol.noSymbol) { _.typeSymbol }) I understand the concern with the code suddenly breaking, but I am pretty sure the previous behavior was more of a buggy one. @nicolasstucki what do you think, should those two flags be reallowed? |
You're right, that's true. I still would prefer the compilation not to depend on the presence/absence of certain compiler flags; especially as the flag are set on the project using the macro (not the one implementing it).
Thanks, that would indeed fix the issue. It still begs the questions
|
We should allow |
I added a pull request that allows In case you want to merge this, is there a chance to merge for 3.3.1? As this code worked in the last release 3.3.0, this would avoid a release that breaks the code. |
This will probably be fixed in 3.3.2. The checks are only run with |
Yes, this is what I was hoping to avoid; but I suppose I can work around it ... |
…I less restrictive (#18217) Fixes #17764 Allows `Flags.Artifact` and `Flags.Synthetic` and the other ["flags that could be allowed"](https://github.com/lampepfl/dotty/blob/3.3.1-RC1/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala#L2880-L2885) as they are valid flags and there is no reason to forbid them.
Compiler version
3.3.2-RC1-bin-20230602-57c2b66-NIGHTLY
Minimized code
#16565 introduced checks for the flags when creating new symbols using the Quotes API. However, this makes it difficult to copy flags from existing symbols under expansion to new symbols. Below is a (not very useful but minimized) example that empties the body of
DefDef
nodes and changes the return type toUnit
. It works under Scala 3.3.0 but fails in Scala 3.3.1 due to the check and the fact thatDefDef
the macro encounters has more flags than the check allows; in the example these areFlags.Artifact
andFlags.Synthetic
.Overall, I would advocate for allowing the flags with the comment "Flags that could be allowed", plus
Flags.Artifact
. I think there is no reason to be overly restrictive.Also, the code worked in 3.3.0; it would be nice to make 3.3.1 not break it.
Example
The text was updated successfully, but these errors were encountered: