|
|
@@ -0,0 +1,330 @@
|
|
|
+// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
|
+// Exceptions. See /LICENSE for license information.
|
|
|
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
+//
|
|
|
+// AUTOUPDATE
|
|
|
+// TIP: To test this file alone, run:
|
|
|
+// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/no_prelude/no_definition_in_impl_file.carbon
|
|
|
+// TIP: To dump output, run:
|
|
|
+// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/no_definition_in_impl_file.carbon
|
|
|
+
|
|
|
+// --- decl_in_api_definition_in_impl.carbon
|
|
|
+
|
|
|
+library "decl_in_api_definition_in_impl";
|
|
|
+
|
|
|
+interface A {};
|
|
|
+
|
|
|
+impl () as A;
|
|
|
+
|
|
|
+// --- decl_in_api_definition_in_impl.impl.carbon
|
|
|
+
|
|
|
+impl library "decl_in_api_definition_in_impl";
|
|
|
+
|
|
|
+impl () as A;
|
|
|
+
|
|
|
+impl () as A {}
|
|
|
+
|
|
|
+// --- use_decl_in_api.carbon
|
|
|
+
|
|
|
+library "use_decl_in_api";
|
|
|
+
|
|
|
+// --- use_decl_in_api.impl.carbon
|
|
|
+
|
|
|
+impl library "use_decl_in_api";
|
|
|
+
|
|
|
+import library "decl_in_api_definition_in_impl";
|
|
|
+
|
|
|
+// --- decl_only_in_api.carbon
|
|
|
+
|
|
|
+library "decl_only_in_api";
|
|
|
+
|
|
|
+interface B {};
|
|
|
+
|
|
|
+impl () as B;
|
|
|
+
|
|
|
+// --- decl_only_in_api.impl.carbon
|
|
|
+
|
|
|
+impl library "decl_only_in_api";
|
|
|
+
|
|
|
+// --- decl_in_api_decl_in_impl.carbon
|
|
|
+
|
|
|
+library "decl_in_api_decl_in_impl";
|
|
|
+
|
|
|
+interface C {};
|
|
|
+
|
|
|
+impl () as C;
|
|
|
+
|
|
|
+// --- fail_decl_in_api_decl_in_impl.impl.carbon
|
|
|
+
|
|
|
+impl library "decl_in_api_decl_in_impl";
|
|
|
+
|
|
|
+// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+4]]:1: ERROR: No definition found for declaration in impl file
|
|
|
+// CHECK:STDERR: impl () as C;
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
+impl () as C;
|
|
|
+
|
|
|
+// --- decl_only_in_impl.carbon
|
|
|
+
|
|
|
+library "decl_only_in_impl";
|
|
|
+
|
|
|
+// --- fail_decl_only_in_impl.impl.carbon
|
|
|
+
|
|
|
+impl library "decl_only_in_impl";
|
|
|
+
|
|
|
+interface D {};
|
|
|
+
|
|
|
+// CHECK:STDERR: fail_decl_only_in_impl.impl.carbon:[[@LINE+3]]:1: ERROR: No definition found for declaration in impl file
|
|
|
+// CHECK:STDERR: impl () as D;
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~
|
|
|
+impl () as D;
|
|
|
+
|
|
|
+// CHECK:STDOUT: --- decl_in_api_definition_in_impl.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: constants {
|
|
|
+// CHECK:STDOUT: %.1: type = interface_type @A [template]
|
|
|
+// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
|
|
|
+// CHECK:STDOUT: %.2: type = tuple_type () [template]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
|
+// CHECK:STDOUT: .A = %A.decl
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: %A.decl: type = interface_decl @A [template = constants.%.1] {}
|
|
|
+// CHECK:STDOUT: impl_decl @impl {
|
|
|
+// CHECK:STDOUT: %.loc6_7.1: %.2 = tuple_literal ()
|
|
|
+// CHECK:STDOUT: %.loc6_7.2: type = converted %.loc6_7.1, constants.%.2 [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%.1]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: interface @A {
|
|
|
+// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: !members:
|
|
|
+// CHECK:STDOUT: .Self = %Self
|
|
|
+// CHECK:STDOUT: witness = ()
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: impl @impl: %.2 as %.1;
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: --- decl_in_api_definition_in_impl.impl.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: constants {
|
|
|
+// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
|
|
+// CHECK:STDOUT: %.2: type = interface_type @A [template]
|
|
|
+// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic]
|
|
|
+// CHECK:STDOUT: %.3: <witness> = interface_witness () [template]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
|
+// CHECK:STDOUT: .A = %import_ref.1
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+1, loaded [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+3, unloaded
|
|
|
+// CHECK:STDOUT: impl_decl @impl {
|
|
|
+// CHECK:STDOUT: %.loc4_7.1: %.1 = tuple_literal ()
|
|
|
+// CHECK:STDOUT: %.loc4_7.2: type = converted %.loc4_7.1, constants.%.1 [template = constants.%.1]
|
|
|
+// CHECK:STDOUT: %A.ref.loc4: type = name_ref A, %import_ref.1 [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: impl_decl @impl {
|
|
|
+// CHECK:STDOUT: %.loc6_7.1: %.1 = tuple_literal ()
|
|
|
+// CHECK:STDOUT: %.loc6_7.2: type = converted %.loc6_7.1, constants.%.1 [template = constants.%.1]
|
|
|
+// CHECK:STDOUT: %A.ref.loc6: type = name_ref A, %import_ref.1 [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: interface @A {
|
|
|
+// CHECK:STDOUT: !members:
|
|
|
+// CHECK:STDOUT: .Self = file.%import_ref.2
|
|
|
+// CHECK:STDOUT: witness = ()
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: impl @impl: %.1 as %.2 {
|
|
|
+// CHECK:STDOUT: %.1: <witness> = interface_witness () [template = constants.%.3]
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: !members:
|
|
|
+// CHECK:STDOUT: witness = %.1
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: --- use_decl_in_api.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: package: <namespace> = namespace [template] {}
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: --- use_decl_in_api.impl.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: constants {
|
|
|
+// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
|
|
+// CHECK:STDOUT: %.2: type = interface_type @A [template]
|
|
|
+// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
|
+// CHECK:STDOUT: .A = %import_ref.1
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded
|
|
|
+// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+3, unloaded
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: interface @A {
|
|
|
+// CHECK:STDOUT: !members:
|
|
|
+// CHECK:STDOUT: .Self = file.%import_ref.2
|
|
|
+// CHECK:STDOUT: witness = ()
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: impl @impl: %.1 as %.2;
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: --- decl_only_in_api.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: constants {
|
|
|
+// CHECK:STDOUT: %.1: type = interface_type @B [template]
|
|
|
+// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
|
|
|
+// CHECK:STDOUT: %.2: type = tuple_type () [template]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
|
+// CHECK:STDOUT: .B = %B.decl
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: %B.decl: type = interface_decl @B [template = constants.%.1] {}
|
|
|
+// CHECK:STDOUT: impl_decl @impl {
|
|
|
+// CHECK:STDOUT: %.loc6_7.1: %.2 = tuple_literal ()
|
|
|
+// CHECK:STDOUT: %.loc6_7.2: type = converted %.loc6_7.1, constants.%.2 [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%.1]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: interface @B {
|
|
|
+// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: !members:
|
|
|
+// CHECK:STDOUT: .Self = %Self
|
|
|
+// CHECK:STDOUT: witness = ()
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: impl @impl: %.2 as %.1;
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: --- decl_only_in_api.impl.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: constants {
|
|
|
+// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
|
|
+// CHECK:STDOUT: %.2: type = interface_type @B [template]
|
|
|
+// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
|
+// CHECK:STDOUT: .B = %import_ref.1
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+1, unloaded
|
|
|
+// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+3, unloaded
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: interface @B {
|
|
|
+// CHECK:STDOUT: !members:
|
|
|
+// CHECK:STDOUT: .Self = file.%import_ref.2
|
|
|
+// CHECK:STDOUT: witness = ()
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: impl @impl: %.1 as %.2;
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: --- decl_in_api_decl_in_impl.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: constants {
|
|
|
+// CHECK:STDOUT: %.1: type = interface_type @C [template]
|
|
|
+// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
|
|
|
+// CHECK:STDOUT: %.2: type = tuple_type () [template]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
|
+// CHECK:STDOUT: .C = %C.decl
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: %C.decl: type = interface_decl @C [template = constants.%.1] {}
|
|
|
+// CHECK:STDOUT: impl_decl @impl {
|
|
|
+// CHECK:STDOUT: %.loc6_7.1: %.2 = tuple_literal ()
|
|
|
+// CHECK:STDOUT: %.loc6_7.2: type = converted %.loc6_7.1, constants.%.2 [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%.1]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: interface @C {
|
|
|
+// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: !members:
|
|
|
+// CHECK:STDOUT: .Self = %Self
|
|
|
+// CHECK:STDOUT: witness = ()
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: impl @impl: %.2 as %.1;
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: --- fail_decl_in_api_decl_in_impl.impl.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: constants {
|
|
|
+// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
|
|
+// CHECK:STDOUT: %.2: type = interface_type @C [template]
|
|
|
+// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
|
+// CHECK:STDOUT: .C = %import_ref.1
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+1, loaded [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+3, unloaded
|
|
|
+// CHECK:STDOUT: impl_decl @impl {
|
|
|
+// CHECK:STDOUT: %.loc8_7.1: %.1 = tuple_literal ()
|
|
|
+// CHECK:STDOUT: %.loc8_7.2: type = converted %.loc8_7.1, constants.%.1 [template = constants.%.1]
|
|
|
+// CHECK:STDOUT: %C.ref: type = name_ref C, %import_ref.1 [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: interface @C {
|
|
|
+// CHECK:STDOUT: !members:
|
|
|
+// CHECK:STDOUT: .Self = file.%import_ref.2
|
|
|
+// CHECK:STDOUT: witness = ()
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: impl @impl: %.1 as %.2;
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: --- decl_only_in_impl.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: package: <namespace> = namespace [template] {}
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: --- fail_decl_only_in_impl.impl.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: constants {
|
|
|
+// CHECK:STDOUT: %.1: type = interface_type @D [template]
|
|
|
+// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
|
|
|
+// CHECK:STDOUT: %.2: type = tuple_type () [template]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
|
+// CHECK:STDOUT: .D = %D.decl
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: %D.decl: type = interface_decl @D [template = constants.%.1] {}
|
|
|
+// CHECK:STDOUT: impl_decl @impl {
|
|
|
+// CHECK:STDOUT: %.loc9_7.1: %.2 = tuple_literal ()
|
|
|
+// CHECK:STDOUT: %.loc9_7.2: type = converted %.loc9_7.1, constants.%.2 [template = constants.%.2]
|
|
|
+// CHECK:STDOUT: %D.ref: type = name_ref D, %D.decl [template = constants.%.1]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: interface @D {
|
|
|
+// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: !members:
|
|
|
+// CHECK:STDOUT: .Self = %Self
|
|
|
+// CHECK:STDOUT: witness = ()
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: impl @impl: %.2 as %.1;
|
|
|
+// CHECK:STDOUT:
|