File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,14 @@ fn gotoDefinitionSymbol(
38
38
.definition = > try decl_handle .definitionToken (analyser , true ),
39
39
.type_definition = > blk : {
40
40
if (try decl_handle .resolveType (analyser )) | ty | {
41
- if (try ty .typeDefinitionToken ()) | token_handle | break :blk token_handle ;
41
+ var resolved_ty = ty ;
42
+ while (true ) {
43
+ resolved_ty =
44
+ try analyser .resolveUnwrapErrorUnionType (resolved_ty , .payload ) orelse
45
+ try analyser .resolveDerefType (resolved_ty ) orelse
46
+ try analyser .resolveOptionalUnwrap (resolved_ty ) orelse break ;
47
+ }
48
+ if (try resolved_ty .typeDefinitionToken ()) | token_handle | break :blk token_handle ;
42
49
}
43
50
const type_declaration = try decl_handle .typeDeclarationNode () orelse return null ;
44
51
Original file line number Diff line number Diff line change @@ -260,6 +260,25 @@ test "non labeled break" {
260
260
);
261
261
}
262
262
263
+ test "type definition unwraps error unions, optionals, pointers" {
264
+ try testDefinition (
265
+ \\const S = <tdef>struct</tdef> {};
266
+ \\const <>foo: error{}!S = .{};
267
+ );
268
+ try testDefinition (
269
+ \\const S = <tdef>struct</tdef> {};
270
+ \\const <>foo: ?S = .{};
271
+ );
272
+ try testDefinition (
273
+ \\const S = <tdef>struct</tdef> {};
274
+ \\const <>foo: *const S = &.{};
275
+ );
276
+ try testDefinition (
277
+ \\const S = <tdef>struct</tdef> {};
278
+ \\const <>foo: error{}!?*const S = &.{};
279
+ );
280
+ }
281
+
263
282
/// - use `<>` to indicate the cursor position
264
283
/// - use `<decl>content</decl>` to set the expected range of the declaration
265
284
/// - use `<def>content</def>` to set the expected range of the definition
You can’t perform that action at this time.
0 commit comments