scala3
scala3 copied to clipboard
inline proxy values appear in capture sets (inline methods retain references?)
blocker for Make -> sugar an inline method #24728
Compiler version
main branch @ https://github.com/scala/scala3/commit/ba4587574519c8a80c07504e53a9157815a69503
Minimized code
taken from an error in library/src/scala/collection/package.scala when trying to make Predef.ArrowAssoc inline
import language.experimental.{captureChecking, separationChecking}
import scala.collection.SeqOps
extension [A](self: A) inline def --> [B](y: B): (A, B) = (self, y)
object +: {
def unapply[A, CC[_] <: Seq[?], C <: SeqOps[A, CC, C]](t: (C & SeqOps[A, CC, C])^): Option[(A, C^{t})] =
if(t.isEmpty) None
else Some(t.head --> t.tail)
}
Output
-- [E007] Type Mismatch Error: local/reproducer.scala:10:14 --------------------
10 | else Some(t.head --> t.tail)
| ^^^^^^^^^^^^^^^^^
| Found: (A^'s1, C^{y$proxy1})
| Required: (A, C)
|
| Note that capability y$proxy1 is not included in capture set {}.
|----------------------------------------------------------------------------
|Inline stack trace
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from reproducer.scala:5
5 |extension [A](self: A) inline def --> [B](y: B): (A, B) = (self, y)
| ^^^^^^^^^
----------------------------------------------------------------------------
|
| longer explanation available when compiling with `-explain`
1 error found
Expectation
i would not expect inline proxy values in capture sets