Skip to content

Commit 8c9a3f7

Browse files
committed
Merge pull request #1205 from dotty-staging/method-check
Ycheck that all methods have method type
2 parents 16b90f7 + 371e8a7 commit 8c9a3f7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ class TreeChecker extends Phase with SymTransformer {
311311
tree
312312
}
313313

314+
/** Check that all methods have MethodicType */
315+
def isMethodType(pt: Type)(implicit ctx: Context): Boolean = pt match {
316+
case at: AnnotatedType => isMethodType(at.tpe)
317+
case _: MethodicType => true // MethodType, ExprType, PolyType
318+
case _ => false
319+
}
320+
314321
override def typedIdent(tree: untpd.Ident, pt: Type)(implicit ctx: Context): Tree = {
315322
assert(tree.isTerm || !ctx.isAfterTyper, tree.show + " at " + ctx.phase)
316323
assert(tree.isType || !needsSelect(tree.tpe), i"bad type ${tree.tpe} for $tree # ${tree.uniqueId}")
@@ -369,7 +376,9 @@ class TreeChecker extends Phase with SymTransformer {
369376
withDefinedSyms(ddef.tparams) {
370377
withDefinedSymss(ddef.vparamss) {
371378
if (!sym.isClassConstructor) assert(isValidJVMMethodName(sym.name), s"${sym.fullName} name is invalid on jvm")
372-
super.typedDefDef(ddef, sym)
379+
val tpdTree = super.typedDefDef(ddef, sym)
380+
assert(isMethodType(sym.info), i"wrong type, expect a method type for ${sym.fullName}, but found: ${sym.info}")
381+
tpdTree
373382
}
374383
}
375384

0 commit comments

Comments
 (0)