22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- // ignore_for_file: analyzer_use_new_elements
6-
75/// Defines the type model. The type model is part of the
86/// [element model] (../dart_element_element/dart_element_element-library.html)
97/// in that most types are defined by Dart code (the types `dynamic` and `void`
1412/// interface defined by a class (an instance of [InterfaceType] ) or the type of
1513/// a function (an instance of [FunctionType] ).
1614///
17- /// We make a distinction between the declaration of a class (a [ClassElement ] )
15+ /// We make a distinction between the declaration of a class (a [ClassElement2 ] )
1816/// and the type defined by that class (an [InterfaceType] ). The biggest reason
1917/// for the distinction is to allow us to more cleanly represent the distinction
2018/// between type parameters and type arguments. For example, if we define a
@@ -41,6 +39,7 @@ abstract class DartType {
4139
4240 /// Return the element representing the declaration of this type, or `null`
4341 /// if the type is not associated with an element.
42+ @Deprecated ('Use element3 instead' )
4443 Element ? get element;
4544
4645 /// Return the element representing the declaration of this type, or `null`
@@ -171,6 +170,7 @@ abstract class DartType {
171170 ///
172171 /// For a [TypeParameterType] with a bound (declared or promoted), returns
173172 /// the interface implemented by the bound.
173+ @Deprecated ('Use asInstanceOf2() instead' )
174174 InterfaceType ? asInstanceOf (InterfaceElement element);
175175
176176 /// Return the canonical interface that this type implements for [element] ,
@@ -271,6 +271,7 @@ abstract class FunctionType implements DartType {
271271 ///
272272 /// The parameter types are not necessarily in the same order as they appear
273273 /// in the declaration of the function.
274+ @Deprecated ('Use formalParameters instead' )
274275 List <ParameterElement > get parameters;
275276
276277 /// All the positional parameter types, starting with the required ones, and
@@ -307,11 +308,7 @@ abstract class FunctionType implements DartType {
307308
308309 /// The formal type parameters of this generic function; for example,
309310 /// `<T> T -> T` .
310- //
311- // TODO(scheglov): Remove the mention for "typeParameters".
312- // These are distinct from the `typeParameters` list, which contains type
313- // parameters from surrounding contexts, and thus are free type variables
314- // from the perspective of this function type.
311+ @Deprecated ('Use typeParameters instead' )
315312 List <TypeParameterElement > get typeFormals;
316313
317314 /// The type parameters.
@@ -325,18 +322,19 @@ abstract class FunctionType implements DartType {
325322 FunctionType instantiate (List <DartType > argumentTypes);
326323}
327324
328- /// Information about an instantiated [TypeAliasElement ] and the type
325+ /// Information about an instantiated [TypeAliasElement2 ] and the type
329326/// arguments with which it is instantiated.
330327abstract class InstantiatedTypeAliasElement {
331328 /// The alias element that is instantiated to produce a [DartType] .
329+ @Deprecated ('Use element2 instead' )
332330 TypeAliasElement get element;
333331
334332 /// The alias element that is instantiated to produce a [DartType] .
335333 @experimental
336334 TypeAliasElement2 get element2;
337335
338- /// The type arguments with which the [element ] was instantiated.
339- /// This list will be empty if the [element ] is not generic.
336+ /// The type arguments with which the [element2 ] was instantiated.
337+ /// This list will be empty if the [element2 ] is not generic.
340338 List <DartType > get typeArguments;
341339}
342340
@@ -347,19 +345,22 @@ abstract class InstantiatedTypeAliasElement {
347345abstract class InterfaceType implements ParameterizedType {
348346 /// Return a list containing all of the accessors (getters and setters)
349347 /// declared in this type.
348+ @Deprecated ('Use getters or setters instead' )
350349 List <PropertyAccessorElement > get accessors;
351350
352351 /// Return all the super-interfaces implemented by this interface. This
353352 /// includes superclasses, mixins, interfaces, and superclass constraints.
354353 List <InterfaceType > get allSupertypes;
355354
356355 /// Return a list containing all of the constructors declared in this type.
356+ @Deprecated ('Use constructors2 instead' )
357357 List <ConstructorElement > get constructors;
358358
359359 /// Return a list containing all of the constructors declared in this type.
360360 @experimental
361361 List <ConstructorElement2 > get constructors2;
362362
363+ @Deprecated ('Use element3 instead' )
363364 @override
364365 InterfaceElement get element;
365366
@@ -378,6 +379,7 @@ abstract class InterfaceType implements ParameterizedType {
378379 List <InterfaceType > get interfaces;
379380
380381 /// Return a list containing all of the methods declared in this type.
382+ @Deprecated ('Use methods2 instead' )
381383 List <MethodElement > get methods;
382384
383385 /// Return a list containing all of the methods declared in this type.
@@ -410,11 +412,18 @@ abstract class InterfaceType implements ParameterizedType {
410412 /// Return the element representing the getter with the given [name] that is
411413 /// declared in this class, or `null` if this class does not declare a getter
412414 /// with the given name.
415+ @Deprecated ('Use getGetter2() instead' )
413416 PropertyAccessorElement ? getGetter (String name);
414417
418+ /// Return the element representing the getter with the given [name] that is
419+ /// declared in this class, or `null` if this class does not declare a getter
420+ /// with the given name.
421+ GetterElement ? getGetter2 (String name);
422+
415423 /// Return the element representing the method with the given [name] that is
416424 /// declared in this class, or `null` if this class does not declare a method
417425 /// with the given name.
426+ @Deprecated ('Use getMethod2() instead' )
418427 MethodElement ? getMethod (String name);
419428
420429 /// Return the element representing the method with the given [name] that is
@@ -425,8 +434,14 @@ abstract class InterfaceType implements ParameterizedType {
425434 /// Return the element representing the setter with the given [name] that is
426435 /// declared in this class, or `null` if this class does not declare a setter
427436 /// with the given name.
437+ @Deprecated ('Use getSetter2() instead' )
428438 PropertyAccessorElement ? getSetter (String name);
429439
440+ /// Return the element representing the setter with the given [name] that is
441+ /// declared in this class, or `null` if this class does not declare a setter
442+ /// with the given name.
443+ SetterElement ? getSetter2 (String name);
444+
430445 /// Return the element representing the constructor that results from looking
431446 /// up the constructor with the given [name] in this class with respect to the
432447 /// given [library] , or `null` if the look up fails. The behavior of this
@@ -437,6 +452,7 @@ abstract class InterfaceType implements ParameterizedType {
437452 /// <i>T<i>. Otherwise, if <i>q</i> is not defined or not accessible, a
438453 /// NoSuchMethodException is thrown.
439454 /// </blockquote>
455+ @Deprecated ('Use lookUpConstructor2() instead' )
440456 ConstructorElement ? lookUpConstructor (String ? name, LibraryElement library);
441457
442458 /// Return the element representing the constructor that results from looking
@@ -449,7 +465,8 @@ abstract class InterfaceType implements ParameterizedType {
449465 /// <i>T<i>. Otherwise, if <i>q</i> is not defined or not accessible, a
450466 /// NoSuchMethodException is thrown.
451467 /// </blockquote>
452- ConstructorElement2 ? lookUpConstructor2 (String ? name, LibraryElement2 library);
468+ ConstructorElement2 ? lookUpConstructor2 (
469+ String ? name, LibraryElement2 library);
453470
454471 /// Return the getter with the given [name] .
455472 ///
@@ -461,6 +478,7 @@ abstract class InterfaceType implements ParameterizedType {
461478 ///
462479 /// If [recoveryStatic] is `true` , then static getters of the class,
463480 /// and its superclasses are considered. Clients should not use it.
481+ @Deprecated ('Use lookUpGetter3() instead' )
464482 PropertyAccessorElement ? lookUpGetter2 (
465483 String name,
466484 LibraryElement library, {
@@ -497,6 +515,7 @@ abstract class InterfaceType implements ParameterizedType {
497515 ///
498516 /// If [recoveryStatic] is `true` , then static methods of the class,
499517 /// and its superclasses are considered. Clients should not use it.
518+ @Deprecated ('Use lookUpMethod3() instead' )
500519 MethodElement ? lookUpMethod2 (
501520 String name,
502521 LibraryElement library, {
@@ -533,6 +552,7 @@ abstract class InterfaceType implements ParameterizedType {
533552 ///
534553 /// If [recoveryStatic] is `true` , then static setters of the class,
535554 /// and its superclasses are considered. Clients should not use it.
555+ @Deprecated ('Use lookUpSetter3() instead' )
536556 PropertyAccessorElement ? lookUpSetter2 (
537557 String name,
538558 LibraryElement library, {
@@ -578,7 +598,7 @@ abstract class NeverType implements DartType {}
578598///
579599/// This substitution will be propagated to its members. For example, say our
580600/// `Foo<T>` class has a field `T bar;` . When we look up this field, we will get
581- /// back a [FieldElement ] that tracks the substituted type as `{S/T}T` , so when
601+ /// back a [FieldElement2 ] that tracks the substituted type as `{S/T}T` , so when
582602/// we ask for the field type we will get `S` .
583603///
584604/// Clients may not extend, implement or mix-in this class.
@@ -667,6 +687,7 @@ abstract class TypeParameterType implements DartType {
667687 /// Always consult the bound if that could be relevant.
668688 ElementLocation get definition;
669689
690+ @Deprecated ('Use element3 instead' )
670691 @override
671692 TypeParameterElement get element;
672693
0 commit comments