@@ -514,5 +514,41 @@ public void CompatVirtualMethod_Interface ()
514514
515515 Assert . True ( writer . ToString ( ) . NormalizeLineEndings ( ) . Contains ( "catch (Java.Lang.NoSuchMethodError) { throw new Java.Lang.AbstractMethodError (__id); }" . NormalizeLineEndings ( ) ) , $ "was: `{ writer } `") ;
516516 }
517+
518+ [ Test ]
519+ public void FixDefaultInterfaceMethodStackOverflow ( )
520+ {
521+ // The bug was that this causes a stack overflow, but this also tests
522+ // that the OverriddenInterfaceMethod is now correctly set in the interface method.
523+ var xml = """
524+ <api>
525+ <package name='io.grpc' jni-name='io/grpc'>
526+ <interface abstract="true" deprecated="not deprecated" final="false" name="InternalConfigurator" static="false" visibility="public" jni-signature="Lio/grpc/InternalConfigurator;">
527+ <implements name="io.grpc.Configurator" name-generic-aware="io.grpc.Configurator" jni-type="Lio/grpc/Configurator;" />
528+ </interface>
529+ <interface abstract="true" deprecated="not deprecated" final="false" name="Configurator" static="false" visibility="" jni-signature="Lio/grpc/Configurator;">
530+ <method abstract="false" deprecated="not deprecated" final="false" name="configureChannelBuilder" jni-signature="V" bridge="false" native="false" return="void" jni-return="V" static="false" synchronized="false" synthetic="false" visibility="public" />
531+ </interface>
532+ </package>
533+ </api>
534+ """ ;
535+
536+ var gens = ParseApiDefinition ( xml ) ;
537+
538+ foreach ( var iface in gens . OfType < InterfaceGen > ( ) ) {
539+ generator . Context . ContextTypes . Push ( iface ) ;
540+ generator . WriteType ( iface , string . Empty , new GenerationInfo ( "" , "" , "MyAssembly" ) ) ;
541+ generator . Context . ContextTypes . Pop ( ) ;
542+ }
543+
544+ var klass1 = gens . Single ( g => g . Name == "IInternalConfigurator" ) ;
545+ var klass2 = gens . Single ( g => g . Name == "IConfigurator" ) ;
546+
547+ Assert . AreEqual ( 1 , klass1 . Methods . Count ) ;
548+ Assert . AreEqual ( 1 , klass2 . Methods . Count ) ;
549+
550+ Assert . AreNotSame ( klass1 . Methods [ 0 ] , klass2 . Methods [ 0 ] ) ;
551+ Assert . AreSame ( klass1 . Methods [ 0 ] . OverriddenInterfaceMethod , klass2 . Methods [ 0 ] ) ;
552+ }
517553 }
518554}
0 commit comments