sdk icon indicating copy to clipboard operation
sdk copied to clipboard

A more specific error should happen when annotations are used in the wrong context

Open FMorschel opened this issue 3 weeks ago • 1 comments

I was tinkering with a new annotation that could enforce annotations and came across the following:

@C([@reflectiveTest])
//  ^ non_constant_list_element, const_with_non_constant_argument, missing_identifier, expected_token (']')
class C {
  const C(List<Object> o);
}

I believe we should have a more specific error when annotations are used in places where they shouldn't be used, like annotation_in_wrong_context or whatever the team prefers.

Also, the the last two errors above are probably a parser/resolver issue (the first two are https://github.com/dart-lang/sdk/issues/59693), but I'm less certain of that.

CC @lrhn @eernstg @bwilkerson @scheglov

FMorschel avatar Nov 19 '25 17:11 FMorschel