@@ -6,37 +6,29 @@ import dotty.tools.dotc
66import dotty .tools .dotc .core .Flags .FlagSet
77import dotty .tools .dotc .transform .{Erasure , GenericSignatures }
88import dotty .tools .dotc .transform .SymUtils ._
9- import java .io .{File => JFile }
9+ import java .io .{File => _ }
1010
1111import scala .collection .generic .Clearable
1212import scala .collection .mutable
1313import scala .reflect .ClassTag
1414import scala .reflect .internal .util .WeakHashSet
15- import dotty .tools .io .{ AbstractFile , Directory , PlainDirectory }
16- import scala .tools .asm .{ AnnotationVisitor , ClassVisitor , FieldVisitor , MethodVisitor }
15+ import dotty .tools .io .AbstractFile
16+ import scala .tools .asm .AnnotationVisitor
1717import scala .tools .nsc .backend .jvm .{BCodeHelpers , BackendInterface }
1818import dotty .tools .dotc .core ._
19- import Periods ._
20- import SymDenotations ._
2119import Contexts ._
2220import Types ._
2321import Symbols ._
24- import Denotations ._
2522import Phases ._
26- import java .lang .AssertionError
2723
28- import dotty .tools .dotc .util .{ DotClass , Positions }
24+ import dotty .tools .dotc .util .Positions
2925import Decorators ._
3026import tpd ._
3127
3228import scala .tools .asm
3329import StdNames .{nme , str }
34- import NameOps ._
3530import NameKinds .{DefaultGetterName , ExpandedName }
36- import dotty .tools .dotc .core
37- import dotty .tools .dotc .core .Names .TypeName
38-
39- import scala .annotation .tailrec
31+ import Names .TermName
4032
4133class DottyBackendInterface (outputDirectory : AbstractFile , val superCallsMap : Map [Symbol , Set [ClassSymbol ]])(implicit ctx : Context ) extends BackendInterface {
4234 import Symbols .{toDenot , toClassDenot }
@@ -84,7 +76,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
8476 type LabelDef = tpd.DefDef
8577 type Closure = tpd.Closure
8678
87- val NoSymbol = Symbols .NoSymbol
79+ val NoSymbol : Symbol = Symbols .NoSymbol
8880 val NoPosition : Position = Positions .NoPosition
8981 val EmptyTree : Tree = tpd.EmptyTree
9082
@@ -112,11 +104,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
112104 val nme_EQEQ_LOCAL_VAR : Name = StdNames .nme.EQEQ_LOCAL_VAR
113105
114106 // require LambdaMetafactory: scalac uses getClassIfDefined, but we need those always.
115- override lazy val LambdaMetaFactory = ctx.requiredClass(" java.lang.invoke.LambdaMetafactory" )
116- override lazy val MethodHandle = ctx.requiredClass(" java.lang.invoke.MethodHandle" )
107+ override lazy val LambdaMetaFactory : ClassSymbol = ctx.requiredClass(" java.lang.invoke.LambdaMetafactory" )
108+ override lazy val MethodHandle : ClassSymbol = ctx.requiredClass(" java.lang.invoke.MethodHandle" )
117109
118110 val nme_valueOf : Name = StdNames .nme.valueOf
119- val nme_apply = StdNames .nme.apply
111+ val nme_apply : TermName = StdNames .nme.apply
120112 val NothingClass : Symbol = defn.NothingClass
121113 val NullClass : Symbol = defn.NullClass
122114 val ObjectClass : Symbol = defn.ObjectClass
@@ -136,7 +128,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
136128 val LongClass : Symbol = defn.LongClass
137129 val FloatClass : Symbol = defn.FloatClass
138130 val DoubleClass : Symbol = defn.DoubleClass
139- def isArrayClone (tree : Tree ) = tree match {
131+ def isArrayClone (tree : Tree ): Boolean = tree match {
140132 case Select (qual, StdNames .nme.clone_) if qual.tpe.widen.isInstanceOf [JavaArrayType ] => true
141133 case _ => false
142134 }
@@ -154,19 +146,19 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
154146 val String_valueOf : Symbol = defn.String_valueOf_Object
155147 lazy val Predef_classOf : Symbol = defn.ScalaPredefModule .requiredMethod(nme.classOf )
156148
157- lazy val AnnotationRetentionAttr = ctx.requiredClass(" java.lang.annotation.Retention" )
158- lazy val AnnotationRetentionSourceAttr = ctx.requiredClass(" java.lang.annotation.RetentionPolicy" ).linkedClass.requiredValue(" SOURCE" )
159- lazy val AnnotationRetentionClassAttr = ctx.requiredClass(" java.lang.annotation.RetentionPolicy" ).linkedClass.requiredValue(" CLASS" )
160- lazy val AnnotationRetentionRuntimeAttr = ctx.requiredClass(" java.lang.annotation.RetentionPolicy" ).linkedClass.requiredValue(" RUNTIME" )
161- lazy val JavaAnnotationClass = ctx.requiredClass(" java.lang.annotation.Annotation" )
149+ lazy val AnnotationRetentionAttr : ClassSymbol = ctx.requiredClass(" java.lang.annotation.Retention" )
150+ lazy val AnnotationRetentionSourceAttr : TermSymbol = ctx.requiredClass(" java.lang.annotation.RetentionPolicy" ).linkedClass.requiredValue(" SOURCE" )
151+ lazy val AnnotationRetentionClassAttr : TermSymbol = ctx.requiredClass(" java.lang.annotation.RetentionPolicy" ).linkedClass.requiredValue(" CLASS" )
152+ lazy val AnnotationRetentionRuntimeAttr : TermSymbol = ctx.requiredClass(" java.lang.annotation.RetentionPolicy" ).linkedClass.requiredValue(" RUNTIME" )
153+ lazy val JavaAnnotationClass : ClassSymbol = ctx.requiredClass(" java.lang.annotation.Annotation" )
162154
163155 def boxMethods : Map [Symbol , Symbol ] = defn.ScalaValueClasses ().map{x => // @darkdimius Are you sure this should be a def?
164156 (x, Erasure .Boxing .boxMethod(x.asClass))
165157 }.toMap
166158 def unboxMethods : Map [Symbol , Symbol ] =
167159 defn.ScalaValueClasses ().map(x => (x, Erasure .Boxing .unboxMethod(x.asClass))).toMap
168160
169- override def isSyntheticArrayConstructor (s : Symbol ) = {
161+ override def isSyntheticArrayConstructor (s : Symbol ): Boolean = {
170162 s eq defn.newArrayMethod
171163 }
172164
@@ -317,7 +309,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
317309 }
318310
319311 override def emitAnnotations (cw : asm.ClassVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
320- (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
312+ (innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
321313 for (annot <- annotations; if shouldEmitAnnotation(annot)) {
322314 val typ = annot.atp
323315 val assocs = annot.assocs
@@ -334,7 +326,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
334326 }
335327
336328 override def emitAnnotations (mw : asm.MethodVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
337- (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
329+ (innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
338330 for (annot <- annotations; if shouldEmitAnnotation(annot)) {
339331 val typ = annot.atp
340332 val assocs = annot.assocs
@@ -344,7 +336,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
344336 }
345337
346338 override def emitAnnotations (fw : asm.FieldVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
347- (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
339+ (innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
348340 for (annot <- annotations; if shouldEmitAnnotation(annot)) {
349341 val typ = annot.atp
350342 val assocs = annot.assocs
@@ -400,7 +392,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
400392
401393 def emitAsmp : Option [String ] = None
402394
403- def shouldEmitJumpAfterLabels = true
395+ def shouldEmitJumpAfterLabels : Boolean = true
404396
405397 def dumpClasses : Option [String ] =
406398 if (ctx.settings.Ydumpclasses .isDefault) None
@@ -428,7 +420,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
428420
429421 val MODULE_INSTANCE_FIELD : String = str.MODULE_INSTANCE_FIELD
430422
431- def dropModule (str : String ) =
423+ def dropModule (str : String ): String =
432424 if (! str.isEmpty && str.last == '$' ) str.take(str.length - 1 ) else str
433425
434426 def newTermName (prefix : String ): Name = prefix.toTermName
@@ -479,7 +471,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
479471 }
480472
481473 // todo: remove
482- def isMaybeBoxed (sym : Symbol ) = {
474+ def isMaybeBoxed (sym : Symbol ): Boolean = {
483475 (sym == ObjectClass ) ||
484476 (sym == JavaSerializableClass ) ||
485477 (sym == defn.ComparableClass ) ||
@@ -1055,13 +1047,13 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
10551047
10561048 // todo: this product1s should also eventually become name-based pattn matching
10571049 object Literal extends LiteralDeconstructor {
1058- def get = field.const
1050+ def get : Constant = field.const
10591051 }
10601052
10611053 object Throw extends ThrowDeconstructor {
1062- def get = field.args.head
1054+ def get : Tree = field.args.head
10631055
1064- override def unapply (s : Throw ): DottyBackendInterface . this . Throw .type = {
1056+ override def unapply (s : Throw ): Throw .type = {
10651057 if (s.fun.symbol eq defn.throwMethod) {
10661058 field = s
10671059 } else {
@@ -1072,11 +1064,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
10721064 }
10731065
10741066 object New extends NewDeconstructor {
1075- def get = field.tpt.tpe
1067+ def get : Type = field.tpt.tpe
10761068 }
10771069
10781070 object This extends ThisDeconstructor {
1079- def get = field.qual.name
1071+ def get : Name = field.qual.name
10801072 def apply (s : Symbol ): This = tpd.This (s.asClass)
10811073 }
10821074
@@ -1096,15 +1088,15 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
10961088 }
10971089
10981090 object Ident extends IdentDeconstructor {
1099- def get = field.name
1091+ def get : Name = field.name
11001092 }
11011093
11021094 object Alternative extends AlternativeDeconstructor {
1103- def get = field.trees
1095+ def get : List [ Tree ] = field.trees
11041096 }
11051097
11061098 object Constant extends ConstantDeconstructor {
1107- def get = field.value
1099+ def get : Any = field.value
11081100 }
11091101 object ThrownException extends ThrownException {
11101102 def unapply (a : Annotation ): Option [Symbol ] = None // todo
@@ -1121,7 +1113,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
11211113 def _2 : List [Symbol ] = field.vparamss.flatMap(_.map(_.symbol))
11221114 def _3 : Tree = field.rhs
11231115
1124- override def unapply (s : LabelDef ): DottyBackendInterface . this . LabelDef .type = {
1116+ override def unapply (s : LabelDef ): LabelDef .type = {
11251117 if (s.symbol is Flags .Label ) this .field = s
11261118 else this .field = null
11271119 this
@@ -1199,9 +1191,9 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
11991191 }
12001192
12011193 object Closure extends ClosureDeconstructor {
1202- def _1 = field.env
1203- def _2 = field.meth
1204- def _3 = {
1194+ def _1 : List [ Tree ] = field.env
1195+ def _2 : Tree = field.meth
1196+ def _3 : Symbol = {
12051197 val t = field.tpt.tpe.typeSymbol
12061198 if (t.exists) t
12071199 else {
@@ -1214,5 +1206,5 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
12141206 }
12151207 }
12161208
1217- def currentUnit = ctx.compilationUnit
1209+ def currentUnit : CompilationUnit = ctx.compilationUnit
12181210}
0 commit comments