@@ -147,7 +147,17 @@ protected TResult GetAssociate<TKey1, TKey2, TAssociate, TResult>()
147147 var associate1 = CreateAssociate < TKey1 , TAssociate > ( out var foundFor ) ;
148148 var associate2 = CreateAssociate < TKey2 , TAssociate > ( out foundFor ) ;
149149 // Preferring non-null ;)
150- var associate = associate1 ?? associate2 ?? PreferAssociate < TKey1 , TKey2 , TAssociate > ( associate1 , associate2 ) ;
150+ TAssociate associate = null ;
151+ if ( associate1 == null ) {
152+ associate = associate2 ;
153+ }
154+ else if ( associate2 == null ) {
155+ associate = associate1 ;
156+ }
157+ else {
158+ // Both are non-null; preferring one of two
159+ associate = PreferAssociate < TKey1 , TKey2 , TAssociate > ( associate1 , associate2 ) ;
160+ }
151161 if ( associate == null ) {
152162 // Try to get complex associate (create it manually)
153163 associate = CreateCustomAssociate < TKey1 , TKey2 , TAssociate > ( ) ;
@@ -161,9 +171,9 @@ protected TResult GetAssociate<TKey1, TKey2, TAssociate, TResult>()
161171 }
162172 throw new InvalidOperationException ( string . Format (
163173 Strings . ExCantFindAssociate2 , stringBuilder ,
164- typeof ( TAssociate ) . GetShortName ( ) ,
165- typeof ( TKey1 ) . GetShortName ( ) ,
166- typeof ( TKey2 ) . GetShortName ( ) ) ) ;
174+ typeof ( TAssociate ) . GetShortName ( ) ,
175+ typeof ( TKey1 ) . GetShortName ( ) ,
176+ typeof ( TKey2 ) . GetShortName ( ) ) ) ;
167177 }
168178 }
169179 return ConvertAssociate < TKey1 , TKey2 , TAssociate , TResult > ( associate ) ;
0 commit comments