lionheart / openradar-mirror

A mirror of radars pulled from http://openradar.me/.
245 stars 17 forks source link

25799364: Passing [NSObject] to a function expecting [Any] causes a run-time exception rather than compile time error #14549

Open openradar-mirror opened 8 years ago

openradar-mirror commented 8 years ago

Description

Summary:

Enter the following code into a playground and observe the runtime exception:

func process(anArray : [Any]) {

}

let a = [1,2,[3],[4,[5,6]],[[7]], 8]

process(a)

the type inferred for 'a' is [NSObject] which results in: "fatal error: array cannot be bridged from Objective-C"

Steps to Reproduce:

  1. Xcode 7.3
  2. Open a playground
  3. Enter the code in the description
  4. Reveal the "debug area"
  5. Observe the runtime exception.

Expected Results: The compiler should generate a compile type error for incompatible types i.e. '[NSObject]' cannot be passed to a function expecting '[Any]'

Actual Results: Runtime exception - "fatal error: array cannot be bridged from Objective-C"

Version: Xcode 7.3 (7D175), OS X 10.11.4 (15E65)

Product Version: Xcode 7.3 (7D175) Created: 2016-04-19T10:20:58.248840 Originated: 2016-04-19T00:00:00 Open Radar Link: http://www.openradar.me/25799364

openradar-mirror commented 8 years ago

Modified: 2016-04-19T10:20:58.249030