diff --git a/src/hex/log/LoggableBuilder.hx b/src/hex/log/LoggableBuilder.hx index 6ab8258..7ff3071 100644 --- a/src/hex/log/LoggableBuilder.hx +++ b/src/hex/log/LoggableBuilder.hx @@ -43,12 +43,12 @@ class LoggableBuilder var isLogger = function(t:ComplexType):Bool { - return switch(t) + return (t == null) ? false : switch(t) { case macro :ILogger: true; case macro :hex.log.ILogger: true; case _: false; - } + }; } var tryLoggerName = function(f:{name:String, pos:Position}) diff --git a/test/hex/log/ExtendedMockLoggableClass.hx b/test/hex/log/ExtendedMockLoggableClass.hx index 7821068..84f65f0 100644 --- a/test/hex/log/ExtendedMockLoggableClass.hx +++ b/test/hex/log/ExtendedMockLoggableClass.hx @@ -70,3 +70,17 @@ class ExtendsLoggableAndOverridesLogger extends MockLoggableClassWithCustomLogge } } + +class ClassWithVariableWithoutType implements IsLoggable +{ + var unknown = "unknown"; + + public function new() + { + } +} + +class ClassThatExtendsClassWithVariableWithoutType extends ClassWithVariableWithoutType implements IsLoggable +{ + +} \ No newline at end of file diff --git a/test/hex/log/IsLoggableExtendsAndCustomCasesTest.hx b/test/hex/log/IsLoggableExtendsAndCustomCasesTest.hx index 6b092ee..df081ed 100644 --- a/test/hex/log/IsLoggableExtendsAndCustomCasesTest.hx +++ b/test/hex/log/IsLoggableExtendsAndCustomCasesTest.hx @@ -1,6 +1,8 @@ package hex.log; import hex.log.ExtendedMockLoggableClass.AnotherExtendedMockLoggableClass; +import hex.log.ExtendedMockLoggableClass.ClassThatExtendsClassWithVariableWithoutType; +import hex.log.ExtendedMockLoggableClass.ClassWithVariableWithoutType; import hex.log.ExtendedMockLoggableClass.ExtendsLoggableAndOverridesLogger; import hex.log.ExtendedMockLoggableClass.ExtendsLoggableWithCustomLogger; import hex.log.ExtendedMockLoggableClass.MockLoggableClassWithCustomLogger; @@ -112,5 +114,22 @@ class IsLoggableExtendsAndCustomCasesTest Assert.equals(message, logger.debugMsg); } + @Test("Test class with variable without type") + public function testClassWithVariableWithoutType() + { + var type = new ClassWithVariableWithoutType(); + + // This only needs to compile, functionality is tested in other tests + Assert.isNull(type.logger); + } + + @Test("Test class that extends class with variable without type") + public function testClassThatExtendsClassWithVariableWithoutType() + { + var type = new ClassThatExtendsClassWithVariableWithoutType(); + + // This only needs to compile, functionality is tested in other tests + Assert.isNull(type.logger); + } } \ No newline at end of file