- edited description
Improper "Illegal assignment" error reported in Apex Editor when calling Iterator methods.
Issue #1817
resolved
It seems like generic types are not propagated in chained method calls to iterators. The bellow apex code deploys and the tests pass on platform, but IC raises an error on line 9. It appears that putting an extra assignment with an explicit Iterator<String>
declaration is a workaround.
Text of the test case from above screenshot:
@IsTest
public with sharing class IteratorGenericsIgnored {
@IsTest
public static void example() {
Set<String> myStrings = new Set<String>();
myStrings.add('a string');
String aString = myStrings.iterator().next();
System.assertEquals('a string', aString);
Iterator<String> iter = myStrings.iterator();
String tryAgain = iter.next();
System.assertEquals('a string', tryAgain);
}
}
Comments (4)
-
reporter -
repo owner Thanks for reporting, Adam. I'll take a look. Sometimes these generics can be tricky. Most of it should be worked out well at this point, but it's not surprising that there might continue to be a corner-case or two.
-
repo owner Fix committed for inclusion in the next build.
-
repo owner - changed status to resolved
Delivered in 2.1.6.1.
- Log in to comment