-
-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fix 2727: class member function type is assigned to a normal func…
…tion type
- Loading branch information
1 parent
382aabe
commit cbe74d6
Showing
4 changed files
with
78 additions
and
14 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
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 @@ | ||
{ | ||
"asc_flags": [], | ||
"stderr": [ | ||
"TS2322: Type '(this: class-member-function-as-parameter/C, i32) => i32' is not assignable to type '(i32) => i32'.", | ||
"TS2322: Type '() => void' is not assignable to type '(this: class-member-function-as-parameter/B) => void'.", | ||
"EOF" | ||
] | ||
} |
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,52 @@ | ||
class C { | ||
aa: i32 = 1; | ||
callback(a: i32): i32 { | ||
return this.aa + a + 3; | ||
} | ||
} | ||
|
||
function expectCallback(c1: (arg0: i32) => i32): i32 { | ||
return c1(4); | ||
} | ||
|
||
export function fut(): i32 { | ||
const c1 = new C(); | ||
return expectCallback(c1.callback); | ||
} | ||
|
||
fut(); | ||
|
||
class A { | ||
foo(): void { | ||
console.log("A"); | ||
} | ||
} | ||
|
||
class B extends A { | ||
foo(): void { | ||
console.log("B"); | ||
} | ||
} | ||
|
||
function foo(): void { | ||
console.log("nothing"); | ||
} | ||
|
||
function consume(callback: (this: B) => void): void { | ||
const b = new B(); | ||
callback.call(b); | ||
} | ||
|
||
export function testNull(): void { | ||
consume(foo); // This should (and does) error; this is fine. | ||
} | ||
|
||
export function testA(): void { | ||
const a = new A(); | ||
consume(a.foo); // This shouldn't error | ||
} | ||
|
||
testNull(); | ||
testA(); | ||
|
||
ERROR("EOF"); |