@@ -407,8 +407,8 @@ class TreeUnpickler[Tasty <: TastyUniverse](
407
407
if (isClass && flags.is(Trait )) flags |= Abstract
408
408
if (tag === DEFDEF ) flags |= Method
409
409
if (tag === VALDEF ) {
410
+ if (flags.is(Inline ) || owner.is(Trait )) flags |= FieldAccessor
410
411
if (flags.not(Mutable )) flags |= Stable
411
- if (owner.is(Trait )) flags |= FieldAccessor
412
412
}
413
413
if (tastyFlags.is(Object ))
414
414
flags = flags | (if (tag === VALDEF ) ObjectCreationFlags else ObjectClassCreationFlags )
@@ -521,16 +521,11 @@ class TreeUnpickler[Tasty <: TastyUniverse](
521
521
sym.setAnnotations(annotFns.map(_(sym)))
522
522
ctx.owner match {
523
523
case cls if cls.isClass && canEnterInClass =>
524
+ if (ctx.mode.is(IndexBody ) && ctx.isLatentCandidate(sym))
525
+ ctx.registerLatent(sym)
524
526
val decl = if (flags.is(Object ) && isClass) sym.sourceObject else sym
525
- val decls = cls.rawInfo.decls
526
- if (allowsOverload(decl)) {
527
- if (ctx.canEnterOverload(decl)) {
528
- decls.enter(decl)
529
- }
530
- }
531
- else {
532
- decls.enterIfNew(decl)
533
- }
527
+ if (ctx.canEnter(decl))
528
+ ctx.enter(cls, decl)
534
529
case _ =>
535
530
}
536
531
registerSym(start, sym)
@@ -581,6 +576,7 @@ class TreeUnpickler[Tasty <: TastyUniverse](
581
576
case STATIC => addFlag(Static )
582
577
case OBJECT => addFlag(Object )
583
578
case TRAIT => addFlag(Trait )
579
+ case SUPERTRAIT => addFlag(SuperTrait )
584
580
case ENUM => addFlag(Enum )
585
581
case LOCAL => addFlag(Local )
586
582
case SYNTHETIC => addFlag(Synthetic )
@@ -721,11 +717,12 @@ class TreeUnpickler[Tasty <: TastyUniverse](
721
717
val localCtx = ctx.withOwner(sym)
722
718
tag match {
723
719
case DEFDEF =>
724
- val unsupported = completer.tastyFlagSet &~ (Extension | Inline | Macro | Exported )
720
+ val unsupported = completer.tastyFlagSet &~ (Extension | Inline | Exported | Erased )
725
721
unsupportedWhen(unsupported.hasFlags, s " flags on $sym: ${showTasty(unsupported)}" )
726
722
if (completer.tastyFlagSet.is(Extension )) ctx.log(s " $tname is a Scala 3 extension method. " )
727
- unsupportedWhen(completer.tastyFlagSet.is(Inline , butNot = Macro ), s " inline $sym" )
728
- unsupportedWhen(completer.tastyFlagSet.is(Inline | Macro ), s " macro $sym" )
723
+ unsupportedWhen(completer.tastyFlagSet.is(Inline ), s " ${if (sym.is(Macro )) " " else " inline " }$sym" )
724
+ val isMacroDef = completer.tastyFlagSet.is(Erased ) && sym.is(Macro )
725
+ unsupportedWhen(completer.tastyFlagSet.is(Erased ) && ! isMacroDef, s " erased $sym" )
729
726
val isCtor = sym.isClassConstructor
730
727
val typeParams = {
731
728
if (isCtor) {
@@ -738,6 +735,10 @@ class TreeUnpickler[Tasty <: TastyUniverse](
738
735
}
739
736
val vparamss = readParamss(localCtx)
740
737
val tpt = readTpt()(localCtx)
738
+ if (isMacroDef) {
739
+ val impl = tpd.Macro (readTerm()(ctx.addMode(ReadMacro )))
740
+ sym.addAnnotation(symbolTable.AnnotationInfo (symbolTable.definitions.MacroTastyImplAnnotation .tpe, List (impl), Nil ))
741
+ }
741
742
val valueParamss = normalizeIfConstructor(vparamss.map(_.map(symFromNoCycle)), isCtor)
742
743
val resType = effectiveResultType(sym, typeParams, tpt.tpe)
743
744
ctx.setInfo(sym, defn.DefDefType (if (isCtor) Nil else typeParams, valueParamss, resType))
@@ -746,14 +747,16 @@ class TreeUnpickler[Tasty <: TastyUniverse](
746
747
val unsupported = completer.tastyFlagSet &~ (Inline | Enum | Extension | Exported )
747
748
unsupportedWhen(unsupported.hasFlags, s " flags on $sym: ${showTasty(unsupported)}" )
748
749
val tpe = readTpt()(localCtx).tpe
749
- if (isInline) unsupportedWhen(! isConstantType(tpe), s " inline val ${sym.nameString} with non-constant type $tpe" )
750
+ val isConstant = isConstantType(tpe)
751
+ if (isInline) unsupportedWhen(! isConstant, s " inline val ${sym.nameString} with non-constant type $tpe" )
750
752
ctx.setInfo(sym,
751
753
if (completer.tastyFlagSet.is(Enum )) defn.ConstantType (tpd.Constant ((sym, tpe))).tap(_.typeSymbol.set(Final ))
754
+ else if (isInline && isConstant) defn.InlineExprType (tpe)
752
755
else if (sym.isMethod) defn.ExprType (tpe)
753
756
else tpe
754
757
)
755
758
case TYPEDEF | TYPEPARAM =>
756
- val unsupported = completer.tastyFlagSet &~ (Enum | Open | Opaque | Exported )
759
+ val unsupported = completer.tastyFlagSet &~ (Enum | Open | Opaque | Exported | SuperTrait )
757
760
unsupportedWhen(unsupported.hasFlags, s " flags on $sym: ${showTasty(unsupported)}" )
758
761
if (sym.isClass) {
759
762
sym.owner.ensureCompleted()
@@ -777,7 +780,7 @@ class TreeUnpickler[Tasty <: TastyUniverse](
777
780
if (nothingButMods(end) && sym.not(ParamSetter )) tpt.tpe
778
781
else defn.ExprType (tpt.tpe))
779
782
}
780
- ctx.log(s " $symAddr typeOf( ${showSym(sym)}) =:= ${if (sym.isType) sym.tpe else sym.info}; owned by ${location(sym.owner)}" )
783
+ ctx.log(s " $symAddr @@@ ${showSym(sym)}.tpe =:= '[ ${if (sym.isType) sym.tpe else sym.info}] ; owned by ${location(sym.owner)}" )
781
784
goto(end)
782
785
NoCycle (at = symAddr)
783
786
} catch ctx.onCompletionError(sym)
@@ -800,8 +803,10 @@ class TreeUnpickler[Tasty <: TastyUniverse](
800
803
// ** MEMBERS **
801
804
ctx.log(s " $symAddr Template: indexing members of $cls: " )
802
805
val bodyIndexer = fork
806
+ val bodyCtx = ctx.addMode(IndexBody )
803
807
while (bodyIndexer.reader.nextByte != DEFDEF ) bodyIndexer.skipTree() // skip until primary ctor
804
- bodyIndexer.indexStats(end)
808
+ bodyIndexer.indexStats(end)(bodyCtx)
809
+ bodyCtx.enterLatents()
805
810
806
811
// ** PARENTS **
807
812
ctx.log(s " $symAddr Template: adding parents of $cls: " )
@@ -897,10 +902,9 @@ class TreeUnpickler[Tasty <: TastyUniverse](
897
902
def completeSelectType (name : TastyName .TypeName )(implicit ctx : Context ): Tree = completeSelect(name)
898
903
899
904
def completeSelect (name : TastyName )(implicit ctx : Context ): Tree = {
900
- val localCtx = ctx.selectionCtx(name)
901
- val qual = readTerm()(localCtx)
902
- val qualType = qual.tpe
903
- tpd.Select (qual, name)(namedMemberOfPrefix(qualType, name)(localCtx))
905
+ val qual = readTerm()
906
+ val qualType = qual.tpe // TODO [tasty]: qual.tpe.widenIfUnstable
907
+ tpd.Select (qual, name)(namedMemberOfPrefix(qualType, name))
904
908
}
905
909
906
910
def completeSelectionParent (name : TastyName )(implicit ctx : Context ): Tree = {
@@ -931,6 +935,19 @@ class TreeUnpickler[Tasty <: TastyUniverse](
931
935
val end = readEnd()
932
936
val result =
933
937
(tag : @ switch) match {
938
+ case SELECTin =>
939
+ val sname = readTastyName()
940
+ val qual = readTerm()
941
+ if (inParentCtor) {
942
+ assert(sname.isSignedConstructor, s " Parent of ${ctx.owner} is not a constructor. " )
943
+ skipTree()
944
+ qual
945
+ }
946
+ else {
947
+ val owner = readType()
948
+ val qualTpe = qual.tpe // qual.tpe.widenIfUnstable
949
+ tpd.Select (qual, sname)(namedMemberOfTypeWithPrefix(qualTpe, owner, sname))
950
+ }
934
951
case SUPER =>
935
952
val qual = readTerm()
936
953
val (mixId, mixTpe) = ifBefore(end)(readQualId(), (untpd.EmptyTypeIdent , defn.NoType ))
@@ -975,7 +992,7 @@ class TreeUnpickler[Tasty <: TastyUniverse](
975
992
if (alias != untpd.EmptyTree ) alias // only for opaque type alias
976
993
else tpd.TypeBoundsTree (lo, hi)
977
994
case BLOCK =>
978
- if (inParentCtor) {
995
+ if (inParentCtor | ctx.mode.is( ReadMacro ) ) {
979
996
val exprReader = fork
980
997
skipTree()
981
998
until(end)(skipTree()) // val stats = readStats(ctx.owner, end)
0 commit comments