Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Aug 5, 2021
1 parent dc7be10 commit 484ad44
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
def Throw(expr: Tree)(using Context): Tree =
ref(defn.throwMethod).appliedTo(expr)

def Hole(isTerm: Boolean, idx: Int, args: List[Tree], content: Tree, tpt: Tree)(using Context): Hole =
ta.assignType(untpd.Hole(isTerm, idx, args, content, tpt), tpt)

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

def prefixIsElidable(tp: NamedType)(using Context): Boolean = {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/Splicing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Splicing extends MacroTransform {
case Some (hole) => cpy.Hole(hole)(content = EmptyTree)
case None =>
holeIdx += 1
val hole = Hole(false, holeIdx, Nil, ref(qual), TypeTree(tp)).withType(tp).asInstanceOf[Hole]
val hole = tpd.Hole(false, holeIdx, Nil, ref(qual), TypeTree(tp))
typeHoles.put(qual.symbol, hole)
hole
cpy.TypeDef(tree)(rhs = hole)
Expand Down Expand Up @@ -162,7 +162,7 @@ class Splicing extends MacroTransform {
val fnType = defn.FunctionType(bindings.size, isContextual = false).appliedTo(bindingsTypes :+ newTree.tpe)
val closure = Block(ddef :: Nil, Closure(Nil, ref(meth), TypeTree(fnType)))
holeIdx += 1
Hole(true, holeIdx, refs, closure, TypeTree(tpe)).withType(tpe)
tpd.Hole(true, holeIdx, refs, closure, TypeTree(tpe))

override def transform(tree: tpd.Tree)(using Context): tpd.Tree =
tree match
Expand Down
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ trait TypeAssigner {

def assignType(tree: untpd.PackageDef, pid: Tree)(using Context): PackageDef =
tree.withType(pid.symbol.termRef)

def assignType(tree: untpd.Hole, tpt: Tree)(using Context): Hole =
tree.withType(tpt.tpe)

}


Expand Down

0 comments on commit 484ad44

Please sign in to comment.