File tree 1 file changed +23
-2
lines changed
1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 6
6
import {
7
7
Class ,
8
8
Program ,
9
- DecoratorFlags
9
+ DecoratorFlags ,
10
+ ElementKind
10
11
} from "./program" ;
11
12
12
13
import {
@@ -475,6 +476,26 @@ export class Type {
475
476
return false ;
476
477
}
477
478
479
+ /** Tests if a value of this class is compatible to the target class / interface in the multi extends / implements situation. */
480
+ isInheritCompatibleTo ( target : Type | null ) : bool {
481
+ if ( target ) {
482
+ if ( this . isInternalReference && target . isInternalReference && this . isManaged && target . isManaged ) {
483
+ let thisClass = this . getClass ( ) ;
484
+ let targetClass = target . getClass ( ) ;
485
+ if ( thisClass && targetClass ) {
486
+ // extends ThisClass implements TargetInterface
487
+ // implements ThisInterface, TargetInterface
488
+ if ( thisClass . kind == ElementKind . CLASS || thisClass . kind == ElementKind . INTERFACE ) {
489
+ if ( targetClass . kind == ElementKind . INTERFACE ) {
490
+ return true ;
491
+ }
492
+ }
493
+ }
494
+ }
495
+ }
496
+ return false ;
497
+ }
498
+
478
499
/** Tests if a value of this type is assignable to the target type excl. implicit conversion. */
479
500
isStrictlyAssignableTo ( target : Type , signednessIsRelevant : bool = false ) : bool {
480
501
if ( this . isReference ) return this . isAssignableTo ( target ) ;
@@ -941,7 +962,7 @@ export class Signature {
941
962
} else {
942
963
// check kind of `this` type
943
964
if ( thisThisType ) {
944
- if ( ! targetThisType || thisThisType . kind != targetThisType . kind || thisThisType . isReference != targetThisType . isReference ) {
965
+ if ( ! thisThisType . isInheritCompatibleTo ( targetThisType ) ) {
945
966
return false ;
946
967
}
947
968
} else if ( targetThisType ) {
You can’t perform that action at this time.
0 commit comments