Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41017 from weswigham/fix-unchecked-cast-crash
Fix crash due to unchecked cast in addImplementationSuccessElaboration
- Loading branch information
Showing
6 changed files
with
134 additions
and
1 deletion.
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
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/namespaceMergedWithFunctionWithOverloadsUsage.errors.txt
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,28 @@ | ||
tests/cases/compiler/index.ts(3,3): error TS2769: No overload matches this call. | ||
Overload 1 of 2, '(opts?: Whatever): void', gave the following error. | ||
Argument of type 'number' is not assignable to parameter of type 'Whatever'. | ||
Overload 2 of 2, '(cb: Function, opts?: Whatever): void', gave the following error. | ||
Argument of type 'number' is not assignable to parameter of type 'Function'. | ||
|
||
|
||
==== tests/cases/compiler/index.ts (1 errors) ==== | ||
import X = require("./file"); | ||
|
||
X(0); // shouldn't cause a crash | ||
~ | ||
!!! error TS2769: No overload matches this call. | ||
!!! error TS2769: Overload 1 of 2, '(opts?: Whatever): void', gave the following error. | ||
!!! error TS2769: Argument of type 'number' is not assignable to parameter of type 'Whatever'. | ||
!!! error TS2769: Overload 2 of 2, '(cb: Function, opts?: Whatever): void', gave the following error. | ||
!!! error TS2769: Argument of type 'number' is not assignable to parameter of type 'Function'. | ||
==== tests/cases/compiler/file.d.ts (0 errors) ==== | ||
declare namespace Foo { | ||
interface Whatever { | ||
prop: any; | ||
} | ||
} | ||
|
||
declare function Foo(opts?: Foo.Whatever): void; | ||
declare function Foo(cb: Function, opts?: Foo.Whatever): void; | ||
|
||
export = Foo; |
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/namespaceMergedWithFunctionWithOverloadsUsage.js
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,23 @@ | ||
//// [tests/cases/compiler/namespaceMergedWithFunctionWithOverloadsUsage.ts] //// | ||
|
||
//// [file.d.ts] | ||
declare namespace Foo { | ||
interface Whatever { | ||
prop: any; | ||
} | ||
} | ||
|
||
declare function Foo(opts?: Foo.Whatever): void; | ||
declare function Foo(cb: Function, opts?: Foo.Whatever): void; | ||
|
||
export = Foo; | ||
//// [index.ts] | ||
import X = require("./file"); | ||
|
||
X(0); // shouldn't cause a crash | ||
|
||
//// [index.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var X = require("./file"); | ||
X(0); // shouldn't cause a crash |
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/namespaceMergedWithFunctionWithOverloadsUsage.symbols
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,36 @@ | ||
=== tests/cases/compiler/index.ts === | ||
import X = require("./file"); | ||
>X : Symbol(X, Decl(index.ts, 0, 0)) | ||
|
||
X(0); // shouldn't cause a crash | ||
>X : Symbol(X, Decl(index.ts, 0, 0)) | ||
|
||
=== tests/cases/compiler/file.d.ts === | ||
declare namespace Foo { | ||
>Foo : Symbol(Foo, Decl(file.d.ts, 4, 1), Decl(file.d.ts, 6, 48), Decl(file.d.ts, 0, 0)) | ||
|
||
interface Whatever { | ||
>Whatever : Symbol(Whatever, Decl(file.d.ts, 0, 23)) | ||
|
||
prop: any; | ||
>prop : Symbol(Whatever.prop, Decl(file.d.ts, 1, 24)) | ||
} | ||
} | ||
|
||
declare function Foo(opts?: Foo.Whatever): void; | ||
>Foo : Symbol(Foo, Decl(file.d.ts, 4, 1), Decl(file.d.ts, 6, 48), Decl(file.d.ts, 0, 0)) | ||
>opts : Symbol(opts, Decl(file.d.ts, 6, 21)) | ||
>Foo : Symbol(Foo, Decl(file.d.ts, 4, 1), Decl(file.d.ts, 6, 48), Decl(file.d.ts, 0, 0)) | ||
>Whatever : Symbol(Foo.Whatever, Decl(file.d.ts, 0, 23)) | ||
|
||
declare function Foo(cb: Function, opts?: Foo.Whatever): void; | ||
>Foo : Symbol(Foo, Decl(file.d.ts, 4, 1), Decl(file.d.ts, 6, 48), Decl(file.d.ts, 0, 0)) | ||
>cb : Symbol(cb, Decl(file.d.ts, 7, 21)) | ||
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>opts : Symbol(opts, Decl(file.d.ts, 7, 34)) | ||
>Foo : Symbol(Foo, Decl(file.d.ts, 4, 1), Decl(file.d.ts, 6, 48), Decl(file.d.ts, 0, 0)) | ||
>Whatever : Symbol(Foo.Whatever, Decl(file.d.ts, 0, 23)) | ||
|
||
export = Foo; | ||
>Foo : Symbol(Foo, Decl(file.d.ts, 4, 1), Decl(file.d.ts, 6, 48), Decl(file.d.ts, 0, 0)) | ||
|
31 changes: 31 additions & 0 deletions
31
tests/baselines/reference/namespaceMergedWithFunctionWithOverloadsUsage.types
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,31 @@ | ||
=== tests/cases/compiler/index.ts === | ||
import X = require("./file"); | ||
>X : { (opts?: X.Whatever): void; (cb: Function, opts?: X.Whatever): void; } | ||
|
||
X(0); // shouldn't cause a crash | ||
>X(0) : void | ||
>X : { (opts?: X.Whatever): void; (cb: Function, opts?: X.Whatever): void; } | ||
>0 : 0 | ||
|
||
=== tests/cases/compiler/file.d.ts === | ||
declare namespace Foo { | ||
interface Whatever { | ||
prop: any; | ||
>prop : any | ||
} | ||
} | ||
|
||
declare function Foo(opts?: Foo.Whatever): void; | ||
>Foo : { (opts?: Foo.Whatever): void; (cb: Function, opts?: Foo.Whatever): void; } | ||
>opts : Foo.Whatever | ||
>Foo : any | ||
|
||
declare function Foo(cb: Function, opts?: Foo.Whatever): void; | ||
>Foo : { (opts?: Foo.Whatever): void; (cb: Function, opts?: Foo.Whatever): void; } | ||
>cb : Function | ||
>opts : Foo.Whatever | ||
>Foo : any | ||
|
||
export = Foo; | ||
>Foo : { (opts?: Foo.Whatever): void; (cb: Function, opts?: Foo.Whatever): void; } | ||
|
15 changes: 15 additions & 0 deletions
15
tests/cases/compiler/namespaceMergedWithFunctionWithOverloadsUsage.ts
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,15 @@ | ||
// @filename: file.d.ts | ||
declare namespace Foo { | ||
interface Whatever { | ||
prop: any; | ||
} | ||
} | ||
|
||
declare function Foo(opts?: Foo.Whatever): void; | ||
declare function Foo(cb: Function, opts?: Foo.Whatever): void; | ||
|
||
export = Foo; | ||
// @filename: index.ts | ||
import X = require("./file"); | ||
|
||
X(0); // shouldn't cause a crash |