Skip to content

[SE-0101] Migration support fix-it #3883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 30, 2016

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jul 30, 2016

What's in this pull request?

Split from #3854
Implement migration support fix-it for SE-0101

error: 'sizeof' is unavailable: use MemoryLayout<T>.size instead.
  _ = sizeof(C.self)
      ^~~~~~~ ~~~~~~
      MemoryLayout< >.size

Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

A smoke test on macOS does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library only for macOS. Simulator standard libraries and
    device standard libraries are not built.
  3. lldb is not built.
  4. The test and validation-test targets are run only for macOS. The optimized
    version of these tests are not run.

A smoke test on Linux does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library incrementally.
  3. lldb is built incrementally.
  4. The swift test and validation-test targets are run. The optimized version of these
    tests are not run.
  5. lldb is tested.

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

@gribozavr
Copy link
Contributor

@rintaro Thank you!


_ = sizeofValue(x) // expected-error {{'sizeofValue' is unavailable: use MemoryLayout<T>.size instead.}} {{7-21=MemoryLayout<Cse0101<P>>.size}} {{none}}
_ = alignofValue(x.val) // expected-error {{'alignofValue' is unavailable: use MemoryLayout<T>.alignment instead.}} {{7-26=MemoryLayout<P>.alignment}} {{none}}
_ = strideofValue(x.val.getIt()) // expected-error {{'strideofValue' is unavailable: use MemoryLayout<T>.stride instead.}} {{7-35=MemoryLayout<P.Value>.stride}} {{none}}
Copy link
Member Author

@rintaro rintaro Jul 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strideofValue(x.val.getIt()) => MemoryLayout<P.Value>.stride
Do we need preserve x.val.getIt()?
i.e. (MemoryLayout<P.Value>.stride, x.val.getIt()).0

@rintaro
Copy link
Member Author

rintaro commented Jul 30, 2016

One more TODO Done: we need special treatment for let x: Int = 1; sizeof(x.dynamicType)
We can't MemoryLayout<x.dynamicType>.size.
Since that is equivalent to sizeofValue(x), we should replace it to MemoryLayout<Int>.size

@rintaro
Copy link
Member Author

rintaro commented Jul 30, 2016

func _func<C: Collection>(c: C)  where C.Index == Int {
  _ = sizeof(C)
  _ = sizeof(C.self)
  _ = sizeof(C.Iterator.self)
  _ = sizeof(c.dynamicType)
  _ = sizeofValue(c)
  _ = sizeofValue(c[0])
}

result

test0101.swift:2:14: warning: missing '.self' for reference to metatype of type 'C'
  _ = sizeof(C)
             ^
              .self
test0101.swift:2:7: error: 'sizeof' is unavailable: use MemoryLayout<T>.size instead.
  _ = sizeof(C)
      ^~~~~~~ ~
      MemoryLayout< >.size
test0101.swift:3:7: error: 'sizeof' is unavailable: use MemoryLayout<T>.size instead.
  _ = sizeof(C.self)
      ^~~~~~~ ~~~~~~
      MemoryLayout< >.size
test0101.swift:4:7: error: 'sizeof' is unavailable: use MemoryLayout<T>.size instead.
  _ = sizeof(C.Iterator.self)
      ^~~~~~~          ~~~~~~
      MemoryLayout<    >.size
test0101.swift:5:7: error: 'sizeof' is unavailable: use MemoryLayout<T>.size instead.
  _ = sizeof(c.dynamicType)
      ^~~~~~~~~~~~~~~~~~~~~
      MemoryLayout<C>.size
test0101.swift:6:7: error: 'sizeofValue' is unavailable: use MemoryLayout<T>.size instead.
  _ = sizeofValue(c)
      ^~~~~~~~~~~~~~
      MemoryLayout<C>.size
test0101.swift:7:7: error: 'sizeofValue' is unavailable: use MemoryLayout<T>.size instead.
  _ = sizeofValue(c[0])
      ^~~~~~~~~~~~~~~~~
      MemoryLayout<C.Iterator.Element>.size

@gribozavr
Copy link
Contributor

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Jul 30, 2016

/home/buildnode/jenkins/workspace/swift-PR-Linux/swift/test/expr/expressions.swift:894:15: error: unexpected warning produced: '.dynamicType' is deprecated. Use 'type(of: ...)' instead
  _ = sizeof(x.dynamicType) // expected-error {{'sizeof' is unavailable: use MemoryLayout<T>.size instead.}} {{7-28=MemoryLayout<Cse0101<P>>.size}} {{none}}
              ^

Need to rebase on #3878 (and #3885).

@gribozavr
Copy link
Contributor

@rintaro Would you mind rebasing? Thanks!

@rintaro rintaro force-pushed the SE-0101-migration-fixit branch from 38887d9 to fd4ddd6 Compare July 30, 2016 09:24
@rintaro
Copy link
Member Author

rintaro commented Jul 30, 2016

@swift-ci Please smoke test

@rintaro rintaro changed the title [WIP][SE-0101] Migration support fix-it [SE-0101] Migration support fix-it Jul 30, 2016
@gribozavr
Copy link
Contributor

@rudkx Would you mind reviewing the updated migration code?

@rintaro rintaro mentioned this pull request Jul 30, 2016
1 task
@rudkx
Copy link
Contributor

rudkx commented Jul 30, 2016

LGTM!

@gribozavr gribozavr merged commit aee7a8b into swiftlang:master Jul 30, 2016
@rintaro rintaro deleted the SE-0101-migration-fixit branch August 6, 2016 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants