Skip to content

Inline expressions with non-trivial computations inside annotations should work or error #22367

Closed
@belamenso

Description

@belamenso

Compiler version

3.6.2

Minimized code

inline val msg = "cba".reverse
trait E[T]
def f(using @annotation.implicitNotFound(msg) e: E[Int]): Unit = ()
@main def hello(): Unit = f

Output

[error] -- [E172] Type Error: Main.scala:5:27 
[error] 5 |@main def hello(): Unit = f
[error]   |                           ^
[error]   |    No given instance of type E[Int] was found for parameter e of method f

Expectation

What happened here is that the complex expression "cba".reverse was assigned to an inline constant which was then used inside an annotation, disabling it. What should happens is one of two things. Either print an error that Scala does not support non-trivial inline expressions used inside annotations, or, it should work:

[error] -- [E172] Type Error: Main.scala:5:27 
[error] 5 |@main def hello(): Unit = f
[error]   |                           ^
[error]   |                           abc

Please note that expressions like "ab" + "c" already work, even when the concatenation is split into multiple inline constants.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions