Skip to content

Copy @use and @consume annotations to parameter types #23324

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Linyxus
Copy link
Contributor

@Linyxus Linyxus commented Jun 6, 2025

... so that they will persist after tree copying.

fixes #23302.

@Linyxus Linyxus requested a review from Copilot June 7, 2025 12:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that the @use and @consume annotations on parameter symbols are correctly copied to their parameter types so that they persist after tree copying. Key changes include:

  • Updating error messages and test expectations in negative test cases.
  • Modifying printers and type handling code to include the new annotations.
  • Adjusting capture checking and transformation logic to accommodate the copied annotations.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/pos-custom-args/captures/cc-use-iterable.scala Adds persistence of annotations in Iterable methods.
tests/neg-custom-args/captures/unsound-reach-4.check Updates expected error messages to reflect the annotations.
tests/neg-custom-args/captures/unbox-overrides.check Adjusts error messages in override scenarios.
tests/neg-custom-args/captures/leak-problem-unboxed.scala Reflects changes in function reference resolution.
tests/neg-custom-args/captures/cc-annot-value-classes2.scala Updates value class tests for annotation correctness.
tests/neg-custom-args/captures/cc-annot-value-classes.scala Updates tests regarding annotation use in value classes.
compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala Updates printing logic to include the new annotations.
compiler/src/dotty/tools/dotc/core/Types.scala Implements copying of @use and @consume annotations.
compiler/src/dotty/tools/dotc/core/Definitions.scala Adds the new annotations to silent annotations.
compiler/src/dotty/tools/dotc/cc/SepCheck.scala Updates capture checking to refer to the new isConsumeParam check.
compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala Refines annotation propagation and handling in capture checking.
compiler/src/dotty/tools/dotc/cc/CaptureOps.scala Adds methods for dropping and checking the new annotations.
Comments suppressed due to low confidence (1)

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala:381

  • [nitpick] Consider revising the documentation comment for grammatical correctness. For example, change 'the annotation that are meant' to 'the annotations that are meant' and 'but was moved' to 'but were moved'.
/** Print the annotation that are meant to be on the parameter symbol but was moved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@use parameter gets ignored in value classes
1 participant