-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 (#16344)
Two fixes: 1. Don't forget about refinements 2. Don't dealias Fixes #16342 Fixes #16338 The first fix is essential for #16342. The second fix is just to keep types tidy and not open aliases needlessly. It probably fixes issues #16337 and #16336 as well, but the test cases were not self-contained, so I could not try them out. It might fix other recent regressions as well. The previous incorrect version hid errors in previous regressions #15365 and #16311 which will need to be re-opened now.
- Loading branch information
Showing
9 changed files
with
75 additions
and
24 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
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
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
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,25 @@ | ||
package de.sciss.kollflitz | ||
|
||
import scala.collection.* | ||
|
||
type Tagged[U] = { type Tag = U } | ||
type @@ [+T, U] = T with Tagged[U] | ||
private val anyTagger = new Tagger[Any] | ||
final class Tagger[U] private[kollflitz] { | ||
def apply[T](t : T): T @@ U = t.asInstanceOf[T @@ U] | ||
} | ||
def tag[U]: Tagger[U] = anyTagger.asInstanceOf[Tagger[U]] | ||
|
||
sealed trait Sorted | ||
|
||
|
||
/** Enrichment methods for random access collections. */ | ||
implicit final class KollFlitzSortedIndexedSeq[A, CC[_], Repr](val self: SeqOps[A, CC, Repr] @@ Sorted) | ||
extends AnyVal { | ||
|
||
/** Nearest percentile (rounded index, no interpolation). */ | ||
def percentile(n: Int): A = self((self.size * n - 50) / 100) | ||
|
||
/** Median found by rounding the index (no interpolation). */ | ||
def median: A = percentile(50) | ||
} |
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] | ||
} |
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,6 @@ | ||
object Test: | ||
|
||
val x: Any { type T = Int } & Object = ??? | ||
val y = if ??? then x else x | ||
val _ : Object { type T = Int } = y | ||
|