Skip to content

Commit bdd9cfd

Browse files
committed
Fix typos and tweak booleans
1 parent 5d43d02 commit bdd9cfd

File tree

7 files changed

+41
-15
lines changed

7 files changed

+41
-15
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,11 +810,11 @@ object Contexts {
810810
final def addMode(mode: Mode): c.type = c.setMode(c.mode | mode)
811811
final def retractMode(mode: Mode): c.type = c.setMode(c.mode &~ mode)
812812

813-
/** Run `op` with a pool-allocated context that has an ExporeTyperState. */
813+
/** Run `op` with a pool-allocated context that has an ExploreTyperState. */
814814
inline def explore[T](inline op: Context ?=> T)(using Context): T =
815815
exploreInFreshCtx(op)
816816

817-
/** Run `op` with a pool-allocated FreshContext that has an ExporeTyperState. */
817+
/** Run `op` with a pool-allocated FreshContext that has an ExploreTyperState. */
818818
inline def exploreInFreshCtx[T](inline op: FreshContext ?=> T)(using Context): T =
819819
val pool = ctx.base.exploreContextPool
820820
val nestedCtx = pool.next()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2307,7 +2307,7 @@ object Types extends TypeUtils {
23072307

23082308
/** A trait for proto-types, used as expected types in typer */
23092309
trait ProtoType extends Type {
2310-
def isMatchedBy(tp: Type, keepConstraint: Boolean = false)(using Context): Boolean
2310+
def isMatchedBy(tp: Type, keepConstraint: Boolean)(using Context): Boolean
23112311
def fold[T](x: T, ta: TypeAccumulator[T])(using Context): T
23122312
def map(tm: TypeMap)(using Context): ProtoType
23132313

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ trait Implicits:
12211221

12221222
def tryConversionForSelection(using Context) =
12231223
val converted = tryConversion
1224-
if !ctx.reporter.hasErrors && !selProto.isMatchedBy(converted.tpe) then
1224+
if !ctx.reporter.hasErrors && !selProto.isMatchedBy(converted.tpe, keepConstraint = false) then
12251225
// this check is needed since adapting relative to a `SelectionProto` can succeed
12261226
// even if the term is not a subtype of the `SelectionProto`
12271227
err.typeMismatch(converted, selProto)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ trait ImportSuggestions:
185185
// To regain precision, test both sides separately.
186186
test(ViewProto(argType, rt1)) || test(ViewProto(argType, rt2))
187187
case pt: ViewProto =>
188-
pt.isMatchedBy(ref)
188+
pt.isMatchedBy(ref, keepConstraint = false)
189189
case _ =>
190190
normalize(ref, pt) <:< pt
191191
test(pt)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ object ProtoTypes {
133133

134134
constFoldException(pt) || {
135135
if Inlines.isInlineable(meth) then
136-
// Stricter behavisour in 3.4+: do not apply `wildApprox` to non-transparent inlines
136+
// Stricter behaviour in 3.4+: do not apply `wildApprox` to non-transparent inlines
137137
// unless their return type is a MatchType. In this case there's no reason
138138
// not to constrain type variables in the expected type. For transparent inlines
139139
// we do not want to constrain type variables in the expected type since the

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4148,7 +4148,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
41484148
Some(adapt(tree, pt, locked))
41494149
else
41504150
val selProto = SelectionProto(name, pt, NoViewsAllowed, privateOK = false, tree.nameSpan)
4151-
if selProto.isMatchedBy(qual.tpe) || tree.hasAttachment(InsertedImplicitOnQualifier) then
4151+
if selProto.isMatchedBy(qual.tpe, keepConstraint = false) || tree.hasAttachment(InsertedImplicitOnQualifier)
4152+
then
41524153
None
41534154
else
41544155
tryEither {
@@ -4465,7 +4466,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
44654466
arg.tpe match
44664467
case failed: SearchFailureType if canProfitFromMoreConstraints =>
44674468
val pt1 = pt.deepenProtoTrans
4468-
if (pt1 `ne` pt) && (pt1 ne sharpenedPt) && tryConstrainResult(pt1) then
4469+
if (pt1 ne pt) && (pt1 ne sharpenedPt) && tryConstrainResult(pt1) then
44694470
return implicitArgs(formals, argIndex, pt1)
44704471
case _ =>
44714472

@@ -4579,13 +4580,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
45794580
// Reset context in case it was set to a supercall context before.
45804581
// otherwise the invariant for taking another this or super call context is not met.
45814582
// Test case is i20483.scala
4582-
tree match
4583-
case tree: Block =>
4584-
readaptSimplified(tpd.Block(tree.stats, tpd.Apply(tree.expr, args)))
4585-
case tree: NamedArg =>
4586-
readaptSimplified(tpd.NamedArg(tree.name, tpd.Apply(tree.arg, args)))
4587-
case _ =>
4588-
readaptSimplified(tpd.Apply(tree, args))
4583+
val cpy = tree match
4584+
case tree: Block => tpd.Block(tree.stats, tpd.Apply(tree.expr, args))
4585+
case tree: NamedArg => tpd.NamedArg(tree.name, tpd.Apply(tree.arg, args))
4586+
case _ => tpd.Apply(tree, args)
4587+
readaptSimplified(cpy)
45894588
end addImplicitArgs
45904589

45914590
pt.revealIgnored match {

tests/pos/i24192.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import scala.language.implicitConversions
2+
3+
// https://github.com/scala/scala-collection-contrib/blob/main/src/main/scala/scala/collection/decorators/package.scala
4+
object decorators {
5+
trait IsMap[A]
6+
implicit def mapDecorator[C](coll: C)(implicit map: IsMap[C]): Map[C, map.type] = ???
7+
}
8+
import decorators.mapDecorator // unused, required to reproduce
9+
10+
trait Eq[T]
11+
trait Applicative[F[_]]
12+
given Applicative[Option] = ???
13+
14+
trait Traverse[F[_]]:
15+
// context bound required to reproduce
16+
def sequence[G[_]: Applicative, A](fga: F[G[A]]): G[F[A]] = ???
17+
18+
object Traverse:
19+
def apply[F[_]]: Traverse[F] = ???
20+
21+
trait Segment[Element: Eq]
22+
23+
case class MergeResult[Element: Eq] private (segments: Seq[Segment[Element]]):
24+
def thisFailsToCompile(): Option[MergeResult[Element]] =
25+
Traverse[Seq]
26+
.sequence(Seq.empty[Option[Segment[Element]]])
27+
.map(MergeResult.apply) // no error

0 commit comments

Comments
 (0)