Files
swift-mirror/test/Macros/magic_literal_expansion.swift
Holly Borla 9eb9ba23c5 [SILGen] Expand magic literals like #file and #line to values in the outermost
source file.

Values inside macro expansion buffers are not useful.
2023-07-20 20:56:41 -07:00

29 lines
1.1 KiB
Swift

// REQUIRES: swift_swift_parser, executable_test
// RUN: %empty-directory(%t)
// RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath
// RUN: %target-build-swift -enable-experimental-feature ExtensionMacros -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) %s -o %t/main -module-name MacroUser -swift-version 5 -emit-tbd -emit-tbd-path %t/MacroUser.tbd -I %t
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s
@freestanding(expression)
macro MagicFile() -> String = #externalMacro(module: "MacroDefinition", type: "MagicFileMacro")
@freestanding(expression)
macro MagicLine() -> Int = #externalMacro(module: "MacroDefinition", type: "MagicLineMacro")
// CHECK: magic_literal_expansion.swift
print(#MagicFile)
// CHECK: 21
print(#MagicLine)
@freestanding(expression)
macro Nested() -> Void = #externalMacro(module: "MacroDefinition", type: "NestedMagicLiteralMacro")
// CHECK: magic_literal_expansion.swift
// CHECK: 28
#Nested