Skip to content

Commit 43f396c

Browse files
committed
simplified implicit class support
1 parent 50e4e75 commit 43f396c

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -256,17 +256,6 @@ object desugar {
256256
evidenceParamBuf.toList)
257257
end elimContextBounds
258258

259-
//TODO: typing causes problems, so using this hack ATM that cannot handle all cases of applying @precise
260-
def isPreciseAnnot(tree: untpd.Tree)(using Context): Boolean =
261-
tree match
262-
case Apply(Select(New(Ident(n)), _), Nil) => n == defn.PreciseAnnot.name
263-
// inContext(ctx.fresh.setReporter(Reporter.NoReporter).setExploreTyperState()) {
264-
// try
265-
// ctx.typer.typedExpr(clsSel).tpe.classSymbol == defn.PreciseAnnot
266-
// catch case _ : Throwable => false
267-
// }
268-
case _ => false
269-
270259
def addDefaultGetters(meth: DefDef)(using Context): Tree =
271260

272261
/** The longest prefix of parameter lists in paramss whose total number of
@@ -392,10 +381,9 @@ object desugar {
392381

393382
@sharable private val synthetic = Modifiers(Synthetic)
394383

395-
private def toDefParam(tparam: TypeDef, keepAnnotations: Boolean)(using Context): TypeDef = {
384+
private def toDefParam(tparam: TypeDef, keepAnnotations: Boolean): TypeDef = {
396385
var mods = tparam.rawMods
397-
val onlyPreciseAnnot = mods.annotations.filter(isPreciseAnnot)
398-
if (!keepAnnotations) mods = mods.withAnnotations(onlyPreciseAnnot)
386+
if (!keepAnnotations) mods = mods.withAnnotations(Nil)
399387
tparam.withMods(mods & EmptyFlags | Param)
400388
}
401389
private def toDefParam(vparam: ValDef, keepAnnotations: Boolean, keepDefault: Boolean): ValDef = {
@@ -486,7 +474,8 @@ object desugar {
486474
// Annotations on class _type_ parameters are set on the derived parameters
487475
// but not on the constructor parameters. The reverse is true for
488476
// annotations on class _value_ parameters.
489-
val constrTparams = impliedTparams.map(toDefParam(_, keepAnnotations = false))
477+
val keepAnnotations = cdef.mods.flags.is(Flags.Implicit)
478+
val constrTparams = impliedTparams.map(toDefParam(_, keepAnnotations = keepAnnotations))
490479
val constrVparamss =
491480
if (originalVparamss.isEmpty) { // ensure parameter list is non-empty
492481
if (isCaseClass)

0 commit comments

Comments
 (0)