@@ -241,7 +241,7 @@ private void BuildCode(CodeContext parentCtx)
241241 || tempVariableInit
242242 || hasOnCreatedStatements )
243243 {
244- lines . Append ( $ "{ buildTools . GetDeclaration ( ctx , var . Declaration ) } { tempVar . Name } = ") ;
244+ lines . Append ( $ "{ buildTools . GetDeclaration ( ctx , var . Declaration , useVar : true ) } { tempVar . Name } = ") ;
245245 lines . Append ( instantiation ) ;
246246 lines . AppendLine ( ";" ) ;
247247 }
@@ -405,7 +405,7 @@ private void BuildCode(CodeContext parentCtx)
405405
406406 if ( ! var . Declaration . IsDeclared && ( var . HasCycle ?? false ) )
407407 {
408- lines . AppendLine ( $ "var { var . Name } = default({ buildTools . GetDeclaration ( ctx , var . Declaration , "" ) } );") ;
408+ lines . AppendLine ( $ "var { var . Name } = default({ typeResolver . Resolve ( ctx . RootContext . Graph . Source , var . InstanceType ) } );") ;
409409 var . Declaration . IsDeclared = true ;
410410 }
411411
@@ -635,7 +635,7 @@ private void BuildCode(CodeContext parentCtx)
635635 }
636636
637637 lines . AppendLine ( ) ;
638- lines . AppendLine ( $ "{ buildTools . GetDeclaration ( ctx , var . Declaration ) } { var . Name } = { localMethodName } ();") ;
638+ lines . AppendLine ( $ "{ buildTools . GetDeclaration ( ctx , var . Declaration , useVar : true ) } { var . Name } = { localMethodName } ();") ;
639639 lines . AppendLines ( buildTools . OnCreated ( ctx , varInjection ) ) ;
640640 break ;
641641
@@ -655,7 +655,7 @@ private void BuildCode(CodeContext parentCtx)
655655 var onCreated = buildTools . OnCreated ( ctx , varInjection ) . ToList ( ) ;
656656 if ( onCreated . Count > 0 )
657657 {
658- lines . AppendLine ( $ "{ buildTools . GetDeclaration ( ctx , var . Declaration ) } { var . Name } = { instantiation } ;") ;
658+ lines . AppendLine ( $ "{ buildTools . GetDeclaration ( ctx , var . Declaration , useVar : true ) } { var . Name } = { instantiation } ;") ;
659659 lines . AppendLines ( onCreated ) ;
660660 }
661661 else
@@ -688,11 +688,11 @@ private void BuildCode(CodeContext parentCtx)
688688 break ;
689689
690690 case MdConstructKind . Composition :
691- lines . AppendLine ( $ "{ buildTools . GetDeclaration ( ctx , var . Declaration ) } { var . Name } = this;") ;
691+ lines . AppendLine ( $ "{ buildTools . GetDeclaration ( ctx , var . Declaration , useVar : true ) } { var . Name } = this;") ;
692692 break ;
693693
694694 case MdConstructKind . OnCannotResolve :
695- lines . AppendLine ( $ "{ buildTools . GetDeclaration ( ctx , var . Declaration ) } { var . Name } = { Names . OnCannotResolve } <{ varInjection . ContractType } >({ varInjection . Injection . Tag . ValueToString ( ) } , { var . AbstractNode . Lifetime . ValueToString ( ) } );") ;
695+ lines . AppendLine ( $ "{ buildTools . GetDeclaration ( ctx , var . Declaration , useVar : true ) } { var . Name } = { Names . OnCannotResolve } <{ varInjection . ContractType } >({ varInjection . Injection . Tag . ValueToString ( ) } , { var . AbstractNode . Lifetime . ValueToString ( ) } );") ;
696696 break ;
697697
698698 case MdConstructKind . ExplicitDefaultValue :
@@ -962,7 +962,7 @@ private void BuildAccumulators(CodeContext ctx)
962962 continue ;
963963 }
964964
965- ctx . Lines . AppendLine ( $ "{ buildTools . GetDeclaration ( ctx , accVar . Declaration ) } { accVar . Name } = new { accVar . InstanceType } ();") ;
965+ ctx . Lines . AppendLine ( $ "{ buildTools . GetDeclaration ( ctx , accVar . Declaration , useVar : true ) } { accVar . Name } = new { accVar . InstanceType } ();") ;
966966 accVar . Declaration . IsDeclared = true ;
967967 accVar . IsCreated = true ;
968968 }
0 commit comments