Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Import computer: a type used only as a constructor call's type argument (var x = new Box<Sol>()) is not imported

Abierto
#178 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
67/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java

Línea de trabajo

Start by locating javaInspector.importComputer and the code that collects types used by constructor calls; the issue reproduces the omission with new Box<Sol>(4) when assigned to var. Run the reproduction through javaInspector.print2 and check that the output includes import a.c.Sol; and compiles with javac. The issue names no test file, so first look for existing import computer tests and add the case there.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

A type that a unit uses only as a type argument of a constructor call, as in var x = new Box<Sol>(4), loses its import: the import computer does not collect it.

package a.c;
public class Sol { }
package a.b;
public class Box<S> { public Box(int i) { } }
package a.b;
import a.c.Sol;
public class V {
    Object m() {
        var box = new Box<Sol>(4);
        return box;
    }
}

javaInspector.print2(cu, null, javaInspector.importComputer(4, cu.sourceSet())) prints

package a.b;
public class V { Object m() { var box = new Box<Sol>(4); return box; } }

without import a.c.Sol;, and javac rejects it. With var, the constructor call's type arguments are the only place the type is written, so nothing else brings the import in.

Found re-parsing printed sources of timefold-solver, where this is a common style: var termination = new MoveCountTermination<TestdataSolution>(4), var map = new HashMap<Class<?>, Set<Object>>(), new LinkedHashMap<Class<?>, List<AbstractRootNode<?>>>(), ... 10 units are dropped for it in one run (TestdataSolution, Set, List, ConstraintMetaModel, MoveSelector, TestdataListSolution).

maddi 0.9.6-alpha.4.

Lenguaje dominante
Java
Estrellas
1
Forks
1
Merge medio
1 h 55 min
PR fusionados (30 d)
8

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CodeLaser/maddi

Todos los issues de CodeLaser/maddi

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.