File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,18 @@ impl<'a> TypeEnt<'a> {
145145 match self . kind ( ) {
146146 Type :: Alias ( alias) => alias. base_type ( ) ,
147147 Type :: Subtype ( subtype) => subtype. base_type ( ) ,
148+ Type :: Protected ( .., is_body) if * is_body => {
149+ // Never use the protected type body in signatures, use the non-body
150+ if let Related :: DeclaredBy ( other) = self . related {
151+ if let Some ( typ) = TypeEnt :: from_any ( other) {
152+ typ
153+ } else {
154+ * self
155+ }
156+ } else {
157+ * self
158+ }
159+ }
148160 _ => * self ,
149161 }
150162 }
Original file line number Diff line number Diff line change @@ -290,3 +290,45 @@ end package;",
290290 Some ( & code. s( "prot_t" , 2 ) . pos( ) )
291291 ) ;
292292}
293+
294+ /// This was a bug where a procedure declared between the protected type and the body
295+ /// did not have the same signature as the definition which was after the body
296+ #[ test]
297+ fn protected_type_and_body_result_in_the_same_signature ( ) {
298+ let mut builder = LibraryBuilder :: new ( ) ;
299+ let code = builder. code (
300+ "libname" ,
301+ "
302+ package pkg is
303+ end package;
304+
305+ package body pkg is
306+ type prot_t is protected
307+ end protected;
308+
309+ procedure myproc(arg : prot_t);
310+
311+ type prot_t is protected body
312+ end protected body;
313+
314+ procedure myproc(arg : prot_t) is
315+ begin
316+ end procedure;
317+
318+ end package body;
319+ " ,
320+ ) ;
321+
322+ let ( root, diagnostics) = builder. get_analyzed_root ( ) ;
323+ check_no_diagnostics ( & diagnostics) ;
324+
325+ assert_eq ! (
326+ root. find_all_references_pos( & code. s1( "prot_t" ) . pos( ) ) . len( ) ,
327+ 4
328+ ) ;
329+
330+ assert_eq ! (
331+ root. find_all_references_pos( & code. s1( "myproc" ) . pos( ) ) . len( ) ,
332+ 2
333+ ) ;
334+ }
You can’t perform that action at this time.
0 commit comments