Skip to content

[pull] swiftwasm-release/5.3 from release/5.3 #1283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,11 @@ const RequirementSource *RequirementSource::getMinimalConformanceSource(

if (parentEquivClass->concreteType)
derivedViaConcrete = true;
else if (parentEquivClass->superclass &&
builder.lookupConformance(parentType->getCanonicalType(),
parentEquivClass->superclass,
source->getProtocolDecl()))
derivedViaConcrete = true;

// The parent potential archetype must conform to the protocol in which
// this requirement resides. Add this constraint.
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2643,6 +2643,7 @@ namespace {
if (!witness || !isa<AbstractFunctionDecl>(witness.getDecl()))
return nullptr;
expr->setInitializer(witness);
expr->setArg(cs.coerceToRValue(expr->getArg()));
return expr;
}

Expand Down
3 changes: 3 additions & 0 deletions lib/Sema/CSBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ void ConstraintSystem::inferTransitiveSupertypeBindings(

auto type = binding.BindingType;

if (type->isHole())
continue;

if (!existingTypes.insert(type->getCanonicalType()).second)
continue;

Expand Down
7 changes: 7 additions & 0 deletions test/Constraints/overload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,10 @@ func autoclosure1<T>(_: [T], _: X) { }
func test_autoclosure1(ia: [Int]) {
autoclosure1(ia, X()) // okay: resolves to the second function
}

// rdar://problem/64368545 - failed to produce diagnostic (hole propagated to func result without recording a fix)
func test_no_hole_propagation() {
func test(withArguments arguments: [String]) -> String {
return arguments.reduce(0, +) // expected-error {{cannot convert value of type 'Int' to expected argument type 'String'}}
}
}
25 changes: 25 additions & 0 deletions test/Generics/superclass_constraint_self_derived.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %target-typecheck-verify-swift

protocol P {
associatedtype T : Q
}

protocol Q {
associatedtype T : R

var t: T { get }
}

protocol R {}

func takesR<T : R>(_: T) {}

class C<T : Q> : P {}

struct Outer<T : P> {
struct Inner<U> where T : C<U> {
func doStuff(_ u: U) {
takesR(u.t)
}
}
}
48 changes: 48 additions & 0 deletions test/SILGen/class_conforms_with_default_implementation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// RUN: %target-swift-emit-silgen %s | %FileCheck %s

protocol P {
associatedtype T : Q
func foo()
}

extension P {
func foo() {}
}

protocol Q {}

class C<T : Q> : P {}

protocol PP {
associatedtype T : QQ
func foo()
}

extension PP {
func foo() {}
}

class QQ {}

class CC<T : QQ> : PP {}

// 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) -> () {
// CHECK: [[WITNESS:%.*]] = function_ref @$s42class_conforms_with_default_implementation1PPAAE3fooyyF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
// CHECK: apply [[WITNESS]]<τ_0_0>(%0) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
// CHECK: return

// 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) -> () {
// CHECK: [[WITNESS:%.*]] = function_ref @$s42class_conforms_with_default_implementation2PPPAAE3fooyyF : $@convention(method) <τ_0_0 where τ_0_0 : PP> (@in_guaranteed τ_0_0) -> ()
// CHECK: apply [[WITNESS]]<τ_0_0>(%0) : $@convention(method) <τ_0_0 where τ_0_0 : PP> (@in_guaranteed τ_0_0) -> ()
// CHECK: return

// CHECK-LABEL: sil_witness_table hidden <T where T : Q> C<T>: P module class_conforms_with_default_implementation {
// CHECK-NEXT: associated_type_protocol (T: Q): dependent
// CHECK-NEXT: associated_type T: T
// CHECK-NEXT: method #P.foo: <Self where Self : P> (Self) -> () -> () : @$s42class_conforms_with_default_implementation1CCyqd__GAA1PA2aEP3fooyyFTW
// CHECK-NEXT: }

// CHECK-LABEL: sil_witness_table hidden <T where T : QQ> CC<T>: PP module class_conforms_with_default_implementation {
// CHECK-NEXT: associated_type T: T
// CHECK-NEXT: method #PP.foo: <Self where Self : PP> (Self) -> () -> () : @$s42class_conforms_with_default_implementation2CCCyqd__GAA2PPA2aEP3fooyyFTW
// CHECK-NEXT: }
10 changes: 10 additions & 0 deletions test/Sema/object_literals_osx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ let text = #fileLiteral(resourceName: "TextFile.txt").relativeString! // expecte

// rdar://problem/49861813
#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}}

// rdar://problem/62927467
func test_literal_arguments_are_loaded() {
var resource = "foo.txt" // expected-warning {{variable 'resource' was never mutated; consider changing to 'let' constant}}
let _: Path = #fileLiteral(resourceName: resource) // Ok

func test(red: inout Float, green: inout Float) -> S {
return #colorLiteral(red: red, green: green, blue: 1, alpha: 1) // Ok
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// RUN: not --crash %target-swift-emit-silgen %s

// REQUIRES: asserts
// RUN: %target-swift-emit-silgen %s

protocol Example {
associatedtype Signed: SignedInteger
Expand Down