Skip to content

Conversation

@SolalPirelli
Copy link
Contributor

Fixes #23487

*/
private def mkContainerTree(x: ValOrDefDef, isVolatile: Boolean)(using Context): (Names.TermName, ValDef) =
val claz = x.symbol.owner.asClass
val tpe = if isVolatile then defn.ObjectType else x.tpe.widen.resultType.widen
Copy link
Contributor Author

@SolalPirelli SolalPirelli Jan 6, 2026

Choose a reason for hiding this comment

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

The original code used:

  • this different type for the container symbol
  • defaultValue(tpe) as the original value for the unsafe version and nullLiteral for the safe version

Using one of these two options for tpe regardless of context causes crashes in the newly added test, in both cases because we can't prove Long <: Object, but preserving the original behavior as this line does works fine.

I don't like it though, I think I'm missing something.

@SolalPirelli SolalPirelli force-pushed the solal/transient-threadUnsafe branch from 077105a to 20bd1d5 Compare January 12, 2026 15:15
@SolalPirelli SolalPirelli marked this pull request as ready for review January 13, 2026 08:37
@SolalPirelli SolalPirelli requested a review from sjrd January 13, 2026 08:40
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.

Lazy vals annotated with @threadUnsafe ignore @transient annotation

3 participants