Skip to content

Commit e67908d

Browse files
Merge pull request #9221 from dotty-staging/fix-#9206
Fix #9206: Add missing type symbol in Scala2 constructors
2 parents 3a4f2ee + 3b9adbb commit e67908d

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ object SymDenotations {
380380
myParamss = pss
381381

382382
final def setParamss(tparams: List[Symbol], vparamss: List[List[Symbol]])(using Context): Unit =
383-
rawParamss = (if tparams.isEmpty then vparamss else tparams :: vparamss)
384-
.filterConserve(!_.isEmpty)
383+
rawParamss = (tparams :: vparamss).filterConserve(!_.isEmpty)
385384

386385
final def setParamssFromDefs(tparams: List[TypeDef[?]], vparamss: List[List[ValDef[?]]])(using Context): Unit =
387386
setParamss(tparams.map(_.symbol), vparamss.map(_.map(_.symbol)))

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,11 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
573573

574574
// println("reading type for " + denot) // !!! DEBUG
575575
val tp = at(inforef, () => readType()(ctx))
576-
if denot.is(Method) then denot.rawParamss = paramssOfType(tp)
576+
if denot.is(Method) then
577+
var params = paramssOfType(tp)
578+
if denot.isConstructor && denot.owner.typeParams.nonEmpty then
579+
params = denot.owner.typeParams :: params
580+
denot.rawParamss = params
577581

578582
denot match {
579583
case denot: ClassDenotation if !isRefinementClass(denot.symbol) =>

tests/run-macros/i9206/Macros_1.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
import scala.quoted.{Expr, QuoteContext}
3+
4+
object Inspect {
5+
inline def inspect[T <: AnyKind]: String = ${ inspectTpe[T] }
6+
7+
def inspectTpe[T <: AnyKind](using tpe: quoted.Type[T], qctx0: QuoteContext): Expr[String] = {
8+
val tree = summon[quoted.Type[T]].unseal.tpe.typeSymbol.tree
9+
Expr(tree.show)
10+
}
11+
}

tests/run-macros/i9206/Test_2.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Inspect._
2+
3+
object Test extends App {
4+
inspect[scala.collection.immutable.List[Int]]
5+
inspect[java.lang.String]
6+
inspect[String]
7+
inspect[List[Unit]]
8+
inspect[Some[Unit]]
9+
inspect[Tuple1[Unit]]
10+
}

0 commit comments

Comments
 (0)