From 53fdeb10b6c0adcd118fd2c545b17f9f1815e107 Mon Sep 17 00:00:00 2001 From: Pavel Yaskevich Date: Mon, 10 Apr 2023 16:59:16 -0700 Subject: [PATCH] [ConstraintSystem] NFC: Print attributes/capabilities only for unbound type variables Print bound type variables as `$T as @ ` and unbound ones as `$T [allows bindings to: ...] [attributes: ...] ... @ ` --- lib/Sema/CSBindings.cpp | 2 +- lib/Sema/TypeCheckConstraints.cpp | 4 ++-- test/Constraints/init_literal_via_coercion.swift | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Sema/CSBindings.cpp b/lib/Sema/CSBindings.cpp index c951f9750e43e..97e93996277d5 100644 --- a/lib/Sema/CSBindings.cpp +++ b/lib/Sema/CSBindings.cpp @@ -1784,7 +1784,7 @@ void BindingSet::dump(llvm::raw_ostream &out, unsigned indent) const { PO.PrintTypesForDebugging = true; if (auto typeVar = getTypeVariable()) { - typeVar->print(out, PO); + typeVar->getImpl().print(out); out << " "; } diff --git a/lib/Sema/TypeCheckConstraints.cpp b/lib/Sema/TypeCheckConstraints.cpp index 0b43cda055e36..b3db3e93c1597 100644 --- a/lib/Sema/TypeCheckConstraints.cpp +++ b/lib/Sema/TypeCheckConstraints.cpp @@ -1442,14 +1442,14 @@ void ConstraintSystem::print(raw_ostream &out) const { auto rep = getRepresentative(tv); if (rep == tv) { if (auto fixed = getFixedType(tv)) { - tv->getImpl().print(out); + tv->print(out, PO); out << " as "; Type(fixed).print(out, PO); } else { const_cast(this)->getBindingsFor(tv).dump(out, 1); } } else { - tv->getImpl().print(out); + tv->print(out, PO); out << " equivalent to "; Type(rep).print(out, PO); } diff --git a/test/Constraints/init_literal_via_coercion.swift b/test/Constraints/init_literal_via_coercion.swift index b5b11e7bf2caa..1a63790c5fb78 100644 --- a/test/Constraints/init_literal_via_coercion.swift +++ b/test/Constraints/init_literal_via_coercion.swift @@ -7,7 +7,7 @@ // CHECK: ---Constraint solving at [{{.*}}:12:1 - line:12:13]--- // CHECK: (integer_literal_expr type='[[LITERAL_VAR:\$T[0-9]+]]' {{.*}} // CHECK: Type Variables: -// CHECK: [[LITERAL_VAR]] [allows bindings to: {{.*}}] as UInt32 {{.*}} +// CHECK: [[LITERAL_VAR]] as UInt32 {{.*}} // CHECK-NOT: disjunction (remembered) \[\[locator@{{.*}} [Coerce@{{.*}}\]\]]: _ = UInt32(0) @@ -15,7 +15,7 @@ _ = UInt32(0) // CHECK: (coerce_expr implicit type='[[CAST_TYPE:\$T[0-9]+]]' {{.*}} // CHECK-NEXT: (nil_literal_expr type='[[LITERAL_VAR:\$T[0-9]+]]' {{.*}} // CHECK: Type Variables: -// CHECK: [[LITERAL_VAR]] [allows bindings to: {{.*}}] as Int? {{.*}} +// CHECK: [[LITERAL_VAR]] as Int? {{.*}} // CHECK: disjunction (remembered) {{.*}} // CHECK-NEXT: > [favored] [[CAST_TYPE]] bind Int? // CHECK-NEXT: > [[CAST_TYPE]] bind Int