mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 18:01:07 +01:00
Avoid symbolic witnesses for .Self in an impl decl (#7564)
Point symbolic witnesses into `.Self` written inside an impl decl at the impl that is being declared. This is tricky because the impl does not yet exist. So we use a new instruction `ImplSelfWitness` which _will_ be replaced by the `ImplWitness` once it becomes available. The `ImplSelfWitness` acts like a symbolic witness, except it does not perform lookup, since we know which impl we will get a witness from. This prevents us from finding other impls when performing lookups into `.Self` in an impl decl, which produces incorrect/incoherent results.
This commit is contained in:
@@ -1008,7 +1008,7 @@ fn TestUnaryOperators(a: Cpp.Int16, b: Cpp.Int32) {
|
||||
// CHECK:STDOUT: %complete_type.359: <witness> = complete_type_witness %facet_type.f26 [concrete]
|
||||
// CHECK:STDOUT: %.Self.frozen.as_type.17a: type = facet_access_type %.Self.frozen.ac6 [symbolic_self]
|
||||
// CHECK:STDOUT: %ModWith.lookup_impl_witness.072: <witness> = lookup_impl_witness %.Self.frozen.ac6, @ModWith.1, @ModWith.1(%Int64) [symbolic_self]
|
||||
// CHECK:STDOUT: %impl.elem0.220: type = impl_witness_access %ModWith.lookup_impl_witness.072, element0 [symbolic_self]
|
||||
// CHECK:STDOUT: %impl.elem0.220f: type = impl_witness_access %ModWith.lookup_impl_witness.072, element0 [symbolic_self]
|
||||
// CHECK:STDOUT: %pattern_type.df3: type = pattern_type %facet_type.096 [concrete]
|
||||
// CHECK:STDOUT: %T.patt.c87: %pattern_type.df3 = symbolic_binding_pattern T, 2 [symbolic]
|
||||
// CHECK:STDOUT: %facet_type.840: type = facet_type <@Destroy & @AddWith.1, @AddWith.1(%Int32) where %impl.elem0.6e6 = %Int64> [concrete]
|
||||
@@ -1526,12 +1526,12 @@ fn TestUnaryOperators(a: Cpp.Int16, b: Cpp.Int32) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core.import_ref.5a1: @AddWith.WithSelf.%AddWith.assoc_type (%AddWith.assoc_type.588) = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, loaded [symbolic = @AddWith.WithSelf.%assoc1 (constants.%assoc1.57d)]
|
||||
// CHECK:STDOUT: %Core.import_ref.5a18: @AddWith.WithSelf.%AddWith.assoc_type (%AddWith.assoc_type.588) = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, loaded [symbolic = @AddWith.WithSelf.%assoc1 (constants.%assoc1.57d)]
|
||||
// CHECK:STDOUT: %Core.import_ref.3cf: @AddWith.WithSelf.%AddWith.WithSelf.Op.type (%AddWith.WithSelf.Op.type.28e) = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, loaded [symbolic = @AddWith.WithSelf.%AddWith.WithSelf.Op (constants.%AddWith.WithSelf.Op.eab)]
|
||||
// CHECK:STDOUT: %Core.import_ref.91f8: type = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, loaded [concrete = %Result.9a4]
|
||||
// CHECK:STDOUT: %Result.9a4: type = assoc_const_decl @Result.1 [concrete] {}
|
||||
// CHECK:STDOUT: %Core.import_ref.9768 = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, unloaded
|
||||
// CHECK:STDOUT: %Core.import_ref.0f33: @SubWith.WithSelf.%SubWith.assoc_type (%SubWith.assoc_type.b0b) = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, loaded [symbolic = @SubWith.WithSelf.%assoc1 (constants.%assoc1.178)]
|
||||
// CHECK:STDOUT: %Core.import_ref.0f3: @SubWith.WithSelf.%SubWith.assoc_type (%SubWith.assoc_type.b0b) = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, loaded [symbolic = @SubWith.WithSelf.%assoc1 (constants.%assoc1.178)]
|
||||
// CHECK:STDOUT: %Core.import_ref.3a4: @SubWith.WithSelf.%SubWith.WithSelf.Op.type (%SubWith.WithSelf.Op.type.68d) = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, loaded [symbolic = @SubWith.WithSelf.%SubWith.WithSelf.Op (constants.%SubWith.WithSelf.Op.97a)]
|
||||
// CHECK:STDOUT: %Core.import_ref.190e: type = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, loaded [concrete = %Result.7bd]
|
||||
// CHECK:STDOUT: %Result.7bd: type = assoc_const_decl @Result.2 [concrete] {}
|
||||
@@ -1592,7 +1592,7 @@ fn TestUnaryOperators(a: Cpp.Int16, b: Cpp.Int32) {
|
||||
// CHECK:STDOUT: %x.ref: @AddWith.loc124.%T.as_type.loc124_29.1 (%T.as_type.6fc) = name_ref x, %x
|
||||
// CHECK:STDOUT: %y.ref: @AddWith.loc124.%U.as_type.loc123_35.1 (%U.as_type.b61) = name_ref y, %y
|
||||
// CHECK:STDOUT: %AddWith.type.loc126: type = facet_type <@AddWith.1, @AddWith.1(constants.%U.as_type.b61)> [symbolic = %AddWith.type.loc123_35.1 (constants.%AddWith.type.9da)]
|
||||
// CHECK:STDOUT: %.loc126_5.1: @AddWith.loc124.%AddWith.assoc_type (%AddWith.assoc_type.bc8) = specific_constant imports.%Core.import_ref.5a1, @AddWith.WithSelf(constants.%U.as_type.b61, constants.%Self.96a) [symbolic = %assoc1 (constants.%assoc1.13e)]
|
||||
// CHECK:STDOUT: %.loc126_5.1: @AddWith.loc124.%AddWith.assoc_type (%AddWith.assoc_type.bc8) = specific_constant imports.%Core.import_ref.5a18, @AddWith.WithSelf(constants.%U.as_type.b61, constants.%Self.96a) [symbolic = %assoc1 (constants.%assoc1.13e)]
|
||||
// CHECK:STDOUT: %Op.ref: @AddWith.loc124.%AddWith.assoc_type (%AddWith.assoc_type.bc8) = name_ref Op, %.loc126_5.1 [symbolic = %assoc1 (constants.%assoc1.13e)]
|
||||
// CHECK:STDOUT: %impl.elem1.loc126_5.1: @AddWith.loc124.%.loc126_5.6 (%.a30) = impl_witness_access constants.%AddWith.lookup_impl_witness.2b1, element1 [symbolic = %impl.elem1.loc126_5.2 (constants.%impl.elem1.b05)]
|
||||
// CHECK:STDOUT: %bound_method.loc126_5.1: <bound method> = bound_method %x.ref, %impl.elem1.loc126_5.1
|
||||
@@ -1636,7 +1636,7 @@ fn TestUnaryOperators(a: Cpp.Int16, b: Cpp.Int32) {
|
||||
// CHECK:STDOUT: %x.ref: @SubWith.loc135.%T.as_type.loc135_29.1 (%T.as_type.58f) = name_ref x, %x
|
||||
// CHECK:STDOUT: %y.ref: @SubWith.loc135.%U.as_type.loc134_35.1 (%U.as_type.b61) = name_ref y, %y
|
||||
// CHECK:STDOUT: %SubWith.type.loc137: type = facet_type <@SubWith.1, @SubWith.1(constants.%U.as_type.b61)> [symbolic = %SubWith.type.loc134_35.1 (constants.%SubWith.type.b5d)]
|
||||
// CHECK:STDOUT: %.loc137_5.1: @SubWith.loc135.%SubWith.assoc_type (%SubWith.assoc_type.3a1) = specific_constant imports.%Core.import_ref.0f33, @SubWith.WithSelf(constants.%U.as_type.b61, constants.%Self.d6b) [symbolic = %assoc1 (constants.%assoc1.8fd)]
|
||||
// CHECK:STDOUT: %.loc137_5.1: @SubWith.loc135.%SubWith.assoc_type (%SubWith.assoc_type.3a1) = specific_constant imports.%Core.import_ref.0f3, @SubWith.WithSelf(constants.%U.as_type.b61, constants.%Self.d6b) [symbolic = %assoc1 (constants.%assoc1.8fd)]
|
||||
// CHECK:STDOUT: %Op.ref: @SubWith.loc135.%SubWith.assoc_type (%SubWith.assoc_type.3a1) = name_ref Op, %.loc137_5.1 [symbolic = %assoc1 (constants.%assoc1.8fd)]
|
||||
// CHECK:STDOUT: %impl.elem1.loc137_5.1: @SubWith.loc135.%.loc137_5.6 (%.a4a) = impl_witness_access constants.%SubWith.lookup_impl_witness.ce5, element1 [symbolic = %impl.elem1.loc137_5.2 (constants.%impl.elem1.e4f)]
|
||||
// CHECK:STDOUT: %bound_method.loc137_5.1: <bound method> = bound_method %x.ref, %impl.elem1.loc137_5.1
|
||||
@@ -3756,7 +3756,7 @@ fn TestUnaryOperators(a: Cpp.Int16, b: Cpp.Int32) {
|
||||
// CHECK:STDOUT: %ModWith.assoc_type => constants.%ModWith.assoc_type.1f7
|
||||
// CHECK:STDOUT: %assoc0 => constants.%assoc0.0a6
|
||||
// CHECK:STDOUT: %ModWith.lookup_impl_witness.loc167_43.1 => constants.%ModWith.lookup_impl_witness.072
|
||||
// CHECK:STDOUT: %impl.elem0.loc167_43.1 => constants.%impl.elem0.220
|
||||
// CHECK:STDOUT: %impl.elem0.loc167_43.1 => constants.%impl.elem0.220f
|
||||
// CHECK:STDOUT: %Result.as_type.loc167_53.1 => constants.%Int64
|
||||
// CHECK:STDOUT: %.Self => constants.%.Self.494
|
||||
// CHECK:STDOUT: %ModWith.lookup_impl_witness.loc167_43.2 => constants.%ModWith.lookup_impl_witness.103
|
||||
|
||||
Reference in New Issue
Block a user