Skip to content

Commit 3f0f5df

Browse files
authored
Merge pull request #10447 from DougGregor/paren-type-equality-4.0
[4.0] [Type checker] Check type equality even for argument tuples in Swift 4.
2 parents 09bd4c3 + c06a633 commit 3f0f5df

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,9 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
13721372
typeVar2 = dyn_cast<TypeVariableType>(type2.getPointer());
13731373

13741374
// If the types are obviously equivalent, we're done.
1375-
if (type1.getPointer() == type2.getPointer())
1375+
if (isa<ParenType>(type1.getPointer()) ==
1376+
isa<ParenType>(type2.getPointer()) &&
1377+
type1->isEqual(type2))
13761378
return SolutionKind::Solved;
13771379
} else {
13781380
typeVar1 = desugar1->getAs<TypeVariableType>();

test/decl/protocol/conforms/associated_type.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-typecheck-verify-swift
1+
// RUN: %target-typecheck-verify-swift -swift-version 3
2+
// RUN: %target-typecheck-verify-swift -swift-version 4
23

34
class C { }
45

@@ -9,3 +10,23 @@ protocol P {
910
struct X : P { // expected-error{{type 'X' does not conform to protocol 'P'}}
1011
typealias AssocP = Int // expected-note{{possibly intended match 'X.AssocP' (aka 'Int') does not inherit from 'C'}}
1112
}
13+
14+
// SR-5166
15+
protocol FooType {
16+
associatedtype BarType
17+
18+
func foo(bar: BarType)
19+
func foo(action: (BarType) -> Void)
20+
}
21+
22+
protocol Bar {}
23+
24+
class Foo: FooType {
25+
typealias BarType = Bar
26+
27+
func foo(bar: Bar) {
28+
}
29+
30+
func foo(action: (Bar) -> Void) {
31+
}
32+
}

0 commit comments

Comments
 (0)