Skip to content

Commit b31e865

Browse files
committed
Fix typos and tweak booleans
1 parent 2953eab commit b31e865

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
@@ -2312,7 +2312,7 @@ object Types extends TypeUtils {
23122312

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

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

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

12081208
def tryConversionForSelection(using Context) =
12091209
val converted = tryConversion
1210-
if !ctx.reporter.hasErrors && !selProto.isMatchedBy(converted.tpe) then
1210+
if !ctx.reporter.hasErrors && !selProto.isMatchedBy(converted.tpe, keepConstraint = false) then
12111211
// this check is needed since adapting relative to a `SelectionProto` can succeed
12121212
// even if the term is not a subtype of the `SelectionProto`
12131213
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
@@ -4174,7 +4174,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
41744174
Some(adapt(tree, pt, locked))
41754175
else
41764176
val selProto = SelectionProto(name, pt, NoViewsAllowed, privateOK = false, tree.nameSpan)
4177-
if selProto.isMatchedBy(qual.tpe) || tree.hasAttachment(InsertedImplicitOnQualifier) then
4177+
if selProto.isMatchedBy(qual.tpe, keepConstraint = false) || tree.hasAttachment(InsertedImplicitOnQualifier)
4178+
then
41784179
None
41794180
else
41804181
tryEither {
@@ -4491,7 +4492,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
44914492
arg.tpe match
44924493
case failed: SearchFailureType if canProfitFromMoreConstraints =>
44934494
val pt1 = pt.deepenProtoTrans
4494-
if (pt1 `ne` pt) && (pt1 ne sharpenedPt) && tryConstrainResult(pt1) then
4495+
if (pt1 ne pt) && (pt1 ne sharpenedPt) && tryConstrainResult(pt1) then
44954496
return implicitArgs(formals, argIndex, pt1)
44964497
case _ =>
44974498

@@ -4605,13 +4606,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
46054606
// Reset context in case it was set to a supercall context before.
46064607
// otherwise the invariant for taking another this or super call context is not met.
46074608
// Test case is i20483.scala
4608-
tree match
4609-
case tree: Block =>
4610-
readaptSimplified(tpd.Block(tree.stats, tpd.Apply(tree.expr, args)))
4611-
case tree: NamedArg =>
4612-
readaptSimplified(tpd.NamedArg(tree.name, tpd.Apply(tree.arg, args)))
4613-
case _ =>
4614-
readaptSimplified(tpd.Apply(tree, args))
4609+
val cpy = tree match
4610+
case tree: Block => tpd.Block(tree.stats, tpd.Apply(tree.expr, args))
4611+
case tree: NamedArg => tpd.NamedArg(tree.name, tpd.Apply(tree.arg, args))
4612+
case _ => tpd.Apply(tree, args)
4613+
readaptSimplified(cpy)
46154614
end addImplicitArgs
46164615

46174616
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)