File tree 6 files changed +20
-19
lines changed
compiler/src/dotty/tools/dotc
tasty/src/dotty/tools/tasty
6 files changed +20
-19
lines changed Original file line number Diff line number Diff line change @@ -1038,8 +1038,6 @@ class Definitions {
1038
1038
@ tu lazy val UncheckedVarianceAnnot : ClassSymbol = requiredClass(" scala.annotation.unchecked.uncheckedVariance" )
1039
1039
@ tu lazy val UncheckedCapturesAnnot : ClassSymbol = requiredClass(" scala.annotation.unchecked.uncheckedCaptures" )
1040
1040
@ tu lazy val VolatileAnnot : ClassSymbol = requiredClass(" scala.volatile" )
1041
- @ tu lazy val WithPureFunsAnnot : ClassSymbol = requiredClass(" scala.annotation.internal.WithPureFuns" )
1042
- @ tu lazy val CaptureCheckedAnnot : ClassSymbol = requiredClass(" scala.annotation.internal.CaptureChecked" )
1043
1041
@ tu lazy val BeanGetterMetaAnnot : ClassSymbol = requiredClass(" scala.annotation.meta.beanGetter" )
1044
1042
@ tu lazy val BeanSetterMetaAnnot : ClassSymbol = requiredClass(" scala.annotation.meta.beanSetter" )
1045
1043
@ tu lazy val FieldMetaAnnot : ClassSymbol = requiredClass(" scala.annotation.meta.field" )
@@ -2004,7 +2002,7 @@ class Definitions {
2004
2002
@ tu lazy val ccExperimental : Set [Symbol ] = Set (
2005
2003
CapsModule , CapsModule .moduleClass, PureClass ,
2006
2004
CapabilityAnnot , RequiresCapabilityAnnot ,
2007
- RetainsAnnot , RetainsByNameAnnot , WithPureFunsAnnot )
2005
+ RetainsAnnot , RetainsByNameAnnot )
2008
2006
2009
2007
// ----- primitive value class machinery ------------------------------------------
2010
2008
Original file line number Diff line number Diff line change @@ -9,16 +9,22 @@ class Attributes private[tasty](
9
9
) {
10
10
def scala2StandardLibrary : Boolean = booleanTags(SCALA2STANDARDLIBRARYattr )
11
11
def explicitNulls : Boolean = booleanTags(EXPLICITNULLSattr )
12
+ def captureChecked : Boolean = booleanTags(CAPTURECHECKEDattr )
13
+ def withPureFuns : Boolean = booleanTags(WITHPUREFUNSattr )
12
14
}
13
15
14
16
object Attributes :
15
17
def apply (
16
18
scala2StandardLibrary : Boolean ,
17
19
explicitNulls : Boolean ,
20
+ captureChecked : Boolean ,
21
+ withPureFuns : Boolean ,
18
22
): Attributes =
19
23
val booleanTags = BitSet .newBuilder
20
24
if scala2StandardLibrary then booleanTags += SCALA2STANDARDLIBRARYattr
21
25
if explicitNulls then booleanTags += EXPLICITNULLSattr
26
+ if captureChecked then booleanTags += CAPTURECHECKEDattr
27
+ if withPureFuns then booleanTags += WITHPUREFUNSattr
22
28
new Attributes (booleanTags.result())
23
29
end apply
24
30
Original file line number Diff line number Diff line change @@ -92,11 +92,9 @@ class TreeUnpickler(reader: TastyReader,
92
92
/** The root owner tree. See `OwnerTree` class definition. Set by `enterTopLevel`. */
93
93
private var ownerTree : OwnerTree = uninitialized
94
94
95
- /** Was unpickled class compiled with pureFunctions? */
96
- private var withPureFuns : Boolean = false
97
-
98
95
/** Was unpickled class compiled with capture checks? */
99
- private var withCaptureChecks : Boolean = false
96
+ private val withCaptureChecks : Boolean =
97
+ attributeUnpicklerOpt.exists(_.attributes.captureChecked)
100
98
101
99
private val unpicklingScala2Library =
102
100
attributeUnpicklerOpt.exists(_.attributes.scala2StandardLibrary)
@@ -655,13 +653,8 @@ class TreeUnpickler(reader: TastyReader,
655
653
}
656
654
registerSym(start, sym)
657
655
if (isClass) {
658
- if sym.owner.is(Package ) then
659
- if annots.exists(_.hasSymbol(defn.CaptureCheckedAnnot )) then
660
- sym.setFlag(CaptureChecked )
661
- withCaptureChecks = true
662
- withPureFuns = true
663
- else if annots.exists(_.hasSymbol(defn.WithPureFunsAnnot )) then
664
- withPureFuns = true
656
+ if sym.owner.is(Package ) && withCaptureChecks then
657
+ sym.setFlag(CaptureChecked )
665
658
sym.completer.withDecls(newScope)
666
659
forkAt(templateStart).indexTemplateParams()(using localContext(sym))
667
660
}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import Contexts.*
7
7
import Decorators .*
8
8
import tasty .*
9
9
import config .Printers .{noPrinter , pickling }
10
+ import config .Feature
10
11
import java .io .PrintStream
11
12
import Periods .*
12
13
import Phases .*
@@ -111,6 +112,8 @@ class Pickler extends Phase {
111
112
val attributes = Attributes (
112
113
scala2StandardLibrary = ctx.settings.YcompileScala2Library .value,
113
114
explicitNulls = ctx.settings.YexplicitNulls .value,
115
+ captureChecked = Feature .ccEnabled,
116
+ withPureFuns = Feature .pureFunsEnabled,
114
117
)
115
118
AttributePickler .pickleAttributes(attributes, pickler, scratch.attributeBuffer)
116
119
Original file line number Diff line number Diff line change @@ -423,11 +423,6 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
423
423
val reference = ctx.settings.sourceroot.value
424
424
val relativePath = util.SourceFile .relativePath(ctx.compilationUnit.source, reference)
425
425
sym.addAnnotation(Annotation .makeSourceFile(relativePath, tree.span))
426
- if sym != defn.WithPureFunsAnnot && sym != defn.CaptureCheckedAnnot then
427
- if Feature .ccEnabled then
428
- sym.addAnnotation(Annotation (defn.CaptureCheckedAnnot , tree.span))
429
- else if Feature .pureFunsEnabled then
430
- sym.addAnnotation(Annotation (defn.WithPureFunsAnnot , tree.span))
431
426
else
432
427
if ! sym.is(Param ) && ! sym.owner.isOneOf(AbstractOrTrait ) then
433
428
Checking .checkGoodBounds(tree.symbol)
Original file line number Diff line number Diff line change @@ -273,6 +273,8 @@ Standard Section: "Attributes" Attribute*
273
273
```none
274
274
Attribute = SCALA2STANDARDLIBRARYattr
275
275
EXPLICITNULLSattr
276
+ CAPTURECHECKEDattr
277
+ WITHPUREFUNSattr
276
278
```
277
279
278
280
**************************************************************************************/
@@ -611,6 +613,8 @@ object TastyFormat {
611
613
612
614
final val SCALA2STANDARDLIBRARYattr = 1
613
615
final val EXPLICITNULLSattr = 2
616
+ final val CAPTURECHECKEDattr = 3
617
+ final val WITHPUREFUNSattr = 4
614
618
615
619
/** Useful for debugging */
616
620
def isLegalTag (tag : Int ): Boolean =
@@ -830,6 +834,8 @@ object TastyFormat {
830
834
def attributeTagToString (tag : Int ): String = tag match {
831
835
case SCALA2STANDARDLIBRARYattr => " SCALA2STANDARDLIBRARYattr"
832
836
case EXPLICITNULLSattr => " EXPLICITNULLSattr"
837
+ case CAPTURECHECKEDattr => " CAPTURECHECKEDattr"
838
+ case WITHPUREFUNSattr => " WITHPUREFUNSattr"
833
839
}
834
840
835
841
/** @return If non-negative, the number of leading references (represented as nats) of a length/trees entry.
You can’t perform that action at this time.
0 commit comments