You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/01/22 14:55:22 UTC
[groovy] branch master updated: STC: normalize inclusion of types
in errors
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 1ce43c1 STC: normalize inclusion of types in errors
1ce43c1 is described below
commit 1ce43c1301b076ead12e4fce663eace497bac7e1
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Jan 21 12:15:12 2021 -0600
STC: normalize inclusion of types in errors
"Cannot call <T> java.util.List#leftShift(T) ..."
was
"Cannot call <T> java.util.List <String>#leftShift(T) ..."
- Arrays are displayed as "java.lang.String[]" not "[Ljava.lang.String;"
---
.../stc/AbstractTypeCheckingExtension.java | 6 +--
.../transform/stc/StaticTypeCheckingSupport.java | 18 +++++++--
.../transform/stc/StaticTypeCheckingVisitor.java | 46 +++++++++++-----------
.../transform/stc/TypeCheckingExtension.java | 2 +-
src/test/groovy/transform/stc/BugsSTCTest.groovy | 2 +-
.../groovy/transform/stc/GenericsSTCTest.groovy | 22 +++++------
.../groovy/transform/stc/MethodCallsSTCTest.groovy | 2 +-
.../InheritConstructorsTransformTest.groovy | 4 +-
8 files changed, 57 insertions(+), 45 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/AbstractTypeCheckingExtension.java b/src/main/java/org/codehaus/groovy/transform/stc/AbstractTypeCheckingExtension.java
index 87d3952..d72a3c0 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/AbstractTypeCheckingExtension.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/AbstractTypeCheckingExtension.java
@@ -283,7 +283,7 @@ public class AbstractTypeCheckingExtension extends TypeCheckingExtension {
}
setHandled(true);
if (debug) {
- LOG.info("Turning "+call.getText()+" into a dynamic method call returning "+returnType.toString(false));
+ LOG.info("Turning " + call.getText() + " into a dynamic method call returning " + StaticTypeCheckingSupport.prettyPrintType(returnType));
}
return new MethodNode(call.getMethodAsString(), 0, returnType, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, EmptyStatement.INSTANCE);
}
@@ -309,7 +309,7 @@ public class AbstractTypeCheckingExtension extends TypeCheckingExtension {
storeType(pexp, returnType);
setHandled(true);
if (debug) {
- LOG.info("Turning '"+pexp.getText()+"' into a dynamic property access of type "+returnType.toString(false));
+ LOG.info("Turning '" + pexp.getText() + "' into a dynamic property access of type " + StaticTypeCheckingSupport.prettyPrintType(returnType));
}
}
@@ -334,7 +334,7 @@ public class AbstractTypeCheckingExtension extends TypeCheckingExtension {
storeType(vexp, returnType);
setHandled(true);
if (debug) {
- LOG.info("Turning '"+vexp.getText()+"' into a dynamic variable access of type "+returnType.toString(false));
+ LOG.info("Turning '" + vexp.getText() + "' into a dynamic variable access of type " + StaticTypeCheckingSupport.prettyPrintType(returnType));
}
}
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index 1094999..cc598a3 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -842,11 +842,23 @@ public abstract class StaticTypeCheckingSupport {
return sb.toString();
}
- static String prettyPrintType(ClassNode type) {
+ /**
+ * Returns string representation of type with generics. Arrays are indicated
+ * with trailing "[]".
+ */
+ static String prettyPrintType(final ClassNode type) {
+ return type.toString(false);
+ }
+
+ /**
+ * Returns string representation of type *no* generics. Arrays are indicated
+ * with trailing "[]".
+ */
+ static String prettyPrintTypeName(final ClassNode type) {
if (type.isArray()) {
- return prettyPrintType(type.getComponentType()) + "[]";
+ return prettyPrintTypeName(type.getComponentType()) + "[]";
}
- return type.toString(false);
+ return type.getText();
}
public static boolean implementsInterfaceOrIsSubclassOf(final ClassNode type, final ClassNode superOrInterface) {
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index bc131a0..9c84b93 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -273,6 +273,7 @@ import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isWild
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.lastArgMatchesVarg;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.missesGenericsTypes;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.prettyPrintType;
+import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.prettyPrintTypeName;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.resolveClassNodeGenerics;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.toMethodParametersString;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodArgumentWithGenerics;
@@ -687,7 +688,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
if (!extension.handleUnresolvedProperty(expression)) {
Expression objectExpression = expression.getObjectExpression();
addStaticTypeError("No such property: " + expression.getPropertyAsString() + " for class: " +
- findCurrentInstanceOfClass(objectExpression, getType(objectExpression)).toString(false), expression);
+ prettyPrintTypeName(findCurrentInstanceOfClass(objectExpression, getType(objectExpression))), expression);
}
}
@@ -698,7 +699,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
if (!extension.handleUnresolvedAttribute(expression)) {
Expression objectExpression = expression.getObjectExpression();
addStaticTypeError("No such attribute: " + expression.getPropertyAsString() + " for class: " +
- findCurrentInstanceOfClass(objectExpression, getType(objectExpression)).toString(false), expression);
+ prettyPrintTypeName(findCurrentInstanceOfClass(objectExpression, getType(objectExpression))), expression);
}
}
@@ -1090,7 +1091,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
ClassNode elemType = getType(listExpression);
ClassNode tupleType = getType(tupleExpression);
if (!isAssignableTo(elemType, tupleType)) {
- addStaticTypeError("Cannot assign value of type " + elemType.toString(false) + " to variable of type " + tupleType.toString(false), rightExpression);
+ addStaticTypeError("Cannot assign value of type " + prettyPrintType(elemType) + " to variable of type " + prettyPrintType(tupleType), rightExpression);
return false; // avoids too many errors
} else {
storeType(tupleExpression, elemType);
@@ -1164,7 +1165,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
private void addPrecisionErrors(final ClassNode leftRedirect, final ClassNode lhsType, final ClassNode rhsType, final Expression rightExpression) {
if (isNumberType(leftRedirect)) {
if (isNumberType(rhsType) && checkPossibleLossOfPrecision(leftRedirect, rhsType, rightExpression)) {
- addStaticTypeError("Possible loss of precision from " + rhsType.toString(false) + " to " + lhsType.toString(false), rightExpression);
+ addStaticTypeError("Possible loss of precision from " + prettyPrintType(rhsType) + " to " + prettyPrintType(lhsType), rightExpression);
}
return;
}
@@ -1175,14 +1176,14 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
for (Expression expression : ((ListExpression) rightExpression).getExpressions()) {
ClassNode rightComponentType = getType(expression);
if (!checkCompatibleAssignmentTypes(leftComponentType, rightComponentType) && !(isNullConstant(expression) && !isPrimitiveType(leftComponentType))) {
- addStaticTypeError("Cannot assign value of type " + rightComponentType.toString(false) + " into array of type " + lhsType.toString(false), rightExpression);
+ addStaticTypeError("Cannot assign value of type " + prettyPrintType(rightComponentType) + " into array of type " + prettyPrintType(lhsType), rightExpression);
}
}
} else if (rhsType.redirect().isArray()) {
ClassNode leftComponentType = leftRedirect.getComponentType();
ClassNode rightComponentType = rhsType.redirect().getComponentType();
if (!checkCompatibleAssignmentTypes(leftComponentType, rightComponentType)) {
- addStaticTypeError("Cannot assign value of type " + rightComponentType.toString(false) + " into array of type " + lhsType.toString(false), rightExpression);
+ addStaticTypeError("Cannot assign value of type " + prettyPrintType(rightComponentType) + " into array of type " + prettyPrintType(lhsType), rightExpression);
}
}
}
@@ -1234,8 +1235,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
isNullConstant(rightExpression)) return;
addStaticTypeError("Incompatible generic argument types. Cannot assign "
- + wrappedRHS.toString(false)
- + " to: " + leftExpressionType.toString(false), rightExpression);
+ + prettyPrintType(wrappedRHS) + " to: " + prettyPrintType(leftExpressionType), rightExpression);
}
private boolean hasGStringStringError(final ClassNode leftExpressionType, final ClassNode wrappedRHS, final Expression rightExpression) {
@@ -1286,7 +1286,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
String pName = keyExpression.getText();
AtomicReference<ClassNode> pType = new AtomicReference<>();
if (!existsProperty(propX(varX("_", receiverType), pName), false, new PropertyLookupVisitor(pType))) {
- addStaticTypeError("No such property: " + pName + " for class: " + receiverType.getText(), receiver);
+ addStaticTypeError("No such property: " + pName + " for class: " + prettyPrintTypeName(receiverType), receiver);
} else {
ClassNode targetType = Optional.ofNullable(receiverType.getSetterMethod(getSetterName(pName), false))
.map(setter -> setter.getParameters()[0].getType()).orElseGet(pType::get);
@@ -1862,7 +1862,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
componentType = forLoopVariableType;
}
if (!checkCompatibleAssignmentTypes(forLoopVariableType, componentType)) {
- addStaticTypeError("Cannot loop with element of type " + forLoopVariableType.toString(false) + " with collection of type " + collectionType.toString(false), forLoop);
+ addStaticTypeError("Cannot loop with element of type " + prettyPrintType(forLoopVariableType) + " with collection of type " + prettyPrintType(collectionType), forLoop);
}
if (forLoopVariableType != DYNAMIC_TYPE) {
// user has specified a type, prefer it over the inferred type
@@ -2132,7 +2132,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
&& !checkCompatibleAssignmentTypes(enclosingMethod.getReturnType(), type, null, false)
&& !(isNullConstant(expression))) {
if (!extension.handleIncompatibleReturnType(statement, type)) {
- addStaticTypeError("Cannot return value of type " + type.toString(false) + " on method returning type " + enclosingMethod.getReturnType().toString(false), expression);
+ addStaticTypeError("Cannot return value of type " + prettyPrintType(type) + " on method returning type " + prettyPrintType(enclosingMethod.getReturnType()), expression);
}
} else if (!enclosingMethod.isVoidMethod()) {
ClassNode previousType = getInferredReturnType(enclosingMethod);
@@ -2401,7 +2401,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
} else if (!(expression instanceof MethodReferenceExpression)) {
ClassNode type = wrapTypeIfNecessary(getType(expression.getExpression()));
if (isClassClassNodeWrappingConcreteType(type)) type = type.getGenericsTypes()[0].getType();
- addStaticTypeError("Cannot find matching method " + type.getText() + "#" + nameText + ". Please check if the declared type is correct and if the method exists.", nameExpr);
+ addStaticTypeError("Cannot find matching method " + prettyPrintTypeName(type) + "#" + nameText + ". Please check if the declared type is correct and if the method exists.", nameExpr);
}
}
}
@@ -2644,7 +2644,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
} else if (parameters.length == 1) {
Parameter param = parameters[0];
if (!param.isDynamicTyped() && !isAssignableTo(receiver, param.getType().redirect())) {
- addStaticTypeError("Expected parameter type: " + receiver.toString(false) + " but was: " + param.getType().redirect().toString(false), param);
+ addStaticTypeError("Expected parameter type: " + prettyPrintType(receiver) + " but was: " + prettyPrintType(param.getType()), param);
}
}
closure.putNodeMetaData(DELEGATION_METADATA, new DelegationMetadata(
@@ -3037,7 +3037,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
boolean lastArg = i == (n - 1);
if (!typeCheckMethodArgumentWithGenerics(originType, inferredType, lastArg)) {
- addError("Expected parameter of type " + inferredType.toString(false) + " but got " + originType.toString(false), closureParam.getType());
+ addError("Expected parameter of type " + prettyPrintType(inferredType) + " but got " + prettyPrintType(originType), closureParam.getType());
}
typeCheckingContext.controlStructureVariables.put(closureParam, inferredType);
@@ -3195,7 +3195,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
if (pTypeGenerics != null && pTypeGenerics.length > gti) {
actualType = pTypeGenerics[gti].getType();
} else {
- addStaticTypeError("Unable to map actual type [" + actualType.toString(false) + "] onto " + paramType.toString(false), methodParam);
+ addStaticTypeError("Unable to map actual type [" + prettyPrintType(actualType) + "] onto " + prettyPrintType(paramType), methodParam);
}
}
}
@@ -4036,7 +4036,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
Expression source = expression.getExpression();
ClassNode expressionType = getType(source);
if (!checkCast(targetType, source) && !isDelegateOrOwnerInClosure(source)) {
- addStaticTypeError("Inconvertible types: cannot cast " + expressionType.toString(false) + " to " + targetType.toString(false), expression);
+ addStaticTypeError("Inconvertible types: cannot cast " + prettyPrintType(expressionType) + " to " + prettyPrintType(targetType), expression);
}
}
storeType(expression, expression.getType());
@@ -4527,9 +4527,9 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
StringBuilder sb = new StringBuilder("[");
for (int i = 0, n = nodes.size(); i < n; i += 1) {
MethodNode node = nodes.get(i);
- sb.append(node.getReturnType().toString(false));
+ sb.append(prettyPrintType(node.getReturnType()));
sb.append(" ");
- sb.append(node.getDeclaringClass().toString(false));
+ sb.append(prettyPrintTypeName(node.getDeclaringClass()));
sb.append("#");
sb.append(toMethodParametersString(node.getName(), extractTypesFromParameters(node.getParameters())));
if (i < n - 1) sb.append(", ");
@@ -5503,7 +5503,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
for (int i = 0, n = parameters.length; i < n; i += 1) {
paramTypes[i] = fullyResolveType(parameters[i].getType(), classGTs);
}
- addStaticTypeError("Cannot call " + toMethodGenericTypesString(candidateMethod) + receiver.toString(false) + "#" +
+ addStaticTypeError("Cannot call " + toMethodGenericTypesString(candidateMethod) + prettyPrintTypeName(receiver) + "#" +
toMethodParametersString(candidateMethod.getName(), paramTypes) + " with arguments " + formatArgumentList(arguments), location);
return false;
}
@@ -5566,7 +5566,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
if (isClassClassNodeWrappingConcreteType(receiver)) {
receiver = receiver.getGenericsTypes()[0].getType();
}
- addStaticTypeError("Cannot find matching method " + receiver.getText() + "#" + toMethodParametersString(name, args) + ". Please check if the declared type is correct and if the method exists.", call);
+ addStaticTypeError("Cannot find matching method " + prettyPrintTypeName(receiver) + "#" + toMethodParametersString(name, args) + ". Please check if the declared type is correct and if the method exists.", call);
}
protected void addAmbiguousErrorMessage(final List<MethodNode> foundMethods, final String name, final ClassNode[] args, final Expression expr) {
@@ -5578,7 +5578,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
}
protected void addAssignmentError(final ClassNode leftType, final ClassNode rightType, final Expression assignmentExpression) {
- addStaticTypeError("Cannot assign value of type " + rightType.toString(false) + " to variable of type " + leftType.toString(false), assignmentExpression);
+ addStaticTypeError("Cannot assign value of type " + prettyPrintType(rightType) + " to variable of type " + prettyPrintType(leftType), assignmentExpression);
}
protected void addUnsupportedPreOrPostfixExpressionError(final Expression expression) {
@@ -5614,7 +5614,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
addStaticTypeError("A closure shared variable [" + target.getName() + "] has been assigned with various types and the method" +
" [" + toMethodParametersString(message, getType(((BinaryExpression) expression).getRightExpression())) + "]" +
" does not exist in the lowest upper bound of those types: [" +
- lub.toString(false) + "]. In general, this is a bad practice (variable reuse) because the compiler cannot" +
+ prettyPrintType(lub) + "]. In general, this is a bad practice (variable reuse) because the compiler cannot" +
" determine safely what is the type of the variable at the moment of the call in a multithreaded context.", expression);
}
}
@@ -5642,7 +5642,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
addStaticTypeError("A closure shared variable [" + target.getName() + "] has been assigned with various types and the method" +
" [" + toMethodParametersString(methodNode.getName(), params) + "]" +
" does not exist in the lowest upper bound of those types: [" +
- lub.toString(false) + "]. In general, this is a bad practice (variable reuse) because the compiler cannot" +
+ prettyPrintType(lub) + "]. In general, this is a bad practice (variable reuse) because the compiler cannot" +
" determine safely what is the type of the variable at the moment of the call in a multithreaded context.", call);
}
}
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java b/src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java
index e0758dd..c662a08 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java
@@ -334,7 +334,7 @@ public class TypeCheckingExtension {
if (generics != null) {
int expectedLength = generics.length;
if (expectedLength != genericsTypeArguments.length) {
- throw new GroovyBugError("Expected number of generic type arguments for " + baseType.toString(false) + " is " + expectedLength + " but you gave " + genericsTypeArguments.length);
+ throw new GroovyBugError("Expected number of generic type arguments for " + StaticTypeCheckingSupport.prettyPrintType(baseType) + " is " + expectedLength + " but you gave " + genericsTypeArguments.length);
}
result.setGenericsTypes(Arrays.stream(genericsTypeArguments)
.map(StaticTypeCheckingVisitor::wrapTypeIfNecessary)
diff --git a/src/test/groovy/transform/stc/BugsSTCTest.groovy b/src/test/groovy/transform/stc/BugsSTCTest.groovy
index 184fea8..510d74d 100644
--- a/src/test/groovy/transform/stc/BugsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/BugsSTCTest.groovy
@@ -169,7 +169,7 @@ class BugsSTCTest extends StaticTypeCheckingTestCase {
L<String> items = ['foo', 'bar'] as L<String>
items.removeIf({a, b -> 1} as Comparator<?>)
assert items
- ''', 'Cannot call L <String>#removeIf(java.util.Comparator <? super java.lang.String>) with arguments [java.util.Comparator <?>]'
+ ''', 'Cannot call L#removeIf(java.util.Comparator <? super java.lang.String>) with arguments [java.util.Comparator <?>]'
}
void testGroovy5482ListsAndFlowTyping() {
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 2e48527..7983f6b 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -74,7 +74,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
shouldFailWithMessages '''
List<String> list = []
list << 1
- ''', '[Static type checking] - Cannot call <T> java.util.List <String>#leftShift(T) with arguments [int] '
+ ''', '[Static type checking] - Cannot call <T> java.util.List#leftShift(T) with arguments [int] '
}
void testAddOnList2UsingLeftShift() {
@@ -129,7 +129,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
shouldFailWithMessages '''
List<Integer> list = new LinkedList<>()
list << 'Hello'
- ''', '[Static type checking] - Cannot call <T> java.util.LinkedList <java.lang.Integer>#leftShift(T) with arguments [java.lang.String]'
+ ''', '[Static type checking] - Cannot call <T> java.util.LinkedList#leftShift(T) with arguments [java.lang.String]'
}
void testAddOnListWithDiamondAndNullUsingLeftShift() {
@@ -243,7 +243,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
void testLinkedListWithListArgumentAndWrongElementTypes() {
shouldFailWithMessages '''
List<String> list = new LinkedList<String>([1,2,3])
- ''', 'Cannot call java.util.LinkedList <String>#<init>(java.util.Collection <? extends java.lang.String>) with arguments [java.util.List <java.lang.Integer>]'
+ ''', 'Cannot call java.util.LinkedList#<init>(java.util.Collection <? extends java.lang.String>) with arguments [java.util.List <java.lang.Integer>]'
}
void testIncompatibleGenericAssignment() {
@@ -637,7 +637,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
}
}
new ClassB()
- ''', 'Cannot call <X> groovy.transform.stc.GenericsSTCTest$ClassA <Long>#bar(java.lang.Class <Long>) with arguments [java.lang.Class <? extends java.lang.Object>]'
+ ''', 'Cannot call <X> groovy.transform.stc.GenericsSTCTest$ClassA#bar(java.lang.Class <Long>) with arguments [java.lang.Class <? extends java.lang.Object>]'
}
// GROOVY-8961
@@ -811,7 +811,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
List<String> list = ['a','b','c']
Collection<Integer> e = (Collection<Integer>) [1,2,3]
boolean r = list.addAll(e)
- ''', 'Cannot call java.util.List <java.lang.String>#addAll(java.util.Collection <? extends java.lang.String>) with arguments [java.util.Collection <Integer>]'
+ ''', 'Cannot call java.util.List#addAll(java.util.Collection <? extends java.lang.String>) with arguments [java.util.Collection <Integer>]'
}
// GROOVY-5528
@@ -1052,7 +1052,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
})
Map<Date, Date> map = new HashMap<>()
map['foo'] = new Date()
- ''', 'Cannot call <K,V> java.util.HashMap <java.util.Date, java.util.Date>#putAt(java.util.Date, java.util.Date) with arguments [java.lang.String, java.util.Date]'
+ ''', 'Cannot call <K,V> java.util.HashMap#putAt(java.util.Date, java.util.Date) with arguments [java.lang.String, java.util.Date]'
}
void testInferDiamondForAssignmentWithDatesAndIllegalValueUsingPut() {
shouldFailWithMessages '''
@@ -1090,7 +1090,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
})
Map<Date, Date> map = new HashMap<>()
map[new Date()] = 'foo'
- ''', 'Cannot call <K,V> java.util.HashMap <java.util.Date, java.util.Date>#putAt(java.util.Date, java.util.Date) with arguments [java.util.Date, java.lang.String]'
+ ''', 'Cannot call <K,V> java.util.HashMap#putAt(java.util.Date, java.util.Date) with arguments [java.util.Date, java.lang.String]'
}
void testCallMethodWithParameterizedArrayList() {
@@ -1268,9 +1268,9 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
test(new Holder<Object>())
''',
- 'Cannot call TypedProperty <String, Object>#eq(java.lang.String) with arguments [groovy.lang.GString]',
- 'Cannot call TypedProperty <String, Unknown>#eq(java.lang.String) with arguments [int]',
- 'Cannot call TypedProperty <Number, Unknown>#eq(java.lang.Number) with arguments [java.lang.String]'
+ 'Cannot call TypedProperty#eq(java.lang.String) with arguments [groovy.lang.GString]',
+ 'Cannot call TypedProperty#eq(java.lang.String) with arguments [int]',
+ 'Cannot call TypedProperty#eq(java.lang.Number) with arguments [java.lang.String]'
}
void testGroovy5748() {
@@ -1886,7 +1886,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
}
GoodCodeRed.foo()
''',
- "Cannot call <T> GoodCodeRed <Long>#attach(GoodCodeRed <Long>) with arguments [GoodCodeRed <Integer>]"
+ "Cannot call <T> GoodCodeRed#attach(GoodCodeRed <Long>) with arguments [GoodCodeRed <Integer>]"
}
void testHiddenGenerics() {
diff --git a/src/test/groovy/transform/stc/MethodCallsSTCTest.groovy b/src/test/groovy/transform/stc/MethodCallsSTCTest.groovy
index 2d504d5..eb4543b 100644
--- a/src/test/groovy/transform/stc/MethodCallsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/MethodCallsSTCTest.groovy
@@ -189,7 +189,7 @@ class MethodCallsSTCTest extends StaticTypeCheckingTestCase {
B c = new B<Integer>()
String[] args = ['a','b','c']
assert c.identity(args) == args
- ''', 'Cannot call groovy.transform.stc.MethodCallsSTCTest$MyMethodCallTestClass2 <Integer>#identity(java.lang.Integer[]) with arguments [java.lang.String[]]'
+ ''', 'Cannot call groovy.transform.stc.MethodCallsSTCTest$MyMethodCallTestClass2#identity(java.lang.Integer[]) with arguments [java.lang.String[]]'
}
void testMethodCallFromSuperOwner() {
diff --git a/src/test/org/codehaus/groovy/transform/InheritConstructorsTransformTest.groovy b/src/test/org/codehaus/groovy/transform/InheritConstructorsTransformTest.groovy
index c3f1aea..30c52fa 100644
--- a/src/test/org/codehaus/groovy/transform/InheritConstructorsTransformTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/InheritConstructorsTransformTest.groovy
@@ -219,9 +219,9 @@ class InheritConstructorsTransformTest extends GroovyShellTestCase {
op.bar(RoundingMode.DOWN)
assert op.toString() == '3|DOWN'
"""
- assert message.contains('Cannot call OrderPublisher <RoundingMode>#<init>(java.util.Deque <java.lang.Integer>) with arguments [java.util.LinkedList <String>]')
+ assert message.contains('Cannot call OrderPublisher#<init>(java.util.Deque <java.lang.Integer>) with arguments [java.util.LinkedList <String>]')
assert message.contains('Cannot find matching method OrderPublisher#<init>(java.util.Date)')
- assert message.contains('Cannot call OrderPublisher <RoundingMode>#<init>(java.util.Set <RoundingMode>) with arguments [java.util.HashSet <Date>]')
+ assert message.contains('Cannot call OrderPublisher#<init>(java.util.Set <RoundingMode>) with arguments [java.util.HashSet <Date>]')
}
// GROOVY-9323