You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/09/14 10:22:52 UTC
[1/3] groovy git commit: trim antlr4 runtime dependency to just
antlr4-runtime
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_6_X c92b9a751 -> 446a8ade1
trim antlr4 runtime dependency to just antlr4-runtime
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/2e0a78dc
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/2e0a78dc
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/2e0a78dc
Branch: refs/heads/GROOVY_2_6_X
Commit: 2e0a78dc827df0a33e929eb1ffb04f126fec8377
Parents: c92b9a7
Author: paulk <pa...@asert.com.au>
Authored: Thu Sep 14 20:12:31 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Thu Sep 14 20:14:25 2017 +1000
----------------------------------------------------------------------
subprojects/parser-antlr4/build.gradle | 8 ++-
.../parser/antlr4/util/GroovyTestRig.groovy | 74 --------------------
2 files changed, 7 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/2e0a78dc/subprojects/parser-antlr4/build.gradle
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/build.gradle b/subprojects/parser-antlr4/build.gradle
index d1fd1d0..371e53a 100644
--- a/subprojects/parser-antlr4/build.gradle
+++ b/subprojects/parser-antlr4/build.gradle
@@ -53,12 +53,18 @@ generateGrammarSource {
compileJava.dependsOn generateGrammarSource
+configurations {
+ compile {
+ extendsFrom = extendsFrom.findAll { it != configurations.antlr }
+ }
+}
+
dependencies {
antlr "com.tunnelvisionlabs:antlr4:$antlr4Version"
+ compile "com.tunnelvisionlabs:antlr4-runtime:$antlr4Version"
testCompile project(':groovy-test')
}
-
sourceSets.main.java.srcDirs += file("$srcMain/java");
sourceSets.main.groovy.srcDirs += file("$srcMain/groovy");
sourceSets.main.resources.srcDirs += file("$srcMain/resources");
http://git-wip-us.apache.org/repos/asf/groovy/blob/2e0a78dc/subprojects/parser-antlr4/src/main/groovy/org/apache/groovy/parser/antlr4/util/GroovyTestRig.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/groovy/org/apache/groovy/parser/antlr4/util/GroovyTestRig.groovy b/subprojects/parser-antlr4/src/main/groovy/org/apache/groovy/parser/antlr4/util/GroovyTestRig.groovy
deleted file mode 100644
index 798ed5f..0000000
--- a/subprojects/parser-antlr4/src/main/groovy/org/apache/groovy/parser/antlr4/util/GroovyTestRig.groovy
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.groovy.parser.antlr4.util
-
-import groovy.util.logging.Log
-import org.antlr.v4.gui.TestRig
-import org.antlr.v4.runtime.ANTLRInputStream
-import org.antlr.v4.runtime.CommonTokenStream
-import org.apache.groovy.parser.antlr4.GroovyLangLexer
-import org.apache.groovy.parser.antlr4.GroovyLangParser
-
-/**
- * A basic debug tool for investigating the parse trees and tokens of Groovy source code
- *
- * @author <a href="mailto:realbluesun@hotmail.com">Daniel.Sun</a>
- * Created on 2016/08/14
- */
-@Log
-public class GroovyTestRig extends TestRig {
- public GroovyTestRig(String[] args) throws Exception {
- super(['Groovy', args.contains('-lexer') ? 'tokens' : 'compilationUnit', *args] as String[]);
- }
-
- public void inspectParseTree() {
- def inputFile = new File(this.inputFiles[0]);
-
- if (!(inputFile.exists() && inputFile.isFile())) {
- log.info "Input file[${inputFile.absolutePath}] does not exist."
- return;
- }
-
- byte[] content = inputFile.bytes;
- String text = new String(content, this.encoding ?: 'UTF-8');
-
- GroovyLangLexer lexer = new GroovyLangLexer(new ANTLRInputStream(text));
- CommonTokenStream tokens = new CommonTokenStream(lexer);
- GroovyLangParser parser = new GroovyLangParser(tokens);
-
- this.process(lexer, GroovyLangParser.class, parser, new ByteArrayInputStream(content), new StringReader(text));
- }
-
- public static void main(String[] args) {
- if (args.length == 0) {
- log.info "Usage: [-tokens] [-lexer] [-tree] [-gui] [-ps file.ps] [-encoding encodingname] [-trace] [-diagnostics] [-SLL] input-filename";
- return;
- }
-
- if (args.every { it.startsWith('-') }) {
- log.info "input-filename is required!"
- return;
- }
-
- GroovyTestRig groovyTestRig = new GroovyTestRig(args);
-
- groovyTestRig.inspectParseTree();
- }
-}
-
[2/3] groovy git commit: GROOVY-8247: AIOOBE in
StaticTypeCheckingVisitor with SAM and explicit closure parameter (closes
#600)
Posted by pa...@apache.org.
GROOVY-8247: AIOOBE in StaticTypeCheckingVisitor with SAM and explicit closure parameter (closes #600)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/cd8d6c04
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/cd8d6c04
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/cd8d6c04
Branch: refs/heads/GROOVY_2_6_X
Commit: cd8d6c04b8392135a767b565ecb4f6894390a347
Parents: 2e0a78d
Author: paulk <pa...@asert.com.au>
Authored: Thu Sep 14 19:38:17 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Thu Sep 14 20:16:42 2017 +1000
----------------------------------------------------------------------
.../stc/StaticTypeCheckingVisitor.java | 12 ++++---
.../groovy/transform/stc/Groovy8247Bug.groovy | 36 ++++++++++++++++++++
2 files changed, 44 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/cd8d6c04/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 7e38ac4..98aebd7 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -2419,20 +2419,24 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
blockParameterTypes = extractTypesFromParameters(p);
}
}
- for (int i=0; i<blockParameterTypes.length; i++) { //TODO: equal length guaranteed?
- extractGenericsConnections(SAMTypeConnections, blockParameterTypes[i], parameterTypesForSAM[i]);
+ for (int i=0; i<blockParameterTypes.length; i++) {
+ extractGenericsConnections(SAMTypeConnections, blockParameterTypes[i], typeOrNull(parameterTypesForSAM, i));
}
// and finally we apply the generics information to the parameters and
// store the type of parameter and block type as meta information
- for (int i=0; i<blockParameterTypes.length; i++) { //TODO: equal length guaranteed?
+ for (int i=0; i<blockParameterTypes.length; i++) {
ClassNode resolvedParameter =
- applyGenericsContext(SAMTypeConnections, parameterTypesForSAM[i]);
+ applyGenericsContext(SAMTypeConnections, typeOrNull(parameterTypesForSAM, i));
blockParameterTypes[i] = resolvedParameter;
}
openBlock.putNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS, blockParameterTypes);
}
+ private ClassNode typeOrNull(ClassNode[] parameterTypesForSAM, int i) {
+ return i < parameterTypesForSAM.length ? parameterTypesForSAM[i] : null;
+ }
+
private List<ClassNode[]> getSignaturesFromHint(final ClosureExpression expression, final MethodNode selectedMethod, final Expression hintClass, final Expression options) {
// initialize hints
List<ClassNode[]> closureSignatures;
http://git-wip-us.apache.org/repos/asf/groovy/blob/cd8d6c04/src/test/groovy/transform/stc/Groovy8247Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/Groovy8247Bug.groovy b/src/test/groovy/transform/stc/Groovy8247Bug.groovy
new file mode 100644
index 0000000..7488352
--- /dev/null
+++ b/src/test/groovy/transform/stc/Groovy8247Bug.groovy
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package groovy.transform.stc
+
+class Groovy8247Bug extends StaticTypeCheckingTestCase {
+ void testClosureWithExplicitParamNoInferrableArguments() {
+ assertScript '''
+ def runnable(Runnable r) {
+ r.run()
+ }
+ def foo() {
+ runnable { it -> // note explicit it
+ println it
+ }
+ }
+ foo()
+ '''
+ }
+}
[3/3] groovy git commit: GROOVY-8246: AIOOBE in
StaticTypeCheckingVisitor with SAM (closes #601)
Posted by pa...@apache.org.
GROOVY-8246: AIOOBE in StaticTypeCheckingVisitor with SAM (closes #601)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/446a8ade
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/446a8ade
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/446a8ade
Branch: refs/heads/GROOVY_2_6_X
Commit: 446a8ade11ed2075433168c0ef55f91accfabca0
Parents: cd8d6c0
Author: paulk <pa...@asert.com.au>
Authored: Thu Sep 14 19:41:00 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Thu Sep 14 20:21:16 2017 +1000
----------------------------------------------------------------------
.../stc/StaticTypeCheckingVisitor.java | 2 +-
.../groovy/transform/stc/Groovy8246Bug.groovy | 36 ++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/446a8ade/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 98aebd7..a257aa0 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -4021,7 +4021,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
ClassNode[] closureParamTypes = (ClassNode[])(enclosingClosure!=null?enclosingClosure.getClosureExpression().getNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS):null);
if (type==null && enclosingClosure !=null && "it".equals(variable.getName()) && closureParamTypes!=null) {
final Parameter[] parameters = enclosingClosure.getClosureExpression().getParameters();
- if (parameters.length==0 && getTemporaryTypesForExpression(vexp)==null) {
+ if (parameters.length==0 && getTemporaryTypesForExpression(vexp)==null && closureParamTypes.length!=0) {
type = closureParamTypes[0];
}
}
http://git-wip-us.apache.org/repos/asf/groovy/blob/446a8ade/src/test/groovy/transform/stc/Groovy8246Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/Groovy8246Bug.groovy b/src/test/groovy/transform/stc/Groovy8246Bug.groovy
new file mode 100644
index 0000000..e634a76
--- /dev/null
+++ b/src/test/groovy/transform/stc/Groovy8246Bug.groovy
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package groovy.transform.stc
+
+class Groovy8246Bug extends StaticTypeCheckingTestCase {
+ void testClosureWithImplicitParamNoInferrableArguments() {
+ assertScript '''
+ def runnable(Runnable r) {
+ r.run()
+ }
+ def foo() {
+ runnable {
+ println it
+ }
+ }
+ foo()
+ '''
+ }
+}