Files
swift-mirror/test/Macros/init_accessor.swift
Pavel Yaskevich a0573e0219 [CodeSynthesis] Make sure that init synthesis expands macros
Previously both `AreAllStoredPropertiesDefaultInitableRequest`
and `HasMemberwiseInitRequest` checked only "current" properties
of the type but macro expansions can add new stored and/or
init accessor properties that affect this logic so we need to
make sure that macro expansions happen and new properties are
accounted for.

Note that the original idea was to use `getStoredProperties()`
but that runs into multiple circularity issues related to lazy
properties.

Resolves: rdar://112153201
2023-08-21 18:03:01 -07:00

32 lines
1.1 KiB
Swift

// 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-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -DTEST_DIAGNOSTICS -swift-version 5
// RUN: %target-build-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) %s -o %t/main -module-name MacroUser -swift-version 5
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main
// REQUIRES: swift_swift_parser, executable_test
@attached(peer, names: named(_value), named(_$value))
macro Wrapped() = #externalMacro(module: "MacroDefinition",
type: "InitWithProjectedValueWrapperMacro")
@propertyWrapper
struct Wrapper {
var wrappedValue: Int {
1
}
var projectedValue: Wrapper {
self
}
}
struct Test {
@Wrapped
var value: Int { 1 }
}
let test = Test(_$value: Wrapper())
print(test.value)
// CHECK: 1