mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-24 11:32:42 +00:00
This is modeled analogously to FunctionType. So far, GenericClassType has no operations, but eventually values of that type will be callable like values of FunctionType. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
132 lines
5.2 KiB
Plaintext
132 lines
5.2 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
|
|
//
|
|
// AUTOUPDATE
|
|
|
|
// --- foo.carbon
|
|
|
|
library "foo" api;
|
|
|
|
class Class(T:! type);
|
|
|
|
// --- foo.impl.carbon
|
|
|
|
library "foo" impl;
|
|
|
|
class Class(T:! type) {
|
|
var x: T;
|
|
}
|
|
|
|
// --- fail_bad_foo.impl.carbon
|
|
|
|
library "foo" impl;
|
|
|
|
// CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+5]]:13: ERROR: Redeclaration differs at parameter 1.
|
|
// CHECK:STDERR: class Class(U:! type) {
|
|
// CHECK:STDERR: ^
|
|
// CHECK:STDERR: fail_bad_foo.impl.carbon: Previous declaration's corresponding parameter here.
|
|
// CHECK:STDERR:
|
|
class Class(U:! type) {
|
|
// CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+3]]:10: ERROR: Name `T` not found.
|
|
// CHECK:STDERR: var x: T;
|
|
// CHECK:STDERR: ^
|
|
var x: T;
|
|
}
|
|
|
|
// CHECK:STDOUT: --- foo.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
|
|
// CHECK:STDOUT: %Class.1: type = generic_class_type @Class [template]
|
|
// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %struct: Class = struct_value () [template]
|
|
// CHECK:STDOUT: %Class.2: type = class_type @Class [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = %Core
|
|
// CHECK:STDOUT: .Class = %Class.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
|
// CHECK:STDOUT: %Class.decl: Class = class_decl @Class [template = constants.%struct] {
|
|
// CHECK:STDOUT: %T.loc4_13.1: type = param T
|
|
// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Class;
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- foo.impl.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %T: type = bind_symbolic_name T 0, <unexpected instref inst+11> [symbolic]
|
|
// CHECK:STDOUT: %Class: type = generic_class_type @Class [template]
|
|
// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %struct.1: Class = struct_value () [template]
|
|
// CHECK:STDOUT: %struct.2: type = struct_value () [template]
|
|
// CHECK:STDOUT: %.2: type = unbound_element_type <cannot stringify inst+9>, T [symbolic]
|
|
// CHECK:STDOUT: %.3: type = struct_type {.x: T} [symbolic]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = %Core
|
|
// CHECK:STDOUT: .Class = %Class.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %import_ref: Class = import_ref ir0, inst+5, loaded [template = constants.%struct.1]
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
|
// CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%struct.2] {
|
|
// CHECK:STDOUT: %T.loc4_13.1: type = param T
|
|
// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Class {
|
|
// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_13.2 [symbolic = constants.%T]
|
|
// CHECK:STDOUT: %.loc5: <unbound element of class <cannot stringify inst+9>> = field_decl x, element0 [template]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%struct.1
|
|
// CHECK:STDOUT: .x = %.loc5
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_bad_foo.impl.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %U: type = bind_symbolic_name U 0 [symbolic]
|
|
// CHECK:STDOUT: %Class: type = generic_class_type @Class [template]
|
|
// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %struct.1: Class = struct_value () [template]
|
|
// CHECK:STDOUT: %T: type = bind_symbolic_name T 0, <unexpected instref inst+12> [symbolic]
|
|
// CHECK:STDOUT: %.2: type = generic_class_type @.1 [template]
|
|
// CHECK:STDOUT: %struct.2: <invalid> = struct_value () [template]
|
|
// CHECK:STDOUT: %.3: type = class_type @.1 [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Class = %import_ref
|
|
// CHECK:STDOUT: .Core = %Core
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %import_ref: Class = import_ref ir0, inst+5, loaded [template = constants.%struct.1]
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
|
// CHECK:STDOUT: %.decl: <invalid> = class_decl @.1 [template = constants.%struct.2] {
|
|
// CHECK:STDOUT: %U.loc9_13.1: type = param U
|
|
// CHECK:STDOUT: %U.loc9_13.2: type = bind_symbolic_name U 0, %U.loc9_13.1 [symbolic = constants.%U]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Class;
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @.1 {
|
|
// CHECK:STDOUT: %T.ref: <error> = name_ref T, <error> [template = <error>]
|
|
// CHECK:STDOUT: %.loc13: <error> = field_decl x, element0 [template]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%.3
|
|
// CHECK:STDOUT: .x = %.loc13
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|