Skip to content

Commit

Permalink
More clear testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dwblaikie committed Jan 9, 2025
1 parent 4dce9bb commit b3f4d7e
Showing 1 changed file with 207 additions and 1 deletion.
208 changes: 207 additions & 1 deletion toolchain/check/testdata/class/virtual_modifiers.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,40 @@ class Derived {
impl fn F();
}

// --- abstract_impl.carbon

package AbstractImpl;

abstract class AbstractBase {
abstract fn F();
}

abstract class AbstractIntermediate {
extend base: AbstractBase;
}

class Derived {
extend base: AbstractIntermediate;
impl fn F();
}

// --- virtual_impl.carbon

package VirtualImpl;

base class VirtualBase {
virtual fn F();
}

base class VirtualIntermediate {
extend base: VirtualBase;
}

class Derived {
extend base: VirtualIntermediate;
impl fn F();
}

// CHECK:STDOUT: --- modifiers.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
Expand Down Expand Up @@ -583,7 +617,7 @@ class Derived {
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
// CHECK:STDOUT: %.loc9: <vtable> = vtable () [template = constants.%.f2b]
// CHECK:STDOUT: %.loc10: <vtable> = vtable () [template = constants.%.f2b]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
Expand Down Expand Up @@ -791,3 +825,175 @@ class Derived {
// CHECK:STDOUT:
// CHECK:STDOUT: impl fn @F();
// CHECK:STDOUT:
// CHECK:STDOUT: --- abstract_impl.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %AbstractBase: type = class_type @AbstractBase [template]
// CHECK:STDOUT: %F.type.abb: type = fn_type @F.1 [template]
// CHECK:STDOUT: %F.b77: %F.type.abb = struct_value () [template]
// CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
// CHECK:STDOUT: %.c77: <vtable> = vtable (%F.b77) [template]
// CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
// CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
// CHECK:STDOUT: %AbstractIntermediate: type = class_type @AbstractIntermediate [template]
// CHECK:STDOUT: %AbstractIntermediate.elem: type = unbound_element_type %AbstractIntermediate, %AbstractBase [template]
// CHECK:STDOUT: %struct_type.base.efd: type = struct_type {.base: %AbstractBase} [template]
// CHECK:STDOUT: %complete_type.2d3: <witness> = complete_type_witness %struct_type.base.efd [template]
// CHECK:STDOUT: %Derived: type = class_type @Derived [template]
// CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %AbstractIntermediate [template]
// CHECK:STDOUT: %F.type.55a: type = fn_type @F.2 [template]
// CHECK:STDOUT: %F.8d5: %F.type.55a = struct_value () [template]
// CHECK:STDOUT: %.8cc: <vtable> = vtable (%F.8d5) [template]
// CHECK:STDOUT: %struct_type.base.da5: type = struct_type {.base: %AbstractIntermediate} [template]
// CHECK:STDOUT: %complete_type.f8c: <witness> = complete_type_witness %struct_type.base.da5 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/...
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .AbstractBase = %AbstractBase.decl
// CHECK:STDOUT: .AbstractIntermediate = %AbstractIntermediate.decl
// CHECK:STDOUT: .Derived = %Derived.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %AbstractBase.decl: type = class_decl @AbstractBase [template = constants.%AbstractBase] {} {}
// CHECK:STDOUT: %AbstractIntermediate.decl: type = class_decl @AbstractIntermediate [template = constants.%AbstractIntermediate] {} {}
// CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @AbstractBase {
// CHECK:STDOUT: %F.decl: %F.type.abb = fn_decl @F.1 [template = constants.%F.b77] {} {}
// CHECK:STDOUT: %.loc13: <vtable> = vtable (%F.decl) [template = constants.%.c77]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%AbstractBase
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @AbstractIntermediate {
// CHECK:STDOUT: %AbstractBase.ref: type = name_ref AbstractBase, file.%AbstractBase.decl [template = constants.%AbstractBase]
// CHECK:STDOUT: %.loc16: %AbstractIntermediate.elem = base_decl %AbstractBase.ref, element0 [template]
// CHECK:STDOUT: %.loc17: <vtable> = vtable (constants.%F.b77) [template = constants.%.c77]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.efd [template = constants.%complete_type.2d3]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%AbstractIntermediate
// CHECK:STDOUT: .base = %.loc16
// CHECK:STDOUT: extend %AbstractBase.ref
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @Derived {
// CHECK:STDOUT: %AbstractIntermediate.ref: type = name_ref AbstractIntermediate, file.%AbstractIntermediate.decl [template = constants.%AbstractIntermediate]
// CHECK:STDOUT: %.loc20: %Derived.elem = base_decl %AbstractIntermediate.ref, element0 [template]
// CHECK:STDOUT: %F.decl: %F.type.55a = fn_decl @F.2 [template = constants.%F.8d5] {} {}
// CHECK:STDOUT: %.loc22: <vtable> = vtable (%F.decl) [template = constants.%.8cc]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.da5 [template = constants.%complete_type.f8c]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%Derived
// CHECK:STDOUT: .base = %.loc20
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: extend %AbstractIntermediate.ref
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: abstract fn @F.1();
// CHECK:STDOUT:
// CHECK:STDOUT: impl fn @F.2();
// CHECK:STDOUT:
// CHECK:STDOUT: --- virtual_impl.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %VirtualBase: type = class_type @VirtualBase [template]
// CHECK:STDOUT: %F.type.c71: type = fn_type @F.1 [template]
// CHECK:STDOUT: %F.9ce: %F.type.c71 = struct_value () [template]
// CHECK:STDOUT: %ptr.454: type = ptr_type <vtable> [template]
// CHECK:STDOUT: %.8db: <vtable> = vtable (%F.9ce) [template]
// CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.454} [template]
// CHECK:STDOUT: %complete_type.513: <witness> = complete_type_witness %struct_type.vptr [template]
// CHECK:STDOUT: %VirtualIntermediate: type = class_type @VirtualIntermediate [template]
// CHECK:STDOUT: %VirtualIntermediate.elem: type = unbound_element_type %VirtualIntermediate, %VirtualBase [template]
// CHECK:STDOUT: %struct_type.base.61e: type = struct_type {.base: %VirtualBase} [template]
// CHECK:STDOUT: %complete_type.f09: <witness> = complete_type_witness %struct_type.base.61e [template]
// CHECK:STDOUT: %Derived: type = class_type @Derived [template]
// CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %VirtualIntermediate [template]
// CHECK:STDOUT: %F.type.55a: type = fn_type @F.2 [template]
// CHECK:STDOUT: %F.8d5: %F.type.55a = struct_value () [template]
// CHECK:STDOUT: %.8cc: <vtable> = vtable (%F.8d5) [template]
// CHECK:STDOUT: %struct_type.base.43c: type = struct_type {.base: %VirtualIntermediate} [template]
// CHECK:STDOUT: %complete_type.fa6: <witness> = complete_type_witness %struct_type.base.43c [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/...
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .VirtualBase = %VirtualBase.decl
// CHECK:STDOUT: .VirtualIntermediate = %VirtualIntermediate.decl
// CHECK:STDOUT: .Derived = %Derived.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %VirtualBase.decl: type = class_decl @VirtualBase [template = constants.%VirtualBase] {} {}
// CHECK:STDOUT: %VirtualIntermediate.decl: type = class_decl @VirtualIntermediate [template = constants.%VirtualIntermediate] {} {}
// CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @VirtualBase {
// CHECK:STDOUT: %F.decl: %F.type.c71 = fn_decl @F.1 [template = constants.%F.9ce] {} {}
// CHECK:STDOUT: %.loc6: <vtable> = vtable (%F.decl) [template = constants.%.8db]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.513]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%VirtualBase
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @VirtualIntermediate {
// CHECK:STDOUT: %VirtualBase.ref: type = name_ref VirtualBase, file.%VirtualBase.decl [template = constants.%VirtualBase]
// CHECK:STDOUT: %.loc9: %VirtualIntermediate.elem = base_decl %VirtualBase.ref, element0 [template]
// CHECK:STDOUT: %.loc10: <vtable> = vtable (constants.%F.9ce) [template = constants.%.8db]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.61e [template = constants.%complete_type.f09]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%VirtualIntermediate
// CHECK:STDOUT: .base = %.loc9
// CHECK:STDOUT: extend %VirtualBase.ref
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @Derived {
// CHECK:STDOUT: %VirtualIntermediate.ref: type = name_ref VirtualIntermediate, file.%VirtualIntermediate.decl [template = constants.%VirtualIntermediate]
// CHECK:STDOUT: %.loc13: %Derived.elem = base_decl %VirtualIntermediate.ref, element0 [template]
// CHECK:STDOUT: %F.decl: %F.type.55a = fn_decl @F.2 [template = constants.%F.8d5] {} {}
// CHECK:STDOUT: %.loc15: <vtable> = vtable (%F.decl) [template = constants.%.8cc]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.43c [template = constants.%complete_type.fa6]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%Derived
// CHECK:STDOUT: .base = %.loc13
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: extend %VirtualIntermediate.ref
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: virtual fn @F.1();
// CHECK:STDOUT:
// CHECK:STDOUT: impl fn @F.2();
// CHECK:STDOUT:

0 comments on commit b3f4d7e

Please sign in to comment.