Skip to content

Commit 6597292

Browse files
authored
Merge pull request #14361 from dwijnand/fix-approximating-RefinedTypes
Fix approximating RefinedTypes (n>1)
2 parents 8ae2962 + 7c3db13 commit 6597292

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5802,7 +5802,7 @@ object Types {
58025802
case Range(infoLo: TypeBounds, infoHi: TypeBounds) =>
58035803
assert(variance == 0)
58045804
if (!infoLo.isTypeAlias && !infoHi.isTypeAlias) propagate(infoLo, infoHi)
5805-
else range(defn.NothingType, tp.parent)
5805+
else range(defn.NothingType, parent)
58065806
case Range(infoLo, infoHi) =>
58075807
propagate(infoLo, infoHi)
58085808
case _ =>

tests/pos/i14349.min.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Inv[M]
2+
3+
class Module:
4+
type X
5+
type Y
6+
type M = Module {
7+
type X = Module.this.X
8+
type Y = Module.this.Y
9+
}
10+
def expose = new Inv[M]
11+
def test = this match { case m => m.expose }
12+
// was: leak: `(m : Module)` in `m.expose: Inv[? <: Module { X = m.X }]`
13+
def res: Inv[_ <: Module] = this match { case m => m.expose }

tests/pos/i14349.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
trait Module:
2+
self =>
3+
type M <: Module {
4+
type X = self.X
5+
type Y = self.Y
6+
}
7+
type X
8+
type Y
9+
10+
def expose: Expose[X, Y, M]
11+
12+
trait Expose[
13+
X0,
14+
Y0,
15+
M <: Module { type X = X0; type Y = Y0 }
16+
]
17+
18+
def test(ms: Seq[Option[Module]]): Seq[Expose[_, _, _]] =
19+
ms.collect { case Some(module) => module.expose }

0 commit comments

Comments
 (0)