Skip to content

Commit 36e74c5

Browse files
committed
wip
1 parent 8950d9a commit 36e74c5

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import dotty.tools.dotc.core.tasty.{ PositionPickler, TastyPickler, TastyPrinter
1616
import dotty.tools.dotc.core.tasty.TreeUnpickler.UnpickleMode
1717
import dotty.tools.dotc.quoted.QuoteContext
1818
import dotty.tools.dotc.tastyreflect.{ReflectionImpl, TastyTreeExpr, TreeType}
19+
import dotty.tools.dotc.util.Spans.NoSpan
1920

2021
import dotty.tools.tasty.TastyString
2122

@@ -112,38 +113,28 @@ object PickledQuotes {
112113
// typeSpliceMap = splicedTypes.toMap
113114
// transform(expr1)
114115
case Hole(isType, idx, args) =>
116+
assert(!isType)
115117
val splice = splices(idx)
116118
def wrap(arg: Tree) =
117119
if (arg.isTerm) (qctx: scala.quoted.QuoteContext) ?=> new TastyTreeExpr(arg, QuoteContext.scopeId)
118120
else new TreeType(arg, QuoteContext.scopeId)
119121
val reifiedArgs = args.map(wrap)
120-
val filled = if (isType) {
121-
???
122-
val quotedType = splice.asInstanceOf[Seq[Any] => quoted.Type[?]](reifiedArgs)
123-
PickledQuotes.quotedTypeToTree(quotedType)
124-
}
125-
else {
126-
val splice1 = splice.asInstanceOf[Seq[Any] => scala.quoted.QuoteContext ?=> quoted.Expr[?]]
127-
val quotedExpr = splice1(reifiedArgs)(using dotty.tools.dotc.quoted.QuoteContext())
128-
PickledQuotes.quotedExprToTree(quotedExpr)
129-
}
122+
123+
val splice1 = splice.asInstanceOf[Seq[Any] => scala.quoted.QuoteContext ?=> quoted.Expr[?]]
124+
val quotedExpr = splice1(reifiedArgs)(using dotty.tools.dotc.quoted.QuoteContext())
125+
val filled = PickledQuotes.quotedExprToTree(quotedExpr)
126+
130127
// We need to make sure a hole is created with the source file of the surrounding context, even if
131-
// it filled with contents a different source file. Otherwise nodes contqaining holes might end
132-
// up without a position. PositionPickler makes sure that holes always get spans assigned,
133-
// so we can just return the filler tree with the new source and no span here.
128+
// it filled with contents a different source file.
134129
if (filled.source == ctx.source) filled
135-
else {
136-
val filled1 = filled.cloneIn(ctx.source)
137-
// filled1.span = NoSpan
138-
filled1
139-
}
130+
else filled.cloneIn(ctx.source)
140131

141132
// super.transform(tree).withType(dealiasTypeTags(tree.tpe))
142133
case tree =>
143134
super.transform(tree).withType(spliceTypes(tree.tpe))
144135
}
145136
}
146-
val evaluatedExpansion = evaluateHoles.transform(expnasion1)
137+
val evaluatedExpansion = evaluateHoles.transform(expnasion1)(inlineContext(call))
147138
cpy.Inlined(unpickled)(call, Nil, evaluatedExpansion)
148139
else
149140
val forceAndCleanArtefacts = new TreeMap {

tests/neg-macros/delegate-match-1.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
6 | f // error
44
| ^
55
| AmbiguousImplicits
6-
| both value a1 in class Test1 and value a2 in class Test1 match type A
6+
| both value a1 in class Test1 and value a2 in class Test1 match type <empty>.this.A
77
| This location contains code that was inlined from Test_2.scala:6

tests/neg-macros/delegate-match-2.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
5 | f // error
44
| ^
55
| DivergingImplicit
6-
| method a1 in class Test produces a diverging implicit search when trying to match type A
6+
| method a1 in class Test produces a diverging implicit search when trying to match type <empty>.this.A
77
| This location contains code that was inlined from Test_2.scala:5

tests/neg-macros/delegate-match-3.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
3 | f // error
44
| ^
55
| NoMatchingImplicits
6-
| no implicit values were found that match type A
6+
| no implicit values were found that match type <empty>.this.A
77
| This location contains code that was inlined from Test_2.scala:3

0 commit comments

Comments
 (0)