mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:30:12 +01:00
In #7436 we stopped substituting `.Self` when collecting witnesses out of a facet type. While this was correct, it did not capture all the cases that need to avoid substituting `.Self`. And it poisoned the `IdentifiedFacetType` cache by not replacing `.Self` but storing the result in the cache. This led to incoherent behaviour, where the result of an impl lookup would change depending on which ones had been done previously. Now we use a flag to track for each `.Self` if we're currently type-checking inside the scope where it was introduced in a facet type. While inside that scope, identify should not replace the `.Self`. Any use of it should remain as-is since we don't yet know what value will replace it. We call this state "frozen" since it should not be modified by identify. This requires a substitution step when we leave the scope that introduced the `.Self`, to remove the flag. The flag is set in the `EntityName` of the `SymbolicBinding`, and is part of the canonical value, since `.Self` can become part of types, which are constants, and the flag needs to follow it for correct behaviour. We also have to ensure the flag is the same when doing comparison with constants from inside a facet type and constants from outside. For instance in `(Z where .Z1 = ()) where .Z2 = .Z1`, when we arrive at the second `.Z1` its `.Self` will be frozen, while the `.Z1 = ()` contains a non-frozen `.Self`. So we add the frozen flag to the first when storing it in `where_stack` in order to compare the constant values of the two `.Z1`. The `WhereExpr` requirement inst kinds now have an `InstConstantKind` of `AlwaysUnique` instead of `Never`. This allows us to add them to the usual InstBlocks, and in an `eval fn` body they have a constant value, so eval does not fail when trying to call that function. We have to be careful to not consider `AlwaysUnique` as being actually concrete though, since their constant value erases `.Self`-dependence. This allows us to stop special casing them when thawing the requirements block in a `WhereExpr`, and we can just thaw each `InstId` in the block in a straightforward manner. We add the new flag to the instruction's fingerprint and name in formatted semir.
541 lines
31 KiB
Plaintext
541 lines
31 KiB
Plaintext
// 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
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
|
|
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
|
|
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/generic_vs_params.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/generic_vs_params.carbon
|
|
|
|
// --- params.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class NotGenericNoParams {}
|
|
class NotGenericButParams() {}
|
|
class GenericAndParams(T:! type) {}
|
|
|
|
class C(T:! type) {
|
|
class GenericNoParams {}
|
|
class GenericAndParams(U:! type) {}
|
|
}
|
|
|
|
class X {}
|
|
|
|
var a: NotGenericNoParams = {};
|
|
var b: NotGenericButParams() = {};
|
|
var c: GenericAndParams(X) = {};
|
|
var d: C(X).GenericNoParams = {};
|
|
var e: C(X).GenericAndParams(X) = {};
|
|
|
|
// --- fail_non_generic_implicit_params.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_non_generic_implicit_params.carbon:[[@LINE+4]]:9: error: parameters of generic types must be constant [GenericParamMustBeConstant]
|
|
// CHECK:STDERR: class A[T: type]() {}
|
|
// CHECK:STDERR: ^~~~~~~
|
|
// CHECK:STDERR:
|
|
class A[T: type]() {}
|
|
|
|
// --- fail_non_generic_params.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_non_generic_params.carbon:[[@LINE+4]]:9: error: parameters of generic types must be constant [GenericParamMustBeConstant]
|
|
// CHECK:STDERR: class A(T: type) {}
|
|
// CHECK:STDERR: ^~~~~~~
|
|
// CHECK:STDERR:
|
|
class A(T: type) {}
|
|
|
|
// This is testing a use of the invalid type.
|
|
fn F(T:! type) {
|
|
A(T);
|
|
}
|
|
|
|
// --- fail_implicit_params_only_empty.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_implicit_params_only_empty.carbon:[[@LINE+4]]:10: error: expected explicit parameters after implicit parameters [GenericMissingExplicitParameters]
|
|
// CHECK:STDERR: class Foo[];
|
|
// CHECK:STDERR: ^~
|
|
// CHECK:STDERR:
|
|
class Foo[];
|
|
|
|
// --- fail_implicit_params_only.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_implicit_params_only.carbon:[[@LINE+4]]:10: error: expected explicit parameters after implicit parameters [GenericMissingExplicitParameters]
|
|
// CHECK:STDERR: class Foo[T:! type];
|
|
// CHECK:STDERR: ^~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
class Foo[T:! type];
|
|
|
|
// CHECK:STDOUT: --- params.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %NotGenericNoParams: type = class_type @NotGenericNoParams [concrete]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
|
|
// CHECK:STDOUT: %NotGenericButParams.type: type = generic_class_type @NotGenericButParams [concrete]
|
|
// CHECK:STDOUT: %NotGenericButParams.generic: %NotGenericButParams.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %NotGenericButParams: type = class_type @NotGenericButParams [concrete]
|
|
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self]
|
|
// CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
|
|
// CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [symbolic]
|
|
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
|
|
// CHECK:STDOUT: %GenericAndParams.type.aa5: type = generic_class_type @GenericAndParams.loc6 [concrete]
|
|
// CHECK:STDOUT: %GenericAndParams.generic.128: %GenericAndParams.type.aa5 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %GenericAndParams.bd1: type = class_type @GenericAndParams.loc6, @GenericAndParams.loc6(%T) [symbolic]
|
|
// CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete]
|
|
// CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %C.1d0: type = class_type @C, @C(%T) [symbolic]
|
|
// CHECK:STDOUT: %GenericNoParams.8d1: type = class_type @GenericNoParams, @GenericNoParams(%T) [symbolic]
|
|
// CHECK:STDOUT: %U.patt: %pattern_type.98f = symbolic_binding_pattern U, 1 [symbolic]
|
|
// CHECK:STDOUT: %U: type = symbolic_binding U, 1 [symbolic]
|
|
// CHECK:STDOUT: %GenericAndParams.type.c37: type = generic_class_type @GenericAndParams.loc10, @C(%T) [symbolic]
|
|
// CHECK:STDOUT: %GenericAndParams.generic.6c8: %GenericAndParams.type.c37 = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %GenericAndParams.423: type = class_type @GenericAndParams.loc10, @GenericAndParams.loc10(%T, %U) [symbolic]
|
|
// CHECK:STDOUT: %X: type = class_type @X [concrete]
|
|
// CHECK:STDOUT: %pattern_type.2dc: type = pattern_type %NotGenericNoParams [concrete]
|
|
// CHECK:STDOUT: %a.patt: %pattern_type.2dc = ref_binding_pattern a [concrete]
|
|
// CHECK:STDOUT: %a.var_patt: %pattern_type.2dc = var_pattern %a.patt [concrete]
|
|
// CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %NotGenericNoParams.val: %NotGenericNoParams = struct_value () [concrete]
|
|
// CHECK:STDOUT: %pattern_type.8e7: type = pattern_type %NotGenericButParams [concrete]
|
|
// CHECK:STDOUT: %b.patt: %pattern_type.8e7 = ref_binding_pattern b [concrete]
|
|
// CHECK:STDOUT: %b.var_patt: %pattern_type.8e7 = var_pattern %b.patt [concrete]
|
|
// CHECK:STDOUT: %NotGenericButParams.val: %NotGenericButParams = struct_value () [concrete]
|
|
// CHECK:STDOUT: %GenericAndParams.421: type = class_type @GenericAndParams.loc6, @GenericAndParams.loc6(%X) [concrete]
|
|
// CHECK:STDOUT: %pattern_type.053: type = pattern_type %GenericAndParams.421 [concrete]
|
|
// CHECK:STDOUT: %c.patt: %pattern_type.053 = ref_binding_pattern c [concrete]
|
|
// CHECK:STDOUT: %c.var_patt: %pattern_type.053 = var_pattern %c.patt [concrete]
|
|
// CHECK:STDOUT: %GenericAndParams.val.83c: %GenericAndParams.421 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %C.a43: type = class_type @C, @C(%X) [concrete]
|
|
// CHECK:STDOUT: %GenericNoParams.ee8: type = class_type @GenericNoParams, @GenericNoParams(%X) [concrete]
|
|
// CHECK:STDOUT: %GenericAndParams.type.4b3: type = generic_class_type @GenericAndParams.loc10, @C(%X) [concrete]
|
|
// CHECK:STDOUT: %GenericAndParams.generic.e4e: %GenericAndParams.type.4b3 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %pattern_type.a4a: type = pattern_type %GenericNoParams.ee8 [concrete]
|
|
// CHECK:STDOUT: %d.patt: %pattern_type.a4a = ref_binding_pattern d [concrete]
|
|
// CHECK:STDOUT: %d.var_patt: %pattern_type.a4a = var_pattern %d.patt [concrete]
|
|
// CHECK:STDOUT: %GenericNoParams.val: %GenericNoParams.ee8 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %GenericAndParams.353: type = class_type @GenericAndParams.loc10, @GenericAndParams.loc10(%X, %X) [concrete]
|
|
// CHECK:STDOUT: %pattern_type.4e2: type = pattern_type %GenericAndParams.353 [concrete]
|
|
// CHECK:STDOUT: %e.patt: %pattern_type.4e2 = ref_binding_pattern e [concrete]
|
|
// CHECK:STDOUT: %e.var_patt: %pattern_type.4e2 = var_pattern %e.patt [concrete]
|
|
// CHECK:STDOUT: %GenericAndParams.val.150: %GenericAndParams.353 = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .NotGenericNoParams = %NotGenericNoParams.decl
|
|
// CHECK:STDOUT: .NotGenericButParams = %NotGenericButParams.decl
|
|
// CHECK:STDOUT: .GenericAndParams = %GenericAndParams.decl
|
|
// CHECK:STDOUT: .C = %C.decl
|
|
// CHECK:STDOUT: .X = %X.decl
|
|
// CHECK:STDOUT: .a = %a
|
|
// CHECK:STDOUT: .b = %b
|
|
// CHECK:STDOUT: .c = %c
|
|
// CHECK:STDOUT: .d = %d
|
|
// CHECK:STDOUT: .e = %e
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %NotGenericNoParams.decl: type = class_decl @NotGenericNoParams [concrete = constants.%NotGenericNoParams] {} {}
|
|
// CHECK:STDOUT: %NotGenericButParams.decl: %NotGenericButParams.type = class_decl @NotGenericButParams [concrete = constants.%NotGenericButParams.generic] {} {}
|
|
// CHECK:STDOUT: %GenericAndParams.decl: %GenericAndParams.type.aa5 = class_decl @GenericAndParams.loc6 [concrete = constants.%GenericAndParams.generic.128] {
|
|
// CHECK:STDOUT: %T.patt.loc6_25.1: %pattern_type.98f = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_25.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %.loc6_28.1: type = splice_block %.loc6_28.2 [concrete = type] {
|
|
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
|
// CHECK:STDOUT: %.loc6_28.2: type = type_literal type [concrete = type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %T.loc6_25.2: type = symbolic_binding T, 0 [symbolic = %T.loc6_25.1 (constants.%T)]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %C.decl: %C.type = class_decl @C [concrete = constants.%C.generic] {
|
|
// CHECK:STDOUT: %T.patt.loc8_10.1: %pattern_type.98f = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_10.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %.loc8_13.1: type = splice_block %.loc8_13.2 [concrete = type] {
|
|
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
|
// CHECK:STDOUT: %.loc8_13.2: type = type_literal type [concrete = type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %T.loc8_10.2: type = symbolic_binding T, 0 [symbolic = %T.loc8_10.1 (constants.%T)]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %X.decl: type = class_decl @X [concrete = constants.%X] {} {}
|
|
// CHECK:STDOUT: %a.var: ref %NotGenericNoParams = var_storage %a.var_patt [concrete]
|
|
// CHECK:STDOUT: %NotGenericNoParams.ref: type = name_ref NotGenericNoParams, %NotGenericNoParams.decl [concrete = constants.%NotGenericNoParams]
|
|
// CHECK:STDOUT: %a: ref %NotGenericNoParams = wrapper_binding a, %a.var [concrete = %a.var]
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %a.patt: %pattern_type.2dc = ref_binding_pattern a [concrete = constants.%a.patt]
|
|
// CHECK:STDOUT: %a.var_patt: %pattern_type.2dc = var_pattern %a.patt [concrete = constants.%a.var_patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %b.var: ref %NotGenericButParams = var_storage %b.var_patt [concrete]
|
|
// CHECK:STDOUT: %.loc16: type = splice_block %NotGenericButParams [concrete = constants.%NotGenericButParams] {
|
|
// CHECK:STDOUT: %NotGenericButParams.ref: %NotGenericButParams.type = name_ref NotGenericButParams, %NotGenericButParams.decl [concrete = constants.%NotGenericButParams.generic]
|
|
// CHECK:STDOUT: %NotGenericButParams: type = class_type @NotGenericButParams [concrete = constants.%NotGenericButParams]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %b: ref %NotGenericButParams = wrapper_binding b, %b.var [concrete = %b.var]
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %b.patt: %pattern_type.8e7 = ref_binding_pattern b [concrete = constants.%b.patt]
|
|
// CHECK:STDOUT: %b.var_patt: %pattern_type.8e7 = var_pattern %b.patt [concrete = constants.%b.var_patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %c.var: ref %GenericAndParams.421 = var_storage %c.var_patt [concrete]
|
|
// CHECK:STDOUT: %.loc17: type = splice_block %GenericAndParams.loc17 [concrete = constants.%GenericAndParams.421] {
|
|
// CHECK:STDOUT: %GenericAndParams.ref.loc17: %GenericAndParams.type.aa5 = name_ref GenericAndParams, %GenericAndParams.decl [concrete = constants.%GenericAndParams.generic.128]
|
|
// CHECK:STDOUT: %X.ref.loc17: type = name_ref X, %X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %GenericAndParams.loc17: type = class_type @GenericAndParams.loc6, @GenericAndParams.loc6(constants.%X) [concrete = constants.%GenericAndParams.421]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %c: ref %GenericAndParams.421 = wrapper_binding c, %c.var [concrete = %c.var]
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %c.patt: %pattern_type.053 = ref_binding_pattern c [concrete = constants.%c.patt]
|
|
// CHECK:STDOUT: %c.var_patt: %pattern_type.053 = var_pattern %c.patt [concrete = constants.%c.var_patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %d.var: ref %GenericNoParams.ee8 = var_storage %d.var_patt [concrete]
|
|
// CHECK:STDOUT: %.loc18_12.1: type = splice_block %GenericNoParams.ref [concrete = constants.%GenericNoParams.ee8] {
|
|
// CHECK:STDOUT: %C.ref.loc18: %C.type = name_ref C, %C.decl [concrete = constants.%C.generic]
|
|
// CHECK:STDOUT: %X.ref.loc18: type = name_ref X, %X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %C.loc18: type = class_type @C, @C(constants.%X) [concrete = constants.%C.a43]
|
|
// CHECK:STDOUT: %.loc18_12.2: type = specific_constant @C.%GenericNoParams.decl, @C(constants.%X) [concrete = constants.%GenericNoParams.ee8]
|
|
// CHECK:STDOUT: %GenericNoParams.ref: type = name_ref GenericNoParams, %.loc18_12.2 [concrete = constants.%GenericNoParams.ee8]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %d: ref %GenericNoParams.ee8 = wrapper_binding d, %d.var [concrete = %d.var]
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %d.patt: %pattern_type.a4a = ref_binding_pattern d [concrete = constants.%d.patt]
|
|
// CHECK:STDOUT: %d.var_patt: %pattern_type.a4a = var_pattern %d.patt [concrete = constants.%d.var_patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %e.var: ref %GenericAndParams.353 = var_storage %e.var_patt [concrete]
|
|
// CHECK:STDOUT: %.loc19_31: type = splice_block %GenericAndParams.loc19 [concrete = constants.%GenericAndParams.353] {
|
|
// CHECK:STDOUT: %C.ref.loc19: %C.type = name_ref C, %C.decl [concrete = constants.%C.generic]
|
|
// CHECK:STDOUT: %X.ref.loc19_10: type = name_ref X, %X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %C.loc19: type = class_type @C, @C(constants.%X) [concrete = constants.%C.a43]
|
|
// CHECK:STDOUT: %.loc19_12: %GenericAndParams.type.4b3 = specific_constant @C.%GenericAndParams.decl, @C(constants.%X) [concrete = constants.%GenericAndParams.generic.e4e]
|
|
// CHECK:STDOUT: %GenericAndParams.ref.loc19: %GenericAndParams.type.4b3 = name_ref GenericAndParams, %.loc19_12 [concrete = constants.%GenericAndParams.generic.e4e]
|
|
// CHECK:STDOUT: %X.ref.loc19_30: type = name_ref X, %X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %GenericAndParams.loc19: type = class_type @GenericAndParams.loc10, @GenericAndParams.loc10(constants.%X, constants.%X) [concrete = constants.%GenericAndParams.353]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %e: ref %GenericAndParams.353 = wrapper_binding e, %e.var [concrete = %e.var]
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %e.patt: %pattern_type.4e2 = ref_binding_pattern e [concrete = constants.%e.patt]
|
|
// CHECK:STDOUT: %e.var_patt: %pattern_type.4e2 = var_pattern %e.patt [concrete = constants.%e.var_patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @NotGenericNoParams {
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%NotGenericNoParams
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @NotGenericButParams {
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%NotGenericButParams
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic class @GenericAndParams.loc6(%T.loc6_25.2: type) {
|
|
// CHECK:STDOUT: %T.patt.loc6_25.2: %pattern_type.98f = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_25.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT: %T.loc6_25.1: type = symbolic_binding T, 0 [symbolic = %T.loc6_25.1 (constants.%T)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class {
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%GenericAndParams.bd1
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic class @C(%T.loc8_10.2: type) {
|
|
// CHECK:STDOUT: %T.patt.loc8_10.2: %pattern_type.98f = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_10.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT: %T.loc8_10.1: type = symbolic_binding T, 0 [symbolic = %T.loc8_10.1 (constants.%T)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %GenericNoParams: type = class_type @GenericNoParams, @GenericNoParams(%T.loc8_10.1) [symbolic = %GenericNoParams (constants.%GenericNoParams.8d1)]
|
|
// CHECK:STDOUT: %GenericAndParams.type: type = generic_class_type @GenericAndParams.loc10, @C(%T.loc8_10.1) [symbolic = %GenericAndParams.type (constants.%GenericAndParams.type.c37)]
|
|
// CHECK:STDOUT: %GenericAndParams.generic: @C.%GenericAndParams.type (%GenericAndParams.type.c37) = struct_value () [symbolic = %GenericAndParams.generic (constants.%GenericAndParams.generic.6c8)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class {
|
|
// CHECK:STDOUT: %GenericNoParams.decl: type = class_decl @GenericNoParams [symbolic = @C.%GenericNoParams (constants.%GenericNoParams.8d1)] {} {}
|
|
// CHECK:STDOUT: %GenericAndParams.decl: @C.%GenericAndParams.type (%GenericAndParams.type.c37) = class_decl @GenericAndParams.loc10 [symbolic = @C.%GenericAndParams.generic (constants.%GenericAndParams.generic.6c8)] {
|
|
// CHECK:STDOUT: %U.patt.loc10_27.1: %pattern_type.98f = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc10_27.2 (constants.%U.patt)]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %.loc10_30.1: type = splice_block %.loc10_30.2 [concrete = type] {
|
|
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
|
// CHECK:STDOUT: %.loc10_30.2: type = type_literal type [concrete = type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %U.loc10_27.2: type = symbolic_binding U, 1 [symbolic = %U.loc10_27.1 (constants.%U)]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%C.1d0
|
|
// CHECK:STDOUT: .GenericNoParams = %GenericNoParams.decl
|
|
// CHECK:STDOUT: .GenericAndParams = %GenericAndParams.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic class @GenericNoParams(@C.%T.loc8_10.2: type) {
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class {
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%GenericNoParams.8d1
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic class @GenericAndParams.loc10(@C.%T.loc8_10.2: type, %U.loc10_27.2: type) {
|
|
// CHECK:STDOUT: %U.patt.loc10_27.2: %pattern_type.98f = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc10_27.2 (constants.%U.patt)]
|
|
// CHECK:STDOUT: %U.loc10_27.1: type = symbolic_binding U, 1 [symbolic = %U.loc10_27.1 (constants.%U)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class {
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%GenericAndParams.423
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @X {
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%X
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @__global_init() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %.loc15_30.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
|
|
// CHECK:STDOUT: %.loc15_30.2: init %NotGenericNoParams to file.%a.var = class_init () [concrete = constants.%NotGenericNoParams.val]
|
|
// CHECK:STDOUT: %.loc15_1: init %NotGenericNoParams = converted %.loc15_30.1, %.loc15_30.2 [concrete = constants.%NotGenericNoParams.val]
|
|
// CHECK:STDOUT: assign file.%a.var, %.loc15_1
|
|
// CHECK:STDOUT: %.loc16_33.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
|
|
// CHECK:STDOUT: %.loc16_33.2: init %NotGenericButParams to file.%b.var = class_init () [concrete = constants.%NotGenericButParams.val]
|
|
// CHECK:STDOUT: %.loc16_1: init %NotGenericButParams = converted %.loc16_33.1, %.loc16_33.2 [concrete = constants.%NotGenericButParams.val]
|
|
// CHECK:STDOUT: assign file.%b.var, %.loc16_1
|
|
// CHECK:STDOUT: %.loc17_31.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
|
|
// CHECK:STDOUT: %.loc17_31.2: init %GenericAndParams.421 to file.%c.var = class_init () [concrete = constants.%GenericAndParams.val.83c]
|
|
// CHECK:STDOUT: %.loc17_1: init %GenericAndParams.421 = converted %.loc17_31.1, %.loc17_31.2 [concrete = constants.%GenericAndParams.val.83c]
|
|
// CHECK:STDOUT: assign file.%c.var, %.loc17_1
|
|
// CHECK:STDOUT: %.loc18_32.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
|
|
// CHECK:STDOUT: %.loc18_32.2: init %GenericNoParams.ee8 to file.%d.var = class_init () [concrete = constants.%GenericNoParams.val]
|
|
// CHECK:STDOUT: %.loc18_1: init %GenericNoParams.ee8 = converted %.loc18_32.1, %.loc18_32.2 [concrete = constants.%GenericNoParams.val]
|
|
// CHECK:STDOUT: assign file.%d.var, %.loc18_1
|
|
// CHECK:STDOUT: %.loc19_36.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
|
|
// CHECK:STDOUT: %.loc19_36.2: init %GenericAndParams.353 to file.%e.var = class_init () [concrete = constants.%GenericAndParams.val.150]
|
|
// CHECK:STDOUT: %.loc19_1: init %GenericAndParams.353 = converted %.loc19_36.1, %.loc19_36.2 [concrete = constants.%GenericAndParams.val.150]
|
|
// CHECK:STDOUT: assign file.%e.var, %.loc19_1
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !observes:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @GenericAndParams.loc6(constants.%T) {
|
|
// CHECK:STDOUT: %T.patt.loc6_25.2 => constants.%T.patt
|
|
// CHECK:STDOUT: %T.loc6_25.1 => constants.%T
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @C(constants.%T) {
|
|
// CHECK:STDOUT: %T.patt.loc8_10.2 => constants.%T.patt
|
|
// CHECK:STDOUT: %T.loc8_10.1 => constants.%T
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @GenericNoParams(constants.%T) {}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @GenericAndParams.loc10(constants.%T, constants.%U) {
|
|
// CHECK:STDOUT: %U.patt.loc10_27.2 => constants.%U.patt
|
|
// CHECK:STDOUT: %U.loc10_27.1 => constants.%U
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @GenericAndParams.loc6(constants.%X) {
|
|
// CHECK:STDOUT: %T.patt.loc6_25.2 => constants.%T.patt
|
|
// CHECK:STDOUT: %T.loc6_25.1 => constants.%X
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @C(constants.%X) {
|
|
// CHECK:STDOUT: %T.patt.loc8_10.2 => constants.%T.patt
|
|
// CHECK:STDOUT: %T.loc8_10.1 => constants.%X
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %GenericNoParams => constants.%GenericNoParams.ee8
|
|
// CHECK:STDOUT: %GenericAndParams.type => constants.%GenericAndParams.type.4b3
|
|
// CHECK:STDOUT: %GenericAndParams.generic => constants.%GenericAndParams.generic.e4e
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @GenericNoParams(constants.%X) {
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @GenericAndParams.loc10(constants.%X, constants.%X) {
|
|
// CHECK:STDOUT: %U.patt.loc10_27.2 => constants.%U.patt
|
|
// CHECK:STDOUT: %U.loc10_27.1 => constants.%X
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_non_generic_implicit_params.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %A.type: type = generic_class_type @A [concrete]
|
|
// CHECK:STDOUT: %A.generic: %A.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %A: type = class_type @A [concrete]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .A = %A.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %A.decl: %A.type = class_decl @A [concrete = constants.%A.generic] {} {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @A {
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%A
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_non_generic_params.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %A.type: type = generic_class_type @A [concrete]
|
|
// CHECK:STDOUT: %A.generic: %A.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %A: type = class_type @A [concrete]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
|
|
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self]
|
|
// CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
|
|
// CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [symbolic]
|
|
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
|
|
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
|
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .A = %A.decl
|
|
// CHECK:STDOUT: .F = %F.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %A.decl: %A.type = class_decl @A [concrete = constants.%A.generic] {} {}
|
|
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
|
|
// CHECK:STDOUT: %T.patt.loc11_7.1: %pattern_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_7.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %.loc11_10.1: type = splice_block %.loc11_10.2 [concrete = type] {
|
|
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
|
// CHECK:STDOUT: %.loc11_10.2: type = type_literal type [concrete = type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %T.loc11_7.2: type = symbolic_binding T, 0 [symbolic = %T.loc11_7.1 (constants.%T)]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @A {
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%A
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic fn @F(%T.loc11_7.2: type) {
|
|
// CHECK:STDOUT: %T.patt.loc11_7.2: %pattern_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_7.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT: %T.loc11_7.1: type = symbolic_binding T, 0 [symbolic = %T.loc11_7.1 (constants.%T)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [concrete = constants.%A.generic]
|
|
// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11_7.2 [symbolic = %T.loc11_7.1 (constants.%T)]
|
|
// CHECK:STDOUT: %A: type = class_type @A [concrete = constants.%A]
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !observes:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @F(constants.%T) {
|
|
// CHECK:STDOUT: %T.patt.loc11_7.2 => constants.%T.patt
|
|
// CHECK:STDOUT: %T.loc11_7.1 => constants.%T
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_implicit_params_only_empty.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [concrete]
|
|
// CHECK:STDOUT: %Foo.generic: %Foo.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .Foo = %Foo.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [concrete = constants.%Foo.generic] {} {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Foo;
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_implicit_params_only.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self]
|
|
// CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
|
|
// CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [symbolic]
|
|
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
|
|
// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [concrete]
|
|
// CHECK:STDOUT: %Foo.generic: %Foo.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .Foo = %Foo.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [concrete = constants.%Foo.generic] {
|
|
// CHECK:STDOUT: %T.patt.loc8_12.1: %pattern_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_12.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %.loc8_15.1: type = splice_block %.loc8_15.2 [concrete = type] {
|
|
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
|
// CHECK:STDOUT: %.loc8_15.2: type = type_literal type [concrete = type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %T.loc8_12.2: type = symbolic_binding T, 0 [symbolic = %T.loc8_12.1 (constants.%T)]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic class @Foo(%T.loc8_12.2: type) {
|
|
// CHECK:STDOUT: %T.patt.loc8_12.2: %pattern_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_12.2 (constants.%T.patt)]
|
|
// CHECK:STDOUT: %T.loc8_12.1: type = symbolic_binding T, 0 [symbolic = %T.loc8_12.1 (constants.%T)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class;
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @Foo(constants.%T) {
|
|
// CHECK:STDOUT: %T.patt.loc8_12.2 => constants.%T.patt
|
|
// CHECK:STDOUT: %T.loc8_12.1 => constants.%T
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|