Skip to content

Commit

Permalink
Refine format according to code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Changqing-JING committed Aug 2, 2023
1 parent 75e3d5e commit b386305
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6610,8 +6610,8 @@ export class Compiler extends DiagnosticEmitter {
let overrideInstance = overrideInstances[i];
if (!overrideInstance.is(CommonFlags.Compiled)) continue; // errored

const overrideSignature = overrideInstance.signature;
const originalSignature = instance.signature;
let overrideSignature = overrideInstance.signature;
let originalSignature = instance.signature;

if (!overrideSignature.isAssignableTo(originalSignature, true)) {
this.error(
Expand Down
7 changes: 3 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1053,11 +1053,10 @@ export class Signature {
let targetThisType = target.thisType;

if (thisThisType != null && targetThisType != null){
const compatibleThisType = checkCompatibleOverride ? thisThisType.canExtendOrImplement(targetThisType)
const compatibleThisType = checkCompatibleOverride
? thisThisType.canExtendOrImplement(targetThisType)
: targetThisType.isAssignableTo(thisThisType);
if (!compatibleThisType) {
return false;
}
if (!compatibleThisType) return false;
}else if (thisThisType || targetThisType){
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/compiler/class-member-function-as-parameter.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
class A {
foo(): void { }
}

class B extends A {
foo(): void { }
}

function foo(): void { }

function consumeA(callback: (this: A) => void): void { }
function consumeB(callback: (this: B) => void): void { }

const a = new A();
const b = new B();

consumeB(a.foo); // shouldn't error
consumeA(foo); // should error
consumeA(b.foo); // should error
Expand Down

0 comments on commit b386305

Please sign in to comment.