Skip to content

Commit

Permalink
SILGen: Don't try using materializeForSet with storage in an @objc pr…
Browse files Browse the repository at this point in the history
  • Loading branch information
slavapestov committed Jan 4, 2017
1 parent 5f9fe6f commit 3b388df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/SILGen/SILGenLValue.cpp
Expand Up @@ -831,10 +831,11 @@ namespace {
return true;
}

// If the declaration is dynamically dispatched through a protocol,
// we have to use materializeForSet.
if (isa<ProtocolDecl>(decl->getDeclContext()))
return true;
// If the declaration is dynamically dispatched through a
// non-ObjC protocol, we have to use materializeForSet.
if (auto *protoDecl = dyn_cast<ProtocolDecl>(decl->getDeclContext()))
if (!protoDecl->isObjC())
return true;

return false;
}
Expand Down
9 changes: 9 additions & 0 deletions test/SILGen/objc_protocols.swift
Expand Up @@ -280,3 +280,12 @@ extension InitializableConformerByExtension: Initializable {
}
}
// CHECK-LABEL: sil hidden [thunk] @_TToFC14objc_protocols33InitializableConformerByExtensionc

// Make sure we're crashing from trying to use materializeForSet here.
@objc protocol SelectionItem {
var time: Double { get set }
}

func incrementTime(contents: SelectionItem) {
contents.time += 1.0
}

0 comments on commit 3b388df

Please sign in to comment.