Skip to content
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

[4.0] [Type checker] Check type equality even for argument tuples in Swift 4. #10447

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,9 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
typeVar2 = dyn_cast<TypeVariableType>(type2.getPointer());

// If the types are obviously equivalent, we're done.
if (type1.getPointer() == type2.getPointer())
if (isa<ParenType>(type1.getPointer()) ==
isa<ParenType>(type2.getPointer()) &&
type1->isEqual(type2))
return SolutionKind::Solved;
} else {
typeVar1 = desugar1->getAs<TypeVariableType>();
Expand Down
23 changes: 22 additions & 1 deletion test/decl/protocol/conforms/associated_type.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %target-typecheck-verify-swift
// RUN: %target-typecheck-verify-swift -swift-version 3
// RUN: %target-typecheck-verify-swift -swift-version 4

class C { }

Expand All @@ -9,3 +10,23 @@ protocol P {
struct X : P { // expected-error{{type 'X' does not conform to protocol 'P'}}
typealias AssocP = Int // expected-note{{possibly intended match 'X.AssocP' (aka 'Int') does not inherit from 'C'}}
}

// SR-5166
protocol FooType {
associatedtype BarType

func foo(bar: BarType)
func foo(action: (BarType) -> Void)
}

protocol Bar {}

class Foo: FooType {
typealias BarType = Bar

func foo(bar: Bar) {
}

func foo(action: (Bar) -> Void) {
}
}