File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
godot-codegen/src/generator Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ pub fn make_virtual_methods_trait(
23
23
view : & ApiView ,
24
24
) -> TokenStream {
25
25
let trait_name = ident ( trait_name_str) ;
26
+ let class_name = & class. name ( ) . rust_ty ;
26
27
27
28
let virtual_method_fns = make_all_virtual_methods ( class, all_base_names, view) ;
28
29
let special_virtual_methods = make_special_virtual_methods ( notification_enum_name) ;
@@ -34,7 +35,7 @@ pub fn make_virtual_methods_trait(
34
35
#[ allow( unused_variables) ]
35
36
#[ allow( clippy:: unimplemented) ]
36
37
#cfg_attributes
37
- pub trait #trait_name: crate :: obj:: GodotClass + crate :: private:: You_forgot_the_attribute__godot_api {
38
+ pub trait #trait_name: crate :: obj:: GodotClass < Base = #class_name> + crate :: private:: You_forgot_the_attribute__godot_api {
38
39
#special_virtual_methods
39
40
#( #virtual_method_fns ) *
40
41
}
Original file line number Diff line number Diff line change @@ -547,6 +547,21 @@ pub fn derive_godot_class(input: TokenStream) -> TokenStream {
547
547
/// }
548
548
/// ```
549
549
///
550
+ /// Using _any_ trait other than the one corresponding with the base class will result in compilation failure.
551
+ ///
552
+ /// ```compile_fail
553
+ /// # use godot::prelude::*;
554
+ /// #[derive(GodotClass)]
555
+ /// #[class(init, base=Node3D)]
556
+ /// pub struct My3DNode;
557
+ ///
558
+ /// #[godot_api]
559
+ /// impl INode for My3DNode {
560
+ /// fn ready(&mut self) {
561
+ /// godot_print!("Hello World!");
562
+ /// }
563
+ /// }
564
+ /// ```
550
565
///
551
566
/// # User-defined functions
552
567
///
You can’t perform that action at this time.
0 commit comments