From 9cd59d39895c4e45105fb7114618b389f1b2b457 Mon Sep 17 00:00:00 2001 From: Juraj Kirchheim Date: Mon, 29 Jan 2018 10:12:06 +0100 Subject: [PATCH] Handle module types properly. --- src/tink/macro/Sisyphus.hx | 10 ++++++++-- tests/Types.hx | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/tink/macro/Sisyphus.hx b/src/tink/macro/Sisyphus.hx index 01a9bf0..473878b 100644 --- a/src/tink/macro/Sisyphus.hx +++ b/src/tink/macro/Sisyphus.hx @@ -99,10 +99,16 @@ class Sisyphus { } static function toTypePath(baseType : BaseType, params : Array) : TypePath return { var module = baseType.module; + var name = module.substring(module.lastIndexOf(".") + 1); + var sub = switch baseType.name { + case _ == name => true: null; + case v: v; + } + { pack: baseType.pack, - name: module.substring(module.lastIndexOf(".") + 1), - sub: baseType.name, + name: name, + sub: sub, params: [ for (t in params) TPType(toComplexType(t)) ], } } diff --git a/tests/Types.hx b/tests/Types.hx index 88cae01..680b6ab 100644 --- a/tests/Types.hx +++ b/tests/Types.hx @@ -44,4 +44,9 @@ class Types extends Base { MacroApi.pos().makeBlankType().toString(); } + + function testToComplex() { + assertEquals('String', Context.getType('String').toComplex().toString()); + assertEquals('tink.CoreApi.Noise', Context.getType('tink.CoreApi.Noise').toComplex().toString()); + } } \ No newline at end of file