swift icon indicating copy to clipboard operation
swift copied to clipboard

[SR-286] Compiler thinks associated type with default value is undeclared

Open jepers opened this issue 10 years ago • 2 comments

Previous ID SR-286
Radar rdar://23671447
Original Reporter @jepers
Type Bug
Status Closed
Resolution Done

Environment

OS X 10.11.2, Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 69940d166c)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: ee1e6ca6cf758c07bfe9960a185ff8da

Issue Description:

protocol P { typealias A = Int }
struct X : P {} // OK
struct Y : P { var a: Y.A } // OK
struct Z : P { var a: A } // Error: Use of undeclared type 'A' (What/why?)

jepers avatar Dec 17 '15 22:12 jepers

Same result when modified for Swift 3 (tested in Xcode 8 beta 3):

protocol P { associatedtype A = Int } // A has default type Int
struct X : P {} // OK
struct Y : P { var a: Y.A } // OK
struct Z : P { var a: A } // Error: Use of undeclared type 'A' (Why?)

jepers avatar Jul 24 '16 08:07 jepers

Fixed in Swift 3.1.

slavapestov avatar Apr 23 '17 11:04 slavapestov