Symbol type parameters can be piracy - #375
Conversation
As described in JuliaTesting#374, types like ClosedInterval{T} = Interval{:closed,:closed,T} from IntervalSets blocked piracy-detection because `:closed` Symbol params caused `is_foreign` to return `false` unconditionally. Fundamentally, this revealed problems with the heuristic used by `is_foreign`. This was essentially acknowledged as a problem in the comments. The strategy taken here is to change the heuristic: if the combination `SomeType{:foo}` appears in the module that defines `SomeType`, then this combination is treated as a foreign type. If no such combination exists, then the Symbol is treated as a user-defined dispatch tag, and the type is treated as a user-defined type. To avoid the need for "grepping" through source code, there is one additional requirement for it to be treated as foreign: the type/symbol combination must be defined as a type alias (UnionAll) in the owning module. Fixes JuliaTesting#374. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #375 +/- ##
==========================================
+ Coverage 87.47% 87.61% +0.13%
==========================================
Files 12 12
Lines 527 541 +14
==========================================
+ Hits 461 474 +13
- Misses 66 67 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I saw that the one failure was about a label. I don't have suitable privileges to add labels, but I did add an entry to the CHANGELOG. |
|
Sorry for ignoring this for so long. I now had the time to finally review it. Unfortunately, this now has non-trivial conflicts due to #377. Could you try to resolve them? One semantical question, because I am not sure what you are concretely trying to do here: and a function As described earlier, defining |
As described in #374, types like
from IntervalSets blocked piracy-detection because
:closedSymbol params causedis_foreignto returnfalseunconditionally.Fundamentally, this revealed problems with the heuristic used by
is_foreign. This was essentially acknowledged as a problem in the comments.The strategy taken here is to change the heuristic: if the combination
SomeType{:foo}appears in the module that definesSomeType, then this combination is treated as a foreign type. If no such combination exists, then the Symbol is treated as a user-defined dispatch tag, and the type is treated as a user-defined type. To avoid the need for "grepping" through source code, there is one additional requirement for it to be treated as foreign: the type/symbol combination must be defined as a type alias (UnionAll) in the owning module.Fixes #374.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com