File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -2483,8 +2483,24 @@ void AttributeChecker::visitCustomAttr(CustomAttr *attr) {
2483
2483
decl = func;
2484
2484
} else if (auto storage = dyn_cast<AbstractStorageDecl>(D)) {
2485
2485
decl = storage;
2486
- auto getter = storage->getParsedAccessor (AccessorKind::Get);
2487
- if (!getter || !getter->hasBody ()) {
2486
+
2487
+ // Check whether this is a property without an explicit getter.
2488
+ auto shouldDiagnose = [&]() -> bool {
2489
+ auto getter = storage->getParsedAccessor (AccessorKind::Get);
2490
+ if (!getter)
2491
+ return true ;
2492
+
2493
+ // Module interfaces don't print bodies for all getters, so allow getters
2494
+ // that don't have a body if we're compiling a module interface.
2495
+ SourceFile *parent = storage->getDeclContext ()->getParentSourceFile ();
2496
+ bool isInInterface = parent && parent->Kind == SourceFileKind::Interface;
2497
+ if (!isInInterface && !getter->hasBody ())
2498
+ return true ;
2499
+
2500
+ return false ;
2501
+ };
2502
+
2503
+ if (shouldDiagnose ()) {
2488
2504
diagnose (attr->getLocation (),
2489
2505
diag::function_builder_attribute_on_storage_without_getter,
2490
2506
nominal->getFullName (),
Original file line number Diff line number Diff line change 2
2
// RUN: %target-swift-frontend -typecheck -module-name FunctionBuilders -emit-module-interface-path %t/FunctionBuilders.swiftinterface %s
3
3
// RUN: %FileCheck %s < %t/FunctionBuilders.swiftinterface
4
4
// RUN: %target-swift-frontend -I %t -typecheck -verify %S/Inputs/function_builders_client.swift
5
+ // RUN: %target-swift-frontend -compile-module-from-interface %t/FunctionBuilders.swiftinterface -o %t/FunctionBuilders.swiftmodule
5
6
6
7
@_functionBuilder
7
8
public struct TupleBuilder {
@@ -33,3 +34,13 @@ public struct TupleBuilder {
33
34
public func tuplify< T> ( _ cond: Bool , @TupleBuilder body: ( Bool ) -> T ) {
34
35
print ( body ( cond) )
35
36
}
37
+
38
+ public struct UsesBuilderProperty {
39
+ // CHECK: @FunctionBuilders.TupleBuilder public var myVar: (Swift.String, Swift.String) {
40
+ // CHECK-NEXT: get
41
+ // CHECK-NEXT: }
42
+ @TupleBuilder public var myVar : ( String , String ) {
43
+ " hello "
44
+ " goodbye "
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments