Add more data for CastError in _ContextTypeVisitor.

Bug: https://github.com/dart-lang/sdk/issues/48965
Change-Id: I50ac5baef607071f5b32df4aa63fb4327645a781
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243840
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov 2022-05-05 18:09:56 +00:00 committed by Commit Bot
parent 25c3f36d95
commit 838b68914f

View file

@ -824,7 +824,18 @@ Class: ${parent.parent}
@override
DartType? visitListLiteral(ListLiteral node) {
if (range.endStart(node.leftBracket, node.rightBracket).contains(offset)) {
return (node.staticType as InterfaceType).typeArguments[0];
final type = node.staticType;
// TODO(scheglov) https://github.com/dart-lang/sdk/issues/48965
if (type == null) {
throw '''
No type.
node: $node
parent: ${node.parent}
parent2: ${node.parent?.parent}
parent3: ${node.parent?.parent?.parent}
''';
}
return (type as InterfaceType).typeArguments[0];
}
return null;
}