Skip to content

Commit 8e7d60d

Browse files
authored
Minimize Tree.symbol calls (#26914)
Encouraged by #26863... Cuts `tree.symbol` calls when compiling `tests/pos/tuple-filter.scala` (no compiler options) from 12025 to 7091. (I've left the commit with the measurement harness + its revert so you can see how I computed this) <details> <summary>Calls in main (click to expand)</summary> <pre> Total: 12025 3168: dotty.tools.dotc.ast.tpd$TreeOps$.setDefTree$extension(tpd.scala:1198) 3167: dotty.tools.dotc.ast.tpd$TreeOps$.ensureHasSym$extension(tpd.scala:1214) 1395: dotty.tools.dotc.core.SymDenotations$.setParamssFromDefs$$anonfun$1$$anonfun$1(SymDenotations.scala:329) 1395: dotty.tools.dotc.core.tasty.TreeUnpickler.dotty$tools$dotc$core$tasty$TreeUnpickler$TreeReader$$_$_$_$$anonfun$17(TreeUnpickler.scala:954) 264: dotty.tools.dotc.core.Annotations$.annotClass(Annotations.scala:19) 235: dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.processPackage(TreeUnpickler.scala:858) 165: dotty.tools.dotc.ast.tpd$.localOwner(tpd.scala:647) 92: dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:256) 91: dotty.tools.dotc.typer.ConstFold$.apply(ConstFold.scala:60) 75: dotty.tools.dotc.inlines.Inlines$.needsInlining(Inlines.scala:123) 64: dotty.tools.dotc.transform.Dependencies.process(Dependencies.scala:177) 59: dotty.tools.dotc.typer.Typer.adaptNoArgsOther$1(Typer.scala:4934) 57: dotty.tools.dotc.typer.Checking$.checkAppliedType(Checking.scala:126) 55: dotty.tools.dotc.typer.Typer.adaptNoArgsOther$1(Typer.scala:4943) 48: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.registerNeedsInlining(PostTyper.scala:814) 42: dotty.tools.dotc.typer.TypeAssigner.assignType$$anonfun$6(TypeAssigner.scala:552) 42: dotty.tools.dotc.typer.TypeAssigner.$anonfun$13(TypeAssigner.scala:548) 35: dotty.tools.dotc.core.tasty.TreeUnpickler.dotty$tools$dotc$core$tasty$TreeUnpickler$TreeReader$$_$constructorApply$1(TreeUnpickler.scala:1418) 35: dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTree$1(TreeUnpickler.scala:1534) 32: dotty.tools.dotc.ast.TypedTreeInfo.localSyms$$anonfun$1(TreeInfo.scala:1016) 32: dotty.tools.dotc.transform.InterceptedMethods.transformRefTree(InterceptedMethods.scala:46) 31: dotty.tools.dotc.typer.VarianceChecker.dotty$tools$dotc$typer$VarianceChecker$Traverser$$$_$sym$2(VarianceChecker.scala:212) 30: dotty.tools.dotc.core.tasty.TreePickler.preRegister(TreePickler.scala:85) 29: dotty.tools.dotc.transform.CheckUnused$.withOriginalName(CheckUnused.scala:551) 29: dotty.tools.dotc.typer.ReTyper.retrieveSym(ReTyper.scala:147) 28: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.checkUsableAsValue(PostTyper.scala:391) 28: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.checkUsableAsValue(PostTyper.scala:386) 27: dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:268) 24: dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:272) 23: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:581) 21: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.checkNotPackage(PostTyper.scala:407) 19: dotty.tools.dotc.transform.CrossVersionChecks.transformIdent(CrossVersionChecks.scala:132) 18: dotty.tools.dotc.ast.TypedTreeInfo.refPurity(TreeInfo.scala:708) 18: dotty.tools.dotc.typer.RefChecks$.checkAnyRefMethodCall(RefChecks.scala:1333) 16: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:641) 16: dotty.tools.dotc.typer.TypeAssigner.$anonfun$2$$anonfun$1(TypeAssigner.scala:50) 16: dotty.tools.dotc.transform.CollectNullableFields.recordUse(CollectNullableFields.scala:60) 16: dotty.tools.dotc.transform.ProtectedAccessors$.needsAccessor(ProtectedAccessors.scala:52) 16: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:635) 15: dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:371) 14: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.processMemberDef(PostTyper.scala:250) 14: dotty.tools.dotc.transform.ArrayApply.dotty$tools$dotc$transform$ArrayApply$$isSeqApply(ArrayApply.scala:57) 14: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:754) 14: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.registerIfHasMacroAnnotations(PostTyper.scala:819) 14: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:751) 14: dotty.tools.dotc.typer.Typer.typedAppliedTypeTree(Typer.scala:2842) 14: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:747) 13: dotty.tools.dotc.transform.SpecializeInlineTraits$$anon$1.transform(SpecializeInlineTraits.scala:59) 13: dotty.tools.dotc.transform.CrossVersionChecks.checkUnrollMemberDef(CrossVersionChecks.scala:98) 12: dotty.tools.dotc.transform.Constructors.markUsedPrivateSymbols(Constructors.scala:63) 12: dotty.tools.dotc.transform.ExpandPrivate.ensurePrivateAccessible(ExpandPrivate.scala:70) 12: dotty.tools.dotc.transform.CountOuterAccesses.markAccessed(CountOuterAccesses.scala:49) 12: dotty.tools.dotc.transform.Erasure$Typer.isErased(Erasure.scala:518) 12: dotty.tools.dotc.transform.Erasure$Typer.checkNotErased(Erasure.scala:537) 11: dotty.tools.dotc.transform.LazyVals.$anonfun$1(LazyVals.scala:204) 11: dotty.tools.dotc.transform.VCInlineMethods.rewireIfNeeded(VCInlineMethods.scala:104) 11: dotty.tools.dotc.typer.Nullables$.computeNullable(Nullables.scala:403) 10: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:482) 10: dotty.tools.dotc.ast.Trees$NamedDefTree.srcName(Trees.scala:381) 10: dotty.tools.dotc.ast.TypedTreeInfo.isStructuralTermSelect$1(TreeInfo.scala:1139) 10: dotty.tools.dotc.transform.CrossVersionChecks.transformSelect(CrossVersionChecks.scala:137) 9: dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:396) 9: dotty.tools.dotc.transform.CapturedVars$$anon$1.traverse(CapturedVars.scala:117) 9: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformSelect(PostTyper.scala:321) 9: dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:399) 9: dotty.tools.dotc.transform.CapturedVars.transformIdent(CapturedVars.scala:90) 9: dotty.tools.dotc.transform.LambdaLift.transformIdent(LambdaLift.scala:291) 9: dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:376) 9: dotty.tools.dotc.transform.RepeatableAnnotations.transformDef(RepeatableAnnotations.scala:28) 9: dotty.tools.dotc.transform.ForwardDepChecks.transformIdent(ForwardDepChecks.scala:90) 9: dotty.tools.dotc.transform.CheckLoopingImplicits.transform(CheckLoopingImplicits.scala:46) 9: dotty.tools.dotc.transform.CrossVersionChecks.checkDeprecatedOvers(CrossVersionChecks.scala:64) 9: dotty.tools.dotc.transform.SuperAccessors.transformSelect(SuperAccessors.scala:178) 8: dotty.tools.dotc.transform.ParamForwarding.transformIfParamAlias(ParamForwarding.scala:43) 8: dotty.tools.dotc.inlines.Inliner$isElideableExpr$.apply(Inliner.scala:66) 8: dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:280) 8: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadModule(BCodeBodyBuilder.scala:1282) 8: dotty.tools.dotc.transform.LazyVals.transformLazyVal(LazyVals.scala:75) 8: dotty.tools.dotc.transform.TypeTestsCasts$.interceptWith$1(TypeTestsCasts.scala:190) 8: dotty.tools.dotc.inlines.Inliner.countRefs$1$$anonfun$1(Inliner.scala:1294) 7: dotty.tools.dotc.transform.ElimErasedValueType.transformApply(ElimErasedValueType.scala:75) 7: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:496) 7: dotty.tools.dotc.transform.ArrayApply.transformApply(ArrayApply.scala:32) 7: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.scala2LibPatch(PostTyper.scala:834) 7: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:498) 7: dotty.tools.dotc.transform.LambdaLift.transformApply(LambdaLift.scala:320) 7: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:487) 7: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:685) 7: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:770) 7: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:359) 7: dotty.tools.dotc.transform.PureStats.$anonfun$1(PureStats.scala:29) 7: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:690) 7: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.processValOrDefDef(PostTyper.scala:264) 6: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:523) 6: dotty.tools.dotc.typer.RefChecks.transformValDef(RefChecks.scala:1487) 6: dotty.tools.dotc.transform.CrossVersionChecks.transformValDef(CrossVersionChecks.scala:109) 6: dotty.tools.dotc.ast.TypedTreeInfo.statPurity(TreeInfo.scala:595) 6: dotty.tools.dotc.typer.Checking.checkNoTargetNameConflict$$anonfun$1(Checking.scala:1735) 6: dotty.tools.dotc.transform.CapturedVars.prepareForValDef(CapturedVars.scala:68) 6: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.processValOrDefDef(PostTyper.scala:268) 6: dotty.tools.dotc.ast.TypedTreeInfo.exprPurity(TreeInfo.scala:624) 6: dotty.tools.dotc.transform.CrossVersionChecks.transformValDef(CrossVersionChecks.scala:110) 6: dotty.tools.dotc.transform.InlineVals.checkInlineConformant(InlineVals.scala:32) 6: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:480) 6: dotty.tools.dotc.transform.TupleOptimizations.transformApply(TupleOptimizations.scala:24) 5: dotty.tools.dotc.typer.RefChecks.transformValDef(RefChecks.scala:1488) 5: dotty.tools.dotc.transform.Getters.transformValDef(Getters.scala:105) 5: dotty.tools.dotc.transform.ElimByName.transformValDef(ElimByName.scala:160) 5: dotty.tools.dotc.typer.Typer.typedInfixOp(Typer.scala:3819) 5: dotty.tools.dotc.transform.CapturedVars.transformValDef(CapturedVars.scala:78) 5: dotty.tools.dotc.transform.Constructors.transformValDef(Constructors.scala:108) 5: dotty.tools.dotc.transform.MegaPhase.loop$1(MegaPhase.scala:465) 5: dotty.tools.dotc.transform.ForwardDepChecks.transformValDef(ForwardDepChecks.scala:80) 5: dotty.tools.dotc.transform.TailRec$TailRecElimination.transform(TailRec.scala:410) 5: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:671) 5: dotty.tools.dotc.transform.TailRec$TailRecElimination.rewriteApply$1(TailRec.scala:312) 5: dotty.tools.dotc.typer.Typer.finalize$1(Typer.scala:4190) 5: dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:4160) 5: dotty.tools.dotc.transform.UncacheGivenAliases.transformValDef(UncacheGivenAliases.scala:55) 4: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:855) 4: dotty.tools.dotc.inlines.Inlines$.isUnapplyExpressionWithDummy$1(Inlines.scala:119) 4: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:656) 4: dotty.tools.dotc.typer.ImportInfo$.sym$2(ImportInfo.scala:30) 4: dotty.tools.dotc.typer.Applications.typedTypeApply(Applications.scala:1618) 4: dotty.tools.dotc.inlines.Inlines$.symbolFromParent(Inlines.scala:126) 4: dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:179) 4: dotty.tools.dotc.inlines.Inlines$InlineCall.expand(Inlines.scala:809) 4: dotty.tools.dotc.inlines.Inliner$isElideableExpr$.apply(Inliner.scala:59) 4: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen(BCodeSkelBuilder.scala:691) 4: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:658) 4: dotty.tools.dotc.inlines.Inliner$InlineTyper.inlineIfNeeded(Inliner.scala:1211) 4: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genDefDef(BCodeSkelBuilder.scala:820) 4: dotty.tools.dotc.ast.tpd$TreeOps$$anon$4.applyOrElse(tpd.scala:1164) 4: dotty.tools.backend.ScalaPrimitives.isPrimitive(ScalaPrimitives.scala:401) 4: dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:5021) 4: dotty.tools.dotc.inlines.Inlines$.needsTransparentInlining(Inlines.scala:169) 4: dotty.tools.dotc.inlines.Inliner.<init>(Inliner.scala:229) 4: dotty.tools.dotc.transform.FirstTransform.reorder$1(FirstTransform.scala:91) 4: dotty.tools.dotc.transform.DesugarSpecializedTraits.checkSpecializedTraitRules$$anonfun$1(DesugarSpecializedTraits.scala:367) 4: dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:206) 4: dotty.tools.backend.ScalaPrimitives.isPrimitive(ScalaPrimitives.scala:400) 4: dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:261) 4: dotty.tools.dotc.transform.DesugarSpecializedTraits.checkSpecializedTraitRules$$anonfun$1(DesugarSpecializedTraits.scala:369) 4: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.emitNormalMethodBody$1(BCodeSkelBuilder.scala:906) 4: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:442) 4: dotty.tools.dotc.inlines.Inliner.computeParamBindings$$anonfun$2(Inliner.scala:388) 4: dotty.tools.dotc.transform.CrossVersionChecks.transformTypeDef(CrossVersionChecks.scala:124) 4: dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:195) 4: dotty.tools.dotc.transform.CrossVersionChecks.transformTypeDef(CrossVersionChecks.scala:123) 4: dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:196) 4: dotty.tools.dotc.inlines.Inliner$InlinerTreeMap.argSpan$1(Inliner.scala:714) 4: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:422) 4: dotty.tools.dotc.inlines.Inliner.$anonfun$16(Inliner.scala:1248) 4: dotty.tools.dotc.inlines.Inliner$InlineableArg$.unapply(Inliner.scala:906) 4: dotty.tools.dotc.inlines.Inliner.$anonfun$19(Inliner.scala:1332) 4: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:326) 4: dotty.tools.dotc.transform.FirstTransform.transformTypeDef(FirstTransform.scala:214) 4: dotty.tools.dotc.inlines.InlineReducer.normalizeBinding(InlineReducer.scala:139) 4: dotty.tools.dotc.transform.TailRec$TailRecElimination.rewriteApply$1(TailRec.scala:315) 4: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genDefDef(BCodeSkelBuilder.scala:817) 3: dotty.tools.dotc.transform.RestoreScopes.restoreScope$$anonfun$1(RestoreScopes.scala:38) 3: dotty.tools.dotc.transform.localopt.StringInterpolatorOpt.transformApply(StringInterpolatorOpt.scala:131) 3: dotty.tools.dotc.transform.FirstTransform.transformDefDef(FirstTransform.scala:135) 3: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:511) 3: dotty.tools.dotc.transform.CheckNoSuperThis.transformDefDef(CheckNoSuperThis.scala:27) 3: dotty.tools.dotc.transform.NonLocalReturns.transformDefDef(NonLocalReturns.scala:94) 3: dotty.tools.dotc.transform.TailRec.transformDefDef(TailRec.scala:117) 3: dotty.tools.dotc.transform.Memoize.transformDefDef(Memoize.scala:102) 3: dotty.tools.dotc.ast.TypedTreeInfo.exprPurity(TreeInfo.scala:619) 3: dotty.tools.dotc.transform.CompleteJavaEnums.transformDefDef(CompleteJavaEnums.scala:90) 3: dotty.tools.dotc.transform.ElimRepeated.transformDefDef(ElimRepeated.scala:177) 3: dotty.tools.dotc.ast.tpd$.desugarIdent(tpd.scala:1515) 3: dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:668) 3: dotty.tools.dotc.transform.LambdaLift.transformSelect(LambdaLift.scala:309) 3: dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.args$extension(ExplicitOuter.scala:431) 3: dotty.tools.dotc.transform.ElimOpaque.transformApply(ElimOpaque.scala:65) 3: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:717) 3: dotty.tools.dotc.transform.CrossVersionChecks.transformDefDef(CrossVersionChecks.scala:117) 3: dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:4156) 3: dotty.tools.dotc.transform.MethodSpecialization$.unapply(DesugarSpecializedTraits.scala:961) 3: dotty.tools.dotc.transform.ExpandPrivate.transformDefDef(ExpandPrivate.scala:114) 3: dotty.tools.dotc.transform.CrossVersionChecks.transformDefDef(CrossVersionChecks.scala:116) 3: dotty.tools.dotc.transform.ResolveSuper.transformDefDef(ResolveSuper.scala:64) 3: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformSelect(PostTyper.scala:323) 3: dotty.tools.dotc.typer.RefChecks.transformDefDef(RefChecks.scala:1502) 3: dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.args$extension(ExplicitOuter.scala:430) 3: dotty.tools.dotc.transform.DesugarSpecializedTraits.collectReferencedSpecializations$$anonfun$1$$anonfun$1(DesugarSpecializedTraits.scala:561) 3: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:507) 3: dotty.tools.dotc.transform.DesugarSpecializedTraits.collectReferencedSpecializations$$anonfun$1$$anonfun$1(DesugarSpecializedTraits.scala:559) 3: dotty.tools.dotc.transform.SelectStatic.transformSelect(SelectStatic.scala:53) 3: dotty.tools.dotc.ast.TypedTreeInfo.exprPurity(TreeInfo.scala:638) 3: dotty.tools.dotc.transform.SimplifySynchronized.transformDefDef(SimplifySynchronized.scala:27) 3: dotty.tools.dotc.transform.InterceptedMethods.transformApply(InterceptedMethods.scala:86) 3: dotty.tools.dotc.transform.ExtensionMethods.transformDefDef(ExtensionMethods.scala:159) 3: dotty.tools.dotc.ast.TypedTreeInfo.decomposeTemplateBody$$anonfun$1(TreeInfo.scala:898) 3: dotty.tools.dotc.transform.DesugarSpecializedTraits.$anonfun$23(DesugarSpecializedTraits.scala:450) 3: dotty.tools.dotc.transform.ArrayConstructors.transformApply(ArrayConstructors.scala:35) 3: dotty.tools.dotc.ast.TypedTreeInfo.isPureApply(TreeInfo.scala:696) 3: dotty.tools.dotc.ast.TypedTreeInfo.splitAtSuper(TreeInfo.scala:1158) 3: dotty.tools.dotc.ast.TypedTreeInfo.isPureApply(TreeInfo.scala:697) 3: dotty.tools.dotc.transform.LambdaLift.transformDefDef(LambdaLift.scala:326) 3: dotty.tools.dotc.transform.LambdaLift$Lifter$$anon$1.process(LambdaLift.scala:46) 3: dotty.tools.dotc.transform.InlinePatterns.transformApply(InlinePatterns.scala:40) 3: dotty.tools.dotc.transform.ArrayConstructors.transformApply(ArrayConstructors.scala:39) 3: dotty.tools.dotc.transform.RestoreScopes.restoreScope$$anonfun$1(RestoreScopes.scala:39) 2: dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1639) 2: dotty.tools.dotc.transform.Erasure$.dotty$tools$dotc$transform$Erasure$Typer$$_$_$_$$anonfun$14(Erasure.scala:1095) 2: dotty.tools.dotc.transform.CheckStatic.transformTemplate$$anonfun$1(CheckStatic.scala:40) 2: dotty.tools.dotc.typer.Applications.widenEnumCase(Applications.scala:1696) 2: dotty.tools.dotc.ast.TypedTreeInfo.decomposeTemplateBody$$anonfun$1(TreeInfo.scala:900) 2: dotty.tools.dotc.transform.HoistSuperArgs$Hoister.hoistSuperArgsFromConstr(HoistSuperArgs.scala:213) 2: dotty.tools.dotc.transform.DropOuterAccessors.dropOuterAccessor$1(DropOuterAccessors.scala:44) 2: dotty.tools.dotc.typer.Typer.hasSameParent$1(Typer.scala:3367) 2: dotty.tools.backend.jvm.BCodeSkelBuilder.dotty$tools$backend$jvm$BCodeSkelBuilder$PlainSkelBuilder$$_$_$_$$anonfun$2(BCodeSkelBuilder.scala:204) 2: dotty.tools.dotc.transform.Constructors.splitStats$1(Constructors.scala:245) 2: dotty.tools.dotc.transform.ContextFunctionResults$.annotateContextResults(ContextFunctionResults.scala:30) 2: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:815) 2: dotty.tools.dotc.typer.Typer.finalize$1(Typer.scala:4191) 2: dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1448) 2: dotty.tools.dotc.transform.Erasure$Typer.isPrimaryConsOfSpecTrait$1(Erasure.scala:1099) 2: dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3682) 2: dotty.tools.dotc.transform.PruneInlinedMethods.$anonfun$2(PruneInlinedMethods.scala:33) 2: dotty.tools.dotc.ast.TypedTreeInfo.topLevelClasses(TreeInfo.scala:1048) 2: dotty.tools.dotc.transform.PruneInlineTraits.$anonfun$2(PruneInlineTraits.scala:37) 2: dotty.tools.dotc.transform.Erasure$Typer.addRetainedInlineBodies$$anonfun$1(Erasure.scala:1048) 2: dotty.tools.dotc.transform.PruneInlineTraits.$anonfun$2(PruneInlineTraits.scala:38) 2: dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3533) 2: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:412) 2: dotty.tools.dotc.transform.SuperAccessors.wrapDefDef(SuperAccessors.scala:229) 2: dotty.tools.dotc.transform.CheckLoopingImplicits.checkNotLooping$1(CheckLoopingImplicits.scala:70) 1: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genPlainClass(BCodeSkelBuilder.scala:165) 1: dotty.tools.dotc.transform.Specialization$.unapply(DesugarSpecializedTraits.scala:900) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:401) 1: dotty.tools.dotc.ast.TypedTreeInfo.sliceTopLevel(TreeInfo.scala:1065) 1: dotty.tools.dotc.transform.SpecializeApplyMethods.transformTemplate(SpecializeApplyMethods.scala:89) 1: dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49) 1: dotty.tools.dotc.transform.CompleteJavaEnums.transformTemplate(CompleteJavaEnums.scala:192) 1: dotty.tools.dotc.ast.MainProxies$.mainMethods$1$$anonfun$1(MainProxies.scala:33) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genStat(BCodeBodyBuilder.scala:106) 1: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:669) 1: dotty.tools.dotc.transform.ResolveSuper.transformTemplate(ResolveSuper.scala:46) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:403) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genStat(BCodeBodyBuilder.scala:96) 1: dotty.tools.dotc.transform.Mixin.transformConstructor$1(Mixin.scala:245) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:808) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genStat(BCodeBodyBuilder.scala:101) 1: dotty.tools.dotc.typer.Checking$$anon$7.traverse(Checking.scala:988) 1: dotty.tools.dotc.transform.FunctionXXLForwarders.transformTemplate(FunctionXXLForwarders.scala:44) 1: dotty.tools.dotc.transform.SyntheticMembers.checkInlining$$anonfun$1$$anonfun$1(SyntheticMembers.scala:735) 1: dotty.tools.dotc.transform.Mixin.$anonfun$1(Mixin.scala:249) 1: dotty.tools.dotc.transform.ProtectedAccessors.transformTemplate(ProtectedAccessors.scala:102) 1: dotty.tools.dotc.transform.Mixin.transformConstructor$1(Mixin.scala:244) 1: dotty.tools.dotc.ast.TypedTreeInfo.sliceTopLevel(TreeInfo.scala:1060) 1: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.paramTKs(BCodeSkelBuilder.scala:150) 1: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genPlainClass(BCodeSkelBuilder.scala:288) 1: dotty.tools.dotc.transform.MoveStatics.$anonfun$2(MoveStatics.scala:44) 1: dotty.tools.dotc.transform.FirstTransform.reorder$1(FirstTransform.scala:92) 1: dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3570) 1: dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:4146) 1: dotty.tools.dotc.transform.LambdaLift$Lifter$$anon$1.process(LambdaLift.scala:51) 1: dotty.tools.dotc.transform.CheckNoSuperThis.transformDefDef(CheckNoSuperThis.scala:31) 1: dotty.tools.dotc.transform.DesugarSpecializedTraits.collectReferencedSpecializations$$anonfun$1$$anonfun$1(DesugarSpecializedTraits.scala:470) 1: dotty.tools.dotc.typer.ReTyper.localDummy(ReTyper.scala:145) 1: dotty.tools.dotc.typer.RefChecks.transformTypeDef(RefChecks.scala:1513) 1: dotty.tools.dotc.transform.MoveStatics.$anonfun$1(MoveStatics.scala:43) 1: dotty.tools.dotc.transform.Mixin.transformTemplate(Mixin.scala:203) 1: dotty.tools.dotc.transform.RestoreScopes.restoreScope(RestoreScopes.scala:46) 1: dotty.tools.dotc.transform.SyntheticMembers.checkInlining$$anonfun$1$$anonfun$1(SyntheticMembers.scala:736) 1: dotty.tools.dotc.transform.Constructors.splitStats$1(Constructors.scala:283) 1: dotty.tools.dotc.transform.CheckLoopingImplicits.checkNotSelfRef$1(CheckLoopingImplicits.scala:49) 1: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:675) 1: dotty.tools.dotc.transform.HoistSuperArgs.transformTypeDef(HoistSuperArgs.scala:232) 1: dotty.tools.dotc.transform.Dependencies.process(Dependencies.scala:258) 1: dotty.tools.backend.jvm.CodeGen.genClassDef$1(CodeGen.scala:36) 1: dotty.tools.dotc.transform.TreeExtractors$BinaryOp$.unapply(TreeExtractors.scala:16) 1: dotty.tools.dotc.transform.Constructors$intoConstr$2$.apply(Constructors.scala:195) 1: dotty.tools.dotc.transform.ElimErasedValueType.prepareForTypeDef(ElimErasedValueType.scala:130) 1: dotty.tools.dotc.transform.TailRec$TailRecElimination.transform(TailRec.scala:418) 1: dotty.tools.dotc.ast.MainProxies$.mainMethods$1$$anonfun$1(MainProxies.scala:35) 1: dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1285) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:400) 1: dotty.tools.dotc.transform.LambdaLift.transformTypeDef(LambdaLift.scala:350) 1: dotty.tools.dotc.transform.RestoreScopes.restoreScope(RestoreScopes.scala:42) 1: dotty.tools.dotc.transform.ExtensionMethods.transformTemplate(ExtensionMethods.scala:151) </pre> </details> <details> <summary>Calls in PR (click to expand)</summary> <pre> Total: 7091 3168: dotty.tools.dotc.ast.tpd$TreeOps$.ensureHasSym$extension(tpd.scala:1221) 1395: dotty.tools.dotc.core.tasty.TreeUnpickler.dotty$tools$dotc$core$tasty$TreeUnpickler$TreeReader$$_$_$_$$anonfun$17(TreeUnpickler.scala:953) 235: dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.processPackage(TreeUnpickler.scala:858) 165: dotty.tools.dotc.ast.tpd$.localOwner(tpd.scala:647) 132: dotty.tools.dotc.core.Annotations$.annotClass(Annotations.scala:19) 92: dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:256) 91: dotty.tools.dotc.typer.ConstFold$.apply(ConstFold.scala:60) 75: dotty.tools.dotc.inlines.Inlines$.needsInlining(Inlines.scala:123) 64: dotty.tools.dotc.transform.Dependencies.process(Dependencies.scala:177) 59: dotty.tools.dotc.typer.Typer.adaptNoArgsOther$1(Typer.scala:4934) 57: dotty.tools.dotc.typer.Checking$.checkAppliedType(Checking.scala:126) 55: dotty.tools.dotc.typer.Typer.adaptNoArgsOther$1(Typer.scala:4943) 48: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.registerNeedsInlining(PostTyper.scala:816) 42: dotty.tools.dotc.typer.TypeAssigner.assignType$$anonfun$6(TypeAssigner.scala:552) 42: dotty.tools.dotc.typer.TypeAssigner.$anonfun$13(TypeAssigner.scala:548) 35: dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTree$1(TreeUnpickler.scala:1533) 35: dotty.tools.dotc.core.tasty.TreeUnpickler.dotty$tools$dotc$core$tasty$TreeUnpickler$TreeReader$$_$constructorApply$1(TreeUnpickler.scala:1418) 29: dotty.tools.dotc.transform.CheckUnused$.withOriginalName(CheckUnused.scala:551) 29: dotty.tools.dotc.typer.ReTyper.retrieveSym(ReTyper.scala:147) 28: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.checkUsableAsValue(PostTyper.scala:386) 27: dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:268) 24: dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:272) 23: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:582) 21: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.checkNotPackage(PostTyper.scala:408) 19: dotty.tools.dotc.transform.CrossVersionChecks.transformIdent(CrossVersionChecks.scala:127) 18: dotty.tools.dotc.ast.tpd$TreeOps$.setDefTree$extension(tpd.scala:1198) 18: dotty.tools.dotc.ast.TypedTreeInfo.refPurity(TreeInfo.scala:708) 16: dotty.tools.dotc.ast.TypedTreeInfo.localSyms$$anonfun$1(TreeInfo.scala:1017) 16: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:642) 16: dotty.tools.dotc.typer.TypeAssigner.$anonfun$2$$anonfun$1(TypeAssigner.scala:50) 16: dotty.tools.dotc.transform.CollectNullableFields.recordUse(CollectNullableFields.scala:60) 16: dotty.tools.dotc.transform.ProtectedAccessors$.needsAccessor(ProtectedAccessors.scala:52) 16: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:636) 16: dotty.tools.dotc.transform.InterceptedMethods.transformRefTree(InterceptedMethods.scala:46) 15: dotty.tools.dotc.core.tasty.TreePickler.preRegister(TreePickler.scala:84) 15: dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:369) 14: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.processMemberDef(PostTyper.scala:250) 14: dotty.tools.dotc.transform.ArrayApply.dotty$tools$dotc$transform$ArrayApply$$isSeqApply(ArrayApply.scala:57) 14: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.registerIfHasMacroAnnotations(PostTyper.scala:821) 14: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:748) 14: dotty.tools.dotc.typer.Typer.typedAppliedTypeTree(Typer.scala:2842) 13: dotty.tools.dotc.transform.SpecializeInlineTraits$$anon$1.transform(SpecializeInlineTraits.scala:59) 13: dotty.tools.dotc.transform.CrossVersionChecks.checkUnrollMemberDef(CrossVersionChecks.scala:96) 12: dotty.tools.dotc.transform.Constructors.markUsedPrivateSymbols(Constructors.scala:63) 12: dotty.tools.dotc.transform.Erasure$Typer.isErased(Erasure.scala:516) 12: dotty.tools.dotc.transform.ExpandPrivate.ensurePrivateAccessible(ExpandPrivate.scala:70) 12: dotty.tools.dotc.transform.CountOuterAccesses.markAccessed(CountOuterAccesses.scala:49) 12: dotty.tools.dotc.transform.Erasure$Typer.checkNotErased(Erasure.scala:537) 11: dotty.tools.dotc.transform.LazyVals.$anonfun$1(LazyVals.scala:204) 11: dotty.tools.dotc.transform.VCInlineMethods.rewireIfNeeded(VCInlineMethods.scala:104) 11: dotty.tools.dotc.typer.Nullables$.computeNullable(Nullables.scala:403) 10: dotty.tools.dotc.ast.Trees$NamedDefTree.srcName(Trees.scala:382) 10: dotty.tools.dotc.ast.TypedTreeInfo.isStructuralTermSelect$1(TreeInfo.scala:1141) 10: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:475) 10: dotty.tools.dotc.transform.CrossVersionChecks.transformSelect(CrossVersionChecks.scala:132) 9: dotty.tools.dotc.transform.CrossVersionChecks.checkDeprecatedOvers(CrossVersionChecks.scala:62) 9: dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:396) 9: dotty.tools.dotc.transform.CapturedVars$$anon$1.traverse(CapturedVars.scala:117) 9: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformSelect(PostTyper.scala:321) 9: dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:399) 9: dotty.tools.dotc.transform.CapturedVars.transformIdent(CapturedVars.scala:90) 9: dotty.tools.dotc.typer.RefChecks$.checkAnyRefMethodCall(RefChecks.scala:1333) 9: dotty.tools.dotc.transform.LambdaLift.transformIdent(LambdaLift.scala:291) 9: dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:376) 9: dotty.tools.dotc.transform.RepeatableAnnotations.transformDef(RepeatableAnnotations.scala:28) 9: dotty.tools.dotc.transform.ForwardDepChecks.transformIdent(ForwardDepChecks.scala:90) 9: dotty.tools.dotc.transform.CheckLoopingImplicits.transform(CheckLoopingImplicits.scala:46) 9: dotty.tools.dotc.transform.SuperAccessors.transformSelect(SuperAccessors.scala:178) 8: dotty.tools.dotc.transform.ParamForwarding.transformIfParamAlias(ParamForwarding.scala:43) 8: dotty.tools.dotc.inlines.Inliner.countRefs$1$$anonfun$1(Inliner.scala:1297) 8: dotty.tools.dotc.transform.LazyVals.transformLazyVal(LazyVals.scala:75) 8: dotty.tools.dotc.transform.TypeTestsCasts$.interceptWith$1(TypeTestsCasts.scala:190) 7: dotty.tools.dotc.typer.VarianceChecker$Traverser$.traverse(VarianceChecker.scala:213) 7: dotty.tools.dotc.transform.ElimErasedValueType.transformApply(ElimErasedValueType.scala:75) 7: dotty.tools.dotc.transform.ArrayApply.transformApply(ArrayApply.scala:32) 7: dotty.tools.dotc.transform.LambdaLift.transformApply(LambdaLift.scala:320) 7: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.scala2LibPatch(PostTyper.scala:836) 7: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:771) 7: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:686) 7: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:359) 7: dotty.tools.dotc.transform.PureStats.$anonfun$1(PureStats.scala:29) 7: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.processValOrDefDef(PostTyper.scala:264) 6: dotty.tools.dotc.ast.TypedTreeInfo.statPurity(TreeInfo.scala:595) 6: dotty.tools.dotc.typer.Checking.checkNoTargetNameConflict$$anonfun$1(Checking.scala:1735) 6: dotty.tools.dotc.transform.CapturedVars.prepareForValDef(CapturedVars.scala:68) 6: dotty.tools.dotc.typer.RefChecks.transformValDef(RefChecks.scala:1488) 6: dotty.tools.dotc.transform.CrossVersionChecks.transformValDef(CrossVersionChecks.scala:107) 6: dotty.tools.dotc.ast.TypedTreeInfo.exprPurity(TreeInfo.scala:624) 6: dotty.tools.dotc.transform.InlineVals.checkInlineConformant(InlineVals.scala:32) 5: dotty.tools.dotc.transform.Getters.transformValDef(Getters.scala:105) 5: dotty.tools.dotc.transform.ElimByName.transformValDef(ElimByName.scala:160) 5: dotty.tools.dotc.typer.Typer.typedInfixOp(Typer.scala:3819) 5: dotty.tools.dotc.transform.CapturedVars.transformValDef(CapturedVars.scala:78) 5: dotty.tools.dotc.transform.Constructors.transformValDef(Constructors.scala:108) 5: dotty.tools.dotc.transform.MegaPhase.loop$1(MegaPhase.scala:465) 5: dotty.tools.dotc.transform.ForwardDepChecks.transformValDef(ForwardDepChecks.scala:80) 5: dotty.tools.dotc.transform.TailRec$TailRecElimination.transform(TailRec.scala:410) 5: dotty.tools.dotc.transform.TailRec$TailRecElimination.rewriteApply$1(TailRec.scala:312) 5: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:672) 5: dotty.tools.dotc.typer.Typer.finalize$1(Typer.scala:4190) 5: dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:4160) 5: dotty.tools.dotc.transform.UncacheGivenAliases.transformValDef(UncacheGivenAliases.scala:55) 4: dotty.tools.dotc.inlines.Inliner.<init>(Inliner.scala:230) 4: dotty.tools.dotc.inlines.Inlines$.isUnapplyExpressionWithDummy$1(Inlines.scala:119) 4: dotty.tools.dotc.typer.ImportInfo$.sym$2(ImportInfo.scala:30) 4: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen(BCodeSkelBuilder.scala:690) 4: dotty.tools.dotc.typer.Applications.typedTypeApply(Applications.scala:1618) 4: dotty.tools.dotc.inlines.Inlines$.symbolFromParent(Inlines.scala:126) 4: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:657) 4: dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:179) 4: dotty.tools.dotc.inlines.Inliner$isElideableExpr$.apply(Inliner.scala:59) 4: dotty.tools.dotc.inlines.Inliner$InlineableArg$.unapply(Inliner.scala:909) 4: dotty.tools.dotc.transform.CrossVersionChecks.transformTypeDef(CrossVersionChecks.scala:119) 4: dotty.tools.dotc.inlines.Inliner$isElideableExpr$.apply(Inliner.scala:66) 4: dotty.tools.dotc.ast.tpd$TreeOps$$anon$4.applyOrElse(tpd.scala:1164) 4: dotty.tools.dotc.inlines.Inliner.$anonfun$16(Inliner.scala:1251) 4: dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:5021) 4: dotty.tools.dotc.inlines.Inlines$.needsTransparentInlining(Inlines.scala:169) 4: dotty.tools.dotc.transform.FirstTransform.reorder$1(FirstTransform.scala:91) 4: dotty.tools.backend.ScalaPrimitives.isPrimitive(ScalaPrimitives.scala:400) 4: dotty.tools.dotc.inlines.Inliner.computeParamBindings$$anonfun$2(Inliner.scala:389) 4: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:443) 4: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:659) 4: dotty.tools.dotc.inlines.Inlines$InlineCall.expand(Inlines.scala:810) 4: dotty.tools.dotc.inlines.Inliner.$anonfun$19(Inliner.scala:1335) 4: dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:194) 4: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadModule(BCodeBodyBuilder.scala:1282) 4: dotty.tools.dotc.inlines.Inliner$InlineTyper.inlineIfNeeded(Inliner.scala:1214) 4: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:423) 4: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:326) 4: dotty.tools.dotc.inlines.Inliner$InlinerTreeMap.argSpan$1(Inliner.scala:716) 4: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:856) 4: dotty.tools.dotc.transform.FirstTransform.transformTypeDef(FirstTransform.scala:214) 4: dotty.tools.dotc.inlines.InlineReducer.normalizeBinding(InlineReducer.scala:139) 4: dotty.tools.dotc.transform.TailRec$TailRecElimination.rewriteApply$1(TailRec.scala:315) 4: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genDefDef(BCodeSkelBuilder.scala:817) 3: dotty.tools.dotc.transform.RestoreScopes.restoreScope$$anonfun$1(RestoreScopes.scala:38) 3: dotty.tools.dotc.transform.localopt.StringInterpolatorOpt.transformApply(StringInterpolatorOpt.scala:131) 3: dotty.tools.dotc.typer.RefChecks.transformDefDef(RefChecks.scala:1503) 3: dotty.tools.dotc.transform.DesugarSpecializedTraits.collectReferencedSpecializations$$anonfun$1$$anonfun$1(DesugarSpecializedTraits.scala:563) 3: dotty.tools.dotc.transform.FirstTransform.transformDefDef(FirstTransform.scala:135) 3: dotty.tools.dotc.transform.CheckNoSuperThis.transformDefDef(CheckNoSuperThis.scala:27) 3: dotty.tools.dotc.transform.NonLocalReturns.transformDefDef(NonLocalReturns.scala:94) 3: dotty.tools.dotc.transform.TailRec.transformDefDef(TailRec.scala:117) 3: dotty.tools.dotc.transform.Memoize.transformDefDef(Memoize.scala:102) 3: dotty.tools.dotc.transform.MethodSpecialization$.unapply(DesugarSpecializedTraits.scala:965) 3: dotty.tools.dotc.ast.TypedTreeInfo.exprPurity(TreeInfo.scala:619) 3: dotty.tools.dotc.transform.CompleteJavaEnums.transformDefDef(CompleteJavaEnums.scala:90) 3: dotty.tools.dotc.ast.tpd$.desugarIdent(tpd.scala:1524) 3: dotty.tools.dotc.transform.CrossVersionChecks.transformDefDef(CrossVersionChecks.scala:113) 3: dotty.tools.dotc.transform.DesugarSpecializedTraits.collectReferencedSpecializations$$anonfun$1$$anonfun$1(DesugarSpecializedTraits.scala:565) 3: dotty.tools.dotc.transform.ElimRepeated.transformDefDef(ElimRepeated.scala:177) 3: dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:668) 3: dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.args$extension(ExplicitOuter.scala:431) 3: dotty.tools.dotc.transform.ElimOpaque.transformApply(ElimOpaque.scala:65) 3: dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:4156) 3: dotty.tools.dotc.transform.ExpandPrivate.transformDefDef(ExpandPrivate.scala:114) 3: dotty.tools.dotc.ast.TypedTreeInfo.splitAtSuper(TreeInfo.scala:1160) 3: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:718) 3: dotty.tools.dotc.transform.ResolveSuper.transformDefDef(ResolveSuper.scala:64) 3: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:505) 3: dotty.tools.dotc.transform.DesugarSpecializedTraits.checkSpecializedTraitRules$$anonfun$1(DesugarSpecializedTraits.scala:368) 3: dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformSelect(PostTyper.scala:323) 3: dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.args$extension(ExplicitOuter.scala:430) 3: dotty.tools.dotc.transform.SelectStatic.transformSelect(SelectStatic.scala:53) 3: dotty.tools.dotc.ast.TypedTreeInfo.exprPurity(TreeInfo.scala:638) 3: dotty.tools.dotc.transform.SimplifySynchronized.transformDefDef(SimplifySynchronized.scala:27) 3: dotty.tools.dotc.transform.InterceptedMethods.transformApply(InterceptedMethods.scala:86) 3: dotty.tools.dotc.transform.ExtensionMethods.transformDefDef(ExtensionMethods.scala:159) 3: dotty.tools.dotc.ast.TypedTreeInfo.decomposeTemplateBody$$anonfun$1(TreeInfo.scala:898) 3: dotty.tools.dotc.transform.ArrayConstructors.transformApply(ArrayConstructors.scala:35) 3: dotty.tools.dotc.ast.TypedTreeInfo.isPureApply(TreeInfo.scala:696) 3: dotty.tools.dotc.ast.TypedTreeInfo.isPureApply(TreeInfo.scala:697) 3: dotty.tools.dotc.transform.LambdaLift.transformDefDef(LambdaLift.scala:326) 3: dotty.tools.dotc.transform.LambdaLift$Lifter$$anon$1.process(LambdaLift.scala:46) 3: dotty.tools.dotc.transform.InlinePatterns.transformApply(InlinePatterns.scala:40) 3: dotty.tools.dotc.transform.DesugarSpecializedTraits.$anonfun$23(DesugarSpecializedTraits.scala:454) 3: dotty.tools.dotc.transform.ArrayConstructors.transformApply(ArrayConstructors.scala:39) 3: dotty.tools.dotc.transform.TupleOptimizations.transformApply(TupleOptimizations.scala:24) 3: dotty.tools.dotc.transform.RestoreScopes.restoreScope$$anonfun$1(RestoreScopes.scala:39) 2: dotty.tools.dotc.transform.Erasure$.dotty$tools$dotc$transform$Erasure$Typer$$_$_$_$$anonfun$14(Erasure.scala:1095) 2: dotty.tools.dotc.transform.CheckStatic.transformTemplate$$anonfun$1(CheckStatic.scala:40) 2: dotty.tools.dotc.typer.Applications.widenEnumCase(Applications.scala:1696) 2: dotty.tools.dotc.ast.TypedTreeInfo.decomposeTemplateBody$$anonfun$1(TreeInfo.scala:900) 2: dotty.tools.dotc.transform.HoistSuperArgs$Hoister.hoistSuperArgsFromConstr(HoistSuperArgs.scala:213) 2: dotty.tools.dotc.transform.DropOuterAccessors.dropOuterAccessor$1(DropOuterAccessors.scala:44) 2: dotty.tools.dotc.ast.TypedTreeInfo.topLevelClasses(TreeInfo.scala:1050) 2: dotty.tools.dotc.typer.Typer.hasSameParent$1(Typer.scala:3367) 2: dotty.tools.backend.jvm.BCodeSkelBuilder.dotty$tools$backend$jvm$BCodeSkelBuilder$PlainSkelBuilder$$_$_$_$$anonfun$2(BCodeSkelBuilder.scala:204) 2: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:816) 2: dotty.tools.dotc.transform.Constructors.splitStats$1(Constructors.scala:245) 2: dotty.tools.dotc.transform.ContextFunctionResults$.annotateContextResults(ContextFunctionResults.scala:30) 2: dotty.tools.dotc.typer.Typer.finalize$1(Typer.scala:4191) 2: dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1448) 2: dotty.tools.dotc.transform.Erasure$Typer.isPrimaryConsOfSpecTrait$1(Erasure.scala:1099) 2: dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3682) 2: dotty.tools.dotc.transform.PruneInlinedMethods.$anonfun$2(PruneInlinedMethods.scala:33) 2: dotty.tools.dotc.transform.PruneInlineTraits.$anonfun$2(PruneInlineTraits.scala:37) 2: dotty.tools.dotc.transform.Erasure$Typer.addRetainedInlineBodies$$anonfun$1(Erasure.scala:1048) 2: dotty.tools.dotc.transform.PruneInlineTraits.$anonfun$2(PruneInlineTraits.scala:38) 2: dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3533) 2: dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1641) 2: dotty.tools.dotc.transform.SuperAccessors.wrapDefDef(SuperAccessors.scala:229) 2: dotty.tools.dotc.transform.CheckLoopingImplicits.checkNotLooping$1(CheckLoopingImplicits.scala:70) 1: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genPlainClass(BCodeSkelBuilder.scala:165) 1: dotty.tools.dotc.transform.SpecializeApplyMethods.transformTemplate(SpecializeApplyMethods.scala:89) 1: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:668) 1: dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49) 1: dotty.tools.dotc.transform.CompleteJavaEnums.transformTemplate(CompleteJavaEnums.scala:192) 1: dotty.tools.dotc.ast.MainProxies$.mainMethods$1$$anonfun$1(MainProxies.scala:33) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genStat(BCodeBodyBuilder.scala:106) 1: dotty.tools.dotc.transform.ResolveSuper.transformTemplate(ResolveSuper.scala:46) 1: dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1294) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genStat(BCodeBodyBuilder.scala:96) 1: dotty.tools.dotc.transform.Mixin.transformConstructor$1(Mixin.scala:245) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:809) 1: dotty.tools.dotc.ast.TypedTreeInfo.sliceTopLevel(TreeInfo.scala:1067) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genStat(BCodeBodyBuilder.scala:101) 1: dotty.tools.dotc.typer.Checking$$anon$7.traverse(Checking.scala:988) 1: dotty.tools.dotc.transform.FunctionXXLForwarders.transformTemplate(FunctionXXLForwarders.scala:44) 1: dotty.tools.dotc.transform.SyntheticMembers.checkInlining$$anonfun$1$$anonfun$1(SyntheticMembers.scala:735) 1: dotty.tools.dotc.transform.Mixin.$anonfun$1(Mixin.scala:249) 1: dotty.tools.dotc.transform.ProtectedAccessors.transformTemplate(ProtectedAccessors.scala:102) 1: dotty.tools.dotc.transform.Mixin.transformConstructor$1(Mixin.scala:244) 1: dotty.tools.dotc.transform.DesugarSpecializedTraits.collectReferencedSpecializations$$anonfun$1$$anonfun$1(DesugarSpecializedTraits.scala:474) 1: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.paramTKs(BCodeSkelBuilder.scala:150) 1: dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genPlainClass(BCodeSkelBuilder.scala:288) 1: dotty.tools.dotc.transform.MoveStatics.$anonfun$2(MoveStatics.scala:44) 1: dotty.tools.dotc.transform.FirstTransform.reorder$1(FirstTransform.scala:92) 1: dotty.tools.dotc.ast.TypedTreeInfo.sliceTopLevel(TreeInfo.scala:1062) 1: dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3570) 1: dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:4146) 1: dotty.tools.dotc.transform.LambdaLift$Lifter$$anon$1.process(LambdaLift.scala:51) 1: dotty.tools.dotc.typer.RefChecks.transformTypeDef(RefChecks.scala:1514) 1: dotty.tools.dotc.transform.CheckNoSuperThis.transformDefDef(CheckNoSuperThis.scala:31) 1: dotty.tools.dotc.typer.ReTyper.localDummy(ReTyper.scala:145) 1: dotty.tools.dotc.transform.MoveStatics.$anonfun$1(MoveStatics.scala:43) 1: dotty.tools.dotc.transform.Mixin.transformTemplate(Mixin.scala:203) 1: dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:674) 1: dotty.tools.dotc.transform.RestoreScopes.restoreScope(RestoreScopes.scala:46) 1: dotty.tools.dotc.transform.SyntheticMembers.checkInlining$$anonfun$1$$anonfun$1(SyntheticMembers.scala:736) 1: dotty.tools.dotc.transform.Constructors.splitStats$1(Constructors.scala:283) 1: dotty.tools.dotc.transform.Specialization$.unapply(DesugarSpecializedTraits.scala:904) 1: dotty.tools.dotc.transform.CheckLoopingImplicits.checkNotSelfRef$1(CheckLoopingImplicits.scala:49) 1: dotty.tools.dotc.transform.HoistSuperArgs.transformTypeDef(HoistSuperArgs.scala:232) 1: dotty.tools.dotc.transform.Dependencies.process(Dependencies.scala:258) 1: dotty.tools.backend.jvm.CodeGen.genClassDef$1(CodeGen.scala:36) 1: dotty.tools.dotc.transform.TreeExtractors$BinaryOp$.unapply(TreeExtractors.scala:16) 1: dotty.tools.dotc.transform.Constructors$intoConstr$2$.apply(Constructors.scala:195) 1: dotty.tools.dotc.transform.ElimErasedValueType.prepareForTypeDef(ElimErasedValueType.scala:130) 1: dotty.tools.dotc.transform.TailRec$TailRecElimination.transform(TailRec.scala:418) 1: dotty.tools.dotc.ast.MainProxies$.mainMethods$1$$anonfun$1(MainProxies.scala:35) 1: dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadTo(BCodeBodyBuilder.scala:400) 1: dotty.tools.dotc.transform.LambdaLift.transformTypeDef(LambdaLift.scala:350) 1: dotty.tools.dotc.transform.RestoreScopes.restoreScope(RestoreScopes.scala:42) 1: dotty.tools.dotc.transform.ExtensionMethods.transformTemplate(ExtensionMethods.scala:151) </pre> </details> ## Have you relied on LLM-based tools in this contribution? No ## How was the solution tested? Covered by existing tests (this is a refactoring)
1 parent a004a75 commit 8e7d60d

24 files changed

Lines changed: 165 additions & 138 deletions

compiler/src/dotty/tools/backend/ScalaPrimitives.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,9 @@ class ScalaPrimitives(using @constructorOnly initCtx: Context) {
397397
primitives.contains(sym)
398398

399399
def isPrimitive(fun: Tree)(using Context): Boolean =
400-
primitives.contains(fun.symbol)
401-
|| (fun.symbol == NoSymbol // the only trees that do not have a symbol assigned are array.{update,select,length,clone}
400+
val sym = fun.symbol
401+
primitives.contains(sym)
402+
|| (sym == NoSymbol // the only trees that do not have a symbol assigned are array.{update,select,length,clone}
402403
&& {
403404
fun match
404405
case Select(_, nme.clone_) => false // but array.clone is NOT a primitive op.

compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,11 @@ trait BCodeBodyBuilder(val primitives: ScalaPrimitives, val bTypes: KnownBTypes)
397397
generatedType = genApply(app, expectedType)
398398

399399
case This(qual) =>
400-
val symIsModuleClass = tree.symbol.is(ModuleClass)
401-
assert(tree.symbol == claszSymbol || symIsModuleClass,
402-
s"Trying to access the this of another class: tree.symbol = ${tree.symbol}, class symbol = $claszSymbol compilation unit: ${ctx.compilationUnit}")
403-
if (symIsModuleClass && tree.symbol != claszSymbol) {
400+
val sym = tree.symbol
401+
val symIsModuleClass = sym.is(ModuleClass)
402+
assert(sym == claszSymbol || symIsModuleClass,
403+
s"Trying to access the this of another class: tree.symbol = $sym, class symbol = $claszSymbol compilation unit: ${ctx.compilationUnit}")
404+
if (symIsModuleClass && sym != claszSymbol) {
404405
generatedType = genLoadModule(tree)
405406
}
406407
else {
@@ -409,7 +410,7 @@ trait BCodeBodyBuilder(val primitives: ScalaPrimitives, val bTypes: KnownBTypes)
409410
// is `[Object` (computed by typeToBType, the type of This(Array) is `Array[T]`). If we would set
410411
// the generatedType to `Array` below, the call to adapt at the end would fail. The situation is
411412
// similar for primitives (`I` vs `Int`).
412-
if (tree.symbol != defn.ArrayClass && !tree.symbol.isPrimitiveValueClass) {
413+
if (sym != defn.ArrayClass && !sym.isPrimitiveValueClass) {
413414
generatedType = bTypeLoader.classBTypeFromSymbol(claszSymbol)
414415
}
415416
}
@@ -1278,13 +1279,13 @@ trait BCodeBodyBuilder(val primitives: ScalaPrimitives, val bTypes: KnownBTypes)
12781279
end genLoadArguments
12791280

12801281
def genLoadModule(tree: Tree)(using Context): BType = {
1281-
val module = (
1282-
if (!tree.symbol.is(PackageClass)) tree.symbol
1283-
else tree.symbol.info.member(nme.PACKAGE).symbol match {
1282+
val sym = tree.symbol
1283+
val module =
1284+
if !sym.is(PackageClass) then sym
1285+
else sym.info.member(nme.PACKAGE).symbol match {
12841286
case NoSymbol => throw new AssertionError(s"SI-5604: Cannot use package as value: $tree")
12851287
case s => throw new AssertionError(s"SI-5604: found package class where package object expected: $tree")
12861288
}
1287-
)
12881289
lineNumber(tree)
12891290
genLoadModule(module)
12901291
symInfoTK(module)

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
646646
}
647647

648648
// on entering a method
649-
def resetMethodBookkeeping(dd: DefDef)(using Context) = {
650-
val rhs = dd.rhs
649+
def resetMethodBookkeeping()(using Context) = {
651650
locals.reset(isStaticMethod = methSymbol.isStaticMember)
652651
jumpDest = immutable.Map.empty
653652

@@ -813,14 +812,15 @@ trait BCodeSkelBuilder extends BCodeHelpers {
813812
private def genDefDef(dd: DefDef)(using Context): Unit = {
814813
val rhs = dd.rhs
815814
val vparamss = dd.termParamss
816-
// the only method whose implementation is not emitted: getClass()
817-
if (dd.symbol eq defn.Any_getClass) { return }
818815
assert(mnode == null, "GenBCode detected nested method.")
819816

820817
methSymbol = dd.symbol
818+
// the only method whose implementation is not emitted: getClass()
819+
if (methSymbol eq defn.Any_getClass) { return }
820+
821821
returnType = bTypeLoader.methodBTypeFromSymbol(methSymbol).returnType
822822

823-
resetMethodBookkeeping(dd)
823+
resetMethodBookkeeping()
824824

825825
// add method-local vars for params
826826

@@ -903,7 +903,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
903903
)
904904
else
905905
// The JVM doesn't support `synchronized` methods on interfaces so we must implement that ourselves
906-
if dd.symbol.is(Synchronized) && dd.symbol.owner.is(Trait) then
906+
if methSymbol.is(Synchronized) && methSymbol.owner.is(Trait) then
907907
bc.aloadThis()
908908
val generatedType = genSynchronized(trimmedRhs, trimmedRhs :: Nil, returnType)
909909
genAdaptAndSendToDest(generatedType, returnType, LoadDestination.Return)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,9 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
10131013
else
10141014
val locals = new mutable.ListBuffer[Symbol]
10151015
for stat <- stats do
1016-
if stat.isDef && stat.symbol.exists then locals += stat.symbol
1016+
if stat.isDef then
1017+
val sym = stat.symbol
1018+
if sym.exists then locals += sym
10171019
locals.toList
10181020

10191021
/** If `tree` is a DefTree, the symbol defined by it, otherwise NoSymbol */

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,10 @@ object Trees {
370370

371371
protected def srcName(using Context): Name =
372372
if name == nme.CONSTRUCTOR then nme.this_
373-
else if symbol.isPackageObject then symbol.owner.name
374-
else name
373+
else
374+
val sym = this.symbol
375+
if sym.isPackageObject then sym.owner.name
376+
else name
375377

376378
/** The position of the name defined by this definition.
377379
* This is a point position if the definition is synthetic, or a range position

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,12 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12001200
tree
12011201
}
12021202

1203+
/** Same as above, but when you already have `tree.symbol` */
1204+
def setDefTree(sym: Symbol)(using Context): ThisTree = {
1205+
if (sym.exists) sym.defTree = tree
1206+
tree
1207+
}
1208+
12031209
/** Make sure tree has given symbol. This is called when typing or unpickling
12041210
* a ValDef or DefDef. It turns out that under very rare circumstances the symbol
12051211
* computed for a tree is not correct. The only known test case is i21755.scala.
@@ -1209,11 +1215,14 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12091215
* corresponding symbol in the superclass. It is not known what are the precise
12101216
* conditions where this happens, but my guess would be that it's connected to the
12111217
* recursion in the self type.
1218+
* As an optimization, returns the symbol.
12121219
*/
1213-
def ensureHasSym(sym: Symbol)(using Context): Unit =
1214-
if sym.exists && sym != tree.symbol then
1215-
typr.println(i"correcting definition symbol from ${tree.symbol.showLocated} to ${sym.showLocated}")
1220+
def ensureHasSym(sym: Symbol)(using Context): Symbol =
1221+
val treeSym = tree.symbol
1222+
if sym.exists && sym != treeSym then
1223+
typr.println(i"correcting definition symbol from ${treeSym.showLocated} to ${sym.showLocated}")
12161224
tree.overwriteType(NamedType(sym.owner.thisType, sym.name, sym.denot))
1225+
treeSym
12171226

12181227
def etaExpandCFT(using Context): Tree =
12191228
def expand(target: Tree, tp: Type)(using Context): Tree = tp match

compiler/src/dotty/tools/dotc/core/Annotations.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import scala.annotation.internal.sharable
1616
object Annotations {
1717

1818
def annotClass(tree: Tree)(using Context) =
19-
if (tree.symbol.isConstructor) tree.symbol.owner
19+
val sym = tree.symbol
20+
if (sym.isConstructor) sym.owner
2021
else tree.tpe.typeSymbol
2122

2223
abstract class Annotation extends Showable {

compiler/src/dotty/tools/dotc/core/TypeEval.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ object TypeEval:
5555
case ConstantType(_) => Some(true)
5656
// constant if the term is constant
5757
case t: TermRef =>
58-
if t.denot.symbol.flagsUNSAFE.is(Flags.Param) then
58+
if t.symbol.flagsUNSAFE.is(Flags.Param) then
5959
// might be substituted later
6060
None
6161
else

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
8080
def addrOfSym(sym: Symbol): Option[Addr] =
8181
symRefs.get(sym)
8282

83-
def preRegister(tree: Tree)(using Context): Unit = tree match {
84-
case tree: MemberDef =>
85-
if (!symRefs.contains(tree.symbol)) symRefs(tree.symbol) = NoAddr
86-
case _ =>
87-
}
83+
def preRegister(tree: Tree)(using Context): Unit = tree match
84+
case tree: MemberDef => symRefs.getOrElseUpdate(tree.symbol, NoAddr)
85+
case _ => ()
8886

8987
def registerDef(sym: Symbol): Unit =
9088
symRefs(sym) = currentAddr
@@ -474,17 +472,18 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
474472
pickleType(tp)
475473
}
476474
case _ =>
475+
val sym = tree.symbol
476+
val ename = sym.targetName
477477
if passesConditionForErroringBestEffortCode(tree.hasType) then
478478
// #19951 The signature of a constructor of a Java annotation is irrelevant
479479
val sig =
480-
if name == nme.CONSTRUCTOR && tree.symbol.exists && tree.symbol.owner.is(JavaAnnotation) then Signature.NotAMethod
480+
if name == nme.CONSTRUCTOR && sym.exists && sym.owner.is(JavaAnnotation) then Signature.NotAMethod
481481
else tree.tpe.signature
482-
var ename = tree.symbol.targetName
483482
val selectFromQualifier =
484483
name.isTypeName
485484
|| qual.isInstanceOf[Hole] // holes have no symbol
486485
|| sig == Signature.NotAMethod // no overload resolution necessary
487-
|| !tree.denot.symbol.exists // polymorphic function type
486+
|| !sym.exists // polymorphic function type
488487
|| tree.denot.asSingleDenotation.isRefinedMethod // refined methods have no defining class symbol
489488
if selectFromQualifier then
490489
writeByte(if name.isTypeName then SELECTtpt else SELECT)
@@ -493,22 +492,22 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
493492
else // select from owner
494493
writeByte(SELECTin)
495494
withLength {
496-
pickleNameAndSig(name, tree.symbol.signature, ename)
495+
pickleNameAndSig(name, sym.signature, ename)
497496
pickleTree(qual)
498-
pickleType(tree.symbol.owner.typeRef)
497+
pickleType(sym.owner.typeRef)
499498
}
500499
else
501500
writeByte(if name.isTypeName then SELECTtpt else SELECT)
502-
val ename = tree.symbol.targetName
503501
pickleNameAndSig(name, Signature.NotAMethod, ename)
504502
pickleTree(qual)
505503
}
506504
case Apply(fun, args) =>
507-
if (fun.symbol eq defn.throwMethod) {
505+
val funSym = fun.symbol
506+
if (funSym eq defn.throwMethod) {
508507
writeByte(THROW)
509508
pickleTree(args.head)
510509
}
511-
else if fun.symbol.originalSignaturePolymorphic.exists then
510+
else if funSym.originalSignaturePolymorphic.exists then
512511
writeByte(APPLYsigpoly)
513512
withLength {
514513
pickleTree(fun)
@@ -520,7 +519,7 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
520519
withLength {
521520
pickleTree(fun)
522521
// #19951 Do not pickle default arguments to Java annotation constructors
523-
if fun.symbol.isClassConstructor && fun.symbol.owner.is(JavaAnnotation) then
522+
if funSym.isClassConstructor && funSym.owner.is(JavaAnnotation) then
524523
for arg <- args do
525524
arg match
526525
case NamedArg(_, Ident(nme.WILDCARD)) => ()

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,8 @@ class TreeUnpickler(reader: TastyReader,
927927
def ValDef(tpt: Tree) =
928928
ta.assignType(untpd.ValDef(sym.name.asTermName, tpt, readRhs(using localCtx)), sym)
929929

930-
def DefDef(paramss: List[ParamClause], tpt: Tree) =
931-
sym.setParamssFromDefs(paramss)
930+
def DefDef(paramss: List[ParamClause], paramsSyms: List[List[Symbol]], tpt: Tree) =
931+
sym.setParamss(paramsSyms)
932932
ta.assignType(
933933
untpd.DefDef(sym.name.asTermName, paramss, tpt, readRhs(using localCtx)),
934934
sym)
@@ -950,18 +950,18 @@ class TreeUnpickler(reader: TastyReader,
950950
case DEFDEF =>
951951
val paramDefss = readParamss()(using localCtx)
952952
val tpt = readTpt()(using localCtx)
953-
val paramss = normalizeIfConstructor(
954-
paramDefss.nestedMap(_.symbol), name == nme.CONSTRUCTOR)
953+
val paramss = paramDefss.nestedMap(_.symbol)
954+
val normalizedParamss = normalizeIfConstructor(paramss, name == nme.CONSTRUCTOR)
955955
val resType =
956956
if name == nme.CONSTRUCTOR then
957-
effectiveResultType(sym, paramss)
957+
effectiveResultType(sym, normalizedParamss)
958958
else if sym.isAllOf(Given | Method) && Feature.enabled(Feature.modularity) then
959-
addParamRefinements(tpt.tpe, paramss)
959+
addParamRefinements(tpt.tpe, normalizedParamss)
960960
else
961961
tpt.tpe
962-
sym.info = methodType(paramss, resType)
962+
sym.info = methodType(normalizedParamss, resType)
963963
nullify(sym)
964-
DefDef(paramDefss, tpt)
964+
DefDef(paramDefss, paramss, tpt)
965965
case VALDEF =>
966966
val tpt = readTpt()(using localCtx)
967967
sym.info = tpt.tpe.suppressIntoIfParam(sym)
@@ -1036,8 +1036,8 @@ class TreeUnpickler(reader: TastyReader,
10361036
}
10371037
}
10381038

1039-
tree.ensureHasSym(sym)
1040-
tree.setDefTree
1039+
val sym1 = tree.ensureHasSym(sym)
1040+
tree.setDefTree(sym1)
10411041
}
10421042

10431043
/** Read enough of parent to determine its type, without reading arguments
@@ -1530,11 +1530,12 @@ class TreeUnpickler(reader: TastyReader,
15301530
tpd.Super(qual, mixId, mixTpe.typeSymbol)
15311531
case APPLY =>
15321532
val fn = readTree()
1533+
val sym = fn.symbol
15331534
val args = until(end)(readTree())
1534-
if fn.symbol.isConstructor then constructorApply(fn, args)
1535-
else if fn.symbol == defn.QuotedRuntime_exprQuote then quotedExpr(fn, args) // decode pre 3.5.0 encoding
1536-
else if fn.symbol == defn.QuotedRuntime_exprSplice then splicedExpr(fn, args) // decode pre 3.5.0 encoding
1537-
else if fn.symbol == defn.QuotedRuntime_exprNestedSplice then nestedSpliceExpr(fn, args) // decode pre 3.5.0 encoding
1535+
if sym.isConstructor then constructorApply(fn, args)
1536+
else if sym == defn.QuotedRuntime_exprQuote then quotedExpr(fn, args) // decode pre 3.5.0 encoding
1537+
else if sym == defn.QuotedRuntime_exprSplice then splicedExpr(fn, args) // decode pre 3.5.0 encoding
1538+
else if sym == defn.QuotedRuntime_exprNestedSplice then nestedSpliceExpr(fn, args) // decode pre 3.5.0 encoding
15381539
else if isSpuriousApply(fn, args) then fn
15391540
else tpd.Apply(fn, args)
15401541
case TYPEAPPLY =>

0 commit comments

Comments
 (0)