Skip to content
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 code suggestion for PR #23473 #24179

Conversation

KRVPerera
Copy link
Contributor

Purpose

Describe the problems, issues, or needs driving this feature/fix and include links to related issues.

Fixes #15533
#23473 (comment)

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

KRVPerera added 14 commits June 16, 2020 08:55
Annotation value is restricted to true, map<anydata|readonly> or
map<anydata|readonly>[] value. Changes will also make sure that
annotation value is a read only clone of the given value. Therefore user
 cannot change annotation value via annotation access.
Uniformity for `readonly & T` and `T & readonly`. Chose `readonly & T`.
Refactor java code logic. Instead of making fields readonly for
implementations of abstract objects, whole object is made readonly.
switch (expr.getKind()) {
case LITERAL:
case NUMERIC_LITERAL:
return true;
case INVOCATION:
BLangInvocation invocation = (BLangInvocation) expr;
if (invocation.name.getValue().equals(CLONE_READ_ONLY)) {
Copy link
Member

Choose a reason for hiding this comment

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

Thinking about this a little more, currently an invocation is not a compile-time-known value right?

So I think we should differentiate between the .cloneReadOnly we add, and what the user may have added for a field.

Shall we allow this only when this is the attachment itself, and return false for recursive checks?

@MaryamZi MaryamZi added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Jun 16, 2020
@MaryamZi MaryamZi added this to the Ballerina 2.0-Preview1 milestone Jun 16, 2020
Annotation expr is wrapped in cloneReadOnly by internal desugar. We
unwrap only this call and prevent other calls being unwrapped.
@KRVPerera
Copy link
Contributor Author

Closing as will be introduced changes by original PR:#23473

@KRVPerera KRVPerera closed this Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Annotations] Restrict constraints of maps/fields of records to be anydata and freeze the values
2 participants