Skip to content

Conversation

@jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented Apr 14, 2017

  • Allow typealiases to use substitutions.
  • Consistently use 'a' as a mangling operator.
  • For generic typealiases, include the alias as context for any generic parameters.

Typealiases don't show up in symbol names, which always refer to canonical types, but they are mangled for debug info and for USRs (unique identifiers used by SourceKit), so it's good to get this right.

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple jrose-apple requested a review from akyrtzi April 14, 2017 00:42
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should add a getUnboundGenericType() to TypeDecl. You already had the same bit of code in an earlier PR today, and I've written it out in a few places also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fine with me. Does it return UnboundGenericType, or just Type to handle the non-generic case?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the latter. No need to do that before merging the PR of course.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, yes, that's the next patch I'm working on. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename demangleNominalType()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wish we had a better name for "nominal or typealias" than "generic type".

@jrose-apple
Copy link
Contributor Author

About to push fixes for the simple things, but I figure I can let the tests keep going while I'm waiting for more feedback: Linux, Mac

@jrose-apple jrose-apple force-pushed the mangle-typealiases-better branch 2 times, most recently from 2444052 to a565c9b Compare April 14, 2017 01:06
@jrose-apple
Copy link
Contributor Author

Both full tests passed, and the only things since then have been renames and removing commented-out code.

@swift-ci Please smoke test

@jrose-apple jrose-apple force-pushed the mangle-typealiases-better branch from a565c9b to d3425ff Compare April 14, 2017 19:12
@jrose-apple
Copy link
Contributor Author

Added additional verification, fixed a bug that would have been caught by that verification, and updated ABI.rst.

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 089b89c69a2ea5d21f80886666ec05decc32334a
Test requested by - @jrose-apple

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 089b89c69a2ea5d21f80886666ec05decc32334a
Test requested by - @jrose-apple

@jrose-apple jrose-apple force-pushed the mangle-typealiases-better branch from d3425ff to c7f9cb7 Compare April 14, 2017 21:14
@jrose-apple jrose-apple changed the title Improve the mangling of typealiases. Improve the mangling of USRs Apr 14, 2017
@jrose-apple jrose-apple requested a review from nkcsgexi April 14, 2017 21:15
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - d3425ff089b0ca5686ffefe269164cc412e26b45
Test requested by - @jrose-apple

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - d3425ff089b0ca5686ffefe269164cc412e26b45
Test requested by - @jrose-apple

@jrose-apple
Copy link
Contributor Author

@shahmishal, any idea why the failure isn't getting posted back on GitHub?

@shahmishal
Copy link
Member

It should have been 82e76edbb7170b0fce95eed922fb7e50bfea9bc0 not c7f9cb7548c51da7db2d21efe7d28478c8ee8e78.

Setting status of c7f9cb7548c51da7db2d21efe7d28478c8ee8e78 to FAILURE with url https://ci.swift.org/job/swift-PR-Linux/6815/ and message: '**Build failed**

@shahmishal
Copy link
Member

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - c7f9cb7548c51da7db2d21efe7d28478c8ee8e78
Test requested by - @shahmishal

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - c7f9cb7548c51da7db2d21efe7d28478c8ee8e78
Test requested by - @shahmishal

@jrose-apple jrose-apple force-pushed the mangle-typealiases-better branch from c7f9cb7 to d1efe11 Compare April 15, 2017 00:02
This lets the mangling preserve the invariant that functions always
structurally have function types. Error types don't show up in mangled
names often anyway, but it can occur when you ask for the USR of a
function with an invalid type.
...and /do/ produce them for 'self' parameters in destructors when
they /are/ named. I suspect this was the cause of the original
problem.
@jrose-apple jrose-apple force-pushed the mangle-typealiases-better branch from d1efe11 to 09ac88b Compare April 15, 2017 00:03
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - c7f9cb7548c51da7db2d21efe7d28478c8ee8e78
Test requested by - @jrose-apple

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - c7f9cb7548c51da7db2d21efe7d28478c8ee8e78
Test requested by - @jrose-apple

@jrose-apple
Copy link
Contributor Author

:-( The builder is testing the correct commit but GitHub is showing them out of order.

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test Linux

This can show up when trying to generate USRs for a document with
errors in it. This isn't a great answer because the names it generates
aren't unique (there may be more than one nameless entity with the
same type), but it at least generates valid mangled names.

When generating mangled names for purposes other than USRs, nameless
entities are now checked for by an assertion.
I /think/ this can only come up in invalid code like

    class Outer {
      let _ = { class Inner {} }
    }

but we still try to generate USRs for this. Just use the enclosing
context as the current context so that we still generate /some/ valid
mangling.
- Allow them to use substitutions.
- Consistently use 'a' as a mangling operator.
- For generic typealiases, include the alias as context for any generic
  parameters.

Typealiases don't show up in symbol names, which always refer to
canonical types, but they are mangled for debug info and for USRs
(unique identifiers used by SourceKit), so it's good to get this
right.
@jrose-apple jrose-apple force-pushed the mangle-typealiases-better branch from 09ac88b to 2d84981 Compare April 17, 2017 18:31
@jrose-apple
Copy link
Contributor Author

Previous full-test passed. Still waiting on review from a SourceKit person. (Erik and I have been talking through chat.)

@swift-ci Please smoke test

@akyrtzi
Copy link
Contributor

akyrtzi commented Apr 17, 2017

Changes LGTM.

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

LGTM!

@jrose-apple jrose-apple merged commit 4e04061 into swiftlang:master Apr 17, 2017
@jrose-apple jrose-apple deleted the mangle-typealiases-better branch April 17, 2017 20:32
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.

6 participants