|
| 1 | +#if MODA_NORMAL |
| 2 | +open class ParentClass { |
| 3 | + open func overridableMethod(param: Int) {} |
| 4 | +} |
| 5 | +#endif |
| 6 | + |
| 7 | +#if MODA_LOC |
| 8 | +open class ParentClass { |
| 9 | +#sourceLocation(file: "REPLACEDWITHSED", line: 10) |
| 10 | + open func overridableMethod(param: Int) {} |
| 11 | +#sourceLocation() |
| 12 | +} |
| 13 | +#endif |
| 14 | + |
| 15 | +#if MODB |
| 16 | +import moda |
| 17 | + |
| 18 | +open class SubClass: ParentClass { |
| 19 | + open override func overridableMethod(param: String) {} |
| 20 | +} |
| 21 | +#endif |
| 22 | + |
| 23 | +// This test depends on line numbers, hence RUN lines being underneath the |
| 24 | +// code. |
| 25 | + |
| 26 | +// RUN: %empty-directory(%t) |
| 27 | +// RUN: %empty-directory(%t/mods) |
| 28 | +// RUN: sed -e 's|REPLACEDWITHSED|%/t/alternative.swift|g' %s > %t/moda.swift |
| 29 | + |
| 30 | +// RUN: %target-swift-frontend -emit-module -emit-module-source-info -o %t/mods/moda.swiftmodule -D MODA_NORMAL %t/moda.swift |
| 31 | + |
| 32 | +// The diagnostic should have the real location from .swiftsourceinfo |
| 33 | +// RUN: not %target-swift-frontend -typecheck -I %t/mods -D MODB %s 2>&1 | %FileCheck -check-prefix=CHECK-EXISTS %s |
| 34 | +// CHECK-EXISTS: moda.swift:3:13: note |
| 35 | + |
| 36 | +// Removed the underlying file, so should use the generated source instead |
| 37 | +// RUN: mv %t/moda.swift %t/moda.swift-moved |
| 38 | +// RUN: not %target-swift-frontend -typecheck -I %t/mods -D MODB %s 2>&1 | %FileCheck -check-prefix=CHECK-GENERATED %s |
| 39 | +// CHECK-GENERATED: moda.ParentClass:{{.*}}: note: |
| 40 | + |
| 41 | +// Underlying file has changed, so the locations in .swiftsourceinfo may not |
| 42 | +// make sense any more. Ignored for now (ie. it is used regardless) |
| 43 | +// RUN: echo "// file was modified" > %t/moda.swift |
| 44 | +// RUN: cat %t/moda.swift-moved >> %t/moda.swift |
| 45 | +// RUN: not %target-swift-frontend -typecheck -I %t/mods -D MODB %s 2>&1 | %FileCheck -check-prefix=CHECK-EXISTS %s |
| 46 | + |
| 47 | + |
| 48 | +// The file and line from a location directive should be used whether or not it |
| 49 | +// exists - the actual source still comes from the original file, so that's what |
| 50 | +// matters in terms of whether generated code is used or not |
| 51 | + |
| 52 | +// RUN: %empty-directory(%t/mods) |
| 53 | +// RUN: mv %t/moda.swift-moved %t/moda.swift |
| 54 | +// RUN: %target-swift-frontend -emit-module -emit-module-source-info -o %t/mods/moda.swiftmodule -D MODA_LOC %t/moda.swift |
| 55 | + |
| 56 | +// Line directive file exists |
| 57 | +// RUN: cp %t/moda.swift %t/alternative.swift |
| 58 | +// RUN: not %target-swift-frontend -typecheck -I %t/mods -D MODB %s 2>&1 | %FileCheck -check-prefix=CHECK-DIRECTIVE %s |
| 59 | + |
| 60 | +// File missing |
| 61 | +// RUN: mv %t/alternative.swift %t/alternative.swift-moved |
| 62 | +// FIXME: Because the presumed location is output and then read back in, the |
| 63 | +// location is invalid and it falls back to the generated. This should be |
| 64 | +// CHECK-DIRECTIVE |
| 65 | +// RUN: not %target-swift-frontend -typecheck -I %t/mods -D MODB %s 2>&1 | %FileCheck -check-prefix=CHECK-GENERATED %s |
| 66 | +// CHECK-DIRECTIVE: alternative.swift:10:13: note |
| 67 | + |
| 68 | +// File exists but location does not |
| 69 | +// RUN: echo "" > %t/alternative.swift |
| 70 | +// FIXME: As above, this should be CHECK-DIRECTIVE |
| 71 | +// RUN: not %target-swift-frontend -typecheck -I %t/mods -D MODB %s 2>&1 | %FileCheck -check-prefix=CHECK-GENERATED %s |
| 72 | + |
| 73 | +// Removed the underlying file, so should use the generated source instead |
| 74 | +// RUN: mv %t/alternative.swift-moved %t/alternative.swift |
| 75 | +// RUN: mv %t/moda.swift %t/moda.swift-moved |
| 76 | +// FIXME: Should be CHECK-GENERATED but works as, again, it's the presumed |
| 77 | +// location that's output |
| 78 | +// RUN: not %target-swift-frontend -typecheck -I %t/mods -D MODB %s 2>&1 | %FileCheck -check-prefix=CHECK-DIRECTIVE %s |
0 commit comments