@@ -2,33 +2,20 @@ package dotty.tools
2
2
package dotc
3
3
package ast
4
4
5
- import core .*
6
- import util .Spans .*
7
- import Types .*
8
- import Contexts .*
9
- import Constants .*
10
- import Names .*
11
- import NameOps .*
12
- import Flags .*
13
- import Symbols .*
14
- import StdNames .*
15
- import Trees .*
16
- import ContextOps .*
17
- import Decorators .*
18
- import transform .SymUtils .*
19
- import NameKinds .{DefaultGetterName , EvidenceParamName , UniqueName , WildcardParamName }
20
- import typer .{Checking , Namer }
21
- import util .{Chars , Property , SourceFile , SourcePosition }
22
- import config .Feature .{enabled , migrateTo3 , sourceVersion }
23
- import config .SourceVersion .*
24
-
5
+ import core ._
6
+ import util .Spans ._ , Types ._ , Contexts ._ , Constants ._ , Names ._ , NameOps ._ , Flags ._
7
+ import Symbols ._ , StdNames ._ , Trees ._ , ContextOps ._
8
+ import Decorators ._ , transform .SymUtils ._
9
+ import NameKinds .{UniqueName , EvidenceParamName , DefaultGetterName , WildcardParamName }
10
+ import typer .{Namer , Checking }
11
+ import util .{Property , SourceFile , SourcePosition , Chars }
12
+ import config .Feature .{sourceVersion , migrateTo3 , enabled }
13
+ import config .SourceVersion ._
25
14
import collection .mutable .ListBuffer
26
- import reporting .*
27
-
15
+ import reporting ._
28
16
import annotation .constructorOnly
29
17
import printing .Formatting .hl
30
18
import config .Printers
31
- import dotty .tools .dotc .core .SymDenotations .NoDenotation
32
19
33
20
import scala .annotation .internal .sharable
34
21
@@ -306,51 +293,14 @@ object desugar {
306
293
vparam => toDefParam(vparam, keepAnnotations = true , keepDefault = false )
307
294
}
308
295
309
- def ignoreErrorsAndRun [R ](op : => R ): R =
310
- val savedState = ctx.typerState.snapshot()
311
- val savedReporter = ctx.reporter
312
- ctx.typerState.setReporter(Reporter .NoReporter )
313
- val ret = op
314
- ctx.typerState.setReporter(savedReporter)
315
- ctx.typerState.resetTo(savedState)
316
- ret
317
-
318
- // gets arguments should be considered precise
319
- val paramPrecises : List [Boolean ] =
320
- // indication for the type parameters preciseness
321
- val preciseMap : Map [TypeName , Boolean ] = ignoreErrorsAndRun {
322
- meth.leadingTypeParams.map(t =>
323
- (t.name, t.mods.annotations.exists {a =>
324
- try
325
- val typedAnnot = ctx.typer.typedExpr(a)
326
- if (typedAnnot.denot == NoDenotation ) false
327
- else typedAnnot.symbol.owner == defn.PreciseAnnot
328
- catch case e : Throwable => false
329
- })
330
- ).toMap
331
- }
332
- // mapping type parameters preciseness onto term parameter preciseness
333
- meth.termParamss.view.flatten.map(p => p.tpt).map {
334
- case Ident (n) => preciseMap.getOrElse(n.asTypeName, false )
335
- case _ => false
336
- }.toList
337
-
338
296
def defaultGetters (paramss : List [ParamClause ], n : Int ): List [DefDef ] = paramss match
339
297
case ValDefs (vparam :: vparams) :: paramss1 =>
340
298
def defaultGetter : DefDef =
341
- val (rhs, tpt) =
342
- // if the parameter is precise, then we add explicit return type for the
343
- // definition to keep the precise type after precise typing.
344
- if paramPrecises(n) then
345
- val rhsTyped = withMode(Mode .Precise ){ctx.typer.typedExpr(vparam.rhs)}
346
- (rhsTyped, TypeTree (rhsTyped.tpe))
347
- // otherwise, the desugaring is unchanged from the status quo
348
- else (vparam.rhs, TypeTree ())
349
299
DefDef (
350
300
name = DefaultGetterName (meth.name, n),
351
301
paramss = getterParamss(n),
352
- tpt = tpt ,
353
- rhs = rhs
302
+ tpt = TypeTree () ,
303
+ rhs = vparam. rhs
354
304
)
355
305
.withMods(Modifiers (
356
306
meth.mods.flags & (AccessFlags | Synthetic ) | (vparam.mods.flags & Inline ),
0 commit comments