swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.6k stars 10.37k forks source link

Removing `throws(E)` type from a declaration in one module breaks incremental compilation #77296

Open NachoSoto opened 2 weeks ago

NachoSoto commented 2 weeks ago

Reproduction

// Module 1
public struct E1: Error {}
public func f1() throws(E1) {}

// Module 2
import Module1 

func f2() throws {
  f1()
}

Changing public func f1() throws(E1) {} to public func f1() throws {} (or doing the reverse) leads to a linking failure:

Undefined symbol: Module1.f() throws(Module1.E1)

Expected behavior

The compiler handles the modification.

Environment

swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0
NachoSoto commented 2 weeks ago

This is just one very specific example, but this happens incredibly often when changing declarations referenced across modules.