@@ -273,12 +273,10 @@ public Collection<? extends Snippet> createStatements(final Context context) {
273273 // for of
274274 res .add (createStatement (context , "for-of" , "for (let v of {1});" ,
275275 TypeDescriptor .NULL ,
276- JavaScriptVerifier .foreignOrHasIteratorVerifier (context , null ),
277- TypeDescriptor .union (
278- TypeDescriptor .STRING ,
279- TypeDescriptor .ARRAY ,
280- TypeDescriptor .ITERABLE ,
281- TypeDescriptor .HASH )));
276+ JavaScriptVerifier .hasIteratorVerifier (null ),
277+ TypeDescriptor .ANY ));
278+ // Using ANY because of GR-30278. Should be: union(STRING, ARRAY, ITERABLE, HASH).
279+
282280 // with
283281 res .add (createStatement (context , "with" , "with({1}) undefined" ,
284282 TypeDescriptor .NULL ,
@@ -538,22 +536,21 @@ public void accept(SnippetRun snippetRun) throws PolyglotException {
538536 }
539537
540538 /**
541- * Creates a {@link ResultVerifier} ignoring errors caused by missing iterator method . Use
542- * this verifier in case the operator accepts arbitrary foreign Objects for iteration but
543- * requires iterator for JSObject .
539+ * Creates a {@link ResultVerifier} ignoring errors caused by non-iterable objects . Use this
540+ * verifier in case the operator formally accepts arbitrary types but requires objects to
541+ * provide an {@link Value#hasIterator() iterator} .
544542 *
545543 * @param next the next {@link ResultVerifier} to be called, null for last one
544+ *
546545 * @return the {@link ResultVerifier}
547546 */
548- static ResultVerifier foreignOrHasIteratorVerifier ( final Context context , ResultVerifier next ) {
547+ static ResultVerifier hasIteratorVerifier ( ResultVerifier next ) {
549548 return new JavaScriptVerifier (next ) {
550549 @ Override
551550 public void accept (SnippetRun snippetRun ) throws PolyglotException {
552551 if (snippetRun .getException () != null ) {
553552 final Value param = snippetRun .getParameters ().get (0 );
554- final boolean jsObject = context .eval (ID , "Object" ).isMetaInstance (param );
555- boolean hasIterator = param .hasIterator ();
556- if (jsObject && !hasIterator ) {
553+ if (!param .hasIterator () && !param .hasArrayElements () && !param .hasHashEntries () && !param .isString ()) {
557554 // Expected for not iterable
558555 return ;
559556 }
0 commit comments