Skip to content

[SR-2737] SwiftFoundation builds with warnings about coercion/force-unwrap #4328

Closed
@swift-ci

Description

@swift-ci
Previous ID SR-2737
Radar None
Original Reporter willstanton1@yahoo.com (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Linux

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, BuildScript, StarterBug
Assignee willstanton1@yahoo.com (JIRA)
Priority Medium

md5: 785f14eb633940d26fb28686494adb86

Issue Description:

A/multiple❓ (new, I believe) diagnostic(s) checked in (a couple days ago?) seems to be causing warnings when building Foundation on Linux. Warnings in:
NSHTTPCookie.swift
URLRequest.swift
TimeZone.swift

Warnings are like:
warning: expression implicitly coerced from 'Any?' to Any
and:
note: force-unwrap the value to avoid this warning
warning: expression implicitly coerced from 'String?' to Any

Warning happens in CI too :-)
https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04/lastBuild/consoleFull

[46/149] CompileSwift: Foundation/NSHTTPCookie.swift
Foundation/NSHTTPCookie.swift:324:35: warning: expression implicitly coerced from 'Any?' to Any
_properties = [.comment : properties[.comment],
^~~~~~~~~~~~~~~~~~~~
Foundation/NSHTTPCookie.swift:324:45: note: provide a default value to avoid this warning
_properties = [.comment : properties[.comment],
~~~~~~~~~^~~~~~~~~
?? <#default value#>
Foundation/NSHTTPCookie.swift:324:45: note: force-unwrap the value to avoid this warning
_properties = [.comment : properties[.comment],
~~~~~~~~~^~~~~~~~~
!
Foundation/NSHTTPCookie.swift:324:45: note: explicitly cast to Any with 'as Any' to silence this warning
_properties = [.comment : properties[.comment],
~~~~~~~~~^~~~~~~~~
as Any
Foundation/NSHTTPCookie.swift:325:38: warning: expression implicitly coerced from 'Any?' to Any
.commentURL : properties[.commentURL],
^~~~~~~~~~~~~~~~~~~~~~~
Foundation/NSHTTPCookie.swift:325:48: note: provide a default value to avoid this warning
.commentURL : properties[.commentURL],
~~~~~~~~~^~~~~~~~~~~~
?? <#default value#>
Foundation/NSHTTPCookie.swift:325:48: note: force-unwrap the value to avoid this warning
.commentURL : properties[.commentURL],
~~~~~~~~~^~~~~~~~~~~~
!
Foundation/NSHTTPCookie.swift:325:48: note: explicitly cast to Any with 'as Any' to silence this warning
.commentURL : properties[.commentURL],
~~~~~~~~~^~~~~~~~~~~~
as Any
Foundation/NSHTTPCookie.swift:329:35: warning: expression implicitly coerced from 'Date?' to Any
.expires : _expiresDate,
^~~~~~~~~~~~
Foundation/NSHTTPCookie.swift:329:35: note: provide a default value to avoid this warning
.expires : _expiresDate,
^~~~~~~~~~~~
?? <#default value#>
Foundation/NSHTTPCookie.swift:329:35: note: force-unwrap the value to avoid this warning
.expires : _expiresDate,
^~~~~~~~~~~~
!
Foundation/NSHTTPCookie.swift:329:35: note: explicitly cast to Any with 'as Any' to silence this warning
.expires : _expiresDate,
^~~~~~~~~~~~
as Any
Foundation/NSHTTPCookie.swift:330:38: warning: expression implicitly coerced from 'Any?' to Any
.maximumAge : properties[.maximumAge],
^~~~~~~~~~~~~~~~~~~~~~~
Foundation/NSHTTPCookie.swift:330:48: note: provide a default value to avoid this warning
.maximumAge : properties[.maximumAge],
~~~~~~~~~^~~~~~~~~~~~
?? <#default value#>
Foundation/NSHTTPCookie.swift:330:48: note: force-unwrap the value to avoid this warning
.maximumAge : properties[.maximumAge],
~~~~~~~~~^~~~~~~~~~~~
!
Foundation/NSHTTPCookie.swift:330:48: note: explicitly cast to Any with 'as Any' to silence this warning
.maximumAge : properties[.maximumAge],
~~~~~~~~~^~~~~~~~~~~~
as Any
Foundation/NSHTTPCookie.swift:332:37: warning: expression implicitly coerced from 'Any?' to Any
.originURL : properties[.originURL],
^~~~~~~~~~~~~~~~~~~~~~
Foundation/NSHTTPCookie.swift:332:47: note: provide a default value to avoid this warning
.originURL : properties[.originURL],
~~~~~~~~~^~~~~~~~~~~
?? <#default value#>
Foundation/NSHTTPCookie.swift:332:47: note: force-unwrap the value to avoid this warning
.originURL : properties[.originURL],
~~~~~~~~~^~~~~~~~~~~
!
Foundation/NSHTTPCookie.swift:332:47: note: explicitly cast to Any with 'as Any' to silence this warning
.originURL : properties[.originURL],
~~~~~~~~~^~~~~~~~~~~
as Any
Foundation/NSHTTPCookie.swift:334:32: warning: expression implicitly coerced from '[NSNumber]?' to Any
.port : _portList,
^~~~~~~~~
Foundation/NSHTTPCookie.swift:334:32: note: provide a default value to avoid this warning
.port : _portList,
^~~~~~~~~
?? <#default value#>
Foundation/NSHTTPCookie.swift:334:32: note: force-unwrap the value to avoid this warning
.port : _portList,
^~~~~~~~~
!
Foundation/NSHTTPCookie.swift:334:32: note: explicitly cast to Any with 'as Any' to silence this warning
.port : _portList,
^~~~~~~~~
as Any
[124/149] CompileSwift: Foundation/URLRequest.swift
Foundation/URLRequest.swift:248:40: warning: expression implicitly coerced from 'URL?' to Any
c.append((label: "url", value: url))
^~~
Foundation/URLRequest.swift:248:40: note: provide a default value to avoid this warning
c.append((label: "url", value: url))
^~~
?? <#default value#>
Foundation/URLRequest.swift:248:40: note: force-unwrap the value to avoid this warning
c.append((label: "url", value: url))
^~~
!
Foundation/URLRequest.swift:248:40: note: explicitly cast to Any with 'as Any' to silence this warning
c.append((label: "url", value: url))
^~~
as Any
Foundation/URLRequest.swift:251:52: warning: expression implicitly coerced from 'URL?' to Any
c.append((label: "mainDocumentURL", value: mainDocumentURL))
^~~~~~~~~~~~~~~
Foundation/URLRequest.swift:251:52: note: provide a default value to avoid this warning
c.append((label: "mainDocumentURL", value: mainDocumentURL))
^~~~~~~~~~~~~~~
?? <#default value#>
Foundation/URLRequest.swift:251:52: note: force-unwrap the value to avoid this warning
c.append((label: "mainDocumentURL", value: mainDocumentURL))
^~~~~~~~~~~~~~~
!
Foundation/URLRequest.swift:251:52: note: explicitly cast to Any with 'as Any' to silence this warning
c.append((label: "mainDocumentURL", value: mainDocumentURL))
^~~~~~~~~~~~~~~
as Any
Foundation/URLRequest.swift:254:47: warning: expression implicitly coerced from 'String?' to Any
c.append((label: "httpMethod", value: httpMethod))
^~~~~~~~~~
Foundation/URLRequest.swift:254:47: note: provide a default value to avoid this warning
c.append((label: "httpMethod", value: httpMethod))
^~~~~~~~~~
?? <#default value#>
Foundation/URLRequest.swift:254:47: note: force-unwrap the value to avoid this warning
c.append((label: "httpMethod", value: httpMethod))
^~~~~~~~~~
!
Foundation/URLRequest.swift:254:47: note: explicitly cast to Any with 'as Any' to silence this warning
c.append((label: "httpMethod", value: httpMethod))
^~~~~~~~~~
as Any
Foundation/URLRequest.swift:255:56: warning: expression implicitly coerced from '[String : String]?' to Any
c.append((label: "allHTTPHeaderFields", value: allHTTPHeaderFields))
^~~~~~~~~~~~~~~~~~~
Foundation/URLRequest.swift:255:56: note: provide a default value to avoid this warning
c.append((label: "allHTTPHeaderFields", value: allHTTPHeaderFields))
^~~~~~~~~~~~~~~~~~~
?? <#default value#>
Foundation/URLRequest.swift:255:56: note: force-unwrap the value to avoid this warning
c.append((label: "allHTTPHeaderFields", value: allHTTPHeaderFields))
^~~~~~~~~~~~~~~~~~~
!
Foundation/URLRequest.swift:255:56: note: explicitly cast to Any with 'as Any' to silence this warning
c.append((label: "allHTTPHeaderFields", value: allHTTPHeaderFields))
^~~~~~~~~~~~~~~~~~~
as Any
Foundation/URLRequest.swift:256:45: warning: expression implicitly coerced from 'Data?' to Any
c.append((label: "httpBody", value: httpBody))
^~~~~~~~
Foundation/URLRequest.swift:256:45: note: provide a default value to avoid this warning
c.append((label: "httpBody", value: httpBody))
^~~~~~~~
?? <#default value#>
Foundation/URLRequest.swift:256:45: note: force-unwrap the value to avoid this warning
c.append((label: "httpBody", value: httpBody))
^~~~~~~~
!
Foundation/URLRequest.swift:256:45: note: explicitly cast to Any with 'as Any' to silence this warning
c.append((label: "httpBody", value: httpBody))
^~~~~~~~
as Any
Foundation/URLRequest.swift:257:51: warning: expression implicitly coerced from 'InputStream?' to Any
c.append((label: "httpBodyStream", value: httpBodyStream))
^~~~~~~~~~~~~~
Foundation/URLRequest.swift:257:51: note: provide a default value to avoid this warning
c.append((label: "httpBodyStream", value: httpBodyStream))
^~~~~~~~~~~~~~
?? <#default value#>
Foundation/URLRequest.swift:257:51: note: force-unwrap the value to avoid this warning
c.append((label: "httpBodyStream", value: httpBodyStream))
^~~~~~~~~~~~~~
!
Foundation/URLRequest.swift:257:51: note: explicitly cast to Any with 'as Any' to silence this warning
c.append((label: "httpBodyStream", value: httpBodyStream))
^~~~~~~~~~~~~~
as Any
[126/149] CompileSwift: Foundation/URLComponents.swift
Foundation/URLComponents.swift:375:42: warning: expression implicitly coerced from 'String?' to Any
c.append((label: "value", value: value))
^~~~~
Foundation/URLComponents.swift:375:42: note: provide a default value to avoid this warning
c.append((label: "value", value: value))
^~~~~
?? <#default value#>
Foundation/URLComponents.swift:375:42: note: force-unwrap the value to avoid this warning
c.append((label: "value", value: value))
^~~~~
!
Foundation/URLComponents.swift:375:42: note: explicitly cast to Any with 'as Any' to silence this warning
c.append((label: "value", value: value))
^~~~~
as Any
[140/149] CompileSwift: Foundation/TimeZone.swift
Foundation/TimeZone.swift:239:49: warning: expression implicitly coerced from 'String?' to Any
c.append((label: "abbreviation", value: abbreviation()))
^~~~~~~~~~~~~~
Foundation/TimeZone.swift:239:49: note: provide a default value to avoid this warning
c.append((label: "abbreviation", value: abbreviation()))
^~~~~~~~~~~~~~
?? <#default value#>
Foundation/TimeZone.swift:239:49: note: force-unwrap the value to avoid this warning
c.append((label: "abbreviation", value: abbreviation()))
^~~~~~~~~~~~~~
!
Foundation/TimeZone.swift:239:49: note: explicitly cast to Any with 'as Any' to silence this warning
c.append((label: "abbreviation", value: abbreviation()))
^~~~~~~~~~~~~~
as Any
[149/149] Link: ../build/Ninja-Release...nux-x86_64/Foundation/libFoundation.so

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions