Commit 8d4e81c
committed
[ImportResolution] Only disallow explicit
When expanding a Swift macro in a clang module where the original clang
module imported a submodule in a C++ standard library module other than
`std`, e.g. a submodule to `std_core`, this would result in an error.
This is because `std_core.math.abs` would be imported as
`CxxStdlib.math.abs`, which would later be translated back as
`std.math.abs` which doesn’t exist.
This changes the mapping to only map `std` to `CxxStdlib`. To prevent
errors when importing modules starting with `std_`, this error is moved
from the late-stage module import to the earlier processing of
`ImportDecl`s. This results in these module names still being forbidden
in explicit imports (i.e. naming them in source code), while still being
allowed in implicit imports inherited from clang modules.
This also fixes a fix-it bug where only the first 3 characters would be
selected for replacing with `CxxStdlib` when importing `std_core`.
This also fixes a diagnostic bug where aliased modules would refer to
the module name in the source code rather than the real module name, and
adds a note clarifying the situation.
rdar://161795429
rdar://161795673
rdar://161795793
fix non-fatal import errorstd imports (allow implicit)1 parent d653b0c commit 8d4e81c
File tree
6 files changed
+120
-13
lines changed- include/swift/AST
- lib
- ClangImporter
- Sema
- test
- ImportResolution
- Interop/Cxx/swiftify-import
6 files changed
+120
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
875 | 875 | | |
876 | 876 | | |
877 | 877 | | |
| 878 | + | |
| 879 | + | |
878 | 880 | | |
879 | 881 | | |
880 | 882 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2415 | 2415 | | |
2416 | 2416 | | |
2417 | 2417 | | |
2418 | | - | |
2419 | | - | |
2420 | | - | |
2421 | | - | |
2422 | 2418 | | |
2423 | 2419 | | |
2424 | 2420 | | |
| |||
8891 | 8887 | | |
8892 | 8888 | | |
8893 | 8889 | | |
8894 | | - | |
| 8890 | + | |
8895 | 8891 | | |
8896 | 8892 | | |
8897 | 8893 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
362 | 382 | | |
363 | 383 | | |
364 | 384 | | |
| |||
513 | 533 | | |
514 | 534 | | |
515 | 535 | | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
522 | 543 | | |
| 544 | + | |
523 | 545 | | |
524 | 546 | | |
525 | 547 | | |
| |||
534 | 556 | | |
535 | 557 | | |
536 | 558 | | |
537 | | - | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
538 | 562 | | |
539 | 563 | | |
540 | 564 | | |
541 | 565 | | |
542 | 566 | | |
543 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
544 | 573 | | |
545 | 574 | | |
546 | 575 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
0 commit comments