File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1238,7 +1238,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
12381238 * how class parents are handled in Namer.
12391239 */
12401240 def typedNewTemplateParent (tree : untpd.Tree , pt : Type )(using Context ): Tree =
1241- // First type with AnyTypeConstructorProto to check if it's a HKTypeLambda
1241+ // Type with AnyTypeConstructorProto to detect type aliases ( HKTypeLambda)
12421242 val parentTpt = typedType(tree, AnyTypeConstructorProto )
12431243 val ptpe = parentTpt.tpe.dealias
12441244
@@ -1254,7 +1254,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
12541254 val typedApp = typedExpr(app, pt)
12551255 TypeTree (typedApp.tpe).withSpan(tree.span)
12561256 case _ =>
1257- inferTypeParams(typedType(tree), pt)
1257+ // For regular class/trait references, reuse the typed tree.
1258+ // If type has params but isn't a TypeLambda, eta-expand for inferTypeParams.
1259+ val resultTpe = parentTpt.tpe
1260+ if resultTpe.typeParams.nonEmpty && ! resultTpe.isInstanceOf [TypeLambda ] then
1261+ inferTypeParams(parentTpt.withType(resultTpe.etaExpand), pt)
1262+ else
1263+ inferTypeParams(parentTpt, pt)
12581264
12591265 def typedNew (tree : untpd.New , pt : Type )(using Context ): Tree =
12601266 tree.tpt match {
You can’t perform that action at this time.
0 commit comments