Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Java printer: a nested type prints by simple name when the unit imports another type of that name

Đang mở
#176 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
57/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
tooling

Hướng nghiên cứu

Start at the Java printer and the importComputer call shown in the issue, then trace how it decides whether a nested type can print by its simple name. Reproduce the case with the two Builder types and confirm the printed source resolves to the wrong one. Done when the nested type remains unambiguous in printed output and the example can be reparsed successfully.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

A nested type of an imported type, written Outer.Impl.Builder, prints by its simple name Builder when the unit also imports another type named Builder. The printed unit then means the imported type.

package a.c;
public class Builder { }
package a.d;
public class Outer {
  public static class Impl {
    public static class Builder { public Builder set(int i) { return this; } }
  }
}
package a.b;
import a.c.Builder;
import a.d.Outer;
public class X {
    Builder own;
    Object make() {
        return new Outer.Impl.Builder().set(0);
    }
}

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

public class X { Builder own; Object make() { return new Builder().set(0); } }

so new Builder() is a.c.Builder, which has no set. It looks as if the printer takes the simple name as visible because some type of that simple name is imported, without checking it is the same type. (#114 was the converse: a nested type qualified by an outer name the unit had taken.)

Found re-parsing printed sources of jenkins core: hudson.model.Build, Project, hudson.Functions and jenkins.model.Jenkins import hudson.tasks.Builder and use another nested Builder; all four units are dropped (the re-parse then fails with "Unexpected javac type in convert: 'recovery'"). Jenkins alone held 8 of the idiom sites lost in that run.

maddi 0.9.6-alpha.4.

Ngôn ngữ chính
Java
Star
1
Fork
1
Merge trung bình
1 giờ 55 phút
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CodeLaser/maddi

Tất cả issue của CodeLaser/maddi

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.