Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't search implicit arguments in singleton type prefix #16490

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ object ProtoTypes {
*/
@sharable object AnySelectionProto extends SelectionProto(nme.WILDCARD, WildcardType, NoViewsAllowed, true)

@sharable object SingletonTypeProto extends SelectionProto(nme.WILDCARD, WildcardType, NoViewsAllowed, true)

/** A prototype for selections in pattern constructors */
class UnapplySelectionProto(name: Name) extends SelectionProto(name, WildcardType, NoViewsAllowed, true)

Expand Down
20 changes: 10 additions & 10 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
completeTypeTree(InferredTypeTree(), pt, tree)

def typedSingletonTypeTree(tree: untpd.SingletonTypeTree)(using Context): SingletonTypeTree = {
val ref1 = typedExpr(tree.ref)
val ref1 = typedExpr(tree.ref, SingletonTypeProto)
checkStable(ref1.tpe, tree.srcPos, "singleton type")
assignType(cpy.SingletonTypeTree(tree)(ref1), ref1)
}
Expand Down Expand Up @@ -3773,20 +3773,20 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
true
}

if ((implicitFun || caseCompanion) &&
!isApplyProto(pt) &&
pt != AssignProto &&
!ctx.mode.is(Mode.Pattern) &&
!ctx.isAfterTyper &&
!ctx.isInlineContext) {
if (implicitFun || caseCompanion)
&& !isApplyProto(pt)
&& pt != SingletonTypeProto
&& pt != AssignProto
&& !ctx.mode.is(Mode.Pattern)
&& !ctx.isAfterTyper
&& !ctx.isInlineContext
then
typr.println(i"insert apply on implicit $tree")
val sel = untpd.Select(untpd.TypedSplice(tree), nme.apply).withAttachment(InsertedApply, ())
try typed(sel, pt, locked) finally sel.removeAttachment(InsertedApply)
}
else if (ctx.mode is Mode.Pattern) {
else if ctx.mode is Mode.Pattern then
checkEqualityEvidence(tree, pt)
tree
}
else
val meth = methPart(tree).symbol
if meth.isAllOf(DeferredInline) && !Inlines.inInlineMethod then
Expand Down
4 changes: 4 additions & 0 deletions tests/pos/i16488.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
trait Ctx
val f: Ctx ?=> Int = ???
type Tpe = f.type