[isabelle-dev] Moving towards Scala 3

Makarius makarius at sketis.net
Mon Apr 4 10:53:17 CEST 2022


Attentive readers of the history have already noticed that we are moving 
towareds Scala 3.

This is a non-trivial step forward on the Scala staircase, see also 
https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html

After the rather big change in Isabelle/87ebf5a50283, most syntax problems 
should be solved. I now continue to work on semantic questions, most notably 
run-time invocation of the Scala compiler.


There is already "isabelle build_scala" and "isabelle build_setup" to produce 
a suitable Isabelle component.
Attached is an adhoc changeset for the most basic setup for scala-3.0.2.


	Makarius
-------------- next part --------------
# HG changeset patch
# User wenzelm
# Date 1648804796 -7200
#      Fri Apr 01 11:19:56 2022 +0200
# Node ID c4cf1620e298848a13d22306877ea749013fc1a2
# Parent  20093a63d03b6f15be1998a9b8a5db4f28523ba8
test

diff -r 20093a63d03b -r c4cf1620e298 Admin/components/main
--- a/Admin/components/main	Fri Apr 01 11:18:03 2022 +0200
+++ b/Admin/components/main	Fri Apr 01 11:19:56 2022 +0200
@@ -9,7 +9,7 @@
 flatlaf-1.6.4
 idea-icons-20210508
 isabelle_fonts-20211004
-isabelle_setup-20220323
+#isabelle_setup-20220323
 jdk-17.0.2+8
 jedit-20211103
 jfreechart-1.5.3
@@ -21,7 +21,7 @@
 pdfjs-2.12.313
 polyml-test-15c840d48c9a
 postgresql-42.2.24
-scala-2.13.5-1
+#scala-2.13.5-1
 smbc-0.4.1
 spass-3.8ds-2
 sqlite-jdbc-3.36.0.3
diff -r 20093a63d03b -r c4cf1620e298 etc/settings
--- a/etc/settings	Fri Apr 01 11:18:03 2022 +0200
+++ b/etc/settings	Fri Apr 01 11:19:56 2022 +0200
@@ -17,7 +17,7 @@
 ISABELLE_TOOL_JAVA_OPTIONS="-Djava.awt.headless=true -Xms512m -Xmx4g -Xss16m"
 
 ISABELLE_JAVAC_OPTIONS="-encoding UTF-8 -Xlint:-options -deprecation -source 11 -target 11"
-ISABELLE_SCALAC_OPTIONS="-encoding UTF-8 -Wconf:cat=other-match-analysis:silent -feature -deprecation -target:11 -Xsource:3 -J-Xms512m -J-Xmx4g -J-Xss16m"
+ISABELLE_SCALAC_OPTIONS="-encoding UTF-8 -feature -deprecation -release 11 -source 3.0-migration -no-indent -color never -pagewidth 78 -explain"
 
 ISABELLE_SCALA_JAR="$ISABELLE_HOME/lib/classes/isabelle.jar"
 
diff -r 20093a63d03b -r c4cf1620e298 src/Pure/Tools/scala_project.scala
--- a/src/Pure/Tools/scala_project.scala	Fri Apr 01 11:18:03 2022 +0200
+++ b/src/Pure/Tools/scala_project.scala	Fri Apr 01 11:19:56 2022 +0200
@@ -72,7 +72,7 @@
 }
 
 dependencies {
-  implementation 'org.scala-lang:scala-library:""" + scala_version + """'
+  implementation 'org.scala-lang:scala3-library_3:scala-library:""" + scala_version + """'
   compileOnly files(
     """ + jars.map(jar => groovy_string(File.platform_path(jar))).mkString("", ",\n    ", ")") +
 """
diff -r 20093a63d03b -r c4cf1620e298 src/Tools/Setup/src/Build.java
--- a/src/Tools/Setup/src/Build.java	Fri Apr 01 11:18:03 2022 +0200
+++ b/src/Tools/Setup/src/Build.java	Fri Apr 01 11:19:56 2022 +0200
@@ -38,7 +38,8 @@
 import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
 
-import scala.tools.nsc.MainClass;
+import dotty.tools.dotc.Driver;
+import dotty.tools.dotc.interfaces.ReporterResult;
 
 
 public class Build
@@ -245,7 +246,7 @@
     }
 
     public static void compile_scala_sources(
-        PrintStream output,  // ignored, but see scala.Console.withOut/withErr
+        PrintStream output,  // ignored, but see scala.Console.withOut/withErr  // FIXME
         Path target_dir,
         String more_options,
         List<Path> deps,
@@ -266,8 +267,10 @@
             if (p.toString().endsWith(".scala")) { scala_sources = true; }
         }
         if (scala_sources) {
-            boolean ok = new MainClass().process(args.toArray(String[]::new));
-            if (!ok) { throw new RuntimeException("Failed to compile Scala sources"); }
+            String[] args_array = args.toArray(String[]::new);
+            new Driver().process(args_array);
+            ReporterResult result = new Driver().process(args_array);
+            if (result.hasErrors()) { throw new RuntimeException("Failed to compile Scala sources"); }
         }
     }
 


More information about the isabelle-dev mailing list