diff --git a/compiler/src/dotty/tools/dotc/core/TyperState.scala b/compiler/src/dotty/tools/dotc/core/TyperState.scala index 1733f4fb5d95..cd5cb1a65105 100644 --- a/compiler/src/dotty/tools/dotc/core/TyperState.scala +++ b/compiler/src/dotty/tools/dotc/core/TyperState.scala @@ -162,6 +162,7 @@ class TyperState() { targetState.mergeConstraintWith(this) targetState.gc() isCommitted = true + ownedVars = SimpleIdentitySet.empty } /** Ensure that this constraint does not associate different TypeVars for the diff --git a/tests/neg/i13407.scala b/tests/neg/i13407.scala new file mode 100644 index 000000000000..a0f9efdbf173 --- /dev/null +++ b/tests/neg/i13407.scala @@ -0,0 +1,19 @@ +import scala.quoted.Type + +trait Tensor[S <: Tuple] { + def sum[Axis <: Shape: Type](axis: Axis): Tensor[S] = { // error + Tensor.mk + } +} + +object Tensor { + def mk[S <: Tuple]: Tensor[S] = new Tensor {} +} + +object Foo { + val t1: Tensor[("batch", "len", "embed")] = Tensor.mk + def foo(x: Any) = { + + } + foo(foo(t1.sum("len"))) // error +}