swiftlang / swift

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

Assertion failed: (!hasAccess() && "access already set") #75713

Open JaapWijnen opened 2 months ago

JaapWijnen commented 2 months ago

Description

Very similar code (but different) to https://github.com/swiftlang/swift/issues/75711 but a different crash and backtrace

Reproduction

import _Differentiation

struct Wrapper<T> {
    var value: T

    func read() -> T {
        return value
    }
}

extension Wrapper: Differentiable where T: Differentiable {
    @derivative(of: read)
    func read() -> (value: T, pullback: (T.TangentVector) -> TangentVector) {
        let value = self.value
        func pullback(_ v: T.TangentVector) -> TangentVector {
            TangentVector(value: .zero)
        }
        return (value: value, pullback: pullback)
    }
}

protocol WrapperProtocol<T>: Differentiable where T: Differentiable {
    associatedtype T

    @differentiable(reverse)
    func read() -> T
}

extension Wrapper: WrapperProtocol where U: Differentiable {
    typealias U = T
}

Stack dump

Building for debugging...
error: emit-module command failed due to signal 6 (use -v to see invocation)
error: compile command failed due to signal 6 (use -v to see invocation)
Assertion failed: (!hasAccess() && "access already set"), function setAccess, file Decl.h, line 3034.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-08-05-a.xctoolchain/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Users/jaap/Developer/variadicCrasher/Sources/variadicCrasher/main.swift -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -I /Users/jaap/Developer/variadicCrasher/.build/arm64-apple-macosx/debug/Modules -I /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /Users/jaap/Developer/variadicCrasher/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -entry-point-function-name variadicCrasher_main -empty-abi-descriptor -Xcc -working-directory -Xcc /Users/jaap/Developer/variadicCrasher -resource-dir /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-08-05-a.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/jaap/Developer/variadicCrasher -Xcc -isysroot -Xcc /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -Xcc -F -Xcc /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -Xcc -g -module-name variadicCrasher -package-name variadiccrasher -in-process-plugin-server-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-08-05-a.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-08-05-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-08-05-a.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 15.0 -target-sdk-name macosx15.0 -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -emit-module-doc-path /Users/jaap/Developer/variadicCrasher/.build/arm64-apple-macosx/debug/Modules/variadicCrasher.swiftdoc -emit-module-source-info-path /Users/jaap/Developer/variadicCrasher/.build/arm64-apple-macosx/debug/Modules/variadicCrasher.swiftsourceinfo -emit-dependencies-path /Users/jaap/Developer/variadicCrasher/.build/arm64-apple-macosx/debug/variadicCrasher.build/variadicCrasher.emit-module.d -o /Users/jaap/Developer/variadicCrasher/.build/arm64-apple-macosx/debug/Modules/variadicCrasher.swiftmodule -emit-abi-descriptor-path /Users/jaap/Developer/variadicCrasher/.build/arm64-apple-macosx/debug/Modules/variadicCrasher.abi.json
1.  Apple Swift version 6.0-dev (LLVM 2fec3215a5e087f, Swift d4339198dcfd073)
2.  Compiling with effective version 5.10
3.  While evaluating request TypeCheckSourceFileRequest(source_file "/Users/jaap/Developer/variadicCrasher/Sources/variadicCrasher/main.swift")
4.  While type-checking extension of Wrapper (at /Users/jaap/Developer/variadicCrasher/Sources/variadicCrasher/main.swift:11:1)
5.  While type-checking 'read()' (at /Users/jaap/Developer/variadicCrasher/Sources/variadicCrasher/main.swift:13:5)
6.  While evaluating request LookupConformanceInModuleRequest(looking up conformance to variadicCrasher.(file).WrapperProtocol@/Users/jaap/Developer/variadicCrasher/Sources/variadicCrasher/main.swift:22:10 for Wrapper<T>)
7.  While evaluating request GenericSignatureRequest(extension of Wrapper@/Users/jaap/Developer/variadicCrasher/Sources/variadicCrasher/main.swift:29:1)
8.  While evaluating request InferredGenericSignatureRequest(<T where T : Copyable, T : Escapable>, (null), extension of Wrapper@/Users/jaap/Developer/variadicCrasher/Sources/variadicCrasher/main.swift:29:1, {}, {}, , 1, 1)
9.  While evaluating request RequirementRequest(extension of Wrapper@/Users/jaap/Developer/variadicCrasher/Sources/variadicCrasher/main.swift:29:1, 0, structural)
10. While evaluating request ResolveTypeRequest(while resolving type , U)
11. While evaluating request UnqualifiedLookupRequest(looking up 'U' from 0x12805b658 ExtensionDecl line=29 base=Wrapper with options { TypeLookup })
12. While evaluating request QualifiedLookupRequest(0x12805b658 ExtensionDecl line=29 base=Wrapper, {variadicCrasher.(file).Wrapper@/Users/jaap/Developer/variadicCrasher/Sources/variadicCrasher/main.swift:3:8}, 'U', { NL_RemoveNonVisible, NL_RemoveOverridden, NL_OnlyTypes })
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000105edc800 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000105edafcc llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000105edce48 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x00000001828e3584 _sigtramp + 56
4  libsystem_pthread.dylib  0x00000001828b2c20 pthread_kill + 288
5  libsystem_c.dylib        0x00000001827bfa30 abort + 180
6  libsystem_c.dylib        0x00000001827bed20 err + 0
7  swift-frontend           0x000000010641c010 swift::SetterAccessLevelRequest::evaluate(swift::Evaluator&, swift::AbstractStorageDecl*) const (.cold.1) + 0
8  swift-frontend           0x0000000101f7bac8 swift::AccessLevelRequest::cacheResult(swift::AccessLevel) const + 72
9  swift-frontend           0x00000001020c2370 swift::ValueDecl::getFormalAccess() const + 120
10 swift-frontend           0x00000001020c2d74 checkAccess(swift::DeclContext const*, swift::ValueDecl const*, bool, bool, llvm::function_ref<swift::AccessLevel ()>) + 192
11 swift-frontend           0x00000001020c2ca8 swift::ValueDecl::isAccessibleFrom(swift::DeclContext const*, bool, bool) const + 44
12 swift-frontend           0x00000001022529e4 isAcceptableLookupResult(swift::DeclContext const*, swift::NLOptions, swift::ValueDecl*, bool) + 272
13 swift-frontend           0x00000001022524a0 swift::QualifiedLookupRequest::evaluate(swift::Evaluator&, swift::DeclContext const*, llvm::SmallVector<swift::NominalTypeDecl*, 4u>, swift::DeclNameRef, swift::NLOptions) const + 1100
14 swift-frontend           0x000000010226e92c swift::SimpleRequest<swift::QualifiedLookupRequest, llvm::SmallVector<swift::ValueDecl*, 4u> (swift::DeclContext const*, llvm::SmallVector<swift::NominalTypeDecl*, 4u>, swift::DeclNameRef, swift::NLOptions), (swift::RequestFlags)1>::evaluateRequest(swift::QualifiedLookupRequest const&, swift::Evaluator&) + 132
15 swift-frontend           0x0000000102266940 swift::QualifiedLookupRequest::OutputType swift::Evaluator::getResultUncached<swift::QualifiedLookupRequest, swift::QualifiedLookupRequest::OutputType swift::evaluateOrDefault<swift::QualifiedLookupRequest>(swift::Evaluator&, swift::QualifiedLookupRequest, swift::QualifiedLookupRequest::OutputType)::'lambda'()>(swift::QualifiedLookupRequest const&, swift::QualifiedLookupRequest::OutputType swift::evaluateOrDefault<swift::QualifiedLookupRequest>(swift::Evaluator&, swift::QualifiedLookupRequest, swift::QualifiedLookupRequest::OutputType)::'lambda'()) + 352
16 swift-frontend           0x0000000102251ffc swift::QualifiedLookupRequest::OutputType swift::evaluateOrDefault<swift::QualifiedLookupRequest>(swift::Evaluator&, swift::QualifiedLookupRequest, swift::QualifiedLookupRequest::OutputType) + 176
17 swift-frontend           0x0000000102251ea8 swift::DeclContext::lookupQualified(llvm::ArrayRef<swift::NominalTypeDecl*>, swift::DeclNameRef, swift::SourceLoc, swift::NLOptions, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 268
18 swift-frontend           0x000000010235556c (anonymous namespace)::ASTScopeDeclConsumerForUnqualifiedLookup::lookInMembers(swift::DeclContext const*) const + 576
19 swift-frontend           0x00000001020402dc swift::ast_scope::ASTScopeImpl::lookup(swift::NullablePtr<swift::ast_scope::ASTScopeImpl const>, swift::NullablePtr<swift::GenericParamList const>, swift::namelookup::AbstractASTScopeDeclConsumer&) const + 272
20 swift-frontend           0x0000000102354430 swift::UnqualifiedLookupRequest::evaluate(swift::Evaluator&, swift::UnqualifiedLookupDescriptor) const + 704
21 swift-frontend           0x000000010226e9cc swift::SimpleRequest<swift::UnqualifiedLookupRequest, swift::LookupResult (swift::UnqualifiedLookupDescriptor), (swift::RequestFlags)33>::evaluateRequest(swift::UnqualifiedLookupRequest const&, swift::Evaluator&) + 44
22 swift-frontend           0x0000000101a568f0 swift::UnqualifiedLookupRequest::OutputType swift::Evaluator::getResultUncached<swift::UnqualifiedLookupRequest, swift::UnqualifiedLookupRequest::OutputType swift::evaluateOrDefault<swift::UnqualifiedLookupRequest>(swift::Evaluator&, swift::UnqualifiedLookupRequest, swift::UnqualifiedLookupRequest::OutputType)::'lambda'()>(swift::UnqualifiedLookupRequest const&, swift::UnqualifiedLookupRequest::OutputType swift::evaluateOrDefault<swift::UnqualifiedLookupRequest>(swift::Evaluator&, swift::UnqualifiedLookupRequest, swift::UnqualifiedLookupRequest::OutputType)::'lambda'()) + 272
23 swift-frontend           0x0000000101a56788 swift::UnqualifiedLookupRequest::OutputType swift::evaluateOrDefault<swift::UnqualifiedLookupRequest>(swift::Evaluator&, swift::UnqualifiedLookupRequest, swift::UnqualifiedLookupRequest::OutputType) + 196
24 swift-frontend           0x0000000101d863ec swift::TypeChecker::lookupUnqualifiedType(swift::DeclContext*, swift::DeclNameRef, swift::SourceLoc, swift::optionset::OptionSet<swift::NameLookupFlags, unsigned int>) + 204
25 swift-frontend           0x0000000101dfb7bc (anonymous namespace)::TypeResolver::resolveDeclRefTypeReprRec(swift::DeclRefTypeRepr*, swift::TypeResolutionOptions) + 816
26 swift-frontend           0x0000000101def9b4 (anonymous namespace)::TypeResolver::resolveType(swift::TypeRepr*, swift::TypeResolutionOptions) + 300
27 swift-frontend           0x0000000101dee69c evaluateTypeResolution(swift::TypeResolution const*, swift::TypeRepr*, swift::SILTypeResolutionContext*) + 88
28 swift-frontend           0x0000000101e03f7c swift::ResolveTypeRequest::OutputType swift::Evaluator::getResultUncached<swift::ResolveTypeRequest, swift::ResolveTypeRequest::OutputType swift::evaluateOrDefault<swift::ResolveTypeRequest>(swift::Evaluator&, swift::ResolveTypeRequest, swift::ResolveTypeRequest::OutputType)::'lambda'()>(swift::ResolveTypeRequest const&, swift::ResolveTypeRequest::OutputType swift::evaluateOrDefault<swift::ResolveTypeRequest>(swift::Evaluator&, swift::ResolveTypeRequest, swift::ResolveTypeRequest::OutputType)::'lambda'()) + 212
29 swift-frontend           0x0000000101dee624 swift::TypeResolution::resolveType(swift::TypeRepr*, swift::SILTypeResolutionContext*) const + 92
30 swift-frontend           0x0000000101d72408 swift::RequirementRequest::evaluate(swift::Evaluator&, swift::WhereClauseOwner, unsigned int, swift::TypeResolutionStage) const + 300
31 swift-frontend           0x000000010233e80c swift::RequirementRequest::OutputType swift::Evaluator::getResultUncached<swift::RequirementRequest, swift::WhereClauseOwner::visitRequirements(swift::TypeResolutionStage, llvm::function_ref<bool (swift::Requirement, swift::RequirementRepr*)>) const &&::$_0>(swift::RequirementRequest const&, swift::WhereClauseOwner::visitRequirements(swift::TypeResolutionStage, llvm::function_ref<bool (swift::Requirement, swift::RequirementRepr*)>) const &&::$_0) + 292
32 swift-frontend           0x00000001023364a0 swift::WhereClauseOwner::visitRequirements(swift::TypeResolutionStage, llvm::function_ref<bool (swift::Requirement, swift::RequirementRepr*)>) const && + 156
33 swift-frontend           0x00000001022dc1a4 swift::InferredGenericSignatureRequest::evaluate(swift::Evaluator&, swift::GenericSignatureImpl const*, swift::GenericParamList*, swift::WhereClauseOwner, llvm::SmallVector<swift::Requirement, 2u>, llvm::SmallVector<swift::TypeBase*, 2u>, swift::SourceLoc, bool, bool) const + 856
34 swift-frontend           0x0000000101dc06f0 llvm::PointerIntPair<swift::GenericSignature, 3u, swift::optionset::OptionSet<swift::GenericSignatureErrorFlags, unsigned int>, llvm::PointerLikeTypeTraits<swift::GenericSignature>, llvm::PointerIntPairInfo<swift::GenericSignature, 3u, llvm::PointerLikeTypeTraits<swift::GenericSignature>>> swift::SimpleRequest<swift::InferredGenericSignatureRequest, llvm::PointerIntPair<swift::GenericSignature, 3u, swift::optionset::OptionSet<swift::GenericSignatureErrorFlags, unsigned int>, llvm::PointerLikeTypeTraits<swift::GenericSignature>, llvm::PointerIntPairInfo<swift::GenericSignature, 3u, llvm::PointerLikeTypeTraits<swift::GenericSignature>>> (swift::GenericSignatureImpl const*, swift::GenericParamList*, swift::WhereClauseOwner, llvm::SmallVector<swift::Requirement, 2u>, llvm::SmallVector<swift::TypeBase*, 2u>, swift::SourceLoc, bool, bool), (swift::RequestFlags)1>::callDerived<0ul, 1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul, 6ul, 7ul>) const + 196
35 swift-frontend           0x0000000101caae2c swift::InferredGenericSignatureRequest::OutputType swift::Evaluator::getResultUncached<swift::InferredGenericSignatureRequest, swift::InferredGenericSignatureRequest::OutputType swift::evaluateOrDefault<swift::InferredGenericSignatureRequest>(swift::Evaluator&, swift::InferredGenericSignatureRequest, swift::InferredGenericSignatureRequest::OutputType)::'lambda'()>(swift::InferredGenericSignatureRequest const&, swift::InferredGenericSignatureRequest::OutputType swift::evaluateOrDefault<swift::InferredGenericSignatureRequest>(swift::Evaluator&, swift::InferredGenericSignatureRequest, swift::InferredGenericSignatureRequest::OutputType)::'lambda'()) + 196
36 swift-frontend           0x0000000101d707a8 swift::GenericSignatureRequest::evaluate(swift::Evaluator&, swift::GenericContext*) const + 2104
37 swift-frontend           0x00000001020b86dc swift::GenericContext::getGenericSignature() const + 528
38 swift-frontend           0x0000000102350fc4 swift::TypeBase::getContextSubstitutionMap(swift::DeclContext const*, swift::GenericEnvironment*) + 120
39 swift-frontend           0x00000001020a6038 swift::LookupConformanceInModuleRequest::evaluate(swift::Evaluator&, swift::LookupConformanceDescriptor) const + 3180
40 swift-frontend           0x00000001020a7fe8 swift::LookupConformanceInModuleRequest::OutputType swift::Evaluator::getResultUncached<swift::LookupConformanceInModuleRequest, swift::LookupConformanceInModuleRequest::OutputType swift::evaluateOrDefault<swift::LookupConformanceInModuleRequest>(swift::Evaluator&, swift::LookupConformanceInModuleRequest, swift::LookupConformanceInModuleRequest::OutputType)::'lambda'()>(swift::LookupConformanceInModuleRequest const&, swift::LookupConformanceInModuleRequest::OutputType swift::evaluateOrDefault<swift::LookupConformanceInModuleRequest>(swift::Evaluator&, swift::LookupConformanceInModuleRequest, swift::LookupConformanceInModuleRequest::OutputType)::'lambda'()) + 212
41 swift-frontend           0x00000001020a4a88 swift::ModuleDecl::lookupConformance(swift::Type, swift::ProtocolDecl*, bool) + 276
42 swift-frontend           0x0000000101d86090 (anonymous namespace)::LookupResultBuilder::add(swift::ValueDecl*, swift::DeclContext*, swift::ValueDecl*, swift::Type, bool) + 476
43 swift-frontend           0x0000000101d86608 swift::TypeChecker::lookupMember(swift::DeclContext*, swift::Type, swift::DeclNameRef, swift::SourceLoc, swift::optionset::OptionSet<swift::NameLookupFlags, unsigned int>) + 356
44 swift-frontend           0x0000000101c8b6e8 findAutoDiffOriginalFunctionDecl(swift::DeclAttribute*, swift::Type, swift::DeclNameRefWithLoc const&, swift::DeclContext*, swift::optionset::OptionSet<swift::NameLookupFlags, unsigned int>, llvm::function_ref<std::__1::optional<AbstractFunctionDeclLookupErrorKind> (swift::AbstractFunctionDecl*)> const&, swift::AnyFunctionType*) + 188
45 swift-frontend           0x0000000101c865a0 typeCheckDerivativeAttr(swift::DerivativeAttr*) + 2092
46 swift-frontend           0x0000000101c71a78 swift::TypeChecker::checkDeclAttributes(swift::Decl*) + 10544
47 swift-frontend           0x0000000101d43290 (anonymous namespace)::DeclChecker::visitFuncDecl(swift::FuncDecl*) + 176
48 swift-frontend           0x0000000101d38c94 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 368
49 swift-frontend           0x0000000101d45200 (anonymous namespace)::DeclChecker::visitExtensionDecl(swift::ExtensionDecl*) + 5716
50 swift-frontend           0x0000000101d398f0 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 3532
51 swift-frontend           0x0000000101d38b10 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 136
52 swift-frontend           0x0000000101e053a4 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 176
53 swift-frontend           0x0000000101e06e58 swift::TypeCheckSourceFileRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()>(swift::TypeCheckSourceFileRequest const&, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()) + 232
54 swift-frontend           0x0000000101e052cc swift::performTypeChecking(swift::SourceFile&) + 84
55 swift-frontend           0x0000000100c7bf08 bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_8>(long, swift::SourceFile&) + 16
56 swift-frontend           0x0000000100c75120 swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) + 156
57 swift-frontend           0x0000000100c75064 swift::CompilerInstance::performSema() + 76
58 swift-frontend           0x0000000100a3bea0 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 60
59 swift-frontend           0x0000000100a31b64 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 716
60 swift-frontend           0x0000000100a31230 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2332
61 swift-frontend           0x000000010081ef84 swift::mainEntry(int, char const**) + 3096
62 dyld                     0x000000018252a0e0 start + 2360

Expected behavior

To either provide a diagnostic or compile successfully

Environment

Apple Swift version 6.0-dev (LLVM 2fec3215a5e087f, Swift d4339198dcfd073) Target: arm64-apple-macosx14.0

Additional information

No response

JaapWijnen commented 2 months ago

tagging @asl

asl commented 2 months ago

Tagging @slavapestov Maybe the underlying issue is same as in https://github.com/swiftlang/swift/issues/75711

AnthonyLatsis commented 2 months ago

This is a different issue. Reduction:

protocol P {}

struct G<T> {}
extension G where A: P {
  typealias A = T
}
slavapestov commented 2 months ago

It's a request cycle:

===CYCLE DETECTED===
 `--TypeCheckSourceFileRequest(source_file "/Users/spestov/src/swift/x.swift")
     `--GenericSignatureRequest(extension of G@/Users/spestov/src/swift/x.swift:4:1)
         `--InferredGenericSignatureRequest(<T where T : Copyable, T : Escapable>, (null), extension of G@/Users/spestov/src/swift/x.swift:4:1, {}, {}, , 1, 1)
             `--RequirementRequest(extension of G@/Users/spestov/src/swift/x.swift:4:1, 0, structural)
                 `--ResolveTypeRequest(while resolving type , A)
                     `--UnqualifiedLookupRequest(looking up 'A' from 0x1380a8f20 ExtensionDecl line=4 base=G with options { TypeLookup })
                         `--QualifiedLookupRequest(0x1380a8f20 ExtensionDecl line=4 base=G, {x.(file).G@/Users/spestov/src/swift/x.swift:3:8}, 'A', { NL_RemoveNonVisible, NL_RemoveOverridden, NL_OnlyTypes })
                             `--AccessLevelRequest(x.(file).G extension.A@/Users/spestov/src/swift/x.swift:5:13)
                                 `--DefaultAndMaxAccessLevelRequest(extension of G@/Users/spestov/src/swift/x.swift:4:1)
                                     `--TypeDeclsFromWhereClauseRequest(extension of G@/Users/spestov/src/swift/x.swift:4:1)
                                         `--UnqualifiedLookupRequest(looking up 'A' from 0x1380a8f20 ExtensionDecl line=4 base=G with options { AllowProtocolMembers, TypeLookup })
                                             `--QualifiedLookupRequest(0x1380a8f20 ExtensionDecl line=4 base=G, {x.(file).G@/Users/spestov/src/swift/x.swift:3:8}, 'A', { NL_ProtocolMembers, NL_RemoveNonVisible, NL_RemoveOverridden, NL_OnlyTypes })
                                                 `--AccessLevelRequest(x.(file).G extension.A@/Users/spestov/src/swift/x.swift:5:13) (cyclic dependency)

We should reject the reference to A from the where clause, I think.