From 7e05c1cbdb27bc52d79b8f31738e801e99679cfd Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Mon, 7 Jun 2021 13:59:12 +0200 Subject: [PATCH] Prevent non-static classes from being used as a type in static initialization --- source/tlang/compiler/typecheck/dependancy.d | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/tlang/compiler/typecheck/dependancy.d b/source/tlang/compiler/typecheck/dependancy.d index dca22738..bea60be2 100644 --- a/source/tlang/compiler/typecheck/dependancy.d +++ b/source/tlang/compiler/typecheck/dependancy.d @@ -4,8 +4,8 @@ import gogga; import compiler.symbols.data; import compiler.symbols.typing.core; import compiler.typecheck.core; - import std.conv : to; +import compiler.parsing.core; public final class StructuralOrganizer { @@ -128,6 +128,15 @@ public final class StructuralOrganizer */ public TreeNode staticInitializeClass(Clazz clazz) { + /** + * This is a recursive static initiliazer, all classes + * must be static + */ + if(clazz.getModifierType() != InitScope.STATIC) + { + Parser.expect("Cannot use a class type that is of a class that is non-static"); + } + /** * This Class's TreeNode */