diff --git a/.haxerc b/.haxerc index 4d2d91c..ed33e32 100644 --- a/.haxerc +++ b/.haxerc @@ -1 +1,4 @@ -{"version":"3.4.7","resolveLibs":"scoped"} \ No newline at end of file +{ + "version": "4.0.0-rc.1", + "resolveLibs": "scoped" +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index f3a8721..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "haxe.displayConfigurations": [ - ["tests.hxml"] - ] -} diff --git a/dev.hxml b/dev.hxml new file mode 100644 index 0000000..6ce49b2 --- /dev/null +++ b/dev.hxml @@ -0,0 +1,6 @@ +tests.hxml +-lib travix +-lib tink_macro +-lib hx3compat +-js whatever.js +--no-output \ No newline at end of file diff --git a/src/tink/macro/Types.hx b/src/tink/macro/Types.hx index 5270477..9306d7c 100644 --- a/src/tink/macro/Types.hx +++ b/src/tink/macro/Types.hx @@ -126,7 +126,8 @@ class Types { static public function isSubTypeOf(t:Type, of:Type, ?pos) return - ECheckType(ECheckType(macro null, toComplex(t)).at(pos), toComplex(of)).at(pos).typeof(); + if (Context.unify(t, of)) ECheckType(ECheckType(macro null, toComplex(t)).at(pos), toComplex(of)).at(pos).typeof(); + else Failure(new Error(t.toString() + ' should be ' + of.toString(), pos.sanitize())); static public function isDynamic(t:Type) return switch reduce(t) { diff --git a/tests/Types.hx b/tests/Types.hx index f373f6c..a0fb67a 100644 --- a/tests/Types.hx +++ b/tests/Types.hx @@ -1,5 +1,6 @@ package ; +#if macro import haxe.macro.Expr; import haxe.macro.Context; @@ -20,6 +21,7 @@ class Types extends Base { assertFalse(o.isSuccess()); function testIs() { + assertSuccess(resolve('Int').isSubTypeOf(resolve('Float'))); assertFailure(resolve('Float').isSubTypeOf(resolve('Int'))); } @@ -41,10 +43,20 @@ class Types extends Base { var bool = type(macro : Bool); assertTrue(blank().isSubTypeOf(bool).isSuccess()); assertTrue(bool.isSubTypeOf(blank()).isSuccess()); - - MacroApi.pos().makeBlankType().toString(); } + #if haxe4 + function testFinal() { + var t = macro : { + final foo:Int; + }; + switch t.toType().sure() { + case TAnonymous(_.get().fields => [f]): assertTrue(f.isFinal); + default: + } + } + #end + function testExpr() { assertEquals('VarChar<255>', (macro : VarChar<255>).toType().sure().toComplex().toString()); } @@ -53,4 +65,5 @@ class Types extends Base { assertEquals('String', Context.getType('String').toComplex().toString()); assertEquals('tink.CoreApi.Noise', Context.getType('tink.CoreApi.Noise').toComplex().toString()); } -} \ No newline at end of file +} +#end \ No newline at end of file