From 90c66f3037aada1983484461c4860fc399005d23 Mon Sep 17 00:00:00 2001 From: Nathan Braswell Date: Mon, 25 May 2015 12:11:45 -0400 Subject: [PATCH] Improved and bugfixed template infrance to be able to infrence based on function types too --- ...functionTemplateInference.expected_results | 2 ++ tests/test_functionTemplateInference.krak | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/tests/test_functionTemplateInference.expected_results b/tests/test_functionTemplateInference.expected_results index 45a4fb7..236483f 100644 --- a/tests/test_functionTemplateInference.expected_results +++ b/tests/test_functionTemplateInference.expected_results @@ -1 +1,3 @@ 8 +9 +10 diff --git a/tests/test_functionTemplateInference.krak b/tests/test_functionTemplateInference.krak index 55e03d8..a7ad5be 100644 --- a/tests/test_functionTemplateInference.krak +++ b/tests/test_functionTemplateInference.krak @@ -1,5 +1,22 @@ import io:* +fun funcID(genFun: fun():T):T { + return genFun() +} + +fun retInt():int { + return 9 +} + +fun doThePrint(func: fun(T):void):void { + func(10) +} + +fun printInt(it:int):void { + println(it) +} + + fun ptrFn(ptr: T*):void { println(*ptr) } @@ -7,6 +24,8 @@ fun ptrFn(ptr: T*):void { fun main():int { var a = 8 ptrFn(&a) + println(funcID(retInt)) + doThePrint(printInt) return 0 }