Consider this:
procedure Visibility is
package Q is
type T is abstract tagged null record;
function "&" (Left, Right : T) return T is abstract;
function "&" (Left, Right : Integer) return T is abstract;
end Q;
package R is
use Q;
type S is new T with null record;
private
overriding function "&" (Left, Right : S) return S;
overriding function "&" (Left, Right : Integer) return S;
end R;
package body R is -- The body is irrelevant
function "&" (Left, Right : S) return S is
begin
return S'(null record);
end "&";
function "&" (Left, Right : Integer) return S is
begin
return S'(null record);
end "&";
end R;
use R;
X : Q.T'Class := (1 & 2) & (3 & 4); -- This is fine
begin
null;
end Visibility;
Now, let’s change it to this (just adding use Q):
use Q, R;
X : T'Class := (1 & 2) & (3 & 4); -- Error!
GNAT 16.2 gives:
visibility.adb:25:27: error: ambiguous expression (cannot resolve "&")
visibility.adb:25:27: error: possible interpretation (inherited) at line 9
visibility.adb:25:27: error: possible interpretation at line 4
gnatmake: "visibility.adb" compilation error
It seems that an abstract primitive function (line 4) gets considered in resolution of “&”! This is quite surprizing to me, but I do not know if the compiler is correct here.