File tree Expand file tree Collapse file tree 4 files changed +30
-9
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +30
-9
lines changed Original file line number Diff line number Diff line change @@ -626,15 +626,27 @@ object Symbols {
626626 final def symbol (implicit ev : DontUseSymbolOnSymbol ): Nothing = unsupported(" symbol" )
627627 type DontUseSymbolOnSymbol
628628
629- final def source (implicit ctx : Context ): SourceFile =
630- if (! defTree.isEmpty && ! ctx.erasedTypes) defTree.source
631- else this match {
632- case cls : ClassSymbol => cls.sourceOfClass
633- case _ =>
634- if (denot.is(Module )) denot.moduleClass.source
635- else if (denot.exists) denot.owner.source
636- else NoSource
637- }
629+ final def source (implicit ctx : Context ): SourceFile = {
630+ def valid (src : SourceFile ): SourceFile =
631+ if (src.exists && src.file.extension != " class" ) src
632+ else NoSource
633+
634+ if (! denot.exists) NoSource
635+ else
636+ valid(defTree.source) match {
637+ case NoSource =>
638+ valid(denot.owner.source) match {
639+ case NoSource =>
640+ this match {
641+ case cls : ClassSymbol => valid(cls.sourceOfClass)
642+ case _ if denot.is(Module ) => valid(denot.moduleClass.source)
643+ case _ => NoSource
644+ }
645+ case src => src
646+ }
647+ case src => src
648+ }
649+ }
638650
639651 /** A symbol related to `sym` that is defined in source code.
640652 *
Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ object Inliner {
165165 case tree : SeqLiteral => finalize(tree, untpd.SeqLiteral (transform(tree.elems), transform(tree.elemtpt))(curSource))
166166 case tree : TypeTree => tpd.TypeTree (tree.tpe)(ctx.withSource(curSource)).withSpan(tree.span)
167167 case tree : Bind => finalize(tree, untpd.Bind (tree.name, transform(tree.body))(curSource))
168+ case tree : DefTree => super .transform(tree).setDefTree
168169 case _ => super .transform(tree)
169170 })
170171 assert(transformed.isInstanceOf [EmptyTree [_]] || transformed.isInstanceOf [EmptyValDef [_]] || transformed.source == curSource)
Original file line number Diff line number Diff line change 1+ object Foo {
2+ inline def foo = new { bar(0 ) }
3+
4+ def bar (i : => Int ): Unit = ()
5+ }
Original file line number Diff line number Diff line change 1+ object Test {
2+ val v = Foo .foo
3+ }
You can’t perform that action at this time.
0 commit comments