File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
src/reflect/scala/reflect/internal Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,20 @@ final class Depth private (val depth: Int) extends AnyVal with Ordered[Depth] {
2121
2222object Depth {
2323 // A don't care value for the depth parameter in lubs/glbs and related operations.
24- final val AnyDepth = new Depth (Int .MinValue )
24+ // When passed this value, the recursion budget will be inferred from the shape of
25+ // the `typeDepth` of the list of types.
26+ final val AnyDepthValue = - 3
27+ final val AnyDepth = new Depth (AnyDepthValue )
28+
2529 final val Zero = new Depth (0 )
2630
27- @ inline final def apply (depth : Int ): Depth = if (depth < 0 ) AnyDepth else new Depth (depth)
31+ // SI-9018: A negative depth is used to signal that we have breached the recursion limit.
32+ // The LUB/GLB implementation will then truncate to Any/Nothing.
33+ //
34+ // We only really need one of these, but we allow representation of Depth(-1) and Depth(-2)
35+ // to mimic the historical choice of 2.10.4.
36+ @ inline final def apply (depth : Int ): Depth = {
37+ if (depth < AnyDepthValue ) AnyDepth
38+ else new Depth (depth)
39+ }
2840}
Original file line number Diff line number Diff line change 1+ object TestObject {
2+
3+ def m (i : Int ): AnyRef = i match {
4+ case 0 => new C ()
5+ case 1 => Some (E .A ).getOrElse(" " )
6+ }
7+
8+ class C extends Ordered [C ] {
9+ def compare (that : C ): Int = ???
10+ }
11+
12+ object E extends Enumeration {
13+ type CharacterClass = Value
14+ val A = Value
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments