diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala index 2faf8d28f404..550f3243df6e 100644 --- a/compiler/src/dotty/tools/dotc/core/NameOps.scala +++ b/compiler/src/dotty/tools/dotc/core/NameOps.scala @@ -270,7 +270,7 @@ object NameOps { original.fieldName } else getterName.fieldName - else FieldName(name) + else FieldName(name.toSimpleName) def stripScala2LocalSuffix: TermName = if (name.isScala2LocalSuffix) name.asSimpleName.dropRight(1) else name diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 75b29cd4d78f..2e7822053056 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -578,7 +578,7 @@ class TreeUnpickler(reader: TastyReader, else ctx.newSymbol(ctx.owner, name, flags, completer, privateWithin, coord) } - sym.annotations = annotFns.map(_(sym)) + sym.annotations = annotFns.map(_(sym.owner)) if sym.isOpaqueAlias then sym.setFlag(Deferred) val isScala2MacroDefinedInScala3 = flags.is(Macro, butNot = Inline) && flags.is(Erased) ctx.owner match { diff --git a/compiler/src/dotty/tools/dotc/transform/Constructors.scala b/compiler/src/dotty/tools/dotc/transform/Constructors.scala index 5e63f93e5d10..ac241b7e45ff 100644 --- a/compiler/src/dotty/tools/dotc/transform/Constructors.scala +++ b/compiler/src/dotty/tools/dotc/transform/Constructors.scala @@ -251,9 +251,9 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase = // Drop accessors that are not retained from class scope if (dropped.nonEmpty) { val clsInfo = cls.classInfo - cls.copy( - info = clsInfo.derivedClassInfo( - decls = clsInfo.decls.filteredScope(!dropped.contains(_)))) + val decls = clsInfo.decls.filteredScope(!dropped.contains(_)) + val clsInfo2 = clsInfo.derivedClassInfo(decls = decls) + cls.copySymDenotation(info = clsInfo2).installAfter(thisPhase) // TODO: this happens to work only because Constructors is the last phase in group } diff --git a/compiler/src/dotty/tools/dotc/transform/MixinOps.scala b/compiler/src/dotty/tools/dotc/transform/MixinOps.scala index 784a21ba248d..16a767cd1932 100644 --- a/compiler/src/dotty/tools/dotc/transform/MixinOps.scala +++ b/compiler/src/dotty/tools/dotc/transform/MixinOps.scala @@ -22,7 +22,7 @@ class MixinOps(cls: ClassSymbol, thisPhase: DenotTransformer)(implicit ctx: Cont val res = member.copy( owner = cls, name = member.name.stripScala2LocalSuffix, - flags = member.flags &~ Deferred | Synthetic | extraFlags, + flags = member.flags &~ Deferred &~ Module | Synthetic | extraFlags, info = cls.thisType.memberInfo(member)).enteredAfter(thisPhase).asTerm res.addAnnotations(member.annotations.filter(_.symbol != defn.TailrecAnnot)) res diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index 7baf74ec90c9..7edbeb81201b 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -270,7 +270,7 @@ class ReifyQuotes extends MacroTransform { val tpe = MethodType(defn.SeqType.appliedTo(defn.AnyType) :: Nil, tree.tpe.widen) val meth = ctx.newSymbol(lambdaOwner, UniqueName.fresh(nme.ANON_FUN), Synthetic | Method, tpe) - Closure(meth, tss => body(tss.head.head)(ctx.withOwner(meth)).changeOwner(ctx.owner, meth)).withSpan(tree.span) + Closure(meth, tss => body(tss.head.head)(ctx.withOwner(meth)).changeNonLocalOwners(meth)).withSpan(tree.span) } private def transformWithCapturer(tree: Tree)(capturer: mutable.Map[Symbol, Tree] => Tree => Tree)(implicit ctx: Context): Tree = { diff --git a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala index fadf853e77ad..a52d8ef1ed9a 100644 --- a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -426,18 +426,19 @@ class TreeChecker extends Phase with SymTransformer { checkOwner(impl) checkOwner(impl.constr) - def isNonMagicalMethod(x: Symbol) = - x.is(Method) && - !x.isValueClassConvertMethod && - !(x.is(Macro) && ctx.phase.refChecked) && - !x.name.is(DocArtifactName) + def isNonMagicalMember(x: Symbol) = + !x.isValueClassConvertMethod && + !x.name.is(DocArtifactName) - val symbolsNotDefined = cls.classInfo.decls.toList.toSet.filter(isNonMagicalMethod) -- impl.body.map(_.symbol) - constr.symbol + val decls = cls.classInfo.decls.toList.toSet.filter(isNonMagicalMember) + val defined = impl.body.map(_.symbol) + + val symbolsNotDefined = decls -- defined - constr.symbol assert(symbolsNotDefined.isEmpty, - i" $cls tree does not define methods: ${symbolsNotDefined.toList}%, %\n" + - i"expected: ${cls.classInfo.decls.toList.toSet.filter(isNonMagicalMethod)}%, %\n" + - i"defined: ${impl.body.map(_.symbol)}%, %") + i" $cls tree does not define members: ${symbolsNotDefined.toList}%, %\n" + + i"expected: ${decls.toList}%, %\n" + + i"defined: ${defined}%, %") super.typedClassDef(cdef, cls) } diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 3802bea63f2c..a47937f33e98 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -859,7 +859,7 @@ class Namer { typer: Typer => if (cls eq sym) ctx.error("An annotation class cannot be annotated with iself", annotTree.sourcePos) else { - val ann = Annotation.deferred(cls)(typedAnnotation(annotTree)) + val ann = Annotation.deferred(cls)(typedAheadAnnotation(annotTree)(using annotCtx)) sym.addAnnotation(ann) } }