@@ -713,9 +713,14 @@ export class Resolver extends DiagnosticEmitter {
713
713
contextualTypeArguments : Map < string , Type > | null = null ,
714
714
reportMode : ReportMode = ReportMode . REPORT
715
715
) : Function | null {
716
+ var classTypeArguments = prototype . classTypeArguments ;
717
+ var classInstanceKey = classTypeArguments ? typesToString ( classTypeArguments ) : "" ;
716
718
var instanceKey = typeArguments ? typesToString ( typeArguments ) : "" ;
717
- var instance = prototype . instances . get ( instanceKey ) ;
718
- if ( instance ) return instance ;
719
+ var classInstances = prototype . instances . get ( classInstanceKey ) ;
720
+ if ( classInstances ) {
721
+ let instance = classInstances . get ( instanceKey ) ;
722
+ if ( instance ) return instance ;
723
+ }
719
724
720
725
var declaration = prototype . declaration ;
721
726
var isInstance = prototype . is ( CommonFlags . INSTANCE ) ;
@@ -734,7 +739,6 @@ export class Resolver extends DiagnosticEmitter {
734
739
}
735
740
736
741
// override with class type arguments if a partially resolved instance method
737
- var classTypeArguments = prototype . classTypeArguments ;
738
742
if ( classTypeArguments ) { // set only if partially resolved
739
743
assert ( prototype . is ( CommonFlags . INSTANCE ) ) ;
740
744
let classDeclaration = assert ( classPrototype ) . declaration ;
@@ -818,7 +822,7 @@ export class Resolver extends DiagnosticEmitter {
818
822
819
823
var internalName = prototype . internalName ;
820
824
if ( instanceKey . length ) internalName += "<" + instanceKey + ">" ;
821
- instance = new Function (
825
+ var instance = new Function (
822
826
prototype ,
823
827
internalName ,
824
828
signature ,
@@ -827,7 +831,8 @@ export class Resolver extends DiagnosticEmitter {
827
831
: classPrototype ,
828
832
contextualTypeArguments
829
833
) ;
830
- prototype . instances . set ( instanceKey , instance ) ;
834
+ if ( ! classInstances ) prototype . instances . set ( classInstanceKey , classInstances = new Map ( ) ) ;
835
+ classInstances . set ( instanceKey , instance ) ;
831
836
this . program . instancesLookup . set ( internalName , instance ) ;
832
837
return instance ;
833
838
}
@@ -856,6 +861,7 @@ export class Resolver extends DiagnosticEmitter {
856
861
partialPrototype . flags = prototype . flags ;
857
862
partialPrototype . operatorKind = prototype . operatorKind ;
858
863
partialPrototype . classTypeArguments = typeArguments ;
864
+ partialPrototype . instances = prototype . instances ;
859
865
return partialPrototype ;
860
866
}
861
867
0 commit comments