Skip to content

Reference to invalid type alias when using same type requirement, plus a cohabiting class in the same scope #81683

Open
@tayloraswift

Description

@tayloraswift

Description

the following example produces the error Reference to invalid type alias 'Snapshot' of type 'PluginBundleCache' on 6.0.3, and on main

the nested class D seems to be the trigger for the compiler bug, relocating it after the f(_:) witness, instead of before, inexplicably resolves the error.

Reproduction

class C<T> {
    init() {}
}

protocol P<ObjectEntry>: Sendable {
    associatedtype ObjectEntry
    associatedtype Object

    typealias Snapshot = C<ObjectEntry>

    func f(_: Snapshot)
}
protocol Q<Object>: P where Object == ObjectEntry {
}

final class PluginBundleCache: Q {
    typealias Object = Int

    class D: Snapshot {}

    func f(_: Snapshot) {}
}

Expected behavior

it should typecheck successfully

Environment

% swift --version
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions