This patch fixes the handling of overloaded indexing operations that are inherited by a type derived from one that carries an indexing aspect. Source: --- with Ada.Text_Io; use Ada.Text_Io; with References; procedure Main is A : aliased References.Iterated; begin A (1) := 42; Put_Line ("A (1)" & References.Object_T'Image (A (1))); Put_Line ("A (1, 1)" & References.Object_T'Image (A (1, 1))); end Main; --- package body References is function Find (I : aliased in out Indexed; Key : Index) return Reference_T is begin return (Object => I.Rep (Key)'Access); end Find; function Find (I : aliased in out Indexed; Key1, Key2 : Index) return Reference_T is begin return (Object => I.Rep (Key1)'Access); end Find; function Find (I : aliased in out Iterated; C : Cursor) return Reference_T is begin return (Object => I.Rep (C.I)'Access); end Find; function Has_Element (Position : Cursor) return Boolean is begin return Position.Has_Element; end Has_Element; function First (Object : Iterator) return Cursor is Has_Elements : constant Boolean := Object.First <= Object.Last; begin if Has_Elements then return (Has_Element => True, I => Object.First); else return (Has_Element => False); end if; end First; function Next (Object : Iterator; Position : Cursor) return Cursor is begin if Position.Has_Element and then Position.I /= Index'Last then return (Has_Element => True, I => Position.I + 1); else return (Has_Element => False); end if; end Next; function Last (Object : Iterator) return Cursor is Has_Elements : constant Boolean := Object.First <= Object.Last; begin if Has_Elements then return (Has_Element => True, I => Object.Last); else return (Has_Element => False); end if; end Last; function Previous (Object : Iterator; Position : Cursor) return Cursor is begin if Position.Has_Element and then Position.I /= Index'First then return (Has_Element => True, I => Position.I - 1); else return (Has_Element => False); end if; end Previous; function Iterate (Container : Iterated) return Iterators.Reversible_Iterator'Class is begin return Iterator'(First => Container.Rep'First, Last => Container.Rep'Last); end Iterate; end References; --- with Ada.Iterator_Interfaces; package References is type Object_T is new Integer; type Reference_T (Object : not null access Object_T) is private with Implicit_Dereference => Object; type Index is range 1 .. 2; type Array_T is array (Index) of aliased Object_T; type Cursor is private; type Indexed is tagged record Rep : Array_T; end record with Variable_Indexing => Find; function Find (I : aliased in out Indexed; Key : Index) return Reference_T; function Find (I : aliased in out Indexed; Key1, Key2 : Index) return Reference_T; function Has_Element (Position : Cursor) return Boolean; package Iterators is new Ada.Iterator_Interfaces (Cursor, Has_Element); type Iterator is new Iterators.Reversible_Iterator with record First : Index; Last : Index; end record; function First (Object : Iterator) return Cursor; function Next (Object : Iterator; Position : Cursor) return Cursor; function Last (Object : Iterator) return Cursor; function Previous (Object : Iterator; Position : Cursor) return Cursor; type Iterated is new Indexed with null record with Default_Iterator => Iterate, Iterator_Element => Object_T; function Find (I : aliased in out Iterated; C : Cursor) return Reference_T; function Iterate (Container : Iterated) return Iterators.Reversible_Iterator'Class; private type Reference_T (Object : not null access Object_T) is null record; type Cursor (Has_Element : Boolean := False) is record case Has_Element is when True => I : Index; when False => null; end case; end record; end References; --- Command: gnatmake -q main main --- Output: A (1) 42 A (1, 1) 42 Tested on x86_64-pc-linux-gnu, committed on trunk 2015-10-26 Ed Schonberg * exp_util.ads, exp_util.adb (Find_Primitive_Operations): New subprogram to retrieve by name the possibly overloaded set of primitive operations of a type. * sem_ch4.adb (Try_Container_Indexing): Use Find_Primitive_Operations to handle overloaded indexing operations of a derived type.