Skip to content

Resolution / inference in ElementAnnotationImpl.annotationAst is incomplete #34894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
scheglov opened this issue Oct 22, 2018 · 2 comments
Open
Labels
area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@scheglov
Copy link
Contributor

The following test, when added to ClassResolutionMixin, passes with task model, and fails with AnalysisDriver.

  Expected: 'List<num>'
    Actual: 'null'

The failure disappears if I move class C {} with its annotation into the test file.

That's because we clone the annotation and store into the element model.

Which does not help to clients that use just element model and look at annotations from other files, possibly resynthesized from summaries.

  solo_test_XXX() async {
    newFile('/test/lib/a.dart', content: r'''
class A {
  final x;
  const A(this.x);
}

@A([1, 2.3])
class C {}
''');
    addTestFile(r'''
import 'a.dart';

C c;
''');
    await resolveTestFile();
    assertNoTestErrors();

    ClassElement c = findNode.simple('C c').staticElement;
    ElementAnnotationImpl m = c.metadata[0];
    var listType = m.annotationAst.arguments.arguments[0].staticType;
    assertElementTypeString(listType, 'List<num>');
  }
@scheglov scheglov added the legacy-area-analyzer Use area-devexp instead. label Oct 22, 2018
@scheglov
Copy link
Contributor Author

scheglov commented Oct 22, 2018

Oh, and this is only a symptom of problems that we have for constants in general.
This test also fails with AnalysisDriver (or should I say with summaries instead?).
This is the same problem as outlined in https://dart-review.googlesource.com/c/sdk/+/80761, tracked as #33441

  solo_test_XXX() async {
    newFile('/test/lib/a.dart', content: r'''
const Object x = [1];
''');
    addTestFile(r'''
import 'a.dart';

const List<String> y = x;
''');
    await resolveTestFile();
    assertHasTestErrors();
  }

@srawlins srawlins added the dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec label Jun 17, 2020
@srawlins srawlins added the P3 A lower priority bug or feature request label Apr 11, 2021
@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Nov 30, 2021
@srawlins
Copy link
Member

srawlins commented Dec 6, 2024

Not sure if we can act on this bug. I don't see ClassResolutionMixin any longer, and I don't see specifics about either test case that are the (maybe hypothesized) problem.

@bwilkerson bwilkerson added area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants