|
Revision 1651, 395 bytes
(checked in by Chuck.Esterbrook, 4 years ago)
|
|
Fix problems with generic methods.
No release notes since generic methods are new since the last release.
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | class X |
|---|
| 2 | |
|---|
| 3 | shared |
|---|
| 4 | |
|---|
| 5 | # Declare a generic method with no args |
|---|
| 6 | def create<of T> as T |
|---|
| 7 | sysType = T.getType |
|---|
| 8 | x = sysType() |
|---|
| 9 | return x to T |
|---|
| 10 | |
|---|
| 11 | class T |
|---|
| 12 | |
|---|
| 13 | def main is shared |
|---|
| 14 | # Invoke a generic method with no args |
|---|
| 15 | x as int = X.create<of int> |
|---|
| 16 | |
|---|
| 17 | # Type inference |
|---|
| 18 | y = X.create<of int> |
|---|
| 19 | |
|---|
| 20 | # Validate type inference with back and forth assignment to x |
|---|
| 21 | y = x |
|---|
| 22 | x = y |
|---|
| 23 | |
|---|
| 24 | CobraCore.noOp(x, y) |
|---|