diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 1474285e42566..a2af916c27b9a 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -1885,19 +1885,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind, // we hit commit_to_conversions below, but we have to add a token restriction // to ensure we wrap the metatype value in a metatype erasure. if (concrete && type2->isExistentialType()) { - - // If we're binding to an empty existential, we need to make sure that the - // conversion is valid. - if (kind == TypeMatchKind::BindType && - type2->isEmptyExistentialComposition()) { - - conversionsOrFixes.push_back(ConversionRestrictionKind::Existential); - addConstraint(ConstraintKind::SelfObjectOfProtocol, - type1, type2, getConstraintLocator(locator)); - - return SolutionKind::Solved; - } - if (kind == TypeMatchKind::ConformsTo) { conversionsOrFixes.push_back(ConversionRestrictionKind:: MetatypeToExistentialMetatype); diff --git a/test/Constraints/generics.swift b/test/Constraints/generics.swift index 94d8d172650f4..5c3ac77c42ccc 100644 --- a/test/Constraints/generics.swift +++ b/test/Constraints/generics.swift @@ -236,3 +236,20 @@ Whatever.foo(a: 23) // expected-error {{generic parameter 'A' could not be infer // Swift useless error: cannot invoke 'foo' with no arguments Whatever.bar() // expected-error {{generic parameter 'A' could not be inferred}} +// Type checker doesn't enforce same-type constraint if associated type is Any +protocol P27515965 { + associatedtype R + func f() -> R +} + +struct S27515965 : P27515965 { + func f() -> Any { return self } +} + +struct V27515965 { + init(_ tp: T) where T.R == Float {} +} + +func test(x: S27515965) -> V27515965 { + return V27515965(x) // expected-error {{generic parameter 'T' could not be inferred}} +}