Skip to content

Commit

Permalink
Properties that unify with the expected type, if no matches are found…
Browse files Browse the repository at this point in the history
…, should just pass thru. (#14)
  • Loading branch information
skial authored Apr 20, 2021
1 parent 278678d commit b7b7163
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/be/resolve/macros/Resolver.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,10 @@ class Resolver {

}

} else if (signature.unify(module)) {
// Compatible types should just pass thru.
result = e;

} else {
Context.fatalError( NoMatches, e.pos );

Expand Down
1 change: 1 addition & 0 deletions tests/Entry.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Entry {
new resolver.AbsInstancePropertySpec(),
new resolver.AbsStaticPropertySpec(),
new resolver.GenericPropertySpec(),
new PassThrough(),
])).handle( Runner.exit );
}

Expand Down
24 changes: 24 additions & 0 deletions tests/PassThrough.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ;

import be.types.Resolve;

@:asserts
class PassThrough {

public function new() {}

public function test() {
var string = 'hello world';
var singleType:Resolve<String> = string;

asserts.assert( singleType == string );

var method = function (v:String):String return '$v$v';
var funcType:Resolve<String->String> = method;

asserts.assert( funcType(string) == string + string );

return asserts.done();
}

}

0 comments on commit b7b7163

Please sign in to comment.