Last change
on this file since 26d40a1 was
fd54fef,
checked in by Michael Brooks <mlbrooks@…>, 4 years ago
|
Converting the project to use the new syntax for otype, dtype and ttytpe.
Changed prelude (gen), libcfa and test suite to use it. Added a simple deprecation rule of the old syntax to the parser; we might wish to support both syntaxes "officially," like with an extra CLI switch, but this measure should serve as a simple reminder for our team to try the new syntax.
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[978e5eb] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // poly-selection.cfa -- tests that show correct candidates selected, given interesting cases of |
---|
| 8 | // forall/overload polymoprphism |
---|
| 9 | // |
---|
| 10 | // Author : Michael Brooks |
---|
| 11 | // Created On : Mon Jan 18 15:00:00 2021 |
---|
| 12 | // Last Modified By : Michael Brooks |
---|
| 13 | // Last Modified On : Mon Jan 18 15:00:00 2021 |
---|
| 14 | // Update Count : 1 |
---|
| 15 | // |
---|
| 16 | |
---|
| 17 | void testSpecializationFromGenericOverBareTyvar() { |
---|
[fd54fef] | 18 | forall( T & ) |
---|
[978e5eb] | 19 | void friend( T & ) { |
---|
| 20 | printf("friending generically\n"); |
---|
| 21 | } |
---|
| 22 | |
---|
[fd54fef] | 23 | forall(T &) |
---|
[978e5eb] | 24 | struct thing { |
---|
| 25 | int x; |
---|
| 26 | }; |
---|
| 27 | |
---|
[fd54fef] | 28 | forall( T & ) |
---|
[978e5eb] | 29 | void friend( thing(T) & ) { |
---|
| 30 | printf("friending specifically\n"); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | float x; friend( x ); |
---|
| 34 | thing(float) y; friend( y ); |
---|
| 35 | } |
---|
| 36 | |
---|
[fcd0b9d7] | 37 | void testSpecializationFromGenericAccessibleWithExtraTyvars() { |
---|
| 38 | |
---|
[fd54fef] | 39 | forall( T &, U & ) |
---|
[fcd0b9d7] | 40 | struct map {}; |
---|
| 41 | |
---|
[fd54fef] | 42 | forall( T & ) |
---|
[fcd0b9d7] | 43 | void f( T & ) { |
---|
| 44 | printf("f-generic\n"); |
---|
| 45 | } |
---|
| 46 | |
---|
[fd54fef] | 47 | forall( T & ) |
---|
[fcd0b9d7] | 48 | void f( map(T, T) & ) { |
---|
| 49 | printf("f-specific\n"); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | float one; |
---|
| 53 | map(float, float) two; |
---|
| 54 | f(one); |
---|
| 55 | f(two); |
---|
| 56 | } |
---|
[978e5eb] | 57 | |
---|
| 58 | int main() { |
---|
| 59 | testSpecializationFromGenericOverBareTyvar(); |
---|
[fcd0b9d7] | 60 | printf("-\n"); |
---|
| 61 | testSpecializationFromGenericAccessibleWithExtraTyvars(); |
---|
[978e5eb] | 62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.