diff --git a/tests/pos-custom-args/captures/i21507.scala b/tests/pos-custom-args/captures/i21507.scala new file mode 100644 index 000000000000..bb80dafb3b45 --- /dev/null +++ b/tests/pos-custom-args/captures/i21507.scala @@ -0,0 +1,10 @@ +import language.experimental.captureChecking + +trait Box[Cap^]: + def store(f: (() -> Unit)^{Cap^}): Unit + +def run[Cap^](f: Box[Cap]^{Cap^} => Unit): Box[Cap]^{Cap^} = + new Box[Cap]: + private var item: () ->{Cap^} Unit = () => () + def store(f: () ->{Cap^} Unit): Unit = + item = f // was error, now ok