Skip to content

Commit d2e1ae0

Browse files
authored
Merge pull request #1283 from swiftwasm/release/5.3
[pull] swiftwasm-release/5.3 from release/5.3
2 parents d418f4f + 703f2c3 commit d2e1ae0

File tree

8 files changed

+100
-3
lines changed

8 files changed

+100
-3
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,11 @@ const RequirementSource *RequirementSource::getMinimalConformanceSource(
837837

838838
if (parentEquivClass->concreteType)
839839
derivedViaConcrete = true;
840+
else if (parentEquivClass->superclass &&
841+
builder.lookupConformance(parentType->getCanonicalType(),
842+
parentEquivClass->superclass,
843+
source->getProtocolDecl()))
844+
derivedViaConcrete = true;
840845

841846
// The parent potential archetype must conform to the protocol in which
842847
// this requirement resides. Add this constraint.

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2643,6 +2643,7 @@ namespace {
26432643
if (!witness || !isa<AbstractFunctionDecl>(witness.getDecl()))
26442644
return nullptr;
26452645
expr->setInitializer(witness);
2646+
expr->setArg(cs.coerceToRValue(expr->getArg()));
26462647
return expr;
26472648
}
26482649

lib/Sema/CSBindings.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ void ConstraintSystem::inferTransitiveSupertypeBindings(
6969

7070
auto type = binding.BindingType;
7171

72+
if (type->isHole())
73+
continue;
74+
7275
if (!existingTypes.insert(type->getCanonicalType()).second)
7376
continue;
7477

test/Constraints/overload.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,10 @@ func autoclosure1<T>(_: [T], _: X) { }
238238
func test_autoclosure1(ia: [Int]) {
239239
autoclosure1(ia, X()) // okay: resolves to the second function
240240
}
241+
242+
// rdar://problem/64368545 - failed to produce diagnostic (hole propagated to func result without recording a fix)
243+
func test_no_hole_propagation() {
244+
func test(withArguments arguments: [String]) -> String {
245+
return arguments.reduce(0, +) // expected-error {{cannot convert value of type 'Int' to expected argument type 'String'}}
246+
}
247+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
protocol P {
4+
associatedtype T : Q
5+
}
6+
7+
protocol Q {
8+
associatedtype T : R
9+
10+
var t: T { get }
11+
}
12+
13+
protocol R {}
14+
15+
func takesR<T : R>(_: T) {}
16+
17+
class C<T : Q> : P {}
18+
19+
struct Outer<T : P> {
20+
struct Inner<U> where T : C<U> {
21+
func doStuff(_ u: U) {
22+
takesR(u.t)
23+
}
24+
}
25+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// RUN: %target-swift-emit-silgen %s | %FileCheck %s
2+
3+
protocol P {
4+
associatedtype T : Q
5+
func foo()
6+
}
7+
8+
extension P {
9+
func foo() {}
10+
}
11+
12+
protocol Q {}
13+
14+
class C<T : Q> : P {}
15+
16+
protocol PP {
17+
associatedtype T : QQ
18+
func foo()
19+
}
20+
21+
extension PP {
22+
func foo() {}
23+
}
24+
25+
class QQ {}
26+
27+
class CC<T : QQ> : PP {}
28+
29+
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s42class_conforms_with_default_implementation1CCyqd__GAA1PA2aEP3fooyyFTW : $@convention(witness_method: P) <τ_0_0><τ_1_0 where τ_0_0 : C<τ_1_0>, τ_1_0 : Q> (@in_guaranteed τ_0_0) -> () {
30+
// CHECK: [[WITNESS:%.*]] = function_ref @$s42class_conforms_with_default_implementation1PPAAE3fooyyF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
31+
// CHECK: apply [[WITNESS]]<τ_0_0>(%0) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
32+
// CHECK: return
33+
34+
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s42class_conforms_with_default_implementation2CCCyqd__GAA2PPA2aEP3fooyyFTW : $@convention(witness_method: PP) <τ_0_0><τ_1_0 where τ_0_0 : CC<τ_1_0>, τ_1_0 : QQ> (@in_guaranteed τ_0_0) -> () {
35+
// CHECK: [[WITNESS:%.*]] = function_ref @$s42class_conforms_with_default_implementation2PPPAAE3fooyyF : $@convention(method) <τ_0_0 where τ_0_0 : PP> (@in_guaranteed τ_0_0) -> ()
36+
// CHECK: apply [[WITNESS]]<τ_0_0>(%0) : $@convention(method) <τ_0_0 where τ_0_0 : PP> (@in_guaranteed τ_0_0) -> ()
37+
// CHECK: return
38+
39+
// CHECK-LABEL: sil_witness_table hidden <T where T : Q> C<T>: P module class_conforms_with_default_implementation {
40+
// CHECK-NEXT: associated_type_protocol (T: Q): dependent
41+
// CHECK-NEXT: associated_type T: T
42+
// CHECK-NEXT: method #P.foo: <Self where Self : P> (Self) -> () -> () : @$s42class_conforms_with_default_implementation1CCyqd__GAA1PA2aEP3fooyyFTW
43+
// CHECK-NEXT: }
44+
45+
// CHECK-LABEL: sil_witness_table hidden <T where T : QQ> CC<T>: PP module class_conforms_with_default_implementation {
46+
// CHECK-NEXT: associated_type T: T
47+
// CHECK-NEXT: method #PP.foo: <Self where Self : PP> (Self) -> () -> () : @$s42class_conforms_with_default_implementation2CCCyqd__GAA2PPA2aEP3fooyyFTW
48+
// CHECK-NEXT: }

test/Sema/object_literals_osx.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@ let text = #fileLiteral(resourceName: "TextFile.txt").relativeString! // expecte
2727

2828
// rdar://problem/49861813
2929
#fileLiteral() // expected-error{{missing argument for parameter 'resourceName' in call}} expected-error{{could not infer type of file reference literal}} expected-note{{import Foundation to use 'URL' as the default file reference literal type}}
30+
31+
// rdar://problem/62927467
32+
func test_literal_arguments_are_loaded() {
33+
var resource = "foo.txt" // expected-warning {{variable 'resource' was never mutated; consider changing to 'let' constant}}
34+
let _: Path = #fileLiteral(resourceName: resource) // Ok
35+
36+
func test(red: inout Float, green: inout Float) -> S {
37+
return #colorLiteral(red: red, green: green, blue: 1, alpha: 1) // Ok
38+
}
39+
}

validation-test/compiler_crashers_2/sr11108.swift renamed to validation-test/compiler_crashers_2_fixed/sr11108.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// RUN: not --crash %target-swift-emit-silgen %s
2-
3-
// REQUIRES: asserts
1+
// RUN: %target-swift-emit-silgen %s
42

53
protocol Example {
64
associatedtype Signed: SignedInteger

0 commit comments

Comments
 (0)