-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topic/1262' into 'master'
Use p_get_aspect in p_iterable_cursor_type Closes #1262 See merge request eng/libadalang/libadalang!1547
- Loading branch information
Showing
4 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
testsuite/tests/name_resolution/iterable_aspect/private_view.adb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
procedure Private_View is | ||
package P is | ||
type Sequence is private with | ||
Iterable => (First => Iter_First, | ||
Has_Element => Iter_Has_Element, | ||
Next => Iter_Next); | ||
|
||
function Iter_First (Container : Sequence) return Integer; | ||
function Iter_Has_Element | ||
(Container : Sequence; | ||
Position : Integer) return Boolean; | ||
function Iter_Next | ||
(Container : Sequence; | ||
Position : Integer) return Integer; | ||
private | ||
|
||
type Sequence is record | ||
Content : String (1 .. 10); | ||
end record; | ||
|
||
function Iter_First (Container : Sequence) return Integer is | ||
(Container.Content'First); | ||
function Iter_Has_Element | ||
(Container : Sequence; | ||
Position : Integer) return Boolean is | ||
(Position < Container.Content'Last); | ||
function Iter_Next | ||
(Container : Sequence; | ||
Position : Integer) return Integer is (Position + 1); | ||
end P; | ||
|
||
package body P is | ||
function Ident (I : Integer) return Boolean is (True); | ||
|
||
-- Below, Sequence refers to the private view of Sequence, which has no | ||
-- aspect Iterable. `p_iterable_cursor_type` should also look for the | ||
-- Iterable aspect on the public part too. | ||
function "<" (Left : Sequence; Right : Sequence) return Boolean is | ||
(for all N in Left => Ident (N)); | ||
pragma Test_Statement; | ||
|
||
type New_Sequence is new Sequence; | ||
|
||
-- Below, New_Sequence refers to the type declared above, inheriting the | ||
-- Iterable aspect from Sequence. `p_iterable_cursor_type` should also | ||
-- look for the Iterable aspect on the parent types. | ||
function "<" (Left : New_Sequence; Right : New_Sequence) return Boolean | ||
is (for all N in Left => Ident (N)); | ||
pragma Test_Statement; | ||
end P; | ||
begin | ||
null; | ||
end Private_View; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
driver: name-resolution | ||
input_sources: [test.adb] | ||
input_sources: [test.adb, private_view.adb] |