-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-questionA question about expected behavior or functionalityA question about expected behavior or functionality
Description
I hit this issue trying to migrate some code to the new Element model, but I couldn't figure out what the fix was...
The code I'm migrating is testing the hover on some code like new A<String>(). Calling getDisplayString() returns "A<String> A()" but calling displayString2() returns "A<T> A()":
Stepping through getDisplayString(), it accesses ExecutableMember.type which calls _substitution.substituteType before returning the type.
However when stepping through displayString2() it accesses _element2 which accesses declaration.asElement2. I don't know if it's this use of declaration that is losing the type substitutions?
Here's a small repro test:
@soloTest
Future<void> test_danny() async {
await resolveTestCode('''
class A<T> {}
void f() {
new A<String>();
}
''');
var element =
findNode.instanceCreation('A<String>').constructorName.staticElement!;
expect(
(element as Element2).displayString2(),
element.getDisplayString(),
);
}Which fails with:
00:00 +0 -2: SearchEngineImplWithNonFunctionTypeAliasesTest | test_danny [E]
Expected: 'A<String> A()'
Actual: 'A<T> A()'
Which: is different.
Expected: A<String> A( ...
Actual: A<T> A()
^
Differ at offset 2
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-questionA question about expected behavior or functionalityA question about expected behavior or functionality
