Skip to content

Commit ee29f47

Browse files
committed
Make CollectEntryPoints stable against type aliases.
1 parent c679218 commit ee29f47

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/dotty/tools/backend/jvm/CollectEntryPoints.scala

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,22 @@ class CollectEntryPoints extends MiniPhaseTransform {
4848
}
4949

5050
object CollectEntryPoints{
51+
def isJavaMainMethod(sym: Symbol)(implicit ctx: Context) = {
52+
val d = ctx.definitions
53+
val StringType = d.StringType
54+
55+
(sym.name == nme.main) && (sym.info match {
56+
case r@MethodType(_, List(d.ArrayType(t))) =>
57+
(t.widenDealias =:= StringType) && (
58+
r.resultType.widenDealias =:= d.UnitType)
59+
case _ => false
60+
})
61+
}
62+
5163
def isJavaEntyPoint(sym: Symbol)(implicit ctx: Context): Boolean = {
5264
import Types.MethodType
5365
val d = ctx.definitions
5466
val StringType = d.StringType
55-
def isJavaMainMethod(sym: Symbol) = (sym.name == nme.main) && (toDenot(sym).info match {
56-
case r@ MethodType(_, List(d.ArrayType(StringType))) => r.resultType eq d.UnitType
57-
case _ => false
58-
})
5967
// The given class has a main method.
6068
def hasJavaMainMethod(sym: Symbol): Boolean =
6169
(toDenot(sym).info member nme.main).alternatives exists(x => isJavaMainMethod(x.symbol))

0 commit comments

Comments
 (0)