Unverified Commit c476138e authored by Ting Huang's avatar Ting Huang Committed by GitHub

fix: compile error w/ scala.function1 (#1389)

* fix: compile error w/ scala.function1 修复编译时报错: 不兼容的类型:scala.Function1不是函数接口 在接口scala.Function1中找到多个非覆盖抽象方法 * fix: unused imports
parent 09452e8d
...@@ -21,6 +21,9 @@ package com.dlink.function.compiler; ...@@ -21,6 +21,9 @@ package com.dlink.function.compiler;
import com.dlink.function.constant.PathConstant; import com.dlink.function.constant.PathConstant;
import lombok.extern.slf4j.Slf4j;
import scala.runtime.AbstractFunction1;
import scala.runtime.BoxedUnit;
import scala.tools.nsc.GenericRunnerSettings; import scala.tools.nsc.GenericRunnerSettings;
import scala.tools.nsc.interpreter.IMain; import scala.tools.nsc.interpreter.IMain;
...@@ -28,11 +31,21 @@ import scala.tools.nsc.interpreter.IMain; ...@@ -28,11 +31,21 @@ import scala.tools.nsc.interpreter.IMain;
* @author ZackYoung * @author ZackYoung
* @since 0.6.8 * @since 0.6.8
*/ */
@Slf4j
public class CustomStringScalaCompiler { public class CustomStringScalaCompiler {
private static class ErrorHandler extends AbstractFunction1<String, BoxedUnit> {
@Override
public BoxedUnit apply(String msg) {
log.error("Interpreter error: {}", msg);
return BoxedUnit.UNIT;
}
}
public static IMain getInterpreter(Integer missionId) { public static IMain getInterpreter(Integer missionId) {
GenericRunnerSettings settings = new GenericRunnerSettings((err) -> null); GenericRunnerSettings settings = new GenericRunnerSettings(new ErrorHandler());
settings.usejavacp().tryToSetFromPropertyValue("true"); settings.usejavacp().tryToSetFromPropertyValue("true");
settings.Yreploutdir().tryToSetFromPropertyValue(PathConstant.getUdfCompilerJavaPath(missionId)); settings.Yreploutdir().tryToSetFromPropertyValue(PathConstant.getUdfCompilerJavaPath(missionId));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment