diff --git a/jakttest/run_one.py b/jakttest/run_one.py index 1296cd061..cd8a8cfc0 100644 --- a/jakttest/run_one.py +++ b/jakttest/run_one.py @@ -104,6 +104,8 @@ def run_regular_test(params: RegularTestParams): "-R", params.runtime_path_for_stdlib, params.cpp_export_gen, + "-I", + params.cpp_include ], check=True, stderr=stderr, @@ -127,7 +129,7 @@ def run_regular_test(params: RegularTestParams): "-Wno-user-defined-literals", "-Wno-deprecated-declarations", "-Iruntime", - params.cpp_include, + f"-I{params.cpp_include}", params.cpp_export_include, "-DJAKT_CONTINUE_ON_PANIC", "-o", @@ -246,7 +248,7 @@ def main(): relevant_cpp_files = [Path(test_file.parent, x).resolve() for x in args.cpp_link.split(":") if len(x) > 0] if args.cpp_include: - cpp_include = f"-I{Path(test_file.parent, args.cpp_include)}" + cpp_include = f"{Path(test_file.parent, args.cpp_include)}" if args.cpp_export_dir: path = temp_dir / args.cpp_export_dir diff --git a/selfhost/cpp_import/clang.jakt b/selfhost/cpp_import/clang.jakt index 9d5df7be2..ca117bc51 100644 --- a/selfhost/cpp_import/clang.jakt +++ b/selfhost/cpp_import/clang.jakt @@ -1741,6 +1741,8 @@ class CppImportProcessor { is_method and clang_CXXMethod_isStatic(cursor) ) or not is_method + let is_virtual = clang_CXXMethod_isVirtual(cursor) + if not this_type.has_value() and (kind is Constructor or kind is Destructor) { if .debug_print { eprintln("[ICE] Constructor or destructor ({}) without a this type", name_from(cursor)) } return @@ -1907,7 +1909,7 @@ class CppImportProcessor { is_instantiated: true parsed_function: None is_comptime: false - is_virtual: false + is_virtual: is_virtual is_override: false is_unsafe: false has_varargs diff --git a/tests/typechecker/polymorphism_override_cpp_method.h b/tests/typechecker/polymorphism_override_cpp_method.h new file mode 100644 index 000000000..f8745be3d --- /dev/null +++ b/tests/typechecker/polymorphism_override_cpp_method.h @@ -0,0 +1,4 @@ +class Parent { +protected: + virtual void f() { AK::outln("From the parent"); }; +}; diff --git a/tests/typechecker/polymorphism_override_cpp_method.jakt b/tests/typechecker/polymorphism_override_cpp_method.jakt new file mode 100644 index 000000000..60cad0be2 --- /dev/null +++ b/tests/typechecker/polymorphism_override_cpp_method.jakt @@ -0,0 +1,14 @@ +/// Expect: +/// - output: "From the child\n" +/// - cppincludes: "." + +import extern "polymorphism_override_cpp_method.h" + +class Child : Parent { + public override fn f(mut this) { print("From the child\n"); } +} + +fn main() { + mut c = Child() + c.f() +}