From 838b68914fecd0df3feb40c79e02856d0233a53c Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Thu, 5 May 2022 18:09:56 +0000 Subject: [PATCH] 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 Reviewed-by: Brian Wilkerson --- .../services/completion/dart/feature_computer.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart index 09966598d2b..6fd8abf967b 100644 --- a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart +++ b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart @@ -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; }