@@ -3063,7 +3063,14 @@ export class Resolver extends DiagnosticEmitter {
30633063 let boundPrototype = classInstance . getMember ( unboundOverridePrototype . name ) ;
30643064 if ( boundPrototype ) { // might have errored earlier and wasn't added
30653065 assert ( boundPrototype . kind == ElementKind . FunctionPrototype ) ;
3066- overrideInstance = this . resolveFunction ( < FunctionPrototype > boundPrototype , instance . typeArguments ) ;
3066+ let boundFuncPrototype = < FunctionPrototype > boundPrototype ;
3067+ let overrideTypeParams = boundFuncPrototype . typeParameterNodes ;
3068+ let numOverrideTypeParams = overrideTypeParams ? overrideTypeParams . length : 0 ;
3069+ let baseTypeArgs = instance . typeArguments ;
3070+ let numBaseTypeArgs = baseTypeArgs ? baseTypeArgs . length : 0 ;
3071+ if ( numOverrideTypeParams == numBaseTypeArgs ) {
3072+ overrideInstance = this . resolveFunction ( boundFuncPrototype , baseTypeArgs ) ;
3073+ }
30673074 }
30683075 }
30693076 if ( overrideInstance ) overrides . add ( overrideInstance ) ;
@@ -3439,6 +3446,20 @@ export class Resolver extends DiagnosticEmitter {
34393446 default : assert ( false ) ;
34403447 }
34413448 if ( ! member . is ( CommonFlags . Abstract ) ) {
3449+ // A generic method cannot implement a non-generic interface method
3450+ // because monomorphization requires a concrete type to generate code,
3451+ // but virtual dispatch through the interface has no type arguments.
3452+ let ifaceMember = unimplemented . get ( memberName ) ;
3453+ if ( ifaceMember
3454+ && member . kind == ElementKind . FunctionPrototype
3455+ && ifaceMember . kind == ElementKind . FunctionPrototype
3456+ ) {
3457+ let memberTypeParams = ( < FunctionPrototype > member ) . typeParameterNodes ;
3458+ let ifaceTypeParams = ( < FunctionPrototype > ifaceMember ) . typeParameterNodes ;
3459+ let numMemberTypeParams = memberTypeParams ? memberTypeParams . length : 0 ;
3460+ let numIfaceTypeParams = ifaceTypeParams ? ifaceTypeParams . length : 0 ;
3461+ if ( numMemberTypeParams != numIfaceTypeParams ) continue ;
3462+ }
34423463 unimplemented . delete ( memberName ) ;
34433464 }
34443465 }
0 commit comments