Skip to content

Fix #9206: Add missing type symbol in Scala2 constructors #9221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ object SymDenotations {
myParamss = pss

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

final def setParamssFromDefs(tparams: List[TypeDef[?]], vparamss: List[List[ValDef[?]]])(using Context): Unit =
setParamss(tparams.map(_.symbol), vparamss.map(_.map(_.symbol)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,11 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas

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

denot match {
case denot: ClassDenotation if !isRefinementClass(denot.symbol) =>
Expand Down
11 changes: 11 additions & 0 deletions tests/run-macros/i9206/Macros_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

import scala.quoted.{Expr, QuoteContext}

object Inspect {
inline def inspect[T <: AnyKind]: String = ${ inspectTpe[T] }

def inspectTpe[T <: AnyKind](using tpe: quoted.Type[T], qctx0: QuoteContext): Expr[String] = {
val tree = summon[quoted.Type[T]].unseal.tpe.typeSymbol.tree
Expr(tree.show)
}
}
10 changes: 10 additions & 0 deletions tests/run-macros/i9206/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Inspect._

object Test extends App {
inspect[scala.collection.immutable.List[Int]]
inspect[java.lang.String]
inspect[String]
inspect[List[Unit]]
inspect[Some[Unit]]
inspect[Tuple1[Unit]]
}