diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 0bbe5ee7c7ac..af7a3b235717 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -182,6 +182,7 @@ object desugar { tpt = TypeTree(defn.UnitType), rhs = setterRhs ).withMods((mods | Accessor) &~ (CaseAccessor | GivenOrImplicit | Lazy)) + .dropEndMarker() // the end marker should only appear on the getter definition Thicket(vdef1, setter) } else vdef1 @@ -883,6 +884,7 @@ object desugar { val clsTmpl = cpy.Template(impl)(self = clsSelf, body = impl.body) val cls = TypeDef(clsName, clsTmpl) .withMods(mods.toTypeFlags & RetainedModuleClassFlags | ModuleClassCreationFlags) + .withEndMarker(copyFrom = mdef) // copy over the end marker position to the module class def Thicket(modul, classDef(cls).withSpan(mdef.span)) } } @@ -1299,7 +1301,9 @@ object desugar { if (nestedStats.isEmpty) pdef else { val name = packageObjectName(ctx.source) - val grouped = ModuleDef(name, Template(emptyConstructor, Nil, Nil, EmptyValDef, nestedStats)) + val grouped = + ModuleDef(name, Template(emptyConstructor, Nil, Nil, EmptyValDef, nestedStats)) + .withMods(Modifiers(Synthetic)) cpy.PackageDef(pdef)(pdef.pid, topStats :+ grouped) } } diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index d1de1094524c..25b67921fc44 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -327,9 +327,58 @@ object Trees { extension (mdef: untpd.DefTree) def mods: untpd.Modifiers = mdef.rawMods - abstract class NamedDefTree[-T >: Untyped](implicit @constructorOnly src: SourceFile) extends NameTree[T] with DefTree[T] { + sealed trait WithEndMarker[-T >: Untyped]: + self: PackageDef[T] | NamedDefTree[T] => + + import WithEndMarker.* + + final def endSpan(using Context): Span = + if hasEndMarker then + val realName = srcName.stripModuleClassSuffix.lastPart + span.withStart(span.end - realName.length) + else + NoSpan + + /** The name in source code that represents this construct, + * and is the name that the user must write to create a valid + * end marker. + * e.g. a constructor definition is terminated in the source + * code by `end this`, so it's `srcName` should return `this`. + */ + protected def srcName(using Context): Name + + final def withEndMarker(): self.type = + self.withAttachment(HasEndMarker, ()) + + final def withEndMarker(copyFrom: WithEndMarker[?]): self.type = + if copyFrom.hasEndMarker then + this.withEndMarker() + else + this + + final def dropEndMarker(): self.type = + self.removeAttachment(HasEndMarker) + this + + protected def hasEndMarker: Boolean = self.hasAttachment(HasEndMarker) + + object WithEndMarker: + /** Property key that signals the tree was terminated + * with an `end` marker in the source code + */ + private val HasEndMarker: Property.StickyKey[Unit] = Property.StickyKey() + + end WithEndMarker + + abstract class NamedDefTree[-T >: Untyped](implicit @constructorOnly src: SourceFile) + extends NameTree[T] with DefTree[T] with WithEndMarker[T] { type ThisTree[-T >: Untyped] <: NamedDefTree[T] + protected def srcName(using Context): Name = + if name == nme.CONSTRUCTOR then nme.this_ + else if symbol.isPackageObject then symbol.owner.name + else name + /** The position of the name defined by this definition. * This is a point position if the definition is synthetic, or a range position * if the definition comes from source. @@ -342,7 +391,7 @@ object Trees { val point = span.point if (rawMods.is(Synthetic) || span.isSynthetic || name.toTermName == nme.ERROR) Span(point) else { - val realName = name.stripModuleClassSuffix.lastPart + val realName = srcName.stripModuleClassSuffix.lastPart Span(point, point + realName.length, point) } } @@ -857,9 +906,10 @@ object Trees { /** package pid { stats } */ case class PackageDef[-T >: Untyped] private[ast] (pid: RefTree[T], stats: List[Tree[T]])(implicit @constructorOnly src: SourceFile) - extends ProxyTree[T] { + extends ProxyTree[T] with WithEndMarker[T] { type ThisTree[-T >: Untyped] = PackageDef[T] def forwardTo: RefTree[T] = pid + protected def srcName(using Context): Name = pid.name } /** arg @annot */ diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 86144347f3fe..0f3ae09d1879 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1275,7 +1275,13 @@ object Parsers { def checkEndMarker[T <: Tree](stats: ListBuffer[T]): Unit = - def matches(stat: Tree): Boolean = stat match + def updateSpanOfLast(last: T): Unit = + last match + case last: WithEndMarker[t] => last.withEndMarker() + case _ => + last.span = last.span.withEnd(in.lastCharOffset) + + def matches(stat: T): Boolean = stat match case stat: MemberDef if !stat.name.isEmpty => if stat.name == nme.CONSTRUCTOR then in.token == THIS else in.isIdent && in.name == stat.name.toTermName @@ -1283,8 +1289,6 @@ object Parsers { in.token == IDENTIFIER && in.name == nme.extension case PackageDef(pid: RefTree, _) => in.isIdent && in.name == pid.name - case PatDef(_, IdPattern(id, _) :: Nil, _, _) => - in.isIdent && in.name == id.name case stat: MemberDef if stat.mods.is(Given) => in.token == GIVEN case _: PatDef => in.token == VAL case _: If => in.token == IF @@ -1295,9 +1299,16 @@ object Parsers { case _: (ForYield | ForDo) => in.token == FOR case _ => false + def matchesAndSetEnd(last: T): Boolean = { + val didMatch = matches(last) + if didMatch then + updateSpanOfLast(last) + didMatch + } + if in.token == END then val start = in.skipToken() - if stats.isEmpty || !matches(stats.last) then + if stats.isEmpty || !matchesAndSetEnd(stats.last) then syntaxError("misaligned end marker", Span(start, in.lastCharOffset)) in.token = IDENTIFIER // Leaving it as the original token can confuse newline insertion in.nextToken() diff --git a/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala b/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala index 89cf6f3df7d5..b233488b9a8c 100644 --- a/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala +++ b/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala @@ -6,7 +6,7 @@ import core._ import Phases._ import ast.tpd._ import ast.untpd.given -import ast.Trees.mods +import ast.Trees.{mods, WithEndMarker} import Contexts._ import Symbols._ import Flags._ @@ -139,47 +139,46 @@ class ExtractSemanticDB extends Phase: case tree => registerDefinition(tree.symbol, tree.span, Set.empty, tree.source) tree.stats.foreach(traverse) case tree: NamedDefTree => - if tree.symbol.isAllOf(ModuleValCreationFlags) then - return - if !excludeDef(tree.symbol) - && tree.span.hasLength then - registerDefinition(tree.symbol, tree.nameSpan, symbolKinds(tree), tree.source) - val privateWithin = tree.symbol.privateWithin - if privateWithin.exists then - registerUseGuarded(None, privateWithin, spanOfSymbol(privateWithin, tree.span, tree.source), tree.source) - else if !excludeSymbol(tree.symbol) then - registerSymbol(tree.symbol, symbolName(tree.symbol), symbolKinds(tree)) - tree match - case tree: ValDef - if tree.symbol.isAllOf(EnumValue) => - tree.rhs match - case Block(TypeDef(_, template: Template) :: _, _) => // simple case with specialised extends clause - template.parents.filter(!_.span.isZeroExtent).foreach(traverse) - case _ => // calls $new - case tree: ValDef - if tree.symbol.isSelfSym => - if tree.tpt.span.hasLength then - traverse(tree.tpt) - case tree: DefDef - if tree.symbol.isConstructor => // ignore typeparams for secondary ctors - tree.trailingParamss.foreach(_.foreach(traverse)) - traverse(tree.rhs) - case tree: (DefDef | ValDef) - if tree.symbol.isSyntheticWithIdent => + if !tree.symbol.isAllOf(ModuleValCreationFlags) then + if !excludeDef(tree.symbol) + && tree.span.hasLength then + registerDefinition(tree.symbol, tree.nameSpan, symbolKinds(tree), tree.source) + val privateWithin = tree.symbol.privateWithin + if privateWithin.exists then + registerUseGuarded(None, privateWithin, spanOfSymbol(privateWithin, tree.span, tree.source), tree.source) + else if !excludeSymbol(tree.symbol) then + registerSymbol(tree.symbol, symbolName(tree.symbol), symbolKinds(tree)) tree match - case tree: DefDef => - tree.paramss.foreach(_.foreach(param => registerSymbolSimple(param.symbol))) - case tree: ValDef if tree.symbol.is(Given) => traverse(tree.tpt) - case _ => - if !tree.symbol.isGlobal then - localBodies(tree.symbol) = tree.rhs - // ignore rhs - case PatternValDef(pat, rhs) => - traverse(rhs) - PatternValDef.collectPats(pat).foreach(traverse) - case tree => - if !excludeChildren(tree.symbol) then - traverseChildren(tree) + case tree: ValDef + if tree.symbol.isAllOf(EnumValue) => + tree.rhs match + case Block(TypeDef(_, template: Template) :: _, _) => // simple case with specialised extends clause + template.parents.filter(!_.span.isZeroExtent).foreach(traverse) + case _ => // calls $new + case tree: ValDef + if tree.symbol.isSelfSym => + if tree.tpt.span.hasLength then + traverse(tree.tpt) + case tree: DefDef + if tree.symbol.isConstructor => // ignore typeparams for secondary ctors + tree.trailingParamss.foreach(_.foreach(traverse)) + traverse(tree.rhs) + case tree: (DefDef | ValDef) + if tree.symbol.isSyntheticWithIdent => + tree match + case tree: DefDef => + tree.paramss.foreach(_.foreach(param => registerSymbolSimple(param.symbol))) + case tree: ValDef if tree.symbol.is(Given) => traverse(tree.tpt) + case _ => + if !tree.symbol.isGlobal then + localBodies(tree.symbol) = tree.rhs + // ignore rhs + case PatternValDef(pat, rhs) => + traverse(rhs) + PatternValDef.collectPats(pat).foreach(traverse) + case tree => + if !excludeChildren(tree.symbol) then + traverseChildren(tree) case tree: Template => val ctorSym = tree.constr.symbol if !excludeDef(ctorSym) then @@ -240,6 +239,13 @@ class ExtractSemanticDB extends Phase: case _ => traverseChildren(tree) + tree match + case tree: WithEndMarker[t] => + val endSpan = tree.endSpan + if endSpan.exists then + registerUseGuarded(None, tree.symbol, endSpan, tree.source) + case _ => + end traverse private def funParamSymbol(funSym: Symbol)(using Context): Name => String = diff --git a/tests/semanticdb/expect/Annotations.expect.scala b/tests/semanticdb/expect/Annotations.expect.scala index fb89c0e94abc..14976ad8aa2f 100644 --- a/tests/semanticdb/expect/Annotations.expect.scala +++ b/tests/semanticdb/expect/Annotations.expect.scala @@ -21,7 +21,7 @@ class Annotations/*<-annot::Annotations#*/[@TypeParameterAnnotation/*->com::java class B/*<-annot::B#*/ @ConstructorAnnotation/*->com::javacp::annot::ConstructorAnnotation#*/()(x/*<-annot::B#x.*/: Int/*->scala::Int#*/) { @ConstructorAnnotation/*->com::javacp::annot::ConstructorAnnotation#*/ - def this()/*<-annot::B#``(+1).*/ = this(42) + def this/*<-annot::B#``(+1).*/() = this(42) } @ObjectAnnotation/*->com::javacp::annot::ObjectAnnotation#*/ diff --git a/tests/semanticdb/expect/AnonymousGiven.expect.scala b/tests/semanticdb/expect/AnonymousGiven.expect.scala index 68800202b6c1..c28b9d5e770d 100644 --- a/tests/semanticdb/expect/AnonymousGiven.expect.scala +++ b/tests/semanticdb/expect/AnonymousGiven.expect.scala @@ -2,4 +2,4 @@ package angiven trait Foo/*<-angiven::Foo#*/ -/*<-angiven::AnonymousGiven$package.*/def bar/*<-angiven::AnonymousGiven$package.bar().*/(using Foo/*->angiven::Foo#*/) = 42 \ No newline at end of file +def bar/*<-angiven::AnonymousGiven$package.bar().*/(using Foo/*->angiven::Foo#*/) = 42 \ No newline at end of file diff --git a/tests/semanticdb/expect/EndMarkers.expect.scala b/tests/semanticdb/expect/EndMarkers.expect.scala new file mode 100644 index 000000000000..76d43a91127c --- /dev/null +++ b/tests/semanticdb/expect/EndMarkers.expect.scala @@ -0,0 +1,59 @@ +package endmarkers: + + class MultiCtor/*<-endmarkers::MultiCtor#*/(val i/*<-endmarkers::MultiCtor#i.*/: Int/*->scala::Int#*/): + def this/*<-endmarkers::MultiCtor#``(+1).*/() = + this(23) + end this/*->endmarkers::MultiCtor#``(+1).*/ + end MultiCtor/*->endmarkers::MultiCtor#*/ + + def topLevelMethod/*<-endmarkers::EndMarkers$package.topLevelMethod().*/: String/*->scala::Predef.String#*/ = + "hello" + end topLevelMethod/*->endmarkers::EndMarkers$package.topLevelMethod().*/ + + val topLevelVal/*<-endmarkers::EndMarkers$package.topLevelVal.*/: Int/*->scala::Int#*/ = + 23 + end topLevelVal/*->endmarkers::EndMarkers$package.topLevelVal.*/ + + var topLevelVar/*<-endmarkers::EndMarkers$package.topLevelVar().*/: String/*->scala::Predef.String#*/ = + "" + end topLevelVar/*->endmarkers::EndMarkers$package.topLevelVar().*/ + + class Container/*<-endmarkers::Container#*/: + + def foo/*<-endmarkers::Container#foo().*/ = + (/*->scala::Tuple3.apply().*/1,2,3) + end foo/*->endmarkers::Container#foo().*/ + + val bar/*<-endmarkers::Container#bar.*/ = + (/*->scala::Tuple3.apply().*/4,5,6) + end bar/*->endmarkers::Container#bar.*/ + + var baz/*<-endmarkers::Container#baz().*/ = + 15 + end baz/*->endmarkers::Container#baz().*/ + + end Container/*->endmarkers::Container#*/ + + def topLevelWithLocals/*<-endmarkers::EndMarkers$package.topLevelWithLocals().*/: Unit/*->scala::Unit#*/ = + + val localVal/*<-local0*/ = + 37 + end localVal/*->local0*/ + + var localVar/*<-local1*/ = + 43 + end localVar/*->local1*/ + + def localDef/*<-local2*/ = + 97 + end localDef/*->local2*/ + + end topLevelWithLocals/*->endmarkers::EndMarkers$package.topLevelWithLocals().*/ + + object TestObj/*<-endmarkers::TestObj.*/: + + def foo/*<-endmarkers::TestObj.foo().*/ = 23 + + end TestObj/*->endmarkers::TestObj.*/ + +end endmarkers diff --git a/tests/semanticdb/expect/EndMarkers.scala b/tests/semanticdb/expect/EndMarkers.scala new file mode 100644 index 000000000000..c7ae04898ebd --- /dev/null +++ b/tests/semanticdb/expect/EndMarkers.scala @@ -0,0 +1,59 @@ +package endmarkers: + + class MultiCtor(val i: Int): + def this() = + this(23) + end this + end MultiCtor + + def topLevelMethod: String = + "hello" + end topLevelMethod + + val topLevelVal: Int = + 23 + end topLevelVal + + var topLevelVar: String = + "" + end topLevelVar + + class Container: + + def foo = + (1,2,3) + end foo + + val bar = + (4,5,6) + end bar + + var baz = + 15 + end baz + + end Container + + def topLevelWithLocals: Unit = + + val localVal = + 37 + end localVal + + var localVar = + 43 + end localVar + + def localDef = + 97 + end localDef + + end topLevelWithLocals + + object TestObj: + + def foo = 23 + + end TestObj + +end endmarkers diff --git a/tests/semanticdb/expect/EndMarkers2.expect.scala b/tests/semanticdb/expect/EndMarkers2.expect.scala new file mode 100644 index 000000000000..61b8f8093a8e --- /dev/null +++ b/tests/semanticdb/expect/EndMarkers2.expect.scala @@ -0,0 +1,7 @@ +package object endmarkers2/*<-endmarkers2::package.*/: + + type Foo/*<-endmarkers2::package.Foo#*/ = + Unit/*->scala::Unit#*/ + end Foo/*->endmarkers2::package.Foo#*/ + +end endmarkers2/*->endmarkers2::package.*/ diff --git a/tests/semanticdb/expect/EndMarkers2.scala b/tests/semanticdb/expect/EndMarkers2.scala new file mode 100644 index 000000000000..377696ca8a79 --- /dev/null +++ b/tests/semanticdb/expect/EndMarkers2.scala @@ -0,0 +1,7 @@ +package object endmarkers2: + + type Foo = + Unit + end Foo + +end endmarkers2 diff --git a/tests/semanticdb/expect/Extension.expect.scala b/tests/semanticdb/expect/Extension.expect.scala index d96dcd4c87c8..536886368502 100644 --- a/tests/semanticdb/expect/Extension.expect.scala +++ b/tests/semanticdb/expect/Extension.expect.scala @@ -1,6 +1,6 @@ package ext -/*<-ext::Extension$package.*/extension (s/*<-ext::Extension$package.foo().(s)*//*<-ext::Extension$package.`#*#`().(s)*/: String/*->scala::Predef.String#*/) +extension (s/*<-ext::Extension$package.foo().(s)*//*<-ext::Extension$package.`#*#`().(s)*/: String/*->scala::Predef.String#*/) def foo/*<-ext::Extension$package.foo().*/: Int/*->scala::Int#*/ = 42 def #*#/*<-ext::Extension$package.`#*#`().*/ (i/*<-ext::Extension$package.`#*#`().(i)*/: Int/*->scala::Int#*/): (String/*->scala::Predef.String#*/, Int/*->scala::Int#*/) = (/*->scala::Tuple2.apply().*/s/*->ext::Extension$package.`#*#`().(s)*/, i/*->ext::Extension$package.`#*#`().(i)*/) diff --git a/tests/semanticdb/expect/InventedNames.expect.scala b/tests/semanticdb/expect/InventedNames.expect.scala index 5ff2f20213bd..f1ac3a4ae0cb 100644 --- a/tests/semanticdb/expect/InventedNames.expect.scala +++ b/tests/semanticdb/expect/InventedNames.expect.scala @@ -11,7 +11,7 @@ trait Z/*<-givens::Z#*/[T/*<-givens::Z#[T]*/]: -/*<-givens::InventedNames$package.*/given intValue/*<-givens::InventedNames$package.intValue.*/: Int/*->scala::Int#*/ = 4 +given intValue/*<-givens::InventedNames$package.intValue.*/: Int/*->scala::Int#*/ = 4 given /*<-givens::InventedNames$package.given_String.*/String/*->scala::Predef.String#*/ = "str" given /*<-givens::InventedNames$package.given_Double().*/(using Int/*->scala::Int#*/): Double/*->scala::Double#*/ = 4.0 given /*<-givens::InventedNames$package.given_List_T().*/[T/*<-givens::InventedNames$package.given_List_T().[T]*/]: List/*->scala::package.List#*/[T/*->givens::InventedNames$package.given_List_T().[T]*/] = Nil/*->scala::package.Nil.*/ diff --git a/tests/semanticdb/expect/RightAssociativeExtension.expect.scala b/tests/semanticdb/expect/RightAssociativeExtension.expect.scala index 38f81d0154ef..c32fd1becfda 100644 --- a/tests/semanticdb/expect/RightAssociativeExtension.expect.scala +++ b/tests/semanticdb/expect/RightAssociativeExtension.expect.scala @@ -1,6 +1,6 @@ package ext -/*<-ext::RightAssociativeExtension$package.*/extension (s/*<-ext::RightAssociativeExtension$package.`:*:`().(s)*/: String/*->scala::Predef.String#*/) +extension (s/*<-ext::RightAssociativeExtension$package.`:*:`().(s)*/: String/*->scala::Predef.String#*/) def :*:/*<-ext::RightAssociativeExtension$package.`:*:`().*/ (i/*<-ext::RightAssociativeExtension$package.`:*:`().(i)*/: Int/*->scala::Int#*/): (String/*->scala::Predef.String#*/, Int/*->scala::Int#*/) = (/*->scala::Tuple2.apply().*/s/*->ext::RightAssociativeExtension$package.`:*:`().(s)*/, i/*->ext::RightAssociativeExtension$package.`:*:`().(i)*/) val b/*<-ext::RightAssociativeExtension$package.b.*/ = "foo" :*:/*->ext::RightAssociativeExtension$package.`:*:`().*/ 23 \ No newline at end of file diff --git a/tests/semanticdb/expect/exports-package.expect.scala b/tests/semanticdb/expect/exports-package.expect.scala index 79c0f5b16e53..512b68dcc842 100644 --- a/tests/semanticdb/expect/exports-package.expect.scala +++ b/tests/semanticdb/expect/exports-package.expect.scala @@ -1,3 +1,3 @@ package exports -/*<-exports::`exports-package$package`.*/export example.{Decoder/*<-exports::`exports-package$package`.Decoder#*/, Encoder/*<-exports::`exports-package$package`.Encoder#*/, Codec/*<-exports::`exports-package$package`.Codec#*/} +export example.{Decoder/*<-exports::`exports-package$package`.Decoder#*/, Encoder/*<-exports::`exports-package$package`.Encoder#*/, Codec/*<-exports::`exports-package$package`.Codec#*/} diff --git a/tests/semanticdb/expect/i9727.expect.scala b/tests/semanticdb/expect/i9727.expect.scala index 017da086d4b5..4cbe6761906f 100644 --- a/tests/semanticdb/expect/i9727.expect.scala +++ b/tests/semanticdb/expect/i9727.expect.scala @@ -1,5 +1,5 @@ package i9727 class Test/*<-i9727::Test#*/(a/*<-i9727::Test#a.*/: Int/*->scala::Int#*/) -/*<-i9727::i9727$package.*/val a/*<-i9727::i9727$package.a.*/ = new Test/*->i9727::Test#*/(1) +val a/*<-i9727::i9727$package.a.*/ = new Test/*->i9727::Test#*/(1) val b/*<-i9727::i9727$package.b.*/ = new Test/*->i9727::Test#*/(2) diff --git a/tests/semanticdb/expect/semanticdb-Flags.expect.scala b/tests/semanticdb/expect/semanticdb-Flags.expect.scala index fe920433e231..7166a5da9859 100644 --- a/tests/semanticdb/expect/semanticdb-Flags.expect.scala +++ b/tests/semanticdb/expect/semanticdb-Flags.expect.scala @@ -2,14 +2,14 @@ package flags import scala.language/*->scala::language.*/.experimental/*->scala::language.experimental.*/.macros/*->scala::language.experimental.macros.*/ -package object p { - p/*<-flags::p::package.*/rivate lazy val x/*<-flags::p::package.x.*/ = 1 +package object p/*<-flags::p::package.*/ { + private lazy val x/*<-flags::p::package.x.*/ = 1 protected implicit var y/*<-flags::p::package.y().*/: Int/*->scala::Int#*/ = 2 def z/*<-flags::p::package.z().*/(pp/*<-flags::p::package.z().(pp)*/: Int/*->scala::Int#*/) = 3 def m/*<-flags::p::package.m().*/[TT/*<-flags::p::package.m().[TT]*/]: Int/*->scala::Int#*/ = macro ???/*->scala::Predef.`???`().*/ abstract class C/*<-flags::p::package.C#*/[+T/*<-flags::p::package.C#[T]*/, -U/*<-flags::p::package.C#[U]*/, V/*<-flags::p::package.C#[V]*/](x/*<-flags::p::package.C#x.*/: T/*->flags::p::package.C#[T]*/, y/*<-flags::p::package.C#y.*/: U/*->flags::p::package.C#[U]*/, z/*<-flags::p::package.C#z.*/: V/*->flags::p::package.C#[V]*/) { - def this()/*<-flags::p::package.C#``(+1).*/ = this(???/*->scala::Predef.`???`().*/, ???/*->scala::Predef.`???`().*/, ???/*->scala::Predef.`???`().*/) - def this(t/*<-flags::p::package.C#``(+2).*//*<-flags::p::package.C#``(+2).(t)*/: T/*->flags::p::package.C#[T]*/) = this(t/*->flags::p::package.C#``(+2).(t)*/, ???/*->scala::Predef.`???`().*/, ???/*->scala::Predef.`???`().*/) + def this/*<-flags::p::package.C#``(+1).*/() = this(???/*->scala::Predef.`???`().*/, ???/*->scala::Predef.`???`().*/, ???/*->scala::Predef.`???`().*/) + def this/*<-flags::p::package.C#``(+2).*/(t/*<-flags::p::package.C#``(+2).(t)*/: T/*->flags::p::package.C#[T]*/) = this(t/*->flags::p::package.C#``(+2).(t)*/, ???/*->scala::Predef.`???`().*/, ???/*->scala::Predef.`???`().*/) def w/*<-flags::p::package.C#w().*/: Int/*->scala::Int#*/ } type T1/*<-flags::p::package.T1#*/ = Int/*->scala::Int#*/ diff --git a/tests/semanticdb/expect/toplevel.expect.scala b/tests/semanticdb/expect/toplevel.expect.scala index a856d673e68c..dfb0cc5de508 100644 --- a/tests/semanticdb/expect/toplevel.expect.scala +++ b/tests/semanticdb/expect/toplevel.expect.scala @@ -1,6 +1,7 @@ -/*<-_empty_::toplevel$package.*/inline val a/*<-_empty_::toplevel$package.a.*/ = "" +inline val a/*<-_empty_::toplevel$package.a.*/ = "" extension (x/*<-_empty_::toplevel$package.combine().(x)*/: Int/*->scala::Int#*/) def combine/*<-_empty_::toplevel$package.combine().*/ (y/*<-_empty_::toplevel$package.combine().(y)*/: Int/*->scala::Int#*/) = x/*->_empty_::toplevel$package.combine().(x)*/ +/*->scala::Int#`+`(+4).*/ y/*->_empty_::toplevel$package.combine().(y)*/ def combine/*<-_empty_::toplevel$package.combine(+1).*/(x/*<-_empty_::toplevel$package.combine(+1).(x)*/: Int/*->scala::Int#*/, y/*<-_empty_::toplevel$package.combine(+1).(y)*/: Int/*->scala::Int#*/, z/*<-_empty_::toplevel$package.combine(+1).(z)*/: Int/*->scala::Int#*/) = x/*->_empty_::toplevel$package.combine(+1).(x)*/ +/*->scala::Int#`+`(+4).*/ y/*->_empty_::toplevel$package.combine(+1).(y)*/ +/*->scala::Int#`+`(+4).*/ z/*->_empty_::toplevel$package.combine(+1).(z)*/ def combine/*<-_empty_::toplevel$package.combine(+2).*/ = 0 def foo/*<-_empty_::toplevel$package.foo().*/ = "foo" /*<-_empty_::MyProgram#*//*->_empty_::toplevel$package.MyProgram().*//*->scala::util::CommandLineParser.parseArgument().*//*->_empty_::MyProgram#main().(args)*//*->scala::util::CommandLineParser.FromString.given_FromString_Int.*//*->scala::util::CommandLineParser.showError().*//*->local0*/@main/*->scala::main#*/ def MyProgram/*<-_empty_::toplevel$package.MyProgram().*/(times/*<-_empty_::toplevel$package.MyProgram().(times)*/: Int/*->scala::Int#*/): Unit/*->scala::Unit#*/ = (/*->scala::LowPriorityImplicits#intWrapper().*/1 to/*->scala::runtime::RichInt#to().*/ times/*->_empty_::toplevel$package.MyProgram().(times)*/) foreach/*->scala::collection::immutable::Range#foreach().*/ (_ => println/*->scala::Predef.println(+1).*/("hello")) +def fooRef/*<-_empty_::toplevel$package.fooRef().*/ = toplevel$package/*->_empty_::toplevel$package.*/.foo/*->_empty_::toplevel$package.foo().*/ diff --git a/tests/semanticdb/expect/toplevel.scala b/tests/semanticdb/expect/toplevel.scala index 5dae4ccadd5e..e6af17e14953 100644 --- a/tests/semanticdb/expect/toplevel.scala +++ b/tests/semanticdb/expect/toplevel.scala @@ -4,3 +4,4 @@ def combine(x: Int, y: Int, z: Int) = x + y + z def combine = 0 def foo = "foo" @main def MyProgram(times: Int): Unit = (1 to times) foreach (_ => println("hello")) +def fooRef = toplevel$package.foo diff --git a/tests/semanticdb/metac.expect b/tests/semanticdb/metac.expect index 5c741a5acf74..00ed8c849766 100644 --- a/tests/semanticdb/metac.expect +++ b/tests/semanticdb/metac.expect @@ -252,7 +252,7 @@ Occurrences: [21:33..21:34): x <- annot/B#x. [21:36..21:39): Int -> scala/Int# [22:3..22:24): ConstructorAnnotation -> com/javacp/annot/ConstructorAnnotation# -[23:6..23:12): <- annot/B#``(+1). +[23:6..23:10): <- annot/B#``(+1). [23:20..23:20): -> annot/B#``(). [26:1..26:17): ObjectAnnotation -> com/javacp/annot/ObjectAnnotation# [27:7..27:8): M <- annot/M. @@ -338,7 +338,7 @@ Uri => AnonymousGiven.scala Text => empty Language => Scala Symbols => 5 entries -Occurrences => 6 entries +Occurrences => 5 entries Symbols: angiven/AnonymousGiven$package. => final package object angiven @@ -351,7 +351,6 @@ Occurrences: [0:8..0:15): angiven <- angiven/ [2:0..2:0): <- angiven/Foo#``(). [2:6..2:9): Foo <- angiven/Foo# -[4:0..4:0): <- angiven/AnonymousGiven$package. [4:4..4:7): bar <- angiven/AnonymousGiven$package.bar(). [4:14..4:17): Foo -> angiven/Foo# @@ -658,6 +657,109 @@ Occurrences: [0:8..0:15): example <- example/ [2:7..2:18): EmptyObject <- example/EmptyObject. +expect/EndMarkers.scala +----------------------- + +Summary: +Schema => SemanticDB v4 +Uri => EndMarkers.scala +Text => empty +Language => Scala +Symbols => 24 entries +Occurrences => 42 entries + +Symbols: +endmarkers/Container# => class Container +endmarkers/Container#``(). => primary ctor +endmarkers/Container#`baz_=`(). => var method baz_= +endmarkers/Container#`baz_=`().(x$1) => param x$1 +endmarkers/Container#bar. => val method bar +endmarkers/Container#baz(). => var method baz +endmarkers/Container#foo(). => method foo +endmarkers/EndMarkers$package. => final package object endmarkers +endmarkers/EndMarkers$package.`topLevelVar_=`(). => var method topLevelVar_= +endmarkers/EndMarkers$package.`topLevelVar_=`().(x$1) => param x$1 +endmarkers/EndMarkers$package.topLevelMethod(). => method topLevelMethod +endmarkers/EndMarkers$package.topLevelVal. => val method topLevelVal +endmarkers/EndMarkers$package.topLevelVar(). => var method topLevelVar +endmarkers/EndMarkers$package.topLevelWithLocals(). => method topLevelWithLocals +endmarkers/MultiCtor# => class MultiCtor +endmarkers/MultiCtor#``(). => primary ctor +endmarkers/MultiCtor#``().(i) => val param i +endmarkers/MultiCtor#``(+1). => ctor +endmarkers/MultiCtor#i. => val method i +endmarkers/TestObj. => final object TestObj +endmarkers/TestObj.foo(). => method foo +local0 => val local localVal +local1 => var local localVar +local2 => local localDef + +Occurrences: +[0:8..0:18): endmarkers <- endmarkers/ +[2:8..2:17): MultiCtor <- endmarkers/MultiCtor# +[2:17..2:17): <- endmarkers/MultiCtor#``(). +[2:22..2:23): i <- endmarkers/MultiCtor#i. +[2:25..2:28): Int -> scala/Int# +[3:8..3:12): <- endmarkers/MultiCtor#``(+1). +[4:11..4:11): -> endmarkers/MultiCtor#``(). +[5:8..5:12): this -> endmarkers/MultiCtor#``(+1). +[6:6..6:15): MultiCtor -> endmarkers/MultiCtor# +[8:6..8:20): topLevelMethod <- endmarkers/EndMarkers$package.topLevelMethod(). +[8:22..8:28): String -> scala/Predef.String# +[10:6..10:20): topLevelMethod -> endmarkers/EndMarkers$package.topLevelMethod(). +[12:6..12:17): topLevelVal <- endmarkers/EndMarkers$package.topLevelVal. +[12:19..12:22): Int -> scala/Int# +[14:6..14:17): topLevelVal -> endmarkers/EndMarkers$package.topLevelVal. +[16:6..16:17): topLevelVar <- endmarkers/EndMarkers$package.topLevelVar(). +[16:19..16:25): String -> scala/Predef.String# +[18:6..18:17): topLevelVar -> endmarkers/EndMarkers$package.topLevelVar(). +[20:8..20:17): Container <- endmarkers/Container# +[22:4..22:4): <- endmarkers/Container#``(). +[22:8..22:11): foo <- endmarkers/Container#foo(). +[23:7..23:7): -> scala/Tuple3.apply(). +[24:8..24:11): foo -> endmarkers/Container#foo(). +[26:8..26:11): bar <- endmarkers/Container#bar. +[27:7..27:7): -> scala/Tuple3.apply(). +[28:8..28:11): bar -> endmarkers/Container#bar. +[30:8..30:11): baz <- endmarkers/Container#baz(). +[32:8..32:11): baz -> endmarkers/Container#baz(). +[34:6..34:15): Container -> endmarkers/Container# +[36:6..36:24): topLevelWithLocals <- endmarkers/EndMarkers$package.topLevelWithLocals(). +[36:26..36:30): Unit -> scala/Unit# +[38:8..38:16): localVal <- local0 +[40:8..40:16): localVal -> local0 +[42:8..42:16): localVar <- local1 +[44:8..44:16): localVar -> local1 +[46:8..46:16): localDef <- local2 +[48:8..48:16): localDef -> local2 +[50:6..50:24): topLevelWithLocals -> endmarkers/EndMarkers$package.topLevelWithLocals(). +[52:9..52:16): TestObj <- endmarkers/TestObj. +[54:8..54:11): foo <- endmarkers/TestObj.foo(). +[56:6..56:13): TestObj -> endmarkers/TestObj. +[58:4..58:14): endmarkers -> endmarkers/ + +expect/EndMarkers2.scala +------------------------ + +Summary: +Schema => SemanticDB v4 +Uri => EndMarkers2.scala +Text => empty +Language => Scala +Symbols => 2 entries +Occurrences => 5 entries + +Symbols: +endmarkers2/package. => final package object endmarkers2 +endmarkers2/package.Foo# => type Foo + +Occurrences: +[0:15..0:26): endmarkers2 <- endmarkers2/package. +[2:7..2:10): Foo <- endmarkers2/package.Foo# +[3:4..3:8): Unit -> scala/Unit# +[4:6..4:9): Foo -> endmarkers2/package.Foo# +[6:4..6:15): endmarkers2 -> endmarkers2/package. + expect/EnumVal.scala -------------------- @@ -1174,7 +1276,7 @@ Uri => Extension.scala Text => empty Language => Scala Symbols => 8 entries -Occurrences => 19 entries +Occurrences => 18 entries Symbols: ext/Extension$package. => final package object ext @@ -1188,7 +1290,6 @@ ext/Extension$package.foo().(s) => param s Occurrences: [0:8..0:11): ext <- ext/ -[2:0..2:0): <- ext/Extension$package. [2:11..2:12): s <- ext/Extension$package.foo().(s) [2:11..2:12): s <- ext/Extension$package.`#*#`().(s) [2:14..2:20): String -> scala/Predef.String# @@ -1643,7 +1744,7 @@ Uri => InventedNames.scala Text => empty Language => Scala Symbols => 45 entries -Occurrences => 73 entries +Occurrences => 72 entries Symbols: givens/InventedNames$package. => final package object givens @@ -1708,7 +1809,6 @@ Occurrences: [9:6..9:9): doZ <- givens/Z#doZ(). [9:11..9:15): List -> scala/package.List# [9:16..9:17): T -> givens/Z#[T] -[13:0..13:0): <- givens/InventedNames$package. [13:6..13:14): intValue <- givens/InventedNames$package.intValue. [13:16..13:19): Int -> scala/Int# [14:6..14:6): <- givens/InventedNames$package.given_String. @@ -2627,7 +2727,7 @@ Uri => RightAssociativeExtension.scala Text => empty Language => Scala Symbols => 5 entries -Occurrences => 14 entries +Occurrences => 13 entries Symbols: ext/RightAssociativeExtension$package. => final package object ext @@ -2638,7 +2738,6 @@ ext/RightAssociativeExtension$package.b. => val method b Occurrences: [0:8..0:11): ext <- ext/ -[2:0..2:0): <- ext/RightAssociativeExtension$package. [2:11..2:12): s <- ext/RightAssociativeExtension$package.`:*:`().(s) [2:14..2:20): String -> scala/Predef.String# [3:6..3:9): :*: <- ext/RightAssociativeExtension$package.`:*:`(). @@ -3367,7 +3466,7 @@ Uri => exports-package.scala Text => empty Language => Scala Symbols => 4 entries -Occurrences => 6 entries +Occurrences => 5 entries Symbols: exports/`exports-package$package`. => final package object exports @@ -3377,7 +3476,6 @@ exports/`exports-package$package`.Encoder# => final type Encoder Occurrences: [0:8..0:15): exports <- exports/ -[2:0..2:0): <- exports/`exports-package$package`. [2:7..2:14): example -> exports/example/ [2:16..2:23): Decoder <- exports/`exports-package$package`.Decoder# [2:25..2:32): Encoder <- exports/`exports-package$package`.Encoder# @@ -3412,7 +3510,7 @@ Uri => i9727.scala Text => empty Language => Scala Symbols => 7 entries -Occurrences => 12 entries +Occurrences => 11 entries Symbols: i9727/Test# => class Test @@ -3429,7 +3527,6 @@ Occurrences: [2:10..2:10): <- i9727/Test#``(). [2:11..2:12): a <- i9727/Test#a. [2:14..2:17): Int -> scala/Int# -[3:0..3:0): <- i9727/i9727$package. [3:4..3:5): a <- i9727/i9727$package.a. [3:12..3:16): Test -> i9727/Test# [3:16..3:16): -> i9727/Test#``(). @@ -3729,7 +3826,7 @@ Occurrences: [2:13..2:21): language -> scala/language. [2:22..2:34): experimental -> scala/language.experimental. [2:35..2:41): macros -> scala/language.experimental.macros. -[4:15..5:3): <- flags/p/package. +[4:15..4:16): p <- flags/p/package. [5:2..5:3): p -> flags/p/ [5:19..5:20): x <- flags/p/package.x. [6:25..6:26): y <- flags/p/package.y(). @@ -3752,12 +3849,12 @@ Occurrences: [9:39..9:40): U -> flags/p/package.C#[U] [9:42..9:43): z <- flags/p/package.C#z. [9:45..9:46): V -> flags/p/package.C#[V] -[10:8..10:14): <- flags/p/package.C#``(+1). +[10:8..10:12): <- flags/p/package.C#``(+1). [10:22..10:22): -> flags/p/package.C#``(). [10:22..10:25): ??? -> scala/Predef.`???`(). [10:27..10:30): ??? -> scala/Predef.`???`(). [10:32..10:35): ??? -> scala/Predef.`???`(). -[11:8..11:14): <- flags/p/package.C#``(+2). +[11:8..11:12): <- flags/p/package.C#``(+2). [11:13..11:14): t <- flags/p/package.C#``(+2).(t) [11:16..11:17): T -> flags/p/package.C#[T] [11:26..11:26): -> flags/p/package.C#``(). @@ -4277,8 +4374,8 @@ Schema => SemanticDB v4 Uri => toplevel.scala Text => empty Language => Scala -Symbols => 18 entries -Occurrences => 42 entries +Symbols => 19 entries +Occurrences => 44 entries Symbols: _empty_/MyProgram# => final class MyProgram @@ -4298,10 +4395,10 @@ _empty_/toplevel$package.combine(+1).(y) => param y _empty_/toplevel$package.combine(+1).(z) => param z _empty_/toplevel$package.combine(+2). => method combine _empty_/toplevel$package.foo(). => method foo +_empty_/toplevel$package.fooRef(). => method fooRef local0 => val local error Occurrences: -[0:0..0:0): <- _empty_/toplevel$package. [0:11..0:12): a <- _empty_/toplevel$package.a. [1:11..1:12): x <- _empty_/toplevel$package.combine().(x) [1:14..1:17): Int -> scala/Int# @@ -4343,4 +4440,7 @@ Occurrences: [5:46..5:51): times -> _empty_/toplevel$package.MyProgram().(times) [5:53..5:60): foreach -> scala/collection/immutable/Range#foreach(). [5:67..5:74): println -> scala/Predef.println(+1). +[6:4..6:10): fooRef <- _empty_/toplevel$package.fooRef(). +[6:13..6:29): toplevel$package -> _empty_/toplevel$package. +[6:30..6:33): foo -> _empty_/toplevel$package.foo().