Skip to content

Commit 32e287f

Browse files
committed
Fix Lucre
The test neg/i12169.scala explains what went wrong and how to fix it. Before this PR Lurcre compiled, since the wildcard was translated to an abstract type that was not entered in scope and that therefore escaped avoidance.
1 parent 9ada968 commit 32e287f

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

tests/neg/i12169.scala

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
object Var:
2+
class Expanded[T <: Txn[T], B] extends Form[T]
3+
4+
trait Txn[T <: Txn[T]]
5+
6+
trait Form[T]
7+
8+
class TT extends Txn[TT]
9+
10+
private final class FlatVarCellView[T <: Txn[T], B](
11+
firstVr : Option[Var.Expanded[TT, B]]
12+
)
13+
14+
def Test =
15+
val opt: Option[Form[TT]] = ???
16+
val firstVr = opt match
17+
case Some(ex: Var.Expanded[TT, _]) => Some(ex)
18+
case _ => None
19+
new FlatVarCellView(firstVr) // error
20+
// Found: (firstVr : Option[Var.Expanded[TT, ?]])
21+
// Required: Option[Var.Expanded[TT, B]]
22+
//
23+
// where: B is a type variable
24+
//
25+
// Note that we cannot do capture conversion since the `?` does not appear as an argument
26+
// of the a type. It's dubious whether capture conversion for more deeply nested types
27+
// would be sound.
28+
29+
// Remedy:
30+
opt match
31+
case Some(ex: Var.Expanded[TT, _]) => new FlatVarCellView(Some(ex))
32+
// here, we instantiate `B` with the unnamed second parameter of `Var.Expanded`
33+
case _ => new FlatVarCellView(None)
34+
opt match
35+
case Some(ex: Var.Expanded[TT, t]) => new FlatVarCellView[TT, t](Some(ex))
36+
// the same as above, spelt out
37+
case _ => new FlatVarCellView(None)

0 commit comments

Comments
 (0)