-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Fix spurious ambiguous member lookup #78132
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f818a5d
Add inherited member lookup test case
j-hui 8d83230
Fix spurious ambiguous member lookup
j-hui 0fe808c
Formatting
j-hui 4d14901
Fix test cases
j-hui c50a16a
Simplify implementation to something self-explanatory
j-hui 23769c5
Get rid of redundant #include
j-hui b61e684
Fix mangling to account for MSVC
j-hui bb0d6bb
Add IBase method to inherited-lookup test
j-hui 3798526
Add IIBase method too
j-hui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/Interop/Cxx/class/inheritance/Inputs/inherited-lookup.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
struct Base1 { | ||
int methodBase(void) const { return 1; } | ||
}; | ||
|
||
struct IBase1 : Base1 { | ||
int methodIBase(void) const { return 11; } | ||
}; | ||
|
||
struct IIBase1 : IBase1 { | ||
int methodIIBase(void) const { return 111; } | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/Interop/Cxx/class/inheritance/inherited-lookup-executable.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -cxx-interoperability-mode=default) | ||
// | ||
// REQUIRES: executable_test | ||
import InheritedLookup | ||
import StdlibUnittest | ||
|
||
var InheritedMemberTestSuite = TestSuite("Test if inherited lookup works") | ||
|
||
InheritedMemberTestSuite.test("IIBase1::method() resolves to grandparent") { | ||
let iibase1 = IIBase1() | ||
expectEqual(iibase1.methodBase(), 1) | ||
expectEqual(iibase1.methodIBase(), 11) | ||
expectEqual(iibase1.methodIIBase(), 111) | ||
} | ||
|
||
runAllTests() |
24 changes: 24 additions & 0 deletions
24
test/Interop/Cxx/class/inheritance/inherited-lookup-typechecker.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=default | ||
import InheritedLookup | ||
|
||
extension IIBase1 { | ||
func ext() { | ||
// NOTE: we deliberately look up a missing member above because doing so | ||
// forces multiple ClangRecordMemberLookup requests, which should be | ||
// idempotent (though this hasn't always been the case, because bugs). | ||
missing() // expected-error {{cannot find 'missing' in scope}} | ||
|
||
// For instance, a non-idempotent ClangRecordMemberLookup would cause | ||
// the following to appear ambiguous: | ||
methodBase() | ||
methodIBase() | ||
methodIIBase() | ||
} | ||
} | ||
|
||
func f(v: IIBase1) { | ||
v.missing() // expected-error {{'IIBase1' has no member 'missing'}} | ||
v.methodBase() | ||
v.methodIBase() | ||
v.methodIIBase() | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.