Files
swift-mirror/validation-test/compiler_crashers_2_fixed/sr13849.swift
Slava Pestov f3f2ea6f62 AST: Skip requirement checks in IsBindableVisitor::visitBoundGenericType() if substituted type is an interface type
IsBindableVisitor is part of TypeBase::substituteBindingsTo(), which
is used for two things:

- Checking if one contextual type is a proper substitution of another
  contextual type, used in the solver

- To compute the substituted generic signature when lowering a SIL
  function type

In the first case, we're interested in knowing if the substitution
succeeds or fails. In the second case, we know the substitution is
correct by construction, and we're trying to recover the generic
requirements.

In the second case though, the substituted type might be an
interface type, and if the interface type is constrained to a
concrete type in the original type's generic signature, we would
conclude that the substitution should fail.

This is incorrect, and we should just skip the check if the
substituted type is an interface type -- we do not have enough
information to know if it succeeds, and instead we must assume it
does because otherwise the substituted type passed in to type
lowering must be incorrect.

Fixes https://bugs.swift.org/browse/SR-13849.
2021-04-01 01:02:38 -04:00

14 lines
235 B
Swift

// RUN: %target-swift-frontend -emit-ir %s
public protocol Prot {
associatedtype T
}
public class C<P: Prot> where P.T: Hashable {
}
public class Spam<P: Prot> where P.T == Int {
public func m(_ f: (C<P>) -> C<P>) {
}
}