|
|
@@ -11,7 +11,7 @@
|
|
|
// TIP: To dump output, run:
|
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/min_prelude/generic_redeclaration.carbon
|
|
|
|
|
|
-// --- same_self_and_interface.carbon
|
|
|
+// --- fail_same_self_and_interface.carbon
|
|
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
|
|
@@ -30,8 +30,29 @@ impl forall [T:! L] T as Interface;
|
|
|
// These are different impls, so they are not redefinitions, even though the
|
|
|
// self type and constraint type are the same.
|
|
|
impl forall [T:! I] T as Interface {}
|
|
|
+// CHECK:STDERR: fail_same_self_and_interface.carbon:[[@LINE+7]]:1: error: found non-final `impl` that fully overlaps previous non-final `impl` [ImplFullyOverlapNonFinal]
|
|
|
+// CHECK:STDERR: impl forall [T:! J] T as Interface {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR: fail_same_self_and_interface.carbon:[[@LINE-4]]:1: note: fully overlaps `impl` here [ImplFullyOverlapNonFinalNote]
|
|
|
+// CHECK:STDERR: impl forall [T:! I] T as Interface {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
impl forall [T:! J] T as Interface {}
|
|
|
+// CHECK:STDERR: fail_same_self_and_interface.carbon:[[@LINE+7]]:1: error: found non-final `impl` that fully overlaps previous non-final `impl` [ImplFullyOverlapNonFinal]
|
|
|
+// CHECK:STDERR: impl forall [T:! K] T as Interface {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR: fail_same_self_and_interface.carbon:[[@LINE-4]]:1: note: fully overlaps `impl` here [ImplFullyOverlapNonFinalNote]
|
|
|
+// CHECK:STDERR: impl forall [T:! J] T as Interface {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
impl forall [T:! K] T as Interface {}
|
|
|
+// CHECK:STDERR: fail_same_self_and_interface.carbon:[[@LINE+7]]:1: error: found non-final `impl` that fully overlaps previous non-final `impl` [ImplFullyOverlapNonFinal]
|
|
|
+// CHECK:STDERR: impl forall [T:! L] T as Interface {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR: fail_same_self_and_interface.carbon:[[@LINE-4]]:1: note: fully overlaps `impl` here [ImplFullyOverlapNonFinalNote]
|
|
|
+// CHECK:STDERR: impl forall [T:! K] T as Interface {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
impl forall [T:! L] T as Interface {}
|
|
|
|
|
|
// --- fail_same_self_and_interface_redefined.carbon
|
|
|
@@ -51,20 +72,23 @@ impl forall [T:! I] T as J {}
|
|
|
// CHECK:STDERR:
|
|
|
impl forall [T:! I] T as J {}
|
|
|
|
|
|
-// --- same_type_different_spelling.carbon
|
|
|
+// --- fail_same_type_different_spelling.carbon
|
|
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
|
|
class C;
|
|
|
interface I {}
|
|
|
|
|
|
-// We accept this because these two types are spelled differently, even though
|
|
|
-// they evaluate to the same type constant. Any use of this impl will be
|
|
|
-// ambiguous unless resolved by a `match_first` or similar.
|
|
|
-//
|
|
|
-// TODO: Produce a warning or maybe an error when this happens in a non-generic
|
|
|
-// impl.
|
|
|
+// Since the spelling is different, it's not caught as a redefinition, but it
|
|
|
+// is diagnosed as an overlapping impl without using a `match_first` block.
|
|
|
impl C as I {}
|
|
|
+// CHECK:STDERR: fail_same_type_different_spelling.carbon:[[@LINE+7]]:1: error: found non-final `impl` that fully overlaps previous non-final `impl` [ImplFullyOverlapNonFinal]
|
|
|
+// CHECK:STDERR: impl (C, C).0 as I {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR: fail_same_type_different_spelling.carbon:[[@LINE-4]]:1: note: fully overlaps `impl` here [ImplFullyOverlapNonFinalNote]
|
|
|
+// CHECK:STDERR: impl C as I {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
impl (C, C).0 as I {}
|
|
|
|
|
|
// --- fail_redefinition_generic_regions.carbon
|
|
|
@@ -92,7 +116,7 @@ impl forall [T:! type] T as I {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// CHECK:STDOUT: --- same_self_and_interface.carbon
|
|
|
+// CHECK:STDOUT: --- fail_same_self_and_interface.carbon
|
|
|
// CHECK:STDOUT:
|
|
|
// CHECK:STDOUT: constants {
|
|
|
// CHECK:STDOUT: %Interface.type: type = facet_type <@Interface> [concrete]
|
|
|
@@ -205,32 +229,32 @@ impl forall [T:! type] T as I {
|
|
|
// CHECK:STDOUT: impl_decl @impl.793 [concrete] {
|
|
|
// CHECK:STDOUT: %T.patt: %pattern_type.28e = symbolic_binding_pattern T, 0 [concrete]
|
|
|
// CHECK:STDOUT: } {
|
|
|
-// CHECK:STDOUT: %T.ref.loc19: %J.type = name_ref T, %T.loc19 [symbolic = %T.loc12_14.2 (constants.%T.ccd)]
|
|
|
-// CHECK:STDOUT: %T.as_type.loc19: type = facet_access_type %T.ref.loc19 [symbolic = %T.as_type.loc12_21.2 (constants.%T.as_type.3df)]
|
|
|
-// CHECK:STDOUT: %.loc19: type = converted %T.ref.loc19, %T.as_type.loc19 [symbolic = %T.as_type.loc12_21.2 (constants.%T.as_type.3df)]
|
|
|
-// CHECK:STDOUT: %Interface.ref.loc19: type = name_ref Interface, file.%Interface.decl [concrete = constants.%Interface.type]
|
|
|
-// CHECK:STDOUT: %J.ref.loc19: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
|
|
|
-// CHECK:STDOUT: %T.loc19: %J.type = bind_symbolic_name T, 0 [symbolic = %T.loc12_14.2 (constants.%T.ccd)]
|
|
|
+// CHECK:STDOUT: %T.ref.loc26: %J.type = name_ref T, %T.loc26 [symbolic = %T.loc12_14.2 (constants.%T.ccd)]
|
|
|
+// CHECK:STDOUT: %T.as_type.loc26: type = facet_access_type %T.ref.loc26 [symbolic = %T.as_type.loc12_21.2 (constants.%T.as_type.3df)]
|
|
|
+// CHECK:STDOUT: %.loc26: type = converted %T.ref.loc26, %T.as_type.loc26 [symbolic = %T.as_type.loc12_21.2 (constants.%T.as_type.3df)]
|
|
|
+// CHECK:STDOUT: %Interface.ref.loc26: type = name_ref Interface, file.%Interface.decl [concrete = constants.%Interface.type]
|
|
|
+// CHECK:STDOUT: %J.ref.loc26: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
|
|
|
+// CHECK:STDOUT: %T.loc26: %J.type = bind_symbolic_name T, 0 [symbolic = %T.loc12_14.2 (constants.%T.ccd)]
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT: impl_decl @impl.c93 [concrete] {
|
|
|
// CHECK:STDOUT: %T.patt: %pattern_type.4a6 = symbolic_binding_pattern T, 0 [concrete]
|
|
|
// CHECK:STDOUT: } {
|
|
|
-// CHECK:STDOUT: %T.ref.loc20: %K.type = name_ref T, %T.loc20 [symbolic = %T.loc13_14.2 (constants.%T.09f)]
|
|
|
-// CHECK:STDOUT: %T.as_type.loc20: type = facet_access_type %T.ref.loc20 [symbolic = %T.as_type.loc13_21.2 (constants.%T.as_type.037)]
|
|
|
-// CHECK:STDOUT: %.loc20: type = converted %T.ref.loc20, %T.as_type.loc20 [symbolic = %T.as_type.loc13_21.2 (constants.%T.as_type.037)]
|
|
|
-// CHECK:STDOUT: %Interface.ref.loc20: type = name_ref Interface, file.%Interface.decl [concrete = constants.%Interface.type]
|
|
|
-// CHECK:STDOUT: %K.ref.loc20: type = name_ref K, file.%K.decl [concrete = constants.%K.type]
|
|
|
-// CHECK:STDOUT: %T.loc20: %K.type = bind_symbolic_name T, 0 [symbolic = %T.loc13_14.2 (constants.%T.09f)]
|
|
|
+// CHECK:STDOUT: %T.ref.loc34: %K.type = name_ref T, %T.loc34 [symbolic = %T.loc13_14.2 (constants.%T.09f)]
|
|
|
+// CHECK:STDOUT: %T.as_type.loc34: type = facet_access_type %T.ref.loc34 [symbolic = %T.as_type.loc13_21.2 (constants.%T.as_type.037)]
|
|
|
+// CHECK:STDOUT: %.loc34: type = converted %T.ref.loc34, %T.as_type.loc34 [symbolic = %T.as_type.loc13_21.2 (constants.%T.as_type.037)]
|
|
|
+// CHECK:STDOUT: %Interface.ref.loc34: type = name_ref Interface, file.%Interface.decl [concrete = constants.%Interface.type]
|
|
|
+// CHECK:STDOUT: %K.ref.loc34: type = name_ref K, file.%K.decl [concrete = constants.%K.type]
|
|
|
+// CHECK:STDOUT: %T.loc34: %K.type = bind_symbolic_name T, 0 [symbolic = %T.loc13_14.2 (constants.%T.09f)]
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT: impl_decl @impl.9e6 [concrete] {
|
|
|
// CHECK:STDOUT: %T.patt: %pattern_type.86b = symbolic_binding_pattern T, 0 [concrete]
|
|
|
// CHECK:STDOUT: } {
|
|
|
-// CHECK:STDOUT: %T.ref.loc21: %L.type = name_ref T, %T.loc21 [symbolic = %T.loc14_14.2 (constants.%T.1d2)]
|
|
|
-// CHECK:STDOUT: %T.as_type.loc21: type = facet_access_type %T.ref.loc21 [symbolic = %T.as_type.loc14_21.2 (constants.%T.as_type.0ed)]
|
|
|
-// CHECK:STDOUT: %.loc21: type = converted %T.ref.loc21, %T.as_type.loc21 [symbolic = %T.as_type.loc14_21.2 (constants.%T.as_type.0ed)]
|
|
|
-// CHECK:STDOUT: %Interface.ref.loc21: type = name_ref Interface, file.%Interface.decl [concrete = constants.%Interface.type]
|
|
|
-// CHECK:STDOUT: %L.ref.loc21: type = name_ref L, file.%L.decl [concrete = constants.%L.type]
|
|
|
-// CHECK:STDOUT: %T.loc21: %L.type = bind_symbolic_name T, 0 [symbolic = %T.loc14_14.2 (constants.%T.1d2)]
|
|
|
+// CHECK:STDOUT: %T.ref.loc42: %L.type = name_ref T, %T.loc42 [symbolic = %T.loc14_14.2 (constants.%T.1d2)]
|
|
|
+// CHECK:STDOUT: %T.as_type.loc42: type = facet_access_type %T.ref.loc42 [symbolic = %T.as_type.loc14_21.2 (constants.%T.as_type.0ed)]
|
|
|
+// CHECK:STDOUT: %.loc42: type = converted %T.ref.loc42, %T.as_type.loc42 [symbolic = %T.as_type.loc14_21.2 (constants.%T.as_type.0ed)]
|
|
|
+// CHECK:STDOUT: %Interface.ref.loc42: type = name_ref Interface, file.%Interface.decl [concrete = constants.%Interface.type]
|
|
|
+// CHECK:STDOUT: %L.ref.loc42: type = name_ref L, file.%L.decl [concrete = constants.%L.type]
|
|
|
+// CHECK:STDOUT: %T.loc42: %L.type = bind_symbolic_name T, 0 [symbolic = %T.loc14_14.2 (constants.%T.1d2)]
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT:
|
|
|
@@ -454,17 +478,17 @@ impl forall [T:! type] T as I {
|
|
|
// CHECK:STDOUT: %T.as_type.loc15_21.2 => constants.%T.as_type
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT:
|
|
|
-// CHECK:STDOUT: --- same_type_different_spelling.carbon
|
|
|
+// CHECK:STDOUT: --- fail_same_type_different_spelling.carbon
|
|
|
// CHECK:STDOUT:
|
|
|
// CHECK:STDOUT: constants {
|
|
|
// CHECK:STDOUT: %C: type = class_type @C [concrete]
|
|
|
// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
|
|
|
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
|
|
|
-// CHECK:STDOUT: %I.impl_witness.215123.1: <witness> = impl_witness file.%I.impl_witness_table.loc13 [concrete]
|
|
|
+// CHECK:STDOUT: %I.impl_witness.215123.1: <witness> = impl_witness file.%I.impl_witness_table.loc9 [concrete]
|
|
|
// CHECK:STDOUT: %tuple.type: type = tuple_type (type, type) [concrete]
|
|
|
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
|
|
|
// CHECK:STDOUT: %tuple: %tuple.type = tuple_value (%C, %C) [concrete]
|
|
|
-// CHECK:STDOUT: %I.impl_witness.215123.2: <witness> = impl_witness file.%I.impl_witness_table.loc14 [concrete]
|
|
|
+// CHECK:STDOUT: %I.impl_witness.215123.2: <witness> = impl_witness file.%I.impl_witness_table.loc17 [concrete]
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT:
|
|
|
// CHECK:STDOUT: imports {
|
|
|
@@ -486,20 +510,20 @@ impl forall [T:! type] T as I {
|
|
|
// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
|
|
|
// CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
|
|
|
// CHECK:STDOUT: }
|
|
|
-// CHECK:STDOUT: %I.impl_witness_table.loc13 = impl_witness_table (), @impl.7704ae.1 [concrete]
|
|
|
-// CHECK:STDOUT: %I.impl_witness.loc13: <witness> = impl_witness %I.impl_witness_table.loc13 [concrete = constants.%I.impl_witness.215123.1]
|
|
|
+// CHECK:STDOUT: %I.impl_witness_table.loc9 = impl_witness_table (), @impl.7704ae.1 [concrete]
|
|
|
+// CHECK:STDOUT: %I.impl_witness.loc9: <witness> = impl_witness %I.impl_witness_table.loc9 [concrete = constants.%I.impl_witness.215123.1]
|
|
|
// CHECK:STDOUT: impl_decl @impl.7704ae.2 [concrete] {} {
|
|
|
-// CHECK:STDOUT: %C.ref.loc14_7: type = name_ref C, file.%C.decl [concrete = constants.%C]
|
|
|
-// CHECK:STDOUT: %C.ref.loc14_10: type = name_ref C, file.%C.decl [concrete = constants.%C]
|
|
|
-// CHECK:STDOUT: %.loc14_11.1: %tuple.type = tuple_literal (%C.ref.loc14_7, %C.ref.loc14_10)
|
|
|
+// CHECK:STDOUT: %C.ref.loc17_7: type = name_ref C, file.%C.decl [concrete = constants.%C]
|
|
|
+// CHECK:STDOUT: %C.ref.loc17_10: type = name_ref C, file.%C.decl [concrete = constants.%C]
|
|
|
+// CHECK:STDOUT: %.loc17_11.1: %tuple.type = tuple_literal (%C.ref.loc17_7, %C.ref.loc17_10)
|
|
|
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
|
|
|
-// CHECK:STDOUT: %tuple: %tuple.type = tuple_value (%C.ref.loc14_7, %C.ref.loc14_10) [concrete = constants.%tuple]
|
|
|
-// CHECK:STDOUT: %.loc14_11.2: %tuple.type = converted %.loc14_11.1, %tuple [concrete = constants.%tuple]
|
|
|
-// CHECK:STDOUT: %tuple.elem0: type = tuple_access %.loc14_11.2, element0 [concrete = constants.%C]
|
|
|
+// CHECK:STDOUT: %tuple: %tuple.type = tuple_value (%C.ref.loc17_7, %C.ref.loc17_10) [concrete = constants.%tuple]
|
|
|
+// CHECK:STDOUT: %.loc17_11.2: %tuple.type = converted %.loc17_11.1, %tuple [concrete = constants.%tuple]
|
|
|
+// CHECK:STDOUT: %tuple.elem0: type = tuple_access %.loc17_11.2, element0 [concrete = constants.%C]
|
|
|
// CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
|
|
|
// CHECK:STDOUT: }
|
|
|
-// CHECK:STDOUT: %I.impl_witness_table.loc14 = impl_witness_table (), @impl.7704ae.2 [concrete]
|
|
|
-// CHECK:STDOUT: %I.impl_witness.loc14: <witness> = impl_witness %I.impl_witness_table.loc14 [concrete = constants.%I.impl_witness.215123.2]
|
|
|
+// CHECK:STDOUT: %I.impl_witness_table.loc17 = impl_witness_table (), @impl.7704ae.2 [concrete]
|
|
|
+// CHECK:STDOUT: %I.impl_witness.loc17: <witness> = impl_witness %I.impl_witness_table.loc17 [concrete = constants.%I.impl_witness.215123.2]
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT:
|
|
|
// CHECK:STDOUT: interface @I {
|
|
|
@@ -512,12 +536,12 @@ impl forall [T:! type] T as I {
|
|
|
// CHECK:STDOUT:
|
|
|
// CHECK:STDOUT: impl @impl.7704ae.1: %C.ref as %I.ref {
|
|
|
// CHECK:STDOUT: !members:
|
|
|
-// CHECK:STDOUT: witness = file.%I.impl_witness.loc13
|
|
|
+// CHECK:STDOUT: witness = file.%I.impl_witness.loc9
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT:
|
|
|
// CHECK:STDOUT: impl @impl.7704ae.2: %tuple.elem0 as %I.ref {
|
|
|
// CHECK:STDOUT: !members:
|
|
|
-// CHECK:STDOUT: witness = file.%I.impl_witness.loc14
|
|
|
+// CHECK:STDOUT: witness = file.%I.impl_witness.loc17
|
|
|
// CHECK:STDOUT: }
|
|
|
// CHECK:STDOUT:
|
|
|
// CHECK:STDOUT: class @C;
|