Avoid single cascades, unnecessary interpolations, and exposing private types

* Make `MicroContextObjects` constructor private, which is not used
  outside the library.
* Remove unused `analysisContext2` constructor parameter.
* Make `tryMatchSubtypeOf` private, which requires a parameter of
  private type.
* Make `_FileStateFiles` public, as it is used outside the library.
* Return empty for void-typed functions.

Change-Id: If67a69effdbbaed2eb364788e52eeb60270a0c19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237855
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Sam Rawlins
2022-03-21 18:12:47 +00:00
committed by Commit Bot
parent fdbd5d8c5d
commit ab22a8dd8c
14 changed files with 171 additions and 174 deletions
+2 -2
View File
@@ -4817,10 +4817,10 @@ class FormalParameterListImpl extends AstNodeImpl
for (int i = 0; i < length; i++) {
FormalParameter parameter = _parameters[i];
if (leftDelimiterNeeded && leftDelimiter!.offset < parameter.offset) {
result..addToken('leftDelimiter', leftDelimiter);
result.addToken('leftDelimiter', leftDelimiter);
leftDelimiterNeeded = false;
}
result..addNode('parameter', parameter);
result.addNode('parameter', parameter);
}
return result
..addToken('rightDelimiter', rightDelimiter)
@@ -125,7 +125,7 @@ class GenericInferrer {
genericClass: genericClass,
isNonNullableByDefault: isNonNullableByDefault,
);
tryMatchSubtypeOf(argumentType, parameterType, origin, covariant: false);
_tryMatchSubtypeOf(argumentType, parameterType, origin, covariant: false);
}
/// Applies all the argument constraints implied by [parameters] and
@@ -164,7 +164,7 @@ class GenericInferrer {
returnType: fnType.returnType,
nullabilitySuffix: fnType.nullabilitySuffix,
);
tryMatchSubtypeOf(inferFnType, contextType, origin, covariant: true);
_tryMatchSubtypeOf(inferFnType, contextType, origin, covariant: true);
}
/// Apply a return type constraint, which asserts that the [declaredType]
@@ -175,39 +175,13 @@ class GenericInferrer {
contextType,
isNonNullableByDefault: isNonNullableByDefault,
);
tryMatchSubtypeOf(declaredType, contextType, origin, covariant: true);
_tryMatchSubtypeOf(declaredType, contextType, origin, covariant: true);
}
/// Performs downwards inference, producing a set of inferred types that may
/// contain references to the "unknown type".
List<DartType> downwardsInfer() => _chooseTypes(downwardsInferPhase: true);
/// Tries to make [i1] a subtype of [i2] and accumulate constraints as needed.
///
/// The return value indicates whether the match was successful. If it was
/// unsuccessful, any constraints that were accumulated during the match
/// attempt have been rewound (see [_rewindConstraints]).
bool tryMatchSubtypeOf(DartType t1, DartType t2, _TypeConstraintOrigin origin,
{required bool covariant}) {
var gatherer = TypeConstraintGatherer(
typeSystem: _typeSystem, typeParameters: _typeParameters);
var success = gatherer.trySubtypeMatch(t1, t2, !covariant);
if (success) {
var constraints = gatherer.computeConstraints();
for (var entry in constraints.entries) {
if (!entry.value.isEmpty && !_fixedTypeParameters.contains(entry.key)) {
var constraint = _constraints[entry.key]!;
constraint.add(
_TypeConstraint(origin, entry.key,
lower: entry.value.lower, upper: entry.value.upper),
);
}
}
}
return success;
}
/// Same as [upwardsInfer], but if [failAtError] is `true` (the default) and
/// inference fails, returns `null` rather than trying to perform error
/// recovery.
@@ -655,6 +629,33 @@ class GenericInferrer {
return NullabilityEliminator.perform(typeProvider, type);
}
/// Tries to make [i1] a subtype of [i2] and accumulate constraints as needed.
///
/// The return value indicates whether the match was successful. If it was
/// unsuccessful, any constraints that were accumulated during the match
/// attempt have been rewound (see [_rewindConstraints]).
bool _tryMatchSubtypeOf(
DartType t1, DartType t2, _TypeConstraintOrigin origin,
{required bool covariant}) {
var gatherer = TypeConstraintGatherer(
typeSystem: _typeSystem, typeParameters: _typeParameters);
var success = gatherer.trySubtypeMatch(t1, t2, !covariant);
if (success) {
var constraints = gatherer.computeConstraints();
for (var entry in constraints.entries) {
if (!entry.value.isEmpty && !_fixedTypeParameters.contains(entry.key)) {
var constraint = _constraints[entry.key]!;
constraint.add(
_TypeConstraint(origin, entry.key,
lower: entry.value.lower, upper: entry.value.upper),
);
}
}
}
return success;
}
String _typeStr(DartType type) {
return type.getDisplayString(withNullability: isNonNullableByDefault);
}
@@ -57,12 +57,11 @@ MicroContextObjects createMicroContextObjects({
analysisContext2.currentSession = analysisSession;
analysisSession.analysisContext = analysisContext2;
return MicroContextObjects(
return MicroContextObjects._(
declaredVariables: declaredVariables,
synchronousSession: synchronousSession,
analysisSession: analysisSession,
analysisContext: analysisContext,
analysisContext2: analysisContext2,
);
}
@@ -71,14 +70,12 @@ class MicroContextObjects {
final SynchronousSession synchronousSession;
final _MicroAnalysisSessionImpl analysisSession;
final AnalysisContextImpl analysisContext;
final _MicroAnalysisContextImpl analysisContext2;
MicroContextObjects({
MicroContextObjects._({
required this.declaredVariables,
required this.synchronousSession,
required this.analysisSession,
required this.analysisContext,
required this.analysisContext2,
});
set analysisOptions(AnalysisOptionsImpl analysisOptions) {
@@ -87,7 +87,7 @@ class FileState {
/// Files that reference this file.
final List<FileState> referencingFiles = [];
_FileStateFiles? _files;
FileStateFiles? _files;
LibraryCycle? _libraryCycle;
@@ -154,10 +154,10 @@ class FileState {
}
}
_FileStateFiles files({
FileStateFiles files({
OperationPerformanceImpl? performance,
}) {
return _files ??= _FileStateFiles(
return _files ??= FileStateFiles(
owner: this,
performance: performance ?? OperationPerformanceImpl('<root>'),
);
@@ -194,6 +194,68 @@ class FileState {
}
}
class FileStateFiles {
final List<FileState> imported = [];
final List<FileState> exported = [];
final List<FileState> parted = [];
final List<FileState> ofLibrary = [];
FileStateFiles({
required FileState owner,
required OperationPerformanceImpl performance,
}) {
var unlinked = owner._unlinked;
var location = unlinked.location;
var unlinkedUnit = unlinked.unlinked.unit;
// Build the graph.
for (var directive in unlinkedUnit.imports) {
var file = location._fileForRelativeUri(
relativeUri: directive.uri,
performance: performance,
);
if (file != null) {
file.referencingFiles.add(owner);
imported.add(file);
}
}
for (var directive in unlinkedUnit.exports) {
var file = location._fileForRelativeUri(
relativeUri: directive.uri,
performance: performance,
);
if (file != null) {
exported.add(file);
file.referencingFiles.add(owner);
}
}
for (var uri in unlinkedUnit.parts) {
var file = location._fileForRelativeUri(
containingLibrary: owner,
relativeUri: uri,
performance: performance,
);
if (file != null) {
parted.add(file);
file.referencingFiles.add(owner);
}
}
ofLibrary.add(owner);
ofLibrary.addAll(parted);
}
/// Return all directly referenced files - imported, exported or parted.
Set<FileState> get directReferencedFiles {
return <FileState>{...imported, ...exported, ...parted};
}
/// Return all directly referenced libraries - imported or exported.
Set<FileState> get directReferencedLibraries {
return <FileState>{...imported, ...exported};
}
}
class FileSystemState {
final ResourceProvider _resourceProvider;
final CiderByteStore _byteStore;
@@ -514,68 +576,6 @@ class _ContentWithDigest {
});
}
class _FileStateFiles {
final List<FileState> imported = [];
final List<FileState> exported = [];
final List<FileState> parted = [];
final List<FileState> ofLibrary = [];
_FileStateFiles({
required FileState owner,
required OperationPerformanceImpl performance,
}) {
var unlinked = owner._unlinked;
var location = unlinked.location;
var unlinkedUnit = unlinked.unlinked.unit;
// Build the graph.
for (var directive in unlinkedUnit.imports) {
var file = location._fileForRelativeUri(
relativeUri: directive.uri,
performance: performance,
);
if (file != null) {
file.referencingFiles.add(owner);
imported.add(file);
}
}
for (var directive in unlinkedUnit.exports) {
var file = location._fileForRelativeUri(
relativeUri: directive.uri,
performance: performance,
);
if (file != null) {
exported.add(file);
file.referencingFiles.add(owner);
}
}
for (var uri in unlinkedUnit.parts) {
var file = location._fileForRelativeUri(
containingLibrary: owner,
relativeUri: uri,
performance: performance,
);
if (file != null) {
parted.add(file);
file.referencingFiles.add(owner);
}
}
ofLibrary.add(owner);
ofLibrary.addAll(parted);
}
/// Return all directly referenced files - imported, exported or parted.
Set<FileState> get directReferencedFiles {
return <FileState>{...imported, ...exported, ...parted};
}
/// Return all directly referenced libraries - imported or exported.
Set<FileState> get directReferencedLibraries {
return <FileState>{...imported, ...exported};
}
}
class _FileStateLocation {
final FileSystemState _fsState;
@@ -106,7 +106,7 @@ class FlowAnalysisHelper {
}
void assignmentExpression(AssignmentExpression node) {
if (flow == null) return null;
if (flow == null) return;
if (node.operator.type == TokenType.QUESTION_QUESTION_EQ) {
flow!.ifNullExpression_rightBegin(node.leftHandSide, node.readType!);
@@ -114,7 +114,7 @@ class FlowAnalysisHelper {
}
void assignmentExpression_afterRight(AssignmentExpression node) {
if (flow == null) return null;
if (flow == null) return;
if (node.operator.type == TokenType.QUESTION_QUESTION_EQ) {
flow!.ifNullExpression_end();
@@ -12,14 +12,14 @@ import 'package:analyzer/src/dart/resolver/scope.dart';
import 'package:analyzer/src/error/codes.dart';
/// A visitor that visits ASTs and fills [UsedImportedElements].
class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor {
class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor<void> {
final LibraryElement library;
final UsedImportedElements usedElements = UsedImportedElements();
GatherUsedImportedElementsVisitor(this.library);
@override
visitAssignmentExpression(AssignmentExpression node) {
void visitAssignmentExpression(AssignmentExpression node) {
_recordAssignmentTarget(node, node.leftHandSide);
return super.visitAssignmentExpression(node);
}
@@ -58,7 +58,7 @@ class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor {
}
@override
visitPostfixExpression(PostfixExpression node) {
void visitPostfixExpression(PostfixExpression node) {
_recordAssignmentTarget(node, node.operand);
return super.visitPostfixExpression(node);
}
@@ -26,7 +26,7 @@ class UseResultVerifier {
void checkPropertyAccess(PropertyAccess node) {
var element = node.propertyName.staticElement;
if (element == null) {
return null;
return;
}
_check(node, element);
@@ -45,7 +45,7 @@ class UseResultVerifier {
var element = node.staticElement;
if (element == null) {
return null;
return;
}
_check(node, element);
+1 -1
View File
@@ -440,7 +440,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
// TODO(scheglov) encapsulate
var bodyContext = BodyInferenceContext.of(body);
if (bodyContext == null) {
return null;
return;
}
var returnType = bodyContext.contextType;
if (returnType == null) {
@@ -186,7 +186,7 @@ abstract class ElementLinkedData<E extends ElementImpl> {
void read(ElementImpl element) {
if (_offset == -1) {
return null;
return;
}
var dataReader = _libraryReader._reader.fork(_offset);
@@ -499,7 +499,7 @@ class FindNode {
}
}
}
throw StateError('$name');
throw StateError(name);
}
TryStatement tryStatement(String search) {
@@ -227,7 +227,7 @@ class ResolutionVerifier extends RecursiveAstVisitor<void> {
MethodInvocation invocation = parent;
if (identical(invocation.methodName, node)) {
var target = invocation.realTarget;
var targetType = target == null ? null : target.staticType;
var targetType = target?.staticType;
if (targetType == null || targetType.isDynamic) {
return;
}
@@ -512,7 +512,7 @@ class TestSource extends Source {
}
@override
String toString() => '$_name';
String toString() => _name;
}
class TestSourceWithUri extends TestSource {
@@ -82,7 +82,7 @@ class C2 = Object with B;
assertThat(classElementA)
..isAncestorOf('C1 = Object with A')
..isAncestorOf('C2 = Object with B');
assertThat(classElementB)..isAncestorOf('C2 = Object with B');
assertThat(classElementB).isAncestorOf('C2 = Object with B');
}
test_hasAncestor_MixinDeclaration() async {
@@ -328,7 +328,7 @@ main() {
}
''');
MethodElement element = findElement.method('foo');
assertThat(element)..isInvokedAt('foo();', true);
assertThat(element).isInvokedAt('foo();', true);
}
test_isInvokedBy_MethodElement_ofNamedExtension_static() async {
@@ -342,7 +342,7 @@ main() {
}
''');
MethodElement element = findElement.method('foo');
assertThat(element)..isInvokedAt('foo();', true);
assertThat(element).isInvokedAt('foo();', true);
}
test_isInvokedBy_MethodElement_ofUnnamedExtension_instance() async {
@@ -363,11 +363,11 @@ main() {
var intMethod = findNode.methodDeclaration('foo() {} // int');
assertThat(intMethod.declaredElement!)
..isInvokedAt('foo(); // int ref', true);
.isInvokedAt('foo(); // int ref', true);
var doubleMethod = findNode.methodDeclaration('foo() {} // double');
assertThat(doubleMethod.declaredElement!)
..isInvokedAt('foo(); // double ref', true);
.isInvokedAt('foo(); // double ref', true);
}
test_isInvokedBy_MethodElement_propagatedType() async {
@@ -636,7 +636,7 @@ class A<T> {}
extension E on A<int> {}
''');
ClassElement element = findElement.class_('A');
assertThat(element)..isReferencedAt('A<int>', false);
assertThat(element).isReferencedAt('A<int>', false);
}
test_isReferencedBy_ClassElement_implicitNew() async {
@@ -695,7 +695,7 @@ main() {
}
''');
ClassElement element = findElement.class_('A');
assertThat(element)..isReferencedAt('A>();', false);
assertThat(element).isReferencedAt('A>();', false);
}
test_isReferencedBy_ClassTypeAlias() async {
@@ -720,7 +720,7 @@ library lib;
export 'lib.dart';
''');
var element = findElement.export('package:test/lib.dart').exportedLibrary!;
assertThat(element)..isReferencedAt("'lib.dart'", true, length: 10);
assertThat(element).isReferencedAt("'lib.dart'", true, length: 10);
}
test_isReferencedBy_CompilationUnitElement_import() async {
@@ -731,7 +731,7 @@ library lib;
import 'lib.dart';
''');
var element = findElement.import('package:test/lib.dart').importedLibrary!;
assertThat(element)..isReferencedAt("'lib.dart'", true, length: 10);
assertThat(element).isReferencedAt("'lib.dart'", true, length: 10);
}
test_isReferencedBy_CompilationUnitElement_part() async {
@@ -741,7 +741,7 @@ library my_lib;
part 'my_unit.dart';
''');
var element = findElement.part('my_unit.dart');
assertThat(element)..isReferencedAt("'my_unit.dart';", true, length: 14);
assertThat(element).isReferencedAt("'my_unit.dart';", true, length: 14);
}
test_isReferencedBy_CompilationUnitElement_part_inPart() async {
@@ -1025,7 +1025,7 @@ main() {
}
''');
ExtensionElement element = findElement.extension_('E');
assertThat(element)..isReferencedAt('E(0).foo()', false);
assertThat(element).isReferencedAt('E(0).foo()', false);
}
test_isReferencedBy_FieldElement_class() async {
@@ -1048,14 +1048,14 @@ main(A a) {
PropertyAccessorElement getter = field.getter!;
PropertyAccessorElement setter = field.setter!;
// A()
assertThat(field)..isWrittenAt('field});', true);
assertThat(field).isWrittenAt('field});', true);
// m()
assertThat(setter)..isReferencedAt('field = 2; // nq', false);
assertThat(getter)..isReferencedAt('field); // nq', false);
assertThat(setter).isReferencedAt('field = 2; // nq', false);
assertThat(getter).isReferencedAt('field); // nq', false);
// main()
assertThat(setter)..isReferencedAt('field = 3; // q', true);
assertThat(getter)..isReferencedAt('field); // q', true);
assertThat(field)..isReferencedAt('field: 4', true);
assertThat(setter).isReferencedAt('field = 3; // q', true);
assertThat(getter).isReferencedAt('field); // q', true);
assertThat(field).isReferencedAt('field: 4', true);
}
test_isReferencedBy_FieldElement_class_multiple() async {
@@ -1077,18 +1077,18 @@ class A {
FieldElement field = findElement.field('aaa');
PropertyAccessorElement getter = field.getter!;
PropertyAccessorElement setter = field.setter!;
assertThat(field)..isWrittenAt('aaa, ', true);
assertThat(getter)..isReferencedAt('aaa);', false);
assertThat(setter)..isReferencedAt('aaa = 1;', false);
assertThat(field).isWrittenAt('aaa, ', true);
assertThat(getter).isReferencedAt('aaa);', false);
assertThat(setter).isReferencedAt('aaa = 1;', false);
}
// bbb
{
FieldElement field = findElement.field('bbb');
PropertyAccessorElement getter = field.getter!;
PropertyAccessorElement setter = field.setter!;
assertThat(field)..isWrittenAt('bbb) {}', true);
assertThat(getter)..isReferencedAt('bbb);', false);
assertThat(setter)..isReferencedAt('bbb = 2;', false);
assertThat(field).isWrittenAt('bbb) {}', true);
assertThat(getter).isReferencedAt('bbb);', false);
assertThat(setter).isReferencedAt('bbb = 2;', false);
}
}
@@ -1147,14 +1147,14 @@ void f(E e) {
PropertyAccessorElement getter = field.getter!;
PropertyAccessorElement setter = field.setter!;
// E()
assertThat(field)..isWrittenAt('field});', true);
assertThat(field).isWrittenAt('field});', true);
// foo()
assertThat(setter)..isReferencedAt('field = 2; // nq', false);
assertThat(getter)..isReferencedAt('field; // nq', false);
assertThat(setter).isReferencedAt('field = 2; // nq', false);
assertThat(getter).isReferencedAt('field; // nq', false);
// f()
assertThat(setter)..isReferencedAt('field = 3; // q', true);
assertThat(getter)..isReferencedAt('field; // q', true);
assertThat(field)..isReferencedAt('field: 4', true);
assertThat(setter).isReferencedAt('field = 3; // q', true);
assertThat(getter).isReferencedAt('field; // q', true);
assertThat(field).isReferencedAt('field: 4', true);
}
test_isReferencedBy_FieldElement_enum_index() async {
@@ -1171,11 +1171,11 @@ main() {
''');
ClassElement enumElement = findElement.enum_('MyEnum');
assertThat(enumElement.getGetter('values')!)
..isReferencedAt('values);', true);
.isReferencedAt('values);', true);
assertThat(typeProvider.enumElement!.getGetter('index')!)
..isReferencedAt('index);', true);
assertThat(enumElement.getGetter('A')!)..isReferencedAt('A);', true);
assertThat(enumElement.getGetter('B')!)..isReferencedAt('B);', true);
.isReferencedAt('index);', true);
assertThat(enumElement.getGetter('A')!).isReferencedAt('A);', true);
assertThat(enumElement.getGetter('B')!).isReferencedAt('B);', true);
}
test_isReferencedBy_FieldElement_enum_synthetic_hasGetter() async {
@@ -1239,10 +1239,10 @@ main() {
var importFind = findElement.importFind('package:test/foo.dart');
assertThat(importFind.importedLibrary)
..isReferencedAt('"foo.dart";', true, length: 10);
.isReferencedAt('"foo.dart";', true, length: 10);
FunctionElement bar = importFind.topFunction('bar');
assertThat(bar)..isInvokedAt('bar();', false);
assertThat(bar).isInvokedAt('bar();', false);
}
test_isReferencedBy_FunctionTypeAliasElement() async {
@@ -1252,7 +1252,7 @@ main(A p) {
}
''');
Element element = findElement.typeAlias('A');
assertThat(element)..isReferencedAt('A p) {', false);
assertThat(element).isReferencedAt('A p) {', false);
}
/// There was a bug in the AST structure, when single [Comment] was cloned and
@@ -1267,7 +1267,7 @@ class A {}
var myVariable = null;
''');
Element element = findElement.class_('A');
assertThat(element)..isReferencedAt('A] text', false);
assertThat(element).isReferencedAt('A] text', false);
}
test_isReferencedBy_MethodElement_class() async {
@@ -1330,7 +1330,7 @@ main() {
}
''');
Element element = findElement.parameter('p');
assertThat(element)..isReferencedAt('p: 1', true);
assertThat(element).isReferencedAt('p: 1', true);
}
test_isReferencedBy_ParameterElement_genericFunctionType() async {
@@ -1384,7 +1384,7 @@ class B extends A {
}
''');
var element = findElement.unnamedConstructor('A').parameter('a');
assertThat(element)..isReferencedAt('a}); // ref', true);
assertThat(element).isReferencedAt('a}); // ref', true);
}
test_isReferencedBy_ParameterElement_ofConstructor_super_positional() async {
@@ -1397,7 +1397,7 @@ class B extends A {
}
''');
var element = findElement.unnamedConstructor('A').parameter('a');
assertThat(element)..isReferencedAt('a); // ref', true);
assertThat(element).isReferencedAt('a); // ref', true);
}
test_isReferencedBy_ParameterElement_optionalNamed_ofConstructor_genericClass() async {
@@ -1411,7 +1411,7 @@ main() {
}
''');
Element element = findElement.parameter('test');
assertThat(element)..isReferencedAt('test: 0', true);
assertThat(element).isReferencedAt('test: 0', true);
}
test_isReferencedBy_ParameterElement_optionalNamed_ofMethod_genericClass() async {
@@ -1425,7 +1425,7 @@ main(A<int> a) {
}
''');
Element element = findElement.parameter('test');
assertThat(element)..isReferencedAt('test: 0', true);
assertThat(element).isReferencedAt('test: 0', true);
}
test_isReferencedBy_ParameterElement_optionalNamed_ofTopFunction() async {
@@ -1437,7 +1437,7 @@ void() {
}
''');
Element element = findElement.parameter('test');
assertThat(element)..isReferencedAt('test: 0', true);
assertThat(element).isReferencedAt('test: 0', true);
}
test_isReferencedBy_ParameterElement_optionalNamed_ofTopFunction_anywhere() async {
@@ -1449,7 +1449,7 @@ void() {
}
''');
Element element = findElement.parameter('test');
assertThat(element)..isReferencedAt('test: 0', true);
assertThat(element).isReferencedAt('test: 0', true);
}
test_isReferencedBy_ParameterElement_optionalPositional() async {
@@ -1476,7 +1476,7 @@ void() {
}
''');
Element element = findElement.parameter('test');
assertThat(element)..isReferencedAt('test: 0', true);
assertThat(element).isReferencedAt('test: 0', true);
}
test_isReferencedBy_PropertyAccessor_ofNamedExtension_instance() async {
@@ -1493,8 +1493,8 @@ main() {
''');
PropertyAccessorElement getter = findElement.getter('foo');
PropertyAccessorElement setter = findElement.setter('foo');
assertThat(getter)..isReferencedAt('foo;', true);
assertThat(setter)..isReferencedAt('foo = 0;', true);
assertThat(getter).isReferencedAt('foo;', true);
assertThat(setter).isReferencedAt('foo = 0;', true);
}
test_isReferencedBy_PropertyAccessor_ofNamedExtension_static() async {
@@ -1511,8 +1511,8 @@ main() {
''');
PropertyAccessorElement getter = findElement.getter('foo');
PropertyAccessorElement setter = findElement.setter('foo');
assertThat(getter)..isReferencedAt('foo;', true);
assertThat(setter)..isReferencedAt('foo = 0;', true);
assertThat(getter).isReferencedAt('foo;', true);
assertThat(setter).isReferencedAt('foo = 0;', true);
}
test_isReferencedBy_PropertyAccessor_ofUnnamedExtension_instance() async {
@@ -1538,16 +1538,16 @@ main() {
var intGetter = findNode.methodDeclaration('0; // int getter');
var intSetter = findNode.methodDeclaration('{} // int setter');
assertThat(intGetter.declaredElement!)
..isReferencedAt('foo; // int getter ref', true);
.isReferencedAt('foo; // int getter ref', true);
assertThat(intSetter.declaredElement!)
..isReferencedAt('foo = 0; // int setter ref', true);
.isReferencedAt('foo = 0; // int setter ref', true);
var doubleGetter = findNode.methodDeclaration('0; // double getter');
var doubleSetter = findNode.methodDeclaration('{} // double setter');
assertThat(doubleGetter.declaredElement!)
..isReferencedAt('foo; // double getter ref', true);
.isReferencedAt('foo; // double getter ref', true);
assertThat(doubleSetter.declaredElement!)
..isReferencedAt('foo = 0; // double setter ref', true);
.isReferencedAt('foo = 0; // double setter ref', true);
}
test_isReferencedBy_synthetic_leastUpperBound() async {
@@ -1577,7 +1577,7 @@ main() {
print(V); // nq
}''');
TopLevelVariableElement variable = importFindLib().topVar('V');
assertThat(variable)..isReferencedAt('V; // imp', true);
assertThat(variable).isReferencedAt('V; // imp', true);
assertThat(variable.getter!)
..isReferencedAt('V); // q', true)
..isReferencedAt('V); // nq', false);
@@ -59,13 +59,12 @@ class DartRepositoryMacroKernelBuilder implements MacroKernelBuilder {
var macroMainPath = '${libraries.first.path}.macro';
var macroMainUri = fileSystem.pathContext.toUri(macroMainPath);
options
..fileSystem = _FileSystem(
fileSystem,
platformDillBytes,
macroMainUri,
macroMainBytes,
);
options.fileSystem = _FileSystem(
fileSystem,
platformDillBytes,
macroMainUri,
macroMainBytes,
);
// TODO(scheglov) For now we convert async into sync.
// ignore: deprecated_member_use