Skip to content

Commit

Permalink
Version 3.6.0-289.0.dev
Browse files Browse the repository at this point in the history
Merge 15540bc into dev
  • Loading branch information
Dart CI committed Sep 27, 2024
2 parents 3a37ef3 + 15540bc commit 133a2f3
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 22 deletions.
5 changes: 5 additions & 0 deletions pkg/analyzer/lib/dart/element/element2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,11 @@ abstract class LibraryImport {
abstract class LocalFunctionElement implements ExecutableElement2 {
/// The function in which the variable is defined.
ExecutableFragment get enclosingFunction;

/// The offset of the name of this element in the file that contains the
/// declaration of this element, or `-1` if this element is synthetic, does
/// not have a name, or otherwise does not have an offset.
int get nameOffset;
}

/// A local variable.
Expand Down
8 changes: 1 addition & 7 deletions pkg/analyzer/lib/src/dart/ast/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9400,13 +9400,7 @@ sealed class IdentifierImpl extends CommentReferableExpressionImpl
@experimental
@override
Element2? get element {
var element = staticElement;
if (element case Fragment fragment) {
return fragment.element;
} else if (element case Element2 element) {
return element;
}
return null;
return staticElement.asElement2;
}

@override
Expand Down
3 changes: 3 additions & 0 deletions pkg/analyzer/lib/src/dart/element/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6481,6 +6481,9 @@ class LocalFunctionElementImpl extends ExecutableElementImpl2
@override
List<ElementAnnotation> get metadata => _wrappedElement.metadata;

@override
int get nameOffset => _wrappedElement.nameOffset;

@override
DartType get returnType => _wrappedElement.returnType;

Expand Down
4 changes: 4 additions & 0 deletions pkg/analyzer/lib/src/utilities/extensions/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/member.dart';
import 'package:meta/meta.dart';

extension Element2OrNullExtension on Element2? {
Expand Down Expand Up @@ -126,6 +127,9 @@ extension ElementOrNullExtension on Element? {
return self;
} else if (self is NeverElementImpl) {
return self;
} else if (self is ParameterMember) {
// TODO(scheglov): we lose types here
return self.declaration.asElement2;
} else if (self is PrefixElementImpl) {
return self;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2805,10 +2805,10 @@ ExpressionStatement
identifier: SimpleIdentifier
token: loadLibrary
staticElement: loadLibrary@-1
<exception>
element: loadLibrary@-1
staticType: Future<dynamic> Function()
staticElement: loadLibrary@-1
<exception>
element: loadLibrary@-1
staticType: Future<dynamic> Function()
semicolon: ;
''');
Expand All @@ -2829,7 +2829,7 @@ FunctionReference
function: SimpleIdentifier
token: foo
staticElement: foo@20
<exception>
element: foo@20
staticType: void Function<T>(T)
typeArguments: TypeArgumentList
leftBracket: <
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ f() {
SimpleIdentifier
token: _
staticElement: _@52
<exception>
element: _@52
staticType: Null Function()
''');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,7 @@ MethodInvocation
methodName: SimpleIdentifier
token: loadLibrary
staticElement: loadLibrary@-1
<exception>
element: loadLibrary@-1
staticType: Future<dynamic> Function()
argumentList: ArgumentList
leftParenthesis: (
Expand Down Expand Up @@ -3554,7 +3554,7 @@ MethodInvocation
methodName: SimpleIdentifier
token: loadLibrary
staticElement: loadLibrary@-1
<exception>
element: loadLibrary@-1
staticType: Future<dynamic> Function()
argumentList: ArgumentList
leftParenthesis: (
Expand Down Expand Up @@ -3588,7 +3588,7 @@ MethodInvocation
methodName: SimpleIdentifier
token: loadLibrary
staticElement: loadLibrary@-1
<exception>
element: loadLibrary@-1
staticType: Future<dynamic> Function()
argumentList: ArgumentList
leftParenthesis: (
Expand Down Expand Up @@ -6604,7 +6604,7 @@ MethodInvocation
methodName: SimpleIdentifier
token: g
staticElement: g@20
<exception>
element: g@20
staticType: double Function(int, String)
argumentList: ArgumentList
leftParenthesis: (
Expand Down Expand Up @@ -6635,7 +6635,7 @@ MethodInvocation
methodName: SimpleIdentifier
token: g
staticElement: g@15
<exception>
element: g@15
staticType: T Function<T, U>(T, U)
argumentList: ArgumentList
leftParenthesis: (
Expand Down Expand Up @@ -6671,7 +6671,7 @@ MethodInvocation
methodName: SimpleIdentifier
token: g
staticElement: g@15
<exception>
element: g@15
staticType: T Function<T>([T?])
argumentList: ArgumentList
leftParenthesis: (
Expand Down Expand Up @@ -6704,7 +6704,7 @@ MethodInvocation
methodName: SimpleIdentifier
token: g
staticElement: g@15
<exception>
element: g@15
staticType: T Function<T>({required T a})
argumentList: ArgumentList
leftParenthesis: (
Expand All @@ -6716,7 +6716,7 @@ MethodInvocation
staticElement: ParameterMember
base: g@15::@parameter::a
substitution: {T: int}
element: <null>
element: g@15::@parameter::a#element
staticType: null
colon: :
expression: IntegerLiteral
Expand Down Expand Up @@ -7129,7 +7129,7 @@ MethodInvocation
methodName: SimpleIdentifier
token: foo
staticElement: foo@16
<exception>
element: foo@16
staticType: void Function(int)
argumentList: ArgumentList
leftParenthesis: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ MethodInvocation
staticElement: ParameterMember
base: <testLibraryFragment>::@function::foo::@parameter::x
substitution: {T: int}
element: <null>
element: <testLibraryFragment>::@function::foo::@parameter::x#element
staticType: null
colon: :
expression: IntegerLiteral
Expand Down
2 changes: 2 additions & 0 deletions pkg/analyzer/test/util/element_printer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class ElementPrinter {
_sink.write('${element.name}@${element.nameOffset}');
case LibraryElementImpl e:
writeReference(e.reference!);
case LocalFunctionElementImpl():
_sink.write('${element.name}@${element.nameOffset}');
case LocalVariableElementImpl():
_sink.write('${element.name}@${element.nameOffset}');
case LocalVariableElementImpl2():
Expand Down
5 changes: 5 additions & 0 deletions pkg/dev_compiler/test/hot_reload_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final testTimeoutSeconds = 10;
final testDiffSeparator = '/** DIFF **/';

final argParser = ArgParser()
..addFlag('help', abbr: 'h', help: 'Display this message.', negatable: false)
..addOption('runtime',
abbr: 'r',
defaultsTo: 'd8',
Expand Down Expand Up @@ -71,6 +72,10 @@ late final bool debug;

Future<void> main(List<String> args) async {
final argResults = argParser.parse(args);
if (argResults['help'] as bool) {
print(argParser.usage);
return;
}
final runtimePlatform =
RuntimePlatforms.values.byName(argResults['runtime'] as String);
final testNameFilter = RegExp(argResults['filter'] as String);
Expand Down
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 3
MINOR 6
PATCH 0
PRERELEASE 288
PRERELEASE 289
PRERELEASE_PATCH 0

0 comments on commit 133a2f3

Please sign in to comment.