Procházet zdrojové kódy

[js] use direct casts for PromiseHandler, but specify the order properly

Dan Korostelev před 6 roky
rodič
revize
86b9b5b59d
1 změnil soubory, kde provedl 3 přidání a 5 odebrání
  1. 3 5
      std/js/Promise.hx

+ 3 - 5
std/js/Promise.hx

@@ -94,11 +94,9 @@ extern class Promise<T>
 	Handler type for the Promise object.
 **/
 abstract PromiseHandler<T,TOut>(T->Dynamic) // T->Dynamic, so the compiler always knows the type of the argument and can infer it for then/catch callbacks
-	from T->Promise<TOut> // direct casts have priority, so we use that to prioritize the Promise<TOut> return type
-{
-	// function casts are checked after direct ones, so we place T->TOut here to make it have lower priority than T->Promise<TOut>
-	@:from static inline function fromNonPromise<T,TOut>(f:T->TOut):PromiseHandler<T,TOut> return cast f;
-}
+	from T->TOut // order is important, because Promise<TOut> return must have priority 
+	from T->Promise<TOut> // although the checking order seems to be reversed at the moment, see https://github.com/HaxeFoundation/haxe/issues/7656
+{}
 
 /**
 	A value with a `then` method.