Skip to content

Commit

Permalink
Make Any.$reach a method.
Browse files Browse the repository at this point in the history
For some reason, http4s in the CB fails compilation otherwise.
It's not clear what the failure has to do with the addition of
$reach to Any, but it goes away when $reach has Method flag.
  • Loading branch information
odersky committed Nov 14, 2023
1 parent 667b757 commit c37c9f9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
11 changes: 2 additions & 9 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,6 @@ class Definitions {
@tu lazy val Any_typeCast: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOfPM, _.paramRefs(0), Final | SyntheticArtifact | StableRealizable)
// generated by pattern matcher and explicit nulls, eliminated by erasure

@tu lazy val Any_ccReach =
newPermanentSymbol(AnyClass, nme.CC_REACH, Final | SyntheticArtifact | StableRealizable,
info = new LazyType:
def complete(denot: SymDenotation)(using Context): Unit =
denot.info = Caps_Cap.typeRef
).entered
// The internal representation of a reach capability `x*` is `x.$reach`.
// See doc comment in CaptureOps.reach for more info on reach capabilities

/** def getClass[A >: this.type](): Class[? <: A] */
@tu lazy val Any_getClass: TermSymbol =
enterPolyMethod(
Expand All @@ -321,6 +312,8 @@ class Definitions {
Final,
bounds = TypeBounds.lower(AnyClass.thisType))

@tu lazy val Any_ccReach = enterMethod(AnyClass, nme.CC_REACH, AnyType)

def AnyMethods: List[TermSymbol] = List(Any_==, Any_!=, Any_equals, Any_hashCode,
Any_toString, Any_##, Any_getClass, Any_isInstanceOf, Any_asInstanceOf, Any_typeTest,
Any_typeCast, Any_ccReach)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2910,8 +2910,8 @@ object Types {
((prefix eq NoPrefix)
|| symbol.is(ParamAccessor) && (prefix eq symbol.owner.thisType)
|| isRootCapability
|| isReach
) && !symbol.isOneOf(UnstableValueFlags)
|| isReach

override def isReach(using Context): Boolean =
name == nme.CC_REACH && symbol == defn.Any_ccReach
Expand Down
1 change: 1 addition & 0 deletions tests/run-macros/i6518.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
##
$asInstanceOf$
$isInstanceOf$
$reach
==
andThen
apply
Expand Down

0 comments on commit c37c9f9

Please sign in to comment.