Skip to content

Commit 86c81be

Browse files
committed
---
yaml --- r: 340330 b: refs/heads/rxwei-patch-1 c: ae5a427 h: refs/heads/master
1 parent 0cf5b92 commit 86c81be

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 6e90172010d810b5a831b811a3deae884ff6d4de
1018+
refs/heads/rxwei-patch-1: ae5a427193a42b9e7427d3f12453d3c03a9dcb12
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/lib/AST/ProtocolConformance.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,23 @@ Witness SelfProtocolConformance::getWitness(ValueDecl *requirement,
966966
ConcreteDeclRef
967967
RootProtocolConformance::getWitnessDeclRef(ValueDecl *requirement,
968968
LazyResolver *resolver) const {
969-
if (auto witness = getWitness(requirement, resolver))
970-
return witness.getDeclRef();
969+
if (auto witness = getWitness(requirement, resolver)) {
970+
auto *witnessDecl = witness.getDecl();
971+
972+
// If the witness is generic, you have to call getWitness() and build
973+
// your own substitutions in terms of the synthetic environment.
974+
if (auto *witnessDC = dyn_cast<DeclContext>(witnessDecl))
975+
assert(!witnessDC->isInnermostContextGeneric());
976+
977+
// If the witness is not generic, use type substitutions from the
978+
// witness's parent. Don't use witness.getSubstitutions(), which
979+
// are written in terms of the synthetic environment.
980+
auto subs =
981+
getType()->getContextSubstitutionMap(getDeclContext()->getParentModule(),
982+
witnessDecl->getDeclContext());
983+
return ConcreteDeclRef(witness.getDecl(), subs);
984+
}
985+
971986
return ConcreteDeclRef();
972987
}
973988

branches/rxwei-patch-1/test/SILGen/literals.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,26 @@ struct FileReference: _ExpressibleByFileReferenceLiteral {
320320
func makeFileReferenceLiteral() -> FileReference {
321321
return #fileLiteral(resourceName: makeTmpString())
322322
}
323+
324+
class ReferenceColor<T> { required init() {} }
325+
326+
protocol Silly {
327+
init()
328+
init(_colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float)
329+
}
330+
331+
extension Silly {
332+
init(_colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float) {
333+
self.init()
334+
}
335+
}
336+
337+
extension ReferenceColor : Silly, _ExpressibleByColorLiteral {}
338+
339+
func makeColorLiteral<T>() -> ReferenceColor<T> {
340+
return #colorLiteral(red: 1.358, green: -0.074, blue: -0.012, alpha: 1.0)
341+
}
342+
343+
// CHECK-LABEL: sil hidden [ossa] @$s8literals16makeColorLiteralAA09ReferenceC0CyxGylF : $@convention(thin) <T> () -> @owned ReferenceColor<T>
344+
// CHECK: [[FN:%.*]] = function_ref @$s8literals5SillyPAAE16_colorLiteralRed5green4blue5alphaxSf_S3ftcfC : $@convention(method) <τ_0_0 where τ_0_0 : Silly> (Float, Float, Float, Float, @thick τ_0_0.Type) -> @out τ_0_0
345+
// CHECK: apply [[FN]]<ReferenceColor<T>>(

0 commit comments

Comments
 (0)