Skip to content

Safe mode rejects unchecked annotations on synthetic symbols #25665

@noti0na1

Description

@noti0na1

Compiler version

3.8.4-RC1-bin-20260331-724e9c3-NIGHTLY
3.nightly

Minimized code

Stest_1.scala

@caps.assumeSafe object A:
  def f(
      a: List[String] = List.empty,
      b: Option[String] = None,
      c: Long = 30000
    ) = ()

Stest_2.scala

import language.experimental.safe

def test(i: Int) =
  A.f(a = List("bar"), c = 1000)

Compile: scala compile -S 3.nightly -experimental Stest_1.scala Stest_2.scala

The code is written in this way to:

  1. construct uncheckedVariance annotations on parameters;
  2. force the desugar to lift the arguments.

Output

-- Error: Work/dotty/Stest_1.scala:116:26 ---------------------
116 |      b: Option[String] = None,
    |                          ^
    |Cannot refer to class uncheckedVariance in package scala.annotation.unchecked from safe code since it is tagged @rejectSafe
1 error found

It's also weird the error is on the first file, not on the synthesised symbol.

Expectation

Should compile

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions