@@ -6,37 +6,29 @@ import dotty.tools.dotc
6
6
import dotty .tools .dotc .core .Flags .FlagSet
7
7
import dotty .tools .dotc .transform .{Erasure , GenericSignatures }
8
8
import dotty .tools .dotc .transform .SymUtils ._
9
- import java .io .{File => JFile }
9
+ import java .io .{File => _ }
10
10
11
11
import scala .collection .generic .Clearable
12
12
import scala .collection .mutable
13
13
import scala .reflect .ClassTag
14
14
import 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
17
17
import scala .tools .nsc .backend .jvm .{BCodeHelpers , BackendInterface }
18
18
import dotty .tools .dotc .core ._
19
- import Periods ._
20
- import SymDenotations ._
21
19
import Contexts ._
22
20
import Types ._
23
21
import Symbols ._
24
- import Denotations ._
25
22
import Phases ._
26
- import java .lang .AssertionError
27
23
28
- import dotty .tools .dotc .util .{ DotClass , Positions }
24
+ import dotty .tools .dotc .util .Positions
29
25
import Decorators ._
30
26
import tpd ._
31
27
32
28
import scala .tools .asm
33
29
import StdNames .{nme , str }
34
- import NameOps ._
35
30
import 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
40
32
41
33
class DottyBackendInterface (outputDirectory : AbstractFile , val superCallsMap : Map [Symbol , Set [ClassSymbol ]])(implicit ctx : Context ) extends BackendInterface {
42
34
import Symbols .{toDenot , toClassDenot }
@@ -84,7 +76,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
84
76
type LabelDef = tpd.DefDef
85
77
type Closure = tpd.Closure
86
78
87
- val NoSymbol = Symbols .NoSymbol
79
+ val NoSymbol : Symbol = Symbols .NoSymbol
88
80
val NoPosition : Position = Positions .NoPosition
89
81
val EmptyTree : Tree = tpd.EmptyTree
90
82
@@ -112,11 +104,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
112
104
val nme_EQEQ_LOCAL_VAR : Name = StdNames .nme.EQEQ_LOCAL_VAR
113
105
114
106
// 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" )
117
109
118
110
val nme_valueOf : Name = StdNames .nme.valueOf
119
- val nme_apply = StdNames .nme.apply
111
+ val nme_apply : TermName = StdNames .nme.apply
120
112
val NothingClass : Symbol = defn.NothingClass
121
113
val NullClass : Symbol = defn.NullClass
122
114
val ObjectClass : Symbol = defn.ObjectClass
@@ -136,7 +128,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
136
128
val LongClass : Symbol = defn.LongClass
137
129
val FloatClass : Symbol = defn.FloatClass
138
130
val DoubleClass : Symbol = defn.DoubleClass
139
- def isArrayClone (tree : Tree ) = tree match {
131
+ def isArrayClone (tree : Tree ): Boolean = tree match {
140
132
case Select (qual, StdNames .nme.clone_) if qual.tpe.widen.isInstanceOf [JavaArrayType ] => true
141
133
case _ => false
142
134
}
@@ -154,19 +146,19 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
154
146
val String_valueOf : Symbol = defn.String_valueOf_Object
155
147
lazy val Predef_classOf : Symbol = defn.ScalaPredefModule .requiredMethod(nme.classOf )
156
148
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" )
162
154
163
155
def boxMethods : Map [Symbol , Symbol ] = defn.ScalaValueClasses ().map{x => // @darkdimius Are you sure this should be a def?
164
156
(x, Erasure .Boxing .boxMethod(x.asClass))
165
157
}.toMap
166
158
def unboxMethods : Map [Symbol , Symbol ] =
167
159
defn.ScalaValueClasses ().map(x => (x, Erasure .Boxing .unboxMethod(x.asClass))).toMap
168
160
169
- override def isSyntheticArrayConstructor (s : Symbol ) = {
161
+ override def isSyntheticArrayConstructor (s : Symbol ): Boolean = {
170
162
s eq defn.newArrayMethod
171
163
}
172
164
@@ -317,7 +309,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
317
309
}
318
310
319
311
override def emitAnnotations (cw : asm.ClassVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
320
- (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
312
+ (innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
321
313
for (annot <- annotations; if shouldEmitAnnotation(annot)) {
322
314
val typ = annot.atp
323
315
val assocs = annot.assocs
@@ -334,7 +326,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
334
326
}
335
327
336
328
override def emitAnnotations (mw : asm.MethodVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
337
- (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
329
+ (innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
338
330
for (annot <- annotations; if shouldEmitAnnotation(annot)) {
339
331
val typ = annot.atp
340
332
val assocs = annot.assocs
@@ -344,7 +336,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
344
336
}
345
337
346
338
override def emitAnnotations (fw : asm.FieldVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
347
- (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
339
+ (innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
348
340
for (annot <- annotations; if shouldEmitAnnotation(annot)) {
349
341
val typ = annot.atp
350
342
val assocs = annot.assocs
@@ -400,7 +392,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
400
392
401
393
def emitAsmp : Option [String ] = None
402
394
403
- def shouldEmitJumpAfterLabels = true
395
+ def shouldEmitJumpAfterLabels : Boolean = true
404
396
405
397
def dumpClasses : Option [String ] =
406
398
if (ctx.settings.Ydumpclasses .isDefault) None
@@ -428,7 +420,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
428
420
429
421
val MODULE_INSTANCE_FIELD : String = str.MODULE_INSTANCE_FIELD
430
422
431
- def dropModule (str : String ) =
423
+ def dropModule (str : String ): String =
432
424
if (! str.isEmpty && str.last == '$' ) str.take(str.length - 1 ) else str
433
425
434
426
def newTermName (prefix : String ): Name = prefix.toTermName
@@ -479,7 +471,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
479
471
}
480
472
481
473
// todo: remove
482
- def isMaybeBoxed (sym : Symbol ) = {
474
+ def isMaybeBoxed (sym : Symbol ): Boolean = {
483
475
(sym == ObjectClass ) ||
484
476
(sym == JavaSerializableClass ) ||
485
477
(sym == defn.ComparableClass ) ||
@@ -1055,13 +1047,13 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1055
1047
1056
1048
// todo: this product1s should also eventually become name-based pattn matching
1057
1049
object Literal extends LiteralDeconstructor {
1058
- def get = field.const
1050
+ def get : Constant = field.const
1059
1051
}
1060
1052
1061
1053
object Throw extends ThrowDeconstructor {
1062
- def get = field.args.head
1054
+ def get : Tree = field.args.head
1063
1055
1064
- override def unapply (s : Throw ): DottyBackendInterface . this . Throw .type = {
1056
+ override def unapply (s : Throw ): Throw .type = {
1065
1057
if (s.fun.symbol eq defn.throwMethod) {
1066
1058
field = s
1067
1059
} else {
@@ -1072,11 +1064,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1072
1064
}
1073
1065
1074
1066
object New extends NewDeconstructor {
1075
- def get = field.tpt.tpe
1067
+ def get : Type = field.tpt.tpe
1076
1068
}
1077
1069
1078
1070
object This extends ThisDeconstructor {
1079
- def get = field.qual.name
1071
+ def get : Name = field.qual.name
1080
1072
def apply (s : Symbol ): This = tpd.This (s.asClass)
1081
1073
}
1082
1074
@@ -1096,15 +1088,15 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1096
1088
}
1097
1089
1098
1090
object Ident extends IdentDeconstructor {
1099
- def get = field.name
1091
+ def get : Name = field.name
1100
1092
}
1101
1093
1102
1094
object Alternative extends AlternativeDeconstructor {
1103
- def get = field.trees
1095
+ def get : List [ Tree ] = field.trees
1104
1096
}
1105
1097
1106
1098
object Constant extends ConstantDeconstructor {
1107
- def get = field.value
1099
+ def get : Any = field.value
1108
1100
}
1109
1101
object ThrownException extends ThrownException {
1110
1102
def unapply (a : Annotation ): Option [Symbol ] = None // todo
@@ -1121,7 +1113,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1121
1113
def _2 : List [Symbol ] = field.vparamss.flatMap(_.map(_.symbol))
1122
1114
def _3 : Tree = field.rhs
1123
1115
1124
- override def unapply (s : LabelDef ): DottyBackendInterface . this . LabelDef .type = {
1116
+ override def unapply (s : LabelDef ): LabelDef .type = {
1125
1117
if (s.symbol is Flags .Label ) this .field = s
1126
1118
else this .field = null
1127
1119
this
@@ -1199,9 +1191,9 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1199
1191
}
1200
1192
1201
1193
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 = {
1205
1197
val t = field.tpt.tpe.typeSymbol
1206
1198
if (t.exists) t
1207
1199
else {
@@ -1214,5 +1206,5 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1214
1206
}
1215
1207
}
1216
1208
1217
- def currentUnit = ctx.compilationUnit
1209
+ def currentUnit : CompilationUnit = ctx.compilationUnit
1218
1210
}
0 commit comments