@@ -142,7 +142,7 @@ private SuggestedFix attemptFix(VariableTree tree, VisitorState state) {
142
142
getPrimitiveType (symbol .type , state .getTypes ()),
143
143
symbol .getSimpleName (),
144
144
constructor .getArguments ().isEmpty ()
145
- ? getDefaultInitializer (symbol )
145
+ ? getDefaultInitializer (symbol , state . getTypes () )
146
146
: state .getSourceForNode (constructor .getArguments ().get (0 ))));
147
147
148
148
new TreePathScanner <Void , Void >() {
@@ -217,7 +217,8 @@ private boolean isVariableDeclarationItself(Tree parentTree) {
217
217
}
218
218
219
219
private static String getPrimitiveType (Type type , Types types ) {
220
- switch (types .erasure (type ).toString ()) {
220
+ String name = types .erasure (type ).toString ();
221
+ switch (name ) {
221
222
case "java.util.concurrent.atomic.AtomicBoolean" :
222
223
return "boolean" ;
223
224
case "java.util.concurrent.atomic.AtomicReference" :
@@ -228,22 +229,23 @@ private static String getPrimitiveType(Type type, Types types) {
228
229
return "int" ;
229
230
case "java.util.concurrent.atomic.AtomicLong" :
230
231
return "long" ;
231
- default : // fall out
232
+ default :
233
+ throw new AssertionError (name );
232
234
}
233
- throw new AssertionError ();
234
235
}
235
236
236
- private static String getDefaultInitializer (VarSymbol symbol ) {
237
- switch (symbol .type .toString ()) {
237
+ private static String getDefaultInitializer (VarSymbol symbol , Types types ) {
238
+ String name = types .erasure (symbol .type ).toString ();
239
+ switch (name ) {
238
240
case "java.util.concurrent.atomic.AtomicBoolean" :
239
241
return "false" ;
240
242
case "java.util.concurrent.atomic.AtomicReference" :
241
243
return "null" ;
242
244
case "java.util.concurrent.atomic.AtomicInteger" :
243
245
case "java.util.concurrent.atomic.AtomicLong" :
244
246
return "0" ;
245
- default : // fall out
247
+ default :
248
+ throw new AssertionError (name );
246
249
}
247
- throw new AssertionError ();
248
250
}
249
251
}
0 commit comments