apple / swift-nio

Event-driven network application framework for high performance protocol servers & clients, non-blocking.
https://swiftpackageindex.com/apple/swift-nio/documentation
Apache License 2.0
7.98k stars 650 forks source link

Unable to build with Swift 4.2 #418

Closed mura-admin closed 6 years ago

mura-admin commented 6 years ago

Expected behavior

To build successfully in Xcode

Actual behavior

Hit a Swift 4.2 bug/error: Assertion failed: ((allowTypeAliasXRef || !isa(D) || D->getModuleContext() == M) && "cannot cross-reference typealiases directly (use the NameAliasType)"), function addDeclRef, file /Users/buildnode/jenkins/workspace/oss-swift-4.2-package-osx/swift/lib/Serialization/Serialization.cpp, line 614.

I understand this is related to a compiler bug: https://bugs.swift.org/browse/SR-6963. Is there a workaround for this in the meantime?

Steps to reproduce

  1. Install the latest Swift 4.2 toolchain and attempt to build in Xcode

SwiftNIO version/commit hash

?

Swift & OS version (output of swift --version && uname -a)

Latest MacOS and Swift 4.2 beta

Lukasa commented 6 years ago

What line in our source code hits this?

mura-admin commented 6 years ago

The compiler hits an assertion and doesn't appear to give any further info as to the source. From a comment in the swift compiler bug report it suggests that it originates from this pull request: https://github.com/apple/swift-nio/pull/374.

Lukasa commented 6 years ago

Let me see if I can reproduce with the most recent 4.2 toolchain from swift.org.

Lukasa commented 6 years ago

Him, I haven't been able to successfully work around this. I can definitely reproduce it, but haven't successfully worked around it. I'll take in @weissi on Monday.

weissi commented 6 years ago

@mura-admin Thanks for reporting! @mura-admin / @Lukasa yes, that's a known Swift 4.2 bug and I contacted the Swift team, it'll be fixed very soon. It's this bug: https://bugs.swift.org/browse/SR-6963 . There's a workaround that I'll put in if not fixed early next week because it's annoying.

weissi commented 6 years ago

@mura-admin sorry, should've read the whole bug report. I think this might work as a workaround:

public typealias RangeType<T> = Range<T>

in the two places where currently we have

public typealias RangeType = Range

Let me check if that works, just need to switch machines.

Lukasa commented 6 years ago

I tried that, and was unable to get that to work.

weissi commented 6 years ago

@mura-admin / @Lukasa this works: https://github.com/apple/swift-nio/pull/420