Last change
on this file since 930a800 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
|
Line | |
---|
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() { |
---|
18 | forall( T & ) |
---|
19 | void friend( T & ) { |
---|
20 | printf("friending generically\n"); |
---|
21 | } |
---|
22 | |
---|
23 | forall(T &) |
---|
24 | struct thing { |
---|
25 | int x; |
---|
26 | }; |
---|
27 | |
---|
28 | forall( T & ) |
---|
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 | |
---|
37 | void testSpecializationFromGenericAccessibleWithExtraTyvars() { |
---|
38 | |
---|
39 | forall( T &, U & ) |
---|
40 | struct map {}; |
---|
41 | |
---|
42 | forall( T & ) |
---|
43 | void f( T & ) { |
---|
44 | printf("f-generic\n"); |
---|
45 | } |
---|
46 | |
---|
47 | forall( T & ) |
---|
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 | } |
---|
57 | |
---|
58 | int main() { |
---|
59 | testSpecializationFromGenericOverBareTyvar(); |
---|
60 | printf("-\n"); |
---|
61 | testSpecializationFromGenericAccessibleWithExtraTyvars(); |
---|
62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.