Support setting public static fields in classes

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

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
clojure, java
領域
tooling

調査の方向性

例を使って clojure.lang.Agent.soloExecutor に対する set! の失敗を再現し、Invalid assignment target を報告するアナライザーの経路を調査します。フィールドアクセスと代入がどのように処理されるかを追跡し、その後、既存の代入動作を変更せずに soloExecutor のような public static フィールドに代入できることを確認します。

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

説明

Is your feature request related to a problem? Please describe.
I stumbled onto this when trying to override the Executor for clojure.lang.Agent. The minimum code that needs to run:

(import '[clojure.lang Agent]
        '[java.util.concurrent Executors])

(set! (.-soloExecutor Agent) (Executors/newFixedThreadPool 10))

Currently, as setting of the public static fields in a class isn't supported, this results in the following error:

----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Invalid assignment target
Data:     {:type :sci/error, :line 4, :column 1, :file "foo.clj", :phase "analysis"}
Location: foo.clj:4:1
Phase:    analysis

----- Context ------------------------------------------------------------------
1: (import '[clojure.lang Agent]
2:         '[java.util.concurrent Executors])
3:
4: (set! (.-soloExecutor Agent) (Executors/newFixedThreadPool 10))
   ^--- Invalid assignment target

----- Stack trace --------------------------------------------------------------
user - foo.clj:4:1

Describe the solution you'd like
I should be able to set that field and other public static fields in a class.

Describe alternatives you've considered
None

Additional context
This is mainly for the ability to be able to override the Executors to support virtual threads in core constructs like (future ...)

主要言語
Clojure
スター
1.4k
フォーク
109
平均マージ
1分
マージ済み PR(30日)
26

環境構築

はじめの一歩

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

babashka/sci のほかの issue

babashka/sci の issue をすべて見る

似ている issue

Clojure の issue をもっと見る

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

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