Skip to content

inline proxy values appear in capture sets (inline methods retain references?) #24729

@bishabosha

Description

@bishabosha

blocker for Make -> sugar an inline method #24728

Compiler version

main branch @ ba45875

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions