KT-24156 Do not optimize for-loops over Strings with custom iterator

'fun CharSequence.iterator()' is an extension function, so one can
overload it with custom implementation.
Other "predefined" containers such as arrays and ranges have member
'fun iterator()', so these containers are not affected.

Check that 'iterator' call corresponds to an extension function
'iterator' defined in package 'kotlin.text' with a receiver of type
'kotlin.CharSequence'.

 #KT-24156 Fixed
This commit is contained in:
Dmitry Petrov
2018-05-10 15:40:55 +03:00
parent f568149863
commit c22dfeaf82
6 changed files with 54 additions and 3 deletions
@@ -15480,6 +15480,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/ranges/forInStringVarUpdatedInLoopBody.kt");
}
@TestMetadata("forInStringWithCustomIterator.kt")
public void testForInStringWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInStringWithCustomIterator.kt");
}
@TestMetadata("forIntRange.kt")
public void testForIntRange() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forIntRange.kt");