External refinements are not applied to packages checked before the spec's package

オープン
#416 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
testing-qa

調査の方向性

Start with RefinementProcessor.processPackage, which the issue identifies as registering external specs, checking package types, and then recursing into sub-packages. Trace how first-pass information is registered across the package tree and how verification consumes external specs. Reproduce the example with VectorRefinements and Client; done means the invalid Vector constructor call reports a refinement error regardless of package order.

索引モデルが issue の本文から書いたものです。

説明

bug

An @ExternalRefinementsFor spec is ignored when the code that uses the class is in a package that is checked before the spec's own package: its parent package, or a sibling that comes earlier. A call that violates the spec then passes verification silently.

Example

sub/VectorRefinements.java:

package sub;

import liquidjava.specification.ExternalRefinementsFor;
import liquidjava.specification.Refinement;

@ExternalRefinementsFor("java.util.Vector")
public interface VectorRefinements<E> {
    public void Vector(@Refinement("_ >= 0") int initialCapacity);
}

Client.java, in the unnamed package:

import java.util.Vector;

public class Client {
    public static void main(String[] args) {
        Vector<String> v = new Vector<>(-1);
    }
}

Verifying the directory gives Correct! Passed Verification. (checked with 0.0.35 and main).

Spec in Client in Result
sub unnamed package (same directory, or spec in sub/) passes
sub sibling app passes
aspec sibling zclient Refinement Error
sub sub or sub.inner Refinement Error
unnamed package unnamed package or app Refinement Error

Cause

RefinementProcessor.processPackage registers a package's external specs, checks that package's types, and only then recurses into its sub-packages. A spec is therefore unknown while every package checked before its own is verified.

Possible fix

Register the external specs (and the other first-pass information) of the whole package tree before checking any package's types.

Impact

Found while running the Barista benchmark specs (package expert.<class>;) against exercises in the unnamed package: every violation passed until the spec's package line was removed.

主要言語
Java
スター
73
フォーク
38
平均マージ
12時間 32分
マージ済み PR(30日)
45

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

liquid-java/liquidjava のほかの issue

liquid-java/liquidjava の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。