Skip to content

Commit a47edfa

Browse files
committed
Move check to constructor
1 parent 386b87f commit a47edfa

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
@@ -41,8 +41,11 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
4141
def Super(qual: Tree, mixName: TypeName, inConstrCall: Boolean, mixinClass: Symbol = NoSymbol)(implicit ctx: Context): Super =
4242
Super(qual, if (mixName.isEmpty) untpd.EmptyTypeIdent else untpd.Ident(mixName), inConstrCall, mixinClass)
4343

44-
def Apply(fn: Tree, args: List[Tree])(implicit ctx: Context): Apply =
44+
def Apply(fn: Tree, args: List[Tree])(implicit ctx: Context): Apply = {
45+
assert(!fn.isInstanceOf[Block])
46+
assert(!fn.isInstanceOf[If])
4547
ta.assignType(untpd.Apply(fn, args), fn, args)
48+
}
4649

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

185-
def UnApply(fun: Tree, implicits: List[Tree], patterns: List[Tree], proto: Type)(implicit ctx: Context): UnApply =
188+
def UnApply(fun: Tree, implicits: List[Tree], patterns: List[Tree], proto: Type)(implicit ctx: Context): UnApply = {
189+
assert(!fun.isInstanceOf[Block])
186190
ta.assignType(untpd.UnApply(fun, implicits, patterns), proto)
191+
}
187192

188193
def ValDef(sym: TermSymbol, rhs: LazyTree = EmptyTree)(implicit ctx: Context): ValDef =
189194
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
@@ -279,7 +279,6 @@ class TreeChecker extends Phase with SymTransformer {
279279
case _ if tree.isType =>
280280
promote(tree)
281281
case _ =>
282-
checkApplyNonBlock(tree)
283282
val tree1 = super.typedUnadapted(tree, pt, locked)
284283
def isSubType(tp1: Type, tp2: Type) =
285284
(tp1 eq tp2) || // accept NoType / NoType
@@ -301,12 +300,6 @@ class TreeChecker extends Phase with SymTransformer {
301300
res
302301
}
303302

304-
def checkApplyNonBlock(tree: untpd.Tree)(implicit ctx: Context) = tree match {
305-
case tree: untpd.Apply => assert(!tree.fun.isInstanceOf[untpd.Block])
306-
case tree: untpd.UnApply => assert(!tree.fun.isInstanceOf[untpd.Block])
307-
case _ =>
308-
}
309-
310303
def checkNotRepeated(tree: Tree)(implicit ctx: Context): tree.type = {
311304
def allowedRepeated = tree.tpe.widen.isRepeatedParam
312305

0 commit comments

Comments
 (0)