mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Constraint generation for interpolated string literals was
meticulously producing a constraint system that included all of the
generated calls to init(stringInterpolationSegment:). While accurate,
this is completely unnecessary (because the
ExpressibleByStringInterpolation protocol allows *anything* to be
interpolated) and leads to large, intertwined constraint systems
where:
(1) There are two additional type variables per string interpolation
segment, and
(2) Those type variables form a bridge between the string
interpolation's type variable and the type variables of each string
interpolation segment, and
(3) init(stringInterpolationSegment:) tends to be overloaded (4
overloads, down from 17 due to
29353013c0)
which left each string interpolation as a large connected component
with big disjunctions.
Drop the calls to init(stringInterpolationSegment:) from the
constraint system. This eliminates two type
variables per segment (due to (1) going away), and breaks the bridge
described in (2), so that each string interpolation segment is
treated as an separate connected component and, therefore, will be
solved independently. The actual resolution of
init(stringInterpolationSegment:) overloads is pushed to the
constraint application phase, where we are only dealing with concrete
types and *much* smaller constraint systems.
Fixes rdar://problem/29389887 more thoroughly.
46 lines
1.6 KiB
Swift
46 lines
1.6 KiB
Swift
// RUN: %target-typecheck-verify-swift -typecheck -debug-constraints %s > %t.dump 2>&1
|
|
// RUN: %FileCheck %s < %t.dump
|
|
|
|
// Make sure that the interpolation segments get placed into separate connected
|
|
// components.
|
|
// CHECK: ---Connected components---
|
|
// CHECK-NEXT: 0:
|
|
// CHECK-NEXT: 1:
|
|
// CHECK-NEXT: 2:
|
|
// CHECK-NEXT: 3:
|
|
// CHECK-NEXT: 4:
|
|
// CHECK-NEXT: 5:
|
|
// CHECK-NEXT: 6:
|
|
// CHECK-NEXT: 7:
|
|
// CHECK-NEXT: 8:
|
|
// CHECK-NEXT: 9:
|
|
|
|
// CHECK: (solving component #
|
|
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
|
|
|
|
// CHECK: (solving component #
|
|
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
|
|
|
|
// CHECK: (solving component #
|
|
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
|
|
|
|
// CHECK: (solving component #
|
|
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
|
|
|
|
// CHECK: (solving component #
|
|
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
|
|
|
|
// CHECK: (solving component #
|
|
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
|
|
|
|
// CHECK: (solving component #
|
|
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
|
|
|
|
// CHECK: (solving component #
|
|
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
|
|
|
|
// CHECK: (solving component #
|
|
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
|
|
|
|
_ = "\(1), \(2), \(3), \(4)"
|