Skip to content

Commit 2fcae59

Browse files
committed
Address review coments
1 parent dd6495d commit 2fcae59

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
545545
def hasConflictingTypeVarsFor(tl: TypeLambda) =
546546
this.typeVarOfParam(tl.paramRefs(0)) ne c.typeVarOfParam(tl.paramRefs(0))
547547
// Note: Since TypeVars are allocated in bulk for each type lambda, we only
548-
// have to check the first one to find out if some of them are dufferent.
548+
// have to check the first one to find out if some of them are different.
549549
val conflicting = c.domainLambdas.find(tl =>
550550
this.contains(tl) && hasConflictingTypeVarsFor(tl))
551551
conflicting match {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class TyperState(private val previous: TyperState /* | Null */) {
145145
def commit()(implicit ctx: Context): Unit = {
146146
Stats.record("typerState.commit")
147147
val targetState = ctx.typerState
148-
if (constraint ne targetState.constraint)
148+
if (constraint ne targetState.constraint)
149149
constr.println(i"committing $this to $targetState, fromConstr = $constraint, toConstr = ${targetState.constraint}")
150150
assert(isCommittable)
151151
if (targetState.constraint eq previousConstraint) targetState.constraint = constraint

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
579579
case Splice(tree) =>
580580
keywordStr("${") ~ toTextGlobal(dropBlock(tree)) ~ keywordStr("}")
581581
case tree: Applications.IntegratedTypeArgs =>
582-
toText(tree.app) ~ "(with integrated type args)"
582+
toText(tree.app) ~ Str("(with integrated type args)").provided(ctx.settings.YprintDebug.value)
583583
case Thicket(trees) =>
584584
"Thicket {" ~~ toTextGlobal(trees, "\n") ~~ "}"
585585
case _ =>

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ object Applications {
188188

189189
/** A wrapper indicating that its `app` argument has already integrated the type arguments
190190
* of the expected type, provided that type is a (possibly ignored) PolyProto.
191+
* I.e., if the expected type is a PolyProto, then `app` will be a `TypeApply(_, args)` where
192+
* `args` are the type arguments of the expected type.
191193
*/
192194
class IntegratedTypeArgs(val app: Tree)(implicit @constructorOnly src: SourceFile) extends tpd.Tree {
193195
override def span = app.span

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2233,8 +2233,11 @@ class Typer extends Namer
22332233
}
22342234

22352235
/** Try to rename `tpt` to a type `T` and typecheck `new T` with given expected type `pt`.
2236+
* The operation is called from either `adapt` or `typedApply`. `adapt` gets to call `tryNew`
2237+
* for calls `p.C(..)` if there is a value `p.C`. `typedApply` calls `tryNew` as a fallback
2238+
* in case typing `p.C` fails since there is no value with path `p.C`. The call from `adapt`
2239+
* is more efficient since it re-uses the prefix `p` in typed form.
22362240
*/
2237-
22382241
def tryNew[T >: Untyped <: Type]
22392242
(treesInst: Instance[T])(tree: Trees.Tree[T], pt: Type, fallBack: => Tree)(implicit ctx: Context): Tree = {
22402243

@@ -2246,6 +2249,8 @@ class Typer extends Namer
22462249
else {
22472250
def recur(tpt: Tree, pt: Type): Tree = pt.revealIgnored match {
22482251
case PolyProto(targs, pt1) if !targs.exists(_.isInstanceOf[NamedArg]) =>
2252+
// Applications with named arguments cannot be converted, since new expressions
2253+
// don't accept named arguments
22492254
IntegratedTypeArgs(recur(AppliedTypeTree(tpt, targs), pt1))
22502255
case _ =>
22512256
typed(untpd.Select(untpd.New(untpd.TypedSplice(tpt)), nme.CONSTRUCTOR), pt)

0 commit comments

Comments
 (0)