Remove type cast in completion to prevent exception

Change-Id: If97adc54523894a3b9df241ffb0308ee1299d03d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372020
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Brian Wilkerson 2024-06-18 14:14:19 +00:00 committed by Commit Queue
parent 3b5065b49e
commit 1e5f96514c
3 changed files with 59 additions and 5 deletions

View file

@ -1144,11 +1144,14 @@ class DeclarationHelper {
);
}
}
_addExtensionMembers(
type: element.thisType as InterfaceType,
excludedGetters: {},
includeMethods: true,
includeSetters: true);
var thisType = element.thisType;
if (thisType is InterfaceType) {
_addExtensionMembers(
type: thisType,
excludedGetters: {},
includeMethods: true,
includeSetters: true);
}
}
/// Completion is inside [declaration].

View file

@ -0,0 +1,49 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../client/completion_driver_test.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(FunctionInvocationTest);
});
}
@reflectiveTest
class FunctionInvocationTest extends AbstractCompletionDriverTest
with FunctionInvocationTestCases {}
mixin FunctionInvocationTestCases on AbstractCompletionDriverTest {
Future<void> test_implicitCall() async {
await computeSuggestions('''
extension E<T> on Comparator<T> {
Comparator<T> get inverse => (T a0, T b0) => this(^);
}
''');
// TODO(brianwilkerson): `super` should not be suggested here.
assertResponse(r'''
suggestions
a0
kind: parameter
b0
kind: parameter
true
kind: keyword
false
kind: keyword
null
kind: keyword
this
kind: keyword
const
kind: keyword
super
kind: keyword
switch
kind: keyword
''');
}
}

View file

@ -33,6 +33,7 @@ import 'for_element_test.dart' as for_element;
import 'for_statement_test.dart' as for_statement;
import 'function_declaration_test.dart' as function_declaration;
import 'function_expression_test.dart' as function_expression;
import 'function_invocation_test.dart' as function_invocation;
import 'if_element_test.dart' as if_element;
import 'if_statement_test.dart' as if_statement;
import 'implements_clause_test.dart' as implements_clause;
@ -112,6 +113,7 @@ void main() {
for_statement.main();
function_declaration.main();
function_expression.main();
function_invocation.main();
if_element.main();
if_statement.main();
implements_clause.main();