forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix calculation to drop transparent classes
Two fixes: 1. Don't forget about refinements 2. Don't dealias Fixes scala#16342 The first fix is essential for $16342. The second fix is just to keep types tidy and not open aliases needlessly. The previous incorrect version hid errors in previous regressions scala#15365 and scala#16311 which will need to be re-opened now.
- Loading branch information
Showing
4 changed files
with
26 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
type Opaque = Base with Tag | ||
|
||
type Base = Any { | ||
type Hack | ||
} | ||
|
||
trait Tag | ||
|
||
object Opaque { | ||
def apply(value: String): Opaque = value.asInstanceOf[Opaque] | ||
|
||
def unapply(userId: Opaque): Option[String] = Option(userId).map(_.value) | ||
def unappy2(userId: Base with Tag): Option[String] = Option(userId).map(_.value) | ||
} | ||
|
||
final implicit class Ops(private val userId: Opaque) extends AnyVal { | ||
def value: String = userId.asInstanceOf[String] | ||
} |