Skip to content

Instantly share code, notes, and snippets.

@tgrapperon
Last active August 15, 2022 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgrapperon/977f0406f67c417a4730a8640ab50526 to your computer and use it in GitHub Desktop.
Save tgrapperon/977f0406f67c417a4730a8640ab50526 to your computer and use it in GitHub Desktop.

FB11244375: Xcode shows an error message when importing a module that declares a typealias to a protocol with a primary associated type

Description

Xcode 14beta5 shows a message stating that "An internal error occurred. Source editor functionality is limited. Attempting to restore..." when importing a module that declare a typealias to a protocol with a primary associated type (and where the alias specifies the primary associated type, generically or not). To reproduce, create a SwiftPM package with two modules A and B having A as a dependency. In the module A, declare:

public protocol Foo<Bar> {
  associatedtype Bar
}
public typealias Problem = Foo<String>

In the module B, import A, and then start to type struct Hello {}:

import A
str // The error message appears

It builds after completing the declaration, but it shows an error message at the top of the editor. I'm attaching a zip of such package where you can reproduce by by starting editing the EditThis.swift file! The issue started to occur in Xcode 14.0 beta 4. There is no issue when using Xcode 14.0 beta 3. It seems to be mostly triggered by starting to write top-level declarations or enums cases. This is likely related to https://github.com/pointfreeco/swift-composable-architecture/discussions/1264. Associated Swift bug report, in any case it comes from Swift itself: https://github.com/apple/swift/issues/60550.

Environment

macOS 13.0 beta 5 (22A5321d) Xcode 4.0 beta 5 (14A5294e)


For some reason, I can't attach the zip archive of the package to this gist. It can be retrieved here or here.

ErrorMessage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment