Open
Description
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>');
}