@@ -768,13 +768,6 @@ export class LuaTranspiler {
768768 if ( ts . isPropertyAccessExpression ( node . expression ) ) {
769769 const expType = this . checker . getTypeAtLocation ( node . expression . expression ) ;
770770
771- // Don't include instance if the type is a namespace
772- if ( expType . symbol && expType . symbol . flags & ts . SymbolFlags . Namespace ) {
773- const callPath = this . transpileExpression ( node . expression ) ;
774- const params = this . transpileArguments ( node . arguments ) ;
775- return `${ callPath } (${ params } )` ;
776- }
777-
778771 if ( expType . symbol && expType . symbol . escapedName == "Math" ) {
779772 const params = this . transpileArguments ( node . arguments ) ;
780773 return this . transpileMathExpression ( node . expression . name ) + `(${ params } )` ;
@@ -794,33 +787,15 @@ export class LuaTranspiler {
794787 return this . transpileArrayCallExpression ( node ) ;
795788 }
796789
797- // Include context parameter if present
798- if ( expType && expType . symbol ) {
799- const funcName = node . expression . name . escapedText ;
800- let funcHolder = tsEx . findMemberHolder ( expType , funcName , this . checker ) ;
801-
802- // ===== EXPERIMENTAL https://github.com/Perryvw/TypescriptToLua/issues/56
803- if ( ts . isParenthesizedExpression ( node . expression . expression )
804- && ( ts . isAsExpression ( node . expression . expression . expression )
805- || ts . isTypeAssertion ( node . expression . expression . expression ) )
806- && ts . isTypeReferenceNode ( node . expression . expression . expression . type ) ) {
807- const castTypeNode = node . expression . expression . expression . type ;
808- if ( this . checker . getTypeFromTypeNode ( castTypeNode ) . symbol . name == funcHolder ) {
809- funcHolder = castTypeNode . getText ( ) ;
810- }
811- }
812- // ===== END EXPERIMENTAL
813-
814- if ( funcHolder === undefined ) {
815- throw new TranspileError ( `Could not find func ${ funcName } on ${ expType . symbol . name } ` , node ) ;
816- }
817-
818- const callPath = `${ funcHolder } .${ funcName } ` ;
819- const params = this . transpileArguments ( node . arguments , node . expression . expression ) ;
790+ if ( expType . symbol && ( expType . symbol . flags & ts . SymbolFlags . Namespace ) ) {
791+ // Don't replace . with : for namespaces
792+ const callPath = this . transpileExpression ( node . expression ) ;
793+ const params = this . transpileArguments ( node . arguments ) ;
820794 return `${ callPath } (${ params } )` ;
821795 } else {
822- const callPath = this . transpileExpression ( node . expression ) ;
823- const params = this . transpileArguments ( node . arguments , node . expression . expression ) ;
796+ // Replace last . with : here
797+ const callPath = `${ this . transpileExpression ( node . expression . expression ) } :${ node . expression . name . escapedText } ` ;
798+ const params = this . transpileArguments ( node . arguments ) ;
824799 return `${ callPath } (${ params } )` ;
825800 }
826801 }
0 commit comments