@@ -33,7 +33,6 @@ import StdNames.nme
3333import NameOps ._
3434
3535class DottyBackendInterface ()(implicit ctx : Context ) extends BackendInterface {
36- trait NonExistentTree extends tpd.Tree
3736 type Symbol = Symbols .Symbol
3837 type Type = Types .Type
3938 type Tree = tpd.Tree
@@ -68,8 +67,8 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
6867 type Modifiers = tpd.Modifiers
6968 type Annotation = Annotations .Annotation
7069 type ArrayValue = tpd.JavaSeqLiteral
71- type ApplyDynamic = NonExistentTree
72- type ModuleDef = NonExistentTree
70+ type ApplyDynamic = Null
71+ type ModuleDef = Null
7372 type LabelDef = tpd.DefDef
7473 type Closure = tpd.Closure
7574
@@ -230,7 +229,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
230229
231230 private def emitArgument (av : AnnotationVisitor ,
232231 name : String ,
233- arg : Tree , bcodeStore : BCodeHelpers )(innerClasesStore : bcodeStore.BCInnerClassGen ) {
232+ arg : Tree , bcodeStore : BCodeHelpers )(innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
234233 (arg : @ unchecked) match {
235234
236235 case Literal (const @ Constant (_)) =>
@@ -296,7 +295,8 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
296295 }
297296 }
298297
299- override def emitAnnotations (cw : asm.ClassVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )(innerClasesStore : bcodeStore.BCInnerClassGen ) {
298+ override def emitAnnotations (cw : asm.ClassVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
299+ (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
300300 for (annot <- annotations; if shouldEmitAnnotation(annot)) {
301301 val typ = annot.atp
302302 val assocs = annot.assocs
@@ -305,14 +305,20 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
305305 }
306306 }
307307
308- private def emitAssocs (av : asm.AnnotationVisitor , assocs : List [(Name , Object )], bcodeStore : BCodeHelpers )(innerClasesStore : bcodeStore.BCInnerClassGen ) {
309- for ((name, value) <- assocs) {
310- emitArgument(av, name.toString(), value.asInstanceOf [Tree ], bcodeStore)(innerClasesStore)
308+ private def emitAssocs (av : asm.AnnotationVisitor , assocs : List [(Name , Object )], bcodeStore : BCodeHelpers )
309+ (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
310+ // for ((name, value) <- assocs) { // dotty deviation, does not work
311+
312+ for (nv <- assocs) {
313+ val name = nv._1
314+ val value = nv._2
315+ emitArgument(av, name.toString, value.asInstanceOf [Tree ], bcodeStore)(innerClasesStore)
311316 }
312317 av.visitEnd()
313318 }
314319
315- override def emitAnnotations (mw : asm.MethodVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )(innerClasesStore : bcodeStore.BCInnerClassGen ) {
320+ override def emitAnnotations (mw : asm.MethodVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
321+ (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
316322 for (annot <- annotations; if shouldEmitAnnotation(annot)) {
317323 val typ = annot.atp
318324 val assocs = annot.assocs
@@ -321,7 +327,8 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
321327 }
322328 }
323329
324- override def emitAnnotations (fw : asm.FieldVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )(innerClasesStore : bcodeStore.BCInnerClassGen ) {
330+ override def emitAnnotations (fw : asm.FieldVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
331+ (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
325332 for (annot <- annotations; if shouldEmitAnnotation(annot)) {
326333 val typ = annot.atp
327334 val assocs = annot.assocs
@@ -330,7 +337,8 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
330337 }
331338 }
332339
333- override def emitParamAnnotations (jmethod : asm.MethodVisitor , pannotss : List [List [Annotation ]], bcodeStore : BCodeHelpers )(innerClasesStore : bcodeStore.BCInnerClassGen ) {
340+ override def emitParamAnnotations (jmethod : asm.MethodVisitor , pannotss : List [List [Annotation ]], bcodeStore : BCodeHelpers )
341+ (innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
334342 val annotationss = pannotss map (_ filter shouldEmitAnnotation)
335343 if (annotationss forall (_.isEmpty)) return
336344 for ((annots, idx) <- annotationss.zipWithIndex;
@@ -678,8 +686,24 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
678686
679687 // members
680688 def primaryConstructor : Symbol = toDenot(sym).primaryConstructor
681- def nestedClasses : List [Symbol ] = memberClasses // exitingPhase(currentRun.lambdaliftPhase)(sym.memberClasses)
682- def memberClasses : List [Symbol ] = toDenot(sym).info.memberClasses.map(_.symbol).toList
689+
690+ /** For currently compiled classes: All locally defined classes including local classes.
691+ * The empty list for classes that are not currently compiled.
692+ */
693+ def nestedClasses : List [Symbol ] = definedClasses(ctx.flattenPhase)
694+
695+ /** For currently compiled classes: All classes that are declared as members of this class
696+ * (but not inherited ones). The empty list for classes that are not currently compiled.
697+ */
698+ def memberClasses : List [Symbol ] = definedClasses(ctx.lambdaLiftPhase)
699+
700+ private def definedClasses (phase : Phase ) =
701+ if (sym.isDefinedInCurrentRun)
702+ ctx.atPhase(phase) { implicit ctx =>
703+ toDenot(sym).info.decls.filter(_.isClass).toList
704+ }
705+ else Nil
706+
683707 def annotations : List [Annotation ] = Nil
684708 def companionModuleMembers : List [Symbol ] = {
685709 // phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
@@ -781,7 +805,8 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
781805 def primitiveOrClassToBType (sym : Symbol ): BType = {
782806 assert(sym.isClass, sym)
783807 assert(sym != ArrayClass || isCompilingArray, sym)
784- primitiveTypeMap.getOrElse(sym, storage.getClassBTypeAndRegisterInnerClass(sym.asInstanceOf [ct.int.Symbol ]))
808+ primitiveTypeMap.getOrElse(sym.asInstanceOf [ct.bTypes.coreBTypes.bTypes.int.Symbol ],
809+ storage.getClassBTypeAndRegisterInnerClass(sym.asInstanceOf [ct.int.Symbol ])).asInstanceOf [BType ]
785810 }
786811
787812 /**
@@ -790,7 +815,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
790815 */
791816 def nonClassTypeRefToBType (sym : Symbol ): ClassBType = {
792817 assert(sym.isType && isCompilingArray, sym)
793- ObjectReference
818+ ObjectReference . asInstanceOf [ct.bTypes. ClassBType ]
794819 }
795820
796821 tp.widenDealias match {
@@ -835,7 +860,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
835860 " If possible, please file a bug on issues.scala-lang.org." )
836861
837862 tp match {
838- case ThisType (ArrayClass ) => ObjectReference // was introduced in 9b17332f11 to fix SI-999, but this code is not reached in its test, or any other test
863+ case ThisType (ArrayClass ) => ObjectReference . asInstanceOf [ct.bTypes. ClassBType ] // was introduced in 9b17332f11 to fix SI-999, but this code is not reached in its test, or any other test
839864 case ThisType (sym) => storage.getClassBTypeAndRegisterInnerClass(sym.asInstanceOf [ct.int.Symbol ])
840865 // case t: SingletonType => primitiveOrClassToBType(t.classSymbol)
841866 case t : SingletonType => t.underlying.toTypeKind(ct)(storage)
0 commit comments