Skip to content

No private field promotion on an extension type #53439

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

Closed
sgrekhov opened this issue Sep 6, 2023 · 2 comments
Closed

No private field promotion on an extension type #53439

sgrekhov opened this issue Sep 6, 2023 · 2 comments
Labels
model-field-promotion Implementation of field promotion

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Sep 6, 2023

The following tests fails in both CFE and Analyzer

// SharedOptions=--enable-experiment=inline-class

extension type ET(int? _id) {
  void test() {
    if (_id is int) {
      _id.isOdd; // Analyzer COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
                 // CFE Error: Property 'isOdd' cannot be accessed on 'int?' because it is potentially null.
    }
  }
}

main() {
  ET et = ET(1);
  et.test();
  if (et._id != null) {
    et._id.isEven;  // Analyzer COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
                    // CFE Error: Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
  }
}

cc @stereotype441 @eernstg

Tested on the exdge SDK (Sept 6, 2023) on Linux x64

@eernstg
Copy link
Member

eernstg commented Sep 6, 2023

Right, the representation variable of an extension type should be promotable (private or not).

[Edit: The rules were changed after I wrote this: An extension type representation variable is only promotable if it is private. However, it is then unconditionally promotable, and it doesn't matter that other declarations in the same library have the same name.]

@stereotype441
Copy link
Member

Thanks for the report! Since this concerns an unreleased feature (extension types) I'll plan to look at it after all other field pormotion work is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
model-field-promotion Implementation of field promotion
Projects
None yet
Development

No branches or pull requests

3 participants