Protocols with default methods in extension fail to compile

未關閉
#562 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
java, swift
領域
compilers

研究方向

從 issue 中描述的分析階段和擷取介面生成開始,然後重現 protocol 和 extension 範例。追蹤如何將 protocol 要求與 extension 中的宣告區分開來;完成的標準是範例能夠編譯,而不會將 extension 方法視為抽象介面要求,並且 extension 宣告按照預期的預設方法行為表示。

由索引模型根據 Issue 內容生成。

描述

If you have a protocol which has a default method implemented in an extension, the generated code will fail to compile because the Java compiler will complain about the extracted interface "is not abstract and does not override abstract method".

Consider the following

protocol MyProtocol {}

extension MyProtocol {
  public func myDefaultMethod() {}
}

will fail with:

error: MyProtocol is not abstract and does not override abstract method myDefaultMethod() in MyProtocol

Instead we should not generate any methods, variables and initializers defined in extensions as part of the extracted interface. But we could generate them as default methods instead. This means we need to change the analysis phase to know what decls are defined in an extension and which come from the protocol requirements themselves.

主要語言
Swift
星號
1.3k
分支
127
平均合併
2 天 14 小時
30 天內合併 PR
5

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

swiftlang/swift-java 的其他 Issue

查看 swiftlang/swift-java 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。