Skip to content

Commit

Permalink
fix macro fail when type is null
Browse files Browse the repository at this point in the history
  • Loading branch information
st3veV committed Apr 25, 2017
1 parent 733b956 commit d39f5df
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hex/log/LoggableBuilder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
14 changes: 14 additions & 0 deletions test/hex/log/ExtendedMockLoggableClass.hx
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,17 @@ class ExtendsLoggableAndOverridesLogger extends MockLoggableClassWithCustomLogge

}
}

class ClassWithVariableWithoutType implements IsLoggable
{
var unknown = "unknown";

public function new()
{
}
}

class ClassThatExtendsClassWithVariableWithoutType extends ClassWithVariableWithoutType implements IsLoggable
{

}
19 changes: 19 additions & 0 deletions test/hex/log/IsLoggableExtendsAndCustomCasesTest.hx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}

}

0 comments on commit d39f5df

Please sign in to comment.