Skip to content

Commit 50a302c

Browse files
committed
Some smaller fixes
- Rename `selectionProto` to `shallowSelectionProto` for clarity. - Additional parameter for `tryExtensionOrConversion`
1 parent 009137f commit 50a302c

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import transform.SymUtils._
1616
import Contexts._
1717
import Names.{Name, TermName}
1818
import NameKinds.{InlineAccessorName, InlineBinderName, InlineScrutineeName, BodyRetainerName}
19-
import ProtoTypes.selectionProto
19+
import ProtoTypes.shallowSelectionProto
2020
import Annotations.Annotation
2121
import SymDenotations.SymDenotation
2222
import Inferencing.isFullyDefined
@@ -1240,7 +1240,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
12401240

12411241
override def typedSelect(tree: untpd.Select, pt: Type)(using Context): Tree = {
12421242
assert(tree.hasType, tree)
1243-
val qual1 = typed(tree.qualifier, selectionProto(tree.name, pt, this))
1243+
val qual1 = typed(tree.qualifier, shallowSelectionProto(tree.name, pt, this))
12441244
val resNoReduce = untpd.cpy.Select(tree)(qual1, tree.name).withType(tree.typeOpt)
12451245
val resMaybeReduced = constToLiteral(reducer.reduceProjection(resNoReduce))
12461246
if (resNoReduce ne resMaybeReduced)

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,11 @@ object ProtoTypes {
229229
/** Create a selection proto-type, but only one level deep;
230230
* treat constructors specially
231231
*/
232-
def selectionProto(name: Name, tp: Type, typer: Typer)(using Context): TermType =
232+
def shallowSelectionProto(name: Name, tp: Type, typer: Typer)(using Context): TermType =
233233
if (name.isConstructorName) WildcardType
234-
else tp match {
234+
else tp match
235235
case tp: UnapplyFunProto => new UnapplySelectionProto(name)
236236
case tp => SelectionProto(name, IgnoredProto(tp), typer, privateOK = true)
237-
}
238237

239238
/** A prototype for expressions [] that are in some unspecified selection operation
240239
*

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ class Typer extends Namer
579579
record("typedSelect")
580580

581581
def typeSelectOnTerm(using Context): Tree =
582-
typedSelect(tree, pt, typedExpr(tree.qualifier, selectionProto(tree.name, pt, this)))
582+
typedSelect(tree, pt, typedExpr(tree.qualifier, shallowSelectionProto(tree.name, pt, this)))
583583
.withSpan(tree.span)
584584
.computeNullable()
585585

@@ -596,7 +596,7 @@ class Typer extends Namer
596596
tryAlternatively(typeSelectOnTerm)(fallBack)
597597

598598
if (tree.qualifier.isType) {
599-
val qual1 = typedType(tree.qualifier, selectionProto(tree.name, pt, this))
599+
val qual1 = typedType(tree.qualifier, shallowSelectionProto(tree.name, pt, this))
600600
assignType(cpy.Select(tree)(qual1, tree.name), qual1)
601601
}
602602
else if (ctx.isJava && tree.name.isTypeName)
@@ -2901,7 +2901,7 @@ class Typer extends Namer
29012901
if selProto.isMatchedBy(qual.tpe) then None
29022902
else
29032903
tryEither {
2904-
val tree1 = tryExtensionOrConversion(tree, pt, qual, locked, NoViewsAllowed, privateOK = false)
2904+
val tree1 = tryExtensionOrConversion(tree, pt, pt, qual, locked, NoViewsAllowed, privateOK = false)
29052905
if tree1.isEmpty then None
29062906
else Some(adapt(tree1, pt, locked))
29072907
} { (_, _) => None
@@ -2912,12 +2912,13 @@ class Typer extends Namer
29122912

29132913
/** Given a selection `qual.name`, try to convert to an extension method
29142914
* application `name(qual)` or insert an implicit conversion `c(qual).name`.
2915+
* @return The converted tree, or `EmptyTree` is not successful.
29152916
*/
29162917
def tryExtensionOrConversion
2917-
(tree: untpd.Select, pt: Type, qual: Tree, locked: TypeVars, compat: Compatibility, privateOK: Boolean)
2918+
(tree: untpd.Select, pt: Type, mbrProto: Type, qual: Tree, locked: TypeVars, compat: Compatibility, privateOK: Boolean)
29182919
(using Context): Tree =
29192920

2920-
def selectionProto = SelectionProto(tree.name, pt, compat, privateOK)
2921+
def selectionProto = SelectionProto(tree.name, mbrProto, compat, privateOK)
29212922
// try an extension method in scope
29222923
try
29232924
val nestedCtx = ctx.fresh.setNewTyperState()
@@ -2950,7 +2951,7 @@ class Typer extends Namer
29502951
if failure.isAmbiguous then
29512952
return (
29522953
if canDefineFurther(qual.tpe.widen) then
2953-
tryExtensionOrConversion(tree, pt, qual, locked, compat, privateOK)
2954+
tryExtensionOrConversion(tree, pt, mbrProto, qual, locked, compat, privateOK)
29542955
else
29552956
err.typeMismatch(qual, selProto, failure.reason) // TODO: report NotAMember instead, but need to be aware of failure
29562957
)

0 commit comments

Comments
 (0)