Skip to content

Commit c488e01

Browse files
authored
Merge pull request #1636 from dotty-staging/topic/restructure-attempt2
Restructuring repo and issues
2 parents 34d64f3 + 9222af0 commit c488e01

File tree

1,158 files changed

+1261
-1159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,158 files changed

+1261
-1159
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.log
44
*.swp
55
*~
6+
tags
67

78
# sbt specific
89
dist/*
@@ -31,6 +32,7 @@ classes/
3132

3233
# Partest
3334
dotty.jar
35+
dotty-lib.jar
3436
tests/partest-generated/
3537
tests/locks/
3638
/test-classes/

bench/src/test/scala/Benchmarks.scala renamed to bench/test/dotty/tools/benchmarks/Benchmarks.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package dotty.tools.benchmarks
22

3-
43
import org.scalameter.Key.reports._
54
import org.scalameter.PerformanceTest.OnlineRegressionReport
65
import org.scalameter.api._
76
import org.scalameter.{Context, History, currentContext, persistence}
87
import org.scalameter.reporting.RegressionReporter.Tester
9-
import test.CompilerTest
8+
import dotty.tools.dotc.CompilerTest
109

1110
import scala.io.Source
1211

@@ -46,13 +45,14 @@ object BenchTests extends OnlineRegressionReport {
4645
implicit val defaultOptions = List("-d", outputDir)
4746
val scala2mode = List("-language:Scala2")
4847

49-
val dottyDir = "./src/dotty/"
48+
val dottyDir = "../compiler/src/dotty/"
5049

51-
val stdlibFiles = Source.fromFile("./test/dotc/scala-collections.whitelist", "UTF8").getLines()
50+
val stdlibFiles = Source.fromFile("../compiler/test/dotc/scala-collections.whitelist", "UTF8").getLines()
5251
.map(_.trim) // allow identation
5352
.filter(!_.startsWith("#")) // allow comment lines prefixed by #
5453
.map(_.takeWhile(_ != '#').trim) // allow comments in the end of line
5554
.filter(_.nonEmpty)
55+
.map("." + _)
5656
.toList
5757

5858
def stdLib = compiler.compileList("compileStdLib", stdlibFiles, "-migration" :: scala2mode)

bin/common

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function build_jar {
5858

5959
local sedjar="$3"
6060
if [ "$sedjar" == "" ]; then
61-
sedjar="/.*\.jar/p"
61+
sedjar="/tests/d; /javadoc/d; /.*\.jar/p"
6262
fi
6363

6464
if [ "$jar" == "" ]; then
@@ -74,6 +74,7 @@ function build_jar {
7474
function update_packages {
7575
echo "$INTERFACES_JAR" > $DOTTY_ROOT/.packages
7676
echo "$MAIN_JAR" >> $DOTTY_ROOT/.packages
77+
echo "$DOTTY_LIB_JAR" >> $DOTTY_ROOT/.packages
7778
echo "$TEST_JAR" >> $DOTTY_ROOT/.packages
7879
}
7980

@@ -84,12 +85,16 @@ function build_all {
8485
INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)
8586
printf "done\n"
8687

87-
printf "Building dotty..."
88-
MAIN_JAR=$(build_jar package "target/scala-$SCALA_BINARY_VERSION")
88+
printf "Building dotty-compiler..."
89+
MAIN_JAR=$(build_jar dotty-compiler/package "compiler/target/scala-$SCALA_BINARY_VERSION")
90+
printf "done\n"
91+
92+
printf "Building dotty library..."
93+
DOTTY_LIB_JAR=$(build_jar dotty-library/package "library/target/scala-$SCALA_BINARY_VERSION")
8994
printf "done\n"
9095

9196
printf "Building tests..."
92-
TEST_JAR=$(build_jar test:package "target/scala-$SCALA_BINARY_VERSION" '/dotty.*-tests\.jar/p')
97+
TEST_JAR=$(build_jar test:package "compiler/target/scala-$SCALA_BINARY_VERSION" '/dotty.*-tests\.jar/p')
9398
printf "done\n"
9499

95100
update_packages
@@ -101,10 +106,11 @@ if [ ! -f "$DOTTY_ROOT/.packages" ]; then
101106
else
102107
IFS=$'\r\n' GLOBIGNORE='*' command eval 'JARS=($(cat $DOTTY_ROOT/.packages))'
103108

104-
if [ "${#JARS[@]}" == "3" ]; then
109+
if [ "${#JARS[@]}" == "4" ]; then
105110
INTERFACES_JAR="${JARS[0]}"
106111
MAIN_JAR="${JARS[1]}"
107-
TEST_JAR="${JARS[2]}"
112+
DOTTY_LIB_JAR="${JARS[2]}"
113+
TEST_JAR="${JARS[3]}"
108114
else
109115
echo "Failed to parse .packages file"
110116
build_all
@@ -118,15 +124,17 @@ function check_jar {
118124
local new_files="$(find "$DOTTY_ROOT/$3" \( -iname "*.scala" -o -iname "*.java" \) -newer "$2")"
119125
if [ ! -z "$new_files" ]; then
120126
printf "New files detected in $1, rebuilding..."
127+
rm $2
121128
eval "$4"
122129
printf "done\n"
123130
update_packages
124131
fi
125132
}
126133

127-
check_jar "dotty-interfaces" $INTERFACES_JAR "interfaces" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)'
128-
check_jar "dotty" $MAIN_JAR "src" 'MAIN_JAR=$(build_jar package target/scala-$SCALA_BINARY_VERSION)'
129-
check_jar "dotty-tests" $TEST_JAR "test" 'TEST_JAR=$(build_jar test:package target/scala-$SCALA_BINARY_VERSION /dotty.*-tests\.jar/p)'
134+
check_jar "dotty-interfaces" $INTERFACES_JAR "interfaces/src" 'INTERFACES_JAR=$(build_jar dotty-interfaces/package interfaces/target)'
135+
check_jar "dotty-compiler" $MAIN_JAR "compiler/src" 'MAIN_JAR=$(build_jar dotty-compiler/package compiler/target/scala-$SCALA_BINARY_VERSION)'
136+
check_jar "dotty-library" $DOTTY_LIB_JAR "library/src" 'DOTTY_LIB_JAR=$(build_jar dotty-library/package library/target/scala-$SCALA_BINARY_VERSION)'
137+
check_jar "dotty-tests" $TEST_JAR "compiler/test" 'TEST_JAR=$(build_jar dotty-compiler/test:package compiler/target/scala-$SCALA_BINARY_VERSION /dotty.*-tests\.jar/p)'
130138

131139
# Autodetecting the scala-library location, in case it wasn't provided by an environment variable
132140
if [ "$SCALA_LIBRARY_JAR" == "" ]; then

bin/dotc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ trap onExit INT
115115
classpathArgs () {
116116
if [[ "true" == $bootstrapped ]]; then
117117
check_jar "dotty-bootstrapped" $DOTTY_JAR "target" 'build_jar "test:runMain dotc.build" target' &> /dev/null
118-
toolchain="$DOTTY_JAR:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR"
118+
toolchain="$DOTTY_JAR:$DOTTY_LIB_JAR:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR"
119119
else
120-
toolchain="$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR"
120+
toolchain="$SCALA_LIBRARY_JAR:$DOTTY_LIB_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR"
121121
fi
122-
bcpJars="$INTERFACES_JAR:$MAIN_JAR"
123-
cpJars="$INTERFACES_JAR:$MAIN_JAR:$TEST_JAR"
122+
bcpJars="$INTERFACES_JAR:$MAIN_JAR:$DOTTY_LIB_JAR"
123+
cpJars="$INTERFACES_JAR:$MAIN_JAR:$DOTTY_LIB_JAR:$TEST_JAR"
124124

125125
if [[ -n "$cygwin" ]]; then
126126
if [[ "$OS" = "Windows_NT" ]] && cygpath -m .>/dev/null 2>/dev/null ; then

bin/dotr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ DOTTY_ROOT="$( cd "$DOTTY_ROOT" >& /dev/null && pwd )/.." # absolute
1111
# Load common functions and variables
1212
source $DOTTY_ROOT/bin/common
1313

14-
# CLASS_PATH is derived from the DOTTY_ROOT and SCALA_LIBRARY_JAR
15-
CLASS_PATH="-Xbootclasspath/a:.:$DOTTY_ROOT/target/scala-$SCALA_BINARY_VERSION/classes/:.:$SCALA_LIBRARY_JAR"
14+
CLASS_PATH="-classpath .:$DOTTY_LIB_JAR:.:$SCALA_LIBRARY_JAR"
1615

1716
function runMain {
1817
local jbin=$(which "java")

test/scripts/TestDotc.scala renamed to bin/test/TestScripts.scala

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import scala.io.Source
77
import scala.sys.process.{Process, ProcessLogger}
88
import java.io.{File => JFile, FileNotFoundException}
99

10-
class TestDotc {
10+
class TestScripts {
1111
private val lineSep = util.Properties.lineSeparator
1212
private def doUnlessWindows(op: => Unit) =
1313
if (!System.getProperty("os.name").toLowerCase.contains("windows"))
@@ -28,11 +28,13 @@ class TestDotc {
2828
}
2929

3030
try {
31-
for (jar <- Source.fromFile(".packages").getLines())
31+
for (jar <- Source.fromFile("./.packages").getLines())
3232
delete(jar)
3333

34-
delete(".packages")
35-
delete("src/dotty/tools/dotc/Dummy.scala")
34+
delete("./.packages")
35+
delete("./compiler/src/dotty/tools/dotc/Dummy.scala")
36+
delete("./HelloWorld.class")
37+
delete("./HelloWorld$.class")
3638
} catch {
3739
case _: FileNotFoundException => ()
3840
}
@@ -45,15 +47,15 @@ class TestDotc {
4547
* execute it using dotr
4648
*/
4749
@Test def buildAndRunHelloWorld = doUnlessWindows {
48-
val (retDotc, dotcOutput) = executeScript("bin/dotc tests/pos/HelloWorld.scala")
50+
val (retDotc, dotcOutput) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
4951

5052
// Check correct output of building and running dotc
5153
assert(
5254
retDotc == 0,
5355
s"bin/dotc script did not run properly. Output:$lineSep$dotcOutput"
5456
)
5557

56-
val (retDotr, dotrOutput) = executeScript("bin/dotr HelloWorld")
58+
val (retDotr, dotrOutput) = executeScript("./bin/dotr HelloWorld")
5759
assert(
5860
retDotr == 0 && dotrOutput == "hello world",
5961
s"Running hello world exited with status: $retDotr and output: $dotrOutput"
@@ -64,24 +66,24 @@ class TestDotc {
6466
* rebuild dotty if needed
6567
*/
6668
@Test def rebuildIfNecessary = doUnlessWindows {
67-
val (retFirstBuild, _) = executeScript("bin/dotc tests/pos/HelloWorld.scala")
68-
assert(retFirstBuild == 0, "building dotc failed")
69+
val (retFirstBuild, out1) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
70+
assert(retFirstBuild == 0, s"building dotc failed: $out1")
6971

70-
// Create a new file
71-
new JFile("src/dotty/tools/dotc/Dummy.scala").createNewFile()
72+
// Create a new file to force rebuild
73+
new JFile("./compiler/src/dotty/tools/dotc/Dummy.scala").createNewFile()
7274

73-
val (retSecondBuild, output) = executeScript("bin/dotc tests/pos/HelloWorld.scala")
75+
val (retSecondBuild, output) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
7476
assert(
7577
retSecondBuild == 0 && output.contains("rebuilding"),
7678
s"Rebuilding the tool should result in jar files being rebuilt. Status: $retSecondBuild, output:$lineSep$output")
7779
}
7880

7981
/** if no changes to dotty, dotc script should be fast */
8082
@Test def beFastOnNoChanges = doUnlessWindows {
81-
val (retFirstBuild, _) = executeScript("bin/dotc tests/pos/HelloWorld.scala")
83+
val (retFirstBuild, _) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
8284
assert(retFirstBuild == 0, "building dotc failed")
8385

84-
val (ret, output) = executeScript("bin/dotc tests/pos/HelloWorld.scala")
86+
val (ret, output) = executeScript("./bin/dotc ./tests/pos/HelloWorld.scala")
8587
assert(
8688
ret == 0 && !output.contains("rebuilding"),
8789
s"Project recompiled when it didn't need to be. Status $ret, output:$lineSep$output")

src/dotty/tools/dotc/Compiler.scala renamed to compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import core.DenotTransformers.DenotTransformer
1717
import core.Denotations.SingleDenotation
1818

1919
import dotty.tools.backend.jvm.{LabelDefs, GenBCode, CollectSuperCalls}
20-
import dotty.tools.backend.sjs.GenSJSIR
2120

2221
/** The central class of the dotc compiler. The job of a compiler is to create
2322
* runs, which process given `phases` in a given `rootContext`.
@@ -98,7 +97,6 @@ class Compiler {
9897
new DropInlined, // Drop Inlined nodes, since backend has no use for them
9998
new MoveStatics, // Move static methods to companion classes
10099
new LabelDefs), // Converts calls to labels to jumps
101-
List(new GenSJSIR), // Generate .js code
102100
List(new GenBCode) // Generate JVM bytecode
103101
)
104102

@@ -117,20 +115,7 @@ class Compiler {
117115
*/
118116
def rootContext(implicit ctx: Context): Context = {
119117
ctx.initialize()(ctx)
120-
val actualPhases = if (ctx.settings.scalajs.value) {
121-
// Remove phases that Scala.js does not want
122-
phases.mapConserve(_.filter {
123-
case _: FunctionalInterfaces => false
124-
case _ => true
125-
}).filter(_.nonEmpty)
126-
} else {
127-
// Remove Scala.js-related phases
128-
phases.mapConserve(_.filter {
129-
case _: GenSJSIR => false
130-
case _ => true
131-
}).filter(_.nonEmpty)
132-
}
133-
ctx.setPhasePlan(actualPhases)
118+
ctx.setPhasePlan(phases)
134119
val rootScope = new MutableScope
135120
val bootstrap = ctx.fresh
136121
.setPeriod(Period(nextRunId, FirstPhaseId))

src/dotty/tools/dotc/ast/Desugar.scala renamed to compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ object desugar {
179179
DefDef(
180180
name = meth.name.defaultGetterName(n),
181181
tparams = meth.tparams.map(tparam => dropContextBound(toDefParam(tparam))),
182-
vparamss = takeUpTo(normalizedVparamss, n),
182+
vparamss = takeUpTo(normalizedVparamss.nestedMap(toDefParam), n),
183183
tpt = TypeTree(),
184184
rhs = vparam.rhs
185185
).withMods(Modifiers(mods.flags & AccessFlags, mods.privateWithin))

src/dotty/tools/dotc/ast/tpd.scala renamed to compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
464464
case tree: Select if qualifier.tpe eq tree.qualifier.tpe =>
465465
tree1.withTypeUnchecked(tree.tpe)
466466
case _ => tree.tpe match {
467-
case tpe: NamedType => tree1.withType(tpe.derivedSelect(qualifier.tpe))
467+
case tpe: NamedType => tree1.withType(tpe.derivedSelect(qualifier.tpe.widenIfUnstable))
468468
case _ => tree1.withTypeUnchecked(tree.tpe)
469469
}
470470
}

src/dotty/tools/dotc/config/JavaPlatform.scala renamed to compiler/src/dotty/tools/dotc/config/JavaPlatform.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ class JavaPlatform extends Platform {
1616
def classPath(implicit ctx: Context): ClassPath = {
1717
if (currentClassPath.isEmpty)
1818
currentClassPath = Some(new PathResolver().result)
19-
currentClassPath.get
19+
val cp = currentClassPath.get
20+
//println(cp)
21+
cp
2022
}
2123

2224
// The given symbol is a method with the right name and signature to be a runnable java program.

src/dotty/tools/dotc/config/PathResolver.scala renamed to compiler/src/dotty/tools/dotc/config/PathResolver.scala

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object PathResolver {
2020
// security exceptions.
2121
import AccessControl._
2222

23-
def firstNonEmpty(xs: String*) = xs find (_ != "") getOrElse ""
23+
def firstNonEmpty(xs: String*) = xs find (_ != "") getOrElse ""
2424

2525
/** Map all classpath elements to absolute paths and reconstruct the classpath.
2626
*/
@@ -47,6 +47,7 @@ object PathResolver {
4747
def sourcePathEnv = envOrElse("SOURCEPATH", "")
4848

4949
def javaBootClassPath = propOrElse("sun.boot.class.path", searchForBootClasspath)
50+
5051
def javaExtDirs = propOrEmpty("java.ext.dirs")
5152
def scalaHome = propOrEmpty("scala.home")
5253
def scalaExtDirs = propOrEmpty("scala.ext.dirs")
@@ -55,20 +56,14 @@ object PathResolver {
5556
def javaUserClassPath = propOrElse("java.class.path", "")
5657
def useJavaClassPath = propOrFalse("scala.usejavacp")
5758

58-
override def toString = """
59+
override def toString = s"""
5960
|object Environment {
60-
| scalaHome = %s (useJavaClassPath = %s)
61-
| javaBootClassPath = <%d chars>
62-
| javaExtDirs = %s
63-
| javaUserClassPath = %s
64-
| scalaExtDirs = %s
65-
|}""".trim.stripMargin.format(
66-
scalaHome, useJavaClassPath,
67-
javaBootClassPath.length,
68-
ppcp(javaExtDirs),
69-
ppcp(javaUserClassPath),
70-
ppcp(scalaExtDirs)
71-
)
61+
| scalaHome = $scalaHome (useJavaClassPath = $useJavaClassPath)
62+
| javaBootClassPath = <${javaBootClassPath.length} chars>
63+
| javaExtDirs = ${ppcp(javaExtDirs)}
64+
| javaUserClassPath = ${ppcp(javaUserClassPath)}
65+
| scalaExtDirs = ${ppcp(scalaExtDirs)}
66+
|}""".trim.stripMargin
7267
}
7368

7469
/** Default values based on those in Environment as interpreted according
@@ -194,7 +189,7 @@ class PathResolver(implicit ctx: Context) {
194189
def javaUserClassPath = if (useJavaClassPath) Defaults.javaUserClassPath else ""
195190
def scalaBootClassPath = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath)
196191
def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs)
197-
def priorityClassPath = cmdLineOrElse("prioritypath", "")
192+
def priorityClassPath = cmdLineOrElse("priorityclasspath", "")
198193
/** Scaladoc doesn't need any bootstrapping, otherwise will create errors such as:
199194
* [scaladoc] ../scala-trunk/src/reflect/scala/reflect/macros/Reifiers.scala:89: error: object api is not a member of package reflect
200195
* [scaladoc] case class ReificationException(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg)
@@ -213,11 +208,11 @@ class PathResolver(implicit ctx: Context) {
213208
* - Otherwise, if CLASSPATH is set, it is that
214209
* - If neither of those, then "." is used.
215210
*/
216-
def userClassPath = (
211+
def userClassPath = {
217212
if (!settings.classpath.isDefault)
218213
settings.classpath.value
219214
else sys.env.getOrElse("CLASSPATH", ".")
220-
)
215+
}
221216

222217
import context._
223218

@@ -243,7 +238,7 @@ class PathResolver(implicit ctx: Context) {
243238
| javaBootClassPath = %s
244239
| javaExtDirs = %s
245240
| javaUserClassPath = %s
246-
| useJavaClassPath = %s
241+
| useJavaClassPath = %s
247242
| scalaBootClassPath = %s
248243
| scalaExtDirs = %s
249244
| userClassPath = %s
@@ -260,7 +255,15 @@ class PathResolver(implicit ctx: Context) {
260255
def containers = Calculated.containers
261256

262257
lazy val result: JavaClassPath = {
263-
val cp = new JavaClassPath(containers.toIndexedSeq, context)
258+
// Prioritize `dotty.jar` and `dotty-lib.jar` to shadow others
259+
val (dottyJars, others) =
260+
containers.partition(x => x.name.contains("dotty-lib.jar") || x.name.contains("dotty.jar"))
261+
// Then any jars with `dotty` in the name - putting them before scala-library
262+
val (dottyCp, remaining) =
263+
others.partition(_.name.contains("dotty-"))
264+
265+
val cp = new JavaClassPath((dottyJars ++ dottyCp ++ remaining).toIndexedSeq, context)
266+
264267
if (settings.Ylogcp.value) {
265268
Console.println("Classpath built from " + settings.toConciseString(ctx.sstate))
266269
Console.println("Defaults: " + PathResolver.Defaults)

src/dotty/tools/dotc/config/ScalaSettings.scala renamed to compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ScalaSettings extends Settings.SettingGroup {
4242
val usejavacp = BooleanSetting("-usejavacp", "Utilize the java.class.path in classpath resolution.")
4343
val verbose = BooleanSetting("-verbose", "Output messages about what the compiler is doing.")
4444
val version = BooleanSetting("-version", "Print product version and exit.")
45-
val pageWidth = IntSetting("-pagewidth", "Set page width", 120)
45+
val pageWidth = IntSetting("-pagewidth", "Set page width", 80)
4646

4747
val jvmargs = PrefixSetting("-J<flag>", "-J", "Pass <flag> directly to the runtime system.")
4848
val defines = PrefixSetting("-Dproperty=value", "-D", "Pass -Dproperty=value directly to the runtime system.")

0 commit comments

Comments
 (0)