Skip to content

Commit f1e440e

Browse files
authored
First step to pipelining support - enable reading Java symbols from TASTy (#19074)
This PR contains the minimal forward incompatible changes of pipelining - reading Java and outline symbols from TASTy. The other changes to implement pipelining have no impact on TASTy or the standard library - so can come in a patch release. To test reading TASTy produced from Java defined classes, we add two private flags `-Yjava-tasty` and `-Yjava-tasty-output`, which are not expected to be used by any build tool. The tests allow us to write just the java signatures to TASTy, package them in a jar, and then read the Java TASTy from the classpath. - Keep Java compilation units up to Pickler phase if `-Yjava-tasty` is set. Skip phases for Java when not needed. - Add `JAVAattr` and `OUTLINEattr` TASTy attributes, `ELIDED` tree tag. `ELIDED` trees are pickled as rhs of java term definitions. `ELIDED` trees can only be unpickled if `OUTLINEattr` is present. - Java units will set the `JAVAattr` TASTy attribute. As currently we outline parse Java files we also set the `OUTLINEattr`. - In the future we might expand `OUTLINEattr` to include outline Scala typing. - `OUTLINEattr` and `JAVAattr` do not need any special flags to _read_ from the classpath, however to read outline tasty in the `-from-tasty` mode (so `tasty-inspector` and `scaladoc` are included) we do require an explicit `-Yallow-outline-from-tasty`, as method bodies are required for full functionality. - write java tasty files to a special jar, set with `-Yjava-tasty-output` this option is for testing purposes only. Fix sealedDescendants method for Java Enums. - Rename `JavaEnumTrait` flags to `JavaEnum` (reflecting the actual flags set) - test java enum in `SealedDescendantsTest` fixes #15908
2 parents 841bbd4 + 9b12e4a commit f1e440e

File tree

66 files changed

+587
-70
lines changed

Some content is hidden

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

66 files changed

+587
-70
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ trait BCodeHelpers extends BCodeIdiomatic {
292292
}
293293
case Ident(nme.WILDCARD) =>
294294
// An underscore argument indicates that we want to use the default value for this parameter, so do not emit anything
295-
case t: tpd.RefTree if t.symbol.owner.linkedClass.isAllOf(JavaEnumTrait) =>
295+
case t: tpd.RefTree if t.symbol.owner.linkedClass.isAllOf(JavaEnum) =>
296296
val edesc = innerClasesStore.typeDescriptor(t.tpe) // the class descriptor of the enumeration class.
297297
val evalue = t.symbol.javaSimpleName // value the actual enumeration value.
298298
av.visitEnum(name, edesc, evalue)

compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I, val frontendAcce
304304
.addFlagIf(sym.is(Bridge), ACC_BRIDGE | ACC_SYNTHETIC)
305305
.addFlagIf(sym.is(Artifact), ACC_SYNTHETIC)
306306
.addFlagIf(sym.isClass && !sym.isInterface, ACC_SUPER)
307-
.addFlagIf(sym.isAllOf(JavaEnumTrait), ACC_ENUM)
307+
.addFlagIf(sym.isAllOf(JavaEnum), ACC_ENUM)
308308
.addFlagIf(sym.is(JavaVarargs), ACC_VARARGS)
309309
.addFlagIf(sym.is(Synchronized), ACC_SYNCHRONIZED)
310310
.addFlagIf(sym.isDeprecated, ACC_DEPRECATED)

compiler/src/dotty/tools/dotc/CompilationUnit.scala

+16-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import scala.annotation.internal.sharable
1919
import scala.util.control.NoStackTrace
2020
import transform.MacroAnnotations
2121

22-
class CompilationUnit protected (val source: SourceFile) {
22+
class CompilationUnit protected (val source: SourceFile, val info: CompilationUnitInfo | Null) {
2323

2424
override def toString: String = source.toString
2525

@@ -30,6 +30,13 @@ class CompilationUnit protected (val source: SourceFile) {
3030
/** Is this the compilation unit of a Java file */
3131
def isJava: Boolean = source.file.name.endsWith(".java")
3232

33+
/** Is this the compilation unit of a Java file, or TASTy derived from a Java file */
34+
def typedAsJava = isJava || {
35+
val infoNN = info
36+
infoNN != null && infoNN.tastyInfo.exists(_.attributes.isJava)
37+
}
38+
39+
3340
/** The source version for this unit, as determined by a language import */
3441
var sourceVersion: Option[SourceVersion] = None
3542

@@ -106,7 +113,7 @@ class CompilationUnit protected (val source: SourceFile) {
106113
myAssignmentSpans.nn
107114
}
108115

109-
@sharable object NoCompilationUnit extends CompilationUnit(NoSource) {
116+
@sharable object NoCompilationUnit extends CompilationUnit(NoSource, info = null) {
110117

111118
override def isJava: Boolean = false
112119

@@ -122,13 +129,14 @@ object CompilationUnit {
122129

123130
/** Make a compilation unit for top class `clsd` with the contents of the `unpickled` tree */
124131
def apply(clsd: ClassDenotation, unpickled: Tree, forceTrees: Boolean)(using Context): CompilationUnit =
125-
val file = clsd.symbol.associatedFile.nn
126-
apply(SourceFile(file, Array.empty[Char]), unpickled, forceTrees)
132+
val compilationUnitInfo = clsd.symbol.compilationUnitInfo.nn
133+
val file = compilationUnitInfo.associatedFile
134+
apply(SourceFile(file, Array.empty[Char]), unpickled, forceTrees, compilationUnitInfo)
127135

128136
/** Make a compilation unit, given picked bytes and unpickled tree */
129-
def apply(source: SourceFile, unpickled: Tree, forceTrees: Boolean)(using Context): CompilationUnit = {
137+
def apply(source: SourceFile, unpickled: Tree, forceTrees: Boolean, info: CompilationUnitInfo)(using Context): CompilationUnit = {
130138
assert(!unpickled.isEmpty, unpickled)
131-
val unit1 = new CompilationUnit(source)
139+
val unit1 = new CompilationUnit(source, info)
132140
unit1.tpdTree = unpickled
133141
if (forceTrees) {
134142
val force = new Force
@@ -156,7 +164,8 @@ object CompilationUnit {
156164
NoSource
157165
}
158166
else source
159-
new CompilationUnit(src)
167+
val info = if src.exists then CompilationUnitInfo(src.file) else null
168+
new CompilationUnit(src, info)
160169
}
161170

162171
/** Force the tree to be loaded */

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import reporting.*
1717
import annotation.constructorOnly
1818
import printing.Formatting.hl
1919
import config.Printers
20+
import parsing.Parsers
2021

2122
import scala.annotation.internal.sharable
2223
import scala.annotation.threadUnsafe
@@ -143,8 +144,13 @@ object desugar {
143144

144145
/** A value definition copied from `vdef` with a tpt typetree derived from it */
145146
def derivedTermParam(vdef: ValDef)(using Context): ValDef =
147+
derivedTermParam(vdef, vdef.unforcedRhs)
148+
149+
def derivedTermParam(vdef: ValDef, rhs: LazyTree)(using Context): ValDef =
146150
cpy.ValDef(vdef)(
147-
tpt = DerivedFromParamTree().withSpan(vdef.tpt.span).watching(vdef))
151+
tpt = DerivedFromParamTree().withSpan(vdef.tpt.span).watching(vdef),
152+
rhs = rhs
153+
)
148154

149155
// ----- Desugar methods -------------------------------------------------
150156

@@ -544,8 +550,11 @@ object desugar {
544550
constrTparams.zipWithConserve(impliedTparams)((tparam, impliedParam) =>
545551
derivedTypeParam(tparam).withAnnotations(impliedParam.mods.annotations))
546552
val derivedVparamss =
547-
constrVparamss.nestedMap(vparam =>
548-
derivedTermParam(vparam).withAnnotations(Nil))
553+
constrVparamss.nestedMap: vparam =>
554+
val derived =
555+
if ctx.compilationUnit.isJava then derivedTermParam(vparam, Parsers.unimplementedExpr)
556+
else derivedTermParam(vparam)
557+
derived.withAnnotations(Nil)
549558

550559
val constr = cpy.DefDef(constr1)(paramss = joinParams(constrTparams, constrVparamss))
551560

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import dotty.tools.dotc.config.Settings.{Setting, SettingGroup}
88
import dotty.tools.dotc.config.SourceVersion
99
import dotty.tools.dotc.core.Contexts.*
1010
import dotty.tools.dotc.rewrites.Rewrites
11-
import dotty.tools.io.{AbstractFile, Directory, JDK9Reflectors, PlainDirectory}
11+
import dotty.tools.io.{AbstractFile, Directory, JDK9Reflectors, PlainDirectory, NoAbstractFile}
1212
import Setting.ChoiceWithHelp
1313

1414
import scala.util.chaining.*
@@ -433,4 +433,9 @@ private sealed trait YSettings:
433433
val YforceInlineWhileTyping: Setting[Boolean] = BooleanSetting("-Yforce-inline-while-typing", "Make non-transparent inline methods inline when typing. Emulates the old inlining behavior of 3.0.0-M3.")
434434

435435
val YdebugMacros: Setting[Boolean] = BooleanSetting("-Ydebug-macros", "Show debug info when quote pattern match fails")
436+
437+
// Pipeline compilation options
438+
val YjavaTasty: Setting[Boolean] = BooleanSetting("-Yjava-tasty", "Pickler phase should compute pickles for .java defined symbols for use by build tools")
439+
val YjavaTastyOutput: Setting[AbstractFile] = OutputSetting("-Yjava-tasty-output", "directory|jar", "(Internal use only!) destination for generated .tasty files containing Java type signatures.", NoAbstractFile)
440+
val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting("-Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.")
436441
end YSettings

compiler/src/dotty/tools/dotc/core/Definitions.scala

+1
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,7 @@ class Definitions {
996996
@tu lazy val AnnotationClass: ClassSymbol = requiredClass("scala.annotation.Annotation")
997997
@tu lazy val StaticAnnotationClass: ClassSymbol = requiredClass("scala.annotation.StaticAnnotation")
998998
@tu lazy val RefiningAnnotationClass: ClassSymbol = requiredClass("scala.annotation.RefiningAnnotation")
999+
@tu lazy val JavaAnnotationClass: ClassSymbol = requiredClass("java.lang.annotation.Annotation")
9991000

10001001
// Annotation classes
10011002
@tu lazy val AllowConversionsAnnot: ClassSymbol = requiredClass("scala.annotation.allowConversions")

compiler/src/dotty/tools/dotc/core/Flags.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ object Flags {
576576
val InlineMethod: FlagSet = Inline | Method
577577
val InlineParam: FlagSet = Inline | Param
578578
val InlineByNameProxy: FlagSet = InlineProxy | Method
579-
val JavaEnumTrait: FlagSet = JavaDefined | Enum // A Java enum trait
579+
val JavaEnum: FlagSet = JavaDefined | Enum // A Java enum trait
580580
val JavaEnumValue: FlagSet = JavaDefined | EnumValue // A Java enum value
581581
val StaticProtected: FlagSet = JavaDefined | JavaStatic | Protected // Java symbol which is `protected` and `static`
582582
val JavaModule: FlagSet = JavaDefined | Module // A Java companion object

compiler/src/dotty/tools/dotc/core/Phases.scala

+10-1
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,25 @@ object Phases {
333333
def subPhases: List[Run.SubPhase] = Nil
334334
final def traversals: Int = if subPhases.isEmpty then 1 else subPhases.length
335335

336+
/** skip the phase for a Java compilation unit, may depend on -Yjava-tasty */
337+
def skipIfJava(using Context): Boolean = true
338+
336339
/** @pre `isRunnable` returns true */
337340
def run(using Context): Unit
338341

339342
/** @pre `isRunnable` returns true */
340343
def runOn(units: List[CompilationUnit])(using runCtx: Context): List[CompilationUnit] =
341344
val buf = List.newBuilder[CompilationUnit]
345+
// factor out typedAsJava check when not needed
346+
val doSkipJava = ctx.settings.YjavaTasty.value && this <= picklerPhase && skipIfJava
342347
for unit <- units do
343348
given unitCtx: Context = runCtx.fresh.setPhase(this.start).setCompilationUnit(unit).withRootImports
344349
if ctx.run.enterUnit(unit) then
345-
try run
350+
try
351+
if doSkipJava && unit.typedAsJava then
352+
()
353+
else
354+
run
346355
catch case ex: Throwable if !ctx.run.enrichedErrorMessage =>
347356
println(ctx.run.enrichErrorMessage(s"unhandled exception while running $phaseName on $unit"))
348357
throw ex

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,7 @@ object SymDenotations {
16951695
c.ensureCompleted()
16961696
end completeChildrenIn
16971697

1698-
if is(Sealed) || isAllOf(JavaEnumTrait) then
1698+
if is(Sealed) || isAllOf(JavaEnum) && isClass then
16991699
if !is(ChildrenQueried) then
17001700
// Make sure all visible children are completed, so that
17011701
// they show up in Child annotations. A possible child is visible if it

compiler/src/dotty/tools/dotc/core/tasty/Attributes.scala

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class Attributes private[tasty](
1111
def explicitNulls: Boolean = booleanTags(EXPLICITNULLSattr)
1212
def captureChecked: Boolean = booleanTags(CAPTURECHECKEDattr)
1313
def withPureFuns: Boolean = booleanTags(WITHPUREFUNSattr)
14+
def isJava: Boolean = booleanTags(JAVAattr)
15+
def isOutline: Boolean = booleanTags(OUTLINEattr)
1416
}
1517

1618
object Attributes:
@@ -19,12 +21,16 @@ object Attributes:
1921
explicitNulls: Boolean,
2022
captureChecked: Boolean,
2123
withPureFuns: Boolean,
24+
isJava: Boolean,
25+
isOutline: Boolean,
2226
): Attributes =
2327
val booleanTags = BitSet.newBuilder
2428
if scala2StandardLibrary then booleanTags += SCALA2STANDARDLIBRARYattr
2529
if explicitNulls then booleanTags += EXPLICITNULLSattr
2630
if captureChecked then booleanTags += CAPTURECHECKEDattr
2731
if withPureFuns then booleanTags += WITHPUREFUNSattr
32+
if isJava then booleanTags += JAVAattr
33+
if isOutline then booleanTags += OUTLINEattr
2834
new Attributes(booleanTags.result())
2935
end apply
3036

compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ object DottyUnpickler {
3636
def unpickle(reader: TastyReader, nameAtRef: NameTable): CommentUnpickler =
3737
new CommentUnpickler(reader)
3838
}
39+
3940
class AttributesSectionUnpickler extends SectionUnpickler[AttributeUnpickler](AttributesSection) {
4041
def unpickle(reader: TastyReader, nameAtRef: NameTable): AttributeUnpickler =
4142
new AttributeUnpickler(reader)

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

+12-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import quoted.QuotePatterns
2323
object TreePickler:
2424
class StackSizeExceeded(val mdef: tpd.MemberDef) extends Exception
2525

26-
class TreePickler(pickler: TastyPickler) {
26+
class TreePickler(pickler: TastyPickler, attributes: Attributes) {
2727
val buf: TreeBuffer = new TreeBuffer
2828
pickler.newSection(ASTsSection, buf)
2929
import buf.*
@@ -322,6 +322,11 @@ class TreePickler(pickler: TastyPickler) {
322322
if (!tree.isEmpty) pickleTree(tree)
323323
}
324324

325+
def pickleElidedUnlessEmpty(tree: Tree, tp: Type)(using Context): Unit =
326+
if !tree.isEmpty then
327+
writeByte(ELIDED)
328+
pickleType(tp)
329+
325330
def pickleDef(tag: Int, mdef: MemberDef, tpt: Tree, rhs: Tree = EmptyTree, pickleParams: => Unit = ())(using Context): Unit = {
326331
val sym = mdef.symbol
327332

@@ -337,7 +342,12 @@ class TreePickler(pickler: TastyPickler) {
337342
case _: Template | _: Hole => pickleTree(tpt)
338343
case _ if tpt.isType => pickleTpt(tpt)
339344
}
340-
pickleTreeUnlessEmpty(rhs)
345+
if attributes.isOutline && sym.isTerm && attributes.isJava then
346+
// TODO: if we introduce outline typing for Scala definitions
347+
// then we will need to update the check here
348+
pickleElidedUnlessEmpty(rhs, tpt.tpe)
349+
else
350+
pickleTreeUnlessEmpty(rhs)
341351
pickleModifiers(sym, mdef)
342352
}
343353
catch

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

+22-2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ class TreeUnpickler(reader: TastyReader,
104104
private val explicitNulls =
105105
attributeUnpicklerOpt.exists(_.attributes.explicitNulls)
106106

107+
private val unpicklingJava =
108+
attributeUnpicklerOpt.exists(_.attributes.isJava)
109+
110+
private val isOutline = attributeUnpicklerOpt.exists(_.attributes.isOutline)
111+
107112
private def registerSym(addr: Addr, sym: Symbol) =
108113
symAtAddr(addr) = sym
109114

@@ -609,7 +614,10 @@ class TreeUnpickler(reader: TastyReader,
609614
val rhsIsEmpty = nothingButMods(end)
610615
if (!rhsIsEmpty) skipTree()
611616
val (givenFlags0, annotFns, privateWithin) = readModifiers(end)
612-
val givenFlags = if isClass && unpicklingScala2Library then givenFlags0 | Scala2x | Scala2Tasty else givenFlags0
617+
val givenFlags =
618+
if isClass && unpicklingScala2Library then givenFlags0 | Scala2x | Scala2Tasty
619+
else if unpicklingJava then givenFlags0 | JavaDefined
620+
else givenFlags0
613621
pickling.println(i"creating symbol $name at $start with flags ${givenFlags.flagsString}, isAbsType = $isAbsType, $ttag")
614622
val flags = normalizeFlags(tag, givenFlags, name, isAbsType, rhsIsEmpty)
615623
def adjustIfModule(completer: LazyType) =
@@ -1037,6 +1045,8 @@ class TreeUnpickler(reader: TastyReader,
10371045
val parentReader = fork
10381046
val parents = readParents(withArgs = false)(using parentCtx)
10391047
val parentTypes = parents.map(_.tpe.dealias)
1048+
if cls.is(JavaDefined) && parentTypes.exists(_.derivesFrom(defn.JavaAnnotationClass)) then
1049+
cls.setFlag(JavaAnnotation)
10401050
val self =
10411051
if (nextByte == SELFDEF) {
10421052
readByte()
@@ -1197,7 +1207,12 @@ class TreeUnpickler(reader: TastyReader,
11971207

11981208
def completeSelect(name: Name, sig: Signature, target: Name): Select =
11991209
val qual = readTree()
1200-
val denot = accessibleDenot(qual.tpe.widenIfUnstable, name, sig, target)
1210+
val denot0 = accessibleDenot(qual.tpe.widenIfUnstable, name, sig, target)
1211+
val denot =
1212+
if unpicklingJava && name == tpnme.Object && denot0.symbol == defn.ObjectClass then
1213+
defn.FromJavaObjectType.denot
1214+
else
1215+
denot0
12011216
makeSelect(qual, name, denot)
12021217

12031218
def readQualId(): (untpd.Ident, TypeRef) =
@@ -1216,6 +1231,11 @@ class TreeUnpickler(reader: TastyReader,
12161231
forkAt(readAddr()).readTree()
12171232
case IDENT =>
12181233
untpd.Ident(readName()).withType(readType())
1234+
case ELIDED =>
1235+
if !isOutline then
1236+
report.error(
1237+
s"Illegal elided tree in unpickler without ${attributeTagToString(OUTLINEattr)}, ${ctx.source}")
1238+
untpd.Ident(nme.WILDCARD).withType(readType())
12191239
case IDENTtpt =>
12201240
untpd.Ident(readName().toTypeName).withType(readType())
12211241
case SELECT =>

compiler/src/dotty/tools/dotc/fromtasty/AlreadyLoadedCompilationUnit.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ import dotty.tools.dotc.util.NoSource
77
* encountered, and attempted to inspect, something that has already been loaded, for example a Scala primitive or a
88
* library class like Option.
99
*/
10-
class AlreadyLoadedCompilationUnit(val className: String) extends CompilationUnit(NoSource)
10+
class AlreadyLoadedCompilationUnit(val className: String) extends CompilationUnit(NoSource, null)

compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala

+10-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,16 @@ class ReadTasty extends Phase {
4646
case unpickler: tasty.DottyUnpickler =>
4747
if (cls.rootTree.isEmpty) None
4848
else {
49-
val unit = CompilationUnit(cls, cls.rootTree, forceTrees = true)
50-
unit.pickled += (cls -> (() => unpickler.unpickler.bytes))
51-
Some(unit)
49+
val attributes = unpickler.tastyAttributes
50+
if attributes.isJava && !ctx.settings.YjavaTasty.value then
51+
// filter out Java compilation units if -Yjava-tasty is not set
52+
None
53+
else if attributes.isOutline && !ctx.settings.YallowOutlineFromTasty.value then
54+
cannotUnpickle("it contains outline signatures and -Yallow-outline-from-tasty is not set.")
55+
else
56+
val unit = CompilationUnit(cls, cls.rootTree, forceTrees = true)
57+
unit.pickled += (cls -> (() => unpickler.unpickler.bytes))
58+
Some(unit)
5259
}
5360
case tree: Tree[?] =>
5461
// TODO handle correctly this case correctly to get the tree or avoid it completely.

compiler/src/dotty/tools/dotc/fromtasty/TASTYCompilationUnit.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ package dotty.tools.dotc.fromtasty
33
import dotty.tools.dotc.CompilationUnit
44
import dotty.tools.dotc.util.NoSource
55

6-
class TASTYCompilationUnit(val className: String) extends CompilationUnit(NoSource) {
6+
class TASTYCompilationUnit(val className: String) extends CompilationUnit(NoSource, null) {
77
override def toString: String = s"class file $className"
88
}

compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ object JavaParsers {
136136
ValDef(name, tpt, EmptyTree).withMods(Modifiers(Flags.JavaDefined | Flags.Param))
137137

138138
def makeConstructor(formals: List[Tree], tparams: List[TypeDef], flags: FlagSet = Flags.JavaDefined): DefDef = {
139-
val vparams = formals.zipWithIndex.map { case (p, i) => makeSyntheticParam(i + 1, p) }
139+
val vparams = formals.zipWithIndex.map { case (p, i) => makeSyntheticParam(i + 1, p).withMods(Modifiers(flags)) }
140140
DefDef(nme.CONSTRUCTOR, joinParams(tparams, List(vparams)), TypeTree(), EmptyTree).withMods(Modifiers(flags))
141141
}
142142

@@ -992,7 +992,7 @@ object JavaParsers {
992992
Select(New(javaLangDot(tpnme.Enum)), nme.CONSTRUCTOR), List(enumType)), Nil)
993993
val enumclazz = atSpan(start, nameOffset) {
994994
TypeDef(name,
995-
makeTemplate(superclazz :: interfaces, body, List(), true)).withMods(mods | Flags.JavaEnumTrait)
995+
makeTemplate(superclazz :: interfaces, body, List(), true)).withMods(mods | Flags.JavaEnum)
996996
}
997997
addCompanionObject(consts ::: statics ::: predefs, enumclazz)
998998
}
@@ -1011,7 +1011,7 @@ object JavaParsers {
10111011
skipAhead()
10121012
accept(RBRACE)
10131013
}
1014-
ValDef(name.toTermName, enumType, unimplementedExpr).withMods(Modifiers(Flags.JavaEnumTrait | Flags.StableRealizable | Flags.JavaDefined | Flags.JavaStatic))
1014+
ValDef(name.toTermName, enumType, unimplementedExpr).withMods(Modifiers(Flags.JavaEnumValue | Flags.JavaStatic))
10151015
}
10161016
}
10171017

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ object Parsers {
9797
private val InCond: Region => Region = Scanners.InParens(LPAREN, _)
9898
private val InFor : Region => Region = Scanners.InBraces(_)
9999

100+
def unimplementedExpr(using Context): Select =
101+
Select(scalaDot(nme.Predef), nme.???)
102+
100103
abstract class ParserCommon(val source: SourceFile)(using Context) {
101104

102105
val in: ScannerCommon
@@ -164,9 +167,6 @@ object Parsers {
164167
*/
165168
def syntaxError(msg: Message, span: Span): Unit =
166169
report.error(msg, source.atSpan(span))
167-
168-
def unimplementedExpr(using Context): Select =
169-
Select(scalaDot(nme.Predef), nme.???)
170170
}
171171

172172
trait OutlineParserCommon extends ParserCommon {

0 commit comments

Comments
 (0)