1212import  com .oracle .truffle .api .nodes .Node ;
1313import  com .oracle .truffle .api .profiles .ConditionProfile ;
1414import  org .enso .interpreter .runtime .EnsoContext ;
15+ import  org .enso .interpreter .runtime .data .EnsoObject ;
1516import  org .enso .interpreter .runtime .data .hash .EnsoHashMap ;
1617import  org .enso .interpreter .runtime .data .hash .HashMapInsertAllNode ;
1718import  org .enso .interpreter .runtime .data .hash .HashMapInsertNode ;
1819import  org .enso .interpreter .runtime .data .hash .HashMapSizeNode ;
1920import  org .enso .interpreter .runtime .data .vector .ArrayLikeAtNode ;
2021import  org .enso .interpreter .runtime .data .vector .ArrayLikeLengthNode ;
22+ import  org .enso .interpreter .runtime .error .DataflowError ;
2123
2224@ GenerateUncached 
2325public  abstract  class  AppendWarningNode  extends  Node  {
@@ -38,9 +40,9 @@ public static AppendWarningNode getUncached() {
3840   *     It is expected that all the elements in the container are of {@link Warning} class. 
3941   * @return A wrapped object with warnings 
4042   */ 
41-   public  abstract  WithWarnings  executeAppend (VirtualFrame  frame , Object  object , Object  warnings );
43+   public  abstract  EnsoObject  executeAppend (VirtualFrame  frame , Object  object , Object  warnings );
4244
43-   @ Specialization 
45+   @ Specialization ( guards  =  "!isError(object)" ) 
4446  WithWarnings  doSingleWarning (
4547      VirtualFrame  frame ,
4648      Object  object ,
@@ -70,7 +72,7 @@ WithWarnings doSingleWarning(
7072    return  new  WithWarnings (value , warnsLimit , isLimitReached , warnsMap );
7173  }
7274
73-   @ Specialization 
75+   @ Specialization ( guards  =  "!isError(object)" ) 
7476  WithWarnings  doMultipleWarningsArray (
7577      VirtualFrame  frame ,
7678      Object  object ,
@@ -106,7 +108,7 @@ WithWarnings doMultipleWarningsArray(
106108   * This specialization should be the most frequent - just wrapping the given {@code object} with 
107109   * warnings hash map 
108110   */ 
109-   @ Specialization (guards  = {"!isWithWarns(object)" })
111+   @ Specialization (guards  = {"!isError(object)"  ,  "! isWithWarns(object)" })
110112  WithWarnings  doObjectMultipleWarningsHashMap (
111113      VirtualFrame  frame ,
112114      Object  object ,
@@ -138,7 +140,8 @@ WithWarnings doWithWarnMultipleWarningsHashMap(
138140    return  new  WithWarnings (withWarnings .value , withWarnings .maxWarnings , isLimitReached , warnsMap );
139141  }
140142
141-   @ Specialization (guards  = {"interop.hasArrayElements(warnings)" , "!isWarnArray(warnings)" })
143+   @ Specialization (
144+       guards  = {"interop.hasArrayElements(warnings)" , "!isError(object)" , "!isWarnArray(warnings)" })
142145  WithWarnings  doMultipleWarningsInterop (
143146      VirtualFrame  frame ,
144147      Object  object ,
@@ -171,6 +174,11 @@ WithWarnings doMultipleWarningsInterop(
171174    return  new  WithWarnings (value , warnsLimit , isLimitReached , resWarningMap );
172175  }
173176
177+   @ Specialization (guards  = "isError(object)" )
178+   EnsoObject  dontAnnotateError (Object  object , Object  ignoreWarnings ) {
179+     return  (EnsoObject ) object ;
180+   }
181+ 
174182  /** Inserts all {@code warnings} to the {@code initialWarningMap}. */ 
175183  private  EnsoHashMap  insertToWarningMap (
176184      VirtualFrame  frame ,
@@ -199,11 +207,15 @@ private EnsoHashMap insertToWarningMap(
199207    return  resWarningMap ;
200208  }
201209
202-   protected   static  boolean  isWarnArray (Object  obj ) {
210+   static  boolean  isWarnArray (Object  obj ) {
203211    return  obj  instanceof  Warning [];
204212  }
205213
206-   protected   static  boolean  isWithWarns (Object  obj ) {
214+   static  boolean  isWithWarns (Object  obj ) {
207215    return  obj  instanceof  WithWarnings ;
208216  }
217+ 
218+   static  boolean  isError (Object  obj ) {
219+     return  obj  instanceof  DataflowError ;
220+   }
209221}
0 commit comments