Skip to content

Commit ab279ab

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 7d6d42f commit ab279ab

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

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

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

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 q: Quotes): q.type = 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/TastyParser.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ case class ScaladocTastyInspector()(using ctx: DocContext) extends DocTastyInspe
3131

3232
def processCompilationUnit(using Quotes)(root: reflect.Tree): Unit = ()
3333

34-
override def postProcess(using Quotes): Unit =
34+
override def postProcess(using q: Quotes): Unit =
3535
// hack into the compiler to get a list of all top-level trees
3636
// in principle, to do this, one would collect trees in processCompilationUnit
3737
// however, path-dependent types disallow doing so w/o using casts

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 q: Quotes): q.reflect.type = 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)