Skip to content

Add explicit return type to some methods #4937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CollectEntryPoints extends MiniPhase {
}

object CollectEntryPoints{
def isJavaMainMethod(sym: Symbol)(implicit ctx: Context) = {
def isJavaMainMethod(sym: Symbol)(implicit ctx: Context): Boolean = {
(sym.name == nme.main) && (sym.info match {
case r@MethodTpe(_, List(defn.ArrayOf(t)), _) =>
(t.widenDealias =:= defn.StringType) && (
Expand All @@ -63,7 +63,7 @@ object CollectEntryPoints{
def hasJavaMainMethod(sym: Symbol): Boolean =
(toDenot(sym).info member nme.main).alternatives exists(x => isJavaMainMethod(x.symbol))

def fail(msg: String, pos: Position = sym.pos) = {
def fail(msg: String, pos: Position = sym.pos): Boolean = {
ctx.warning( sym.name +
s" has a main method with parameter type Array[String], but ${toDenot(sym).fullName} will not be a runnable program.\n Reason: $msg",
sourcePos(sym.pos)
Expand All @@ -74,7 +74,7 @@ object CollectEntryPoints{
)
false
}
def failNoForwarder(msg: String) = {
def failNoForwarder(msg: String): Boolean = {
fail(s"$msg, which means no static forwarder can be generated.\n")
}
val possibles = if (sym.flags is Flags.Module) (toDenot(sym).info nonPrivateMember nme.main).alternatives else Nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CollectSuperCalls extends MiniPhase {
tree
}

private def registerSuperCall(sym: ClassSymbol, calls: ClassSymbol)(implicit ctx: Context) = {
private def registerSuperCall(sym: ClassSymbol, calls: ClassSymbol)(implicit ctx: Context): Unit = {
ctx.genBCodePhase match {
case genBCodePhase: GenBCode =>
genBCodePhase.registerSuperCall(sym, calls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
}

override def emitAnnotations(cw: asm.ClassVisitor, annotations: List[Annotation], bcodeStore: BCodeHelpers)
(innerClasesStore: bcodeStore.BCInnerClassGen) = {
(innerClasesStore: bcodeStore.BCInnerClassGen): Unit = {
for(annot <- annotations; if shouldEmitAnnotation(annot)) {
val typ = annot.atp
val assocs = annot.assocs
Expand All @@ -323,14 +323,14 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
}

private def emitAssocs(av: asm.AnnotationVisitor, assocs: List[(Name, Object)], bcodeStore: BCodeHelpers)
(innerClasesStore: bcodeStore.BCInnerClassGen) = {
(innerClasesStore: bcodeStore.BCInnerClassGen): Unit = {
for ((name, value) <- assocs)
emitArgument(av, name.mangledString, value.asInstanceOf[Tree], bcodeStore)(innerClasesStore)
av.visitEnd()
}

override def emitAnnotations(mw: asm.MethodVisitor, annotations: List[Annotation], bcodeStore: BCodeHelpers)
(innerClasesStore: bcodeStore.BCInnerClassGen) = {
(innerClasesStore: bcodeStore.BCInnerClassGen): Unit = {
for(annot <- annotations; if shouldEmitAnnotation(annot)) {
val typ = annot.atp
val assocs = annot.assocs
Expand All @@ -340,7 +340,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
}

override def emitAnnotations(fw: asm.FieldVisitor, annotations: List[Annotation], bcodeStore: BCodeHelpers)
(innerClasesStore: bcodeStore.BCInnerClassGen) = {
(innerClasesStore: bcodeStore.BCInnerClassGen): Unit = {
for(annot <- annotations; if shouldEmitAnnotation(annot)) {
val typ = annot.atp
val assocs = annot.assocs
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ object DesugarEnums {
* $values.register(this)
* }
*/
private def enumValueCreator(implicit ctx: Context) = {
private def enumValueCreator(implicit ctx: Context): Tree = {
def param(name: TermName, typ: Type) =
ValDef(name, TypeTree(typ), EmptyTree).withFlags(Param)
val enumTagDef =
Expand Down Expand Up @@ -178,7 +178,7 @@ object DesugarEnums {
val (count, seenKind) = ctx.tree.removeAttachment(EnumCaseCount).getOrElse((0, CaseKind.Class))
val minKind = if (kind < seenKind) kind else seenKind
ctx.tree.pushAttachment(EnumCaseCount, (count + 1, minKind))
val scaffolding =
val scaffolding: List[Tree] =
if (enumClass.typeParams.nonEmpty || kind >= seenKind) Nil
else if (kind == CaseKind.Object) enumScaffolding
else if (seenKind == CaseKind.Object) enumValueCreator :: Nil
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
case _ => false
}

def isOpAssign(tree: Tree) = unsplice(tree) match {
def isOpAssign(tree: Tree): Boolean = unsplice(tree) match {
case Apply(fn, _ :: _) =>
unsplice(fn) match {
case Select(_, name) if name.isOpAssignmentName => true
Expand Down Expand Up @@ -510,7 +510,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
/** Is tree a reference to a mutable variable, or to a potential getter
* that has a setter in the same class?
*/
def isVariableOrGetter(tree: Tree)(implicit ctx: Context) = {
def isVariableOrGetter(tree: Tree)(implicit ctx: Context): Boolean = {
def sym = tree.symbol
def isVar = sym is Mutable
def isGetter =
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {

// ------ Making references ------------------------------------------------------

def prefixIsElidable(tp: NamedType)(implicit ctx: Context) = {
def prefixIsElidable(tp: NamedType)(implicit ctx: Context): Boolean = {
val typeIsElidable = tp.prefix match {
case pre: ThisType =>
tp.isType ||
Expand Down Expand Up @@ -470,7 +470,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
/** A `_' with given type */
def Underscore(tp: Type)(implicit ctx: Context) = untpd.Ident(nme.WILDCARD).withType(tp)

def defaultValue(tpe: Types.Type)(implicit ctx: Context) = {
def defaultValue(tpe: Types.Type)(implicit ctx: Context): Tree = {
val tpw = tpe.widen

if (tpw isRef defn.IntClass) Literal(Constant(0))
Expand Down Expand Up @@ -1008,7 +1008,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
.select(TermRef(receiver.tpe, selected.termSymbol.asTerm))
.appliedToTypes(targs)

def adaptLastArg(lastParam: Tree, expectedType: Type) = {
def adaptLastArg(lastParam: Tree, expectedType: Type): List[Tree] = {
if (isAnnotConstructor && !(lastParam.tpe <:< expectedType)) {
val defn = ctx.definitions
val prefix = args.take(selected.widen.paramInfoss.head.size - 1)
Expand Down Expand Up @@ -1055,7 +1055,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
*
* ~within('tree)
*/
def letBindUnless(level: TreeInfo.PurityLevel, tree: Tree)(within: Tree => Tree)(implicit ctx: Context) = {
def letBindUnless(level: TreeInfo.PurityLevel, tree: Tree)(within: Tree => Tree)(implicit ctx: Context): Tree = {
if (exprPurity(tree) >= level) within(tree)
else {
val vdef = SyntheticValDef(TempResultName.fresh(), tree)
Expand Down