@@ -12,6 +12,8 @@ import 'package:analyzer/dart/ast/visitor.dart';
12
12
import 'package:analyzer/dart/element/element.dart';
13
13
import 'package:analyzer/dart/element/type.dart';
14
14
import 'package:analyzer/src/context/context.dart';
15
+ import 'package:analyzer/src/dart/ast/ast.dart'
16
+ show SimpleIdentifierImpl, PrefixedIdentifierImpl;
15
17
import 'package:analyzer/src/dart/element/element.dart';
16
18
import 'package:analyzer/src/dart/element/member.dart';
17
19
import 'package:analyzer/src/dart/element/type.dart';
@@ -17074,6 +17076,30 @@ class TypeResolverVisitorTest {
17074
17076
_listener.assertNoErrors();
17075
17077
}
17076
17078
17079
+ void test_visitTypeName_noParameters_noArguments_undefined() {
17080
+ SimpleIdentifier id = AstFactory.identifier3("unknown")
17081
+ ..staticElement = new _StaleElement();
17082
+ TypeName typeName = new TypeName(id, null);
17083
+ _resolveNode(typeName, []);
17084
+ expect(typeName.type, UndefinedTypeImpl.instance);
17085
+ expect(typeName.name.staticElement, null);
17086
+ _listener.assertErrorsWithCodes([StaticWarningCode.UNDEFINED_CLASS]);
17087
+ }
17088
+
17089
+ void test_visitTypeName_prefixed_noParameters_noArguments_undefined() {
17090
+ SimpleIdentifier prefix = AstFactory.identifier3("unknownPrefix")
17091
+ ..staticElement = new _StaleElement();
17092
+ SimpleIdentifier suffix = AstFactory.identifier3("unknownSuffix")
17093
+ ..staticElement = new _StaleElement();
17094
+ TypeName typeName =
17095
+ new TypeName(AstFactory.identifier(prefix, suffix), null);
17096
+ _resolveNode(typeName, []);
17097
+ expect(typeName.type, UndefinedTypeImpl.instance);
17098
+ expect(prefix.staticElement, null);
17099
+ expect(suffix.staticElement, null);
17100
+ _listener.assertErrorsWithCodes([StaticWarningCode.UNDEFINED_CLASS]);
17101
+ }
17102
+
17077
17103
void test_visitTypeName_parameters_arguments() {
17078
17104
ClassElement classA = ElementFactory.classElement2("A", ["E"]);
17079
17105
ClassElement classB = ElementFactory.classElement2("B");
@@ -17233,6 +17259,21 @@ class _SimpleResolverTest_localVariable_types_invoked
17233
17259
}
17234
17260
}
17235
17261
17262
+ /**
17263
+ * Represents an element left over from a previous resolver run.
17264
+ *
17265
+ * A _StaleElement should always be replaced with either null or a new Element.
17266
+ */
17267
+ class _StaleElement extends ElementImpl {
17268
+ _StaleElement() : super("_StaleElement", -1);
17269
+
17270
+ @override
17271
+ accept(_) => throw "_StaleElement shouldn't be visited";
17272
+
17273
+ @override
17274
+ get kind => throw "_StaleElement's kind shouldn't be accessed";
17275
+ }
17276
+
17236
17277
/**
17237
17278
* Shared infrastructure for [StaticTypeAnalyzer2Test] and
17238
17279
* [StrongModeStaticTypeAnalyzer2Test].
0 commit comments