Return-Path: X-Original-To: apmail-groovy-commits-archive@minotaur.apache.org Delivered-To: apmail-groovy-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7445D1873F for ; Tue, 5 Jan 2016 03:14:00 +0000 (UTC) Received: (qmail 21441 invoked by uid 500); 5 Jan 2016 03:14:00 -0000 Delivered-To: apmail-groovy-commits-archive@groovy.apache.org Received: (qmail 21408 invoked by uid 500); 5 Jan 2016 03:14:00 -0000 Mailing-List: contact commits-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list commits@groovy.apache.org Received: (qmail 21399 invoked by uid 99); 5 Jan 2016 03:14:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jan 2016 03:14:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 176EDE07EE; Tue, 5 Jan 2016 03:14:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: paulk@apache.org To: commits@groovy.apache.org Message-Id: <2c9a86fbb0134463aa122e61a3d0fe48@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: groovy git commit: GROOVY-6835: flow typing activated by if statement doing an "instanceof" check doesn't work as expected with interface types (test only) Date: Tue, 5 Jan 2016 03:14:00 +0000 (UTC) Repository: groovy Updated Branches: refs/heads/GROOVY_2_4_X f5cc12d6e -> d04c3ad95 GROOVY-6835: flow typing activated by if statement doing an "instanceof" check doesn't work as expected with interface types (test only) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/d04c3ad9 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d04c3ad9 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d04c3ad9 Branch: refs/heads/GROOVY_2_4_X Commit: d04c3ad955bd109aefe758a3d67b817d8e5c4c95 Parents: f5cc12d Author: paulk Authored: Tue Jan 5 13:12:22 2016 +1000 Committer: paulk Committed: Tue Jan 5 13:13:41 2016 +1000 ---------------------------------------------------------------------- .../transform/stc/TypeInferenceSTCTest.groovy | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/d04c3ad9/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy ---------------------------------------------------------------------- diff --git a/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy b/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy index 9dadeb8..d1f61d8 100644 --- a/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy +++ b/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy @@ -736,6 +736,24 @@ Thing.run() ''' } + // GROOVY-6835 + void testFlowTypingWithInstanceofAndInterfaceTypes() { + assertScript ''' + class ShowUnionTypeBug { + Map instanceMap = (Map)['a': 'Hello World'] + def findInstance(String key) { + Set allInstances = [] as Set + def instance = instanceMap.get(key) + if(instance instanceof CharSequence) { + allInstances.add(instance) + } + allInstances + } + } + assert new ShowUnionTypeBug().findInstance('a') == ['Hello World'] as Set + ''' + } + void testInferenceWithImplicitClosureCoercionAndGenericTypeAsParameter() { assertScript ''' interface Action { void execute(T t) }