[GitHub] groovy pull request #645: DefaultGroovyMethods bug fix: Set.intersect(Iterab...
Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/645 ---
[GitHub] groovy pull request #645: DefaultGroovyMethods bug fix: Set.intersect(Iterab...
Github user hlerebours commented on a diff in the pull request: https://github.com/apache/groovy/pull/645#discussion_r158601211 --- Diff: subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/completion/ImportsSyntaxCompletor.groovy --- @@ -105,12 +105,12 @@ class ImportsSyntaxCompletor implements IdentifierCompletor { Class clazz = shell.interp.evaluate([className]) as Class if (clazz != null) { List clazzSymbols = ReflectionCompletor.getPublicFieldsAndMethods(clazz, '')*.value -List importedSymbols; +Collection importedSymbols if (symbolName == '*') { -importedSymbols = clazzSymbols; +importedSymbols = clazzSymbols } else { Set acceptableMatches = [symbolName, symbolName + '(', symbolName + '()'] -importedSymbols = acceptableMatches.intersect(clazzSymbols) +importedSymbols = (acceptableMatches as Collection).intersect(clazzSymbols) --- End diff -- Yes, because intersect() being called on a Set, it returns a Set now, not a List. So without this change, the assignment to importedSymbols throws a ClassCastException. About the cast of the Set to Collection, it was just for the call to intersect() to not be ambiguous, for there were two candidates: intersect(Set, Iterable) and intersect(Collection, Collection), the first one just calling the latter. ---
[GitHub] groovy pull request #645: DefaultGroovyMethods bug fix: Set.intersect(Iterab...
Github user paulk-asert commented on a diff in the pull request: https://github.com/apache/groovy/pull/645#discussion_r158594944 --- Diff: subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/completion/ImportsSyntaxCompletor.groovy --- @@ -105,12 +105,12 @@ class ImportsSyntaxCompletor implements IdentifierCompletor { Class clazz = shell.interp.evaluate([className]) as Class if (clazz != null) { List clazzSymbols = ReflectionCompletor.getPublicFieldsAndMethods(clazz, '')*.value -List importedSymbols; +Collection importedSymbols if (symbolName == '*') { -importedSymbols = clazzSymbols; +importedSymbols = clazzSymbols } else { Set acceptableMatches = [symbolName, symbolName + '(', symbolName + '()'] -importedSymbols = acceptableMatches.intersect(clazzSymbols) +importedSymbols = (acceptableMatches as Collection).intersect(clazzSymbols) --- End diff -- Was changing this file needed? ---
[GitHub] groovy pull request #645: DefaultGroovyMethods bug fix: Set.intersect(Iterab...
GitHub user hlerebours opened a pull request: https://github.com/apache/groovy/pull/645 DefaultGroovyMethods bug fix: Set.intersect(Iterable) throwing if the iterable is bigger than the set You can merge this pull request into a Git repository by running: $ git pull https://github.com/criteo-forks/groovy master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/645.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #645 commit 345d274849d9ab2dc5c85324a5711c6ed921f560 Author: Hugues Lerebours Date: 2017-12-18T19:46:22Z DefaultGroovyMethods: intersect allocates the size of the smallest operand commit 93e738ab388e9f3f6515b030aacd500ad29c79af Author: Hugues Lerebours Date: 2017-12-18T19:48:22Z DefaultGroovyMethods fix: intersect's return type depends on lhs type [Set].intersect([Iterable]) returns a Set, as the signature says it does, instead of throwing a ClassCastException if the Iterable is bigger than the Set ---