Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is this a bug in opaque types? #23050

Unanswered
mwisnicki asked this question in General Question
Apr 25, 2025 · 1 comments · 2 replies
Discussion options

trait Entity[T <: Entity[?]] {
 def id: Types.Id[T] = Types.defaultId
}
object Types {
 opaque type Id[T <: Entity[?]] = Long
 def defaultId[T <: Entity[?]]: Id[T] = 0L
}
List[Entity[?]]().groupBy(_.id).get("not an opaque long")

The above code compiles but maybe shouldn't?
The key of that map should be of opaque type Id but instead becomes Any.

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

What behavior do you get and what did you expect instead?

If you don't know whether it's a bug or not, then there are more chances that its is correct than buggy. Perhaps ask on https://users.scala-lang.org/ instead?

You must be logged in to vote
2 replies
Comment options

I updated my question with expectation and actual behavior. Will try posting on the other site, thanks.

Comment options

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

AltStyle によって変換されたページ (->オリジナル) /