Skip to content

Commit 684a391

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Fix completion error when a typedef points to a mixin
This fixes an exception that prevents completion from working if a typedef points at a mixin, which is something Flutter has: ```dart typedef RenderConstrainedLayoutBuilder<LayoutInfoType, ChildType extends RenderObject> = RenderAbstractLayoutBuilderMixin<LayoutInfoType, ChildType>; mixin RenderAbstractLayoutBuilderMixin<LayoutInfoType, ChildType extends RenderObject> on RenderObjectWithChildMixin<ChildType>, RenderObjectWithLayoutCallbackMixin ``` Fixes #61197 Change-Id: Ibf31612d34893f2183a7da513359bdbff6a5c066 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441962 Reviewed-by: Keerti Parthasarathy <[email protected]> Commit-Queue: Keerti Parthasarathy <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent cc687f1 commit 684a391

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,7 @@ class DeclarationHelper {
18321832
return;
18331833
}
18341834
if (checkVisibilty &&
1835+
constructors.isNotEmpty &&
18351836
!visibilityTracker.isVisible(
18361837
element: constructors.first.enclosingElement,
18371838
importData: importData,

pkg/analysis_server/test/src/services/completion/dart/completion_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@ abstract class C {
100100
''');
101101
assertHasNoCompletion('C.c');
102102
}
103+
104+
/// Ensures completion does not error when a typedef points at a mixin because
105+
/// there are no constructors.
106+
Future<void> test_typeDef_toMixin_noError_issue61197() async {
107+
await getTestCodeSuggestions('''
108+
typedef T = M;
109+
mixin M {}
110+
111+
void main() {
112+
^
113+
}
114+
''');
115+
}
103116
}
104117

105118
@reflectiveTest

0 commit comments

Comments
 (0)