Skip to content

Requestify Extension Type Validation #26844

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 4 commits into from
Aug 27, 2019

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Aug 26, 2019

No description provided.

@CodaFi CodaFi requested a review from slavapestov August 26, 2019 16:59
@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 26, 2019

@swift-ci please smoke test

//----------------------------------------------------------------------------//

Optional<Type> ExtendedTypeRequest::getCachedResult() const {
auto *ext = std::get<0>(getStorage());
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps ExtensionDecl could just store a TypeRepr instead of a TypeLoc and we can use built-in caching for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Lots of cleanup falling out of this.

@CodaFi CodaFi force-pushed the extension-intervention branch 2 times, most recently from 0777b27 to 2aa2215 Compare August 26, 2019 18:42
@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 26, 2019

@swift-ci please smoke test

Replumb the TypeLoc for the extended type as a TypeRepr instead. Fixup
the myriad callsites this touches in the process.
@CodaFi CodaFi force-pushed the extension-intervention branch from 2aa2215 to 8d22702 Compare August 26, 2019 18:48
@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 26, 2019

@swift-ci please smoke test

@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 27, 2019

@swift-ci please smoke test

@@ -14,8 +14,5 @@
// CHECK1: s:4Foo219FooOverlayClassBaseC
// CHECK1: FooOverlayClassBase.Type

// RUN: %sourcekitd-test -req=interface-gen %S/Inputs/UnresolvedExtension.swift -- %S/Inputs/UnresolvedExtension.swift | %FileCheck -check-prefix=CHECK2 %s
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@akyrtzi Can you remember what this test was trying to do? It seems like pure coincidence that it passed before.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite remember but I'd guess this is likely to have been checking that this test case doesn't trigger a crash.

@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 27, 2019

@swift-ci please smoke test

@dan-zheng
Copy link
Contributor

I wonder if this patch could be a step towards resolving TF-632: supporting extensions of synthesized member types? Related forum discussion.

Perhaps not; @slavapestov's suggestions at the bottom of the thread suggest handling TF-632 requires lower-level name lookup changes.

struct TF_632<T: Differentiable, U: Differentiable>: @memberwise Differentiable {
    var x: T
    var y: U

    // The compiler synthesizes:
    // struct TangentVector: Differentiable, AdditiveArithmetic {
    //     var x: T.TangentVector
    //     var y: U.TangentVector
    // }
}
extension TF_632.TangentVector {}
foo.swift:12:15: error: 'TangentVector' is not a member type of 'TF_632'
extension TF_632.TangentVector {}
          ~~~ ^

@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 27, 2019

⛵️

@CodaFi CodaFi merged commit 3676568 into swiftlang:master Aug 27, 2019
@CodaFi CodaFi deleted the extension-intervention branch August 27, 2019 18:23
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.

4 participants