Skip to content

Commit 9eecbd4

Browse files
committed
Fix stability check for inline parameters
Inline parameters are not stable. Two references to the same parameter may not be idempotent.
1 parent f92ab11 commit 9eecbd4

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ object SymDenotations {
739739
* So the first call to a stable member might fail and/or produce side effects.
740740
*/
741741
final def isStableMember(using Context): Boolean = {
742-
def isUnstableValue = isOneOf(UnstableValueFlags) || info.isInstanceOf[ExprType]
742+
def isUnstableValue = isOneOf(UnstableValueFlags) || info.isInstanceOf[ExprType] || isAllOf(InlineParam)
743743
isType || is(StableRealizable) || exists && !isUnstableValue
744744
}
745745

library/src/scala/quoted/Quotes.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import scala.reflect.TypeTest
1414
* }
1515
* ```
1616
*/
17-
transparent inline def quotes(using inline q: Quotes): q.type = q
17+
transparent inline def quotes(using inline q: Quotes): Quotes = q
1818

1919
/** Quotation context provided by a macro expansion or in the scope of `scala.quoted.staging.run`.
2020
* Used to perform all operations on quoted `Expr` or `Type`.

library/src/scala/runtime/stdLibPatches/Predef.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object Predef:
3131
* @tparam T the type of the value to be summoned
3232
* @return the given value typed: the provided type parameter
3333
*/
34-
transparent inline def summon[T](using inline x: T): x.type = x
34+
transparent inline def summon[T](using inline x: T): T = x
3535

3636
// Extension methods for working with explicit nulls
3737

scaladoc/src/dotty/tools/scaladoc/tasty/reflect.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ package tasty
44
import scala.quoted._
55

66
/** Shorthand for `quotes.reflect` */
7-
transparent inline def reflect(using inline q: Quotes): q.reflect.type = q.reflect
7+
transparent inline def reflect(using inline q: Quotes) = q.reflect
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
inline val a = 3
2+
inline def f(inline x: Int, y: Int, z: => Int): Unit =
3+
val x2: x.type = x // error: (x : Int) is not a valid singleton type, since it is not an immutable path
4+
val y2: y.type = y
5+
val z2: z.type = z // error: (z : Int) is not a valid singleton type, since it is not an immutable path
6+
val a2: a.type = a

0 commit comments

Comments
 (0)