-
-
Notifications
You must be signed in to change notification settings - Fork 661
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[js] fix type inference for Promise callback arguments (closes #6790)
- Loading branch information
Showing
7 changed files
with
99 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import js.Promise; | ||
|
||
class Main { | ||
static function main() { | ||
var p = new Promise<String>(null); | ||
|
||
$type(p.then(function(x) $type(x))); | ||
$type(p.then(function(x) $type(x), function(e) $type(e))); | ||
|
||
$type(p.then(function(x) {$type(x); return 1;})); | ||
$type(p.then(function(x) {$type(x); return Promise.resolve(1);})); | ||
|
||
$type(p.then(null,function(x) {$type(x); return 1;})); | ||
$type(p.then(null,function(x) {$type(x); return Promise.resolve(1);})); | ||
|
||
$type(p.then(function(x) {$type(x); return 1;}, function(e) {$type(e); return 1;})); | ||
$type(p.then(function(x) {$type(x); return Promise.resolve(1);}, function(e) {$type(e); return 1;})); | ||
$type(p.then(function(x) {$type(x); return 1;}, function(e) {$type(e); return Promise.resolve(1);})); | ||
$type(p.then(function(x) {$type(x); return Promise.resolve(1);}, function(e) {$type(e); return Promise.resolve(1);})); | ||
|
||
$type(p.catchError(function(x) {$type(x);})); | ||
$type(p.catchError(function(x) {$type(x); return Promise.resolve(1);})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import js.Promise; | ||
|
||
class Mismatch { | ||
static function main() { | ||
var p = new Promise<String>(null); | ||
p.then(x -> 10, e -> ""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-main Mismatch | ||
-js whatever.js | ||
--no-output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Mismatch.hx:6: characters 19-26 : (e : Unknown<0>) -> String should be Null<js.PromiseHandler<Dynamic, Int>> | ||
Mismatch.hx:6: characters 19-26 : For optional function argument 'rejectCallback' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-main Main | ||
-js whatever.js | ||
--no-output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Main.hx:7: characters 34-35 : Warning : String | ||
Main.hx:7: characters 9-37 : Warning : js.Promise<Void> | ||
Main.hx:8: characters 34-35 : Warning : String | ||
Main.hx:8: characters 56-57 : Warning : Unknown<0> | ||
Main.hx:8: characters 9-59 : Warning : js.Promise<Void> | ||
Main.hx:10: characters 35-36 : Warning : String | ||
Main.hx:10: characters 9-50 : Warning : js.Promise<Int> | ||
Main.hx:11: characters 35-36 : Warning : String | ||
Main.hx:11: characters 9-67 : Warning : js.Promise<Int> | ||
Main.hx:13: characters 40-41 : Warning : Unknown<0> | ||
Main.hx:13: characters 9-55 : Warning : js.Promise<Int> | ||
Main.hx:14: characters 40-41 : Warning : Unknown<0> | ||
Main.hx:14: characters 9-72 : Warning : js.Promise<Int> | ||
Main.hx:16: characters 35-36 : Warning : String | ||
Main.hx:16: characters 70-71 : Warning : Unknown<0> | ||
Main.hx:16: characters 9-85 : Warning : js.Promise<Int> | ||
Main.hx:17: characters 35-36 : Warning : String | ||
Main.hx:17: characters 87-88 : Warning : Unknown<0> | ||
Main.hx:17: characters 9-102 : Warning : js.Promise<Int> | ||
Main.hx:18: characters 35-36 : Warning : String | ||
Main.hx:18: characters 70-71 : Warning : Unknown<0> | ||
Main.hx:18: characters 9-102 : Warning : js.Promise<Int> | ||
Main.hx:19: characters 35-36 : Warning : String | ||
Main.hx:19: characters 87-88 : Warning : Unknown<0> | ||
Main.hx:19: characters 9-119 : Warning : js.Promise<Int> | ||
Main.hx:21: characters 41-42 : Warning : Unknown<0> | ||
Main.hx:21: characters 9-46 : Warning : js.Promise<Void> | ||
Main.hx:22: characters 41-42 : Warning : Unknown<0> | ||
Main.hx:22: characters 9-73 : Warning : js.Promise<Int> |