@@ -28,7 +28,7 @@ import tpd._
28
28
import scala .tools .asm
29
29
import StdNames .{nme , str }
30
30
import NameKinds .{DefaultGetterName , ExpandedName }
31
-
31
+ import Names . TermName
32
32
33
33
class DottyBackendInterface (outputDirectory : AbstractFile , val superCallsMap : Map [Symbol , Set [ClassSymbol ]])(implicit ctx : Context ) extends BackendInterface {
34
34
import Symbols .{toDenot , toClassDenot }
@@ -76,7 +76,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
76
76
type LabelDef = tpd.DefDef
77
77
type Closure = tpd.Closure
78
78
79
- val NoSymbol = Symbols .NoSymbol
79
+ val NoSymbol : Symbols . NoSymbol . type = Symbols .NoSymbol
80
80
val NoPosition : Position = Positions .NoPosition
81
81
val EmptyTree : Tree = tpd.EmptyTree
82
82
@@ -104,11 +104,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
104
104
val nme_EQEQ_LOCAL_VAR : Name = StdNames .nme.EQEQ_LOCAL_VAR
105
105
106
106
// require LambdaMetafactory: scalac uses getClassIfDefined, but we need those always.
107
- override lazy val LambdaMetaFactory = ctx.requiredClass(" java.lang.invoke.LambdaMetafactory" )
108
- 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" )
109
109
110
110
val nme_valueOf : Name = StdNames .nme.valueOf
111
- val nme_apply = StdNames .nme.apply
111
+ val nme_apply : TermName = StdNames .nme.apply
112
112
val NothingClass : Symbol = defn.NothingClass
113
113
val NullClass : Symbol = defn.NullClass
114
114
val ObjectClass : Symbol = defn.ObjectClass
@@ -128,7 +128,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
128
128
val LongClass : Symbol = defn.LongClass
129
129
val FloatClass : Symbol = defn.FloatClass
130
130
val DoubleClass : Symbol = defn.DoubleClass
131
- def isArrayClone (tree : Tree ) = tree match {
131
+ def isArrayClone (tree : Tree ): Boolean = tree match {
132
132
case Select (qual, StdNames .nme.clone_) if qual.tpe.widen.isInstanceOf [JavaArrayType ] => true
133
133
case _ => false
134
134
}
@@ -146,19 +146,19 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
146
146
val String_valueOf : Symbol = defn.String_valueOf_Object
147
147
lazy val Predef_classOf : Symbol = defn.ScalaPredefModule .requiredMethod(nme.classOf )
148
148
149
- lazy val AnnotationRetentionAttr = ctx.requiredClass(" java.lang.annotation.Retention" )
150
- lazy val AnnotationRetentionSourceAttr = ctx.requiredClass(" java.lang.annotation.RetentionPolicy" ).linkedClass.requiredValue(" SOURCE" )
151
- lazy val AnnotationRetentionClassAttr = ctx.requiredClass(" java.lang.annotation.RetentionPolicy" ).linkedClass.requiredValue(" CLASS" )
152
- lazy val AnnotationRetentionRuntimeAttr = ctx.requiredClass(" java.lang.annotation.RetentionPolicy" ).linkedClass.requiredValue(" RUNTIME" )
153
- 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" )
154
154
155
155
def boxMethods : Map [Symbol , Symbol ] = defn.ScalaValueClasses ().map{x => // @darkdimius Are you sure this should be a def?
156
156
(x, Erasure .Boxing .boxMethod(x.asClass))
157
157
}.toMap
158
158
def unboxMethods : Map [Symbol , Symbol ] =
159
159
defn.ScalaValueClasses ().map(x => (x, Erasure .Boxing .unboxMethod(x.asClass))).toMap
160
160
161
- override def isSyntheticArrayConstructor (s : Symbol ) = {
161
+ override def isSyntheticArrayConstructor (s : Symbol ): Boolean = {
162
162
s eq defn.newArrayMethod
163
163
}
164
164
@@ -309,7 +309,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
309
309
}
310
310
311
311
override def emitAnnotations (cw : asm.ClassVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
312
- (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
312
+ (innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
313
313
for (annot <- annotations; if shouldEmitAnnotation(annot)) {
314
314
val typ = annot.atp
315
315
val assocs = annot.assocs
@@ -326,7 +326,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
326
326
}
327
327
328
328
override def emitAnnotations (mw : asm.MethodVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
329
- (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
329
+ (innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
330
330
for (annot <- annotations; if shouldEmitAnnotation(annot)) {
331
331
val typ = annot.atp
332
332
val assocs = annot.assocs
@@ -336,7 +336,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
336
336
}
337
337
338
338
override def emitAnnotations (fw : asm.FieldVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
339
- (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
339
+ (innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
340
340
for (annot <- annotations; if shouldEmitAnnotation(annot)) {
341
341
val typ = annot.atp
342
342
val assocs = annot.assocs
@@ -392,7 +392,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
392
392
393
393
def emitAsmp : Option [String ] = None
394
394
395
- def shouldEmitJumpAfterLabels = true
395
+ def shouldEmitJumpAfterLabels : Boolean = true
396
396
397
397
def dumpClasses : Option [String ] =
398
398
if (ctx.settings.Ydumpclasses .isDefault) None
@@ -420,7 +420,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
420
420
421
421
val MODULE_INSTANCE_FIELD : String = str.MODULE_INSTANCE_FIELD
422
422
423
- def dropModule (str : String ) =
423
+ def dropModule (str : String ): String =
424
424
if (! str.isEmpty && str.last == '$' ) str.take(str.length - 1 ) else str
425
425
426
426
def newTermName (prefix : String ): Name = prefix.toTermName
@@ -471,7 +471,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
471
471
}
472
472
473
473
// todo: remove
474
- def isMaybeBoxed (sym : Symbol ) = {
474
+ def isMaybeBoxed (sym : Symbol ): Boolean = {
475
475
(sym == ObjectClass ) ||
476
476
(sym == JavaSerializableClass ) ||
477
477
(sym == defn.ComparableClass ) ||
@@ -1047,13 +1047,13 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1047
1047
1048
1048
// todo: this product1s should also eventually become name-based pattn matching
1049
1049
object Literal extends LiteralDeconstructor {
1050
- def get = field.const
1050
+ def get : Constant = field.const
1051
1051
}
1052
1052
1053
1053
object Throw extends ThrowDeconstructor {
1054
- def get = field.args.head
1054
+ def get : Tree = field.args.head
1055
1055
1056
- override def unapply (s : Throw ): DottyBackendInterface . this . Throw .type = {
1056
+ override def unapply (s : Throw ): Throw .type = {
1057
1057
if (s.fun.symbol eq defn.throwMethod) {
1058
1058
field = s
1059
1059
} else {
@@ -1064,11 +1064,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1064
1064
}
1065
1065
1066
1066
object New extends NewDeconstructor {
1067
- def get = field.tpt.tpe
1067
+ def get : Type = field.tpt.tpe
1068
1068
}
1069
1069
1070
1070
object This extends ThisDeconstructor {
1071
- def get = field.qual.name
1071
+ def get : Name = field.qual.name
1072
1072
def apply (s : Symbol ): This = tpd.This (s.asClass)
1073
1073
}
1074
1074
@@ -1088,15 +1088,15 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1088
1088
}
1089
1089
1090
1090
object Ident extends IdentDeconstructor {
1091
- def get = field.name
1091
+ def get : Name = field.name
1092
1092
}
1093
1093
1094
1094
object Alternative extends AlternativeDeconstructor {
1095
- def get = field.trees
1095
+ def get : List [ Tree ] = field.trees
1096
1096
}
1097
1097
1098
1098
object Constant extends ConstantDeconstructor {
1099
- def get = field.value
1099
+ def get : Any = field.value
1100
1100
}
1101
1101
object ThrownException extends ThrownException {
1102
1102
def unapply (a : Annotation ): Option [Symbol ] = None // todo
@@ -1113,7 +1113,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1113
1113
def _2 : List [Symbol ] = field.vparamss.flatMap(_.map(_.symbol))
1114
1114
def _3 : Tree = field.rhs
1115
1115
1116
- override def unapply (s : LabelDef ): DottyBackendInterface . this . LabelDef .type = {
1116
+ override def unapply (s : LabelDef ): LabelDef .type = {
1117
1117
if (s.symbol is Flags .Label ) this .field = s
1118
1118
else this .field = null
1119
1119
this
@@ -1191,9 +1191,9 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1191
1191
}
1192
1192
1193
1193
object Closure extends ClosureDeconstructor {
1194
- def _1 = field.env
1195
- def _2 = field.meth
1196
- def _3 = {
1194
+ def _1 : List [ Tree ] = field.env
1195
+ def _2 : Tree = field.meth
1196
+ def _3 : Symbol = {
1197
1197
val t = field.tpt.tpe.typeSymbol
1198
1198
if (t.exists) t
1199
1199
else {
@@ -1206,5 +1206,5 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1206
1206
}
1207
1207
}
1208
1208
1209
- def currentUnit = ctx.compilationUnit
1209
+ def currentUnit : CompilationUnit = ctx.compilationUnit
1210
1210
}
0 commit comments