Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to sbt 1 #3872

Merged
merged 107 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
6aafb69
sbt 1.0.0-M6
smarter Jun 6, 2017
4ce83b8
Upgrade to sbt 1.0.0-M6
smarter Jun 6, 2017
c91171d
Fix sbt bridge
ttreyer May 10, 2017
024f5fb
Add method SymDenotation.isTopLevelClass
ttreyer May 10, 2017
e1018d1
Remove SimpleType
ttreyer May 15, 2017
7865186
Update bridge for compatibility with Zinc 1.0.0-X15
ttreyer May 21, 2017
3f8a49c
Fix for zinc 1.0.0-X16
smarter Jun 6, 2017
848e41b
ExtractAPI: fix children of sealed classes
smarter Jun 6, 2017
bfd2b0f
ExtractAPI: add missing startSource callback
smarter Jun 6, 2017
d3f50a4
Fix various issues
smarter Jun 6, 2017
f02dacb
Propagate class files through GenBCode pipeline
ttreyer Jun 7, 2017
d7dba97
Catch FileConflictException creating class files
ttreyer Jun 7, 2017
fb9c611
Adapt to latest Zinc
Duhemm Oct 12, 2017
aef68c2
Compile only the bridge, not the whole compiler
Duhemm Oct 28, 2017
0f13174
Adapt to new main class detection in Zinc 1
Duhemm Oct 20, 2017
323b451
Re-enable `dist-*` projects
Duhemm Oct 23, 2017
c05353a
Fix `bin/dot*` scripts
Duhemm Oct 23, 2017
4c91ed2
Fix `source-dependencies/abstract-type-override`
Duhemm Oct 20, 2017
2cf0abe
Fix `source-dependencies/transitive-memberRef`
Duhemm Oct 20, 2017
f232fbe
Disable `source-dependencies/inherited-deps-java`
Duhemm Oct 20, 2017
494beb9
Fix test `source-dependencies/compactify`
Duhemm Oct 20, 2017
b749648
Mark test `source-dependencies/binary` pending
Duhemm Oct 20, 2017
dd7841d
Fix test source-dependencies/export-jars
Duhemm Oct 20, 2017
98c9e8d
Update test `source-dependencies/import-class`
Duhemm Nov 7, 2017
479c6c2
Fix test source-dependencies/trait-member-modified
Duhemm Oct 20, 2017
240e133
Fix test source-dependencies/java-analyis-serialization-error
Duhemm Oct 20, 2017
08e09b8
Fix test source-dependencies/canon
Duhemm Oct 20, 2017
939dd31
Fix test source-dependencies/restore-classes
Duhemm Oct 20, 2017
4ee6fd5
Fix test source-dependencies/type-alias
Duhemm Oct 20, 2017
159a19e
Fix test source-dependencies/typeref-only
Duhemm Oct 20, 2017
149c8b1
Fix test source-dependencies/less-inter-inv-java
Duhemm Oct 20, 2017
389cdcc
Fix test source-dependencies/backtick-qupted-names
Duhemm Oct 20, 2017
ca77743
Fix test source-dependencies/replace-test-a
Duhemm Oct 20, 2017
e4f092d
Fix test source-dependencies/inherited_type_params
Duhemm Oct 20, 2017
ce237c7
Fix test source-dependencies/same-file-used-names
Duhemm Oct 20, 2017
b46a4b3
Fix test source-dependencies/ext
Duhemm Oct 20, 2017
9281d1c
Fix test source-dependencies/less-inter-inv
Duhemm Oct 20, 2017
ff34abb
Fix test sbt-dotty/example-project
Duhemm Oct 20, 2017
805eceb
Fix test compilerReporter/simple
Duhemm Oct 20, 2017
4475e9e
Fix test source-dependencies/value-class-underlying
Duhemm Oct 23, 2017
5b5b260
Disable test source-dependencies/trait-private-var
Duhemm Oct 20, 2017
df2ac08
Always run scripted tests
Duhemm Nov 6, 2017
d818a2c
Split scripted tests in two groups
Duhemm Nov 7, 2017
2075f13
Remove `Message` and `Log`
Duhemm Nov 7, 2017
39ac06b
Upgrade to sbt 1.0.3
Duhemm Nov 7, 2017
f35894c
Change name of scala-library jar in tests
Duhemm Nov 7, 2017
ef10d7c
Address review comments
Duhemm Nov 8, 2017
80d36d5
Port sbt/zinc#444
Duhemm Nov 8, 2017
7705124
Address review comments
Duhemm Nov 9, 2017
440f1ea
Merge branch 'master' into 'topic/sbt1'
allanrenucci Jan 19, 2018
a438ed6
Update dependencies and plugins version
allanrenucci Jan 19, 2018
6278264
Workaround sbt/sbt#3469
allanrenucci Jan 19, 2018
59a0e55
Fix merge breakages + Cleanup
allanrenucci Jan 19, 2018
a13bc6b
wip
allanrenucci Jan 23, 2018
3a60f32
Use mangledString instead of toString
allanrenucci Feb 19, 2018
cfded3e
Merge branch 'master' into topic/sbt1
allanrenucci Feb 19, 2018
a2d86e8
Use Dotty naming scheme and toString
allanrenucci Mar 1, 2018
4a74fb7
Strip module suffix for module class
allanrenucci Mar 1, 2018
88fb4ea
Fix separate compilation
allanrenucci Mar 5, 2018
fd5aa53
Fix binary class name for Java Symbol
allanrenucci Mar 5, 2018
9994ebf
Revert to old scheme for binary class name
allanrenucci Mar 5, 2018
cf20829
Small build cleanup
allanrenucci Mar 5, 2018
31a93a1
Merge two caches
allanrenucci Mar 6, 2018
96aa562
Simplify UsedName
allanrenucci Mar 6, 2018
bd2a665
Resolve dependency source
allanrenucci Mar 6, 2018
6b9aa1f
Rework type traverser
allanrenucci Mar 7, 2018
01d35ff
Rework inheritance dependencies
allanrenucci Mar 7, 2018
2db0047
Use Symbol instead of String for usedNames cache's key
allanrenucci Mar 7, 2018
26241d0
Cleanup
allanrenucci Mar 7, 2018
d56e34f
Record finer grained dependencies
allanrenucci Mar 7, 2018
5193632
Don't record dependency on package
allanrenucci Mar 7, 2018
452356b
Use non local enclosing class as dependency source
allanrenucci Mar 7, 2018
cdfa433
Optimise resolveDependencySource
allanrenucci Mar 7, 2018
8e3bad9
Address review comments
allanrenucci Mar 7, 2018
0c471e5
Fix resolveDependencySource
allanrenucci Mar 8, 2018
ac88395
Build cleanup
allanrenucci Mar 8, 2018
4b862f8
Add new tests from Zinc
allanrenucci Mar 8, 2018
97c5d92
Workaround the broken hashCode of api.* classes
smarter Mar 9, 2018
950735d
Fix/Disable newly added tests
allanrenucci Mar 9, 2018
6d339d0
Port Unit test from latest Zinc
allanrenucci Mar 9, 2018
b769005
Remove dependency on specs2
allanrenucci Mar 9, 2018
e4eed7b
Remove duplicate implementation of isLocal
allanrenucci Mar 13, 2018
ca2b2d5
Port sbt/zinc#288
allanrenucci Mar 13, 2018
5247afa
Remove useless test
allanrenucci Mar 13, 2018
881f1a8
Fix latest unit tests from Zinc
allanrenucci Mar 20, 2018
8c8a950
Small Cleanup
allanrenucci Mar 20, 2018
e2e6f7a
Merge branch 'master' into 'topic/sbt1'
allanrenucci Mar 20, 2018
e9223c1
Enable all tests
allanrenucci Mar 20, 2018
066a01c
Fix vulpix meta test
allanrenucci Mar 21, 2018
036a633
Remove dead code
allanrenucci Mar 21, 2018
0495c85
Only run sbt scripted tests on nightly or deployment
allanrenucci Mar 21, 2018
1776242
Update CI Docker Image
allanrenucci Mar 21, 2018
b088b84
Upgrade sbt to 1.1.2
smarter Mar 27, 2018
7020f13
Merge branch 'master' into 'topic/sbt1'
allanrenucci Mar 27, 2018
25e8c75
Don't use deprecated ScalaInstance constructor
allanrenucci Mar 27, 2018
482c65b
Improve name conflict warning for case-insensitive filesystems
allanrenucci Mar 28, 2018
67ff1f2
Use SAM type whenever possible
allanrenucci Mar 28, 2018
e78a3fb
Update docker image for sbt 1.1.2
allanrenucci Mar 29, 2018
7a99074
Reorder arguments in assertEquals according to the spec:
allanrenucci Mar 29, 2018
2d4c129
Merge branch 'master' into 'topic/sbt1'
allanrenucci Apr 3, 2018
f107d74
Enable sbt scripted tests
allanrenucci Apr 3, 2018
9e73aca
Upgrade to sbt 1.1.4
smarter Apr 9, 2018
3f3ab9a
Update docker image
allanrenucci Apr 10, 2018
08d8336
Fix publishing
allanrenucci Apr 12, 2018
a15d0cd
Cleanup build imports
allanrenucci Apr 12, 2018
096d0d3
Merge branch 'master' into 'topic/sbt1'
allanrenucci Apr 12, 2018
fed5232
Only run scripted tests on nightly
allanrenucci Apr 12, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 9 additions & 9 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,39 @@ pipeline:
# We run tests in parallel. Tests run in a copy of the working directory to avoid conflict
test:
group: test
image: lampepfl/dotty:2018-01-17
image: lampepfl/dotty:2018-04-10
commands:
- cp -R . /tmp/1/ && cd /tmp/1/
- ./project/scripts/sbt ";compile ;test"
- ./project/scripts/cmdTests

test_bootstrapped:
group: test
image: lampepfl/dotty:2018-01-17
image: lampepfl/dotty:2018-04-10
commands:
- cp -R . /tmp/2/ && cd /tmp/2/
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test"

test_optimised:
group: test
image: lampepfl/dotty:2018-01-17
image: lampepfl/dotty:2018-04-10
commands:
- cp -R . /tmp/3/ && cd /tmp/3/
- ./project/scripts/sbt dotty-optimised/test

test_sbt:
group: test
image: lampepfl/dotty:2018-01-17
image: lampepfl/dotty:2018-04-10
commands:
- cp -R . /tmp/4/ && cd /tmp/4/
- ./project/scripts/sbt sbt-dotty/scripted
when:
# sbt scripted tests are slow and don't run on PRs
# sbt scripted tests are slow and only run on nightly or deployment
event: [ tag, deployment ]

# DOCUMENTATION:
documentation:
image: lampepfl/dotty:2018-01-17
image: lampepfl/dotty:2018-04-10
commands:
- ./project/scripts/genDocs
secrets: [ bot_pass ]
Expand All @@ -67,7 +67,7 @@ pipeline:
# PUBLISHING:
# Publishing expect NIGHTLYBUILD or RELEASEBUILD to be set. See dottyVersion in Build.scala
publish_nightly:
image: lampepfl/dotty:2018-01-17
image: lampepfl/dotty:2018-04-10
environment:
- NIGHTLYBUILD=yes
commands:
Expand All @@ -78,7 +78,7 @@ pipeline:
environment: nightly

publish_release:
image: lampepfl/dotty:2018-01-17
image: lampepfl/dotty:2018-04-10
environment:
- RELEASEBUILD=yes
commands:
Expand All @@ -102,7 +102,7 @@ pipeline:
event: tag

publish_sbt_release:
image: lampepfl/dotty:2018-01-17
image: lampepfl/dotty:2018-04-10
environment:
- RELEASEBUILD=yes
commands:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ project/local-plugins.sbt
.history
.ensime
.ensime_cache/
.sbt-scripted/

# npm
node_modules
Expand Down
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ val `dotty-library-optimised` = Build.`dotty-library-optimised`
val `dotty-sbt-bridge` = Build.`dotty-sbt-bridge`
val `dotty-sbt-bridge-bootstrapped` = Build.`dotty-sbt-bridge-bootstrapped`
val `dotty-language-server` = Build.`dotty-language-server`
val sjsSandbox = Build.sjsSandbox
val `dotty-bench` = Build.`dotty-bench`
val `dotty-bench-bootstrapped` = Build.`dotty-bench-bootstrapped`
val `dotty-bench-optimised` = Build.`dotty-bench-optimised`
Expand Down
145 changes: 81 additions & 64 deletions compiler/src/dotty/tools/backend/jvm/GenBCode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import scala.tools.nsc.backend.jvm._
import dotty.tools.dotc
import dotty.tools.dotc.backend.jvm.DottyPrimitives
import dotty.tools.dotc.transform.Erasure
import dotty.tools.dotc.transform.SymUtils._
import dotty.tools.dotc.interfaces
import java.util.Optional

import scala.reflect.ClassTag
import dotty.tools.dotc.core._
import dotty.tools.dotc.sbt.ExtractDependencies
import Periods._
import SymDenotations._
import Contexts._
Expand Down Expand Up @@ -113,14 +115,16 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter

/* ---------------- q2 ---------------- */

case class Item2(arrivalPos: Int,
mirror: asm.tree.ClassNode,
plain: asm.tree.ClassNode,
outFolder: scala.tools.nsc.io.AbstractFile) {
case class SubItem2(classNode: asm.tree.ClassNode,
file: scala.tools.nsc.io.AbstractFile)

case class Item2(arrivalPos: Int,
mirror: SubItem2,
plain: SubItem2) {
def isPoison = { arrivalPos == Int.MaxValue }
}

private val poison2 = Item2(Int.MaxValue, null, null, null)
private val poison2 = Item2(Int.MaxValue, null, null)
private val q2 = new _root_.java.util.LinkedList[Item2]

/* ---------------- q3 ---------------- */
Expand All @@ -134,13 +138,13 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
*/
case class SubItem3(
jclassName: String,
jclassBytes: Array[Byte]
jclassBytes: Array[Byte],
jclassFile: scala.tools.nsc.io.AbstractFile
)

case class Item3(arrivalPos: Int,
mirror: SubItem3,
plain: SubItem3,
outFolder: scala.tools.nsc.io.AbstractFile) {
plain: SubItem3) {

def isPoison = { arrivalPos == Int.MaxValue }
}
Expand All @@ -151,15 +155,31 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
else 1
}
}
private val poison3 = Item3(Int.MaxValue, null, null, null)
private val poison3 = Item3(Int.MaxValue, null, null)
private val q3 = new java.util.PriorityQueue[Item3](1000, i3comparator)

/*
* Pipeline that takes ClassDefs from queue-1, lowers them into an intermediate form, placing them on queue-2
*/
class Worker1(needsOutFolder: Boolean) {

val caseInsensitively = scala.collection.mutable.HashMap.empty[String, Symbol]
private val lowerCaseNames = mutable.HashMap.empty[String, Symbol]
private def checkForCaseConflict(javaClassName: String, classSymbol: Symbol) = {
val lowerCaseName = javaClassName.toLowerCase
lowerCaseNames.get(lowerCaseName) match {
case None =>
lowerCaseNames.put(lowerCaseName, classSymbol)
case Some(dupClassSym) =>
// Order is not deterministic so we enforce lexicographic order between the duplicates for error-reporting
val (cl1, cl2) =
if (classSymbol.effectiveName.toString < dupClassSym.effectiveName.toString) (classSymbol, dupClassSym)
else (dupClassSym, classSymbol)
ctx.atPhase(ctx.typerPhase) { implicit ctx =>
ctx.warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " +
"Such classes will overwrite one another on case-insensitive filesystems.", cl1.pos)
}
}
}

def run(): Unit = {
while (true) {
Expand Down Expand Up @@ -189,30 +209,6 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
val Item1(arrivalPos, cd, cunit) = item
val claszSymbol = cd.symbol

// GenASM checks this before classfiles are emitted, https://github.com/scala/scala/commit/e4d1d930693ac75d8eb64c2c3c69f2fc22bec739
def checkName(claszSymbol: Symbol): Unit = {
val lowercaseJavaClassName = claszSymbol.effectiveName.toString.toLowerCase
caseInsensitively.get(lowercaseJavaClassName) match {
case None =>
caseInsensitively.put(lowercaseJavaClassName, claszSymbol)
case Some(dupClassSym) =>
if (claszSymbol.effectiveName.toString != dupClassSym.effectiveName.toString) {
// Order is not deterministic so we enforce lexicographic order between the duplicates for error-reporting
val (cl1, cl2) =
if (claszSymbol.effectiveName.toString < dupClassSym.effectiveName.toString) (claszSymbol, dupClassSym)
else (dupClassSym, claszSymbol)
ctx.warning(s"Class ${cl1.effectiveName} differs only in case from ${cl2.effectiveName}. " +
"Such classes will overwrite one another on case-insensitive filesystems.", cl1.pos)
}
}
}
checkName(claszSymbol)
if (int.symHelper(claszSymbol).isModuleClass) {
val companionModule = claszSymbol.companionModule
if (int.symHelper(companionModule.owner).isPackageClass)
checkName(companionModule)
}

// -------------- mirror class, if needed --------------
val mirrorC =
if (int.symHelper(claszSymbol).isTopLevelModuleClass) {
Expand Down Expand Up @@ -253,12 +249,50 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
}


// ----------- create files

val classNodes = List(mirrorC, plainC)
val classFiles = classNodes.map(cls =>
if (outF != null && cls != null) {
try {
checkForCaseConflict(cls.name, claszSymbol)
getFileForClassfile(outF, cls.name, ".class")
} catch {
case e: FileConflictException =>
ctx.error(s"error writing ${cls.name}: ${e.getMessage}")
null
}
} else null
)

// ----------- compiler and sbt's callbacks

val (fullClassName, isLocal) = ctx.atPhase(ctx.sbtExtractDependenciesPhase) { implicit ctx =>
(ExtractDependencies.classNameAsString(claszSymbol), claszSymbol.isLocal)
}

for ((cls, clsFile) <- classNodes.zip(classFiles)) {
if (cls != null) {
val className = cls.name.replace('/', '.')
if (ctx.compilerCallback != null)
ctx.compilerCallback.onClassGenerated(sourceFile, convertAbstractFile(clsFile), className)
if (ctx.sbtCallback != null) {
if (isLocal)
ctx.sbtCallback.generatedLocalClass(sourceFile.jfile.orElse(null), clsFile.file)
else {
ctx.sbtCallback.generatedNonLocalClass(sourceFile.jfile.orElse(null), clsFile.file,
className, fullClassName)
}
}
}
}

// ----------- hand over to pipeline-2

val item2 =
Item2(arrivalPos,
mirrorC, plainC,
outF)
SubItem2(mirrorC, classFiles(0)),
SubItem2(plainC, classFiles(1)))

q2 add item2 // at the very end of this method so that no Worker2 thread starts mutating before we're done.

Expand Down Expand Up @@ -288,12 +322,12 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
}
else {
try {
localOptimizations(item.plain)
localOptimizations(item.plain.classNode)
addToQ3(item)
} catch {
case ex: Throwable =>
ex.printStackTrace()
ctx.error(s"Error while emitting ${item.plain.name}\n${ex.getMessage}")
ctx.error(s"Error while emitting ${item.plain.classNode.name}\n${ex.getMessage}")
}
}
}
Expand All @@ -307,18 +341,17 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
cw.toByteArray
}

val Item2(arrivalPos, mirror, plain, outFolder) = item
val Item2(arrivalPos, SubItem2(mirror, mirrorFile), SubItem2(plain, plainFile)) = item

val mirrorC = if (mirror == null) null else SubItem3(mirror.name, getByteArray(mirror))
val plainC = SubItem3(plain.name, getByteArray(plain))
val mirrorC = if (mirror == null) null else SubItem3(mirror.name, getByteArray(mirror), mirrorFile)
val plainC = SubItem3(plain.name, getByteArray(plain), plainFile)

if (AsmUtils.traceSerializedClassEnabled && plain.name.contains(AsmUtils.traceSerializedClassPattern)) {
if (mirrorC != null) AsmUtils.traceClass(mirrorC.jclassBytes)
AsmUtils.traceClass(plainC.jclassBytes)
}

q3 add Item3(arrivalPos, mirrorC, plainC, outFolder)

q3 add Item3(arrivalPos, mirrorC, plainC)
}

} // end of class BCodePhase.Worker2
Expand Down Expand Up @@ -416,25 +449,10 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
/* Pipeline that writes classfile representations to disk. */
private def drainQ3() = {

def sendToDisk(cfr: SubItem3, outFolder: scala.tools.nsc.io.AbstractFile): Unit = {
def sendToDisk(cfr: SubItem3): Unit = {
if (cfr != null){
val SubItem3(jclassName, jclassBytes) = cfr
try {
val outFile =
if (outFolder == null) null
else getFileForClassfile(outFolder, jclassName, ".class")
bytecodeWriter.writeClass(jclassName, jclassName, jclassBytes, outFile)

val className = jclassName.replace('/', '.')
if (ctx.compilerCallback != null)
ctx.compilerCallback.onClassGenerated(sourceFile, convertAbstractFile(outFile), className)
if (ctx.sbtCallback != null)
ctx.sbtCallback.generatedClass(sourceFile.jfile.orElse(null), outFile.file, className)
}
catch {
case e: FileConflictException =>
ctx.error(s"error writing $jclassName: ${e.getMessage}")
}
val SubItem3(jclassName, jclassBytes, jclassFile) = cfr
bytecodeWriter.writeClass(jclassName, jclassName, jclassBytes, jclassFile)
}
}

Expand All @@ -447,9 +465,8 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
moreComing = !incoming.isPoison
if (moreComing) {
val item = incoming
val outFolder = item.outFolder
sendToDisk(item.mirror, outFolder)
sendToDisk(item.plain, outFolder)
sendToDisk(item.mirror)
sendToDisk(item.plain)
expected += 1
}
}
Expand Down
9 changes: 1 addition & 8 deletions compiler/src/dotty/tools/dotc/config/JavaPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,12 @@ class JavaPlatform extends Platform {
}

// The given symbol is a method with the right name and signature to be a runnable java program.
def isJavaMainMethod(sym: SymDenotation)(implicit ctx: Context) =
def isMainMethod(sym: SymDenotation)(implicit ctx: Context) =
(sym.name == nme.main) && (sym.info match {
case MethodTpe(_, defn.ArrayOf(el) :: Nil, restpe) => el =:= defn.StringType && (restpe isRef defn.UnitClass)
case _ => false
})

// The given class has a main method.
def hasJavaMainMethod(sym: Symbol)(implicit ctx: Context): Boolean =
(sym.info member nme.main).hasAltWith {
case x: SymDenotation => isJavaMainMethod(x)
case _ => false
}

/** Update classpath with a substituted subentry */
def updateClassPath(subst: Map[ClassPath, ClassPath]): Unit = currentClassPath.get match {
case AggregateClassPath(entries) =>
Expand Down
12 changes: 12 additions & 0 deletions compiler/src/dotty/tools/dotc/config/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ package config
import io.{ClassPath, AbstractFile}
import core.Contexts._, core.Symbols._
import core.SymbolLoader
import core.SymDenotations.SymDenotation
import core.StdNames.nme

/** The platform dependent pieces of Global.
*/
Expand All @@ -35,5 +37,15 @@ abstract class Platform {

/** Create a new class loader to load class file `bin` */
def newClassLoader(bin: AbstractFile)(implicit ctx: Context): SymbolLoader

/** The given symbol is a method with the right name and signature to be a runnable program. */
def isMainMethod(sym: SymDenotation)(implicit ctx: Context): Boolean

/** The given class has a main method. */
final def hasMainMethod(sym: Symbol)(implicit ctx: Context): Boolean =
sym.info.member(nme.main).hasAltWith {
case x: SymDenotation => isMainMethod(x)
case _ => false
}
}

3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ object Names {
"dotty$tools$dotc$core$NameOps$NameDecorator$$functionArityFor$extension",
"dotty$tools$dotc$typer$Checking$CheckNonCyclicMap$$apply",
"$plus$plus",
"readConstant")
"readConstant",
"extractedName")
.contains(elem.getMethodName))
}

Expand Down
Loading