Skip to content

Commit 1aeac76

Browse files
committed
Move check to constructor
1 parent 6de1a23 commit 1aeac76

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
4040
def Super(qual: Tree, mixName: TypeName, inConstrCall: Boolean, mixinClass: Symbol = NoSymbol)(implicit ctx: Context): Super =
4141
Super(qual, if (mixName.isEmpty) untpd.EmptyTypeIdent else untpd.Ident(mixName), inConstrCall, mixinClass)
4242

43-
def Apply(fn: Tree, args: List[Tree])(implicit ctx: Context): Apply =
43+
def Apply(fn: Tree, args: List[Tree])(implicit ctx: Context): Apply = {
44+
assert(!fn.isInstanceOf[Block])
45+
assert(!fn.isInstanceOf[If])
4446
ta.assignType(untpd.Apply(fn, args), fn, args)
47+
}
4548

4649
def TypeApply(fn: Tree, args: List[Tree])(implicit ctx: Context): TypeApply =
4750
ta.assignType(untpd.TypeApply(fn, args), fn, args)
@@ -181,8 +184,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
181184
def Alternative(trees: List[Tree])(implicit ctx: Context): Alternative =
182185
ta.assignType(untpd.Alternative(trees), trees)
183186

184-
def UnApply(fun: Tree, implicits: List[Tree], patterns: List[Tree], proto: Type)(implicit ctx: Context): UnApply =
187+
def UnApply(fun: Tree, implicits: List[Tree], patterns: List[Tree], proto: Type)(implicit ctx: Context): UnApply = {
188+
assert(!fun.isInstanceOf[Block])
185189
ta.assignType(untpd.UnApply(fun, implicits, patterns), proto)
190+
}
186191

187192
def ValDef(sym: TermSymbol, rhs: LazyTree = EmptyTree)(implicit ctx: Context): ValDef =
188193
ta.assignType(untpd.ValDef(sym.name, TypeTree(sym.info), rhs), sym)

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ class TreeChecker extends Phase with SymTransformer {
269269
case _ if tree.isType =>
270270
promote(tree)
271271
case _ =>
272-
checkApplyNonBlock(tree)
273272
val tree1 = super.typedUnadapted(tree, pt, locked)
274273
def isSubType(tp1: Type, tp2: Type) =
275274
(tp1 eq tp2) || // accept NoType / NoType
@@ -291,12 +290,6 @@ class TreeChecker extends Phase with SymTransformer {
291290
res
292291
}
293292

294-
def checkApplyNonBlock(tree: untpd.Tree)(implicit ctx: Context) = tree match {
295-
case tree: untpd.Apply => assert(!tree.fun.isInstanceOf[untpd.Block])
296-
case tree: untpd.UnApply => assert(!tree.fun.isInstanceOf[untpd.Block])
297-
case _ =>
298-
}
299-
300293
def checkNotRepeated(tree: Tree)(implicit ctx: Context): tree.type = {
301294
def allowedRepeated = tree.tpe.widen.isRepeatedParam
302295

0 commit comments

Comments
 (0)