@@ -3137,13 +3137,13 @@ private static LambdaExpression constructLambdaExpressionForMethodReference(fina
3137
3137
private void checkNamedParamsAnnotation (final Parameter param , final MapExpression args ) {
3138
3138
if (!isOrImplements (param .getType (), MAP_TYPE )) return ;
3139
3139
List <MapEntryExpression > entryExpressions = args .getMapEntryExpressions ();
3140
- Map <Object , Expression > entries = new LinkedHashMap <>();
3140
+ Map <Object , MapEntryExpression > entries = new LinkedHashMap <>();
3141
3141
for (MapEntryExpression entry : entryExpressions ) {
3142
3142
Object key = entry .getKeyExpression ();
3143
3143
if (key instanceof ConstantExpression ) {
3144
3144
key = ((ConstantExpression ) key ).getValue ();
3145
3145
}
3146
- entries .put (key , entry . getValueExpression () );
3146
+ entries .put (key , entry );
3147
3147
}
3148
3148
List <String > collectedNames = new ArrayList <>();
3149
3149
List <AnnotationNode > annotations = param .getAnnotations (NAMED_PARAMS_CLASSNODE );
@@ -3177,21 +3177,22 @@ private void checkNamedParamsAnnotation(final Parameter param, final MapExpressi
3177
3177
}
3178
3178
}
3179
3179
if (!collectedNames .isEmpty ()) {
3180
- for (Map .Entry <Object , Expression > entry : entries .entrySet ()) {
3181
- if (!collectedNames .contains (entry .getKey ())) {
3182
- addStaticTypeError ("unexpected named arg: " + entry .getKey (), args );
3180
+ for (Map .Entry <Object , MapEntryExpression > entry : entries .entrySet ()) {
3181
+ Object name = entry .getKey ();
3182
+ if (!collectedNames .contains (name )) {
3183
+ addStaticTypeError ("unexpected named arg: " + name , entry .getValue ());
3183
3184
}
3184
3185
}
3185
3186
}
3186
3187
}
3187
3188
3188
- private void processNamedParam (final AnnotationConstantExpression value , final Map <Object , Expression > entries , final Expression expression , final List <String > collectedNames ) {
3189
+ private void processNamedParam (final AnnotationConstantExpression value , final Map <Object , MapEntryExpression > entries , final MapExpression args , final List <String > collectedNames ) {
3189
3190
AnnotationNode namedParam = (AnnotationNode ) value .getValue ();
3190
3191
if (!namedParam .getClassNode ().getName ().equals (NamedParam .class .getName ())) return ;
3191
- processNamedParam (namedParam , entries , expression , collectedNames );
3192
+ processNamedParam (namedParam , entries , args , collectedNames );
3192
3193
}
3193
3194
3194
- private void processNamedParam (final AnnotationNode namedParam , final Map <Object , Expression > entries , final Expression expression , final List <String > collectedNames ) {
3195
+ private void processNamedParam (final AnnotationNode namedParam , final Map <Object , MapEntryExpression > entries , final MapExpression args , final List <String > collectedNames ) {
3195
3196
String name = null ;
3196
3197
boolean required = false ;
3197
3198
ClassNode expectedType = null ;
@@ -3210,12 +3211,13 @@ private void processNamedParam(final AnnotationNode namedParam, final Map
3210
3211
}
3211
3212
if (!entries .containsKey (name )) {
3212
3213
if (required ) {
3213
- addStaticTypeError ("required named param '" + name + "' not found." , expression );
3214
+ addStaticTypeError ("required named param '" + name + "' not found." , args );
3214
3215
}
3215
3216
} else if (expectedType != null ) {
3216
- ClassNode argumentType = getDeclaredOrInferredType (entries .get (name ));
3217
+ MapEntryExpression entry = entries .get (name );
3218
+ ClassNode argumentType = getDeclaredOrInferredType (entry .getValueExpression ());
3217
3219
if (!isAssignableTo (argumentType , expectedType )) {
3218
- addStaticTypeError ("argument for named param '" + name + "' has type '" + prettyPrintType (argumentType ) + "' but expected '" + prettyPrintType (expectedType ) + "'." , expression );
3220
+ addStaticTypeError ("argument for named param '" + name + "' has type '" + prettyPrintType (argumentType ) + "' but expected '" + prettyPrintType (expectedType ) + "'." , entry );
3219
3221
}
3220
3222
}
3221
3223
}
0 commit comments