File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -415,7 +415,17 @@ pub fn firstParamIs(
415415 else = > expected_type ,
416416 };
417417
418- return deref_type .eql (deref_expected_type );
418+ return switch (deref_type .data ) {
419+ .either = > | entries | {
420+ for (entries ) | entry | {
421+ if (entry .type_data .eql (deref_expected_type .data )) {
422+ return true ;
423+ }
424+ }
425+ return false ;
426+ },
427+ else = > deref_type .eql (deref_expected_type ),
428+ };
419429}
420430
421431pub fn getVariableSignature (
Original file line number Diff line number Diff line change @@ -4338,6 +4338,34 @@ test "generic function with @This() as self param" {
43384338 });
43394339}
43404340
4341+ test "methods of branching type" {
4342+ try testCompletion (
4343+ \\const Reader = switch (undefined) {
4344+ \\ .windows => struct {
4345+ \\ fn foo(_: *Reader) bool {}
4346+ \\ },
4347+ \\ else => struct {
4348+ \\ fn bar(_: *Reader) bool {}
4349+ \\ },
4350+ \\};
4351+ \\test {
4352+ \\ var reader: Reader = undefined;
4353+ \\ reader.<cursor>
4354+ \\}
4355+ , &.{
4356+ .{
4357+ .label = "foo" ,
4358+ .kind = .Function ,
4359+ .detail = "fn (_: *either type) bool" ,
4360+ },
4361+ .{
4362+ .label = "bar" ,
4363+ .kind = .Function ,
4364+ .detail = "fn (_: *either type) bool" ,
4365+ },
4366+ });
4367+ }
4368+
43414369fn testCompletion (source : []const u8 , expected_completions : []const Completion ) ! void {
43424370 try testCompletionWithOptions (source , expected_completions , .{});
43434371}
You can’t perform that action at this time.
0 commit comments