mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:48:25 +00:00
Fix an invalid null check in InlineMethodRefactoring.
Saw it failing in the crash log. Change-Id: I6cf715aeb6f41e405af58a00b69b8742fd7c5ed0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214182 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
9854a04210
commit
31922b8c57
|
@ -147,7 +147,8 @@ Set<String> _getNamesConflictingAt(AstNode node) {
|
|||
// local variables and functions
|
||||
{
|
||||
var localsRange = _getLocalsConflictingRange(node);
|
||||
var enclosingExecutable = getEnclosingExecutableNode(node)!;
|
||||
var enclosingExecutable = getEnclosingExecutableNode(node);
|
||||
if (enclosingExecutable != null) {
|
||||
var visibleRangeMap = VisibleRangesComputer.forNode(enclosingExecutable);
|
||||
visibleRangeMap.forEach((element, elementRange) {
|
||||
if (elementRange.intersects(localsRange)) {
|
||||
|
@ -155,6 +156,7 @@ Set<String> _getNamesConflictingAt(AstNode node) {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// fields
|
||||
{
|
||||
var enclosingClassElement = getEnclosingClassElement(node);
|
||||
|
|
|
@ -1739,6 +1739,17 @@ void f(bool p, bool p2, bool p3) {
|
|||
''');
|
||||
}
|
||||
|
||||
Future<void> test_target_topLevelVariable() async {
|
||||
await indexTestUnit(r'''
|
||||
int get test => 42;
|
||||
var a = test;
|
||||
''');
|
||||
_createRefactoring('test =>');
|
||||
return _assertSuccessfulRefactoring(r'''
|
||||
var a = 42;
|
||||
''');
|
||||
}
|
||||
|
||||
Future _assertConditionsError(String message) async {
|
||||
var status = await refactoring.checkAllConditions();
|
||||
assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
|
||||
|
|
Loading…
Reference in a new issue