@@ -24,10 +24,12 @@ public void AddNewConnectionBetween(Connection source, Connection destination)
2424 Graph . Connect ( source , destination , false ) ;
2525
2626 // we're plugging something something with a generic into something without a generic
27- if ( source . IsAssignableTo ( destination , true , true , out var newTypes , out var usedInitialTypes ) && newTypes . Count != 0 )
27+ if ( source . IsAssignableTo ( destination , true , true , out var newTypesLeft , out var newTypesRight , out var usedInitialTypes ) )
2828 {
29- PropagateNewGeneric ( source . Parent , newTypes , usedInitialTypes , destination , false ) ;
30- PropagateNewGeneric ( destination . Parent , newTypes , usedInitialTypes , source , false ) ;
29+ if ( newTypesLeft . Count != 0 )
30+ PropagateNewGeneric ( source . Parent , newTypesLeft , usedInitialTypes , destination , false ) ;
31+ if ( newTypesRight . Count != 0 )
32+ PropagateNewGeneric ( destination . Parent , newTypesRight , usedInitialTypes , source , false ) ;
3133 }
3234
3335 GraphCanvas . UpdatePortColor ( source ) ;
@@ -55,7 +57,7 @@ public void DisconnectConnectionBetween(Connection source, Connection destinatio
5557 /// Propagate the new generic type to all the connections of the node and recursively to the connected nodes.
5658 /// </summary>
5759 /// <param name="initiatingConnection">The connection that initiated the propagation. This is used to avoid reupdating back and forth, sometimes erasing information in the process.</param>
58- public void PropagateNewGeneric ( Node node , IReadOnlyDictionary < UndefinedGenericType , TypeBase > changedGenerics , bool useInitialTypes , Connection ? initiatingConnection , bool overrideInitialTypes )
60+ public void PropagateNewGeneric ( Node node , IReadOnlyDictionary < string , TypeBase > changedGenerics , bool useInitialTypes , Connection ? initiatingConnection , bool overrideInitialTypes )
5961 {
6062 bool hadAnyChanges = false ;
6163 foreach ( var port in node . InputsAndOutputs ) // check if any of the ports have the generic we just solved
@@ -74,14 +76,19 @@ public void PropagateNewGeneric(Node node, IReadOnlyDictionary<UndefinedGenericT
7476 // check if other connections had their own generics and if we just solved them
7577 foreach ( var other in port . Connections . ToList ( ) )
7678 {
77- if ( other == initiatingConnection )
79+ if ( other == initiatingConnection )
7880 continue ;
7981
8082 var source = isPortInput ? other : port ;
8183 var target = isPortInput ? port : other ;
82- if ( source . IsAssignableTo ( target , isPortInput , ! isPortInput , out var changedGenerics2 , out var usedInitialTypes ) && changedGenerics2 . Count != 0 )
83- PropagateNewGeneric ( other . Parent , changedGenerics2 , usedInitialTypes , port , false ) ;
84- else if ( ( changedGenerics2 ? . Count ?? 0 ) != 0 ) // looks like changing the generic made it so we can't link to this connection anymore
84+ if ( source . IsAssignableTo ( target , isPortInput , ! isPortInput , out var changedGenericsLeft2 , out var changedGenericsRight2 , out var usedInitialTypes ) && ( changedGenericsLeft2 . Count != 0 || changedGenericsRight2 . Count != 0 ) )
85+ {
86+ if ( changedGenericsLeft2 . Count != 0 )
87+ PropagateNewGeneric ( port . Parent , changedGenericsLeft2 , usedInitialTypes , other , false ) ;
88+ if ( changedGenericsRight2 . Count != 0 )
89+ PropagateNewGeneric ( other . Parent , changedGenericsRight2 , usedInitialTypes , port , false ) ;
90+ }
91+ else if ( ( changedGenericsLeft2 ? . Count ?? 0 ) != 0 ) // looks like changing the generic made it so we can't link to this connection anymore
8592 DisconnectConnectionBetween ( port , other ) ;
8693 }
8794 }
0 commit comments