@@ -369,8 +369,11 @@ public int getNumberOfSlots() {
369369 return nextId - 1 ;
370370 }
371371
372- @ Override
373- public SourceVariableSlot createSourceVariableSlot (AnnotationLocation location , TypeMirror type ) {
372+ private SourceVariableSlot createSourceVariableSlot (
373+ AnnotationLocation location ,
374+ TypeMirror type ,
375+ boolean insertable
376+ ) {
374377 AnnotationMirror defaultAnnotation = null ;
375378 if (!InferenceOptions .makeDefaultsExplicit ) {
376379 // retrieve the default annotation when needed
@@ -381,7 +384,7 @@ public SourceVariableSlot createSourceVariableSlot(AnnotationLocation location,
381384 if (location .getKind () == AnnotationLocation .Kind .MISSING ) {
382385 if (InferenceMain .isHackMode ()) {
383386 //Don't cache slot for MISSING LOCATION. Just create a new one and return.
384- sourceVarSlot = new SourceVariableSlot (nextId (), location , type , defaultAnnotation , true );
387+ sourceVarSlot = new SourceVariableSlot (nextId (), location , type , defaultAnnotation , insertable );
385388 addToSlots (sourceVarSlot );
386389 } else {
387390 throw new BugInCF ("Creating SourceVariableSlot on MISSING_LOCATION!" );
@@ -391,13 +394,25 @@ public SourceVariableSlot createSourceVariableSlot(AnnotationLocation location,
391394 int id = locationCache .get (location );
392395 sourceVarSlot = (SourceVariableSlot ) getSlot (id );
393396 } else {
394- sourceVarSlot = new SourceVariableSlot (nextId (), location , type , defaultAnnotation , true );
397+ sourceVarSlot = new SourceVariableSlot (nextId (), location , type , defaultAnnotation , insertable );
395398 addToSlots (sourceVarSlot );
396399 locationCache .put (location , sourceVarSlot .getId ());
397400 }
398401 return sourceVarSlot ;
399402 }
400403
404+ @ Override
405+ public SourceVariableSlot createSourceVariableSlot (AnnotationLocation location , TypeMirror type ) {
406+ return createSourceVariableSlot (location , type , true );
407+ }
408+
409+ @ Override
410+ public VariableSlot createPolymorphicInstanceSlot (AnnotationLocation location , TypeMirror type ) {
411+ // TODO: For now, a polymorphic instance slot is just equivalent to a non-insertable
412+ // source variable slot. We may consider changing this implementation later.
413+ return createSourceVariableSlot (location , type , false );
414+ }
415+
401416 /**
402417 * Find the default annotation for this location by checking the real type factory.
403418 * @param location location to create a new {@link SourceVariableSlot}
0 commit comments