Skip to content

Conversation

@halotukozak
Copy link
Member

@transientDefault should not compile when default value was not provided

@halotukozak halotukozak self-assigned this Sep 22, 2025
@halotukozak halotukozak force-pushed the transient-default-warn-when-value-not-provided branch from 0258539 to deb5dbb Compare September 22, 2025 13:56
@halotukozak
Copy link
Member Author

@ddworak @sebaciv how about this one?

def isTransientDefault(param: ApplyParam): Boolean =
param.defaultValue.nonEmpty && hasAnnotation(param.sym, TransientDefaultAnnotType)

def isTransientDefault(param: ApplyParam, warnIfDefaultNotProvided: Boolean = false): Boolean =
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer overloading to avoid binary compatibility problems

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copilot AI review requested due to automatic review settings January 5, 2026 09:02
Copy link

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 adds compile-time validation for the @transientDefault annotation to ensure it is only used on parameters that have default values. Previously, the annotation would silently have no effect when applied to parameters without defaults.

Key Changes:

  • Added compile-time warning/error when @transientDefault is used without a default value
  • Refactored the isTransientDefault method to support optional validation
  • Added test coverage for both valid and invalid usage of @transientDefault

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
GenCodecMacros.scala Refactored isTransientDefault to validate that @transientDefault has a default value and emit an error when missing
NotUsedTransientDefault.scala Added test suite to verify compile-time validation of @transientDefault annotation usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@halotukozak halotukozak requested a review from sebaciv January 5, 2026 12:41
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.

3 participants