Skip to content

Commit 5b40951

Browse files
authored
Merge pull request #1634 from dotty-staging/change-tasty-pos-ctd
Towards correct positions in TASTY types
2 parents 601a286 + a2b1e60 commit 5b40951

37 files changed

+703
-497
lines changed

docs/syntax-summary.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ grammar.
160160
SimpleExpr1 ::= Literal
161161
| Path
162162
| `_'
163-
| `(' ExprsInParens `)' Parens(exprs)
163+
| `(' ExprsInParens2 `)' Parens(exprs)
164164
| SimpleExpr `.' id Select(expr, id)
165165
| SimpleExpr (TypeArgs | NamedTypeArgs) TypeApply(expr, args)
166166
| SimpleExpr1 ArgumentExprs Apply(expr, args)
@@ -210,7 +210,7 @@ grammar.
210210
| SimplePattern1 `.' id
211211
PatVar ::= varid
212212
| `_'
213-
Patterns ::= Pattern [`,' Pattern]
213+
Patterns ::= Pattern {`,' Pattern}
214214
ArgumentPatterns ::= `(' [Patterns] `)' Apply(fn, pats)
215215
| `(' [Patterns `,'] Pattern2 `:' `_' `*' ')
216216

src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
973973
}
974974

975975
object This extends ThisDeconstructor {
976-
def get = field.qual
976+
def get = field.qual.name
977977
def apply(s: Symbol): This = tpd.This(s.asClass)
978978
}
979979

@@ -1020,7 +1020,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
10201020
}
10211021
object Super extends SuperDeconstructor {
10221022
def _1: Tree = field.qual
1023-
def _2: Name = field.mix
1023+
def _2: Name = field.mix.name
10241024
}
10251025
object ArrayValue extends ArrayValueDeconstructor {
10261026
def _1: Type = field.tpe match {

src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ object desugar {
234234
if (tdef.mods is PrivateLocalParam) {
235235
val tparam = cpy.TypeDef(tdef)(name = tdef.name.expandedName(ctx.owner))
236236
.withMods(tdef.mods &~ PrivateLocal | ExpandedName)
237-
val alias = cpy.TypeDef(tdef)(rhs = refOfDef(tparam), tparams = Nil)
237+
val alias = cpy.TypeDef(tdef)(rhs = refOfDef(tparam))
238238
.withMods(tdef.mods & VarianceFlags | PrivateLocalParamAccessor | Synthetic)
239239
Thicket(tparam, alias)
240240
}
@@ -341,7 +341,7 @@ object desugar {
341341
val isDefinedMeth = syntheticProperty(nme.isDefined, Literal(Constant(true)))
342342
val caseParams = constrVparamss.head.toArray
343343
val productElemMeths = for (i <- 0 until arity) yield
344-
syntheticProperty(nme.selectorName(i), Select(This(EmptyTypeName), caseParams(i).name))
344+
syntheticProperty(nme.selectorName(i), Select(This(EmptyTypeIdent), caseParams(i).name))
345345
def isRepeated(tree: Tree): Boolean = tree match {
346346
case PostfixOp(_, nme.raw.STAR) => true
347347
case ByNameTypeTree(tree1) => isRepeated(tree1)
@@ -463,8 +463,7 @@ object desugar {
463463
cpy.TypeDef(cdef)(
464464
name = className,
465465
rhs = cpy.Template(impl)(constr, parents1, self1,
466-
tparamAccessors ::: vparamAccessors ::: normalizedBody ::: caseClassMeths),
467-
tparams = Nil)
466+
tparamAccessors ::: vparamAccessors ::: normalizedBody ::: caseClassMeths))
468467
}
469468

470469
// install the watch on classTycon

src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,12 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
272272
case mdef: ValOrDefDef =>
273273
mdef.unforcedRhs == EmptyTree && !mdef.name.isConstructorName && !mdef.mods.is(ParamAccessor)
274274
case mdef: TypeDef =>
275-
mdef.rhs.isEmpty || mdef.rhs.isInstanceOf[TypeBoundsTree]
275+
def isBounds(rhs: Tree): Boolean = rhs match {
276+
case _: TypeBoundsTree => true
277+
case PolyTypeTree(_, body) => isBounds(body)
278+
case _ => false
279+
}
280+
mdef.rhs.isEmpty || isBounds(mdef.rhs)
276281
case _ => false
277282
}
278283

@@ -382,9 +387,9 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
382387
def isIdempotentRef(tree: Tree)(implicit ctx: Context) =
383388
refPurity(tree) >= Idempotent
384389

385-
/** If `tree` is a constant expression, its value as a Literal,
390+
/** If `tree` is a constant expression, its value as a Literal,
386391
* or `tree` itself otherwise.
387-
*
392+
*
388393
* Note: Demanding idempotency instead of purity in literalize is strictly speaking too loose.
389394
* Example
390395
*
@@ -410,11 +415,11 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
410415
*
411416
* Revisit this issue once we have implemented `inline`. Then we can demand
412417
* purity of the prefix unless the selection goes to an inline val.
413-
*
418+
*
414419
* Note: This method should be applied to all term tree nodes that are not literals,
415420
* that can be idempotent, and that can have constant types. So far, only nodes
416-
* of the following classes qualify:
417-
*
421+
* of the following classes qualify:
422+
*
418423
* Ident
419424
* Select
420425
* TypeApply

src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ object Trees {
6060
with Cloneable {
6161

6262
if (Stats.enabled) ntrees += 1
63-
63+
6464
private def nxId = {
6565
nextId += 1
6666
//assert(nextId != 199, this)
67-
nextId
67+
nextId
6868
}
6969

7070
/** A unique identifier for this tree. Used for debugging, and potentially
7171
* tracking presentation compiler interactions
7272
*/
7373
private var myUniqueId: Int = nxId
74-
74+
7575
def uniqueId = myUniqueId
7676

7777
/** The type constructor at the root of the tree */
@@ -159,7 +159,7 @@ object Trees {
159159
/** Does this tree define a new symbol that is not defined elsewhere? */
160160
def isDef: Boolean = false
161161

162-
/** Is this tree either the empty tree or the empty ValDef? */
162+
/** Is this tree either the empty tree or the empty ValDef or an empty type ident? */
163163
def isEmpty: Boolean = false
164164

165165
/** Convert tree to a list. Gives a singleton list, except
@@ -192,7 +192,7 @@ object Trees {
192192

193193
override def hashCode(): Int = uniqueId // for debugging; was: System.identityHashCode(this)
194194
override def equals(that: Any) = this eq that.asInstanceOf[AnyRef]
195-
195+
196196
override def clone: Tree[T] = {
197197
val tree = super.clone.asInstanceOf[Tree[T]]
198198
tree.myUniqueId = nxId
@@ -353,7 +353,7 @@ object Trees {
353353
}
354354

355355
/** qual.this */
356-
case class This[-T >: Untyped] private[ast] (qual: TypeName)
356+
case class This[-T >: Untyped] private[ast] (qual: untpd.Ident)
357357
extends DenotingTree[T] with TermTree[T] {
358358
type ThisTree[-T >: Untyped] = This[T]
359359
// Denotation of a This tree is always the underlying class; needs correction for modules.
@@ -368,7 +368,7 @@ object Trees {
368368
}
369369

370370
/** C.super[mix], where qual = C.this */
371-
case class Super[-T >: Untyped] private[ast] (qual: Tree[T], mix: TypeName)
371+
case class Super[-T >: Untyped] private[ast] (qual: Tree[T], mix: untpd.Ident)
372372
extends ProxyTree[T] with TermTree[T] {
373373
type ThisTree[-T >: Untyped] = Super[T]
374374
def forwardTo = qual
@@ -653,12 +653,6 @@ object Trees {
653653

654654
/** Is this a definition of a class? */
655655
def isClassDef = rhs.isInstanceOf[Template[_]]
656-
657-
/** If this a non-class type definition, its type parameters.
658-
* Can be different from Nil only for PolyTypeDefs, which are always
659-
* untyped and get eliminated during desugaring.
660-
*/
661-
def tparams: List[untpd.TypeDef] = Nil
662656
}
663657

664658
/** extends parents { self => body } */
@@ -896,12 +890,12 @@ object Trees {
896890
case tree: Select if (qualifier eq tree.qualifier) && (name == tree.name) => tree
897891
case _ => finalize(tree, untpd.Select(qualifier, name))
898892
}
899-
def This(tree: Tree)(qual: TypeName): This = tree match {
900-
case tree: This if qual == tree.qual => tree
893+
def This(tree: Tree)(qual: untpd.Ident): This = tree match {
894+
case tree: This if qual eq tree.qual => tree
901895
case _ => finalize(tree, untpd.This(qual))
902896
}
903-
def Super(tree: Tree)(qual: Tree, mix: TypeName): Super = tree match {
904-
case tree: Super if (qual eq tree.qual) && (mix == tree.mix) => tree
897+
def Super(tree: Tree)(qual: Tree, mix: untpd.Ident): Super = tree match {
898+
case tree: Super if (qual eq tree.qual) && (mix eq tree.mix) => tree
905899
case _ => finalize(tree, untpd.Super(qual, mix))
906900
}
907901
def Apply(tree: Tree)(fun: Tree, args: List[Tree])(implicit ctx: Context): Apply = tree match {
@@ -1023,9 +1017,9 @@ object Trees {
10231017
case tree: DefDef if (name == tree.name) && (tparams eq tree.tparams) && (vparamss eq tree.vparamss) && (tpt eq tree.tpt) && (rhs eq tree.unforcedRhs) => tree
10241018
case _ => finalize(tree, untpd.DefDef(name, tparams, vparamss, tpt, rhs))
10251019
}
1026-
def TypeDef(tree: Tree)(name: TypeName, rhs: Tree, tparams: List[untpd.TypeDef]): TypeDef = tree match {
1027-
case tree: TypeDef if (name == tree.name) && (rhs eq tree.rhs) && (tparams eq tree.tparams) => tree
1028-
case _ => finalize(tree, untpd.TypeDef(name, tparams, rhs))
1020+
def TypeDef(tree: Tree)(name: TypeName, rhs: Tree): TypeDef = tree match {
1021+
case tree: TypeDef if (name == tree.name) && (rhs eq tree.rhs) => tree
1022+
case _ => finalize(tree, untpd.TypeDef(name, rhs))
10291023
}
10301024
def Template(tree: Tree)(constr: DefDef, parents: List[Tree], self: ValDef, body: LazyTreeList): Template = tree match {
10311025
case tree: Template if (constr eq tree.constr) && (parents eq tree.parents) && (self eq tree.self) && (body eq tree.unforcedBody) => tree
@@ -1064,8 +1058,8 @@ object Trees {
10641058
ValDef(tree: Tree)(name, tpt, rhs)
10651059
def DefDef(tree: DefDef)(name: TermName = tree.name, tparams: List[TypeDef] = tree.tparams, vparamss: List[List[ValDef]] = tree.vparamss, tpt: Tree = tree.tpt, rhs: LazyTree = tree.unforcedRhs): DefDef =
10661060
DefDef(tree: Tree)(name, tparams, vparamss, tpt, rhs)
1067-
def TypeDef(tree: TypeDef)(name: TypeName = tree.name, rhs: Tree = tree.rhs, tparams: List[untpd.TypeDef] = tree.tparams): TypeDef =
1068-
TypeDef(tree: Tree)(name, rhs, tparams)
1061+
def TypeDef(tree: TypeDef)(name: TypeName = tree.name, rhs: Tree = tree.rhs): TypeDef =
1062+
TypeDef(tree: Tree)(name, rhs)
10691063
def Template(tree: Template)(constr: DefDef = tree.constr, parents: List[Tree] = tree.parents, self: ValDef = tree.self, body: LazyTreeList = tree.unforcedBody): Template =
10701064
Template(tree: Tree)(constr, parents, self, body)
10711065
}
@@ -1146,7 +1140,7 @@ object Trees {
11461140
case tree @ DefDef(name, tparams, vparamss, tpt, _) =>
11471141
cpy.DefDef(tree)(name, transformSub(tparams), vparamss mapConserve (transformSub(_)), transform(tpt), transform(tree.rhs))
11481142
case tree @ TypeDef(name, rhs) =>
1149-
cpy.TypeDef(tree)(name, transform(rhs), tree.tparams)
1143+
cpy.TypeDef(tree)(name, transform(rhs))
11501144
case tree @ Template(constr, parents, self, _) =>
11511145
cpy.Template(tree)(transformSub(constr), transform(parents), transformSub(self), transformStats(tree.body))
11521146
case Import(expr, selectors) =>
@@ -1294,7 +1288,6 @@ object Trees {
12941288
case tree: Bind => cpy.Bind(tree)(newName, tree.body)
12951289
case tree: ValDef => cpy.ValDef(tree)(name = newName.asTermName)
12961290
case tree: DefDef => cpy.DefDef(tree)(name = newName.asTermName)
1297-
case tree: untpd.PolyTypeDef => untpd.cpy.PolyTypeDef(tree)(newName.asTypeName, tree.tparams, tree.rhs).withMods(tree.rawMods)
12981291
case tree: TypeDef => cpy.TypeDef(tree)(name = newName.asTypeName)
12991292
}
13001293
}.asInstanceOf[tree.ThisTree[T]]

src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
3131
untpd.Select(qualifier, tp.name).withType(tp)
3232

3333
def This(cls: ClassSymbol)(implicit ctx: Context): This =
34-
untpd.This(cls.name).withType(cls.thisType)
34+
untpd.This(untpd.Ident(cls.name)).withType(cls.thisType)
3535

36-
def Super(qual: Tree, mix: TypeName, inConstrCall: Boolean, mixinClass: Symbol = NoSymbol)(implicit ctx: Context): Super =
36+
def Super(qual: Tree, mix: untpd.Ident, inConstrCall: Boolean, mixinClass: Symbol)(implicit ctx: Context): Super =
3737
ta.assignType(untpd.Super(qual, mix), qual, inConstrCall, mixinClass)
3838

39+
def Super(qual: Tree, mixName: TypeName, inConstrCall: Boolean, mixinClass: Symbol = NoSymbol)(implicit ctx: Context): Super =
40+
Super(qual, if (mixName.isEmpty) untpd.EmptyTypeIdent else untpd.Ident(mixName), inConstrCall, mixinClass)
41+
3942
def Apply(fn: Tree, args: List[Tree])(implicit ctx: Context): Apply =
4043
ta.assignType(untpd.Apply(fn, args), fn, args)
4144

@@ -133,14 +136,18 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
133136
def OrTypeTree(left: Tree, right: Tree)(implicit ctx: Context): OrTypeTree =
134137
ta.assignType(untpd.OrTypeTree(left, right), left, right)
135138

136-
// RefinedTypeTree is missing, handled specially in Typer and Unpickler.
139+
def RefinedTypeTree(parent: Tree, refinements: List[Tree], refineCls: ClassSymbol)(implicit ctx: Context): Tree =
140+
ta.assignType(untpd.RefinedTypeTree(parent, refinements), parent, refinements, refineCls)
137141

138142
def AppliedTypeTree(tycon: Tree, args: List[Tree])(implicit ctx: Context): AppliedTypeTree =
139143
ta.assignType(untpd.AppliedTypeTree(tycon, args), tycon, args)
140144

141145
def ByNameTypeTree(result: Tree)(implicit ctx: Context): ByNameTypeTree =
142146
ta.assignType(untpd.ByNameTypeTree(result), result)
143147

148+
def PolyTypeTree(tparams: List[TypeDef], body: Tree)(implicit ctx: Context): PolyTypeTree =
149+
ta.assignType(untpd.PolyTypeTree(tparams, body), tparams, body)
150+
144151
def TypeBoundsTree(lo: Tree, hi: Tree)(implicit ctx: Context): TypeBoundsTree =
145152
ta.assignType(untpd.TypeBoundsTree(lo, hi), lo, hi)
146153

src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
8080
case class ContextBounds(bounds: TypeBoundsTree, cxBounds: List[Tree]) extends TypTree
8181
case class PatDef(mods: Modifiers, pats: List[Tree], tpt: Tree, rhs: Tree) extends DefTree
8282

83-
class PolyTypeDef(name: TypeName, override val tparams: List[TypeDef], rhs: Tree)
84-
extends TypeDef(name, rhs)
83+
@sharable object EmptyTypeIdent extends Ident(tpnme.EMPTY) with WithoutTypeOrPos[Untyped] {
84+
override def isEmpty = true
85+
}
8586

8687
/** A block arising from a right-associative infix operation, where, e.g.
8788
*
@@ -228,8 +229,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
228229
def BackquotedIdent(name: Name): BackquotedIdent = new BackquotedIdent(name)
229230
def Select(qualifier: Tree, name: Name): Select = new Select(qualifier, name)
230231
def SelectWithSig(qualifier: Tree, name: Name, sig: Signature): Select = new SelectWithSig(qualifier, name, sig)
231-
def This(qual: TypeName): This = new This(qual)
232-
def Super(qual: Tree, mix: TypeName): Super = new Super(qual, mix)
232+
def This(qual: Ident): This = new This(qual)
233+
def Super(qual: Tree, mix: Ident): Super = new Super(qual, mix)
233234
def Apply(fun: Tree, args: List[Tree]): Apply = new Apply(fun, args)
234235
def TypeApply(fun: Tree, args: List[Tree]): TypeApply = new TypeApply(fun, args)
235236
def Literal(const: Constant): Literal = new Literal(const)
@@ -310,9 +311,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
310311

311312
def TypeTree(tpe: Type)(implicit ctx: Context): TypedSplice = TypedSplice(TypeTree().withTypeUnchecked(tpe))
312313

313-
def TypeDef(name: TypeName, tparams: List[TypeDef], rhs: Tree): TypeDef =
314-
if (tparams.isEmpty) TypeDef(name, rhs) else new PolyTypeDef(name, tparams, rhs)
315-
316314
def unitLiteral = Literal(Constant(()))
317315

318316
def ref(tp: NamedType)(implicit ctx: Context): Tree =
@@ -348,6 +346,9 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
348346
def makeSyntheticParameter(n: Int = 1, tpt: Tree = TypeTree())(implicit ctx: Context): ValDef =
349347
ValDef(nme.syntheticParamName(n), tpt, EmptyTree).withFlags(SyntheticTermParam)
350348

349+
def lambdaAbstract(tparams: List[TypeDef], tpt: Tree)(implicit ctx: Context) =
350+
if (tparams.isEmpty) tpt else PolyTypeTree(tparams, tpt)
351+
351352
/** A reference to given definition. If definition is a repeated
352353
* parameter, the reference will be a repeated argument.
353354
*/
@@ -392,10 +393,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
392393
if (expr eq tree.expr) && (handler eq tree.handler) && (finalizer eq tree.finalizer) => tree
393394
case _ => untpd.ParsedTry(expr, handler, finalizer).withPos(tree.pos)
394395
}
395-
def PolyTypeDef(tree: Tree)(name: TypeName, tparams: List[TypeDef], rhs: Tree) = tree match {
396-
case tree: PolyTypeDef if (name eq tree.name) && (tparams eq tree.tparams) && (rhs eq tree.rhs) => tree
397-
case _ => new PolyTypeDef(name, tparams, rhs).withPos(tree.pos)
398-
}
399396
def SymbolLit(tree: Tree)(str: String) = tree match {
400397
case tree: SymbolLit if str == tree.str => tree
401398
case _ => untpd.SymbolLit(str).withPos(tree.pos)
@@ -506,8 +503,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
506503
cpy.ContextBounds(tree)(transformSub(bounds), transform(cxBounds))
507504
case PatDef(mods, pats, tpt, rhs) =>
508505
cpy.PatDef(tree)(mods, transform(pats), transform(tpt), transform(rhs))
509-
case tree: PolyTypeDef =>
510-
cpy.PolyTypeDef(tree)(tree.name, transformSub(tree.tparams), transform(tree.rhs))
511506
case _ =>
512507
super.transform(tree)
513508
}
@@ -553,8 +548,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
553548
this(this(x, bounds), cxBounds)
554549
case PatDef(mods, pats, tpt, rhs) =>
555550
this(this(this(x, pats), tpt), rhs)
556-
case tree: PolyTypeDef =>
557-
this(this(x, tree.tparams), tree.rhs)
558551
case TypedSplice(tree) =>
559552
this(x, tree)
560553
case _ =>
@@ -566,10 +559,4 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
566559
class UntypedDeepFolder[X](f: (X, Tree) => X) extends UntypedTreeAccumulator[X] {
567560
def apply(x: X, tree: Tree)(implicit ctx: Context): X = foldOver(f(x, tree), tree)
568561
}
569-
570-
override def rename(tree: NameTree, newName: Name)(implicit ctx: Context): tree.ThisTree[Untyped] = tree match {
571-
case t: PolyTypeDef =>
572-
cpy.PolyTypeDef(t)(newName.asTypeName, t.tparams, t.rhs).asInstanceOf[tree.ThisTree[Untyped]]
573-
case _ => super.rename(tree, newName)
574-
}
575562
}

src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -735,15 +735,11 @@ object StdNames {
735735
class ScalaTypeNames extends ScalaNames[TypeName] {
736736
protected implicit def fromString(s: String): TypeName = typeName(s)
737737

738-
def syntheticTypeParamName(i: Int): TypeName = "T" + i
739-
def syntheticLambdaParamName(i: Int): TypeName = "X" + i
738+
def syntheticTypeParamName(i: Int): TypeName = "X" + i
740739

741740
def syntheticTypeParamNames(num: Int): List[TypeName] =
742741
(0 until num).map(syntheticTypeParamName)(breakOut)
743742

744-
def syntheticLambdaParamNames(num: Int): List[TypeName] =
745-
(0 until num).map(syntheticLambdaParamName)(breakOut)
746-
747743
final val Conforms = encode("<:<")
748744

749745
final val Uninstantiated: TypeName = "?$"

src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,11 @@ class TypeApplications(val self: Type) extends AnyVal {
340340
def LambdaAbstract(tparams: List[TypeParamInfo])(implicit ctx: Context): Type = {
341341
def expand(tp: Type) =
342342
PolyType(
343-
tpnme.syntheticLambdaParamNames(tparams.length), tparams.map(_.paramVariance))(
343+
tparams.map(_.paramName), tparams.map(_.paramVariance))(
344344
tl => tparams.map(tparam => tl.lifted(tparams, tparam.paramBounds).bounds),
345345
tl => tl.lifted(tparams, tp))
346-
self match {
346+
if (tparams.isEmpty) self
347+
else self match {
347348
case self: TypeAlias =>
348349
self.derivedTypeAlias(expand(self.alias))
349350
case self @ TypeBounds(lo, hi) =>

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
12671267
original(tp1.appliedTo(tp1.typeParams.map(_.paramBoundsAsSeenFrom(tp1))), tp2)
12681268
else
12691269
PolyType(
1270-
paramNames = tpnme.syntheticLambdaParamNames(tparams1.length),
1270+
paramNames = tpnme.syntheticTypeParamNames(tparams1.length),
12711271
variances = (tparams1, tparams2).zipped.map((tparam1, tparam2) =>
12721272
(tparam1.paramVariance + tparam2.paramVariance) / 2))(
12731273
paramBoundsExp = tl => (tparams1, tparams2).zipped.map((tparam1, tparam2) =>

0 commit comments

Comments
 (0)