Skip to content

Commit c64e676

Browse files
committed
Fix #8058: Fix isStableMember test
isStableMember classified NoSymbol as stable. This meant that an Application without a symbol was classified as pure in TreeInfo. This in turn meant that the application could be dropped and replaced with `Unit` at the end of a block. The (non-)pure application in the test was an array update.
1 parent 54ab00e commit c64e676

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ object SymDenotations {
727727
*/
728728
final def isStableMember(implicit ctx: Context): Boolean = {
729729
def isUnstableValue = isOneOf(UnstableValueFlags) || info.isInstanceOf[ExprType]
730-
isType || is(StableRealizable) || !isUnstableValue
730+
isType || is(StableRealizable) || exists && !isUnstableValue
731731
}
732732

733733
/** Is this a denotation of a class that does not have - either direct or inherited -

tests/run/i8058.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
extension on (x: Array[Char]):
2+
inline def swap(i: Int, j: Int) : Unit =
3+
val v = x(i)
4+
x(i) = x(j)
5+
x(j) = v
6+
7+
@main def Test =
8+
val a = Array('A','B')
9+
a.swap(0, 1)
10+
assert(a.toList == List('B', 'A'))

0 commit comments

Comments
 (0)