Skip to content

Commit 2d8aec0

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate a few summary tests.
Change-Id: I52791ad27681de7b1507925c9598b824b1ebb7c1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396568 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent cc99ae9 commit 2d8aec0

File tree

8 files changed

+221
-189
lines changed

8 files changed

+221
-189
lines changed

pkg/analyzer/analyzer_use_new_elements.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,8 @@ test/src/dart/resolution/super_formal_parameter_test.dart
227227
test/src/services/top_level_declarations_test.dart
228228
test/src/summary/element_text.dart
229229
test/src/summary/elements/class_test.dart
230-
test/src/summary/elements/const_test.dart
231230
test/src/summary/elements/enum_test.dart
232231
test/src/summary/elements/extension_type_test.dart
233-
test/src/summary/elements/library_export_test.dart
234-
test/src/summary/elements/library_fragment_test.dart
235-
test/src/summary/elements/library_import_test.dart
236232
test/src/summary/elements/metadata_test.dart
237233
test/src/summary/elements/since_sdk_version_test.dart
238234
test/src/summary/elements/top_level_function_test.dart

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
799799
@override
800800
List<ExtensionElement2> get accessibleExtensions2 {
801801
return scope.accessibleExtensions
802-
.map((element) => element.augmentation as ExtensionElement2)
802+
.map((element) => element.augmented as ExtensionElement2)
803803
.toList();
804804
}
805805

@@ -9186,8 +9186,10 @@ class PrefixElementImpl2 extends ElementImpl2 implements PrefixElement2 {
91869186
String? get name3 => firstFragment.name2;
91879187

91889188
@override
9189-
// TODO(scheglov): implement scope
9190-
Scope get scope => throw UnimplementedError();
9189+
Scope get scope {
9190+
var libraryFragment = firstFragment.libraryFragment;
9191+
return LibraryFragmentScope(libraryFragment);
9192+
}
91919193

91929194
@override
91939195
T? accept2<T>(ElementVisitor2<T> visitor) {

pkg/analyzer/test/src/summary/elements/const_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,14 +663,14 @@ library
663663
''');
664664
var x = library.definingCompilationUnit.topLevelVariables[0];
665665
var xExpr = x.constantInitializer as InstanceCreationExpression;
666-
var xType = xExpr.constructorName.staticElement!.returnType;
666+
var xType = xExpr.constructorName.element!.returnType;
667667
_assertTypeStr(
668668
xType,
669669
'C<int>',
670670
);
671671
var y = library.definingCompilationUnit.topLevelVariables[0];
672672
var yExpr = y.constantInitializer as InstanceCreationExpression;
673-
var yType = yExpr.constructorName.staticElement!.returnType;
673+
var yType = yExpr.constructorName.element!.returnType;
674674
_assertTypeStr(yType, 'C<int>');
675675
}
676676

pkg/analyzer/test/src/summary/elements/library_export_test.dart

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,11 @@ library
827827
firstFragment: <testLibraryFragment>::@class::B::@constructor::new
828828
superConstructor: package:test/foo.dart::<fragment>::@class::A::@constructor::new#element
829829
''');
830-
var typeA = library.definingCompilationUnit.getClass('B')!.supertype!;
831-
expect(typeA.element.source.shortName, 'foo.dart');
830+
831+
var typeA = library.getClass2('B')!.supertype!;
832+
var fragmentA = typeA.element3.firstFragment;
833+
var sourceA = fragmentA.libraryFragment.source;
834+
expect(sourceA.shortName, 'foo.dart');
832835
}
833836

834837
test_exportImport_configurations_useFirst() async {
@@ -896,8 +899,11 @@ library
896899
firstFragment: <testLibraryFragment>::@class::B::@constructor::new
897900
superConstructor: package:test/foo_io.dart::<fragment>::@class::A::@constructor::new#element
898901
''');
899-
var typeA = library.definingCompilationUnit.getClass('B')!.supertype!;
900-
expect(typeA.element.source.shortName, 'foo_io.dart');
902+
903+
var typeA = library.getClass2('B')!.supertype!;
904+
var fragmentA = typeA.element3.firstFragment;
905+
var sourceA = fragmentA.libraryFragment.source;
906+
expect(sourceA.shortName, 'foo_io.dart');
901907
}
902908

903909
test_exportImport_configurations_useSecond() async {
@@ -965,8 +971,11 @@ library
965971
firstFragment: <testLibraryFragment>::@class::B::@constructor::new
966972
superConstructor: package:test/foo_html.dart::<fragment>::@class::A::@constructor::new#element
967973
''');
968-
var typeA = library.definingCompilationUnit.getClass('B')!.supertype!;
969-
expect(typeA.element.source.shortName, 'foo_html.dart');
974+
975+
var typeA = library.getClass2('B')!.supertype!;
976+
var fragmentA = typeA.element3.firstFragment;
977+
var sourceA = fragmentA.libraryFragment.source;
978+
expect(sourceA.shortName, 'foo_html.dart');
970979
}
971980

972981
test_exports() async {

0 commit comments

Comments
 (0)