mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
In top-level code, we were incorrectly pulling closure discriminators from TopLevelCodeDecls, not from the enclosing source file, which could lead to the same discriminators being assigned to different closures that come from macro expansions at the top level. Hilarity ensures, yet I am not amused. Adjust the DeclContext appropriately when computing discriminators. Fixes rdar://123836908.
16 lines
838 B
Swift
16 lines
838 B
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
|
|
|
|
// RUN: %target-build-swift -swift-version 5 -g -load-plugin-library %t/%target-library-name(MacroDefinition) %s -o %t/main -module-name MacroUser -Xfrontend -emit-dependencies-path -Xfrontend %t/main.d -Xfrontend -emit-reference-dependencies-path -Xfrontend %t/main.swiftdeps
|
|
// RUN: %target-codesign %t/main
|
|
// RUN: %target-run %t/main | %FileCheck %s
|
|
|
|
@freestanding(expression) macro stringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
|
|
|
|
// CHECK: 3
|
|
// CHECK-NEXT: 7
|
|
print(#stringify({ 1 + 2 }()))
|
|
print(#stringify({ 3 + 4 }()))
|