@@ -212,6 +212,14 @@ public static ImExpr translateIntern(ExprBinary e, ImTranslator t, ImFunction f)
212212 FuncLink overloadedOperator = e .attrFuncLink ();
213213 ImExpr left = translateConcatOperand (e , e .getLeft (), t , f , overloadedOperator );
214214 ImExpr right = translateConcatOperand (e , e .getRight (), t , f , overloadedOperator );
215+ if (overloadedOperator == null ) {
216+ // A built-in operator can leave both operands with the same erased
217+ // generic type. In that case there is no concrete expected type to
218+ // trigger wrapTranslation, but Lua still needs each operand's
219+ // primitive default restored before applying the operator.
220+ left = normalizeBuiltinOperand (e .getLeft (), left , t );
221+ right = normalizeBuiltinOperand (e .getRight (), right , t );
222+ }
215223 if (op == WurstOperator .PLUS && overloadedOperator == null ) {
216224 left = wrapImplicitToString (e , e .getLeft (), left , t );
217225 right = wrapImplicitToString (e , e .getRight (), right , t );
@@ -243,6 +251,14 @@ public static ImExpr translateIntern(ExprBinary e, ImTranslator t, ImFunction f)
243251 return ImOperatorCall (op , ImExprs (left , right ));
244252 }
245253
254+ private static ImExpr normalizeBuiltinOperand (Expr operand , ImExpr translated , ImTranslator t ) {
255+ if (!t .isLuaTarget () || !(operand .attrTypRaw () instanceof WurstTypeBoundTypeParam )
256+ || isAlreadyTypeAssured (translated , t )) {
257+ return translated ;
258+ }
259+ return wrapLua (operand , t , translated , operand .attrTypRaw ());
260+ }
261+
246262 private static ImExpr translateConcatOperand (ExprBinary concat , Expr operand , ImTranslator t , ImFunction f ,
247263 @ Nullable FuncLink overloadedOperator ) {
248264 if (concat .getOp () == WurstOperator .PLUS && overloadedOperator == null
@@ -926,7 +942,9 @@ public static ImExpr translateIntern(ExprNewObject e, ImTranslator t, ImFunction
926942 WurstTypeClass wurstType = (WurstTypeClass ) e .attrTyp ();
927943 ImClass imClass = t .getClassFor (wurstType .getClassDef ());
928944 ImTypeArguments typeArgs = getFunctionCallTypeArguments (t , sig , e , imClass .getTypeVariables ());
929- return ImFunctionCall (e , constructorImFunc , typeArgs , translateExprs (e .getArgs (), t , f ), false , CallType .NORMAL );
945+ FunctionSignature selectedSignature = t .isLuaTarget () ? sig : null ;
946+ return ImFunctionCall (e , constructorImFunc , typeArgs ,
947+ translateExprs (e .getArgs (), t , f , false , selectedSignature ), false , CallType .NORMAL );
930948 }
931949
932950 public static ImExprOpt translate (NoExpr e , ImTranslator translator , ImFunction f ) {
0 commit comments