Skip to content

Commit 1bc9004

Browse files
author
builduser
committed
Merged branch idea243.release into idea243.x
2 parents 4a24329 + 3add445 commit 1bc9004

File tree

2 files changed

+175
-3
lines changed

2 files changed

+175
-3
lines changed

scala/debugger/src/org/jetbrains/plugins/scala/debugger/ScalaPositionManager.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class ScalaPositionManager(val debugProcess: DebugProcess) extends PositionManag
135135
val qName = getSpecificNameForDebugger(td)
136136
val additional = td match {
137137
case _: ScTrait =>
138-
qName.stripSuffix(TraitImplementationClassSuffix_211) :: Nil
138+
qName :: Nil
139139
case c: ScClass if ValueClassType.isValueClass(c) =>
140140
s"$qName$$" :: Nil
141141
case c if isDelayedInit(c) =>
@@ -909,7 +909,6 @@ object ScalaPositionManager {
909909

910910
td match {
911911
case _: ScObject => name + "$"
912-
case _: ScTrait => name + TraitImplementationClassSuffix_211 //is valid only before scala 2.12
913912
case _ => name
914913
}
915914
}
@@ -1063,7 +1062,7 @@ object ScalaPositionManager {
10631062
val name = refType.name()
10641063

10651064
exactName match {
1066-
case Some(qName) => qName == name || qName.stripSuffix(TraitImplementationClassSuffix_211) == name
1065+
case Some(qName) => qName == name
10671066
case None => checkParts(name)
10681067
}
10691068
}

scala/debugger/test/org/jetbrains/plugins/scala/debugger/breakpoints/LambdaBreakpointsTest.scala

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,28 @@ class LambdaBreakpointsTest_2_12 extends LambdaBreakpointsTestBase {
8080
(4, "$anonfun$doubleIt$extension$1")
8181
)
8282
}
83+
84+
override def testLambdaBreakpointsInsideTrait(): Unit = {
85+
breakpointsTest()(
86+
(22, "$anonfun$fooFromTrait$1"), (23, "$anonfun$fooFromTrait$1"), (22, "$anonfun$fooFromTrait$1"), (23, "$anonfun$fooFromTrait$1"), (25, "fooFromTrait"),
87+
(33, "$anonfun$fooFromAbstractClass$1"), (34, "$anonfun$fooFromAbstractClass$1"), (33, "$anonfun$fooFromAbstractClass$1"), (34, "$anonfun$fooFromAbstractClass$1"), (36, "fooFromAbstractClass"),
88+
(11, "$anonfun$fooFromMain$1"), (12, "$anonfun$fooFromMain$1"), (11, "$anonfun$fooFromMain$1"), (12, "$anonfun$fooFromMain$1"), (14, "fooFromMain"),
89+
)
90+
}
91+
92+
override def testOneLineLambdaInTrait(): Unit = {
93+
breakpointsTest()(
94+
(4, "$anonfun$fooInTrait$1"), (4, "$anonfun$fooInTrait$1"), (5, "fooInTrait")
95+
)
96+
}
97+
98+
override def testLineInLambdaWithLambdaOnLineInTrait(): Unit = {
99+
breakpointsTest()(
100+
(5, "$anonfun$fooInTrait$1"), (6, "$anonfun$fooInTrait$1"), (6, "$anonfun$fooInTrait$2"),
101+
(5, "$anonfun$fooInTrait$1"), (6, "$anonfun$fooInTrait$1"), (6, "$anonfun$fooInTrait$2"),
102+
(8, "fooInTrait")
103+
)
104+
}
83105
}
84106

85107
class LambdaBreakpointsTest_2_13 extends LambdaBreakpointsTest_2_12 {
@@ -242,6 +264,28 @@ class LambdaBreakpointsTest_3_3 extends LambdaBreakpointsTestBase {
242264
(4, "ByNameInExtensionMethod$IntOpt$$$_$doubleIt$extension$$anonfun$1")
243265
)
244266
}
267+
268+
override def testLambdaBreakpointsInsideTrait(): Unit = {
269+
breakpointsTest()(
270+
(22, "$anonfun$2"), (23, "$anonfun$2"), (22, "$anonfun$2"), (23, "$anonfun$2"), (25, "fooFromTrait"),
271+
(33, "$anonfun$3"), (34, "$anonfun$3"), (33, "$anonfun$3"), (34, "$anonfun$3"), (36, "fooFromAbstractClass"),
272+
(11, "$anonfun$1"), (12, "$anonfun$1"), (11, "$anonfun$1"), (12, "$anonfun$1"), (14, "fooFromMain"),
273+
)
274+
}
275+
276+
override def testOneLineLambdaInTrait(): Unit = {
277+
breakpointsTest()(
278+
(4, "$anonfun$1"), (4, "$anonfun$1"), (5, "fooInTrait")
279+
)
280+
}
281+
282+
override def testLineInLambdaWithLambdaOnLineInTrait(): Unit = {
283+
breakpointsTest()(
284+
(5, "$anonfun$1"), (6, "$anonfun$1"), (6, "$anonfun$1$$anonfun$1"),
285+
(5, "$anonfun$1"), (6, "$anonfun$1"), (6, "$anonfun$1$$anonfun$1"),
286+
(8, "fooInTrait")
287+
)
288+
}
245289
}
246290

247291
class LambdaBreakpointsTest_3_4 extends LambdaBreakpointsTest_3_3 {
@@ -312,6 +356,34 @@ class LambdaBreakpointsTest_3_4 extends LambdaBreakpointsTest_3_3 {
312356
(20, "main"), (20, "main$$anonfun$9")
313357
)
314358
}
359+
360+
override def testLambdaBreakpointsInsideTrait(): Unit = {
361+
breakpointsTest()(
362+
(23, "fooFromTrait"),
363+
(22, "$anonfun$2"), (23, "$anonfun$2"), (22, "$anonfun$2"), (23, "$anonfun$2"), (25, "fooFromTrait"),
364+
(34, "fooFromAbstractClass"),
365+
(33, "$anonfun$3"), (34, "$anonfun$3"), (33, "$anonfun$3"), (34, "$anonfun$3"), (36, "fooFromAbstractClass"),
366+
(12, "fooFromMain"),
367+
(11, "$anonfun$1"), (12, "$anonfun$1"), (11, "$anonfun$1"), (12, "$anonfun$1"), (14, "fooFromMain"),
368+
)
369+
}
370+
371+
override def testLineInLambdaWithLambdaOnLineInTrait(): Unit = {
372+
breakpointsTest()(
373+
(6, "fooInTrait"),
374+
(5, "$anonfun$1"), (6, "$anonfun$1"), (6, "$anonfun$1$$anonfun$1"),
375+
(5, "$anonfun$1"), (6, "$anonfun$1"), (6, "$anonfun$1$$anonfun$1"),
376+
(8, "fooInTrait")
377+
)
378+
}
379+
}
380+
381+
class LambdaBreakpointsTest_3_5 extends LambdaBreakpointsTest_3_3 {
382+
override protected def supportedIn(version: ScalaVersion): Boolean = version == ScalaVersion.Latest.Scala_3_5
383+
}
384+
385+
class LambdaBreakpointsTest_3_6 extends LambdaBreakpointsTest_3_3 {
386+
override protected def supportedIn(version: ScalaVersion): Boolean = version == ScalaVersion.Latest.Scala_3_6
315387
}
316388

317389
class LambdaBreakpointsTest_3_RC extends LambdaBreakpointsTest_3_3 {
@@ -618,5 +690,106 @@ abstract class LambdaBreakpointsTestBase extends ScalaDebuggerTestCase {
618690
(4, "apply$mcI$sp")
619691
)
620692
}
693+
694+
addSourceFile("LambdaBreakpointsInsideTrait.scala",
695+
s"""
696+
|object LambdaBreakpointsInsideTrait extends MyAbstractClass with MyTrait {
697+
| def main(args: Array[String]): Unit = {
698+
| fooFromTrait()
699+
| fooFromAbstractClass()
700+
| fooFromMain()
701+
| }
702+
|
703+
| def fooFromMain(): Unit = {
704+
| val seq = 1 to 2
705+
| val seqNew = seq.map { item =>
706+
| val x = 1 + 1 $breakpoint
707+
| item + x $breakpoint
708+
| }
709+
| println(seqNew) $breakpoint
710+
| }
711+
|}
712+
|
713+
|trait MyTrait {
714+
| def fooFromTrait(): Unit = {
715+
| val seq = 1 to 2
716+
| val seqNew = seq.map { item =>
717+
| val x = 1 + 1 $breakpoint
718+
| item + x $breakpoint
719+
| }
720+
| println(seqNew) $breakpoint
721+
| }
722+
|}
723+
|
724+
|abstract class MyAbstractClass {
725+
| def fooFromAbstractClass(): Unit = {
726+
| val seq = 1 to 2
727+
| val seqNew = seq.map { item =>
728+
| val x = 1 + 1 $breakpoint
729+
| item + x $breakpoint
730+
| }
731+
| println(seqNew) $breakpoint
732+
| }
733+
|}
734+
|""".stripMargin)
735+
736+
def testLambdaBreakpointsInsideTrait(): Unit = {
737+
breakpointsTest()(
738+
(22, "apply$mcII$sp"), (23, "apply$mcII$sp"), (22, "apply$mcII$sp"), (23, "apply$mcII$sp"), (25, "fooFromTrait"),
739+
(33, "apply$mcII$sp"), (34, "apply$mcII$sp"), (33, "apply$mcII$sp"), (34, "apply$mcII$sp"), (36, "fooFromAbstractClass"),
740+
(11, "apply$mcII$sp"), (12, "apply$mcII$sp"), (11, "apply$mcII$sp"), (12, "apply$mcII$sp"), (14, "fooFromMain"),
741+
)
742+
}
743+
744+
addSourceFile("OneLineLambdaInTrait.scala",
745+
s"""
746+
|trait MyTraitWithOneLineLambda {
747+
| def fooInTrait(): Unit = {
748+
| val seq = 1 to 2
749+
| val seqNew = seq.map(_ + 2) $breakpoint ${lambdaOrdinal(0)}
750+
| println(seqNew) $breakpoint
751+
| }
752+
|}
753+
|
754+
|object OneLineLambdaInTrait extends MyTraitWithOneLineLambda {
755+
| def main(args: Array[String]): Unit = {
756+
| fooInTrait()
757+
| }
758+
|}
759+
|""".stripMargin)
760+
761+
def testOneLineLambdaInTrait(): Unit = {
762+
breakpointsTest()(
763+
(4, "apply$mcII$sp"), (4, "apply$mcII$sp"), (5, "fooInTrait")
764+
)
765+
}
766+
767+
addSourceFile("LineInLambdaWithLambdaOnLineInTrait.scala",
768+
s"""
769+
|trait MyTraitWithLambdaWithLambdaOnLine {
770+
| def fooInTrait(): Unit = {
771+
| val seq = 1 to 2
772+
| val seqNew = seq.flatMap { item =>
773+
| val x = 1 + 1 $breakpoint
774+
| Seq(item).map(_ + x) $breakpoint
775+
| }
776+
| println(seqNew) $breakpoint
777+
| }
778+
|}
779+
|
780+
|object LineInLambdaWithLambdaOnLineInTrait extends MyTraitWithLambdaWithLambdaOnLine {
781+
| def main(args: Array[String]): Unit = {
782+
| fooInTrait()
783+
| }
784+
|}
785+
|""".stripMargin)
786+
787+
def testLineInLambdaWithLambdaOnLineInTrait(): Unit = {
788+
breakpointsTest()(
789+
(5, "apply"), (6, "apply"), (6, "apply$mcII$sp"),
790+
(5, "apply"), (6, "apply"), (6, "apply$mcII$sp"),
791+
(8, "fooInTrait")
792+
)
793+
}
621794
}
622795

0 commit comments

Comments
 (0)