diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2020-04-14 10:55:10 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-14 10:55:10 -0700 |
| commit | cbdee1b1873ff0b7be887bccfbe5409e1a7ba685 (patch) | |
| tree | 37ca219c3bb3a939e484c54e53b950bea01b23af /tests/language-feature/static-members | |
| parent | 79f6a0193c3b9f9d7211c03cd90e434347245af6 (diff) | |
Fix front-end handling of generic static methods (#1319)
* Fix front-end handling of generic static methods
The front-end logic that was testing if a member was usable as a static member neglected to unwrap any generic-ness and look at the declaration inside (the parser currently puts all modifiers on the inner declaration instead of the outer generic).
The test case included here is not a full compute test so that it only runs the front-end checking logic (where we had the bug).
* fixup: tabs->spaces
Diffstat (limited to 'tests/language-feature/static-members')
| -rw-r--r-- | tests/language-feature/static-members/generic-static-method.slang | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/language-feature/static-members/generic-static-method.slang b/tests/language-feature/static-members/generic-static-method.slang new file mode 100644 index 000000000..b1868175f --- /dev/null +++ b/tests/language-feature/static-members/generic-static-method.slang @@ -0,0 +1,30 @@ +// generic-static-method.slang + +// Confirm that the compiler can handle a generic +// `static` method declaration and call. + +//TEST:SIMPLE: + +interface IFrobnicator +{ + float frobnicate(float value); +} + +struct Doubler : IFrobnicator +{ + float frobnicate(float value) { return 2.0f * value; } +} + +struct FrobnicateHelpers +{ + static float doubleFrobnicate<F : IFrobnicator>(F f, float value) + { + return f.frobnicate(f.frobnicate(value)); + } +} + +float test(float value) +{ + Doubler d; + return FrobnicateHelpers.doubleFrobnicate(d, value); +} |
